Blame SOURCES/libvirt-cim-0.6.3-1c7dfda2.patch

c55d09
From 1c7dfda2b543da27ea092a7cb9deab8b2917acba Mon Sep 17 00:00:00 2001
c55d09
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
c55d09
Date: Tue, 5 Nov 2013 10:03:31 +0100
c55d09
Subject: [PATCH 32/48] build: Fix incorrect provider registration in upgrade
c55d09
 path
c55d09
c55d09
The scriplet logic was incorrectly assuming that the superseded package's
c55d09
%postun script would be called before the superceding packages %pre/%post.
c55d09
This effectively broke upgrades of libvirt-cim because all the providers
c55d09
were deregistered.
c55d09
We are now checking whether we are in an upgrade situation and if so
c55d09
will not deregister the providers in postun.
c55d09
Another enhancement is that we do a full deregistration in the %post
c55d09
section for tog-pegasus now. This should make installs and upgrades more
c55d09
robust against potentially damaged repositories (e.g., on development
c55d09
systems).
c55d09
c55d09
As a reminder here's a short description of RPM's scriptlet processing.
c55d09
c55d09
action:         install upgrade uninstall
c55d09
        %pre    1       >1       -
c55d09
        %post   1       >1       -
c55d09
        %preun  -       1        0
c55d09
        %postun -       1        0
c55d09
c55d09
Scriptlet invocation order on upgrade
c55d09
1. %pre(new_package)
c55d09
2. %post(new_package)
c55d09
3. %preun(old_package)
c55d09
4. %postun(old_package)
c55d09
c55d09
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
c55d09
Signed-off-by: John Ferlan <jferlan@redhat.com>
c55d09
---
c55d09
 libvirt-cim.spec.in | 115 +++++++++++++++++++++++++++++++---------------------
c55d09
 1 file changed, 68 insertions(+), 47 deletions(-)
c55d09
c55d09
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
c55d09
index 459650c..b50cbd1 100644
c55d09
--- a/libvirt-cim.spec.in
c55d09
+++ b/libvirt-cim.spec.in
c55d09
@@ -64,7 +64,6 @@ mkdir -p $RPM_BUILD_ROOT@INFO_STORE@
c55d09
 %clean
c55d09
 rm -fr $RPM_BUILD_ROOT
c55d09
 
c55d09
-%pre
c55d09
 %define REGISTRATION %{_datadir}/%{name}/*.registration
c55d09
 %define SCHEMA %{_datadir}/%{name}/*.mof
c55d09
 
c55d09
@@ -77,24 +76,46 @@ rm -fr $RPM_BUILD_ROOT
c55d09
 %define CIMV2_REG %{_datadir}/%{name}/{HostedResourcePool,ElementCapabilities,HostedService,HostedDependency,ElementConformsToProfile,HostedAccessPoint}.registration
c55d09
 %define CIMV2_MOF %{_datadir}/%{name}/{HostedResourcePool,ElementCapabilities,HostedService,HostedDependency,RegisteredProfile,ComputerSystem,ElementConformsToProfile,HostedAccessPoint}.mof
c55d09
 
c55d09
+%pre
c55d09
 # _If_ there is already a version of this installed, we must deregister
c55d09
 # the classes we plan to install in post, otherwise we may corrupt
c55d09
 # the pegasus repository.  This is convention in other provider packages
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
-	-n @CIM_VIRT_NS@ \
c55d09
-	-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
+if [ $1 -gt 1 ]
c55d09
+then
c55d09
+    if [ -x /usr/sbin/cimserver ]
c55d09
+    then
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+	    -n @CIM_VIRT_NS@ \
c55d09
+	    -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+            -n root/interop \
c55d09
+            -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+            -n root/PG_InterOp \
c55d09
+            -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+            -n root/cimv2\
c55d09
+        -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
c55d09
+    fi
c55d09
 
c55d09
 # Remove open-pegasus-specific providers installed in sfcb repository
c55d09
 # by older libvirt-cim packages
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
-    -n root/PG_InterOp \
c55d09
-    -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
c55d09
-
c55d09
+    if [ -x /usr/sbin/sfcbd ]
c55d09
+    then
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
+	    -n root/PG_InterOp \
c55d09
+	    -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
c55d09
+    fi
c55d09
+fi
c55d09
 
c55d09
 %post
c55d09
 /sbin/ldconfig
c55d09
 
c55d09
-%{_datadir}/%{name}/install_base_schema.sh %{_datadir}/%{name}
c55d09
+if [ $1 -eq 1 ]
c55d09
+then
c55d09
+# Install the CIM base schema if this is the initial install
c55d09
+    %{_datadir}/%{name}/install_base_schema.sh %{_datadir}/%{name}
c55d09
+fi
c55d09
 
c55d09
 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
c55d09
     if [ "`systemctl is-active tog-pegasus.service`" = "active" ]
c55d09
@@ -112,65 +133,65 @@ rm -fr $RPM_BUILD_ROOT
c55d09
 
c55d09
 if [ -x /usr/sbin/cimserver ]
c55d09
 then
c55d09
-%{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
 	-n @CIM_VIRT_NS@ \
c55d09
 	-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
-        -n @CIM_VIRT_NS@ \
c55d09
-        -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
         -n root/interop \
c55d09
         -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
         -n root/PG_InterOp \
c55d09
         -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t pegasus \
c55d09
         -n root/cimv2\
c55d09
         -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
c55d09
 fi
c55d09
 if [ -x /usr/sbin/sfcbd ]
c55d09
 then
c55d09
-%{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
-	-n root/virt \
c55d09
-	-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
         -n root/virt \
c55d09
         -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
         -n root/interop \
c55d09
         -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
+    %{_datadir}/%{name}/provider-register.sh -t sfcb \
c55d09
         -n root/cimv2\
c55d09
         -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
c55d09
 fi
c55d09
 
c55d09
 %preun
c55d09
-if [ -x /usr/sbin/cimserver ]
c55d09
+# The uninstall scriptlets are called after the install scriptlets
c55d09
+# in the upgrade case. Therefore we must only deregister the providers
c55d09
+# when $1 == 0 (final remove).
c55d09
+if [ $1 -eq 0 ]
c55d09
 then
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
-	-n root/virt \
c55d09
-	-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
-	-n root/interop \
c55d09
-	-r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
-	-n root/PG_InterOp \
c55d09
-	-r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
-	-n root/cimv2 \
c55d09
-	-r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
c55d09
-fi
c55d09
-if [ -x /usr/sbin/sfcbd ]
c55d09
-then
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
-	-n root/virt \
c55d09
-	-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
-	-n root/interop \
c55d09
-	-r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
c55d09
-%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
-	-n root/cimv2 \
c55d09
-	-r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
c55d09
+    if [ -x /usr/sbin/cimserver ]
c55d09
+    then
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+	    -n root/virt \
c55d09
+	    -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+	    -n root/interop \
c55d09
+	    -r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+	    -n root/PG_InterOp \
c55d09
+	    -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
c55d09
+	    -n root/cimv2 \
c55d09
+	    -r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
c55d09
+    fi
c55d09
+    if [ -x /usr/sbin/sfcbd ]
c55d09
+    then
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
+	    -n root/virt \
c55d09
+	    -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
+	    -n root/interop \
c55d09
+	    -r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
c55d09
+	%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
c55d09
+	    -n root/cimv2 \
c55d09
+	    -r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
c55d09
+    fi
c55d09
 fi
c55d09
 
c55d09
 %postun -p /sbin/ldconfig
c55d09
-- 
c55d09
1.8.5.3
c55d09