# mkosi Changelog
+## v11 (unreleased)
+
+- The `--build-environemnt` option was renamed to `--environment` and
+ extended to cover *all* invoked scripts, not just the `mkosi.build`.
+ The old name is still understood.
+
## v10
- Minimum supported Python version is now 3.7.
`--environment=`
-: Adds environment variables to the environment that the build script
- is executed with. Takes a space-separated list of variable
- assignments or just variable names. In the latter case, the values
- of those variables will be passed through from the environment in
- which `mkosi` was invoked. This option may be specified more than
- once, in which case all listed variables will be set. If the same
- variable is set twice, the later setting overrides the earlier one.
+: Adds variables to the environment that the
+ build/prepare/postinstall/finalize scripts are executed with. Takes
+ a space-separated list of variable assignments or just variable
+ names. In the latter case, the values of those variables will be
+ passed through from the environment in which `mkosi` was
+ invoked. This option may be specified more than once, in which case
+ all listed variables will be set. If the same variable is set twice,
+ the later setting overrides the earlier one.
`--build-sources=`
params.append("--setenv=SRCDIR=/root/src")
params.append("--chdir=/root/src")
if sft == SourceFileTransfer.mount:
- params.append("--bind=" + args.build_sources + ":/root/src")
+ params.append(f"--bind={args.build_sources}:/root/src")
if args.read_only:
params.append("--overlay=+/root/src::/root/src")
else:
params.append("--chdir=/root")
+ params.extend(f"--setenv={env}" for env in args.environment)
+
return params
verb = "build" if do_run_build_script else "final"
with complete_step("Running finalize script…"):
- env = collections.ChainMap({"BUILDROOT": root, "OUTPUTDIR": output_dir(args)}, os.environ)
+ env = dict(cast(Tuple[str, str], v.split("=", maxsplit=1)) for v in args.environment)
+ env = collections.ChainMap(dict(BUILDROOT=root, OUTPUTDIR=output_dir(args)), env, os.environ)
run([args.finalize_script, verb], env=env)
"-E",
action=SpaceDelimitedListAction,
default=[],
- help="Set an environment variable when running the build script",
+ help="Set an environment variable when running scripts",
metavar="NAME[=VALUE]",
)
group.add_argument(
if args.remove_files:
MkosiPrinter.info(" Remove Files: " + line_join_list(args.remove_files))
MkosiPrinter.info(" Build Script: " + none_to_none(args.build_script))
- MkosiPrinter.info(" Build Environment: " + line_join_list(args.environment))
+ MkosiPrinter.info(" Script Environment: " + line_join_list(args.environment))
if args.build_script:
MkosiPrinter.info(" Run tests: " + yes_no(args.with_tests))
"--bind-ro=/dev/block",
"--bind-ro=/dev/disk",
]
+
for partno in (args.esp_partno, args.bios_partno, args.root_partno, args.xbootldr_partno):
if partno is not None:
p = partition(loopdev, partno)
if os.path.exists(p):
params += [f"--bind-ro={p}", f"--property=DeviceAllow={p}"]
+
+ params.extend(f"--setenv={env}" for env in args.environment)
+
return params