Bug 462011

Summary: packaging script robustness -- easyfix
Product: [Fedora] Fedora Reporter: R P Herrold <herrold>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 10CC: berrange, markmc, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-01-21 05:31:15 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description R P Herrold 2008-09-11 17:52:33 EDT
Description of problem:

libvirt packaging is not robust against repeated install, deinstall, and re-installs


Problem demonstrated:

[root@centos-5 ~]# yum -y install xen-libs xen libvirt libvirt-python \
   virt-viewer python-virtinst virt-manager
   ... snip
Running Transaction
  Installing: xen-libs                     ######################### [1/9]
  Installing: libvirt                      ######################### [2/9]
ln: creating symbolic link `/etc/libvirt/qemu/networks/autostart/default.xml' to `../default.xml': File exists
  Installing: virt-viewer                  ######################### [3/9]
  Installing: xen-libs                     ######################### [4/9]
  Installing: libvirt                      ######################### [5/9]
  Installing: libvirt-python               ######################### [6/9]
  Installing: python-virtinst              ######################### [7/9]
  Installing: virt-manager                 ######################### [8/9]
  Installing: xen                          ######################### [9/9]

Installed: virt-manager.x86_64 0:0.5.3-8.el5 xen.x86_64 0:3.0.3-64.el5_2.1
Dependency Installed: libvirt.x86_64 0:0.3.3-7.el5 libvirt.i386 0:0.3.3-7.el5 libvirt-python.x86_64 0:0.3.3-7.el5 python-virtinst.noarch 0:0.300.2-8.el5 virt-viewer.x86_64 0:0.0.2-2.el5 xen-libs.i686 0:3.0.3-64.el5_2.1 xen-libs.x86_64 0:3.0.3-64.el5_2.1
Complete!


The error is in not testing for and removing any prior 'default' networking file.  As the file is not under RPM control, but rather script control, the script needs to be more robust.


Fix locus (two):

[root@centos-5 ~]# rpm -q --scripts libvirt
postinstall scriptlet (using /bin/sh):
/sbin/ldconfig

# We want to install the default network for initial RPM installs
# or on the first upgrade from a non-network aware libvirt only.
# We check this by looking to see if the daemon is already installed
/sbin/chkconfig --list libvirtd 1>/dev/null 2>&1
if [ $? != 0 ]
then
    UUID=`/usr/bin/uuidgen`
    sed -e "s,</name>,</name>\n  <uuid>$UUID</uuid>," \
         < /usr/share/libvirt/networks/default.xml \
         > /etc/libvirt/qemu/networks/default.xml
    ln -s ../default.xml /etc/libvirt/qemu/networks/autostart/default.xml

THIS LINE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fi

/sbin/chkconfig --add libvirtd
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
    /sbin/service libvirtd stop 1>/dev/null 2>&1
    /sbin/chkconfig --del libvirtd
fi
postuninstall scriptlet (using /bin/sh):
/sbin/ldconfig
postinstall scriptlet (using /bin/sh):
/sbin/ldconfig

# We want to install the default network for initial RPM installs
# or on the first upgrade from a non-network aware libvirt only.
# We check this by looking to see if the daemon is already installed
/sbin/chkconfig --list libvirtd 1>/dev/null 2>&1
if [ $? != 0 ]
then
    UUID=`/usr/bin/uuidgen`
    sed -e "s,</name>,</name>\n  <uuid>$UUID</uuid>," \
         < /usr/share/libvirt/networks/default.xml \
         > /etc/libvirt/qemu/networks/default.xml
    ln -s ../default.xml /etc/libvirt/qemu/networks/autostart/default.xml

AND THIS LINE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fi

/sbin/chkconfig --add libvirtd
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
    /sbin/service libvirtd stop 1>/dev/null 2>&1
    /sbin/chkconfig --del libvirtd
fi
postuninstall scriptlet (using /bin/sh):
/sbin/ldconfig
[root@centos-5 ~]# 


How reproducible:

as above

  
Actual results:

failed ln -s


Expected results:

success by adding a prior line at the two indicated places:

[ -e /etc/libvirt/qemu/networks/default.xml ] && \
      rm -f /etc/libvirt/qemu/networks/default.xml


results:   

Profit  !!
Comment 1 Bug Zapper 2008-11-25 22:03:13 EST
This bug appears to have been reported against 'rawhide' during the Fedora 10 development cycle.
Changing version to '10'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 2 Mark McLoughlin 2009-01-21 05:31:15 EST
Hmm, this doesn't make much sense

We only create the symlink if chkconfig --list exits non-zero

It won't do that once chkconfig --add has been called

So even when you're installing 32 bit and 64 bit versions of the library like above, you shouldn't see this warning.

Ah - that's not the issue! The problem is if you previously previously installed a version of libvirt and then removed it, the link remains and when you re-install we get the warning

herrold: thanks for the report, I've sent a patch upstream. It'll be fixed in the next release coming very soon.

http://www.redhat.com/archives/libvir-list/2009-January/msg00557.html
Comment 3 R P Herrold 2009-01-21 16:33:32 EST
my pleasure -- thanks for the commit of a fix

-- Russ herrold