allow detecting when in chroot (MR 2063)
Touch the file /in-pmbootstrap in chroots so that we can avoid performing automated actions that should only happen on a real device (like flashing the kernel).
This commit is contained in:
parent
7145ab2e50
commit
e27bb82252
|
@ -30,6 +30,16 @@ def copy_resolv_conf(args, suffix="native"):
|
|||
pmb.helpers.run.root(args, ["touch", chroot])
|
||||
|
||||
|
||||
def mark_in_chroot(args, suffix="native"):
|
||||
"""
|
||||
Touch a flag so we can know when we're running in chroot (and
|
||||
don't accidentally flash partitions on our host)
|
||||
"""
|
||||
in_chroot_file = f"{args.work}/chroot_{suffix}/in-pmbootstrap"
|
||||
if not os.path.exists(in_chroot_file):
|
||||
pmb.helpers.run.root(args, ["touch", in_chroot_file])
|
||||
|
||||
|
||||
def setup_qemu_emulation(args, suffix):
|
||||
arch = pmb.parse.arch.from_chroot_suffix(args, suffix)
|
||||
if not pmb.parse.arch.cpu_emulation_required(args, arch):
|
||||
|
@ -53,6 +63,7 @@ def init(args, suffix="native"):
|
|||
|
||||
pmb.chroot.mount(args, suffix)
|
||||
setup_qemu_emulation(args, suffix)
|
||||
mark_in_chroot(args, suffix)
|
||||
if os.path.islink(f"{chroot}/bin/sh"):
|
||||
pmb.config.workdir.chroot_check_channel(args, suffix)
|
||||
copy_resolv_conf(args, suffix)
|
||||
|
|
|
@ -710,6 +710,10 @@ def install_on_device_installer(args, step, steps):
|
|||
boot_label, "pmOS_install", args.split, args.sdcard)
|
||||
|
||||
|
||||
def cleanup(args, suffix):
|
||||
pmb.chroot.root(args, ["rm", "/in-pmbootstrap"], suffix)
|
||||
|
||||
|
||||
def create_device_rootfs(args, step, steps):
|
||||
# List all packages to be installed (including the ones specified by --add)
|
||||
# and upgrade the installed packages/apkindexes
|
||||
|
@ -776,6 +780,7 @@ def create_device_rootfs(args, step, steps):
|
|||
setup_hostname(args)
|
||||
|
||||
disable_sshd(args)
|
||||
cleanup(args, suffix)
|
||||
|
||||
|
||||
def install(args):
|
||||
|
|
Loading…
Reference in New Issue