]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Handle symlink explicitly in finalize_staging()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 11 Mar 2024 16:33:57 +0000 (17:33 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 11 Mar 2024 19:03:14 +0000 (20:03 +0100)
move_tree() doesn't handle symlinks so add some special casing for
the symlink we create in the staging directory.

Fixes #2479

mkosi/__init__.py

index 659d1f00ff53c8e60da22c824da96b6e970ad258..4c35cbe35e741339533c5da0fa5d05c699d0fa00 100644 (file)
@@ -3195,6 +3195,12 @@ def finalize_staging(context: Context) -> None:
         # Make sure all build outputs that are not directories are owned by the user running mkosi.
         if not f.is_dir():
             os.chown(f, INVOKING_USER.uid, INVOKING_USER.gid, follow_symlinks=False)
+
+        if f.is_symlink():
+            (context.config.output_dir_or_cwd() / f.name).symlink_to(f.readlink())
+            os.chown(f, INVOKING_USER.uid, INVOKING_USER.gid, follow_symlinks=False)
+            continue
+
         move_tree(
             f, context.config.output_dir_or_cwd(),
             use_subvolumes=context.config.use_subvolumes,