From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 Nov 2023 11:10:11 +0000 (+0100) Subject: Use the main tool name in error when tool is not found X-Git-Tag: v20~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c8993300f7686d1decf3d35d307a6d015c2a943;p=thirdparty%2Fmkosi.git Use the main tool name in error when tool is not found 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 54d9c8fe8..e1211ddf5 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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", )