- convert to systemd-native startup (#716997)

This commit is contained in:
Nalin Dahyabhai 2011-07-13 18:40:48 -04:00
parent 8bb3ad8953
commit ca9ea0cced

View File

@ -1,3 +1,17 @@
%if 0%{?fedora} > 15 || 0%{?rhel} > 6
%global systemd 1
%global sysvinit 0
%else
%global systemd 0
%global sysvinit 1
%endif
%if 0%{?fedora} > 14 || 0%{?rhel} > 6
%global tmpfiles 1
%else
%global tmpfiles 0
%endif
Name: nss-pam-ldapd Name: nss-pam-ldapd
Version: 0.7.13 Version: 0.7.13
Release: 5%{?dist} Release: 5%{?dist}
@ -9,6 +23,7 @@ Source0: http://arthurdejong.org/nss-pam-ldapd/nss-pam-ldapd-%{version}.tar.gz
Source1: http://arthurdejong.org/nss-pam-ldapd/nss-pam-ldapd-%{version}.tar.gz.sig Source1: http://arthurdejong.org/nss-pam-ldapd/nss-pam-ldapd-%{version}.tar.gz.sig
Source2: nslcd.init Source2: nslcd.init
Source3: nslcd.tmpfiles Source3: nslcd.tmpfiles
Source4: nslcd.service
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: openldap-devel, krb5-devel BuildRequires: openldap-devel, krb5-devel
Obsoletes: nss-ldapd < 0.7 Obsoletes: nss-ldapd < 0.7
@ -20,9 +35,18 @@ Provides: nss-ldapd = %{version}-%{release}
Requires: pam_ldap%{?_isa} Requires: pam_ldap%{?_isa}
# Pull in nscd, which is recommended. # Pull in nscd, which is recommended.
Requires: nscd Requires: nscd
%if %{sysvinit}
Requires(post): /sbin/ldconfig, chkconfig, grep, sed Requires(post): /sbin/ldconfig, chkconfig, grep, sed
Requires(preun): chkconfig, initscripts Requires(preun): chkconfig, initscripts
Requires(postun): /sbin/ldconfig, initscripts Requires(postun): /sbin/ldconfig, initscripts
%endif
%if %{systemd}
BuildRequires: systemd-units
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires(post): systemd-sysv
%endif
%description %description
The nss-pam-ldapd daemon, nslcd, uses a directory server to look up name The nss-pam-ldapd daemon, nslcd, uses a directory server to look up name
@ -39,8 +63,13 @@ make %{?_smp_mflags}
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/{%{_initddir},%{_libdir}} mkdir -p $RPM_BUILD_ROOT/{%{_initddir},%{_libdir},lib/systemd/system}
%if %{sysvinit}
install -p -m755 %{SOURCE2} $RPM_BUILD_ROOT/%{_initddir}/nslcd install -p -m755 %{SOURCE2} $RPM_BUILD_ROOT/%{_initddir}/nslcd
%endif
%if %{systemd}
install -p -m755 %{SOURCE4} $RPM_BUILD_ROOT/lib/systemd/system/
%endif
%if 0%{?fedora} > 13 %if 0%{?fedora} > 13
# Follow glibc's convention and provide a .so symlink so that people who know # Follow glibc's convention and provide a .so symlink so that people who know
# what to expect can link directly with the module. # what to expect can link directly with the module.
@ -59,8 +88,10 @@ sed -i -e 's,^uid.*,uid nslcd,g' -e 's,^gid.*,gid ldap,g' \
$RPM_BUILD_ROOT/%{_sysconfdir}/nslcd.conf $RPM_BUILD_ROOT/%{_sysconfdir}/nslcd.conf
touch -r nslcd.conf $RPM_BUILD_ROOT/%{_sysconfdir}/nslcd.conf touch -r nslcd.conf $RPM_BUILD_ROOT/%{_sysconfdir}/nslcd.conf
mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/nslcd mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/nslcd
%if %{tmpfiles}
mkdir -p -m 0755 $RPM_BUILD_ROOT/etc/tmpfiles.d mkdir -p -m 0755 $RPM_BUILD_ROOT/etc/tmpfiles.d
install -p -m 0644 %{SOURCE3} $RPM_BUILD_ROOT/etc/tmpfiles.d/%{name}.conf install -p -m 0644 %{SOURCE3} $RPM_BUILD_ROOT/etc/tmpfiles.d/%{name}.conf
%endif
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -72,10 +103,17 @@ rm -rf $RPM_BUILD_ROOT
/%{_lib}/*.so.* /%{_lib}/*.so.*
%{_mandir}/*/* %{_mandir}/*/*
%attr(0600,root,root) %config(noreplace) %verify(not md5 size mtime) /etc/nslcd.conf %attr(0600,root,root) %config(noreplace) %verify(not md5 size mtime) /etc/nslcd.conf
%if %{tmpfiles}
%attr(0644,root,root) %config(noreplace) /etc/tmpfiles.d/%{name}.conf %attr(0644,root,root) %config(noreplace) /etc/tmpfiles.d/%{name}.conf
%endif
%if %{sysvinit}
%attr(0755,root,root) %{_initddir}/nslcd %attr(0755,root,root) %{_initddir}/nslcd
%endif
%if %{systemd}
%config(noreplace) /lib/systemd/system/*
%endif
%attr(0755,nslcd,root) /var/run/nslcd %attr(0755,nslcd,root) /var/run/nslcd
%if 0%{?fedora} > 13 %if 0%{?fedora} > 13 || %{?rhel} > 5
# This would be the only thing in the -devel subpackage, so we include it. It # This would be the only thing in the -devel subpackage, so we include it. It
# will conflict with nss_ldap, so only include it for releases where pam_ldap is # will conflict with nss_ldap, so only include it for releases where pam_ldap is
# its own package. # its own package.
@ -91,7 +129,12 @@ getent passwd nslcd > /dev/null || \
%post %post
# The usual stuff. # The usual stuff.
%if %{sysvinit}
/sbin/chkconfig --add nslcd /sbin/chkconfig --add nslcd
%endif
%if %{systemd}
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
/sbin/ldconfig /sbin/ldconfig
# Import important non-default settings from nss_ldap or pam_ldap configuration # Import important non-default settings from nss_ldap or pam_ldap configuration
# files, but only the first time this package is installed. # files, but only the first time this package is installed.
@ -143,7 +186,12 @@ fi
# is an upgrade, leave the user's runlevel selections alone. # is an upgrade, leave the user's runlevel selections alone.
if [ "$1" -eq "1" ]; then if [ "$1" -eq "1" ]; then
if egrep -q '^USELDAP=yes$' /etc/sysconfig/authconfig 2> /dev/null ; then if egrep -q '^USELDAP=yes$' /etc/sysconfig/authconfig 2> /dev/null ; then
%if %{sysvinit}
/sbin/chkconfig nslcd on /sbin/chkconfig nslcd on
%endif
%if %{systemd}
/bin/systemctl --no-reload enable nslcd.service >/dev/null 2>&1 ||:
%endif
fi fi
fi fi
# Earlier versions of 0.7.6 of this package would have included both 'gid # Earlier versions of 0.7.6 of this package would have included both 'gid
@ -162,19 +210,49 @@ exit 0
%preun %preun
if [ "$1" -eq "0" ]; then if [ "$1" -eq "0" ]; then
%if %{sysvinit}
/sbin/service nslcd stop >/dev/null 2>&1 /sbin/service nslcd stop >/dev/null 2>&1
/sbin/chkconfig --del nslcd /sbin/chkconfig --del nslcd
%endif
%if %{systemd}
/bin/systemctl --no-reload disable nslcd.service > /dev/null 2>&1 || :
/bin/systemctl stop nslcd.service > /dev/null 2>&1 || :
%endif
fi fi
exit 0 exit 0
%postun %postun
/sbin/ldconfig /sbin/ldconfig
%if %{sysvinit}
if [ "$1" -ge "1" ]; then if [ "$1" -ge "1" ]; then
/etc/rc.d/init.d/nslcd condrestart >/dev/null 2>&1 /etc/rc.d/init.d/nslcd condrestart >/dev/null 2>&1
fi fi
%endif
%if %{systemd}
/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
exit 0 exit 0
%if %{systemd}
%triggerun -- nss-pam-ldapd < 0.7.13-6
# Save the current service runlevel info, in case the user wants to apply
# the enabled status manually later, by running
# "systemd-sysv-convert --apply nslcd".
%{_bindir}/systemd-sysv-convert --save nslcd >/dev/null 2>&1 ||:
# Do this because the old package's %%postun doesn't know we need to do it.
/sbin/chkconfig --del nslcd >/dev/null 2>&1 || :
# Do this because the old package's %%postun wouldn't have tried.
/bin/systemctl try-restart nslcd.service >/dev/null 2>&1 || :
exit 0
%endif
%changelog %changelog
* Wed Jul 13 2011 Nalin Dahyabhai <nalin@redhat.com> 0.7.13-6
- convert to systemd-native startup (#716997)
* Mon Jun 13 2011 Nalin Dahyabhai <nalin@redhat.com> 0.7.13-5 * Mon Jun 13 2011 Nalin Dahyabhai <nalin@redhat.com> 0.7.13-5
- change the file path Requires: we have for pam_ldap into a package name - change the file path Requires: we have for pam_ldap into a package name
Requires: (#601931) Requires: (#601931)