diff --git a/mkosi/__init__.py b/mkosi/__init__.py index c883f6af0..be8e46cd4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2538,18 +2538,12 @@ def make_image( cmdline += ["--definitions", d] options += ["--ro-bind", d, d] - env = { - option: value - for option, value in context.config.environment.items() - if option.startswith("SYSTEMD_REPART_MKFS_OPTIONS_") or option == "SOURCE_DATE_EPOCH" - } - with complete_step(msg): output = json.loads( run( cmdline, stdout=subprocess.PIPE, - env=env, + env=context.config.environment, sandbox=context.sandbox(devices=not context.config.repart_offline, options=options), ).stdout ) @@ -3035,6 +3029,7 @@ def run_shell(args: Args, config: Config) -> None: fname, ], stdin=sys.stdin, + env=config.environment, sandbox=config.sandbox(network=True, devices=True, options=["--bind", fname, fname]), ) diff --git a/mkosi/qemu.py b/mkosi/qemu.py index fa3d518f1..8284c98c3 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -746,8 +746,13 @@ def run_qemu(args: Args, config: Config) -> None: if want_scratch(config): scratch = stack.enter_context(tempfile.NamedTemporaryFile(dir="/var/tmp", prefix="mkosi-scratch")) scratch.truncate(1024**4) - run([f"mkfs.{config.distribution.filesystem()}", "-L", "scratch", scratch.name], - stdout=subprocess.DEVNULL, sandbox=config.sandbox(options=["--bind", scratch.name, scratch.name])) + fs = config.distribution.filesystem() + extra = config.environment.get(f"SYSTEMD_REPART_MKFS_OPTIONS_{fs.upper()}", "") + run( + [f"mkfs.{fs}", "-L", "scratch", *extra.split(), scratch.name], + stdout=subprocess.DEVNULL, + sandbox=config.sandbox(options=["--bind", scratch.name, scratch.name]), + ) cmdline += [ "-drive", f"if=none,id=scratch,file={scratch.name},format=raw", "-device", "scsi-hd,drive=scratch",