use %%{_unitdir} and new systemd macros

- when deciding where to put systemd configuration, based
  on patch from Václav Pavlín (#850232)
- use new systemd macros for scriptlet hooks, when available, based on
  patch from Václav Pavlín (#850232)
This commit is contained in:
Nalin Dahyabhai 2013-01-18 15:28:43 -05:00
parent 849bb83ec8
commit 5cded00af8
1 changed files with 27 additions and 3 deletions

View File

@ -6,6 +6,14 @@
%global sysvinit 1
%endif
# Fedora had these in F18, but we didn't cut over to use them until after F18
# was frozen, so pretend it didn't happen until F19.
%if 0%{?fedora} > 18 || 0%{?rhel} > 6
%global systemd_macros 1
%else
%global systemd_macros 0
%endif
%if 0%{?fedora} > 14 || 0%{?rhel} > 6
%global tmpfiles 1
%else
@ -105,12 +113,12 @@ make check
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/{%{_initddir},%{_libdir},lib/systemd/system}
mkdir -p $RPM_BUILD_ROOT/{%{_initddir},%{_libdir},%{_unitdir}}
%if %{sysvinit}
install -p -m755 %{SOURCE2} $RPM_BUILD_ROOT/%{_initddir}/nslcd
%endif
%if %{systemd}
install -p -m755 %{SOURCE4} $RPM_BUILD_ROOT/lib/systemd/system/
install -p -m644 %{SOURCE4} $RPM_BUILD_ROOT/%{_unitdir}/
%endif
%if 0%{?fedora} > 13 || 0%{?rhel} > 5
@ -161,7 +169,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(0755,root,root) %{_initddir}/nslcd
%endif
%if %{systemd}
%config(noreplace) /lib/systemd/system/*
%config(noreplace) %{_unitdir}/*
%endif
%attr(0755,nslcd,root) /var/run/nslcd
%if 0%{?fedora} > 13 || 0%{?rhel} > 5
@ -184,8 +192,12 @@ getent passwd nslcd > /dev/null || \
/sbin/chkconfig --add nslcd
%endif
%if %{systemd}
%if %{systemd_macros}
%systemd_post nslcd.service
%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
%endif
/sbin/ldconfig
# Import important non-default settings from nss_ldap or pam_ldap configuration
# files, but only the first time this package is installed.
@ -266,9 +278,13 @@ if [ "$1" -eq "0" ]; then
/sbin/chkconfig --del nslcd
%endif
%if %{systemd}
%if %{systemd_macros}
%systemd_preun nslcd.service
%else
/bin/systemctl --no-reload disable nslcd.service > /dev/null 2>&1 || :
/bin/systemctl stop nslcd.service > /dev/null 2>&1 || :
%endif
%endif
fi
exit 0
@ -280,11 +296,15 @@ if [ "$1" -ge "1" ]; then
fi
%endif
%if %{systemd}
%if %{systemd_macros}
%systemd_postun_with_restart nslcd.service
%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ "$1" -ge "1" ]; then
/bin/systemctl try-restart nslcd.service >/dev/null 2>&1
fi
%endif
%endif
exit 0
%if %{systemd}
@ -308,6 +328,10 @@ exit 0
to make sure that nslcd is started after them if they're to be started
on the local system (#832706)
- alter the versioned Obsoletes: on pam_ldap to include the F18 package
- use %%{_unitdir} when deciding where to put systemd configuration, based
on patch from Václav Pavlín (#850232)
- use new systemd macros for scriptlet hooks, when available, based on
patch from Václav Pavlín (#850232)
* Sun Sep 09 2012 Jakub Hrozek <jhrozek@redhat.com> 0.7.17-1
- new upstream release 0.7.17