]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use the main tool name in error when tool is not found
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2023 11:10:11 +0000 (12:10 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 Nov 2023 11:27:19 +0000 (12:27 +0100)
We would say that we cannnot find /usr/lib/systemd/ukify, which
is somewhat confusing, since we're looking for ukify in $PATH
first, and only for /usr/lib/systemd/ukify as a fallback.

This also avoids a second which call on the results of a which call.

mkosi/__init__.py

index 54d9c8fe8e9acdd7c12ceeafd1870fcf5c136d6d..e1211ddf52694e1b15abbd777dd7c4b478aff873 100644 (file)
@@ -1695,9 +1695,12 @@ def check_outputs(config: MkosiConfig) -> None:
             die(f"Output path {f} exists already. (Consider invocation with --force.)")
 
 
-def check_systemd_tool(tool: PathString, *, reason: str, hint: Optional[str] = None) -> None:
-    if not shutil.which(tool):
-        die(f"Could not find '{tool}' which is required to {reason}.", hint=hint)
+def check_systemd_tool(*tools: PathString, reason: str, hint: Optional[str] = None) -> None:
+    for tool in tools:
+        if shutil.which(tool):
+            break
+    else:
+        die(f"Could not find '{tools[0]}' which is required to {reason}.", hint=hint)
 
     v = GenericVersion(run([tool, "--version"], stdout=subprocess.PIPE).stdout.split()[1])
     if v < MINIMUM_SYSTEMD_VERSION:
@@ -1708,7 +1711,7 @@ def check_systemd_tool(tool: PathString, *, reason: str, hint: Optional[str] = N
 def check_tools(args: MkosiArgs, config: MkosiConfig) -> None:
     if want_uki(config):
         check_systemd_tool(
-            shutil.which("ukify") or "/usr/lib/systemd/ukify",
+            "ukify", "/usr/lib/systemd/ukify",
             reason="build bootable images",
             hint="Bootable=no can be used to create a non-bootable image",
         )