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 <qwan@redhat.com>
This commit is contained in:
Qixiang Wan 2017-03-16 11:16:47 +08:00 committed by Lubomír Sedlář
parent d0974d5c6a
commit 258d716a71
4 changed files with 19 additions and 1 deletions

View File

@ -14,6 +14,7 @@
# along with this program; if not, see <https://gnu.org/licenses/>. # along with this program; if not, see <https://gnu.org/licenses/>.
import copy
import os import os
import time import time
import json import json
@ -168,7 +169,18 @@ def write_compose_info(compose):
compose.log_info("[BEGIN] %s" % msg) compose.log_info("[BEGIN] %s" % msg)
path = compose.paths.compose.metadata("composeinfo.json") 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) compose.log_info("[DONE ] %s" % msg)

View File

@ -66,6 +66,8 @@ class CreateisoPhase(PhaseLoggerMixin, PhaseBase):
commands = [] commands = []
for variant in self.compose.get_variants(types=["variant", "layered-product", "optional"]): for variant in self.compose.get_variants(types=["variant", "layered-product", "optional"]):
if variant.is_empty:
continue
for arch in variant.arches + ["src"]: for arch in variant.arches + ["src"]:
skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant) skip_iso = get_arch_variant_data(self.compose.conf, "createiso_skip", arch, variant)
if skip_iso == [True]: if skip_iso == [True]:

View File

@ -37,6 +37,8 @@ class ExtraFilesPhase(ConfigGuardedPhase):
def run(self): def run(self):
for arch in self.compose.get_arches() + ["src"]: for arch in self.compose.get_arches() + ["src"]:
for variant in self.compose.get_variants(arch=arch): 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) cfg = get_arch_variant_data(self.compose.conf, self.name, arch, variant)
if cfg: if cfg:
copy_extra_files(self.compose, cfg, arch, variant, self.pkgset_phase.package_sets) copy_extra_files(self.compose, cfg, arch, variant, self.pkgset_phase.package_sets)

View File

@ -75,6 +75,8 @@ class GatherPhase(PhaseBase):
for arch in self.compose.get_arches(): for arch in self.compose.get_arches():
for variant in self.compose.get_variants(arch=arch): for variant in self.compose.get_variants(arch=arch):
if variant.is_empty:
continue
link_files(self.compose, arch, variant, link_files(self.compose, arch, variant,
pkg_map[arch][variant.uid], pkg_map[arch][variant.uid],
self.pkgset_phase.package_sets, self.pkgset_phase.package_sets,