From 454363fba87101acd2d52e93a3412fe901ec918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 16 Feb 2016 10:23:08 +0100 Subject: [PATCH] Allow specifying empty variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variants.xml file can list a variant with is_empty="true" and no groups. If such variant is found, not package gathering will be run for it, and no repos will be created. This only makes sense for a variant that will have some other deliverables like live media or images. Signed-off-by: Lubomír Sedlář --- bin/pungi-koji | 2 +- pungi/metadata.py | 2 +- pungi/phases/createrepo.py | 10 +++++++++- pungi/phases/gather/__init__.py | 9 +++++++++ pungi/phases/product_img.py | 6 +++--- pungi/wrappers/variants.py | 4 +++- share/variants.dtd | 3 ++- tests/data/dummy-variants.xml | 6 ++++++ 8 files changed, 34 insertions(+), 8 deletions(-) diff --git a/bin/pungi-koji b/bin/pungi-koji index 5740ddaf..6ed8c046 100755 --- a/bin/pungi-koji +++ b/bin/pungi-koji @@ -294,7 +294,7 @@ def run_compose(compose): # write .discinfo and media.repo before ISOs are created for variant in compose.get_variants(recursive=True): - if variant.type == "addon": + if variant.type == "addon" or variant.is_empty: continue for arch in variant.arches + ["src"]: timestamp = pungi.metadata.write_discinfo(compose, arch, variant) diff --git a/pungi/metadata.py b/pungi/metadata.py index f037708b..62801300 100644 --- a/pungi/metadata.py +++ b/pungi/metadata.py @@ -170,7 +170,7 @@ def write_compose_info(compose): def write_tree_info(compose, arch, variant, timestamp=None): - if variant.type in ("addon", ): + if variant.type in ("addon", ) or variant.is_empty: return if not timestamp: diff --git a/pungi/phases/createrepo.py b/pungi/phases/createrepo.py index 521d0467..62c2ea46 100644 --- a/pungi/phases/createrepo.py +++ b/pungi/phases/createrepo.py @@ -77,16 +77,24 @@ class CreaterepoPhase(PhaseBase): for arch in self.compose.get_arches(): for variant in self.compose.get_variants(arch=arch): + if variant.is_empty: + continue self.pool.queue_put((self.compose, arch, variant, "rpm")) self.pool.queue_put((self.compose, arch, variant, "debuginfo")) for variant in self.compose.get_variants(): + if variant.is_empty: + continue self.pool.queue_put((self.compose, None, variant, "srpm")) self.pool.start() def create_variant_repo(compose, arch, variant, pkg_type): + if variant.is_empty: + compose.log_info("[SKIP ] Creating repo (arch: %s, variant: %s): %s" % (arch, variant)) + return + createrepo_c = compose.conf.get("createrepo_c", True) createrepo_checksum = compose.conf["createrepo_checksum"] repo = CreaterepoWrapper(createrepo_c=createrepo_c) @@ -131,7 +139,7 @@ def create_variant_repo(compose, arch, variant, pkg_type): manifest = productmd.rpms.Rpms() manifest.load(manifest_file) - for rpms_arch, data in manifest.rpms[variant.uid].items(): + for rpms_arch, data in manifest.rpms[variant.uid].iteritems(): if arch is None and pkg_type != "srpm": continue if arch is not None and arch != rpms_arch: diff --git a/pungi/phases/gather/__init__.py b/pungi/phases/gather/__init__.py index 9c11b000..05152d98 100644 --- a/pungi/phases/gather/__init__.py +++ b/pungi/phases/gather/__init__.py @@ -164,6 +164,15 @@ def gather_packages(compose, arch, variant, package_sets, fulltree_excludes=None GatherMethod = get_gather_method(compose.conf["gather_method"]) msg = "Gathering packages (arch: %s, variant: %s)" % (arch, variant) + + if variant.is_empty: + compose.log_info("[SKIP ] %s" % msg) + return { + "rpm": [], + "srpm": [], + "debuginfo": [], + } + compose.log_info("[BEGIN] %s" % msg) packages, groups, filter_packages = get_variant_packages(compose, arch, variant, package_sets) diff --git a/pungi/phases/product_img.py b/pungi/phases/product_img.py index a39ac926..687d2618 100644 --- a/pungi/phases/product_img.py +++ b/pungi/phases/product_img.py @@ -98,14 +98,14 @@ class ProductimgPhase(PhaseBase): def run(self): # create PRODUCT.IMG for variant in self.compose.get_variants(): - if variant.type != "variant": + if variant.type != "variant" or variant.is_empty: continue create_product_img(self.compose, "global", variant) # copy PRODUCT.IMG for arch in self.compose.get_arches(): for variant in self.compose.get_variants(arch=arch): - if variant.type != "variant": + if variant.type != "variant" or variant.is_empty: continue image = self.compose.paths.work.product_img(variant) os_tree = self.compose.paths.compose.os_tree(arch, variant) @@ -117,7 +117,7 @@ class ProductimgPhase(PhaseBase): for arch in self.compose.get_arches(): for variant in self.compose.get_variants(arch=arch): - if variant.type != "variant": + if variant.type != "variant" or variant.is_empty: continue rebuild_boot_iso(self.compose, arch, variant, self.pkgset_phase.package_sets) diff --git a/pungi/wrappers/variants.py b/pungi/wrappers/variants.py index 6625642e..9448020f 100755 --- a/pungi/wrappers/variants.py +++ b/pungi/wrappers/variants.py @@ -71,6 +71,7 @@ class VariantsXmlParser(object): "groups": [], "environments": [], "buildinstallpackages": [], + "is_empty": bool(variant_node.attrib.get("is_empty", False)), } if self.tree_arches: variant_dict["arches"] = [i for i in variant_dict["arches"] if i in self.tree_arches] @@ -162,7 +163,7 @@ class VariantsXmlParser(object): class Variant(object): - def __init__(self, id, name, type, arches, groups, environments=None, buildinstallpackages=None): + def __init__(self, id, name, type, arches, groups, environments=None, buildinstallpackages=None, is_empty=False): if not id.isalnum(): raise ValueError("Variant ID must contain only alphanumeric characters: %s" % id) @@ -178,6 +179,7 @@ class Variant(object): self.buildinstallpackages = sorted(buildinstallpackages) self.variants = {} self.parent = None + self.is_empty = is_empty def __getitem__(self, name): return self.variants[name] diff --git a/share/variants.dtd b/share/variants.dtd index 1944d022..49d48813 100644 --- a/share/variants.dtd +++ b/share/variants.dtd @@ -1,11 +1,12 @@ - + diff --git a/tests/data/dummy-variants.xml b/tests/data/dummy-variants.xml index 871ced2a..23591d77 100644 --- a/tests/data/dummy-variants.xml +++ b/tests/data/dummy-variants.xml @@ -11,6 +11,12 @@ + + + x86_64 + + +