%define pkg_version 0.7.3
%define pkg_release 3%{?_dist_release}

Summary:       IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Name:          hostapd
Version:       %{pkg_version}
Release:       %{pkg_release}
Source0:       %{name}-%{version}.tar.gz
Source1:       %{name}-init.sh
Source2:       %{name}-%{version}.config
Patch0:        %{name}-%{version}.patch
License:       GPL2
Group:         System Environment/Daemons
URL:           http://hostap.epitest.fi/hostapd/

Requires:      openssl, libnl >= 1.1
Requires(post): chkconfig
Requires(preun): chkconfig
BuildRequires: openssl-devel, libnl-devel
BuildRoot:     %{_tmppath}/%{name}-%{version}-root

Vendor:        Project Vine
Distribution:  Vine Linux
Packager:      miyabi

%description
hostapd is a user space daemon for access point and authentication servers. It implements IEEE 802.11 access point management,
IEEE 802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server.
The current version supports Linux (Host AP, madwifi, mac80211-based drivers) and FreeBSD (net80211).

%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
cp %{SOURCE1} .
cp %{SOURCE2} ./%{name}/.config

%build
cd %{name}
%{__make}

%install
[ "${RPM_BUILD_ROOT}" != "/" ] && %{__rm} -rf ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}%{_initdir}

pushd %{name}
%{__make} install DESTDIR="${RPM_BUILD_ROOT}"
popd

install %{SOURCE1} ${RPM_BUILD_ROOT}%{_initdir}/%{name}

%post
if ! /sbin/chkconfig %{name}; then
  /sbin/chkconfig --add %{name}
fi

if [ $1 -eq 2 ]; then
  %{_initdir}/%{name} condrestart
fi

%preun
if [ $1 -eq 0 ]; then
  %{_initdir}/%{name} stop
  /sbin/chkconfig --del %{name}
fi

%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && %{__rm} -rf ${RPM_BUILD_ROOT}

%files
%defattr(-, root, root)
%doc hostapd/ChangeLog COPYING README
%dir %{_sysconfdir}/hostapd/
%attr(0755, root, root) %{_sbindir}/hostapd
%attr(0755, root, root) %{_bindir}/hostapd_cli
%{_mandir}/man8/hostapd.8.gz
%{_mandir}/man1/hostapd_cli.1.gz
%attr(0644, root, root) %config %{_sysconfdir}/hostapd/hostapd.conf
%attr(0755, root, root) %{_sysconfdir}/rc.d/init.d/hostapd

%changelog
* Mon Feb 21 2011 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.7.3-3
- merge spec file

* Thu Feb 10 2011 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.7.3-2
- fix daemon script
- change spec file
- separation from patch file
  - daemon script
  - .config
- add Source1 - hostapd-init.sh
- add Source2 - hostapd-0.7.3.config
- add Requires(post) - chkconfig
- add Requires(preun) - chkconfig

* Sun Feb 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.11-2
- rebuild with openssl-1.0.0c

* Tue Sep 21 2010 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.7.3-1
- new upstream release

* Sat May 08 2010 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.6.10-1
- new upstream release

* Mon Nov 15 2009 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.6.9-1
- new upstream release

* Mon Jan 05 2009 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.5.11-1
- new upstream release

* Wed Apr 16 2008 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.5.10-1
- initial build for Vine Linux
