else:
params += ["--chdir=/root"]
- params += [f"--setenv={env}" for env in args.environment]
+ params += [f"--setenv={env}={value}" for env, value in args.environment.items()]
return params
raise ValueError("Parameter 'loopdev' required for bootable images.")
nspawn_params += nspawn_params_for_blockdev_access(args, loopdev)
- env = dict(cast(Tuple[str, str], v.split("=", maxsplit=1)) for v in args.environment)
-
run_workspace_command(args, root, ["/root/postinst", verb],
network=(args.with_network is True),
nspawn_params=nspawn_params,
- env=env)
+ env=args.environment)
root_home(args, root).joinpath("postinst").unlink()
verb = "build" if do_run_build_script else "final"
with complete_step("Running finalize script…"):
- env = dict(cast(Tuple[str, str], v.split("=", maxsplit=1)) for v in args.environment)
- env = collections.ChainMap(dict(BUILDROOT=str(root), OUTPUTDIR=str(output_dir(args))), env, os.environ)
+ env = collections.ChainMap(dict(BUILDROOT=str(root), OUTPUTDIR=str(output_dir(args))),
+ args.environment,
+ os.environ)
run([args.finalize_script, verb], env=env)
args.postinst_script = normalize_script(args.postinst_script)
args.finalize_script = normalize_script(args.finalize_script)
- for i in range(len(args.environment)):
- if "=" not in args.environment[i]:
- value = os.getenv(args.environment[i], "")
- args.environment[i] += f"={value}"
+ if args.environment:
+ env = {}
+ for s in args.environment:
+ key, _, value = s.partition("=")
+ value = value or os.getenv(key, "")
+ env[key] = value
+ args.environment = env
+ else:
+ args.environment = {}
if args.cache_path is not None:
args.cache_path = args.cache_path.absolute()
if args.remove_packages:
MkosiPrinter.info(" Remove Packages: " + line_join_list(args.remove_packages))
MkosiPrinter.info(" Build Script: " + none_to_none(args.build_script))
- MkosiPrinter.info(" Script Environment: " + line_join_list(args.environment))
+ env = [f"{k}={v}" for k, v in args.environment.items()]
+ MkosiPrinter.info(" Script Environment: " + line_join_list(env))
if args.build_script:
MkosiPrinter.info(" Run tests: " + yes_no(args.with_tests))
*nspawn_rlimit_params(),
]
- cmdline.extend(f"--setenv={env}" for env in args.environment)
+ cmdline.extend(f"--setenv={env}={value}" for env, value in args.environment.items())
# TODO: Use --autopipe once systemd v247 is widely available.
console_arg = f"--console={'interactive' if sys.stdout.isatty() else 'pipe'}"
skeleton_trees: List[Path]
clean_package_metadata: Union[bool, str]
remove_files: List[Path]
- environment: List[str]
+ environment: Dict[str, str]
build_sources: Optional[Path]
build_dir: Optional[Path]
include_dir: Optional[Path]
if path and path.exists():
params += [f"--bind-ro={path}", f"--property=DeviceAllow={path}"]
- params += [f"--setenv={env}" for env in args.environment]
+ params += [f"--setenv={env}={value}" for env, value in args.environment.items()]
return params