[lcgdm: 1/2] Introduce systemd-rpm macros

Alejandro Alvarez aalvarez at fedoraproject.org
Fri Aug 30 13:50:51 UTC 2013


commit fcc7c7b0b680e9d25aa07831e1dbdac7d7db4dda
Author: aalvarez <alejandro.alvarez.ayllon at cern.ch>
Date:   Fri Aug 30 15:48:28 2013 +0200

    Introduce systemd-rpm macros

 lcgdm.spec |  110 +++++++++++++++++++++++++++--------------------------------
 1 files changed, 50 insertions(+), 60 deletions(-)
---
diff --git a/lcgdm.spec b/lcgdm.spec
index 6b4f386..3741ad1 100644
--- a/lcgdm.spec
+++ b/lcgdm.spec
@@ -36,7 +36,7 @@
 
 Name:		lcgdm
 Version:	1.8.7
-Release:	3%{?dist}
+Release:	4%{?dist}
 Summary:	LHC Computing Grid Data Management
 
 Group:		Applications/Internet
@@ -824,13 +824,13 @@ fi
   --slave %{_mandir}/man8/lfc-shutdown.8.gz lfc-shutdown.8.gz \
 	  %{_libdir}/lfc-mysql/lfc-shutdown.8.gz
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+%systemd_post lfcdaemon.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add lfcdaemon
-%endif
 fi
+%endif
 
 %preun -n lfc-server-mysql
 export LANG=C
@@ -839,9 +839,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display lfcdaemon | \
 	grep currently | grep -q lfc-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable lfcdaemon.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop lfcdaemon.service > /dev/null 2>&1 || :
+	%systemd_preun lfcdaemon.service
 %else
 	/sbin/service lfcdaemon stop > /dev/null 2>&1 || :
 %endif
@@ -861,7 +859,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display lfcdaemon | \
 	grep currently | grep -q lfc-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart lfcdaemon.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart lfcdaemon.service
 %else
 	/sbin/service lfcdaemon condrestart > /dev/null 2>&1 || :
 %endif
@@ -877,33 +875,32 @@ if [ -r %{_initrddir}/lfc-dli ] ; then
 fi
 %endif
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+%systemd_post lfc-dli.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add lfc-dli
-%endif
 fi
+%endif
 
 %preun -n lfc-dli
-if [ $1 -eq 0 ]; then
 %if %systemd
-    /bin/systemctl --no-reload disable lfc-dli.service > /dev/null 2>&1 || :
-    /bin/systemctl stop lfc-dli.service > /dev/null 2>&1 || :
+%systemd_preun lfc-dli.service
 %else
+if [ $1 -eq 0 ]; then
     /sbin/service lfc-dli stop > /dev/null 2>&1 || :
     /sbin/chkconfig --del lfc-dli
-%endif
 fi
+%endif
 
 %postun -n lfc-dli
-if [ $1 -ge 1 ]; then
 %if %systemd
-    /bin/systemctl try-restart lfc-dli.service > /dev/null 2>&1 || :
+    %systemd_postun_with_restart lfc-dli.service
 %else
+if [ $1 -ge 1 ]; then
     /sbin/service lfc-dli condrestart > /dev/null 2>&1 || :
-%endif
 fi
+%endif
 
 %post -n dpm-server-mysql
 %if %systemd
@@ -940,13 +937,13 @@ fi
   --slave %{_mandir}/man8/dpm-buildfsv.8.gz dpm-buildfsv.8.gz \
 	  %{_libdir}/dpm-mysql/dpm-buildfsv.8.gz
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+    %systemd_post dpm.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add dpm
-%endif
 fi
+%endif
 
 %preun -n dpm-server-mysql
 export LANG=C
@@ -955,9 +952,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display dpm | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable dpm.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop dpm.service > /dev/null 2>&1 || :
+	%systemd_preun dpm.service
 %else
 	/sbin/service dpm stop > /dev/null 2>&1 || :
 %endif
@@ -977,7 +972,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display dpm | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart dpm.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart dpm.service
 %else
 	/sbin/service dpm condrestart > /dev/null 2>&1 || :
 %endif
@@ -1015,13 +1010,13 @@ fi
   --slave %{_mandir}/man8/dpns-shutdown.8.gz dpns-shutdown.8.gz \
 	  %{_libdir}/dpm-mysql/dpns-shutdown.8.gz
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+    %systemd_post dpnsdaemon.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add dpnsdaemon
-%endif
 fi
+%endif
 
 %preun -n dpm-name-server-mysql
 export LANG=C
@@ -1030,9 +1025,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display dpnsdaemon | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable dpnsdaemon.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop dpnsdaemon.service > /dev/null 2>&1 || :
+	%systemd_preun dpnsdaemon.service
 %else
 	/sbin/service dpnsdaemon stop > /dev/null 2>&1 || :
 %endif
@@ -1052,7 +1045,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display dpnsdaemon | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart dpnsdaemon.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart dpnsdaemon.service
 %else
 	/sbin/service dpnsdaemon condrestart > /dev/null 2>&1 || :
 %endif
