Skip to content

Commit

Permalink
Check for required tools earlier
Browse files Browse the repository at this point in the history
Let's check for required tools before we run sync or configure scripts
so that all required tools are checked before we actually use them.
  • Loading branch information
DaanDeMeyer authored and behrmann committed Aug 12, 2024
1 parent 11b0501 commit f5c3742
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4760,15 +4760,11 @@ def run_build(args: Args, config: Config, *, resources: Path, package_dir: Optio
with (
complete_step(f"Building {config.name()} image"),
prepend_to_environ_path(config),
acl_toggle_build(config, INVOKING_USER.uid),
rchown_package_manager_dirs(config),
setup_workspace(args, config) as workspace,
):
check_tools(config, Verb.build)

with (
acl_toggle_build(config, INVOKING_USER.uid),
rchown_package_manager_dirs(config),
setup_workspace(args, config) as workspace,
):
build_image(Context(args, config, workspace=workspace, resources=resources, package_dir=package_dir))
build_image(Context(args, config, workspace=workspace, resources=resources, package_dir=package_dir))


def ensure_root_is_mountpoint() -> None:
Expand Down Expand Up @@ -4899,6 +4895,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:

if tools and not (tools.output_dir_or_cwd() / tools.output).exists():
if args.verb == Verb.build or args.force > 0:
check_tools(tools, Verb.build)
fork_and_wait(run_sync, args, tools, resources=resources)
fork_and_wait(run_build, args, tools, resources=resources)
else:
Expand All @@ -4918,6 +4915,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
)
)

check_tools(config, args.verb)
images[i] = config = run_configure_scripts(config)

if args.verb != Verb.build and args.force == 0:
Expand All @@ -4933,6 +4931,9 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
if config.output_format == OutputFormat.none and not config.build_scripts:
return

if args.verb != Verb.build:
check_tools(config, Verb.build)

check_inputs(config)
fork_and_wait(run_sync, args, config, resources=resources)
fork_and_wait(run_build, args, config, resources=resources, package_dir=Path(package_dir))
Expand All @@ -4953,8 +4954,6 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
hint="Make sure to build the image first with 'mkosi build' or use '--force'")

with prepend_to_environ_path(last):
check_tools(last, args.verb)

with (
acl_toggle_boot(last, INVOKING_USER.uid)
if args.verb in (Verb.shell, Verb.boot)
Expand Down

0 comments on commit f5c3742

Please sign in to comment.