Blame SOURCES/BZ-1713649-depsolve-every-provider-conflicts.patch

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