pmb.chroot: install() make chroot a required argument (MR 2252)

Defaulting to the native chroot isn't necessarily intuitive. Let's
require this be specified in full.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-24 03:33:13 +02:00 committed by Oliver Smith
parent 3322eab30c
commit 2e68f40dd4
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
8 changed files with 19 additions and 18 deletions

View file

@ -198,7 +198,7 @@ def is_necessary_warn_depends(args: PmbArgs, apkbuild, arch, force, depends_buil
def init_buildenv(args: PmbArgs, apkbuild, arch, strict=False, force=False, cross=None,
suffix: Chroot = Chroot.native(), skip_init_buildenv=False, src=None):
chroot: Chroot = Chroot.native(), skip_init_buildenv=False, src=None):
"""Build all dependencies.
Check if we need to build at all (otherwise we've
@ -227,22 +227,22 @@ def init_buildenv(args: PmbArgs, apkbuild, arch, strict=False, force=False, cros
# Install and configure abuild, ccache, gcc, dependencies
if not skip_init_buildenv:
pmb.build.init(args, suffix)
pmb.build.other.configure_abuild(args, suffix)
pmb.build.init(args, chroot)
pmb.build.other.configure_abuild(args, chroot)
if args.ccache:
pmb.build.other.configure_ccache(args, suffix)
pmb.build.other.configure_ccache(args, chroot)
if "rust" in depends or "cargo" in depends:
pmb.chroot.apk.install(args, ["sccache"], suffix)
pmb.chroot.apk.install(args, ["sccache"], chroot)
if not strict and "pmb:strict" not in apkbuild["options"] and len(depends):
pmb.chroot.apk.install(args, depends, suffix)
pmb.chroot.apk.install(args, depends, chroot)
if src:
pmb.chroot.apk.install(args, ["rsync"], suffix)
pmb.chroot.apk.install(args, ["rsync"], chroot)
# Cross-compiler init
if cross:
pmb.build.init_compiler(args, depends, cross, arch)
if cross == "crossdirect":
pmb.chroot.mount_native_into_foreign(args, suffix)
pmb.chroot.mount_native_into_foreign(args, chroot)
return True

View file

@ -129,4 +129,4 @@ def init_compiler(args: PmbArgs, depends, cross, arch):
# native macros / build scripts
cross_pkgs += depends
pmb.chroot.apk.install(args, cross_pkgs)
pmb.chroot.apk.install(args, cross_pkgs, Chroot.native())

View file

@ -219,7 +219,7 @@ def install_run_apk(args: PmbArgs, to_add, to_add_local, to_del, chroot: Chroot)
chroot=chroot)
def install(args: PmbArgs, packages, chroot: Chroot=Chroot.native(), build=True):
def install(args: PmbArgs, packages, chroot: Chroot, build=True):
"""
Install packages from pmbootstrap's local package index or the pmOS/Alpine
binary package mirrors. Iterate over all dependencies recursively, and

View file

@ -23,7 +23,7 @@ def register(args: PmbArgs, arch):
# always make sure the qemu-<arch> binary is installed, since registering
# may happen outside of this method (e.g. by OS)
if f"qemu-{arch_qemu}" not in pmb.chroot.apk.installed(args):
pmb.chroot.apk.install(args, ["qemu-" + arch_qemu])
pmb.chroot.apk.install(args, ["qemu-" + arch_qemu], Chroot.native())
if is_registered(arch_qemu):
return

View file

@ -40,7 +40,7 @@ def install_depends(args: PmbArgs):
depends = pmaports_cfg.get("supported_mtkclient_depends",
"mtkclient,android-tools").split(",")
pmb.chroot.apk.install(args, depends)
pmb.chroot.apk.install(args, depends, Chroot.native())
def init(args: PmbArgs):

View file

@ -134,7 +134,7 @@ def copy_files_from_chroot(args: PmbArgs, chroot: Chroot):
# Update or copy all files
if args.rsync:
pmb.chroot.apk.install(args, ["rsync"])
pmb.chroot.apk.install(args, ["rsync"], Chroot.native())
rsync_flags = "-a"
if args.verbose:
rsync_flags += "vP"
@ -883,7 +883,7 @@ def install_system_image(args: PmbArgs, size_reserve, chroot: Chroot, step, step
if sparse and not split and not disk:
workdir = Path("/home/pmos/rootfs")
logging.info("(native) make sparse rootfs")
pmb.chroot.apk.install(args, ["android-tools"])
pmb.chroot.apk.install(args, ["android-tools"], Chroot.native())
sys_image = args.device + ".img"
sys_image_sparse = args.device + "-sparse.img"
pmb.chroot.user(args, ["img2simg", sys_image, sys_image_sparse],
@ -895,7 +895,7 @@ def install_system_image(args: PmbArgs, size_reserve, chroot: Chroot, step, step
samsungify_strategy = args.deviceinfo["flash_sparse_samsung_format"]
if samsungify_strategy:
logging.info("(native) convert sparse image into Samsung's sparse image format")
pmb.chroot.apk.install(args, ["sm-sparse-image-tool"])
pmb.chroot.apk.install(args, ["sm-sparse-image-tool"], Chroot.native())
sys_image = f"{args.device}.img"
sys_image_patched = f"{args.device}-patched.img"
pmb.chroot.user(args, ["sm_sparse_image_tool", "samsungify", "--strategy",
@ -1302,7 +1302,7 @@ def install(args: PmbArgs):
# Install required programs in native chroot
step = 1
logging.info(f"*** ({step}/{steps}) PREPARE NATIVE CHROOT ***")
pmb.chroot.apk.install(args, pmb.config.install_native_packages,
pmb.chroot.apk.install(args, pmb.config.install_native_packages, Chroot.native(),
build=False)
step += 1

View file

@ -8,6 +8,7 @@ import pmb.helpers.run
import pmb.chroot.root
import pmb.chroot.user
import pmb.chroot.other
import pmb.chroot.apk
from pmb.core import Chroot
@ -79,7 +80,7 @@ def bootimg(args: PmbArgs, path: Path):
logging.info("NOTE: You will be prompted for your sudo/doas password, so"
" we can set up a chroot to extract and analyze your"
" boot.img file")
pmb.chroot.apk.install(args, ["file", "unpackbootimg"])
pmb.chroot.apk.install(args, ["file", "unpackbootimg"], Chroot.native())
temp_path = pmb.chroot.other.tempfolder(args, Path("/tmp/bootimg_parser"))
bootimg_path = Chroot.native() / temp_path / "boot.img"

View file

@ -325,7 +325,7 @@ def install_depends(args: PmbArgs, arch):
if args.efi:
depends.append("ovmf")
pmb.chroot.apk.install(args, depends)
pmb.chroot.apk.install(args, depends, Chroot.native())
def run(args: PmbArgs):