diff --git a/doc/configuration.rst b/doc/configuration.rst index c0119d6d..80c0c962 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -581,6 +581,16 @@ Options with everything. Set this option to ``False`` to ignore ``noarch`` in ``ExclusiveArch`` and always consider only binary architectures. +**pkgset_inherit_exclusive_arch_to_noarch** = True + (*bool*) -- When set to ``True``, the value of ``ExclusiveArch`` or + ``ExcludeArch`` will be copied from source rpm to all its noarch packages. + That will than limit which architectures the noarch packages can be + included in. + + By setting this option to ``False`` this step is skipped, and noarch + packages will by default land in all architectures. They can still be + excluded by listing them in a relevant section of ``filter_packages``. + **pkgset_allow_reuse** = True (*bool*) -- When set to ``True``, *Pungi* will try to reuse pkgset data from the old composes specified by ``--old-composes``. When enabled, this diff --git a/pungi/checks.py b/pungi/checks.py index 1b0bf201..cc7d00c7 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -830,6 +830,10 @@ def make_schema(): "type": "boolean", "default": True, }, + "pkgset_inherit_exclusive_arch_to_noarch": { + "type": "boolean", + "default": True, + }, "pkgset_scratch_modules": { "type": "object", "patternProperties": { diff --git a/pungi/phases/pkgset/common.py b/pungi/phases/pkgset/common.py index 14dad789..800eaa6c 100644 --- a/pungi/phases/pkgset/common.py +++ b/pungi/phases/pkgset/common.py @@ -38,12 +38,17 @@ from pungi.phases.createrepo import add_modular_metadata 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 = global_pkgset.subset(arch, arches, exclusive_noarch=exclusive_noarch) + pkgset = global_pkgset.subset( + arch, + arches, + exclusive_noarch=compose.conf["pkgset_exclusive_arch_considers_noarch"], + inherit_to_noarch=compose.conf["pkgset_inherit_exclusive_arch_to_noarch"], + ) pkgset.save_file_list( compose.paths.work.package_list(arch=arch, pkgset=global_pkgset), remove_path_prefix=path_prefix, diff --git a/pungi/phases/pkgset/pkgsets.py b/pungi/phases/pkgset/pkgsets.py index 7d543421..c0611747 100644 --- a/pungi/phases/pkgset/pkgsets.py +++ b/pungi/phases/pkgset/pkgsets.py @@ -203,16 +203,31 @@ class PackageSetBase(kobo.log.LoggingBase): return self.rpms_by_arch - def subset(self, primary_arch, arch_list, exclusive_noarch=True): + def subset( + self, primary_arch, arch_list, exclusive_noarch=True, inherit_to_noarch=True + ): """Create a subset of this package set that only includes packages compatible with""" pkgset = PackageSetBase( self.name, self.sigkey_ordering, logger=self._logger, arches=arch_list ) - pkgset.merge(self, primary_arch, arch_list, exclusive_noarch=exclusive_noarch) + pkgset.merge( + self, + primary_arch, + arch_list, + exclusive_noarch=exclusive_noarch, + inherit_to_noarch=inherit_to_noarch, + ) return pkgset - def merge(self, other, primary_arch, arch_list, exclusive_noarch=True): + def merge( + self, + other, + primary_arch, + arch_list, + exclusive_noarch=True, + inherit_to_noarch=True, + ): """ Merge ``other`` package set into this instance. """ @@ -251,7 +266,7 @@ class PackageSetBase(kobo.log.LoggingBase): if i.file_path in self.file_cache: # TODO: test if it really works continue - if exclusivearch_list and arch == "noarch": + if inherit_to_noarch and exclusivearch_list and arch == "noarch": if is_excluded(i, exclusivearch_list, logger=self._logger): continue diff --git a/tests/test_pkgset_common.py b/tests/test_pkgset_common.py index 4e4ae9fe..96f6312d 100755 --- a/tests/test_pkgset_common.py +++ b/tests/test_pkgset_common.py @@ -47,7 +47,7 @@ class TestMaterializedPkgsetCreate(helpers.PungiTestCase): pkgset.name = name pkgset.reuse = None - def mock_subset(primary, arch_list, exclusive_noarch): + def mock_subset(primary, arch_list, **kwargs): self.subsets[primary] = mock.Mock() return self.subsets[primary] @@ -73,10 +73,16 @@ class TestMaterializedPkgsetCreate(helpers.PungiTestCase): self.assertEqual(result["amd64"], self.subsets["amd64"]) self.pkgset.subset.assert_any_call( - "x86_64", ["x86_64", "noarch", "src"], exclusive_noarch=True + "x86_64", + ["x86_64", "noarch", "src"], + exclusive_noarch=True, + inherit_to_noarch=True, ) self.pkgset.subset.assert_any_call( - "amd64", ["amd64", "x86_64", "noarch", "src"], exclusive_noarch=True + "amd64", + ["amd64", "x86_64", "noarch", "src"], + exclusive_noarch=True, + inherit_to_noarch=True, ) for arch, pkgset in result.package_sets.items(): diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index 4436d23a..ee63c35b 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -934,6 +934,28 @@ class TestMergePackageSets(PkgsetCompareMixin, unittest.TestCase): first.rpms_by_arch, {"i686": ["rpms/bash@4.3.42@4.fc24@i686"], "noarch": []} ) + def test_merge_doesnt_exclude_noarch_exclude_arch_when_configured(self): + first = pkgsets.PackageSetBase("first", [None]) + second = pkgsets.PackageSetBase("second", [None]) + + pkg = first.file_cache.add("rpms/bash@4.3.42@4.fc24@i686") + first.rpms_by_arch.setdefault(pkg.arch, []).append(pkg) + + pkg = second.file_cache.add("rpms/pungi@4.1.3@3.fc25@noarch") + pkg.excludearch = ["i686"] + second.rpms_by_arch.setdefault(pkg.arch, []).append(pkg) + + first.merge(second, "i386", ["i686", "noarch"], inherit_to_noarch=False) + + print(first.rpms_by_arch) + self.assertPkgsetEqual( + first.rpms_by_arch, + { + "i686": ["rpms/bash@4.3.42@4.fc24@i686"], + "noarch": ["rpms/pungi@4.1.3@3.fc25@noarch"], + }, + ) + def test_merge_excludes_noarch_exclusive_arch(self): first = pkgsets.PackageSetBase("first", [None]) second = pkgsets.PackageSetBase("second", [None])