]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Check for required tools earlier
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 12 Aug 2024 09:55:53 +0000 (11:55 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 12 Aug 2024 12:12:01 +0000 (14:12 +0200)
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.

mkosi/__init__.py

index 9bf98afe2195738d1ac3c437dddb5cfa0190d5f6..72851ecd9b8d723c18343fcc00b1501a998e1a81 100644 (file)
@@ -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:
@@ -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:
@@ -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:
@@ -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))
@@ -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)