[yum-git] Branch 'yum-3_2_X' - 3 commits - output.py test/depsolvetests.py yum/__init__.py

James Antill james at linux.duke.edu
Mon Aug 11 05:15:13 UTC 2008


 output.py             |   14 +++++++++++--
 test/depsolvetests.py |   39 +++++++++++++++++++++++++++++++++++++
 yum/__init__.py       |   52 ++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 91 insertions(+), 14 deletions(-)

New commits:
commit 456d18d98e10c9414f3a664b57c3d5d7a64b51f4
Author: James Antill <james at and.org>
Date:   Mon Aug 11 01:13:25 2008 -0400

    Turn on fix for test_min_up_and_dep[12] and add fix for test_min_up_and_dep3

diff --git a/test/depsolvetests.py b/test/depsolvetests.py
index a0fc9bc..4a3dad5 100644
--- a/test/depsolvetests.py
+++ b/test/depsolvetests.py
@@ -989,6 +989,45 @@ class DepsolveTests(DepsolveTests):
         self.assertEquals('ok', *self.resolveCode())
         self.assertResult((ipo2, po4))
 
+    def test_min_up_and_dep3(self):
+        rpo1 = FakePackage('bar', version='1')
+        self.rpmdb.addPackage(rpo1)
+        rpo2 = FakePackage('bar-blah', version='1')
+        rpo2.addRequires('bar', 'EQ', ('0', '1', '1'))
+        self.rpmdb.addPackage(rpo2)
+
+        ipo1 = FakePackage('bar', version='2')
+        self.tsInfo.addUpdate(ipo1, oldpo=rpo1)
+        ipo2 = FakePackage('bar-blah', version='2')
+        ipo2.addRequires('bar', 'EQ', ('0', '2', '1'))
+        self.tsInfo.addUpdate(ipo2, oldpo=rpo2)
+
+        ipo3 = FakePackage('foo')
+        ipo3.addRequires('bar', 'GE', (None, '3', '0'))
+        self.tsInfo.addInstall(ipo3)
+
+        po1 = FakePackage('foo')
+        po1.addRequires('bar', 'GE', (None, '3', '0'))
+        self.xsack.addPackage(po1)
+        po2 = FakePackage('bar', version='2')
+        self.xsack.addPackage(po2)
+        po3 = FakePackage('bar', version='3')
+        self.xsack.addPackage(po3)
+        po4 = FakePackage('bar', version='4')
+        self.xsack.addPackage(po4)
+        po5 = FakePackage('bar-blah', version='2')
+        po5.addRequires('bar', 'EQ', ('0', '2', '1'))
+        self.xsack.addPackage(po5)
+        po6 = FakePackage('bar-blah', version='3')
+        po6.addRequires('bar', 'EQ', ('0', '3', '1'))
+        self.xsack.addPackage(po6)
+        po7 = FakePackage('bar-blah', version='4')
+        po7.addRequires('bar', 'EQ', ('0', '4', '1'))
+        self.xsack.addPackage(po7)
+
+        self.assertEquals('ok', *self.resolveCode())
+        self.assertResult((ipo3, po4, po7))
+
     def test_multi_inst_dep1(self):
         ipo1 = FakePackage('foo')
         ipo1.addRequires('bar-prov1', None, (None, None, None))
diff --git a/yum/__init__.py b/yum/__init__.py
index 8508b44..7facdd6 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2386,16 +2386,29 @@ class YumBase(depsolve.Depsolve):
         
         return tx_return
 
+    def _check_new_update_provides(self, opkg, npkg):
+        """ Check for any difference in the provides of the old and new update
+            that is needed by the transaction. If so we "update" those pkgs
+            too, to the latest version. """
+        oprovs = set(opkg.returnPrco('provides'))
+        nprovs = set(npkg.returnPrco('provides'))
+        for prov in oprovs.difference(nprovs):
+            reqs = self.tsInfo.getRequires(*prov)
+            for pkg in reqs:
+                for req in reqs[pkg]:
+                    if not npkg.inPrcoRange('provides', req):
+                        naTup = (pkg.name, pkg.arch)
+                        for pkg in self.pkgSack.returnNewestByNameArch(naTup):
+                            self.update(po=pkg)
+                        break
+
     def _newer_update_in_trans(self, pkgtup, available_pkg):
         """ We return True if there is a newer package already in the
-            transaction. If there is an older one, we remove it and return
-            False so we'll goto this available one. """
+            transaction. If there is an older one, we remove it (and update any
+            deps. that aren't satisfied by the newer pkg) and return False so
+            we'll update to this newer pkg. """
         found = False
         for txmbr in self.tsInfo.getMembersWithState(pkgtup, [TS_UPDATED]):
-            if True: # FIXME: This "works" but fails related deps.
-                # Ie. update-minimal glibc pam == works
-                # Ie. update-minimal glibc glibc-common pam == hard fail
-                return True
             count = 0
             for po in txmbr.updated_by:
                 if available_pkg.verLE(po):
@@ -2403,6 +2416,8 @@ class YumBase(depsolve.Depsolve):
                 else:
                     for ntxmbr in self.tsInfo.getMembers(po.pkgtup):
                         self.tsInfo.remove(ntxmbr.po.pkgtup)
+                        self._check_new_update_provides(ntxmbr.po,
+                                                        available_pkg)
             if count:
                 found = True
             else:
commit 4d50fe27ef770d1c349c33aecc1ea21ad1105a76
Author: James Antill <james at and.org>
Date:   Mon Aug 11 00:25:17 2008 -0400

    Tweak listTransaction() output so columns are always aligned

diff --git a/output.py b/output.py
index b483389..ed4645f 100644
--- a/output.py
+++ b/output.py
@@ -632,8 +632,18 @@ class YumOutput:
                 repoid = txmbr.repoid
                 pkgsize = float(txmbr.po.size)
                 size = self.format_number(pkgsize)
-                msg = u" %-22s  %-9s  %-15s  %-16s  %5s\n" % (n, a,
-                              evr, repoid, size)
+
+                total_width = 1
+                msg = u' '
+                for (val, width) in ((n, 23), (a, 10), (evr, 16), (repoid, 17)):
+                    if len(val) <= width:
+                        msg += u"%%-%ds " % width
+                    else:
+                        msg += u"%s\n" + " " * (total_width + width + 1)
+                    total_width += width
+                    total_width += 1
+                msg += u"%5s\n"
+                msg %= (n, a, evr, repoid, size)
                 for obspo in txmbr.obsoletes:
                     appended = _('     replacing  %s.%s %s\n\n') % (obspo.name,
                         obspo.arch, obspo.printVer())
commit 7624c5b76d6c3fdee688c83caecb4b6c728f1580
Author: James Antill <james at and.org>
Date:   Mon Aug 11 00:00:05 2008 -0400

     Remove two FIXME's:
    
    . Print better messages (and don't error) for install'ing things already
    installed but unavailable.
    
    . Put a deprecation warning in getInstalledPackageObject()

diff --git a/yum/__init__.py b/yum/__init__.py
index 3e547f5..8508b44 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1969,9 +1969,8 @@ class YumBase(depsolve.Depsolve):
 
     def getInstalledPackageObject(self, pkgtup):
         """returns a YumInstallPackage object for the pkgtup specified"""
-        
-        #FIXME - this should probably emit a deprecation warning telling
-        # people to just use the command below
+        warnings.warn(_('getInstalledPackageObject() will go away, use self.rpmdb.searchPkgTuple().\n'),
+                Errors.YumFutureDeprecationWarning, stacklevel=2)
         
         po = self.rpmdb.searchPkgTuple(pkgtup)[0] # take the first one
         return po
@@ -2320,9 +2319,21 @@ class YumBase(depsolve.Depsolve):
                     lst.extend(self.bestPackagesFromList(pkgs))
                 pkgs = lst
 
-        if len(pkgs) == 0:
-            #FIXME - this is where we could check to see if it already installed
-            # for returning better errors
+        if not pkgs:
+            # Do we still want to return errors here?
+            # We don't in the cases below, so I didn't here...
+            if 'pattern' in kwargs:
+                pats = [kwargs['pattern']]
+                pkgs = self.rpmdb.returnPackages(patterns=pats)
+                exactmatch, matched, unmatched = parsePackages(pkgs, pats,
+                                                               casematch=1)
+                pkgs = exactmatch + matched
+            if 'name' in kwargs:
+                pkgs = self.rpmdb.searchNevra(name=kwargs['name'])
+            for pkg in pkgs:
+                self.verbose_logger.warning(_('Package %s installed and not available'), pkg)
+            if pkgs:
+                return []
             raise Errors.InstallError, _('No package(s) available to install')
         
         # FIXME - lots more checking here
@@ -2670,6 +2681,8 @@ class YumBase(depsolve.Depsolve):
         # if by any chance we're a noncompat arch rpm - bail and throw out an error
         # FIXME -our archlist should be stored somewhere so we don't have to
         # do this: but it's not a config file sort of thing
+        # FIXME: Should add noarch, yum localinstall works ...
+        # just rm this method?
         if po.arch not in rpmUtils.arch.getArchList():
             self.logger.critical(_('Cannot add package %s to transaction. Not a compatible architecture: %s'), pkg, po.arch)
             return tx_return



More information about the Yum-cvs-commits mailing list