chroot: allow mounting the device rootfs (MR 2252)

Add a new flag --image which can be used to mount the rootfs generated
with "pmbootstrap install".

For now this is quite limited in scope. But it's enough to allow for
building a package, updating it in the QEMU image, and then booting it.

The major "gotcha" with this is that the QEMU uses the kernel and
initramfs from the device chroot unless you run it with --efi.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-14 07:25:49 +02:00 committed by Oliver Smith
parent d1a86fe702
commit f331b95824
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
8 changed files with 55 additions and 11 deletions

View file

@ -20,6 +20,7 @@ import pmb.chroot.other
import pmb.chroot.initfs
import pmb.config
import pmb.config.pmaports
import pmb.install.losetup
from pmb.types import PathString, PmbArgs
import pmb.helpers.run
import pmb.parse.cpuinfo
@ -345,6 +346,10 @@ def run(args: PmbArgs):
"and select the 'qemu' vendor.")
arch = pmb.parse.deviceinfo().arch
# Make sure the rootfs image isn't mounted
pmb.mount.umount_all(Chroot(ChrootType.IMAGE, "").path)
pmb.install.losetup.detach_all()
img_path = system_image(device)
img_path_2nd = None
if args.second_storage: