install: handle chroot unmount/mount properly (MR 2252)

We used to called pmb.chroot.shutdown() with "only_install_related=True"
here to unmount everything in the chroot so we could reliably "df" it to
figure out the rootfs image size.

Since ("pmb.chroot: only init once"), the chroot is no longer
automatically spun back up when we run mkinitfs, and the in-pmbootstrap
marker isn't recreated.

We only actually need to unmount the chroot anyway, so let's restrict it
to just that and remount things again afterwards.

This avoids weird side effects (like the native chroot being
shutdown?!), but this is something we should look into more in the
future since we're still doing a finnicky balancing act to manage chroot
state here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-09 08:03:01 +02:00 committed by Oliver Smith
parent aba3584b02
commit ef38c12e39
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 18 additions and 16 deletions

View file

@ -55,20 +55,6 @@ def mark_in_chroot(chroot: Chroot=Chroot.native()):
pmb.helpers.run.root(["touch", in_chroot_file])
def setup_qemu_emulation(chroot: Chroot):
arch = chroot.arch
if not arch.cpu_emulation_required():
return
arch_qemu = arch.qemu()
# mount --bind the qemu-user binary
pmb.chroot.binfmt.register(arch)
pmb.helpers.mount.bind_file(Chroot.native() / f"/usr/bin/qemu-{arch_qemu}",
chroot / f"usr/bin/qemu-{arch_qemu}-static",
create_folders=True)
def init_keys():
"""
All Alpine and postmarketOS repository keys are shipped with pmbootstrap.
@ -131,7 +117,6 @@ def init(chroot: Chroot=Chroot.native(), usr_merge=UsrMerge.AUTO,
return
pmb.chroot.mount(chroot)
setup_qemu_emulation(chroot)
mark_in_chroot(chroot)
if (chroot / "bin/sh").is_symlink():
pmb.config.workdir.chroot_check_channel(chroot)