hybrid: Apply filters to debuginfo and source packages
For binary packages the filters are handled at the depsolver level. However sources and debuginfo is added later in the process, so the filters have to be explicitly applied. JIRA: COMPOSE-3114 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
e573246a2a
commit
23bf01bb45
@ -191,17 +191,16 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):
|
|||||||
|
|
||||||
# Filters are received as tuples (name, arch), we should convert it to
|
# Filters are received as tuples (name, arch), we should convert it to
|
||||||
# strings.
|
# strings.
|
||||||
filter_packages = [_fmt_pkg(*p) for p in filter_packages]
|
filters = [_fmt_pkg(*p) for p in filter_packages]
|
||||||
|
|
||||||
nvrs, out_modules = self.run_solver(
|
nvrs, out_modules = self.run_solver(variant, arch, packages, platform, filters)
|
||||||
variant, arch, packages, platform, filter_packages
|
|
||||||
)
|
|
||||||
filter_modules(variant, arch, out_modules)
|
filter_modules(variant, arch, out_modules)
|
||||||
return expand_packages(
|
return expand_packages(
|
||||||
self._get_pkg_map(arch),
|
self._get_pkg_map(arch),
|
||||||
variant.arch_mmds.get(arch, {}),
|
variant.arch_mmds.get(arch, {}),
|
||||||
pungi.phases.gather.get_lookaside_repos(self.compose, arch, variant),
|
pungi.phases.gather.get_lookaside_repos(self.compose, arch, variant),
|
||||||
nvrs,
|
nvrs,
|
||||||
|
filter_packages=filter_packages,
|
||||||
)
|
)
|
||||||
# maybe check invalid sigkeys
|
# maybe check invalid sigkeys
|
||||||
|
|
||||||
@ -475,7 +474,7 @@ def _make_result(paths):
|
|||||||
return [{"path": path, "flags": []} for path in sorted(paths)]
|
return [{"path": path, "flags": []} for path in sorted(paths)]
|
||||||
|
|
||||||
|
|
||||||
def expand_packages(nevra_to_pkg, variant_modules, lookasides, nvrs):
|
def expand_packages(nevra_to_pkg, variant_modules, lookasides, nvrs, filter_packages):
|
||||||
"""For each package add source RPM and possibly also debuginfo."""
|
"""For each package add source RPM and possibly also debuginfo."""
|
||||||
# This will server as the final result. We collect sets of paths to the
|
# This will server as the final result. We collect sets of paths to the
|
||||||
# packages.
|
# packages.
|
||||||
@ -483,6 +482,8 @@ def expand_packages(nevra_to_pkg, variant_modules, lookasides, nvrs):
|
|||||||
srpms = set()
|
srpms = set()
|
||||||
debuginfo = set()
|
debuginfo = set()
|
||||||
|
|
||||||
|
filters = set(filter_packages)
|
||||||
|
|
||||||
# Collect list of all packages in lookaside. These will not be added to the
|
# Collect list of all packages in lookaside. These will not be added to the
|
||||||
# result. Fus handles this in part: if a package is explicitly mentioned as
|
# result. Fus handles this in part: if a package is explicitly mentioned as
|
||||||
# input (which can happen with comps group expansion), it will be in the
|
# input (which can happen with comps group expansion), it will be in the
|
||||||
@ -520,6 +521,9 @@ def expand_packages(nevra_to_pkg, variant_modules, lookasides, nvrs):
|
|||||||
# debuginfo is explicitly listed in the output, and we don't
|
# debuginfo is explicitly listed in the output, and we don't
|
||||||
# want anything more.
|
# want anything more.
|
||||||
srpm_arches[srpm_nevra].add(arch)
|
srpm_arches[srpm_nevra].add(arch)
|
||||||
|
if (srpm.name, "src") in filters:
|
||||||
|
# Filtered package, skipping
|
||||||
|
continue
|
||||||
if srpm.file_path not in lookaside_packages:
|
if srpm.file_path not in lookaside_packages:
|
||||||
srpms.add(srpm.file_path)
|
srpms.add(srpm.file_path)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -531,6 +535,9 @@ def expand_packages(nevra_to_pkg, variant_modules, lookasides, nvrs):
|
|||||||
# for architecture that has at least one binary package, we include it too.
|
# for architecture that has at least one binary package, we include it too.
|
||||||
for pkg in nevra_to_pkg.values():
|
for pkg in nevra_to_pkg.values():
|
||||||
if pkg_is_debug(pkg) and pkg.arch in srpm_arches[_get_srpm_nevra(pkg)]:
|
if pkg_is_debug(pkg) and pkg.arch in srpm_arches[_get_srpm_nevra(pkg)]:
|
||||||
|
if set([(pkg.name, pkg.arch), (pkg.name, None)]) & filters:
|
||||||
|
# Filtered package, skipping
|
||||||
|
continue
|
||||||
if pkg.file_path not in lookaside_packages:
|
if pkg.file_path not in lookaside_packages:
|
||||||
debuginfo.add(pkg.file_path)
|
debuginfo.add(pkg.file_path)
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ class TestMethodHybrid(helpers.PungiTestCase):
|
|||||||
{},
|
{},
|
||||||
glr.return_value,
|
glr.return_value,
|
||||||
m.run_solver.return_value[0],
|
m.run_solver.return_value[0],
|
||||||
|
filter_packages=[],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -365,7 +366,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
|
|||||||
"x86_64",
|
"x86_64",
|
||||||
[],
|
[],
|
||||||
platform="pl",
|
platform="pl",
|
||||||
filter_packages=["foo"],
|
filter_packages=[("foo", None)],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(res, po.return_value)
|
self.assertEqual(res, po.return_value)
|
||||||
@ -390,7 +391,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
|
|||||||
[self._repo("repo"), self._repo("module_repo_Server")],
|
[self._repo("repo"), self._repo("module_repo_Server")],
|
||||||
[],
|
[],
|
||||||
platform="pl",
|
platform="pl",
|
||||||
filter_packages=["foo"],
|
filter_packages=[("foo", None)],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -744,11 +745,13 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = {"pkg-3:1-2.x86_64": pkg}
|
nevra_to_pkg = {"pkg-3:1-2.x86_64": pkg}
|
||||||
if src or debug_arch:
|
if src or debug_arch:
|
||||||
nevra_to_pkg["pkg-3:1-2.src"] = pkg._replace(
|
nevra_to_pkg["pkg-3:1-2.src"] = pkg._replace(
|
||||||
arch="src", file_path="/tmp/spkg.rpm"
|
name="pkg", arch="src", file_path="/tmp/pkg.src.rpm"
|
||||||
)
|
)
|
||||||
if debug_arch:
|
if debug_arch:
|
||||||
nevra_to_pkg["pkg-debuginfo-3:1-2.%s" % debug_arch] = pkg._replace(
|
nevra_to_pkg["pkg-debuginfo-3:1-2.%s" % debug_arch] = pkg._replace(
|
||||||
name="pkg-debuginfo", arch=debug_arch, file_path="/tmp/d1.rpm"
|
name="pkg-debuginfo",
|
||||||
|
arch=debug_arch,
|
||||||
|
file_path="/tmp/pkg-debuginfo.%s.rpm" % debug_arch
|
||||||
)
|
)
|
||||||
return nevra_to_pkg
|
return nevra_to_pkg
|
||||||
|
|
||||||
@ -756,7 +759,7 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = self._mk_packages()
|
nevra_to_pkg = self._mk_packages()
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])]
|
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -772,15 +775,75 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])]
|
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
res,
|
res,
|
||||||
{
|
{
|
||||||
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
"srpm": [{"path": "/tmp/spkg.rpm", "flags": []}],
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
"debuginfo": [{"path": "/tmp/d1.rpm", "flags": []}],
|
"debuginfo": [{"path": "/tmp/pkg-debuginfo.x86_64.rpm", "flags": []}],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_filter_src_and_debuginfo(self):
|
||||||
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
|
res = hybrid.expand_packages(
|
||||||
|
nevra_to_pkg,
|
||||||
|
{},
|
||||||
|
[],
|
||||||
|
[("pkg-3:1-2", "x86_64", [])],
|
||||||
|
filter_packages=[("pkg-debuginfo", "x86_64"), ("pkg", "src")],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
res,
|
||||||
|
{
|
||||||
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
|
"srpm": [],
|
||||||
|
"debuginfo": [],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_filter_debuginfo_missing_arch(self):
|
||||||
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
|
res = hybrid.expand_packages(
|
||||||
|
nevra_to_pkg,
|
||||||
|
{},
|
||||||
|
[],
|
||||||
|
[("pkg-3:1-2", "x86_64", [])],
|
||||||
|
filter_packages=[("pkg-debuginfo", None)],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
res,
|
||||||
|
{
|
||||||
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
|
"debuginfo": [],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_filter_debuginfo_different_arch(self):
|
||||||
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
|
res = hybrid.expand_packages(
|
||||||
|
nevra_to_pkg,
|
||||||
|
{},
|
||||||
|
[],
|
||||||
|
[("pkg-3:1-2", "x86_64", [])],
|
||||||
|
filter_packages=[("pkg-debuginfo", "aarch64")],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
res,
|
||||||
|
{
|
||||||
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
|
"debuginfo": [{"path": "/tmp/pkg-debuginfo.x86_64.rpm", "flags": []}],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -788,14 +851,14 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", ["modular"])]
|
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", ["modular"])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
res,
|
res,
|
||||||
{
|
{
|
||||||
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
"srpm": [{"path": "/tmp/spkg.rpm", "flags": []}],
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
"debuginfo": [],
|
"debuginfo": [],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -804,15 +867,15 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, [], [("pkg-debuginfo-3:1-2", "x86_64", ["modular"])]
|
nevra_to_pkg, {}, [], [("pkg-debuginfo-3:1-2", "x86_64", ["modular"])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
res,
|
res,
|
||||||
{
|
{
|
||||||
"rpm": [],
|
"rpm": [],
|
||||||
"srpm": [{"path": "/tmp/spkg.rpm", "flags": []}],
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
"debuginfo": [{"path": "/tmp/d1.rpm", "flags": []}],
|
"debuginfo": [{"path": "/tmp/pkg-debuginfo.x86_64.rpm", "flags": []}],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -820,14 +883,14 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
nevra_to_pkg = self._mk_packages(debug_arch="i686")
|
nevra_to_pkg = self._mk_packages(debug_arch="i686")
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])]
|
nevra_to_pkg, {}, [], [("pkg-3:1-2", "x86_64", [])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
res,
|
res,
|
||||||
{
|
{
|
||||||
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
||||||
"srpm": [{"path": "/tmp/spkg.rpm", "flags": []}],
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
||||||
"debuginfo": [],
|
"debuginfo": [],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -841,20 +904,20 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
name="pkg",
|
name="pkg",
|
||||||
arch="src",
|
arch="src",
|
||||||
location_base="file:///tmp/",
|
location_base="file:///tmp/",
|
||||||
location_href="spkg.rpm",
|
location_href="pkg.src.rpm",
|
||||||
),
|
),
|
||||||
"def": NamedMock(
|
"def": NamedMock(
|
||||||
name="pkg-debuginfo",
|
name="pkg-debuginfo",
|
||||||
arch="x86_64",
|
arch="x86_64",
|
||||||
location_base="file:///tmp/",
|
location_base="file:///tmp/",
|
||||||
location_href="d1.rpm",
|
location_href="pkg-debuginfo.x86_64.rpm",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
cr.Metadata.return_value.keys.return_value = repo.keys()
|
cr.Metadata.return_value.keys.return_value = repo.keys()
|
||||||
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, lookasides, [("pkg-3:1-2", "x86_64", [])]
|
nevra_to_pkg, {}, lookasides, [("pkg-3:1-2", "x86_64", [])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -882,7 +945,7 @@ class TestExpandPackages(helpers.PungiTestCase):
|
|||||||
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
||||||
|
|
||||||
res = hybrid.expand_packages(
|
res = hybrid.expand_packages(
|
||||||
nevra_to_pkg, {}, lookasides, [("pkg-3:1-2", "x86_64", [])]
|
nevra_to_pkg, {}, lookasides, [("pkg-3:1-2", "x86_64", [])], []
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(res, {"rpm": [], "srpm": [], "debuginfo": []})
|
self.assertEqual(res, {"rpm": [], "srpm": [], "debuginfo": []})
|
||||||
|
Loading…
Reference in New Issue
Block a user