forked from Mirror/pmbootstrap
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:
parent
aba3584b02
commit
ef38c12e39
3 changed files with 18 additions and 16 deletions
|
@ -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)
|
||||
|
|
|
@ -4,6 +4,7 @@ from pmb.helpers import logging
|
|||
import os
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
import pmb.chroot.binfmt
|
||||
import pmb.config
|
||||
import pmb.helpers.run
|
||||
import pmb.parse
|
||||
|
@ -97,6 +98,19 @@ def mount(chroot: Chroot):
|
|||
pmb.helpers.mount.bind(source, target_outer)
|
||||
|
||||
|
||||
# Set up binfmt
|
||||
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 mount_native_into_foreign(chroot: Chroot):
|
||||
source = Chroot.native().path
|
||||
target = chroot / "native"
|
||||
|
|
|
@ -815,7 +815,7 @@ def install_system_image(args: PmbArgs, size_reserve, chroot: Chroot, step, step
|
|||
device = chroot.name()
|
||||
# Partition and fill image file/disk block device
|
||||
logging.info(f"*** ({step}/{steps}) PREPARE INSTALL BLOCKDEVICE ***")
|
||||
pmb.chroot.shutdown(True)
|
||||
pmb.helpers.mount.umount_all(chroot.path)
|
||||
(size_boot, size_root) = get_subpartitions_size(chroot)
|
||||
layout = get_partition_layout(size_reserve, pmb.parse.deviceinfo().cgpt_kpart \
|
||||
and args.install_cgpt)
|
||||
|
@ -833,6 +833,9 @@ def install_system_image(args: PmbArgs, size_reserve, chroot: Chroot, step, step
|
|||
|
||||
pmb.install.format(args, layout, boot_label, root_label, disk)
|
||||
|
||||
# Since we shut down the chroot we need to mount it again
|
||||
pmb.chroot.mount(chroot)
|
||||
|
||||
# Create /etc/fstab and /etc/crypttab
|
||||
logging.info("(native) create /etc/fstab")
|
||||
create_fstab(args, layout, chroot)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue