[yum-git] Branch 'yum-3_2_X' - 7 commits - cli.py test/depsolvetests.py test/simpleupdatetests.py yum/depsolve.py yum/__init__.py yum/misc.py yum/packageSack.py yum/packages.py

James Antill james at linux.duke.edu
Sun Jul 6 23:09:29 UTC 2008


 cli.py                    |    6 +++---
 test/depsolvetests.py     |    7 ++-----
 test/simpleupdatetests.py |    4 ++--
 yum/__init__.py           |   18 +++++++++++-------
 yum/depsolve.py           |    8 ++++----
 yum/misc.py               |    4 ++--
 yum/packageSack.py        |   15 +++++++--------
 yum/packages.py           |   27 +++++++++++++++++++++++++--
 8 files changed, 56 insertions(+), 33 deletions(-)

New commits:
commit 11f565a96c27ae3211492ebd3c53110701153152
Author: James Antill <james at and.org>
Date:   Sun Jul 6 19:04:19 2008 -0400

     When we are updating from foo.noarch to foo.i386/foo.x86_64 ... then
    sort the available pkgs by ._compare_providers(). This does the consistently
    corrct thing.
     Also tweak the unittests to use os.uname()[-1] instead of
    rpmutils.getBestArch().
    
     make check now passes on .i386 and .x86_64 ... wooo!

diff --git a/test/depsolvetests.py b/test/depsolvetests.py
index 3f8c748..ca80d97 100644
--- a/test/depsolvetests.py
+++ b/test/depsolvetests.py
@@ -329,7 +329,7 @@ class DepsolveTests(DepsolveTests):
         self.xsack.addPackage(xpo64)
 
         self.assertEquals('ok', *self.resolveCode())
-        if rpmUtils.arch.getBestArch() == 'x86_64':
+        if os.uname()[-1] == 'x86_64':
             self.assertResult((po, xpo64))
         else:
             self.assertResult((po, xpo))
@@ -844,10 +844,7 @@ class DepsolveTests(DepsolveTests):
         self.xsack.addPackage(po3)
 
         self.assertEquals('ok', *self.resolveCode())
-        # FIXME: This is wrong, it should be one of:
-        # self.assertResult((xpo, po3))
-        # self.assertResult((xpo, po2))
-        self.assertResult((xpo, po2, po3))
+        self.assertResult((xpo, po3))
 
     def testMultiPkgVersions4(self):
         ipo1 = FakePackage('abcd', arch='i386')
diff --git a/test/simpleupdatetests.py b/test/simpleupdatetests.py
index fe4f414..9ee7ce0 100644
--- a/test/simpleupdatetests.py
+++ b/test/simpleupdatetests.py
@@ -100,7 +100,7 @@ class SimpleUpdateTests(OperationsTests):
         p = self.pkgs
         res, msg = self.runOperation(['install', 'zsh-utils'], [p.installed_noarch], [p.update_x86_64, p.update_i386, p.requires_update])
         self.assert_(res=='ok', msg)
-        if rpmUtils.arch.getBestArch() == 'x86_64':
+        if os.uname()[-1] == 'x86_64':
             self.assertResult((p.update_x86_64, p.requires_update))
         else:
             self.assertResult((p.update_i386, p.requires_update))
@@ -108,7 +108,7 @@ class SimpleUpdateTests(OperationsTests):
         p = self.pkgs
         res, msg = self.runOperation(['install', 'zsh-utils'], [p.installed_noarch], [p.update_i386, p.update_x86_64, p.requires_update])
         self.assert_(res=='ok', msg)
-        if rpmUtils.arch.getBestArch() == 'x86_64':
+        if os.uname()[-1] == 'x86_64':
             self.assertResult((p.update_x86_64, p.requires_update))
         else:
             self.assertResult((p.update_i386, p.requires_update))
diff --git a/yum/__init__.py b/yum/__init__.py
index de7782e..ce40791 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2386,7 +2386,9 @@ class YumBase(depsolve.Depsolve):
                 availpkgs = self.pkgSack.searchNevra(name=nevra_dict['name'],
                             epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
                             ver=nevra_dict['version'], rel=nevra_dict['release'])
-
+                if len(availpkgs) > 1:
+                    availpkgs = self._compare_providers(availpkgs, requiringPo)
+                    availpkgs = map(lambda x: x[0], availpkgs)
 
        
         # for any thing specified
commit 406e48c9701c37627749017768d9b26cf335d228
Author: James Antill <james at and.org>
Date:   Sun Jul 6 19:00:36 2008 -0400

    Do much faster pkgtup lookup, when checking if "req" providers are installed

diff --git a/yum/depsolve.py b/yum/depsolve.py
index fbc6d05..cb2546b 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -432,7 +432,7 @@ class Depsolve(object):
         # get rid of things that are already in the rpmdb - b/c it's pointless to use them here
 
         for pkg in provSack.returnPackages():
-            if pkg.pkgtup in self.rpmdb.simplePkgList(): # is it already installed?
+            if self.rpmdb.contains(pkg.pkgtup): # is it already installed?
                 self.verbose_logger.log(logginglevels.DEBUG_2, _('%s is in providing packages but it is already installed, removing.'), pkg)
                 provSack.delPackage(pkg)
                 continue
commit 7362a3a800a724a9f24360c4844064b4b9cea21c
Author: James Antill <james at and.org>
Date:   Sun Jul 6 17:59:28 2008 -0400

    Fix the "make check" failures where empty sacks call returnNewestByName()

diff --git a/yum/packageSack.py b/yum/packageSack.py
index d3124e2..4bb57bf 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -376,7 +376,7 @@ class MetaSack(PackageSackBase):
         calr = self._computeAggregateListResult
         pkgs = calr("returnNewestByNameArch", naTup, patterns, ignore_case)
         pkgs = packagesNewestByNameArch(pkgs)
-        if not pkgs:
+        if not pkgs and (naTup or patterns):
             ui_pats = ", ".join(patterns or [])
             raise PackageSackError, 'No Package Matching %s' % ui_pats
         return pkgs
@@ -388,7 +388,7 @@ class MetaSack(PackageSackBase):
         pkgs = self._computeAggregateListResult("returnNewestByName", name,
                                                 patterns, ignore_case)
         pkgs = packagesNewestByName(pkgs)
-        if not pkgs:
+        if not pkgs and (name or patterns):
             if name:
                 ui_pats = name
             else:
commit 1c22c8421dbb7383f88a668a9bba91d6cb3b5940
Author: James Antill <james at and.org>
Date:   Sun Jul 6 17:52:08 2008 -0400

    Convert .EVR usage to .ver* ... stop making/destroying objects all the time.

diff --git a/cli.py b/cli.py
index b8575b9..4dc1772 100644
--- a/cli.py
+++ b/cli.py
@@ -980,17 +980,17 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         # go through each package 
         if len(comparable) > 0:
             for instpo in comparable:
-                if pkg.EVR > instpo.EVR: # we're newer - this is an update, pass to them
+                if pkg.verGT(instpo): # we're newer - this is an update, pass to them
                     if instpo.name in exactarchlist:
                         if pkg.arch == instpo.arch:
                             return True
                     else:
                         return True
                         
-                elif pkg.EVR == instpo.EVR: # same, ignore
+                elif pkg.verEQ(instpo): # same, ignore
                     return False
                     
-                elif pkg.EVR < instpo.EVR: # lesser, check if the pkgtup is an exactmatch
+                elif pkg.verLT(instpo): # lesser, check if the pkgtup is an exactmatch
                                    # if so then add it to be installed
                                    # if it can be multiply installed
                                    # this is where we could handle setting 
diff --git a/yum/__init__.py b/yum/__init__.py
index 0f24467..de7782e 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2471,7 +2471,7 @@ class YumBase(depsolve.Depsolve):
             #        most likely correct
             pot_updated = self.rpmdb.searchNevra(name=available_pkg.name, arch=available_pkg.arch)
             for ipkg in pot_updated:
-                if ipkg.EVR < available_pkg.EVR:
+                if ipkg.verLT(available_pkg):
                     txmbr = self.tsInfo.addUpdate(available_pkg, ipkg)
                     if requiringPo:
                         txmbr.setAsDep(requiringPo)
@@ -2583,7 +2583,7 @@ class YumBase(depsolve.Depsolve):
                 installpkgs.append(po)
 
         for installed_pkg in installedByKey:
-            if po.EVR > installed_pkg.EVR: # we're newer - this is an update, pass to them
+            if po.verGT(installed_pkg): # we're newer - this is an update, pass to them
                 if installed_pkg.name in self.conf.exactarchlist:
                     if po.arch == installed_pkg.arch:
                         updatepkgs.append((po, installed_pkg))
