From 970143e59f0253a818f2b200ad5b6058a482302b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 4 Dec 2017 14:12:43 +0100 Subject: [PATCH] pkgset: Add SRPMs to whitelist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When cherry picking packages from Koji tag, we need to make sure that for every binary package we always have a corresponding source package. Even if it does not go into the compose, we need it to get values for Exclusive or Exclude Arch tags. This means we need to process the binary packages first and only then look at source ones. Instead of sorting a potentially very long list, let's just iterate twice. Signed-off-by: Lubomír Sedlář --- pungi/phases/pkgset/pkgsets.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pungi/phases/pkgset/pkgsets.py b/pungi/phases/pkgset/pkgsets.py index 6363f549..52badcc9 100644 --- a/pungi/phases/pkgset/pkgsets.py +++ b/pungi/phases/pkgset/pkgsets.py @@ -19,7 +19,7 @@ The KojiPackageSet object obtains the latest RPMs from a Koji tag. It automatically finds a signed copies according to *sigkey_ordering*. """ - +import itertools import os import kobo.log @@ -214,7 +214,7 @@ class KojiPackageSet(PackageSetBase): arches=arches, logger=logger) self.koji_wrapper = koji_wrapper # Names of packages to look for in the Koji tag. - self.packages = packages + self.packages = set(packages or []) def __getstate__(self): result = self.__dict__.copy() @@ -285,7 +285,14 @@ class KojiPackageSet(PackageSetBase): skipped_arches = [] skipped_packages_count = 0 - for rpm_info in rpms: + # We need to process binary packages first, and then source packages. + # If we have a list of packages to use, we need to put all source rpms + # names into it. Otherwise if the SRPM name does not occur on the list, + # it would be missing from the package set. Even if it ultimately does + # not end in the compose, we need it to extract ExcludeArch and + # ExclusiveArch for noarch packages. + for rpm_info in itertools.chain((rpm for rpm in rpms if not _is_src(rpm)), + (rpm for rpm in rpms if _is_src(rpm))): if self.arches and rpm_info["arch"] not in self.arches: if rpm_info["arch"] not in skipped_arches: self.log_debug("Skipping packages for arch: %s" % rpm_info["arch"]) @@ -297,10 +304,13 @@ class KojiPackageSet(PackageSetBase): continue build_info = builds_by_id[rpm_info["build_id"]] - if rpm_info["arch"] in ("src", "nosrc"): + if _is_src(rpm_info): result_srpms.append((rpm_info, build_info)) else: result_rpms.append((rpm_info, build_info)) + if self.packages: + # Only add the package if we already have some whitelist. + self.packages.add(build_info['name']) if skipped_packages_count: self.log_debug("Skipped %d packages, not marked as to be " @@ -318,3 +328,8 @@ class KojiPackageSet(PackageSetBase): self.log_info("[DONE ] %s" % msg) return result + + +def _is_src(rpm_info): + """Check if rpm info object returned by Koji refers to source packages.""" + return rpm_info['arch'] in ('src', 'nosrc')