#1563 repoclosure: Use --forcearch for dnf repoclosure
Merged 2 years ago by lsedlar. Opened 2 years ago by lsedlar.
lsedlar/pungi repoclosure-fix  into  master

@@ -40,9 +40,13 @@ 

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

@@ -25,8 +25,14 @@ 

  

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

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

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

I tested this today and it works. Thanks!

Pull-Request has been merged by lsedlar

2 years ago