arch: Move exclu(de|sive)arch check to a function
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
3601d6d1a8
commit
700106facf
@ -91,3 +91,18 @@ def split_name_arch(name_arch):
|
|||||||
else:
|
else:
|
||||||
name, arch = name_arch, None
|
name, arch = name_arch, None
|
||||||
return name, arch
|
return name, arch
|
||||||
|
|
||||||
|
|
||||||
|
def is_excluded(package, arches, logger=None):
|
||||||
|
"""Check if package is excluded from given architectures."""
|
||||||
|
if (package.excludearch and set(package.excludearch) & set(arches)):
|
||||||
|
if logger:
|
||||||
|
logger.debug("Excluding (EXCLUDEARCH: %s): %s"
|
||||||
|
% (sorted(set(package.excludearch)), package.file_name))
|
||||||
|
return True
|
||||||
|
if (package.exclusivearch and not (set(package.exclusivearch) & set(arches))):
|
||||||
|
if logger:
|
||||||
|
logger.debug("Excluding (EXCLUSIVEARCH: %s): %s"
|
||||||
|
% (sorted(set(package.exclusivearch)), package.file_name))
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
@ -48,11 +48,7 @@ class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):
|
|||||||
for rpm_obj in rpms:
|
for rpm_obj in rpms:
|
||||||
# Skip the RPM if it is excluded on this arch or exclusive
|
# Skip the RPM if it is excluded on this arch or exclusive
|
||||||
# for different arch.
|
# for different arch.
|
||||||
if (rpm_obj.excludearch and
|
if pungi.arch.is_excluded(rpm_obj, compatible_arches):
|
||||||
set(rpm_obj.excludearch) & set(compatible_arches)):
|
|
||||||
continue
|
|
||||||
if (rpm_obj.exclusivearch and not
|
|
||||||
(set(rpm_obj.exclusivearch) & set(compatible_arches))):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for mmd in variant.mmds:
|
for mmd in variant.mmds:
|
||||||
|
@ -30,7 +30,7 @@ from kobo.threads import WorkerThread, ThreadPool
|
|||||||
|
|
||||||
import pungi.wrappers.kojiwrapper
|
import pungi.wrappers.kojiwrapper
|
||||||
from pungi.util import pkg_is_srpm
|
from pungi.util import pkg_is_srpm
|
||||||
from pungi.arch import get_valid_arches
|
from pungi.arch import get_valid_arches, is_excluded
|
||||||
|
|
||||||
|
|
||||||
class ReaderPool(ThreadPool):
|
class ReaderPool(ThreadPool):
|
||||||
@ -160,13 +160,7 @@ class PackageSetBase(kobo.log.LoggingBase):
|
|||||||
# TODO: test if it really works
|
# TODO: test if it really works
|
||||||
continue
|
continue
|
||||||
if exclusivearch_list and arch == "noarch":
|
if exclusivearch_list and arch == "noarch":
|
||||||
if i.excludearch and set(i.excludearch) & set(exclusivearch_list):
|
if is_excluded(i, exclusivearch_list, logger=self._logger):
|
||||||
self.log_debug("Excluding (EXCLUDEARCH: %s): %s"
|
|
||||||
% (sorted(set(i.excludearch)), i.file_name))
|
|
||||||
continue
|
|
||||||
if i.exclusivearch and not (set(i.exclusivearch) & set(exclusivearch_list)):
|
|
||||||
self.log_debug("Excluding (EXCLUSIVEARCH: %s): %s"
|
|
||||||
% (sorted(set(i.exclusivearch)), i.file_name))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if arch in ("nosrc", "src"):
|
if arch in ("nosrc", "src"):
|
||||||
|
@ -118,5 +118,24 @@ class TestArch(unittest.TestCase):
|
|||||||
self.assertEqual(get_valid_multilib_arches("x86_64"), ['athlon', 'i686', 'i586', 'i486', 'i386'])
|
self.assertEqual(get_valid_multilib_arches("x86_64"), ['athlon', 'i686', 'i586', 'i486', 'i386'])
|
||||||
|
|
||||||
|
|
||||||
|
class TestExclusiveExcludeArch(unittest.TestCase):
|
||||||
|
def test_no_exclude(self):
|
||||||
|
pkg = mock.Mock(excludearch=[], exclusivearch=[], file_name='pkg.rpm')
|
||||||
|
self.assertFalse(is_excluded(pkg, ['x86_64']))
|
||||||
|
|
||||||
|
def test_exclude_arch(self):
|
||||||
|
log = mock.Mock()
|
||||||
|
pkg = mock.Mock(excludearch=['x86_64'], exclusivearch=[], file_name='pkg.rpm')
|
||||||
|
self.assertTrue(is_excluded(pkg, ['x86_64'], logger=log))
|
||||||
|
self.assertEqual(log.mock_calls,
|
||||||
|
[mock.call.debug("Excluding (EXCLUDEARCH: ['x86_64']): pkg.rpm")])
|
||||||
|
|
||||||
|
def test_exclusive_arch(self):
|
||||||
|
log = mock.Mock()
|
||||||
|
pkg = mock.Mock(excludearch=[], exclusivearch=['aarch64'], file_name='pkg.rpm')
|
||||||
|
self.assertTrue(is_excluded(pkg, ['x86_64'], logger=log))
|
||||||
|
self.assertEqual(log.mock_calls,
|
||||||
|
[mock.call.debug("Excluding (EXCLUSIVEARCH: ['aarch64']): pkg.rpm")])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user