chroot: apk: safety net when chroot unitialized (MR 2252)

We recently changed how we manage chroots, requiring the user (of the
chroot) to initialize it before doing stuff like installing packages.

There are however still certain edgecases in pmbootstrap where this
doesn't get done (for example qemu/run.py would attempt to install the
kernel package for the device, but we don't initialize the rootfs chroot
in QEMU since that doesn't make sense to do). Check for and catch this
situation explicitly so we don't ruin someones day, but still be loud
about it so we can hopefully catch the remaining instances of this.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-22 18:59:05 +02:00 committed by Oliver Smith
parent 794048e2d5
commit cb6cd3bc4c
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 16 additions and 0 deletions

View file

@ -91,6 +91,10 @@ class Chroot:
return (self / "bin/sh").is_symlink()
def is_mounted(self) -> bool:
return self.exists() and pmb.helpers.mount.ismount(self.path / "etc/apk/keys")
@property
def arch(self) -> Arch:
if self.type == ChrootType.NATIVE: