Support multiple architectures in `pmbootstrap menuconfig` command (#814)

This commit is contained in:
drebrez 2017-10-24 18:18:42 +02:00 committed by Oliver Smith
parent 860482f386
commit 459f97ef1d
3 changed files with 33 additions and 4 deletions

View File

@ -28,7 +28,32 @@ import pmb.helpers.run
import pmb.parse
def menuconfig(args, pkgname, arch):
def get_arch(args, apkbuild):
"""
Get the architecture, that the user wants to run menuconfig on, depending on
the APKBUILD and on the --arch parameter.
:param apkbuild: looks like: {"pkgname": "linux-...", "arch": ["all"]}
or: {"pkgname": "linux-...", "arch": ["armhf"]}
"""
pkgname = apkbuild["pkgname"]
# Multiple architectures (requires --arch)
if "all" in apkbuild["arch"]:
if args.arch is None:
raise RuntimeError("Package '" + pkgname + "' supports multiple"
" architectures, please use '--arch' to specify"
" the desired architecture.")
return args.arch
# Single architecture (--arch must be unset or match)
if args.arch is None or args.arch == apkbuild["arch"][0]:
return apkbuild["arch"][0]
raise RuntimeError("Package '" + pkgname + "' only supports the '" +
apkbuild["arch"][0] + "' architecture.")
def menuconfig(args, pkgname):
# Pkgname: allow omitting "linux-" prefix
if pkgname.startswith("linux-"):
pkgname_ = pkgname.split("linux-")[1]
@ -40,6 +65,7 @@ def menuconfig(args, pkgname, arch):
# Read apkbuild
aport = pmb.build.find_aport(args, pkgname)
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
arch = get_arch(args, apkbuild)
# Set up build tools and makedepends
pmb.build.init(args)

View File

@ -150,7 +150,7 @@ def export(args):
def menuconfig(args):
pmb.build.menuconfig(args, args.package, args.deviceinfo["arch"])
pmb.build.menuconfig(args, args.package)
def kconfig_check(args):

View File

@ -101,6 +101,8 @@ def arguments_initfs(subparser):
def arguments():
parser = argparse.ArgumentParser(prog="pmbootstrap")
arch_native = pmb.parse.arch.alpine_native()
arch_choices = set(pmb.config.build_device_architectures + [arch_native])
# Other
parser.add_argument("-V", "--version", action="version",
@ -227,6 +229,7 @@ def arguments():
# Action: menuconfig / parse_apkbuild
menuconfig = sub.add_parser("menuconfig", help="run menuconfig on"
" a kernel aport")
menuconfig.add_argument("--arch", choices=arch_choices)
parse_apkbuild = sub.add_parser("parse_apkbuild")
for action in [menuconfig, parse_apkbuild]:
action.add_argument("package")
@ -237,7 +240,7 @@ def arguments():
" (aport/APKBUILD) based on an upstream aport from Alpine")
build = sub.add_parser("build", help="create a package for a"
" specific architecture")
build.add_argument("--arch")
build.add_argument("--arch", choices=arch_choices)
build.add_argument("--force", action="store_true")
build.add_argument("--buildinfo", action="store_true")
build.add_argument("--strict", action="store_true", help="(slower) zap and install only"
@ -319,7 +322,7 @@ def arguments():
setattr(args, varname, old.replace("$WORK", args.work))
# Add convenience shortcuts
setattr(args, "arch_native", pmb.parse.arch.alpine_native())
setattr(args, "arch_native", arch_native)
# Add a caching dict (caches parsing of files etc. for the current session)
setattr(args, "cache", {"apkindex": {},