]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove output symlink target as well when cleaning
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 14 Apr 2024 21:27:19 +0000 (23:27 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 15 Apr 2024 07:37:38 +0000 (09:37 +0200)
mkosi/__init__.py

index f8c9cf8c2f32a1fb2f2dbb5d8d8b5f53b3f9f336..5a31b124318c041d218d08aa49610988da6f0043 100644 (file)
@@ -4216,11 +4216,15 @@ def run_clean(args: Args, config: Config, *, resources: Path) -> None:
         remove_build_cache = args.force > 1
         remove_package_cache = args.force > 2
 
-    outputs = [
+    outputs = {
         config.output_dir_or_cwd() / output
         for output in config.outputs
         if (config.output_dir_or_cwd() / output).exists()
-    ]
+    }
+
+    # Make sure we resolve the symlink we create in the output directory and remove its target as well as it might not
+    # be in the list of outputs anymore if the compression or output format was changed.
+    outputs |= {o.resolve() for o in outputs}
 
     if outputs:
         with (