From: Daan De Meyer Date: Wed, 24 Sep 2025 08:41:59 +0000 (+0200) Subject: postmarketos: Set up usrmerge in install() instead of setup() X-Git-Tag: v26~109^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0c828681021e8e2cb95cc0f7af34783eebf1ba6;p=thirdparty%2Fmkosi.git postmarketos: Set up usrmerge in install() instead of setup() We try to not touch the rootfs directory in setup() at all, so set up merged /usr in install() instead like we do for debian. Additionally, we also make sync() does not touch the rootfs either by having it operate on a temporary directory instead of the real rootfs. --- diff --git a/mkosi/distributions/postmarketos.py b/mkosi/distributions/postmarketos.py index e03843c44..2404be30e 100644 --- a/mkosi/distributions/postmarketos.py +++ b/mkosi/distributions/postmarketos.py @@ -38,12 +38,6 @@ class Installer(DistributionInstaller): @classmethod def setup(cls, context: Context) -> None: - # TODO: Create merged /usr manually for now until our upstream (Alpine Linux) supports it: - # https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/85504 - for dir in ["lib", "bin", "sbin"]: - (context.root / "usr" / dir).mkdir(parents=True, exist_ok=True) - (context.root / dir).symlink_to(f"usr/{dir}") - with complete_step("Setting up postmarketOS keyring"): # Create keys directory in sandbox keys_dir = context.sandbox_tree / "etc/apk/keys" @@ -69,6 +63,12 @@ class Installer(DistributionInstaller): @classmethod def install(cls, context: Context) -> None: + # TODO: Create merged /usr manually for now until our upstream (Alpine Linux) supports it: + # https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/85504 + for dir in ["lib", "bin", "sbin"]: + (context.root / "usr" / dir).mkdir(parents=True, exist_ok=True) + (context.root / dir).symlink_to(f"usr/{dir}") + Apk.install(context, ["postmarketos-baselayout", "postmarketos-release"], apivfs=False) @classmethod diff --git a/mkosi/installer/apk.py b/mkosi/installer/apk.py index c489ab686..5f31ec140 100644 --- a/mkosi/installer/apk.py +++ b/mkosi/installer/apk.py @@ -9,6 +9,7 @@ from mkosi.config import Config from mkosi.context import Context from mkosi.installer import PackageManager from mkosi.run import CompletedProcess, run, workdir +from mkosi.tree import rmtree from mkosi.util import _FILE, PathString @@ -112,9 +113,14 @@ class Apk(PackageManager): @classmethod def sync(cls, context: Context, force: bool) -> None: - # Initialize database first + # Updating the cache requires an initialized apk database but we don't want to touch the image root + # directory so temporarily replace it with an empty directory to make apk happy. + saved = context.root.rename(context.workspace / "saved-root") + context.root.mkdir() cls.invoke(context, "add", ["--initdb"]) cls.invoke(context, "update", ["--update-cache"] if force else []) + rmtree(context.root) + saved.rename(context.root) @classmethod def createrepo(cls, context: Context) -> None: