Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various tools tree fixes #3205

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -4179,15 +4179,14 @@ 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(
cmdline + ["--include=mkosi-tools", "build"],
resources=resources,
)

tools = dataclasses.replace(tools, image=f"{config.tools_tree_distribution}-tools")
tools = dataclasses.replace(tools, image="tools")

return tools

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -4648,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 args.verb != Verb.build
and (
not (tools.output_dir_or_cwd() / tools.output).exists()
or (tools.incremental and not have_cache(tools))
)
and (args.verb != Verb.build or last.output_format == OutputFormat.none)
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:
Expand Down
Loading