1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-19 18:45:09 +03:00

treewide: split chroots from workdir

Introduce a new "cache" subdirectory in the pmbootstrap workdir, all the
cache and config bits go in here, anything that needs to be accessible
from inside a chroot. The whole dir is then bind-mounted into the chroot
as /cache with appropriate symlinks.

This dir is in the config as config.cache.

In addition, all the cache_* and other config dirs are renamed to
be closer to the names of the equivalent dirs in the chroot (e.g.
abuild-config) and to avoid redundant naming since they are now under a
"cache" dir.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
This commit is contained in:
Casey Connolly 2025-05-26 18:23:49 +02:00
parent 1560a3f221
commit 9f8edf539d
34 changed files with 130 additions and 127 deletions

View file

@ -42,7 +42,7 @@ def mount(chroot: Chroot):
channel = pmb.config.pmaports.read_config(pkgrepo_default_path())["channel"]
mountpoints: dict[Path, Path] = {}
for src_template, target_template in pmb.config.chroot_mount_bind.items():
src_template = src_template.replace("$WORK", os.fspath(get_context().config.work))
src_template = src_template.replace("$CACHE", os.fspath(get_context().config.cache))
src_template = src_template.replace("$ARCH", str(arch))
src_template = src_template.replace("$CHANNEL", channel)
mountpoints[Path(src_template).resolve()] = Path(target_template)
@ -81,13 +81,13 @@ def mount_native_into_foreign(chroot: Chroot) -> None:
def remove_mnt_pmbootstrap(chroot: Chroot) -> None:
"""Safely remove /mnt/pmbootstrap directories from the chroot, without
"""Safely remove /cache directories from the chroot, without
running rm -r as root and potentially removing data inside the
mountpoint in case it was still mounted (bug in pmbootstrap, or user
ran pmbootstrap 2x in parallel). This is similar to running 'rm -r -d',
but we don't assume that the host's rm has the -d flag (busybox does
not)."""
mnt_dir = chroot / "mnt/pmbootstrap"
mnt_dir = chroot / "work"
if not mnt_dir.exists():
return
@ -96,7 +96,7 @@ def remove_mnt_pmbootstrap(chroot: Chroot) -> None:
path.rmdir()
if mnt_dir.exists():
raise RuntimeError("Failed to remove /work!")
raise RuntimeError("Failed to remove /cache!")
def umount(chroot: Chroot) -> None: