From ea056ec8e23e1ac8a0afa501c4dd67671f557a7f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 18 Dec 2023 21:13:18 +0100 Subject: [PATCH] Process all overlays before we do any bind mounts Otherwise, later overlays will hide earlier bind mounts. --- mkosi/__init__.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 44cfe7d67..4733d5ffd 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3030,22 +3030,31 @@ def mount_tools(tree: Optional[Path]) -> Iterator[None]: # without running into permission errors. overlays = set() + dirs = [ + subdir + for subdir in ( + Path("etc/pki"), + Path("etc/ssl"), + Path("etc/crypto-policies"), + Path("etc/ca-certificates"), + Path("etc/pacman.d"), + Path("var/lib/ca-certificates"), + ) + if (tree / subdir).exists() + ] - for subdir in (Path("etc/pki"), - Path("etc/ssl"), - Path("etc/crypto-policies"), - Path("etc/ca-certificates"), - Path("etc/pacman.d"), - Path("var/lib/ca-certificates")): - if not (tree / subdir).exists(): + for subdir in dirs: + if (Path("/") / subdir).exists(): continue - if not (Path("/") / subdir).exists() and subdir.parent not in overlays: + if subdir.parent not in overlays: tmp = stack.enter_context(tempfile.TemporaryDirectory(dir="/var/tmp")) stack.enter_context(mount_overlay([Path("/") / subdir.parent], Path(tmp), Path("/") / subdir.parent)) overlays.add(subdir.parent) - (Path("/") / subdir).mkdir(parents=True, exist_ok=True) + (Path("/") / subdir).mkdir(parents=True, exist_ok=True) + + for subdir in dirs: stack.enter_context( mount(what=tree / subdir, where=Path("/") / subdir, operation="--bind", read_only=True) ) -- 2.47.2