From f960b4d15593f2a2b1913d7bee8efc6ebde03505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 17 Mar 2023 15:02:47 +0100 Subject: [PATCH] pkgset: Support extra builds with no tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a rather fringe use case. If the configuration contains pkgset_koji_builds or pkgset_koji_scratch_tasks but no pkgset_koji_tag, the compose will be empty. The expectation though is that the packages should be pulled. The extra RPMs are added to all non-modular tags because they are supposed to mask builds from the same packages (e.g. user may want to explicitly pull in older version than tagged). This patch adds support for composes containing only explicitly listed builds by creating a dummy package set that is not actually using any tag. JIRA: RHELCMP-11385 Signed-off-by: Lubomír Sedlář --- pungi/phases/pkgset/pkgsets.py | 11 +++++++++-- pungi/phases/pkgset/sources/source_koji.py | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pungi/phases/pkgset/pkgsets.py b/pungi/phases/pkgset/pkgsets.py index c069aae4..7d543421 100644 --- a/pungi/phases/pkgset/pkgsets.py +++ b/pungi/phases/pkgset/pkgsets.py @@ -318,6 +318,11 @@ class FilelistPackageSet(PackageSetBase): return result +# This is a marker to indicate package set with only extra builds/tasks and no +# tasks. +MISSING_KOJI_TAG = object() + + class KojiPackageSet(PackageSetBase): def __init__( self, @@ -371,7 +376,7 @@ class KojiPackageSet(PackageSetBase): :param int signed_packages_wait: How long to wait between search attemts. """ super(KojiPackageSet, self).__init__( - name, + name if name != MISSING_KOJI_TAG else "no-tag", sigkey_ordering=sigkey_ordering, arches=arches, logger=logger, @@ -576,7 +581,9 @@ class KojiPackageSet(PackageSetBase): inherit, ) self.log_info("[BEGIN] %s" % msg) - rpms, builds = self.get_latest_rpms(tag, event, inherit=inherit) + rpms, builds = [], [] + if tag != MISSING_KOJI_TAG: + rpms, builds = self.get_latest_rpms(tag, event, inherit=inherit) extra_rpms, extra_builds = self.get_extra_rpms() rpms += extra_rpms builds += extra_builds diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index baea26c9..04301587 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -791,17 +791,23 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event): pkgsets = [] + extra_builds = force_list(compose.conf.get("pkgset_koji_builds", [])) + extra_tasks = force_list(compose.conf.get("pkgset_koji_scratch_tasks", [])) + + if not pkgset_koji_tags and (extra_builds or extra_tasks): + # We have extra packages to pull in, but no tag to merge them with. + compose_tags.append(pungi.phases.pkgset.pkgsets.MISSING_KOJI_TAG) + pkgset_koji_tags.append(pungi.phases.pkgset.pkgsets.MISSING_KOJI_TAG) + # Get package set for each compose tag and merge it to global package # list. Also prepare per-variant pkgset, because we do not have list # of binary RPMs in module definition - there is just list of SRPMs. for compose_tag in compose_tags: compose.log_info("Loading package set for tag %s", compose_tag) + kwargs = {} if compose_tag in pkgset_koji_tags: - extra_builds = force_list(compose.conf.get("pkgset_koji_builds", [])) - extra_tasks = force_list(compose.conf.get("pkgset_koji_scratch_tasks", [])) - else: - extra_builds = [] - extra_tasks = [] + kwargs["extra_builds"] = extra_builds + kwargs["extra_tasks"] = extra_tasks pkgset = pungi.phases.pkgset.pkgsets.KojiPackageSet( compose_tag, @@ -813,10 +819,9 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event): allow_invalid_sigkeys=allow_invalid_sigkeys, populate_only_packages=populate_only_packages_to_gather, cache_region=compose.cache_region, - extra_builds=extra_builds, - extra_tasks=extra_tasks, signed_packages_retries=compose.conf["signed_packages_retries"], signed_packages_wait=compose.conf["signed_packages_wait"], + **kwargs ) # Check if we have cache for this tag from previous compose. If so, use