From 258d716a71a7db45e63e405798437caac40384b7 Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: Thu, 16 Mar 2017 11:16:47 +0800 Subject: [PATCH] Not create empty skeleton dirs for empty variants Do not create empty skeleton dirs for empty variants which we do for rpm variants in some phases (some others already have the check): 1. createiso phase 2. extra_files phase 3. gather phase In addtion to this, compose metadata (composeinfo.json) doesn't include variant paths which don't exist or are just empty dirs now. Fixes: #497 Merges: #572 Signed-off-by: Qixiang Wan --- pungi/metadata.py | 14 +++++++++++++- pungi/phases/createiso.py | 2 ++ pungi/phases/extra_files.py | 2 ++ pungi/phases/gather/__init__.py | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pungi/metadata.py b/pungi/metadata.py index 57cd05d5..4b886987 100644 --- a/pungi/metadata.py +++ b/pungi/metadata.py @@ -14,6 +14,7 @@ # along with this program; if not, see . +import copy import os import time import json @@ -168,7 +169,18 @@ def write_compose_info(compose): compose.log_info("[BEGIN] %s" % msg) path = compose.paths.compose.metadata("composeinfo.json") - ci.dump(path) + # make a copy of composeinfo and modify the copy + # if any path in variant paths doesn't exist or just an empty + # dir, set it to None, then it won't be dumped. + ci_copy = copy.deepcopy(ci) + for variant in ci_copy.variants.variants.values(): + for field in variant.paths._fields: + field_paths = getattr(variant.paths, field) + for arch, dirpath in field_paths.iteritems(): + dirpath = os.path.join(compose.paths.compose.topdir(), dirpath) + if not (os.path.isdir(dirpath) and os.listdir(dirpath)): + field_paths[arch] = None + ci_copy.dump(path) compose.log_info("[DONE ] %s" % msg) diff --git a/pungi/phases/createiso.py b/pungi/phases/createiso.py index 26609dbe..a0d7f425 100644 --- a/pungi/phases/createiso.py +++ b/pungi/phases/createiso.py @@ -66,6 +66,8 @@ class CreateisoPhase(PhaseLoggerMixin, PhaseBase): commands = [] for variant in self.compose.get_variants(types=["variant", "layered-product", "optional"]): + if variant.is_empty: + continue for arch in variant.arches + ["src"]: skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant) if skip_iso == [True]: diff --git a/pungi/phases/extra_files.py b/pungi/phases/extra_files.py index 70284d97..6594c0d8 100644 --- a/pungi/phases/extra_files.py +++ b/pungi/phases/extra_files.py @@ -37,6 +37,8 @@ class ExtraFilesPhase(ConfigGuardedPhase): def run(self): for arch in self.compose.get_arches() + ["src"]: for variant in self.compose.get_variants(arch=arch): + if variant.is_empty: + continue cfg = get_arch_variant_data(self.compose.conf, self.name, arch, variant) if cfg: copy_extra_files(self.compose, cfg, arch, variant, self.pkgset_phase.package_sets) diff --git a/pungi/phases/gather/__init__.py b/pungi/phases/gather/__init__.py index 6b8da82d..8a22c4b3 100644 --- a/pungi/phases/gather/__init__.py +++ b/pungi/phases/gather/__init__.py @@ -75,6 +75,8 @@ class GatherPhase(PhaseBase): for arch in self.compose.get_arches(): for variant in self.compose.get_variants(arch=arch): + if variant.is_empty: + continue link_files(self.compose, arch, variant, pkg_map[arch][variant.uid], self.pkgset_phase.package_sets,