#1684 use preferred arch if there is more options
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1620  into  master

file modified
+11 -2
@@ -1349,8 +1349,17 @@ 

  

          rootopts = {

              'repo_id': repo_id

-             }

-         br_arch = self.find_arch(arch, self.session.host.getHost(), self.session.getBuildConfig(root, event=event_id))

+         }

+         if arch == "noarch":

+             # There could have been forced taskarch Exclusive/ExcludeArch,

+             # so we should honor it here.

+             task = self.session.getTaskInfo(self.id)

+             preferred_arch = task['arch']

+         else:

+             preferred_arch = None

+         br_arch = self.find_arch(arch, self.session.host.getHost(),

+                                  self.session.getBuildConfig(root, event=event_id),

+                                  preferred_arch=preferred_arch)

          broot = BuildRoot(self.session, self.options, root, br_arch, self.id, **rootopts)

          broot.workdir = self.workdir

  

file modified
+7 -1
@@ -495,10 +495,12 @@ 

      def subtask2(self, __taskopts, __method, *args, **kwargs):

          return self.session.host.subtask2(self.id, __taskopts, __method, *args, **kwargs)

  

-     def find_arch(self, arch, host, tag):

+     def find_arch(self, arch, host, tag, preferred_arch=None):

          """

          For noarch tasks, find a canonical arch that is supported by both the host and tag.

          If the arch is anything other than noarch, return it unmodified.

+ 

+         If preferred_arch is set, try to get it, but not fail on that

          """

          if arch != "noarch":

              return arch
@@ -521,6 +523,10 @@ 

          # find the intersection of host and tag arches

          common_arches = list(host_arches & tag_arches)

          if common_arches:

+             if preferred_arch and preferred_arch in common_arches:

+                 self.logger.info('Valid arches: %s, using preferred: %s' %

+                                  (' '.join(sorted(common_arches)), preferred_arch))

+                 return preferred_arch

              # pick one of the common arches randomly

              # need to re-seed the prng or we'll get the same arch every time,

              # because we just forked from a common parent

https://pagure.io/koji/pull-request/323 introduced option to force an
arch for noarch packages. Nevertheless, it is only task architecture and
not buildroot one. So, if builder can provide more possible archs (32/64
bit), it will pick one of these randomly and can go against preferred arch.

Patch introduces "preferred_arch" option for find_arch and use the
task's one when it works with noarch rpm.

Fixes: https://pagure.io/koji/issue/789

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Commit 5f3694e fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago