From 6af11d5747aa7e84165e50cf44dbef3caf947c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 22 Sep 2023 11:29:46 +0200 Subject: [PATCH] gather: Support dotarch notation for debuginfo packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lubomír Sedlář (cherry picked from commit 986099f8b5041be3af967bb4d3bbaebaf4cc6c9f) --- pungi/gather_dnf.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pungi/gather_dnf.py b/pungi/gather_dnf.py index 10764c87..8d64dfa1 100644 --- a/pungi/gather_dnf.py +++ b/pungi/gather_dnf.py @@ -40,6 +40,20 @@ def get_source_name(pkg): return pkg.sourcerpm.rsplit("-", 2)[0] +def filter_dotarch(queue, pattern): + """Filter queue for packages matching the pattern. If pattern matches the + dotarch format of ., it is processed as such. Otherwise it is + treated as just a name. + """ + kwargs["name__glob"] = pattern + if "." in pattern: + name, arch = pattern.split(".", 1) + if arch in arch_utils.arches or arch == "noarch": + kwargs["name_glob"] = name + kwargs["arch_eq"] = arch + return queue.filter(**kwargs).apply() + + class GatherOptions(pungi.common.OptionsBase): def __init__(self, **kwargs): super(GatherOptions, self).__init__() @@ -522,25 +536,14 @@ class Gather(GatherBase): name__glob=pattern[:-2] ).apply() else: - pkgs = self.q_debug_packages.filter( - name__glob=pattern - ).apply() + pkgs = filter_dotarch(self.q_debug_packages, pattern) else: if pattern.endswith(".+"): pkgs = self.q_multilib_binary_packages.filter( name__glob=pattern[:-2] ).apply() else: - 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() + pkgs = filter_dotarch(self.q_binary_packages, pattern) if not pkgs: self.logger.error(