]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't show the same "Generating disk image" message 3x times
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 7 Nov 2023 07:34:56 +0000 (08:34 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 7 Nov 2023 08:17:57 +0000 (09:17 +0100)
Let's show a custom message each time we call systemd-repart. Let's
also not call it a third time if split artifacts were not requested.

mkosi/__init__.py

index 857acdae4fe390639f6c983dd5c05e54656818b0..adcf854d58f1661f556be25223872250320a7360 100644 (file)
@@ -1955,7 +1955,7 @@ def reuse_cache(state: MkosiState) -> bool:
     return True
 
 
-def make_image(state: MkosiState, skip: Sequence[str] = [], split: bool = False) -> list[Partition]:
+def make_image(state: MkosiState, msg: str, skip: Sequence[str] = [], split: bool = False) -> list[Partition]:
     if not state.config.output_format == OutputFormat.disk:
         return []
 
@@ -1984,7 +1984,7 @@ def make_image(state: MkosiState, skip: Sequence[str] = [], split: bool = False)
         cmdline += ["--certificate", state.config.verity_certificate]
     if skip:
         cmdline += ["--defer-partitions", ",".join(skip)]
-    if split and state.config.split_artifacts:
+    if split:
         cmdline += ["--split=yes"]
     if state.config.sector_size:
         cmdline += ["--sector-size", state.config.sector_size]
@@ -2065,7 +2065,7 @@ def make_image(state: MkosiState, skip: Sequence[str] = [], split: bool = False)
         if option == "SOURCE_DATE_EPOCH":
             env[option] = value
 
-    with complete_step("Generating disk image"):
+    with complete_step(msg):
         output = json.loads(run(cmdline, stdout=subprocess.PIPE, env=env).stdout)
 
     logging.debug(json.dumps(output, indent=4))
@@ -2190,15 +2190,18 @@ def build_image(args: MkosiArgs, config: MkosiConfig) -> None:
             run_finalize_scripts(state)
 
         normalize_mtime(state.root, state.config.source_date_epoch)
-        partitions = make_image(state, skip=("esp", "xbootldr"))
+        partitions = make_image(state, skip=("esp", "xbootldr"), msg="Generating disk image")
         install_uki(state, partitions)
         prepare_grub_efi(state)
         prepare_grub_bios(state, partitions)
         normalize_mtime(state.root, state.config.source_date_epoch, directory=Path("boot"))
         normalize_mtime(state.root, state.config.source_date_epoch, directory=Path("efi"))
-        partitions = make_image(state)
+        partitions = make_image(state, msg="Formatting ESP/XBOOTLDR partitions")
         install_grub_bios(state, partitions)
-        make_image(state, split=True)
+
+        if state.config.split_artifacts:
+            make_image(state, split=True, msg="Extracting partitions")
+
         copy_vmlinuz(state)
 
         if state.config.output_format == OutputFormat.tar: