Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > e53c27ce7a27944d2cee0a028d0ccfc9 > files > 11

yum-3.2.22-37.sl.src.rpm

commit bbddbbfc24156b17f263c4efea8ffece5595b1a6
Author: James Antill <james@and.org>
Date:   Tue May 18 15:19:54 2010 -0400

    Add testcase for obsoletes of to be installed pkgs. -- 593349

diff --git a/test/simpleobsoletestests.py b/test/simpleobsoletestests.py
index cf1821f..091e3a4 100644
--- a/test/simpleobsoletestests.py
+++ b/test/simpleobsoletestests.py
@@ -157,11 +157,27 @@ class SimpleObsoletesTests(OperationsTests):
         self.assert_(res=='ok', msg)
         self.assertResult((p.obsoletes_x86_64, p.requires_obsoletes))
 
-    def testObsoletex86_64ToMultiarch(self):
+    def testObsoletex86_64ToMultiarch1(self):
         p = self.pkgs
         res, msg = self.runOperation(['update'], [p.installed_x86_64], [p.obsoletes_i386, p.obsoletes_x86_64])
         self.assert_(res=='ok', msg)
         self.assertResult((p.obsoletes_x86_64,))
+    def testObsoletex86_64ToMultiarch2(self):
+        p = self.pkgs
+        res, msg = self.runOperation(['update'], [p.installed_x86_64], [p.obsoletes_x86_64, p.obsoletes_i386])
+        self.assert_(res=='ok', msg)
+        self.assertResult((p.obsoletes_x86_64,))
+    def testInstallObsoletex86_64ToMultiarch1(self):
+        # Found by BZ 593349, libgfortran43/44
+        p = self.pkgs
+        res, msg = self.runOperation(['install', 'zsh.x86_64'], [], [p.installed_x86_64, p.installed_i386, p.obsoletes_x86_64, p.obsoletes_i386])
+        self.assert_(res=='ok', msg)
+        self.assertResult((p.obsoletes_x86_64,))
+    def testInstallObsoletex86_64ToMultiarch2(self):
+        p = self.pkgs
+        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 testObsoletex86_64ToMultiarchForDependency(self):
         p = self.pkgs
         res, msg = self.runOperation(['install', 'superzippy'],
commit 0408550d397b266840eb84e1c856ed8830586952
Author: James Antill <james@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 thispkgobsdict.has_key(po.pkgtup):
-            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
commit 594a58bb622bc171782e9d0ec2943070507a6c79
Author: James Antill <james@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 9a2fa66d899c8c2cd0a91d7dfc61a26cd01bc382
Author: James Antill <james@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 rpmsack
 import rpmUtils.updates
 import rpmUtils.arch
-from rpmUtils.arch import getCanonArch, archDifference, canCoinstall
+from rpmUtils.arch import getCanonArch, archDifference, canCoinstall, 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(rpmUtils.arch.getBestArch(), a1, a2)
+                    return ret
+                obsoleting.sort(_sort_arch)
             obsoleting = obsoleting[0]
             obsoleting_pkg = self.getPackageObject(obsoleting)
             return obsoleting_pkg