gather: Support dotarch in DNF backend

The documentation claims that dotarch syntax is supported for additional
packages. For yum backend this seems to be handled automatically, but
the dnf backend could not interpret this.

This patch checks if a package is specified in the syntax and contains a
valid architecture. If so, the query will honor the arch.

JIRA: RHELCMP-11728
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
(cherry picked from commit 82ca4f4e65)
This commit is contained in:
Lubomír Sedlář 2023-05-15 08:39:15 +02:00 committed by Stepan Oksanichenko
parent 85c9e9e776
commit c1f2fa5035
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
1 changed files with 11 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import pungi.common
import pungi.dnf_wrapper
import pungi.multilib_dnf
import pungi.util
from pungi import arch_utils
from pungi.linker import Linker
from pungi.profiler import Profiler
from pungi.util import DEBUG_PATTERNS
@ -500,9 +501,16 @@ class Gather(GatherBase):
name__glob=pattern[:-2]
).apply()
else:
pkgs = self.q_binary_packages.filter(
name__glob=pattern
).apply()
kwargs = {"name__glob": pattern}
if "." in pattern:
# The pattern could be name.arch. Check if the
# arch is valid, and if yes, make a more
# specific query.
name, arch = pattern.split(".", 1)
if arch in arch_utils.arches:
kwargs["name__glob"] = name
kwargs["arch__eq"] = arch
pkgs = self.q_binary_packages.filter(**kwargs).apply()
if not pkgs:
self.logger.error("No package matches pattern %s" % pattern)