Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/rift/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions lib/rift/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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):
"""
Expand Down
51 changes: 51 additions & 0 deletions tests/Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))