diff --git a/pungi/wrappers/repoclosure.py b/pungi/wrappers/repoclosure.py index f62b3da4..268df094 100644 --- a/pungi/wrappers/repoclosure.py +++ b/pungi/wrappers/repoclosure.py @@ -40,9 +40,13 @@ def get_repoclosure_cmd(backend="yum", arch=None, repos=None, lookaside=None): # There are options that are not exposed here, because we don't need # them. - for i in force_list(arch or []): + arches = force_list(arch or []) + for i in arches: cmd.append("--arch=%s" % i) + if backend == "dnf" and arches: + cmd.append("--forcearch=%s" % arches[0]) + repos = repos or {} for repo_id, repo_path in repos.items(): cmd.append("--repofrompath=%s,%s" % (repo_id, _to_url(repo_path))) diff --git a/tests/test_repoclosure_wrapper.py b/tests/test_repoclosure_wrapper.py index af2dc3e0..361d5846 100755 --- a/tests/test_repoclosure_wrapper.py +++ b/tests/test_repoclosure_wrapper.py @@ -25,8 +25,14 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase): def test_multiple_arches(self): self.assertEqual( - rc.get_repoclosure_cmd(arch=["x86_64", "ppc64"]), - ["/usr/bin/repoclosure", "--tempcache", "--arch=x86_64", "--arch=ppc64"], + rc.get_repoclosure_cmd(arch=["x86_64", "i686", "noarch"]), + [ + "/usr/bin/repoclosure", + "--tempcache", + "--arch=x86_64", + "--arch=i686", + "--arch=noarch", + ], ) def test_full_command(self): @@ -61,6 +67,34 @@ class RepoclosureWrapperTestCase(helpers.BaseTestCase): cmd[2:], [ "--arch=x86_64", + "--forcearch=x86_64", + "--repofrompath=my-repo,file:///mnt/koji/repo", + "--repofrompath=fedora,http://kojipkgs.fp.o/repo", + "--repo=my-repo", + "--check=my-repo", + "--repo=fedora", + ], + ) + + def test_dnf_command_with_multiple_arches(self): + repos = {"my-repo": "/mnt/koji/repo"} + lookaside = {"fedora": "http://kojipkgs.fp.o/repo"} + + cmd = rc.get_repoclosure_cmd( + backend="dnf", + arch=["x86_64", "i686", "noarch"], + repos=repos, + lookaside=lookaside, + ) + self.assertEqual(cmd[:2], ["dnf", "repoclosure"]) + six.assertCountEqual( + self, + cmd[2:], + [ + "--arch=x86_64", + "--arch=i686", + "--arch=noarch", + "--forcearch=x86_64", "--repofrompath=my-repo,file:///mnt/koji/repo", "--repofrompath=fedora,http://kojipkgs.fp.o/repo", "--repo=my-repo",