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.
This commit is contained in:
Oliver Smith 2019-04-20 01:20:16 +02:00
parent 9241dbb35b
commit 99e7ae3019
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
2 changed files with 18 additions and 7 deletions

View File

@ -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):

View File

@ -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