]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fixed building when skipping final phase
authorMichael A Cassaniti <michael@cassaniti.id.au>
Fri, 22 Jul 2022 09:49:06 +0000 (19:49 +1000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 5 Aug 2022 07:20:53 +0000 (09:20 +0200)
When running using a build script and the option `--skip-final-phase` is given,
no image is generated causing an issue linking the image. This change skips any
attempts to link the image or print the resulting output size.

mkosi/__init__.py

index 8c9e47c16e92c5d2d4c392a5a679ac62eb116a92..fbc8d9b995393fe771a2c3f1099ab9dbdbaa9c52 100644 (file)
@@ -4517,6 +4517,9 @@ def _link_output(
 def link_output(args: MkosiArgs, root: Path, artifact: Optional[BinaryIO]) -> None:
     with complete_step("Linking image file…", f"Linked {path_relative_to_cwd(args.output)}"):
         if args.output_format in (OutputFormat.directory, OutputFormat.subvolume):
+            if not root.exists():
+                return
+
             assert artifact is None
 
             make_read_only(args, root, for_cache=False, b=False)
@@ -4528,7 +4531,9 @@ def link_output(args: MkosiArgs, root: Path, artifact: Optional[BinaryIO]) -> No
             OutputFormat.tar,
             OutputFormat.cpio,
         ):
-            assert artifact is not None
+            if artifact is None:
+                return
+
             _link_output(args, artifact.name, args.output)
 
 
@@ -4691,6 +4696,9 @@ def save_manifest(args: MkosiArgs, manifest: Manifest) -> None:
 
 
 def print_output_size(args: MkosiArgs) -> None:
+    if not args.output.exists():
+        return
+
     if args.output_format in (OutputFormat.directory, OutputFormat.subvolume):
         MkosiPrinter.print_step("Resulting image size is " + format_bytes(dir_size(args.output)) + ".")
     else: