env=env | config.environment,
sandbox=config.sandbox(
binary=None,
- tools=False,
mounts=[*sources, Mount(script, "/work/configure", ro=True)],
options=["--dir", "/work/src", "--chdir", "/work/src"]
),
die("No configuration found",
hint="Make sure you're running mkosi from a directory with configuration files")
- for i, config in enumerate(images):
- images[i] = run_configure_scripts(config)
-
if args.verb == Verb.summary:
if args.json:
text = json.dumps(
check_workspace_directory(config)
+ if tools and not (tools.output_dir_or_cwd() / tools.output).exists():
+ if args.verb == Verb.build or args.force > 0:
+ fork_and_wait(run_sync, args, tools, resources=resources)
+ fork_and_wait(run_build, args, tools, resources=resources)
+ else:
+ 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'")
+
build = False
for i, config in enumerate(images):
)
)
+ images[i] = config = run_configure_scripts(config)
+
if args.verb != Verb.build and args.force == 0:
continue
- if tools and not (tools.output_dir_or_cwd() / tools.output).exists():
- fork_and_wait(run_sync, args, tools, resources=resources)
- fork_and_wait(run_build, args, tools, resources=resources)
-
if (config.output_dir_or_cwd() / config.output_with_compression).exists():
continue
current working directory. The following scripts are supported:
* If **`mkosi.configure`** (`ConfigureScripts=`) exists, it is executed
- after parsing the configuration files. This script may be used to
- dynamically modify the configuration. It receives the configuration
- serialized as JSON on stdin and should output the modified
- configuration serialized as JSON on stdout. Note that this script does
- not use the tools tree even if one is configured.
+ before building the image. This script may be used to dynamically
+ modify the configuration. It receives the configuration serialized as
+ JSON on stdin and should output the modified configuration serialized
+ as JSON on stdout. Note that this script only runs when building or
+ booting the image (`build`, `qemu`, `boot` and `shell` verbs). If a
+ default tools tree is configured, it will be built before running the
+ configure scripts and the configure scripts will run with the tools
+ tree available. This also means that the modifications made by
+ configure scripts will not be visible in the `summary` output.
* If **`mkosi.sync`** (`SyncScripts=`) exists, it is executed before the
image is built. This script may be used to update various sources that