From 77b780f58137a5aba438f699dad12d6c13e6ad41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Pavl=C3=ADn?= Date: Thu, 25 Oct 2012 12:10:55 +0200 Subject: [PATCH] spec: replace scriptlets with new systemd macros https://bugzilla.redhat.com/850186 I added %with_systemd_macros so it should now work in F17 with old scriptlets and in F18+/RHEL7+ with systemd macros (see https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd) I missed libvirt-guests.service because there is no systemctl call for it. So I only added systemd macros calls. (cherry picked from commit ec02d49dfd98313d1c8c4179e88754f10a82ca46) --- libvirt.spec.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index e353f0ad95..a3e4f95427 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -325,6 +325,13 @@ %define with_rhel5 0 %endif +%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 +%define with_systemd_macros 1 +%else +%define with_systemd_macros 0 +%endif + + Summary: Library providing a simple virtualization API Name: libvirt Version: @VERSION@ @@ -1460,10 +1467,14 @@ done %endif %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_post libvirtd.service +%else if [ $1 -eq 1 ] ; then # Initial installation /bin/systemctl enable libvirtd.service >/dev/null 2>&1 || : fi +%endif %else %if %{with_cgconfig} # Starting with Fedora 16/RHEL-7, systemd automounts all cgroups, @@ -1483,11 +1494,15 @@ fi %preun daemon %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_preun libvirtd.service +%else if [ $1 -eq 0 ] ; then # Package removal, not upgrade /bin/systemctl --no-reload disable libvirtd.service > /dev/null 2>&1 || : /bin/systemctl stop libvirtd.service > /dev/null 2>&1 || : fi +%endif %else if [ $1 = 0 ]; then /sbin/service libvirtd stop 1>/dev/null 2>&1 @@ -1497,12 +1512,16 @@ fi %postun daemon %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_postun_with_restart libvirtd.service +%else /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : fi %endif +%endif %if %{with_network} %post daemon-config-network @@ -1533,6 +1552,9 @@ fi %preun client %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_preun libvirt-guests.service +%endif %else if [ $1 = 0 ]; then /sbin/chkconfig --del libvirt-guests @@ -1544,6 +1566,9 @@ fi /sbin/ldconfig %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_post libvirt-guests.service +%endif %else /sbin/chkconfig --add libvirt-guests %endif @@ -1551,6 +1576,9 @@ fi %postun client -p /sbin/ldconfig %if %{with_systemd} +%if %{with_systemd_macros} +%systemd_postun_with_restart libvirt-guests.service +%endif %triggerun client -- libvirt < 0.9.4 %{_bindir}/systemd-sysv-convert --save libvirt-guests >/dev/null 2>&1 ||: -- 2.47.2