Allow specifying empty variants

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-16 10:23:08 +01:00
parent adbc772fd0
commit 454363fba8
8 changed files with 34 additions and 8 deletions

View File

@ -294,7 +294,7 @@ def run_compose(compose):
# write .discinfo and media.repo before ISOs are created # write .discinfo and media.repo before ISOs are created
for variant in compose.get_variants(recursive=True): for variant in compose.get_variants(recursive=True):
if variant.type == "addon": if variant.type == "addon" or variant.is_empty:
continue continue
for arch in variant.arches + ["src"]: for arch in variant.arches + ["src"]:
timestamp = pungi.metadata.write_discinfo(compose, arch, variant) timestamp = pungi.metadata.write_discinfo(compose, arch, variant)

View File

@ -170,7 +170,7 @@ def write_compose_info(compose):
def write_tree_info(compose, arch, variant, timestamp=None): def write_tree_info(compose, arch, variant, timestamp=None):
if variant.type in ("addon", ): if variant.type in ("addon", ) or variant.is_empty:
return return
if not timestamp: if not timestamp:

View File

@ -77,16 +77,24 @@ class CreaterepoPhase(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
self.pool.queue_put((self.compose, arch, variant, "rpm")) self.pool.queue_put((self.compose, arch, variant, "rpm"))
self.pool.queue_put((self.compose, arch, variant, "debuginfo")) self.pool.queue_put((self.compose, arch, variant, "debuginfo"))
for variant in self.compose.get_variants(): for variant in self.compose.get_variants():
if variant.is_empty:
continue
self.pool.queue_put((self.compose, None, variant, "srpm")) self.pool.queue_put((self.compose, None, variant, "srpm"))
self.pool.start() self.pool.start()
def create_variant_repo(compose, arch, variant, pkg_type): 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_c = compose.conf.get("createrepo_c", True)
createrepo_checksum = compose.conf["createrepo_checksum"] createrepo_checksum = compose.conf["createrepo_checksum"]
repo = CreaterepoWrapper(createrepo_c=createrepo_c) repo = CreaterepoWrapper(createrepo_c=createrepo_c)
@ -131,7 +139,7 @@ def create_variant_repo(compose, arch, variant, pkg_type):
manifest = productmd.rpms.Rpms() manifest = productmd.rpms.Rpms()
manifest.load(manifest_file) 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": if arch is None and pkg_type != "srpm":
continue continue
if arch is not None and arch != rpms_arch: if arch is not None and arch != rpms_arch:

View File

@ -164,6 +164,15 @@ def gather_packages(compose, arch, variant, package_sets, fulltree_excludes=None
GatherMethod = get_gather_method(compose.conf["gather_method"]) GatherMethod = get_gather_method(compose.conf["gather_method"])
msg = "Gathering packages (arch: %s, variant: %s)" % (arch, variant) 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) compose.log_info("[BEGIN] %s" % msg)
packages, groups, filter_packages = get_variant_packages(compose, arch, variant, package_sets) packages, groups, filter_packages = get_variant_packages(compose, arch, variant, package_sets)

View File

@ -98,14 +98,14 @@ class ProductimgPhase(PhaseBase):
def run(self): def run(self):
# create PRODUCT.IMG # create PRODUCT.IMG
for variant in self.compose.get_variants(): for variant in self.compose.get_variants():
if variant.type != "variant": if variant.type != "variant" or variant.is_empty:
continue continue
create_product_img(self.compose, "global", variant) create_product_img(self.compose, "global", variant)
# copy PRODUCT.IMG # copy PRODUCT.IMG
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.type != "variant": if variant.type != "variant" or variant.is_empty:
continue continue
image = self.compose.paths.work.product_img(variant) image = self.compose.paths.work.product_img(variant)
os_tree = self.compose.paths.compose.os_tree(arch, 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 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.type != "variant": if variant.type != "variant" or variant.is_empty:
continue continue
rebuild_boot_iso(self.compose, arch, variant, self.pkgset_phase.package_sets) rebuild_boot_iso(self.compose, arch, variant, self.pkgset_phase.package_sets)

View File

@ -71,6 +71,7 @@ class VariantsXmlParser(object):
"groups": [], "groups": [],
"environments": [], "environments": [],
"buildinstallpackages": [], "buildinstallpackages": [],
"is_empty": bool(variant_node.attrib.get("is_empty", False)),
} }
if self.tree_arches: if self.tree_arches:
variant_dict["arches"] = [i for i in variant_dict["arches"] if i in 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): 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(): if not id.isalnum():
raise ValueError("Variant ID must contain only alphanumeric characters: %s" % id) raise ValueError("Variant ID must contain only alphanumeric characters: %s" % id)
@ -178,6 +179,7 @@ class Variant(object):
self.buildinstallpackages = sorted(buildinstallpackages) self.buildinstallpackages = sorted(buildinstallpackages)
self.variants = {} self.variants = {}
self.parent = None self.parent = None
self.is_empty = is_empty
def __getitem__(self, name): def __getitem__(self, name):
return self.variants[name] return self.variants[name]

View File

@ -1,11 +1,12 @@
<!ELEMENT variants (ref*,variant*)> <!ELEMENT variants (ref*,variant*)>
<!ELEMENT variant (release?,arches,groups,environments*,variants*,buildinstallpackages?)?> <!ELEMENT variant (release?,arches,groups?,environments*,variants*,buildinstallpackages?)?>
<!ATTLIST variant <!ATTLIST variant
id ID #REQUIRED id ID #REQUIRED
name CDATA #REQUIRED name CDATA #REQUIRED
type (variant|addon|optional|layered-product) #REQUIRED type (variant|addon|optional|layered-product) #REQUIRED
has_optional (true|false) #IMPLIED has_optional (true|false) #IMPLIED
is_empty (true|false) "false"
> >
<!ELEMENT release (#PCDATA)> <!ELEMENT release (#PCDATA)>

View File

@ -11,6 +11,12 @@
</groups> </groups>
</variant> </variant>
<variant id="Live" name="Live" type="variant" is_empty="true">
<arches>
<arch>x86_64</arch>
</arches>
</variant>
<variant id="Gluster" name="Gluster Layered Product" type="layered-product"> <variant id="Gluster" name="Gluster Layered Product" type="layered-product">
<release name="Gluster" version="2.3" short="Gluster" /> <release name="Gluster" version="2.3" short="Gluster" />
<arches> <arches>