build: make preferred target arch configurable
When invoking pmbootstrap build most packages default to the host arch, however depending on your workflow it might be preferrable to default to the device arch. Add a new config option "build_default_device_arch" which when set will make "pmbootstrap build" prioritise the device arch over the native arch. Default to False to preserve the old behaviour and don't ask during pmbootstrap init as this may not be relevant for most folks. Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org> Co-developed-by: Oliver Smith <ollieparanoid@postmarketos.org> Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230418-build-default-arch-v5-2-5223fab65867@postmarketos.org%3E
This commit is contained in:
parent
681fcfe775
commit
204419fe49
21
README.md
21
README.md
|
@ -103,6 +103,27 @@ Generate a template for a new package:
|
|||
$ pmbootstrap newapkbuild "https://gitlab.com/postmarketOS/osk-sdl/-/archive/0.52/osk-sdl-0.52.tar.bz2"
|
||||
```
|
||||
|
||||
#### Default architecture
|
||||
|
||||
Packages will be compiled for the architecture of the device running
|
||||
pmbootstrap by default. For example, if your `x86_64` PC runs pmbootstrap, it
|
||||
would build a package for `x86_64` with this command:
|
||||
```
|
||||
$ pmbootstrap build hello-world
|
||||
```
|
||||
|
||||
If you would rather build for the target device selected in `pmbootstrap init`
|
||||
by default, then use the `build_default_device_arch` option:
|
||||
```
|
||||
$ pmbootstrap config build_default_device_arch True
|
||||
```
|
||||
|
||||
If your target device is `pine64-pinephone` for example, pmbootstrap will now
|
||||
build this package for `aarch64`:
|
||||
```
|
||||
$ pmbootstrap build hello-world
|
||||
```
|
||||
|
||||
### Chroots
|
||||
Enter the `armhf` building chroot:
|
||||
```
|
||||
|
|
|
@ -40,7 +40,7 @@ def arch(args, pkgname):
|
|||
:returns: arch string like "x86_64" or "armhf". Preferred order, depending
|
||||
on what is supported by the APKBUILD:
|
||||
* native arch
|
||||
* device arch
|
||||
* device arch (this will be preferred instead if build_default_device_arch is true)
|
||||
* first arch in the APKBUILD
|
||||
"""
|
||||
aport = pmb.helpers.pmaports.find(args, pkgname)
|
||||
|
@ -50,14 +50,19 @@ def arch(args, pkgname):
|
|||
|
||||
apkbuild = pmb.parse.apkbuild(f"{aport}/APKBUILD")
|
||||
arches = apkbuild["arch"]
|
||||
if ("noarch" in arches or
|
||||
"all" in arches or
|
||||
pmb.config.arch_native in arches):
|
||||
return pmb.config.arch_native
|
||||
|
||||
arch_device = args.deviceinfo["arch"]
|
||||
if arch_device in arches:
|
||||
return arch_device
|
||||
if args.build_default_device_arch:
|
||||
preferred_arch = args.deviceinfo["arch"]
|
||||
preferred_arch_2nd = pmb.config.arch_native
|
||||
else:
|
||||
preferred_arch = pmb.config.arch_native
|
||||
preferred_arch_2nd = args.deviceinfo["arch"]
|
||||
|
||||
if "noarch" in arches or "all" in arches or preferred_arch in arches:
|
||||
return preferred_arch
|
||||
|
||||
if preferred_arch_2nd in arches:
|
||||
return preferred_arch_2nd
|
||||
|
||||
try:
|
||||
return apkbuild["arch"][0]
|
||||
|
|
|
@ -63,6 +63,7 @@ sudo = which_sudo()
|
|||
config_keys = [
|
||||
"aports",
|
||||
"boot_size",
|
||||
"build_default_device_arch",
|
||||
"build_pkgs_on_install",
|
||||
"ccache_size",
|
||||
"device",
|
||||
|
@ -130,7 +131,8 @@ defaults = {
|
|||
"boot_size": "256",
|
||||
"extra_space": "0",
|
||||
"sudo_timer": False,
|
||||
"qemu_redir_stdio": False
|
||||
"qemu_redir_stdio": False,
|
||||
"build_default_device_arch": False,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue