From d4f8e32a80f80d2640b5a1a524ad99f18d497792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 20 Jan 2017 10:17:19 +0100 Subject: [PATCH] Fix handling globs in input packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lubomír Sedlář --- pungi/gather_dnf.py | 17 +++++++++++++---- tests/test_gather.py | 4 ---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pungi/gather_dnf.py b/pungi/gather_dnf.py index 83e2d71b..8ec9f3a2 100644 --- a/pungi/gather_dnf.py +++ b/pungi/gather_dnf.py @@ -340,12 +340,21 @@ class Gather(GatherBase): else: pkgs = self.q_binary_packages.filter(name__glob=pattern).apply() - pkgs = self._get_best_package(pkgs) - if pkgs: - added.update(pkgs) - else: + if not pkgs: self.logger.error("No package matches pattern %s" % pattern) + # The pattern could have been a glob. In that case we want to + # group the packages by name and get best match in those + # smaller groups. + packages_by_name = {} + for po in pkgs: + packages_by_name.setdefault(po.name, []).append(po) + + for name, packages in packages_by_name.iteritems(): + pkgs = self._get_best_package(packages) + if pkgs: + added.update(pkgs) + for pkg in added: self._set_flag(pkg, PkgFlag.input) diff --git a/tests/test_gather.py b/tests/test_gather.py index d40e1b71..b75ed647 100644 --- a/tests/test_gather.py +++ b/tests/test_gather.py @@ -1717,10 +1717,6 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase): def test_multilib_exclude_pattern_does_not_match_noarch(self): pass - @unittest.skip('Not implemented yet') - def test_input_by_wildcard(self): - pass - def test_firefox_selfhosting_with_krb5_lookaside(self): super(DNFDepsolvingTestCase, self).test_firefox_selfhosting_with_krb5_lookaside() self.assertFlags("dummy-krb5-1.10-5.x86_64", [PkgFlag.lookaside])