[Yum-devel] [PATCH 1/2] make sure obsoletes are looked up for localinstall/updated pkgs this handles the cases where the localpkg is a proper update AND an obsolete for a different installed pkg.

Seth Vidal skvidal at fedoraproject.org
Wed Aug 12 17:25:33 UTC 2009



On Wed, 12 Aug 2009, Seth Vidal wrote:

>> unless we have a case where this is unhappy.
>
> Commented and I also tested the above with rpm and obsoleting (but not 
> conflicting) packages. both pkgs get installed with rpm -Uvh - the obsoleting 
> one alone isn't installed. I found that curious.
>
> I'll post new patches of both.
>

here's the latest:

-sv
-------------- next part --------------
diff --git a/rpmUtils/miscutils.py b/rpmUtils/miscutils.py
index f494fc3..a925027 100644
--- a/rpmUtils/miscutils.py
+++ b/rpmUtils/miscutils.py
@@ -173,8 +173,12 @@ def rangeCompare(reqtuple, provtuple):
         if reqf in ['GT', 'GE', 4, 12]:
             return 1
         if reqf in ['EQ', 8]:
-            if f in ['LE', 10]:
+            if f in ['LE', 10, 'LT', 2]:
+                return 1                
+        if reqf in ['LE', 'LT', 'EQ', 10, 2, 8]:
+            if f in ['LE', 'LT', 10, 2]:
                 return 1
+
     if rc == 0:
         if reqf in ['GT', 4]:
             if f in ['GT', 'GE', 4, 12]:
diff --git a/yum/__init__.py b/yum/__init__.py
index 9930c08..0df32a3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2586,10 +2586,18 @@ class YumBase(depsolve.Depsolve):
 
     def _find_obsoletees(self, po):
         """ Return the pkgs. that are obsoleted by the po we pass in. """
-        for (obstup, inst_tup) in self.up.getObsoletersTuples(name=po.name):
-            if po.pkgtup == obstup:
-                installed_pkg =  self.rpmdb.searchPkgTuple(inst_tup)[0]
-                yield installed_pkg
+        if not isinstance(po, YumLocalPackage):
+            for (obstup, inst_tup) in self.up.getObsoletersTuples(name=po.name):
+                if po.pkgtup == obstup:
+                    installed_pkg =  self.rpmdb.searchPkgTuple(inst_tup)[0]
+                    yield installed_pkg
+        else:
+            for (obs_n, obs_f, (obs_e, obs_v, obs_r)) in po.obsoletes:
+                for pkg in self.rpmdb.searchNevra(name=obs_n):
+                    installedtup = (pkg.name, 'EQ', (pkg.epoch, 
+                                   pkg.ver, pkg.release))
+                    if po.inPrcoRange('obsoletes', installedtup):
+                        yield pkg
 
     def _add_prob_flags(self, *flags):
         """ Add all of the passed flags to the tsInfo.probFilterFlags array. """
@@ -3139,7 +3147,6 @@ class YumBase(depsolve.Depsolve):
         # append it to self.localPackages
         # check if it can be installed or updated based on nevra versus rpmdb
         # don't import the repos until we absolutely need them for depsolving
-
         tx_return = []
         installpkgs = []
         updatepkgs = []
@@ -3222,7 +3229,20 @@ class YumBase(depsolve.Depsolve):
         for po in donothingpkgs:
             self.verbose_logger.log(logginglevels.INFO_2,
                 _('%s: does not update installed package.'), po.localpath)
-
+        
+        # this checks to make sure that any of the to-be-installed pkgs
+        # does not obsolete something else that's installed
+        # this doesn't handle the localpkgs obsoleting EACH OTHER or
+        # anything else in the transaction set, though. That could/should
+        # be fixed later but a fair bit of that is a pebkac and should be
+        # said as "don't do that". potential 'fixme'
+        for txmbr in tx_return:
+            if txmbr.po.obsoletes:
+                for obs_pkg in self._find_obsoletees(txmbr.po):
+                    self.tsInfo.addObsoleted(obs_pkg, txmbr.po)
+                    txmbr.obsoletes.append(obs_pkg)
+                    self.tsInfo.addObsoleting(txmbr.po,obs_pkg)
+                
         return tx_return
 
     def reinstallLocal(self, pkg, po=None):


More information about the Yum-devel mailing list