Browse code

uninstall libvirt-python and reinstall

libvirt-python compiles against the currently installed libvirt. If
you upgrade that, it needs to rebuild, however it won't change
versions, so pip install just noops. Force an uninstall / reinstall of
it every time to handle potential upgrades of libvirt.

Change-Id: If34541b34aa6d55eedaf6c603fd1fe92eb887308

Sean Dague authored on 2017/05/08 11:02:10
Showing 2 changed files
... ...
@@ -351,6 +351,20 @@ function pip_install {
351 351
     return $result
352 352
 }
353 353
 
354
+function pip_uninstall {
355
+    local name=$1
356
+    if [[ -n ${PIP_VIRTUAL_ENV:=} && -d ${PIP_VIRTUAL_ENV} ]]; then
357
+        local cmd_pip=$PIP_VIRTUAL_ENV/bin/pip
358
+        local sudo_pip="env"
359
+    else
360
+        local cmd_pip
361
+        cmd_pip=$(get_pip_command $PYTHON2_VERSION)
362
+        local sudo_pip="sudo -H"
363
+    fi
364
+    # don't error if we can't uninstall, it might not be there
365
+    $sudo_pip $cmd_pip uninstall $name || /bin/true
366
+}
367
+
354 368
 # get version of a package from global requirements file
355 369
 # get_from_global_requirements <package>
356 370
 function get_from_global_requirements {
... ...
@@ -67,6 +67,8 @@ function install_libvirt {
67 67
         else
68 68
             install_package libvirt-clients libvirt-daemon-system libvirt-dev
69 69
         fi
70
+        # uninstall in case the libvirt version changed
71
+        pip_uninstall libvirt-python
70 72
         pip_install_gr libvirt-python
71 73
         #pip_install_gr <there-si-no-guestfs-in-pypi>
72 74
     elif is_fedora || is_suse; then
... ...
@@ -84,6 +86,7 @@ function install_libvirt {
84 84
         fi
85 85
 
86 86
         install_package libvirt libvirt-devel
87
+        pip_uninstall libvirt-python
87 88
         pip_install_gr libvirt-python
88 89
     fi
89 90