From f24f84282d9c99933a89879e2a59e8389b8c964a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 5 Oct 2018 09:44:16 -0700 Subject: [PATCH] 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 --- src/pylorax/api/projects.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pylorax/api/projects.py b/src/pylorax/api/projects.py index f4679682..2072be41 100644 --- a/src/pylorax/api/projects.py +++ b/src/pylorax/api/projects.py @@ -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)))