]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't build the image automatically for boot/qemu verbs without --force
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 22 Apr 2024 12:37:30 +0000 (14:37 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 22 Apr 2024 13:25:45 +0000 (15:25 +0200)
Let's insist on --force to build the image if boot/qemu are used to
give users an easy way to insist that an image has already been built
when booting it.

mkosi/__init__.py

index 74fe26d4f53d6979ef026ee485c1797c59ece511..59b03371725ca7affebbc933e0a00ac621960392 100644 (file)
@@ -4528,6 +4528,9 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
             tools_tree=tools.output_dir_or_cwd() / tools.output if tools else config.tools_tree,
         )
 
+        if args.verb != Verb.build and args.force == 0:
+            continue
+
         if tools and not (tools.output_dir_or_cwd() / tools.output_with_compression).exists():
             fork_and_wait(run_sync, args, tools, resources=resources)
             fork_and_wait(run_build, args, tools, resources=resources)
@@ -4549,6 +4552,10 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
 
     last = images[-1]
 
+    if not (last.output_dir_or_cwd() / last.output_with_compression).exists():
+        die(f"Image '{last.name()}' has not been built yet",
+            hint="Make sure to build the image first with 'mkosi build' or use --force")
+
     with prepend_to_environ_path(last):
         check_tools(last, args.verb)