@@ -1084,13 +1077,13 @@ fi
   --slave %{_sysconfdir}/logrotate.d/dpmcopyd dpmcopyd.logrotate \
 	  %{_sysconfdir}/dpm-mysql/dpmcopyd.logrotate
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+    %systemd_post dpmcopyd.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add dpmcopyd
-%endif
 fi
+%endif
 
 %preun -n dpm-copy-server-mysql
 export LANG=C
@@ -1099,9 +1092,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display dpmcopyd | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable dpmcopyd.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop dpmcopyd.service > /dev/null 2>&1 || :
+	%systemd_preun dpmcopyd.service
 %else
 	/sbin/service dpmcopyd stop > /dev/null 2>&1 || :
 %endif
@@ -1121,7 +1112,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display dpmcopyd | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart dpmcopyd.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart dpmcopyd.service
 %else
 	/sbin/service dpmcopyd condrestart > /dev/null 2>&1 || :
 %endif
@@ -1193,15 +1184,18 @@ fi
   --slave %{_sysconfdir}/logrotate.d/srmv2.2 srmv2.2.logrotate \
 	  %{_sysconfdir}/dpm-mysql/srmv2.2.logrotate
 
-if [ $1 -eq 1 ]; then
+
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+    %systemd_post srmv1.service
+    %systemd_post srmv2.service
+    %systemd_post srmv2.2.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add srmv1
     /sbin/chkconfig --add srmv2
     /sbin/chkconfig --add srmv2.2
-%endif
 fi
+%endif
 
 %preun -n dpm-srm-server-mysql
 export LANG=C
@@ -1210,9 +1204,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv1 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable srmv1.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop srmv1.service > /dev/null 2>&1 || :
+	%systemd_preun srmv1.service
 %else
 	/sbin/service srmv1 stop > /dev/null 2>&1 || :
 %endif
@@ -1227,9 +1219,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv2 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable srmv2.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop srmv2.service > /dev/null 2>&1 || :
+	%systemd_preun srmv2.service
 %else
 	/sbin/service srmv2 stop > /dev/null 2>&1 || :
 %endif
@@ -1244,9 +1234,7 @@ if [ $1 -eq 0 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv2.2 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl --no-reload disable srmv2.2.service \
-	    > /dev/null 2>&1 || :
-	/bin/systemctl stop srmv2.2.service > /dev/null 2>&1 || :
+	%systemd_preun srmv2.2.service
 %else
 	/sbin/service srmv2.2 stop > /dev/null 2>&1 || :
 %endif
@@ -1266,7 +1254,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv1 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart srmv1.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart srmv1.service
 %else
 	/sbin/service srmv1 condrestart > /dev/null 2>&1 || :
 %endif
@@ -1275,7 +1263,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv2 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart srmv2.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart srmv2.service
 %else
 	/sbin/service srmv2 condrestart > /dev/null 2>&1 || :
 %endif
@@ -1284,7 +1272,7 @@ if [ $1 -ge 1 ]; then
     if ( %{_sbindir}/update-alternatives --display srmv2.2 | \
 	grep currently | grep -q dpm-mysql ) ; then
 %if %systemd
-	/bin/systemctl try-restart srmv2.2.service > /dev/null 2>&1 || :
+	%systemd_postun_with_restart srmv2.2.service
 %else
 	/sbin/service srmv2.2 condrestart > /dev/null 2>&1 || :
 %endif
@@ -1300,19 +1288,18 @@ if [ -r %{_initrddir}/rfiod ] ; then
 fi
 %endif
 
-if [ $1 -eq 1 ]; then
 %if %systemd
-    /bin/systemctl daemon-reload > /dev/null 2>&1 || :
+%systemd_post rfiod.service
 %else
+if [ $1 -eq 1 ]; then
     /sbin/chkconfig --add rfiod
-%endif
 fi
+%endif
 
 %preun -n dpm-rfio-server
 if [ $1 -eq 0 ]; then
 %if %systemd
-    /bin/systemctl --no-reload disable rfiod.service > /dev/null 2>&1 || :
-    /bin/systemctl stop rfiod.service > /dev/null 2>&1 || :
+    %systemd_preun rfiod.service
 %else
     /sbin/service rfiod stop > /dev/null 2>&1 || :
     /sbin/chkconfig --del rfiod
@@ -1322,7 +1309,7 @@ fi
 %postun -n dpm-rfio-server
 if [ $1 -ge 1 ]; then
 %if %systemd
-    /bin/systemctl try-restart rfiod.service > /dev/null 2>&1 || :
+    %systemd_postun_with_restart rfiod.service
 %else
     /sbin/service rfiod condrestart > /dev/null 2>&1 || :
 %endif
@@ -1631,6 +1618,9 @@ fi
 %doc %{_mandir}/man8/rfiod.8*
 
 %changelog
+* Fri Aug 30 2013 Alejandro Alvarez <aalvarez at cern.ch> 1.8.7-4
+- Introduce systemd-rpm macros
+
 * Wed Jul 10 2013 Alejandro Alvarez <aalvarez at cern.ch> 1.8.7-3
 - Update for new upstream release
 - Fixed bogus dates


More information about the scm-commits mailing list