]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't clean tools tree unless at least -f is specified 2908/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Jul 2024 15:27:26 +0000 (17:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 24 Jul 2024 15:29:01 +0000 (17:29 +0200)
Otherwise if we run mkosi qemu and the cache is out of date we
remove the tools tree which we shouldn't do.

mkosi/__init__.py

index cf201065fb7936139580d8bc07e4ead38d5c5d3c..a6639262f8eb66dae6cebe4dbaa0c8659177e124 100644 (file)
@@ -4854,9 +4854,13 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
     if last.tools_tree and last.tools_tree == Path("default"):
         tools = finalize_default_tools(args, last, resources=resources)
 
-        # If we're doing an incremental tools tree and the cache is not out of date, don't clean up the tools tree
+        # If we're doing an incremental build and the cache is not out of date, don't clean up the tools tree
         # so that we can reuse the previous one.
-        if not tools.incremental or not have_cache(tools) or needs_clean(args, tools, force=2):
+        if (
+            not tools.incremental or
+            ((args.verb == Verb.build or args.force > 0) and not have_cache(tools)) or
+            needs_clean(args, tools, force=2)
+        ):
             fork_and_wait(run_clean, args, tools, resources=resources)
     else:
         tools = None