From 6ec206f9aeab3f27d1bc47bd56ac8e44e89f59dc Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Thu, 13 Jun 2019 13:22:47 +0800 Subject: [PATCH] gather: fix crash issue when gather_method = "nodeps" JIRA: COMPOSE-3089 Signed-off-by: Haibo Lin --- pungi/phases/gather/methods/method_nodeps.py | 32 +++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/pungi/phases/gather/methods/method_nodeps.py b/pungi/phases/gather/methods/method_nodeps.py index 0bcc60d0..e9706263 100644 --- a/pungi/phases/gather/methods/method_nodeps.py +++ b/pungi/phases/gather/methods/method_nodeps.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +import os from pprint import pformat from fnmatch import fnmatch import six @@ -128,13 +129,36 @@ def expand_groups(compose, arch, variant, groups, set_pkg_arch=True): # No groups, nothing to do (this also covers case when there is no # comps file. return set() + comps = [] comps_file = compose.paths.work.comps(arch, variant, create_dir=False) - comps = CompsWrapper(comps_file) + comps.append(CompsWrapper(comps_file)) + + if variant and variant.parent: + parent_comps_file = compose.paths.work.comps(arch, variant.parent, create_dir=False) + comps.append(CompsWrapper(parent_comps_file)) + + if variant.type == 'optional': + for v in variant.parent.variants.values(): + if v.id == variant.id: + continue + comps_file = compose.paths.work.comps(arch, v, create_dir=False) + if os.path.exists(comps_file): + comps.append(CompsWrapper(comps_file)) + packages = set() - pkg_arch = arch if set_pkg_arch else None - for group in groups: - packages.update([(pkg, pkg_arch) for pkg in comps.get_packages(group)]) + found = False + ex = None + for c in comps: + try: + packages.update([(pkg, pkg_arch) for pkg in c.get_packages(group)]) + found = True + break + except KeyError as e: + ex = e + + if not found: + raise ex return packages