Skip to content

Commit

Permalink
ltmpl: Handle installing provides with filter_provides
Browse files Browse the repository at this point in the history
Previously the installpkg command used filter_match to select packages,
which works great most of the time. It fails when the package is only
available as a provide. This happened recently with wget moving to
wget2-wget, causing builds to fail because it couldn't find wget.

This changes installpkg to first try the name, but if that fails it will
try provides. This *may* still fail if the package isn't available by
name but has multiple providers. Currently this is not an issue, just
something to keep in mind.

NOTE: This change only applies to packages without version selection. If
a version comparison is included it only works with named packages, not
provides.
  • Loading branch information
bcl committed Jan 29, 2024
1 parent 4f3eebf commit 6ba7583
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pylorax/ltmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,14 @@ def _pkgver(self, pkg_spec):
if not any(g for g in ['=', '<', '>', '!'] if g in pkg_spec):
# glob?
if any(g for g in ['*', '?', '[', ']'] if g in pkg_spec):
query.filter_name([pkg_spec], GLOB)
op = GLOB
else:
query.filter_name([pkg_spec], EQ)
op = EQ

query.filter_name([pkg_spec], op)
if len(list(query)) == 0:
query = dnf5.rpm.PackageQuery(self.dbo)
query.filter_provides([pkg_spec], op)
else:
pcv = re.split(r'([!<>=]+)', pkg_spec)
if not pcv[0]:
Expand Down Expand Up @@ -345,8 +350,8 @@ def installpkg(self, *pkgs):
for exclude in excludes:
pkgobjs = [p for p in pkgobjs if not fnmatch.fnmatch(p.get_name(), exclude)]

# If the request is a glob, expand it in the log
if any(g for g in ['*','?','.'] if g in pkg):
# If the request is a glob or returns more than one package, expand it in the log
if len(pkgobjs) > 1 or any(g for g in ['*','?','.'] if g in pkg):
logger.info("installpkg: %s expands to %s", pkg, ",".join(p.get_nevra() for p in pkgobjs))

for p in pkgobjs:
Expand Down

0 comments on commit 6ba7583

Please sign in to comment.