From: Michael A Cassaniti Date: Fri, 22 Jul 2022 09:49:06 +0000 (+1000) Subject: Fixed building when skipping final phase X-Git-Tag: v14~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e097ec1840773a48b7490099b174236d558ad96;p=thirdparty%2Fmkosi.git Fixed building when skipping final phase 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 8c9e47c16..fbc8d9b99 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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: