diff --git a/pungi/phases/gather/methods/method_deps.py b/pungi/phases/gather/methods/method_deps.py index 44fb60b2..e82c9070 100644 --- a/pungi/phases/gather/methods/method_deps.py +++ b/pungi/phases/gather/methods/method_deps.py @@ -68,15 +68,17 @@ def raise_on_invalid_sigkeys(arch, variant, package_sets, result): def _format_packages(pkgs): """Sort packages and merge name with arch.""" - for pkg, pkg_arch in sorted(pkgs): + result = set() + for pkg, pkg_arch in pkgs: if type(pkg) in [SimpleRpmWrapper, RpmWrapper]: pkg_name = pkg.name else: pkg_name = pkg if pkg_arch: - yield '%s.%s' % (pkg_name, pkg_arch) + result.add("%s.%s" % (pkg_name, pkg_arch)) else: - yield pkg_name + result.add(pkg_name) + return sorted(result) def write_pungi_config(compose, arch, variant, packages, groups, filter_packages, diff --git a/tests/test_gather_method_deps.py b/tests/test_gather_method_deps.py index 1d577209..85a24a47 100644 --- a/tests/test_gather_method_deps.py +++ b/tests/test_gather_method_deps.py @@ -41,6 +41,27 @@ class TestWritePungiConfig(helpers.PungiTestCase): exclude_packages=['pkg3', 'pkg4.x86_64'], fulltree_excludes=fulltree, package_whitelist=set()) + @mock.patch("pungi.phases.gather.methods.method_deps.PungiWrapper") + def test_duplicated_package_name(self, PungiWrapper): + pkgs = [("pkg1", None), ("pkg1", "x86_64")] + grps = [] + filter = [("pkg2", None), ("pkg2", "x86_64")] + white = mock.Mock() + black = 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, + prepopulate=prepopulate, fulltree_excludes=fulltree) + self.assertWritten(PungiWrapper, packages=["pkg1", "pkg1.x86_64"], + ks_path=self.topdir + "/work/x86_64/pungi/Server.x86_64.conf", + lookaside_repos={}, multilib_whitelist=white, multilib_blacklist=black, + groups=[], prepopulate=prepopulate, + repos={"pungi-repo": self.topdir + "/work/x86_64/repo", + "comps-repo": self.topdir + "/work/x86_64/comps_repo_Server"}, + exclude_packages=["pkg2", "pkg2.x86_64"], + fulltree_excludes=fulltree, package_whitelist=set()) + @mock.patch('pungi.phases.gather.get_lookaside_repos') @mock.patch('pungi.phases.gather.methods.method_deps.PungiWrapper') def test_with_lookaside(self, PungiWrapper, glr):