You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

210 lines
8.1 KiB

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