Work around dnf problem with multiple repos

If a package is in multiple repos dnf may return more than 1 of them
when using best...glob so we pick the highest NEVRA one and install
that.

Related: rhbz#1636239
This commit is contained in:
Brian C. Lane 2018-10-05 09:44:16 -07:00
parent 8f1bc6e882
commit f24f84282d

View File

@ -210,13 +210,13 @@ def _depsolve(dbo, projects, groups):
try: try:
if not version: if not version:
version = "*" version = "*"
pkgs = [pkg for pkg in dnf.subject.Subject(name).get_best_query(dbo.sack).filter(version__glob=version, latest=True)] # Find the best package matching the name + version glob
if not pkgs: # dnf can return multiple packages if it is in more than 1 repository, so use max() to select one of them
pkg = max([pkg for pkg in dnf.subject.Subject(name).get_best_query(dbo.sack).filter(version__glob=version, latest=True)] or [None])
if not pkg:
install_errors.append(("%s-%s" % (name, version), "No match")) install_errors.append(("%s-%s" % (name, version), "No match"))
continue continue
dbo.package_install(pkg)
for p in pkgs:
dbo.package_install(p)
except dnf.exceptions.MarkingError as e: except dnf.exceptions.MarkingError as e:
install_errors.append(("%s-%s" % (name, version), str(e))) install_errors.append(("%s-%s" % (name, version), str(e)))