pmb.chroot.shutdown: clean up chroot marker here (MR 2082)

Remove /in-pmbootstrap inside chroots in "pmbootstrap shutdown" instead
of having it at a specific part of "pmbootstrap install".

Reasoning:
* With current approach, it didn't get removed in the on-device
  installer chroot.
* This is less error prone than calling it multiple times in
  "pmbootstrap install"
This commit is contained in:
Oliver Smith 2021-07-11 16:59:28 +02:00
parent c347b27f69
commit 7616803207
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 10 additions and 7 deletions

View file

@ -33,7 +33,8 @@ def copy_resolv_conf(args, suffix="native"):
def mark_in_chroot(args, suffix="native"): def mark_in_chroot(args, suffix="native"):
""" """
Touch a flag so we can know when we're running in chroot (and Touch a flag so we can know when we're running in chroot (and
don't accidentally flash partitions on our host) don't accidentally flash partitions on our host). This marker
gets removed in pmb.chroot.shutdown (pmbootstrap shutdown).
""" """
in_chroot_file = f"{args.work}/chroot_{suffix}/in-pmbootstrap" in_chroot_file = f"{args.work}/chroot_{suffix}/in-pmbootstrap"
if not os.path.exists(in_chroot_file): if not os.path.exists(in_chroot_file):

View file

@ -73,6 +73,14 @@ def shutdown(args, only_install_related=False):
if os.path.exists(path): if os.path.exists(path):
pmb.helpers.mount.umount_all(args, path) pmb.helpers.mount.umount_all(args, path)
# Remove "in-pmbootstrap" marker from all chroots. This marker indicates
# that pmbootstrap has set up all mount points etc. to run programs inside
# the chroots, but we want it gone afterwards (e.g. when the chroot
# contents get copied to a rootfs / installer image, or if creating an
# android recovery zip from its contents).
for marker in glob.glob(f"{args.work}/chroot_*/in-pmbootstrap"):
pmb.helpers.run.root(args, ["rm", marker])
if not only_install_related: if not only_install_related:
# Umount all folders inside args.work # Umount all folders inside args.work
# The folders are explicitly iterated over, so folders symlinked inside # The folders are explicitly iterated over, so folders symlinked inside

View file

@ -789,10 +789,6 @@ def install_on_device_installer(args, step, steps):
boot_label, "pmOS_install", args.split, args.sdcard) 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): def create_device_rootfs(args, step, steps):
# List all packages to be installed (including the ones specified by --add) # List all packages to be installed (including the ones specified by --add)
# and upgrade the installed packages/apkindexes # and upgrade the installed packages/apkindexes
@ -872,8 +868,6 @@ def create_device_rootfs(args, step, steps):
setup_hostname(args) setup_hostname(args)
disable_sshd(args) disable_sshd(args)
cleanup(args, suffix)
disable_firewall(args) disable_firewall(args)