repoclosure: Use --forcearch for dnf repoclosure

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2021-11-02 08:49:04 +01:00
parent e8305f3978
commit e2b3002726
2 changed files with 41 additions and 3 deletions

View File

@ -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)))

View File

@ -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",