From 99e7ae30194e79697ed2908c629cd12f26c3b09d Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sat, 20 Apr 2019 01:20:16 +0200 Subject: [PATCH] pmb.helpers.package.check_arch(): split (!1776) Split the part that actually checks the arch against the arches list into pmb.helpers.pmaports.check_arches(arches, arch), and call it from pmb.helpers.package.check_arch(args, pkgname, arch, binary). This will be used in a follow up commit, where we have already resolved the package data and only need to check the architecture. --- pmb/helpers/package.py | 8 +------- pmb/helpers/pmaports.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) 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