[yum-commits] Branch 'yum-3_2_X' - 3 commits - test/simpleobsoletestests.py yum/__init__.py
James Antill
james at osuosl.org
Wed May 19 03:35:40 UTC 2010
test/simpleobsoletestests.py | 5 ++++
yum/__init__.py | 47 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 50 insertions(+), 2 deletions(-)
New commits:
commit 9a2fa66d899c8c2cd0a91d7dfc61a26cd01bc382
Author: James Antill <james at and.org>
Date: Tue May 18 16:54:32 2010 -0400
Fix obsoleting pkgs. from <install norach> to multilib. using archdistance
diff --git a/yum/__init__.py b/yum/__init__.py
index f5f2b51..773b433 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -41,7 +41,8 @@ from config import ParsingError, ConfigParser
import Errors
import rpmsack
import rpmUtils.updates
-from rpmUtils.arch import canCoinstall, ArchStorage, isMultiLibArch
+from rpmUtils.arch import archDifference, canCoinstall, ArchStorage, isMultiLibArch
+from rpmUtils.miscutils import compareEVR
import rpmUtils.transaction
import comps
import pkgtag_db
@@ -2890,9 +2891,40 @@ class YumBase(depsolve.Depsolve):
oobsoleting.append(opkgtup)
if oobsoleting:
obsoleting = oobsoleting
- # NOTE: if we move from noarch => multilib. then the ordering
- # here seems to always prefer i386 over x86_64 which is wrong.
- # Need to sort by arch?
+ if len(obsoleting) > 1:
+ # Pick the first name, and run with it...
+ first = obsoleting[0]
+ obsoleting = [pkgtup for pkgtup in obsoleting
+ if first[0] == pkgtup[0]]
+ if len(obsoleting) > 1:
+ # Lock to the latest version...
+ def _sort_ver(x, y):
+ n1,a1,e1,v1,r1 = x
+ n2,a2,e2,v2,r2 = y
+ return compareEVR((e1,v1,r1), (e2,v2,r2))
+ obsoleting.sort(_sort_ver)
+ first = obsoleting[0]
+ obsoleting = [pkgtup for pkgtup in obsoleting
+ if not _sort_ver(first, pkgtup)]
+ if len(obsoleting) > 1:
+ # Now do arch distance (see depsolve:compare_providers)...
+ def _sort_arch_i(carch, a1, a2):
+ res1 = archDifference(carch, a1)
+ if not res1:
+ return 0
+ res2 = archDifference(carch, a2)
+ if not res2:
+ return 0
+ return res1 - res2
+ def _sort_arch(x, y):
+ n1,a1,e1,v1,r1 = x
+ n2,a2,e2,v2,r2 = y
+ ret = _sort_arch_i(po.arch, a1, a2)
+ if ret:
+ return ret
+ ret = _sort_arch_i(self.arch.bestarch, a1, a2)
+ return ret
+ obsoleting.sort(_sort_arch)
obsoleting = obsoleting[0]
obsoleting_pkg = self.getPackageObject(obsoleting)
return obsoleting_pkg
commit 594a58bb622bc171782e9d0ec2943070507a6c79
Author: James Antill <james at and.org>
Date: Tue May 18 16:54:08 2010 -0400
Now do the same testcase for noarch => multilib
diff --git a/test/simpleobsoletestests.py b/test/simpleobsoletestests.py
index 091e3a4..dfaa7e5 100644
--- a/test/simpleobsoletestests.py
+++ b/test/simpleobsoletestests.py
@@ -178,6 +178,11 @@ class SimpleObsoletesTests(OperationsTests):
res, msg = self.runOperation(['install', 'zsh.i386'], [], [p.installed_x86_64, p.installed_i386, p.obsoletes_x86_64, p.obsoletes_i386])
self.assert_(res=='ok', msg)
self.assertResult((p.obsoletes_i386,))
+ def testInstallObsoletex86_64ToMultiarch3(self):
+ p = self.pkgs
+ res, msg = self.runOperation(['install', 'zsh'], [], [p.installed_noarch, p.obsoletes_x86_64, p.obsoletes_i386])
+ self.assert_(res=='ok', msg)
+ self.assertResult((p.obsoletes_x86_64,))
def testObsoletex86_64ToMultiarchForDependency(self):
p = self.pkgs
res, msg = self.runOperation(['install', 'superzippy'],
commit 0408550d397b266840eb84e1c856ed8830586952
Author: James Antill <james at and.org>
Date: Tue May 18 16:17:18 2010 -0400
Fix for obsoleting pkgs. we are trying to install
diff --git a/yum/__init__.py b/yum/__init__.py
index 612b6ab..f5f2b51 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2882,7 +2882,18 @@ class YumBase(depsolve.Depsolve):
we should install instead. Or None if there isn't one. """
thispkgobsdict = self.up.checkForObsolete([po.pkgtup])
if po.pkgtup in thispkgobsdict:
- obsoleting = thispkgobsdict[po.pkgtup][0]
+ obsoleting = thispkgobsdict[po.pkgtup]
+ oobsoleting = []
+ # We want to keep the arch. of the obsoleted pkg. if possible.
+ for opkgtup in obsoleting:
+ if not canCoinstall(po.arch, opkgtup[1]):
+ oobsoleting.append(opkgtup)
+ if oobsoleting:
+ obsoleting = oobsoleting
+ # NOTE: if we move from noarch => multilib. then the ordering
+ # here seems to always prefer i386 over x86_64 which is wrong.
+ # Need to sort by arch?
+ obsoleting = obsoleting[0]
obsoleting_pkg = self.getPackageObject(obsoleting)
return obsoleting_pkg
return None
More information about the Yum-commits
mailing list