@@ -2591,7 +2591,7 @@ class YumBase(depsolve.Depsolve):
                         donothingpkgs.append(po)
                 else:
                     updatepkgs.append((po, installed_pkg))
-            elif po.EVR == installed_pkg.EVR:
+            elif po.verEQ(installed_pkg):
                 if (po.arch != installed_pkg.arch and
                     (rpmUtils.arch.isMultiLibArch(po.arch) or
                      rpmUtils.arch.isMultiLibArch(installed_pkg.arch))):
diff --git a/yum/depsolve.py b/yum/depsolve.py
index dad4912..fbc6d05 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -447,18 +447,18 @@ class Depsolve(object):
                 # from ts
                 tspkgs = self.tsInfo.matchNaevr(name=pkg.name, arch=pkg.arch)
                 for tspkg in tspkgs:
-                    if tspkg.po.EVR > pkg.EVR:
+                    if tspkg.po.verGT(pkg):
                         msg = _('Potential resolving package %s has newer instance in ts.') % pkg
                         self.verbose_logger.log(logginglevels.DEBUG_2, msg)
                         provSack.delPackage(pkg)
                         continue
-                    elif tspkg.po.EVR < pkg.EVR:
+                    elif tspkg.po.verLT(pkg):
                         upgraded.setdefault(pkg.pkgtup, []).append(tspkg.pkgtup)
                 
                 # from rpmdb
                 dbpkgs = self.rpmdb.searchNevra(name=pkg.name, arch=pkg.arch)
                 for dbpkg in dbpkgs:
-                    if dbpkg.EVR > pkg.EVR:
+                    if dbpkg.verGT(pkg):
                         msg = _('Potential resolving package %s has newer instance installed.') % pkg
                         self.verbose_logger.log(logginglevels.DEBUG_2, msg)
                         provSack.delPackage(pkg)
diff --git a/yum/misc.py b/yum/misc.py
index cc7221b..5a59ee4 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -388,10 +388,10 @@ def newestInList(pkgs):
     ret = [ pkgs.pop() ]
     newest = ret[0]
     for pkg in pkgs:
-        if pkg.EVR > newest.EVR:
+        if pkg.verGT(newest):
             ret = [ pkg ]
             newest = pkg
-        elif pkg.EVR == newest.EVR:
+        elif pkg.verEQ(newest):
             ret.append(pkg)
     return ret
 
diff --git a/yum/packageSack.py b/yum/packageSack.py
index b0e2a10..d3124e2 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -775,7 +775,7 @@ class PackageSack(PackageSackBase):
                 highdict[(pkg.name, pkg.arch)] = pkg
             else:
                 pkg2 = highdict[(pkg.name, pkg.arch)]
-                if pkg.EVR > pkg2.EVR:
+                if pkg.verGT(pkg2):
                     highdict[(pkg.name, pkg.arch)] = pkg
         
         if naTup:
@@ -798,9 +798,9 @@ class PackageSack(PackageSackBase):
                 highdict[pkg.name].append(pkg)
             else:
                 pkg2 = highdict[pkg.name][0]
-                if pkg.EVR > pkg2.EVR:
+                if pkg.verGT(pkg2):
                     highdict[pkg.name] = [pkg]
-                if pkg.EVR == pkg2.EVR:
+                if pkg.verEQ(pkg2):
                     highdict[pkg.name].append(pkg)
                 
         if name:
commit fafcdca0b103134b66efc0758872c631726b3653
Author: James Antill <james at and.org>
Date:   Sun Jul 6 17:45:23 2008 -0400

    Move from comparing version data in pkgs with __cmp__ to using verCMP/etc.

diff --git a/yum/__init__.py b/yum/__init__.py
index e10a80c..0f24467 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1414,7 +1414,7 @@ class YumBase(depsolve.Depsolve):
                         available.append(pkg)
                 else:
                     ipkgs = self.rpmdb.searchNevra(pkg.name, arch=pkg.arch)
-                    if not ipkgs or pkg > sorted(ipkgs, reverse=True)[0]:
+                    if not ipkgs or pkg.verGT(sorted(ipkgs, reverse=True)[0]):
                         available.append(pkg)
 
 
diff --git a/yum/packageSack.py b/yum/packageSack.py
index 75b883d..b0e2a10 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -23,7 +23,6 @@ import warnings
 import re
 import fnmatch
 import misc
