hybrid: Honor filter_packages

JIRA: COMPOSE-3011
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-10-16 12:29:00 +02:00
parent 111af836ea
commit 4f712259d7
4 changed files with 49 additions and 6 deletions

View File

@ -149,6 +149,7 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):
groups=[], groups=[],
multilib_whitelist=[], multilib_whitelist=[],
multilib_blacklist=[], multilib_blacklist=[],
filter_packages=[],
**kwargs **kwargs
): ):
self.arch = arch self.arch = arch
@ -172,7 +173,13 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):
expand_groups(self.compose, arch, variant, groups, set_pkg_arch=False) expand_groups(self.compose, arch, variant, groups, set_pkg_arch=False)
) )
nvrs, out_modules = self.run_solver(variant, arch, packages, platform) # Filters are received as tuples (name, arch), we should convert it to
# strings.
filter_packages = [_fmt_pkg(*p) for p in filter_packages]
nvrs, out_modules = self.run_solver(
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),
@ -182,7 +189,7 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):
) )
# maybe check invalid sigkeys # maybe check invalid sigkeys
def run_solver(self, variant, arch, packages, platform): def run_solver(self, variant, arch, packages, platform, filter_packages):
repos = [self.compose.paths.work.arch_repo(arch=arch)] repos = [self.compose.paths.work.arch_repo(arch=arch)]
modules = [] modules = []
@ -206,6 +213,7 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):
input_packages, input_packages,
modules, modules,
platform=platform, platform=platform,
filter_packages=filter_packages,
) )
logfile = self.compose.paths.log.log_file( logfile = self.compose.paths.log.log_file(
arch, "hybrid-depsolver-%s-iter-%d" % (variant, step) arch, "hybrid-depsolver-%s-iter-%d" % (variant, step)

View File

@ -32,7 +32,7 @@ def get_cmd(
packages, packages,
modules, modules,
platform=None, platform=None,
filter_packages=None, # TODO not supported yet filter_packages=None,
): ):
cmd = ["fus", "--verbose", "--arch", arch] cmd = ["fus", "--verbose", "--arch", arch]
@ -46,6 +46,9 @@ def get_cmd(
if platform: if platform:
cmd.append("--platform=%s" % platform) cmd.append("--platform=%s" % platform)
for pkg in sorted(filter_packages or []):
cmd.append("--exclude=%s" % pkg)
for module in modules: for module in modules:
cmd.append("module(%s)" % module) cmd.append("module(%s)" % module)

View File

@ -29,6 +29,7 @@ class TestGetCmd(unittest.TestCase):
["pkg"], ["pkg"],
["mod:1.0"], ["mod:1.0"],
platform="f29", platform="f29",
filter_packages=["foo", "bar"],
) )
self.assertEqual( self.assertEqual(
cmd, cmd,
@ -42,6 +43,8 @@ class TestGetCmd(unittest.TestCase):
"--repo=repo-0,repo,/tmp/first", "--repo=repo-0,repo,/tmp/first",
"--repo=repo-1,repo,/tmp/second", "--repo=repo-1,repo,/tmp/second",
"--platform=f29", "--platform=f29",
"--exclude=bar",
"--exclude=foo",
"module(mod:1.0)", "module(mod:1.0)",
"pkg", "pkg",
], ],

View File

