[ddclient] - Use the new systemd macros (#850084, thanks to Lukáš Nykrýn) - Adapted the spec file to handle
Robert Scheck
robert at fedoraproject.org
Wed Dec 25 22:00:02 UTC 2013
commit 1f8a3f6364478f0b1f31188bb19be3822ffbcfcc
Author: Robert Scheck <robert at fedoraproject.org>
Date: Wed Dec 25 22:59:47 2013 +0100
- Use the new systemd macros (#850084, thanks to Lukáš Nykrýn)
- Adapted the spec file to handle systemd and SysV initscripts
ddclient.spec | 124 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 79 insertions(+), 45 deletions(-)
---
diff --git a/ddclient.spec b/ddclient.spec
index 4ef6094..004465c 100644
--- a/ddclient.spec
+++ b/ddclient.spec
@@ -4,7 +4,7 @@
Summary: Client to update dynamic DNS host entries
Name: ddclient
Version: 3.8.1
-Release: 8%{?dist}
+Release: 9%{?dist}
License: GPLv2+
Group: System Environment/Daemons
URL: http://ddclient.sourceforge.net/
@@ -14,17 +14,20 @@ Source2: ddclient.service
Source3: ddclient.sysconfig
Source4: ddclient.NetworkManager
Source5: ddclient-tmpfiles.conf
+Source6: ddclient.initscript
BuildArch: noarch
-BuildRequires: systemd-units
Requires(pre): shadow-utils
-#Requires(post): /sbin/chkconfig
-#Requires(preun): /sbin/service, /sbin/chkconfig
-#Requires(postun): /sbin/service
-Requires(post): systemd-units
-Requires(preun): systemd-units
-Requires(postun): systemd-units
-Requires: perl(Digest::SHA1)
-Requires: perl(IO::Socket::SSL)
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+BuildRequires: systemd-units
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else
+Requires(post): /sbin/chkconfig
+Requires(preun): /sbin/service, /sbin/chkconfig
+Requires(postun): /sbin/service
+%endif
+Requires: perl(Digest::SHA1), perl(IO::Socket::SSL)
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
@@ -53,16 +56,18 @@ sed -e 's|/etc/ddclient/|%{_sysconfdir}/|' -i %{name}
%install
rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT{%{_sbindir},%{_sysconfdir}/{rwtab.d,sysconfig}}
-mkdir -p $RPM_BUILD_ROOT%{_unitdir}
-install -p -m 755 %{name} $RPM_BUILD_ROOT%{_sbindir}/%{name}
-install -p -m 600 sample-etc_ddclient.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.conf
-install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rwtab.d/%{name}
-install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
-install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
+install -D -p -m 755 %{name} $RPM_BUILD_ROOT%{_sbindir}/%{name}
+install -D -p -m 600 sample-etc_ddclient.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.conf
+install -D -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rwtab.d/%{name}
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+install -D -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
+install -D -p -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_tmpfilesdir}/%{name}.conf
+%else
+install -D -p -m 755 %{SOURCE6} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name}
+%endif
+install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
%if 0%{?fedora}%{?rhel} > 4
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d
-install -p -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/50-%{name}
+install -D -p -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d/50-%{name}
%endif
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/{cache,run}/%{name}
touch $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name}/%{name}.cache
@@ -70,9 +75,6 @@ touch $RPM_BUILD_ROOT%{_localstatedir}/cache/%{name}/%{name}.cache
# Correct permissions for later usage in %doc
chmod 644 sample-*
-mkdir -p %{buildroot}%{_tmpfilesdir}
-install -m 0644 %{SOURCE5} %{buildroot}%{_tmpfilesdir}/%{name}.conf
-
%clean
rm -rf $RPM_BUILD_ROOT
@@ -82,34 +84,56 @@ getent passwd %{name} > /dev/null || %{_sbindir}/useradd -r -g %{name} -d %{_loc
exit 0
%post
-#/sbin/chkconfig --add %{name}
-if [ $1 -eq 1 ] ; then
- # Initial installation
- /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+%if 0%{?fedora} >= 18
+ %systemd_post %{name}.service
+%else
+if [ $1 -eq 1 ]; then
+ # Package install, not upgrade
+ /bin/systemctl daemon-reload > /dev/null 2>&1 || :
fi
+%endif
+%else
+/sbin/chkconfig --add %{name}
+%endif
%preun
-#if [ $1 -eq 0 ]; then
-# /sbin/service %{name} stop > /dev/null 2>&1 || :
-# /sbin/chkconfig --del %{name}
-#fi
-if [ $1 -eq 0 ] ; then
- # Package removal, not upgrade
- /bin/systemctl --no-reload disable ddclient.service > /dev/null 2>&1 || :
- /bin/systemctl stop ddclient.service > /dev/null 2>&1 || :
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+%if 0%{?fedora} >= 18
+ %systemd_preun %{name}.service
+%else
+# Work around RHBZ #655116
+if [ $1 -eq 0 ]; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
+ /bin/systemctl stop %{name}.service > /dev/null 2>&1 || :
fi
-
+%endif
+%else
+if [ $1 -eq 0 ]; then
+ /sbin/service %{name} stop > /dev/null 2>&1 || :
+ /sbin/chkconfig --del %{name}
+fi
+%endif
%postun
-#if [ $1 -ne 0 ]; then
-# /sbin/service %{name} condrestart > /dev/null 2>&1 || :
-#fi
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
+%if 0%{?fedora} >= 18
+ %systemd_postun_with_restart %{name}.service
+%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
- # Package upgrade, not uninstall
- /bin/systemctl try-restart ddclient.service >/dev/null 2>&1 || :
+if [ $1 -ge 1 ]; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
+%endif
+%else
+if [ $1 -ne 0 ]; then
+ /sbin/service %{name} condrestart > /dev/null 2>&1 || :
+fi
+%endif
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
%triggerun -- ddclient < 3.8.1-1
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply ddclient
@@ -117,15 +141,23 @@ fi
/usr/bin/systemd-sysv-convert --save ddclient >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
-/sbin/chkconfig --del ddclient >/dev/null 2>&1 || :
-/bin/systemctl try-restart ddclient.service >/dev/null 2>&1 || :
+/sbin/chkconfig --del %{name} > /dev/null 2>&1 || :
+/bin/systemctl try-restart %{name}.service > /dev/null 2>&1 || :
+%endif
%files
%defattr(-,root,root,-)
%doc README* COPYING COPYRIGHT Changelog sample-etc_ppp_ip-up.local
%doc sample-etc_dhclient-exit-hooks sample-etc_cron.d_ddclient
%doc sample-ddclient-wrapper.sh sample-etc_dhcpc_dhcpcd-eth0.exe
+%if 0%{?fedora} > 14 || 0%{?rhel} > 6
%{_unitdir}/%{name}.service
+%{_tmpfilesdir}/%{name}.conf
+%ghost %attr(0755,%{name},%{name}) %dir %{_localstatedir}/run/%{name}/
+%else
+%{_sysconfdir}/rc.d/init.d/%{name}
+%attr(0755,%{name},%{name}) %dir %{_localstatedir}/run/%{name}/
+%endif
%if 0%{?fedora}%{?rhel} > 4
%{_sysconfdir}/NetworkManager/dispatcher.d/50-%{name}
%endif
@@ -135,10 +167,12 @@ fi
%{_sbindir}/%{name}
%attr(0700,%{name},%{name}) %dir %{_localstatedir}/cache/%{name}/
%attr(0600,%{name},%{name}) %ghost %{_localstatedir}/cache/%{name}/%{name}.cache
-%attr(0755,%{name},%{name}) %dir %{_localstatedir}/run/%{name}/
-%{_tmpfilesdir}/%{name}.conf
%changelog
+* Wed Dec 25 2013 Robert Scheck <robert at fedoraproject.org> 3.8.1-9
+- Use the new systemd macros (#850084, thanks to Lukáš Nykrýn)
+- Adapted the spec file to handle systemd and SysV initscripts
+
* Sat Aug 10 2013 Paul Howarth <paul at city-fan.org> - 3.8.1-8
- BR: systemd-units for %%{_unitdir} macro definition (fixes FTBFS #992118)
- Put tmpfiles config in %%{_tmpfilesdir}, not under /etc
More information about the scm-commits
mailing list