packages: rpm-build-macros/rpm.macros - add systemd macros: %systemd_post %...

cactus cactus at pld-linux.org
Sat Dec 3 23:43:07 CET 2011


Author: cactus                       Date: Sat Dec  3 22:43:07 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- add systemd macros: %systemd_post %systemd_enable %systemd_postun %systemd_preun

---- Files affected:
packages/rpm-build-macros:
   rpm.macros (1.619 -> 1.620) 

---- Diffs:

================================================================
Index: packages/rpm-build-macros/rpm.macros
diff -u packages/rpm-build-macros/rpm.macros:1.619 packages/rpm-build-macros/rpm.macros:1.620
--- packages/rpm-build-macros/rpm.macros:1.619	Thu Aug 25 21:14:39 2011
+++ packages/rpm-build-macros/rpm.macros	Sat Dec  3 23:43:02 2011
@@ -2039,4 +2039,59 @@
 };} \
 %{nil}
 
+
+# pre/post script for -systemd subpackages
+#
+# Author: Bartlomiej Zimon <uzi18 at o2.pl>
+#
+# Usage:
+# %systemd_post
+# %systemd_enable service_name.service
+# %systemd_preun  service_name.service
+# %systemd_postun service_name.service
+#
+# Sample:
+# %post systemd
+# %systemd_post %{name}
+# or if service must be enabled by default:
+# %post systemd
+# %systemd_post %{name}
+# %systemd_enable %{name}
+#
+# %preun systemd
+# %systemd_preun %{name}
+#
+# %postun systemd
+# %systemd_postun %{name}
+#
+# Requirements:
+# BuildRequires: rpmbuild(macros) >= ...
+# Requires:	 rc-scripts >= ...
+
+%systemd_enable() {
+if [ $1 -eq 1 ] ; then 
+    /bin/systemctl enable %1 >/dev/null 2>&1 || : \
+fi \
+}
+
+%systemd_post() {
+if [ $1 -eq 1 ] ; then 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || : \
+fi \
+}
+
+%systemd_preun() {
+if [ $1 -eq 0 ] ; then \
+    /bin/systemctl --no-reload disable %1 > /dev/null 2>&1 || : \
+    /bin/systemctl stop %1 > /dev/null 2>&1 || : \
+fi \
+}
+                    
+%systemd_postun() {
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || : \
+    if [ $1 -ge 1 ] ; then \
+    /bin/systemctl try-restart %1 >/dev/null 2>&1 || : \
+fi \
+}
+
 # EOF
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/rpm-build-macros/rpm.macros?r1=1.619&r2=1.620&f=u



More information about the pld-cvs-commit mailing list