Skip to content

Commit

Permalink
depsolve: penalize conflicting providers (v2). BZ 1713649
Browse files Browse the repository at this point in the history
This is a corrected version of my original patch (commit ae2d51b).

For technical details and motivations, please see that other commit's
message.
  • Loading branch information
dmnks committed Feb 12, 2020
1 parent 8483bc7 commit b6ff909
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions yum/depsolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,14 @@ def _info_req(x, y):
return True
return False

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
Expand Down Expand Up @@ -1558,6 +1566,7 @@ def _pkg2prov_version(pkg, provname):
pkgs = unique_nevra_pkgs.values()

pkgresults = {}
penalize = set()

for pkg in pkgs:
pkgresults[pkg] = 0
Expand Down Expand Up @@ -1671,6 +1680,10 @@ def _pkg2prov_version(pkg, provname):
self.verbose_logger.log(logginglevels.DEBUG_4,
_('informational req %s and %s' % (po, reqpo)))
pkgresults[po] += 333
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)))
Expand Down Expand Up @@ -1755,6 +1768,13 @@ def _pkg2prov_version(pkg, provname):
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,
Expand Down

0 comments on commit b6ff909

Please sign in to comment.