comps: Apply arch filtering to environment/optionlist

Let's filter this list too, not just the grouplist tag.

JIRA: RHELCMP-7926
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
(cherry picked from commit d3f0701e01)
This commit is contained in:
Lubomír Sedlář 2023-04-24 08:25:29 +02:00 committed by Stepan Oksanichenko
parent c402ff3d60
commit 72ddf65e62
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
2 changed files with 10 additions and 8 deletions

View File

@ -183,15 +183,16 @@ class CompsFilter(object):
"""
all_groups = self.tree.xpath("/comps/group/id/text()") + lookaside_groups
for environment in self.tree.xpath("/comps/environment"):
for group in environment.xpath("grouplist/groupid"):
if group.text not in all_groups:
group.getparent().remove(group)
for parent_tag in ("grouplist", "optionlist"):
for group in environment.xpath("%s/groupid" % parent_tag):
if group.text not in all_groups:
group.getparent().remove(group)
for group in environment.xpath("grouplist/groupid[@arch]"):
value = group.attrib.get("arch")
values = [v for v in re.split(r"[, ]+", value) if v]
if arch not in values:
group.getparent().remove(group)
for group in environment.xpath("%s/groupid[@arch]" % parent_tag):
value = group.attrib.get("arch")
values = [v for v in re.split(r"[, ]+", value) if v]
if arch not in values:
group.getparent().remove(group)
def remove_empty_environments(self):
"""

View File

@ -108,6 +108,7 @@
<groupid>core</groupid>
</grouplist>
<optionlist>
<groupid arch="x86_64">standard</groupid>
</optionlist>
</environment>