diff --git a/pmb/helpers/package.py b/pmb/helpers/package.py index 5a7077a0..d907386c 100644 --- a/pmb/helpers/package.py +++ b/pmb/helpers/package.py @@ -164,13 +164,7 @@ def check_arch(args, pkgname, arch, binary=True): arches = get(args, pkgname, arch)["arch"] else: arches = pmb.helpers.pmaports.get(args, pkgname)["arch"] - - if "!" + arch in arches: - return False - for value in [arch, "all", "noarch"]: - if value in arches: - return True - return False + return pmb.helpers.pmaports.check_arches(arches, arch) def check_arch_recurse(args, pkgname, arch): diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py index 27c63d3f..2d60cc99 100644 --- a/pmb/helpers/pmaports.py +++ b/pmb/helpers/pmaports.py @@ -166,3 +166,20 @@ def get_repo(args, pkgname, must_exist=True): if not aport: return None return os.path.basename(os.path.dirname(aport)) + + +def check_arches(arches, arch): + """ Check if building for a certain arch is allowed. + + :param arches: list of all supported arches, as it can be found in the + arch="" line of APKBUILDS (including all, noarch, + !arch, ...). For example: ["x86_64", "x86", "!armhf"] + :param arch: the architecture to check for + :returns: True when building is allowed, False otherwise + """ + if "!" + arch in arches: + return False + for value in [arch, "all", "noarch"]: + if value in arches: + return True + return False