]> git.pld-linux.org Git - packages/rpm-build-macros.git/commitdiff
- add systemd macros: %systemd_post %systemd_enable %systemd_postun %systemd_preun
authorBartłomiej Zimoń <cactus@pld-linux.org>
Sat, 3 Dec 2011 22:43:02 +0000 (22:43 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    rpm.macros -> 1.620

rpm.macros

index 66c418a89c448a553d2d96838b2848574bb6bb2b..23bdb82efb1fbcd0c1b9048102cac042e0b8a558 100644 (file)
@@ -2039,4 +2039,59 @@ else: \
 };} \
 %{nil}
 
+
+# pre/post script for -systemd subpackages
+#
+# Author: Bartlomiej Zimon <uzi18@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
This page took 0.046963 seconds and 4 git commands to generate.