Blame 0003-deployUtil.yumSearchVersion-compare-versions-sanely.patch

83b9f8f
From 67309fc8a7a4edd4996490b64f51ce37f0ed2327 Mon Sep 17 00:00:00 2001
83b9f8f
From: Dan Kenigsberg <danken@redhat.com>
83b9f8f
Date: Tue, 19 Jun 2012 00:33:22 +0300
83b9f8f
Subject: [PATCH 03/17] deployUtil.yumSearchVersion: compare versions sanely
83b9f8f
83b9f8f
Change-Id: I0aa40c3395ca012a21f148f20125b54e3ba16d8a
83b9f8f
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
83b9f8f
Reviewed-on: http://gerrit.ovirt.org/5469
83b9f8f
Reviewed-by: Mark Wu <wudxw@linux.vnet.ibm.com>
83b9f8f
Tested-by: Douglas Schilling Landgraf <dougsland@redhat.com>
83b9f8f
Reviewed-by: Douglas Schilling Landgraf <dougsland@redhat.com>
83b9f8f
Reviewed-on: http://gerrit.ovirt.org/5544
83b9f8f
Tested-by: Federico Simoncelli <fsimonce@redhat.com>
83b9f8f
Reviewed-by: Federico Simoncelli <fsimonce@redhat.com>
83b9f8f
---
83b9f8f
 vds_bootstrap/vds_bootstrap.py |    6 +++---
83b9f8f
 vdsm_reg/deployUtil.py.in      |   31 +++++++------------------------
83b9f8f
 2 files changed, 10 insertions(+), 27 deletions(-)
83b9f8f
83b9f8f
diff --git a/vds_bootstrap/vds_bootstrap.py b/vds_bootstrap/vds_bootstrap.py
83b9f8f
index 12e127e..9801459 100755
83b9f8f
--- a/vds_bootstrap/vds_bootstrap.py
83b9f8f
+++ b/vds_bootstrap/vds_bootstrap.py
83b9f8f
@@ -80,13 +80,13 @@ fedorabased = deployUtil.versionCompare(deployUtil.getOSVersion(), "16") >= 0
83b9f8f
 
83b9f8f
 if rhel6based:
83b9f8f
     VDSM_NAME = "vdsm"
83b9f8f
-    VDSM_MIN_VER = VDSM_NAME + "-4.9"
83b9f8f
+    VDSM_MIN_VER = "4.9"
83b9f8f
     KERNEL_VER = "2.6.32-.*.el6"
83b9f8f
     KERNEL_MIN_VER = 150
83b9f8f
     MINIMAL_SUPPORTED_PLATFORM = "6.0"
83b9f8f
 else:
83b9f8f
     VDSM_NAME = "vdsm22"
83b9f8f
-    VDSM_MIN_VER = VDSM_NAME + "-4.5"
83b9f8f
+    VDSM_MIN_VER = "4.5"
83b9f8f
     KERNEL_VER = "2.6.18-.*.el5"
83b9f8f
     KERNEL_MIN_VER = 159
83b9f8f
     MINIMAL_SUPPORTED_PLATFORM = "5.5"
83b9f8f
@@ -250,7 +250,7 @@ class Deploy:
83b9f8f
         rc = True
83b9f8f
 
83b9f8f
         try:
83b9f8f
-            rc = deployUtil.yumSearchVersion(VDSM_NAME, VDSM_MIN_VER, True)
83b9f8f
+            rc = deployUtil.yumSearchVersion(VDSM_NAME, VDSM_MIN_VER)
83b9f8f
         except:
83b9f8f
             rc = False
83b9f8f
             logging.error("checkMajorVersion: Error searching for VDSM version!",
83b9f8f
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
83b9f8f
index 1adf1a5..1474196 100644
83b9f8f
--- a/vdsm_reg/deployUtil.py.in
83b9f8f
+++ b/vdsm_reg/deployUtil.py.in
83b9f8f
@@ -1039,32 +1039,15 @@ def yumListPackages(pkgName):
83b9f8f
     my.preconf.debuglevel = 0 # Remove yum noise
83b9f8f
     return my.pkgSack.searchNevra(name=pkgName)
83b9f8f
 
83b9f8f
-def yumSearchVersion(pkgName, ver, startWith=True):
83b9f8f
-    """
83b9f8f
-        Returns True is package exists in yum's db with the given version.
83b9f8f
-        Note: yum internal code has verEQ and verGT. We should use it ASAP.
83b9f8f
-    """
83b9f8f
-    fReturn = False
83b9f8f
+def yumSearchVersion(pkgName, ver):
83b9f8f
+    "Return True if package exists in yum's db with the given version or higer"
83b9f8f
+    import rpmUtils.miscutils
83b9f8f
 
83b9f8f
-    pkgs = yumListPackages(pkgName)
83b9f8f
-    if pkgs:
83b9f8f
-        for item in pkgs:
83b9f8f
-            if startWith:
83b9f8f
-                if str(item).startswith(ver):
83b9f8f
-                    fReturn = True
83b9f8f
-                    logging.debug("yumSearchVersion: pkg " + str(item) + " starts with: " + ver)
83b9f8f
-                else:
83b9f8f
-                    logging.debug("yumSearchVersion: pkg " + str(item) + " does not start with: " + ver)
83b9f8f
-            else:
83b9f8f
-                if str(item) == ver:
83b9f8f
-                    fReturn = True
83b9f8f
-                    logging.debug("yumSearchVersion: pkg " + str(item) + " matches: " + ver)
83b9f8f
-                else:
83b9f8f
-                    logging.debug("yumSearchVersion: pkg " + str(item) + " does not match: " + ver)
83b9f8f
+    for pkg in yumListPackages(pkgName):
83b9f8f
+        if rpmUtils.miscutils.compareVerOnly(pkg.ver, ver) >= 0:
83b9f8f
+            return True
83b9f8f
     else:
83b9f8f
-        logging.debug("yumSearchVersion: package " + str(pkgName) + " not found!")
83b9f8f
-
83b9f8f
-    return fReturn
83b9f8f
+        return False
83b9f8f
 
83b9f8f
 #############################################################################################################
83b9f8f
 # Host PKI functions.
83b9f8f
-- 
83b9f8f
1.7.1
83b9f8f