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 81d38b6445
commit 3b41faae2c

View File

@ -210,13 +210,13 @@ def _depsolve(dbo, projects, groups):
try:
if not version:
version = "*"
pkgs = [pkg for pkg in dnf.subject.Subject(name).get_best_query(dbo.sack).filter(version__glob=version, latest=True)]
if not pkgs:
# Find the best package matching the name + version glob
# 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"))
continue
for p in pkgs:
dbo.package_install(p)
dbo.package_install(pkg)
except dnf.exceptions.MarkingError as e:
install_errors.append(("%s-%s" % (name, version), str(e)))