From 6efefe2e3a431d36f3c5faa6c0a5edc9d3adf843 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 29 Jan 2025 21:37:02 +0100 Subject: [PATCH 1/2] Fix condition when removing duplicate files from the overlay --- mkosi/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 863a72722..f5d5c0fd0 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -185,11 +185,14 @@ def mount_base_trees(context: Context) -> Iterator[None]: rel = p.relative_to(context.root) q = context.workspace / "lower" / rel - if not q.is_symlink() and q.is_dir(): - if p.is_symlink() or not p.is_dir(): - die(f"/{rel} is a directory in the base tree but not in the overlay") + if not q.is_symlink() and not q.exists(): + continue + + if not p.is_symlink() and p.is_dir(): + if q.is_symlink() or not q.is_dir(): + die(f"/{rel} is a directory in the overlay but not in the base tree") shutil.copystat(q, p) - elif q.is_symlink() or q.exists(): + else: logging.info(f"Removing duplicate path /{rel} from overlay") p.unlink() From af82c63d873bb274e9ac437540bbf87a24c09d63 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 30 Jan 2025 15:24:22 +0100 Subject: [PATCH 2/2] Skip files outside of known paths for extension outputs --- mkosi/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index f5d5c0fd0..51b06ab05 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -185,6 +185,16 @@ def mount_base_trees(context: Context) -> Iterator[None]: rel = p.relative_to(context.root) q = context.workspace / "lower" / rel + if ( + context.config.output_format == OutputFormat.sysext + and not rel.is_relative_to("usr") + and not rel.is_relative_to("opt") + ): + continue + + if context.config.output_format == OutputFormat.confext and not rel.is_relative_to("etc"): + continue + if not q.is_symlink() and not q.exists(): continue