From a53dc6f1bb166d905fe443a205b1e44f3844965f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 5 Sep 2018 15:00:01 +0200 Subject: [PATCH] gather: Expand multilib lists for hybrid method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there are globs in the blacklist or whitelist, we need to expand it to full package name. Signed-off-by: Lubomír Sedlář --- pungi/phases/gather/methods/method_hybrid.py | 17 +++++++- tests/test_gather_method_hybrid.py | 42 ++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/pungi/phases/gather/methods/method_hybrid.py b/pungi/phases/gather/methods/method_hybrid.py index 9b775ca4..9dbe4ded 100644 --- a/pungi/phases/gather/methods/method_hybrid.py +++ b/pungi/phases/gather/methods/method_hybrid.py @@ -107,6 +107,19 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase): self._prepare_packages() return self.packages[nevra] + def expand_list(self, arch, patterns): + """Given a list of globs, create a list of package names matching any + of the pattern. + """ + expanded = set() + for pkg_arch in self.package_sets[arch].rpms_by_arch: + for pkg in self.package_sets[arch].rpms_by_arch[pkg_arch]: + for pattern in patterns: + if fnmatch(pkg.name, pattern): + expanded.add(pkg.name) + break + return expanded + def prepare_langpacks(self, arch, variant): if not self.compose.has_comps: return @@ -147,7 +160,9 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase): self.compose.conf, "multilib", arch, variant ) self.multilib = multilib_dnf.Multilib( - self.multilib_methods, multilib_blacklist, multilib_whitelist + self.multilib_methods, + self.expand_list(arch, multilib_blacklist), + self.expand_list(arch, multilib_whitelist), ) platform = create_module_repo(self.compose, variant, arch) diff --git a/tests/test_gather_method_hybrid.py b/tests/test_gather_method_hybrid.py index 66e40ce1..c6d7d0da 100644 --- a/tests/test_gather_method_hybrid.py +++ b/tests/test_gather_method_hybrid.py @@ -128,6 +128,48 @@ class TestMethodHybrid(helpers.PungiTestCase): self.assertEqual(m.langpacks, {"foo": set(["foo-en"])}) + def test_expand_list(self): + compose = helpers.DummyCompose(self.topdir, {}) + m = hybrid.GatherMethodHybrid(compose) + m.package_sets = { + "x86_64": mock.Mock( + rpms_by_arch={ + "x86_64": [ + MockPkg( + name="foo", + version="1", + release="2", + arch="x86_64", + epoch=0, + sourcerpm=None, + file_path=None, + ), + MockPkg( + name="foo-en", + version="1", + release="2", + arch="x86_64", + epoch=0, + sourcerpm=None, + file_path=None, + ), + MockPkg( + name="bar", + version="1", + release="2", + arch="x86_64", + epoch=0, + sourcerpm=None, + file_path=None, + ), + ] + } + ) + } + expanded = m.expand_list("x86_64", ["foo*"]) + + self.assertItemsEqual(expanded, ["foo", "foo-en"]) + class MockModule(object): def __init__(