page(text, args.pager)
return
- for config in images:
- if not config.minimum_version or config.minimum_version <= __version__:
- continue
-
- die(f"mkosi {config.minimum_version} or newer is required to build this configuration (found {__version__})")
+ if args.verb in (Verb.journalctl, Verb.coredumpctl, Verb.ssh):
+ # We don't use a tools tree for verbs that don't need an image build.
+ last = dataclasses.replace(images[-1], tools_tree=None)
+ return {
+ Verb.ssh: run_ssh,
+ Verb.journalctl: run_journalctl,
+ Verb.coredumpctl: run_coredumpctl,
+ }[args.verb](args, last)
- for config in images:
- if not config.repart_offline and os.getuid() != 0:
- die(f"Must be root to build {config.name()} image configured with RepartOffline=no")
-
- for config in images:
- check_workspace_directory(config)
+ assert args.verb.needs_build() or args.verb == Verb.clean
for config in images:
if args.verb == Verb.build and not args.force:
# 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.
- tools: Optional[Config]
-
for config in images:
- if not args.verb.needs_build() and args.verb != Verb.clean:
- continue
-
if config.tools_tree and config.tools_tree == Path("default"):
fork_and_wait(run_clean, args, finalize_default_tools(args, config, resources=resources))
if args.verb == Verb.clean:
return
+ for config in images:
+ if (minversion := config.minimum_version) and minversion <= __version__:
+ die(f"mkosi {minversion} or newer is required to build this configuration (found {__version__})")
+
+ if not config.repart_offline and os.getuid() != 0:
+ die(f"Must be root to build {config.name()} image configured with RepartOffline=no")
+
+ check_workspace_directory(config)
+
build = False
for i, config in enumerate(images):
- if not args.verb.needs_build():
- continue
-
tools = (
finalize_default_tools(args, config, resources=resources)
if config.tools_tree and config.tools_tree == Path("default")
Verb.shell: run_shell,
Verb.boot: run_shell,
Verb.qemu: run_qemu,
- Verb.ssh: run_ssh,
Verb.serve: run_serve,
- Verb.journalctl: run_journalctl,
- Verb.coredumpctl: run_coredumpctl,
Verb.burn: run_burn,
}[args.verb](args, last)
`ToolsTree=`, `--tools-tree=`
-: If specified, programs executed by mkosi are looked up inside the
- given tree instead of in the host system. Use this option to make
- image builds more reproducible by always using the same versions of
- programs to build the final image instead of whatever version is
- installed on the host system. If this option is not used, but the
- `mkosi.tools/` directory is found in the local directory it is
+: If specified, programs executed by mkosi to build and boot an image
+ are looked up inside the given tree instead of in the host system. Use
+ this option to make image builds more reproducible by always using the
+ same versions of programs to build the final image instead of whatever
+ version is installed on the host system. If this option is not used,
+ but the `mkosi.tools/` directory is found in the local directory it is
automatically used for this purpose with the root directory as target.
Note that when looking up binaries in `--tools-tree=`, only `/usr/bin`
and `/usr/sbin` are considered. Specifically, paths specified by