gather: Clean up method deps
* Remove unused arguments * Remove duplication Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
0168388492
commit
dcc1750df2
@ -38,16 +38,24 @@ class GatherMethodDeps(pungi.phases.gather.method.GatherMethodBase):
|
||||
# }
|
||||
|
||||
write_pungi_config(self.compose, arch, variant, packages, groups, filter_packages,
|
||||
multilib_whitelist, multilib_blacklist, package_set=package_sets[arch],
|
||||
multilib_whitelist, multilib_blacklist,
|
||||
fulltree_excludes=fulltree_excludes, prepopulate=prepopulate)
|
||||
result = resolve_deps(self.compose, arch, variant)
|
||||
check_deps(self.compose, arch, variant)
|
||||
return result
|
||||
|
||||
|
||||
def _format_packages(pkgs):
|
||||
"""Sort packages and merge name with arch."""
|
||||
for pkg_name, pkg_arch in sorted(pkgs):
|
||||
if pkg_arch:
|
||||
yield '%s.%s' % (pkg_name, pkg_arch)
|
||||
else:
|
||||
yield pkg_name
|
||||
|
||||
|
||||
def write_pungi_config(compose, arch, variant, packages, groups, filter_packages,
|
||||
multilib_whitelist, multilib_blacklist, repos=None,
|
||||
comps_repo=None, package_set=None, fulltree_excludes=None,
|
||||
multilib_whitelist, multilib_blacklist, fulltree_excludes=None,
|
||||
prepopulate=None):
|
||||
"""write pungi config (kickstart) for arch/variant"""
|
||||
pungi_wrapper = PungiWrapper()
|
||||
@ -60,27 +68,14 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
||||
|
||||
compose.log_info(msg)
|
||||
|
||||
if not repos:
|
||||
repo_path = compose.paths.work.arch_repo(arch=arch)
|
||||
repos = {"pungi-repo": repo_path}
|
||||
repos = {"pungi-repo": compose.paths.work.arch_repo(arch=arch)}
|
||||
|
||||
lookaside_repos = {}
|
||||
for i, repo_url in enumerate(pungi.phases.gather.get_lookaside_repos(compose, arch, variant)):
|
||||
lookaside_repos["lookaside-repo-%s" % i] = repo_url
|
||||
|
||||
packages_str = []
|
||||
for pkg_name, pkg_arch in sorted(packages):
|
||||
if pkg_arch:
|
||||
packages_str.append("%s.%s" % (pkg_name, pkg_arch))
|
||||
else:
|
||||
packages_str.append(pkg_name)
|
||||
|
||||
filter_packages_str = []
|
||||
for pkg_name, pkg_arch in sorted(filter_packages):
|
||||
if pkg_arch:
|
||||
filter_packages_str.append("%s.%s" % (pkg_name, pkg_arch))
|
||||
else:
|
||||
filter_packages_str.append(pkg_name)
|
||||
packages_str = list(_format_packages(packages))
|
||||
filter_packages_str = list(_format_packages(filter_packages))
|
||||
|
||||
if not groups and not packages_str and not prepopulate:
|
||||
raise RuntimeError(
|
||||
@ -89,7 +84,7 @@ def write_pungi_config(compose, arch, variant, packages, groups, filter_packages
|
||||
|
||||
pungi_wrapper.write_kickstart(
|
||||
ks_path=pungi_cfg, repos=repos, groups=groups, packages=packages_str,
|
||||
exclude_packages=filter_packages_str, comps_repo=comps_repo,
|
||||
exclude_packages=filter_packages_str,
|
||||
lookaside_repos=lookaside_repos, fulltree_excludes=fulltree_excludes,
|
||||
multilib_whitelist=multilib_whitelist, multilib_blacklist=multilib_blacklist,
|
||||
prepopulate=prepopulate)
|
||||
|
@ -28,11 +28,10 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
filter = [('pkg3', None), ('pkg4', 'x86_64')]
|
||||
white = mock.Mock()
|
||||
black = mock.Mock()
|
||||
comps_repo = mock.Mock()
|
||||
prepopulate = mock.Mock()
|
||||
fulltree = mock.Mock()
|
||||
deps.write_pungi_config(self.compose, 'x86_64', self.compose.variants['Server'],
|
||||
pkgs, grps, filter, white, black, comps_repo=comps_repo,
|
||||
pkgs, grps, filter, white, black,
|
||||
prepopulate=prepopulate, fulltree_excludes=fulltree)
|
||||
self.assertWritten(PungiWrapper, packages=['pkg1', 'pkg2.x86_64'],
|
||||
ks_path=self.topdir + '/work/x86_64/pungi/Server.x86_64.conf',
|
||||
@ -40,8 +39,7 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
groups=['grp1'], prepopulate=prepopulate,
|
||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||
exclude_packages=['pkg3', 'pkg4.x86_64'],
|
||||
fulltree_excludes=fulltree,
|
||||
comps_repo=comps_repo)
|
||||
fulltree_excludes=fulltree)
|
||||
|
||||
@mock.patch('pungi.phases.gather.get_lookaside_repos')
|
||||
@mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper')
|
||||
@ -56,7 +54,7 @@ class TestWritePungiConfig(helpers.PungiTestCase):
|
||||
multilib_whitelist=[], multilib_blacklist=[],
|
||||
groups=[], prepopulate=None,
|
||||
repos={'pungi-repo': self.topdir + '/work/x86_64/repo'},
|
||||
exclude_packages=[], fulltree_excludes=None, comps_repo=None)
|
||||
exclude_packages=[], fulltree_excludes=None)
|
||||
self.assertEqual(glr.call_args_list,
|
||||
[mock.call(self.compose, 'x86_64', self.compose.variants['Server'])])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user