Skip to content

Commit

Permalink
Merge pull request #3451 from DaanDeMeyer/overlay
Browse files Browse the repository at this point in the history
Fix condition when removing duplicate files from the overlay
  • Loading branch information
behrmann authored Jan 30, 2025
2 parents d4f3447 + af82c63 commit 6a6459e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,24 @@ 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 (
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

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()

Expand Down

0 comments on commit 6a6459e

Please sign in to comment.