From 3735aaa443349a42508c268b0e6d47c29474998c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 21 Jan 2021 16:38:42 +0100 Subject: [PATCH] comps: Preserve default arg on groupid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the wrapper processes comps file, it wasn't emitting "default" argument for groupid element. The default is false and most entries are actually using the default, so let's only emit it if set to true. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1882358 Signed-off-by: Lubomír Sedlář (cherry picked from commit 9ea1098eaee9a6c1195d8b0e8e3073c2d4308cb4) --- pungi/wrappers/comps.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pungi/wrappers/comps.py b/pungi/wrappers/comps.py index 4eaddb0e..aa7685b4 100644 --- a/pungi/wrappers/comps.py +++ b/pungi/wrappers/comps.py @@ -325,9 +325,8 @@ class CompsWrapper(object): group_node.appendChild(packagelist) for category in self.comps.categories: - groups = set(x.name for x in category.group_ids) & set( - self.get_comps_groups() - ) + group_ids = set(self.get_comps_groups()) + groups = set(g for g in category.group_ids if g.name in group_ids) if not groups: continue cat_node = doc.createElement("category") @@ -341,7 +340,7 @@ class CompsWrapper(object): append_grouplist(doc, cat_node, groups) for environment in sorted(self.comps.environments, key=attrgetter("id")): - groups = set(x.name for x in environment.group_ids) + groups = set(environment.group_ids) if not groups: continue env_node = doc.createElement("environment") @@ -356,10 +355,7 @@ class CompsWrapper(object): if environment.option_ids: append_grouplist( - doc, - env_node, - (x.name for x in environment.option_ids), - "optionlist", + doc, env_node, set(environment.option_ids), "optionlist", ) if self.comps.langpacks: @@ -460,8 +456,11 @@ def append(doc, parent, elem, content=None, lang=None, **kwargs): def append_grouplist(doc, parent, groups, elem="grouplist"): grouplist_node = doc.createElement(elem) - for groupid in sorted(groups): - append(doc, grouplist_node, "groupid", groupid) + for groupid in sorted(groups, key=lambda x: x.name): + kwargs = {} + if groupid.default: + kwargs["default"] = "true" + append(doc, grouplist_node, "groupid", groupid.name, **kwargs) parent.appendChild(grouplist_node)