Fix #941: Use the right arch for foreign-arch-only packages (#943)

This is a follow-up to #935.

* fix regression #941: pmbootstrap doesn't automatically pick the
  right architecture for building when none is specified
* remove obsolete --noarch-arch parameter
This commit is contained in:
Oliver Smith 2017-11-28 19:12:16 +00:00 committed by GitHub
parent b5b127756b
commit e9ca68dc05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 10 deletions

View File

@ -22,6 +22,22 @@ import pmb.chroot.apk
import pmb.parse.arch
def arch(args, pkgname):
"""
Find a good default in case the user did not specify for which architecture
a package should be built.
:returns: native architecture (x86_64 in most cases) when the APKBUILD has
"noarch" or "all". Otherwise the first architecture in the
APKBUILD.
"""
aport = pmb.build.find_aport(args, pkgname)
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
if "noarch" in apkbuild["arch"] or "all" in apkbuild["arch"]:
return args.arch_native
return apkbuild["arch"][0]
def suffix(args, apkbuild, arch):
if arch == args.arch_native:
return "native"

View File

@ -27,6 +27,7 @@ import sys
import pmb.aportgen
import pmb.build
import pmb.build.autodetect
import pmb.config
import pmb.challenge
import pmb.chroot
@ -141,7 +142,8 @@ def build(args):
# Build all packages
for package in args.packages:
pmb.build.package(args, package, args.arch, args.force,
arch_package = args.arch or pmb.build.autodetect.arch(args, package)
pmb.build.package(args, package, arch_package, args.force,
args.buildinfo, args.strict)

View File

@ -156,6 +156,10 @@ def apkbuild(args, path):
raise RuntimeError("The pkgname must be equal to the name of"
" the folder, that contains the APKBUILD!")
# Sanity check: arch
if not len(ret["arch"]):
raise RuntimeError("Arch must not be empty: " + path)
# Fill cache
args.cache["apkbuild"][path] = ret
return ret

View File

@ -270,9 +270,10 @@ 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", choices=arch_choices, default=arch_native,
build.add_argument("--arch", choices=arch_choices, default=None,
help="CPU architecture to build for (default: " +
arch_native + ")")
arch_native + " or first available architecture in"
" APKBUILD)")
build.add_argument("--force", action="store_true", help="even build if not"
" necessary")
build.add_argument("--buildinfo", action="store_true")
@ -285,13 +286,6 @@ def arguments():
" you don't need to build and install the kernel. But it"
" is incompatible with how Alpine's abuild handles it.",
dest="ignore_depends")
build.add_argument("--noarch-arch", dest="noarch_arch", default=None,
help="which architecture to use to build 'noarch'"
" packages. Defaults to the native arch normally,"
" and to the device arch when --strict is set."
" Override in case of strict mode failing on"
" dependencies, which only exist for a certain"
" arch.")
for action in [checksum, build, aportgen]:
action.add_argument("packages", nargs="+")