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

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