From e2b3002726e6b25f2e8aa15d4ce7256fecd3ce4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 2 Nov 2021 08:49:04 +0100 Subject: [PATCH] repoclosure: Use --forcearch for dnf repoclosure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DNF repoclosure requires this option when checking a repository that is not compatible with host architecture. It seems that when it is compatible, it works as well. Based on how the list of architectures is generated, we know that the main one will always be first. Fixes: https://pagure.io/pungi/issue/1562 Signed-off-by: Lubomír Sedlář --- pungi/wrappers/repoclosure.py | 6 ++++- tests/test_repoclosure_wrapper.py | 38 +++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) 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",