Blob Blame History Raw
%define _hardened_build 1

Name:           ahcpd
Version:        0.53
Release:        2%{?dist}
Summary:        Ad-hoc network configuration daemon

Group:          System Environment/Base
License:        MIT
URL:            http://www.pps.univ-paris-diderot.fr/~jch/software/ahcp/
Source0:        http://www.pps.univ-paris-diderot.fr/~jch/software/files/%{name}-%{version}.tar.gz
Source1:        %{name}.service
Source2:        %{name}.conf
Source3:        %{name}.logrotate
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units

%description
AHCP is a configuration protocol that can replace DHCP on networks without 
transitive connectivity, such as mesh networks.

%prep
%setup -q

%build
make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
install -Dpm 755 ahcpd $RPM_BUILD_ROOT%{_sbindir}/ahcpd
install -Dpm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
install -Dpm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/ahcpd.conf
install -Dpm 644 ahcpd.man $RPM_BUILD_ROOT/%{_mandir}/man8/ahcpd.8
install -Dp -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ahcpd
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/ahcpd/leases/

%clean
rm -rf $RPM_BUILD_ROOT


%post
if [ $1 -eq 1 ] ; then
    # Initial installation
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
  
%preun
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable ahcpd.service > /dev/null 2>&1 || :
    /bin/systemctl stop ahcpd.service > /dev/null 2>&1 || :
fi

%postun
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart ahcpd.service >/dev/null 2>&1 || :
fi


%files
%defattr(-,root,root,-)
%doc CHANGES LICENCE README
%{_sbindir}/ahcpd
%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/ahcpd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/ahcpd
%{_mandir}/man8/ahcpd.8.gz
%ghost %attr(0600,root,root) %{_localstatedir}/log/ahcpd.log


%changelog
* Mon Aug 27 2012 Jon Ciesla <limburgher@gmail.com> - 0.53-2
- Dropped unneeded parts for review.
- Added log, logrotate, state file, and default config.

* Tue Aug 21 2012 Jon Ciesla <limburgher@gmail.com> - 0.53-1
- Initial package.