@ -54,7 +54,7 @@ class TestMethodHybrid(helpers.PungiTestCase):
self.assertEqual(cmr.call_args_list, [mock.call(compose, variant, arch)]) self.assertEqual(cmr.call_args_list, [mock.call(compose, variant, arch)])
self.assertEqual( self.assertEqual(
m.run_solver.call_args_list, m.run_solver.call_args_list,
[mock.call(variant, arch, set(["pkg", "foo", "bar"]), cmr.return_value)], [mock.call(variant, arch, set(["pkg", "foo", "bar"]), cmr.return_value, [])],
) )
self.assertEqual( self.assertEqual(
ep.call_args_list, ep.call_args_list,
@ -333,6 +333,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[], [],
platform="pl", platform="pl",
filter_packages=["foo"],
) )
self.assertEqual(res, po.return_value) self.assertEqual(res, po.return_value)
@ -355,6 +356,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
[], [],
["mod:master"], ["mod:master"],
platform="pl", platform="pl",
filter_packages=["foo"],
) )
], ],
) )
@ -382,6 +384,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[], [],
platform="pl", platform="pl",
filter_packages=["foo"],
) )
self.assertEqual(res, po.return_value) self.assertEqual(res, po.return_value)
@ -404,6 +407,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
[], [],
["mod:master", "mod-devel:master"], ["mod:master", "mod-devel:master"],
platform="pl", platform="pl",
filter_packages=["foo"],
) )
], ],
) )
@ -415,6 +419,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[("pkg", None)], [("pkg", None)],
platform=None, platform=None,
filter_packages=[],
) )
self.assertEqual(res, po.return_value) self.assertEqual(res, po.return_value)
@ -429,7 +434,17 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
) )
self.assertEqual( self.assertEqual(
gc.call_args_list, gc.call_args_list,
[mock.call("x86_64", [self._repo("repo")], [], ["pkg"], [], platform=None)], [
mock.call(
"x86_64",
[self._repo("repo")],
[],
["pkg"],
[],
platform=None,
filter_packages=[],
)
],
) )
def test_with_langpacks(self, run, gc, po): def test_with_langpacks(self, run, gc, po):
@ -442,6 +457,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[("pkg", None)], [("pkg", None)],
platform=None, platform=None,
filter_packages=["foo"],
) )
self.assertEqual(res, (final, [])) self.assertEqual(res, (final, []))
@ -463,7 +479,13 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
gc.call_args_list, gc.call_args_list,
[ [
mock.call( mock.call(
"x86_64", [self._repo("repo")], [], ["pkg"], [], platform=None "x86_64",
[self._repo("repo")],
[],
["pkg"],
[],
platform=None,
filter_packages=["foo"],
), ),
mock.call( mock.call(
"x86_64", "x86_64",
@ -472,6 +494,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
["pkg", "pkg-en"], ["pkg", "pkg-en"],
[], [],
platform=None, platform=None,
filter_packages=["foo"],
), ),
], ],
) )
@ -509,6 +532,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[("pkg-devel", None), ("foo", None)], [("pkg-devel", None), ("foo", None)],
platform=None, platform=None,
filter_packages=[],
) )
self.assertEqual(res, (final, [])) self.assertEqual(res, (final, []))
@ -536,6 +560,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
["pkg-devel", "foo"], ["pkg-devel", "foo"],
[], [],
platform=None, platform=None,
filter_packages=[],
), ),
mock.call( mock.call(
"x86_64", "x86_64",
@ -544,6 +569,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
["pkg-devel", "foo", "pkg-devel.i686"], ["pkg-devel", "foo", "pkg-devel.i686"],
[], [],
platform=None, platform=None,
filter_packages=[],
), ),
], ],
) )
@ -607,6 +633,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
"x86_64", "x86_64",
[("pkg-devel", None), ("foo", None)], [("pkg-devel", None), ("foo", None)],
platform=None, platform=None,
filter_packages=[],
) )
self.assertEqual(res, (final, [])) self.assertEqual(res, (final, []))
@ -634,6 +661,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
["pkg-devel", "foo"], ["pkg-devel", "foo"],
[], [],
platform=None, platform=None,
filter_packages=[],
), ),
mock.call( mock.call(
"x86_64", "x86_64",
@ -642,6 +670,7 @@ class TestRunSolver(HelperMixin, helpers.PungiTestCase):
["pkg-devel", "foo", "foo.i686"], ["pkg-devel", "foo", "foo.i686"],
[], [],
platform=None, platform=None,
filter_packages=[],
), ),
], ],
) )