#914 pkgset: Add option to ignore noarch in ExclusiveArch
Merged 5 years ago by lsedlar. Opened 5 years ago by lsedlar.
lsedlar/pungi fix-noarch-exclude  into  master

file modified
+6
@@ -471,6 +471,12 @@ 

      (*dict*) -- A mapping of architectures to repositories with RPMs: ``{arch:

      [repo]}``. Only use when ``pkgset_source = "repos"``.

  

+ **pkgset_exclusive_arch_considers_noarch** = True

+     (*bool*) -- If a package includes ``noarch`` in its ``ExclusiveArch`` tag,

+     it will be included in all architectures since ``noarch`` is compatible

+     with everything. Set this option to ``False`` to ignore ``noarch`` in

+     ``ExclusiveArch`` and always consider only binary architectures.

+ 

  

  Example

  -------

file modified
+4
@@ -757,6 +757,10 @@ 

                  "type": "boolean",

                  "default": False

              },

+             "pkgset_exclusive_arch_considers_noarch": {

+                 "type": "boolean",

+                 "default": True,

+             },

  

              "disc_types": {

                  "type": "object",

@@ -27,12 +27,13 @@ 

  # TODO: per arch?

  def populate_arch_pkgsets(compose, path_prefix, global_pkgset):

      result = {}

+     exclusive_noarch = compose.conf['pkgset_exclusive_arch_considers_noarch']

      for arch in compose.get_arches():

          compose.log_info("Populating package set for arch: %s" % arch)

          is_multilib = is_arch_multilib(compose.conf, arch)

          arches = get_valid_arches(arch, is_multilib, add_src=True)

          pkgset = pungi.phases.pkgset.pkgsets.PackageSetBase(compose.conf["sigkeys"], logger=compose._logger, arches=arches)

-         pkgset.merge(global_pkgset, arch, arches)

+         pkgset.merge(global_pkgset, arch, arches, exclusive_noarch=exclusive_noarch)

          pkgset.save_file_list(compose.paths.work.package_list(arch=arch), remove_path_prefix=path_prefix)

          result[arch] = pkgset

      return result

@@ -161,7 +161,7 @@ 

  

          return self.rpms_by_arch

  

-     def merge(self, other, primary_arch, arch_list):

+     def merge(self, other, primary_arch, arch_list, exclusive_noarch=True):

          """

          Merge ``other`` package set into this instance.

          """
@@ -184,6 +184,13 @@ 

          if primary_arch:

              exclusivearch_list = get_valid_arches(

                  primary_arch, multilib=False, add_noarch=False, add_src=False)

+             # We don't want to consider noarch: if a package is true noarch

+             # build (not just a subpackage), it has to have noarch in

+             # ExclusiveArch otherwise rpm will refuse to build it.

+             # This should eventually become a default, but it could have a big

+             # impact and thus it's hidden behind an option.

+             if not exclusive_noarch and 'noarch' in exclusivearch_list:

+                 exclusivearch_list.remove('noarch')

          else:

              exclusivearch_list = None

          for arch in arch_list:

The add_noarch option of get_valid_arches is broken and doesn't really do anything (noarch is always present in the result).

This causes packages that have ExclusiveArch including noarch to actually not be excluded. They should be.

Changing this globally could have a very big impact. Therefore we can hide it behind a configuration option so that it's opt-in.

This is basically what mash did. It ignored noarch in the list of compatible arches as well.

rebased onto 46889b2e2577d05a497cd8f784ae50e64d9c5d2a

5 years ago

I modified this PR so that it can be merged and users can try to run a compose with it to see how it changes the results. The default behaviour will not be affected.

Pretty please pagure-ci rebuild

rebased onto a4bbf47

5 years ago

The code itself looks good for me. Probably the least painful solution.

Tested in Fedora stage with F27 packages. The difference is not huge. Some packages are clearly included where they should not be. Others have incorrectly set ExclusiveArch. However since this fix is opt-in, we can merge it and release it.

Pull-Request has been merged by lsedlar

5 years ago