if args.verb == Verb.build and not args.force:
check_outputs(config)
+ last = images[-1]
+
+ if last.tools_tree and last.tools_tree == Path("default"):
+ tools = finalize_default_tools(args, last, resources=resources)
+
+ # If we're doing an incremental tools tree and the cache is not out of date, don't clean up the tools tree
+ # so that we can reuse the previous one.
+ if not tools.incremental or not have_cache(tools) or needs_clean(args, tools, force=2):
+ fork_and_wait(run_clean, args, tools, resources=resources)
+ else:
+ tools = None
+
# First, process all directory removals because otherwise if different images share directories a later
# image build could end up deleting the output generated by an earlier image build.
for config in images:
- if config.tools_tree and config.tools_tree == Path("default"):
- toolsconfig = finalize_default_tools(args, config, resources=resources)
-
- # If we're doing an incremental tools tree and the cache is not out of date, don't clean up the tools tree
- # so that we can reuse the previous one.
- if not toolsconfig.incremental or not have_cache(toolsconfig) or needs_clean(args, toolsconfig, force=2):
- fork_and_wait(run_clean, args, toolsconfig, resources=resources)
-
fork_and_wait(run_clean, args, config, resources=resources)
if args.verb == Verb.clean:
build = False
for i, config in enumerate(images):
- tools = (
- finalize_default_tools(args, config, resources=resources)
- if config.tools_tree and config.tools_tree == Path("default")
- else None
- )
-
images[i] = config = dataclasses.replace(
config,
- tools_tree=tools.output_dir_or_cwd() / tools.output if tools else config.tools_tree,
+ tools_tree=(
+ tools.output_dir_or_cwd() / tools.output
+ if tools and config.tools_tree == Path("default")
+ else config.tools_tree
+ )
)
if args.verb != Verb.build and args.force == 0:
continue
- if tools and not (tools.output_dir_or_cwd() / tools.output_with_compression).exists():
+ 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 args.verb == Verb.build:
return
+ # The images array has been modified so we need to reevaluate last again.
last = images[-1]
if not (last.output_dir_or_cwd() / last.output_with_compression).exists():
`ExtraSearchPaths=`, the binary will be executed on the host.
: If set to `default`, mkosi will automatically add an extra tools tree
- image and use it as the tools tree. The following table shows for
- which distributions default tools tree packages are defined and which
- packages are included in those default tools trees:
+ image and use it as the tools tree.
+
+: Note that mkosi will only build a single default tools tree per build,
+ even if multiple images are defined in `mkosi.images` with
+ `ToolsTree=default`. The settings of the "last" image will apply to
+ the default tools tree (usually the image defined last in
+ mkosi.images and without any dependencies on other images).
+
+: The following table shows for which distributions default tools tree
+ packages are defined and which packages are included in those default
+ tools trees:
| | Fedora | CentOS | Debian | Ubuntu | Arch | openSUSE |
|-------------------------|--------|--------|--------|--------|------|----------|