pkgset: Add option to ignore noarch in ExclusiveArch

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.

JIRA: COMPOSE-2457
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-04-17 12:56:13 +02:00
parent c85d80f3c2
commit a4bbf475f1
4 changed files with 20 additions and 2 deletions

View File

@ -471,6 +471,12 @@ Options
(*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
-------

View File

@ -757,6 +757,10 @@ def make_schema():
"type": "boolean",
"default": False
},
"pkgset_exclusive_arch_considers_noarch": {
"type": "boolean",
"default": True,
},
"disc_types": {
"type": "object",

View File

@ -27,12 +27,13 @@ from pungi.util import is_arch_multilib, find_old_compose
# 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

View File

@ -161,7 +161,7 @@ class PackageSetBase(kobo.log.LoggingBase):
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 @@ class PackageSetBase(kobo.log.LoggingBase):
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: