Blob Blame History Raw
diff --git a/yum/depsolve.py b/yum/depsolve.py
index d8e3ecc6..046623d1 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -1436,6 +1436,14 @@ class Depsolve(object):
                 return False
             return x.sourcerpm == y.sourcerpm
 
+        def _conflict_req(x, y):
+            if y is None:
+                return False
+            for ydep in y.conflicts:
+                if x.checkPrco('provides', ydep):
+                    return True
+            return False
+
         def _compare_arch_distance(x, y, req_compare_arch):
             # take X and Y package objects
             # determine which has a closer archdistance to compare_arch
@@ -1488,15 +1496,9 @@ class Depsolve(object):
                 continue
             unique_nevra_pkgs[pkg.pkgtup] = pkg
         pkgs = unique_nevra_pkgs.values()
-
-        # Do a conflict filtering; get rid of those pkgs that reqpo conflicts
-        # with
-        if reqpo is not None:
-            pkgs = [pkg for pkg in pkgs
-                        if not any(pkg.checkPrco('provides', conflict)
-                                   for conflict in reqpo.conflicts)]
             
         pkgresults = {}
+        penalize = set()
 
         for pkg in pkgs:
             pkgresults[pkg] = 0
@@ -1602,6 +1604,10 @@ class Depsolve(object):
                 self.verbose_logger.log(logginglevels.DEBUG_4,
                     _('common sourcerpm %s and %s' % (po, reqpo)))
                 pkgresults[po] += 20
+            if _conflict_req(po, reqpo):
+                self.verbose_logger.log(logginglevels.DEBUG_4,
+                    _('conflict req %s and %s' % (po, reqpo)))
+                penalize.add(po)
             if self.isPackageInstalled(po.base_package_name):
                 self.verbose_logger.log(logginglevels.DEBUG_4,
                     _('base package %s is installed for %s' % (po.base_package_name, po)))
@@ -1686,6 +1692,13 @@ class Depsolve(object):
             pkgresults[po] += 1000
             pkgresults[po] += (len(po.name)*-1)
 
+        # Bump down any packages that we identified as "last-resort" in such a
+        # way that they all score below the worst overall score whilst keeping
+        # their relative differences.
+        shift = max(pkgresults.values()) - min(pkgresults.values()) + 1
+        for po in penalize:
+            pkgresults[po] -= shift
+
         bestorder = sorted(pkgresults.items(),
                            key=lambda x: (x[1], x[0]), reverse=True)
         self.verbose_logger.log(logginglevels.DEBUG_4,