[libvirt PATCH 2/3] spec: avoid repeated calls to systemd macros and binaries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zbigniew Jędrzejewski-Szmek <zbyszek@xxxxxxxxx>

The macro can take multiple arguments, and the calls are more efficient
if done in one go.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@xxxxxxxxx>
---
 libvirt.spec.in | 50 +++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7f12a92b7f..39226175ce 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1257,31 +1257,35 @@ getent group libvirt >/dev/null || groupadd -r libvirt
 exit 0
 
 %post daemon
+%global post_units \\\
+        virtlockd.socket virtlockd-admin.socket \\\
+        virtlogd.socket virtlogd-admin.socket \\\
+        libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\
+        libvirtd-tcp.socket libvirtd-tls.socket \\\
+        libvirtd.service \\\
+        libvirt-guests.service
 
-%systemd_post virtlockd.socket virtlockd-admin.socket
-%systemd_post virtlogd.socket virtlogd-admin.socket
-%systemd_post libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
-%systemd_post libvirtd-tcp.socket libvirtd-tls.socket
-%systemd_post libvirtd.service
-%systemd_post libvirt-guests.service
+%systemd_post %post_units
 
 # request daemon restart in posttrans
 mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
 touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
 
 %preun daemon
-%systemd_preun libvirtd.service
-%systemd_preun libvirtd-tcp.socket libvirtd-tls.socket
-%systemd_preun libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
-%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service
-%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service
-%systemd_preun libvirt-guests.service
+%global preun_units \\\
+        libvirtd.service \\\
+        libvirtd-tcp.socket libvirtd-tls.socket \\\
+        libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\
+        virtlogd.socket virtlogd-admin.socket virtlogd.service \\\
+        virtlockd.socket virtlockd-admin.socket virtlockd.service \\\
+        libvirt-guests.service
+
+%systemd_preun %preun_units
 
 %postun daemon
 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
 if [ $1 -ge 1 ] ; then
-    /bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || :
-    /bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || :
+    /bin/systemctl reload-or-try-restart virtlockd.service virtlogd.service >/dev/null 2>&1 || :
 fi
 %systemd_postun libvirt-guests.service
 
@@ -1308,11 +1312,12 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
         # systemd socket activation, because switching things
         # might confuse mgmt tool like puppet/ansible that
         # expect the old style libvirtd
-        /bin/systemctl mask libvirtd.socket >/dev/null 2>&1 || :
-        /bin/systemctl mask libvirtd-ro.socket >/dev/null 2>&1 || :
-        /bin/systemctl mask libvirtd-admin.socket >/dev/null 2>&1 || :
-        /bin/systemctl mask libvirtd-tls.socket >/dev/null 2>&1 || :
-        /bin/systemctl mask libvirtd-tcp.socket >/dev/null 2>&1 || :
+        /bin/systemctl mask \
+                libvirtd.socket \
+                libvirtd-ro.socket \
+                libvirtd-admin.socket \
+                libvirtd-tls.socket \
+                libvirtd-tcp.socket >/dev/null 2>&1 || :
     else
         # Old libvirtd owns the sockets and will delete them on
         # shutdown. Can't use a try-restart as libvirtd will simply
@@ -1324,9 +1329,10 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
         then
             /bin/systemctl stop libvirtd.service >/dev/null 2>&1 || :
 
-            /bin/systemctl try-restart libvirtd.socket >/dev/null 2>&1 || :
-            /bin/systemctl try-restart libvirtd-ro.socket >/dev/null 2>&1 || :
-            /bin/systemctl try-restart libvirtd-admin.socket >/dev/null 2>&1 || :
+            /bin/systemctl try-restart \
+                    libvirtd.socket \
+                    libvirtd-ro.socket \
+                    libvirtd-admin.socket >/dev/null 2>&1 || :
 
             /bin/systemctl start libvirtd.service >/dev/null 2>&1 || :
         fi
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux