[yum-commits] Branch 'yum-3_2_X' - test/simpleobsoletestests.py yum/__init__.py
James Antill
james at osuosl.org
Sat Nov 15 17:46:34 UTC 2008
test/simpleobsoletestests.py | 10 ++++++++++
yum/__init__.py | 38 +++++++++++++++++++++++++++++---------
2 files changed, 39 insertions(+), 9 deletions(-)
New commits:
commit a89961b334e4eed0d960b50cfed635619d870d7c
Author: James Antill <james at and.org>
Date: Sat Nov 15 12:46:26 2008 -0500
Add test case and fix for 471736, same as 470440 but for update not install
diff --git a/test/simpleobsoletestests.py b/test/simpleobsoletestests.py
index 9a9b5fc..8c37a83 100644
--- a/test/simpleobsoletestests.py
+++ b/test/simpleobsoletestests.py
@@ -263,6 +263,16 @@ class SimpleObsoletesTests(OperationsTests):
self.assert_(res=='ok', msg)
self.assertResult((pkgs['shark'],))
+ def testMultiObs4(self):
+ # This tests update...
+ pkgs = self._MultiObsHelper()
+ oldshark = FakePackage('shark', '0.1', '1', '0', 'noarch')
+
+ res, msg = self.runOperation(['update', 'shark'],
+ pkgs['pi'] + [oldshark], pkgs['po'])
+ self.assert_(res=='ok', msg)
+ self.assertResult((pkgs['shark'],))
+
class GitMetapackageObsoletesTests(OperationsTests):
@staticmethod
diff --git a/yum/__init__.py b/yum/__init__.py
index 86375b7..1d770f9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2382,6 +2382,15 @@ class YumBase(depsolve.Depsolve):
tx_return.extend(txmbrs)
return tx_return
+ def _find_obsoletees(self, po):
+ """ Return the pkgs. that are obsoleted by the po we pass in. """
+ for (obstup, inst_tup) in self.up.getObsoletesTuples(name=po.name,
+ arch=po.arch):
+ if po.pkgtup == obstup:
+ installed_pkg = self.rpmdb.searchPkgTuple(inst_tup)[0]
+ yield installed_pkg
+
+
def install(self, po=None, **kwargs):
"""try to mark for install the item specified. Uses provided package
object, if available. If not it uses the kwargs and gets the best
@@ -2543,13 +2552,10 @@ class YumBase(depsolve.Depsolve):
# at this point we are going to mark the pkg to be installed, make sure
# it doesn't obsolete anything. If it does, mark that in the tsInfo, too
if po.pkgtup in self.up.getObsoletesList(name=po.name, arch=po.arch):
- for (obstup, inst_tup) in self.up.getObsoletesTuples(name=po.name,
- arch=po.arch):
- if po.pkgtup == obstup:
- installed_pkg = self.rpmdb.searchPkgTuple(inst_tup)[0]
- txmbr = self.tsInfo.addObsoleting(po, installed_pkg)
- self.tsInfo.addObsoleted(installed_pkg, po)
- tx_return.append(txmbr)
+ for obsoletee in self._find_obsoletees(po):
+ txmbr = self.tsInfo.addObsoleting(po, obsoletee)
+ self.tsInfo.addObsoleted(obsoletee, po)
+ tx_return.append(txmbr)
else:
txmbr = self.tsInfo.addInstall(po)
tx_return.append(txmbr)
@@ -2707,8 +2713,11 @@ class YumBase(depsolve.Depsolve):
# check for obsoletes first
if self.conf.obsoletes:
+ print "JDBG:", instpkgs, availpkgs
for installed_pkg in instpkgs:
+ print "JDBG: inst:", installed_pkg, self.up.getObsoletesList(name=installed_pkg.name, arch=installed_pkg.arch)
for obsoleting in self.up.obsoleted_dict.get(installed_pkg.pkgtup, []):
+ print "JDBG: obs:", obsoleting
obsoleting_pkg = self.getPackageObject(obsoleting)
# FIXME check for what might be in there here
txmbr = self.tsInfo.addObsoleting(obsoleting_pkg, installed_pkg)
@@ -2731,12 +2740,23 @@ class YumBase(depsolve.Depsolve):
for installed_pkg in instpkgs:
for updating in self.up.updatesdict.get(installed_pkg.pkgtup, []):
- updating_pkg = self.getPackageObject(updating)
+ po = self.getPackageObject(updating)
if self.tsInfo.isObsoleted(installed_pkg.pkgtup):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s'),
installed_pkg.pkgtup)
+ # at this point we are going to mark the pkg to be installed, make sure
+ # it doesn't obsolete anything. If it does, mark that in the tsInfo, too
+ elif po.pkgtup in self.up.getObsoletesList(name=po.name,
+ arch=po.arch):
+ for obsoletee in self._find_obsoletees(po):
+ txmbr = self.tsInfo.addUpdate(po, installed_pkg)
+ if requiringPo:
+ txmbr.setAsDep(requiringPo)
+ self.tsInfo.addObsoleting(po, obsoletee)
+ self.tsInfo.addObsoleted(obsoletee, po)
+ tx_return.append(txmbr)
else:
- txmbr = self.tsInfo.addUpdate(updating_pkg, installed_pkg)
+ txmbr = self.tsInfo.addUpdate(po, installed_pkg)
if requiringPo:
txmbr.setAsDep(requiringPo)
tx_return.append(txmbr)
More information about the Yum-commits
mailing list