Allow specifying which packages to install in variants xml

This patch updates the variants DTD and parsing to allow specifying
multiple build install packages for each variant.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2015-12-03 13:12:59 +01:00
parent cfda99e6fe
commit 791448cc32
2 changed files with 12 additions and 2 deletions

View File

@ -70,6 +70,7 @@ class VariantsXmlParser(object):
"arches": [str(i) for i in variant_node.xpath("arches/arch/text()")],
"groups": [],
"environments": [],
"buildinstallpackages": [],
}
if self.tree_arches:
variant_dict["arches"] = [i for i in variant_dict["arches"] if i in self.tree_arches]
@ -106,6 +107,10 @@ class VariantsXmlParser(object):
variant_dict["environments"].append(environment)
for buildinstallpackages_node in variant_node.xpath("buildinstallpackages"):
for package_node in buildinstallpackages_node.xpath("package"):
variant_dict["buildinstallpackages"].append(package_node.text)
variant = Variant(**variant_dict)
if variant.type == "layered-product":
release_node = variant_node.xpath("release")[0]
@ -157,11 +162,12 @@ class VariantsXmlParser(object):
class Variant(object):
def __init__(self, id, name, type, arches, groups, environments=None):
def __init__(self, id, name, type, arches, groups, environments=None, buildinstallpackages=None):
if not id.isalnum():
raise ValueError("Variant ID must contain only alphanumeric characters: %s" % id)
environments = environments or []
buildinstallpackages = buildinstallpackages or []
self.id = id
self.name = name
@ -169,6 +175,7 @@ class Variant(object):
self.arches = sorted(copy.deepcopy(arches))
self.groups = sorted(copy.deepcopy(groups), lambda x, y: cmp(x["name"], y["name"]))
self.environments = sorted(copy.deepcopy(environments), lambda x, y: cmp(x["name"], y["name"]))
self.buildinstallpackages = sorted(buildinstallpackages)
self.variants = {}
self.parent = None

View File

@ -1,6 +1,6 @@
<!ELEMENT variants (ref*,variant*)>
<!ELEMENT variant (release?,arches,groups,environments*,variants*)?>
<!ELEMENT variant (release?,arches,groups,environments*,variants*,buildinstallpackages?)?>
<!ATTLIST variant
id ID #REQUIRED
name CDATA #REQUIRED
@ -40,3 +40,6 @@
<!ATTLIST ref
id IDREF #REQUIRED
>
<!ELEMENT buildinstallpackages (package)+>
<!ELEMENT package (#PCDATA)>