diff --git a/mkosi/sandbox.py b/mkosi/sandbox.py index 20fca27aa..604408dd8 100755 --- a/mkosi/sandbox.py +++ b/mkosi/sandbox.py @@ -459,11 +459,16 @@ def __eq__(self, other: object) -> bool: def execute(self, oldroot: str, newroot: str) -> None: src = chase(oldroot, self.src) - dst = chase(newroot, self.dst) if not os.path.exists(src) and not self.required: return + # If we're mounting a file on top of a symlink, mount directly on top of the symlink instead of + # resolving it. + if not os.path.isdir(src) and os.path.islink(self.dst): + return mount_rbind(src, self.dst, attrs=MOUNT_ATTR_RDONLY if self.readonly else 0) + + dst = chase(newroot, self.dst) if not os.path.exists(dst): isfile = os.path.isfile(src)