gather: Expand multilib lists for hybrid method

If there are globs in the blacklist or whitelist, we need to expand it
to full package name.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-09-05 15:00:01 +02:00
parent 1350684c31
commit a53dc6f1bb
2 changed files with 58 additions and 1 deletions

View File

@ -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)

View File

@ -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__(