gather: Support dotarch notation for debuginfo packages

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2023-09-22 11:29:46 +02:00 committed by lsedlar
parent 947ddf0a1a
commit 986099f8b5

View File

@ -40,6 +40,20 @@ def get_source_name(pkg):
return pkg.sourcerpm.rsplit("-", 2)[0] 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 <name>.<arch>, 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): class GatherOptions(pungi.common.OptionsBase):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(GatherOptions, self).__init__() super(GatherOptions, self).__init__()
@ -522,25 +536,14 @@ class Gather(GatherBase):
name__glob=pattern[:-2] name__glob=pattern[:-2]
).apply() ).apply()
else: else:
pkgs = self.q_debug_packages.filter( pkgs = filter_dotarch(self.q_debug_packages, pattern)
name__glob=pattern
).apply()
else: else:
if pattern.endswith(".+"): if pattern.endswith(".+"):
pkgs = self.q_multilib_binary_packages.filter( pkgs = self.q_multilib_binary_packages.filter(
name__glob=pattern[:-2] name__glob=pattern[:-2]
).apply() ).apply()
else: else:
kwargs = {"name__glob": pattern} pkgs = filter_dotarch(self.q_binary_packages, 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: if not pkgs:
self.logger.error( self.logger.error(