-import packages
 
 class PackageSackBase(object):
     """Base class that provides the interface for PackageSacks."""
@@ -861,7 +860,7 @@ def packagesNewestByName(pkgs):
         # Can't use pkg.__cmp__ because it takes .arch into account
         cval = 1
         if key in newest:
-            cval = packages.comparePoEVR(pkg, newest[key][0])
+            cval = pkg.verCMP(newest[key][0])
         if cval > 0:
             newest[key] = [pkg]
         elif cval == 0:
@@ -875,7 +874,7 @@ def packagesNewestByNameArch(pkgs):
     newest = {}
     for pkg in pkgs:
         key = (pkg.name, pkg.arch)
-        if key in newest and pkg <= newest[key]:
+        if key in newest and pkg.verLE(newest[key]):
             continue
         newest[key] = pkg
     return newest.values()
commit 90d6fcab18952b36790be737526164c165b6ac53
Author: James Antill <james at and.org>
Date:   Sun Jul 6 17:40:28 2008 -0400

    Unicode fix for GPG key imports, bug#454163

diff --git a/yum/__init__.py b/yum/__init__.py
index d2d48db..e10a80c 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2718,7 +2718,7 @@ class YumBase(depsolve.Depsolve):
                 rawkey = urlgrabber.urlread(keyurl, limit=9999)
             except urlgrabber.grabber.URLGrabError, e:
                 raise Errors.YumBaseError(_('GPG key retrieval failed: ') +
-                                          unicode(str(e), 'UTF-8', 'replace'))
+                                          to_unicode(str(e)))
 
             # Parse the key
             keys_info = misc.getgpgkeyinfo(rawkey, multiple=True)
@@ -2742,7 +2742,9 @@ class YumBase(depsolve.Depsolve):
                     continue
 
                 # Try installing/updating GPG key
-                self.logger.critical(_('Importing GPG key 0x%s "%s" from %s') % (hexkeyid, userid, keyurl.replace("file://","")))
+                self.logger.critical(_('Importing GPG key 0x%s "%s" from %s') %
+                                     (hexkeyid, to_unicode(userid),
+                                      keyurl.replace("file://","")))
                 rc = False
                 if self.conf.assumeyes:
                     rc = True
commit c7c70148876d770a43ca1b22cbc93da1428912d2
Author: James Antill <james at and.org>
Date:   Fri Jul 4 00:50:24 2008 -0400

    Add versioned only comparison functions to the base package object

diff --git a/yum/packages.py b/yum/packages.py
index 169f30f..527b4a5 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -188,17 +188,40 @@ class PackageObject(object):
                                       self.arch)
         return out
 
-    def __cmp__(self, other):
-        """ Compare packages. """
+    def verCMP(self, other):
+        """ Compare package to another one, only rpm-version ordering. """
         if not other:
             return 1
         ret = cmp(self.name, other.name)
         if ret == 0:
             ret = comparePoEVR(self, other)
+        return ret
+
+    def __cmp__(self, other):
+        """ Compare packages, this is just for UI/consistency. """
+        ret = self.verCMP(other)
         if ret == 0:
             ret = cmp(self.arch, other.arch)
+        if ret == 0 and hasattr(self, 'repoid') and hasattr(other, 'repoid'):
+            ret = cmp(self.repoid, other.repoid)
         return ret
 
+    def verEQ(self, other):
+        """ Uses verCMP, tests if the _rpm-versions_ are the same. """
+        return self.verCMP(other) == 0
+    def verLT(self, other):
+        """ Uses verCMP, tests if the other _rpm-version_ is <  ours. """
+        return self.verCMP(other) <  0
+    def verLE(self, other):
+        """ Uses verCMP, tests if the other _rpm-version_ is <= ours. """
+        return self.verCMP(other) <= 0
+    def verGT(self, other):
+        """ Uses verCMP, tests if the other _rpm-version_ is >  ours. """
+        return self.verCMP(other) >  0
+    def verGE(self, other):
+        """ Uses verCMP, tests if the other _rpm-version_ is >= ours. """
+        return self.verCMP(other) >= 0
+
     def __repr__(self):
         return "<%s : %s (%s)>" % (self.__class__.__name__, str(self),hex(id(self))) 
 



More information about the Yum-cvs-commits mailing list