diff --git a/lib/rift/Controller.py b/lib/rift/Controller.py index 0268427..c3a7407 100644 --- a/lib/rift/Controller.py +++ b/lib/rift/Controller.py @@ -539,7 +539,7 @@ def test_pkgs(config, args, pkgs, arch, extra_repos=None): results.add_failure(case, time.time() - now, err=str(ex)) continue - if not spec.supports_arch(arch): + if not pkg.supports_arch(arch) or not spec.supports_arch(arch): logging.info( "Skipping test on architecture %s not supported by " "package %s", @@ -585,7 +585,7 @@ def validate_pkgs(config, args, pkgs, arch): results.add_failure(case, time.time() - now, err=str(ex)) continue # skip current package - if not spec.supports_arch(arch): + if not pkg.supports_arch(arch) or not spec.supports_arch(arch): logging.info( "Skipping validation on architecture %s not supported by " "package %s", @@ -753,7 +753,7 @@ def build_pkgs(config, args, pkgs, arch): results.add_failure(case, time.time() - now, err=str(ex)) continue # skip current package - if not spec.supports_arch(arch): + if not pkg.supports_arch(arch) or not spec.supports_arch(arch): logging.info( "Skipping build on architecture %s not supported by " "package %s", diff --git a/lib/rift/Package.py b/lib/rift/Package.py index 808b239..a8ab0fe 100644 --- a/lib/rift/Package.py +++ b/lib/rift/Package.py @@ -69,6 +69,7 @@ def __init__(self, name, config, staff, modules): self.origin = None self.ignore_rpms = None self.rpmnames = None + self.exclude_archs = None # Static paths pkgdir = os.path.join(self._config.get('packages_dir'), self.name) @@ -131,6 +132,8 @@ def write(self): data['rpm_names'] = self.rpmnames if self.ignore_rpms: data['ignore_rpms'] = self.ignore_rpms + if self.exclude_archs: + data['exclude_archs'] = self.exclude_archs with open(self.metafile, 'w', encoding='utf-8') as fyaml: yaml.dump({'package': data}, fyaml, default_flow_style=False) @@ -163,6 +166,10 @@ def load(self, infopath=None): self.ignore_rpms = [data.get('ignore_rpms')] else: self.ignore_rpms = data.get('ignore_rpms', []) + if isinstance(data.get('exclude_archs'), str): + self.exclude_archs = [data.get('exclude_archs')] + else: + self.exclude_archs = data.get('exclude_archs', []) self.check_info() @@ -197,6 +204,13 @@ def build_rpms(self, mock, srpm, sign): """ return mock.build_rpms(srpm, sign) + def supports_arch(self, arch): + """ + Return True if package does not exclude any architecture or the given + arch is not listed in excluded architectures. + """ + return not self.exclude_archs or arch not in self.exclude_archs + @classmethod def list(cls, config, staff, modules, names=None): """ diff --git a/tests/Package.py b/tests/Package.py index e5a615b..83706e6 100644 --- a/tests/Package.py +++ b/tests/Package.py @@ -62,3 +62,54 @@ def test_load(self): self.assertEqual(pkg.origin, 'Company') self.assertEqual(pkg.rpmnames, [ 'pkg', 'pkg-devel' ]) self.assertEqual(pkg.ignore_rpms, [ 'pkg-debuginfos' ]) + self.assertCountEqual(pkg.exclude_archs, []) + + def test_load_exclude_archs_str(self): + """ Test Package information loading with exclude_archs string """ + pkgfile = make_temp_file(""" +package: + maintainers: + - J. Doe + module: Tools + reason: Missing package + origin: Company + exclude_archs: x86_64 + """) + pkg = Package('pkg', self.config, self.staff, self.modules) + pkg.load(infopath = pkgfile.name) + self.assertEqual(pkg.module, 'Tools') + self.assertEqual(pkg.maintainers, ['J. Doe']) + self.assertEqual(pkg.reason, 'Missing package') + self.assertEqual(pkg.origin, 'Company') + self.assertCountEqual(pkg.exclude_archs, ['x86_64']) + + def test_load_exclude_archs_list(self): + """ Test Package information loading with exclude_archs list """ + pkgfile = make_temp_file(""" +package: + maintainers: + - J. Doe + module: Tools + reason: Missing package + origin: Company + exclude_archs: + - x86_64 + - aarch64 + """) + pkg = Package('pkg', self.config, self.staff, self.modules) + pkg.load(infopath = pkgfile.name) + self.assertEqual(pkg.module, 'Tools') + self.assertEqual(pkg.maintainers, ['J. Doe']) + self.assertEqual(pkg.reason, 'Missing package') + self.assertEqual(pkg.origin, 'Company') + self.assertCountEqual(pkg.exclude_archs, ['x86_64', 'aarch64']) + + def test_supports_arch(self): + """ Test Package.supports_arch() """ + pkg = Package('pkg', self.config, self.staff, self.modules) + pkg.exclude_archs = [] + self.assertTrue(pkg.supports_arch('x86_64')) + self.assertTrue(pkg.supports_arch('aarch64')) + pkg.exclude_archs = ['x86_64'] + self.assertFalse(pkg.supports_arch('x86_64')) + self.assertTrue(pkg.supports_arch('aarch64'))