From e0c2b42358d03cc3bc1664fdc1bf8201140154ae Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 18 Nov 2024 20:59:29 +0100 Subject: [PATCH 1/4] Drop dead code We don't use the returned Args object so no point in passing --force. --- mkosi/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 4f8541364..7c681c26c 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4146,7 +4146,7 @@ def prepend_to_environ_path(config: Config) -> Iterator[None]: os.environ["PATH"] = ":".join(olds) -def finalize_default_tools(args: Args, config: Config, *, resources: Path) -> Config: +def finalize_default_tools(config: Config, *, resources: Path) -> Config: if not config.tools_tree_distribution: die( f"{config.distribution} does not have a default tools tree distribution", @@ -4179,7 +4179,6 @@ def finalize_default_tools(args: Args, config: Config, *, resources: Path) -> Co *(["--proxy-peer-certificate", str(p)] if (p := config.proxy_peer_certificate) else []), *(["--proxy-client-certificate", str(p)] if (p := config.proxy_client_certificate) else []), *(["--proxy-client-key", str(p)] if (p := config.proxy_client_key) else []), - *(["-f"] * args.force), ] # fmt: skip _, [tools] = parse_config( @@ -4616,7 +4615,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: }[args.verb](args, last) if last.tools_tree and last.tools_tree == Path("default"): - tools = finalize_default_tools(args, last, resources=resources) + tools = finalize_default_tools(last, resources=resources) else: tools = None From cb0eef89dda76d625172a3d21b52ce910a885152 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 18 Nov 2024 21:00:10 +0100 Subject: [PATCH 2/4] Remove distribution from tools tree cache name We already made the same change for the output, let's make the same change for the cache name as well. --- mkosi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 7c681c26c..565c2b85a 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4186,7 +4186,7 @@ def finalize_default_tools(config: Config, *, resources: Path) -> Config: resources=resources, ) - tools = dataclasses.replace(tools, image=f"{config.tools_tree_distribution}-tools") + tools = dataclasses.replace(tools, image="tools") return tools From 577f328ca6bc7622a4f6ac108eadcac97173b731 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 18 Nov 2024 21:06:17 +0100 Subject: [PATCH 3/4] Also fail early if default tools tree is out of date without --force We fail early if the tools tree does not exist and build or --force was not specified, let's do the same if the tools tree is incremental and the cache is out-of-date. --- mkosi/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 565c2b85a..55ace22d4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4647,13 +4647,17 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: if ( tools - and not (tools.output_dir_or_cwd() / tools.output).exists() + and ( + not (tools.output_dir_or_cwd() / tools.output).exists() + or (tools.incremental and not have_cache(tools)) + ) and args.verb != Verb.build and not args.force ): die( - f"Default tools tree requested for image '{last.name()}' but it has not been built yet", - hint="Make sure to build the image first with 'mkosi build' or use '--force'", + f"Default tools tree requested for image '{last.name()}' but it is out-of-date or has not been " + "built yet", + hint="Make sure to (re)build the image first with 'mkosi build' or use '--force'", ) if not last.repart_offline and os.getuid() != 0: From d88111b51346d53c32d09e20fe18d72587b89738 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 18 Nov 2024 21:16:40 +0100 Subject: [PATCH 4/4] Require that default tools tree exists when mkosi -t none is invoked Let's insist on the default tools tree already existing when invoking mkosi -t none without --force. --- mkosi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 55ace22d4..7e71fab5b 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -4651,7 +4651,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: not (tools.output_dir_or_cwd() / tools.output).exists() or (tools.incremental and not have_cache(tools)) ) - and args.verb != Verb.build + and (args.verb != Verb.build or last.output_format == OutputFormat.none) and not args.force ): die(