return Path("default") in config.initrds
-def finalize_historydir(args: Args) -> Path:
+def finalize_historydir(args: Args, output_dir: Optional[Path] = None) -> Path:
+ # When an output dir is given on the CLI, store the build history there so that concurrent builds with
+ # different output dirs don't clobber a shared history. Don't check the finalized OutputDirectory=
+ # config, only the CLI value: the former isn't known yet here (config files and includes are
+ # parsed later) and vm/boot can't see it anyway since they recover the config from the history instead of
+ # parsing it. An output dir set only in config files keeps the history in the config dir.
+ if output_dir is not None:
+ return output_dir / ".mkosi-private/history"
+
configdir = finalize_configdir(args.directory)
return (configdir or Path.cwd()) / ".mkosi-private/history"
return args, None, ()
configdir = finalize_configdir(args.directory)
- historydir = finalize_historydir(args)
+ historydir = finalize_historydir(args, context.cli.get("output_dir"))
if have_history(args, historydir):
history = Config.from_partial_json((historydir / "latest.json").read_text())
"--register=no",
"--machine",
self.machine,
+ "--output-directory", self.output_dir,
*options,
],
args,
stdin=sys.stdin if sys.stdin.isatty() else None,
check=False,
- )
+ ) # fmt: skip
if result.returncode != 123:
raise subprocess.CalledProcessError(result.returncode, result.args, result.stdout, result.stderr)
"--register=no",
"--machine",
self.machine,
+ "--output-directory", self.output_dir,
*options,
],
args,
stdin=sys.stdin if sys.stdin.isatty() else None,
check=False,
- )
+ ) # fmt: skip
if result.returncode != 123:
raise subprocess.CalledProcessError(result.returncode, result.args, result.stdout, result.stderr)