SOURCES (AC-branch): rpm.macros, rpm.macros - add "%service [-q] S...

glen glen at pld-linux.org
Sun Jul 10 13:43:45 CEST 2005


Author: glen                         Date: Sun Jul 10 11:43:45 2005 GMT
Module: SOURCES                       Tag: AC-branch
---- Log message:
- add "%service [-q] SERVICE ACTION" macro

---- Files affected:
SOURCES:
   rpm.macros (1.158.4.49 -> 1.158.4.50) 
SOURCES:
   rpm.macros (1.227 -> 1.228) 

---- Diffs:

================================================================
Index: SOURCES/rpm.macros
diff -u SOURCES/rpm.macros:1.158.4.49 SOURCES/rpm.macros:1.158.4.50
--- SOURCES/rpm.macros:1.158.4.49	Thu Jun 30 23:50:33 2005
+++ SOURCES/rpm.macros	Sun Jul 10 13:43:40 2005
@@ -739,3 +739,36 @@
 	done ) \
 ) | ( %banner -t 5 -e %{name}-un ); fi; \
 }
+
+# service macro.
+#
+# calls usual service restart on package %post, but skips the restart if
+# administrator has disabled automatic service restarts in either global
+# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
+#
+# written by glen at pld-linux.org.
+# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+#
+# Usage:
+#   %service [-q] SERVICE ACTION
+#
+#  -q be silent when service isn't started (for postun scriplets)
+#
+%service(q) \
+# we use function, not to globber namespace with useless variables \
+skip_auto_restart() { \
+	. /etc/sysconfig/rpm # global setting \
+	[ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1 # per service setting \
+	echo ${RPM_SKIP_AUTO_RESTART:-no} \
+} \
+if [ -f /var/lock/subsys/%1 ]; then \
+	if [ $(skip_auto_restart) = no ]; then \
+		/etc/rc.d/init.d/%1 %2 1>&2 \
+	else \
+		echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %1 service.' \
+	fi \
+else \
+	%{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %1 service.'} \
+	%{-q::} \
+fi;
+

================================================================
Index: SOURCES/rpm.macros
diff -u SOURCES/rpm.macros:1.227 SOURCES/rpm.macros:1.228
--- SOURCES/rpm.macros:1.227	Thu Jul  7 21:23:35 2005
+++ SOURCES/rpm.macros	Sun Jul 10 13:43:40 2005
@@ -740,3 +740,36 @@
 	done ) \
 ) | ( %banner -t 5 -e %{name}-un ); fi; \
 }
+
+# service macro.
+#
+# calls usual service restart on package %post, but skips the restart if
+# administrator has disabled automatic service restarts in either global
+# /etc/sysconfig/rpm or per service /etc/sysconfig/SERVICE file.
+#
+# written by glen at pld-linux.org.
+# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
+#
+# Usage:
+#   %service [-q] SERVICE ACTION
+#
+#  -q be silent when service isn't started (for postun scriplets)
+#
+%service(q) \
+# we use function, not to globber namespace with useless variables \
+skip_auto_restart() { \
+	. /etc/sysconfig/rpm # global setting \
+	[ -f /etc/sysconfig/%1 ] && . /etc/sysconfig/%1 # per service setting \
+	echo ${RPM_SKIP_AUTO_RESTART:-no} \
+} \
+if [ -f /var/lock/subsys/%1 ]; then \
+	if [ $(skip_auto_restart) = no ]; then \
+		/etc/rc.d/init.d/%1 %2 1>&2 \
+	else \
+		echo 'Run "/etc/rc.d/init.d/%1 %2" to %2 %1 service.' \
+	fi \
+else \
+	%{!-q:echo 'Run "/etc/rc.d/init.d/%1 start" to start %1 service.'} \
+	%{-q::} \
+fi;
+
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/rpm.macros?r1=1.158.4.49&r2=1.158.4.50&f=u
    http://cvs.pld-linux.org/SOURCES/rpm.macros?r1=1.227&r2=1.228&f=u




More information about the pld-cvs-commit mailing list