c9b571e
commit 32f39d67971f1bd6dbf4b559a8f95e8712edccf8
c9b571e
Author: Richard Hughes <richard@hughsie.com>
c9b571e
Date:   Thu Oct 30 16:22:47 2008 +0000
c9b571e
c9b571e
    bugfix: yum: fix getting distibution upgrade information when we have multiple repos providing preupgrade. Fixes rh#469172
c9b571e
c9b571e
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
c9b571e
index 9a75200..85cf4da 100755
c9b571e
--- a/backends/yum/yumBackend.py
c9b571e
+++ b/backends/yum/yumBackend.py
c9b571e
@@ -1657,15 +1657,17 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
c9b571e
         pkgs = self.yumbase.rpmdb.searchNevra(name='preupgrade')
c9b571e
         if len(pkgs) == 0:
c9b571e
             #install preupgrade
c9b571e
-            pkgs = self.yumbase.pkgSack.searchNevra(name='preupgrade')
c9b571e
+            pkgs = self.yumbase.pkgSack.returnNewestByName(name='preupgrade')
c9b571e
             if len(pkgs) == 0:
c9b571e
                 self.error(ERROR_PACKAGE_NOT_FOUND, "Could not find upgrade preupgrade package in any enabled repos")
c9b571e
-            elif len(pkgs) == 1:
c9b571e
-                txmbr = self.yumbase.install(po=pkgs[0])
c9b571e
-                if txmbr:
c9b571e
-                    self._runYumTransaction()
c9b571e
+            # we can have more than one result if the package is in multiple repos, for example
c9b571e
+            # a machine with i386 _and_ x86_64 configured.
c9b571e
+            # in this case, just pick the first entry as they are both noarch
c9b571e
+            txmbr = self.yumbase.install(po=pkgs[0])
c9b571e
+            if txmbr:
c9b571e
+                self._runYumTransaction()
c9b571e
             else:
c9b571e
-                self.error(ERROR_INTERNAL_ERROR, "not one update possibility")
c9b571e
+                self.error(ERROR_INTERNAL_ERROR, "could not install preupgrade as no transaction")
c9b571e
         elif len(pkgs) == 1:
c9b571e
             # check if there are any updates to the preupgrade package
c9b571e
             po = pkgs[0]