Skip to content

Commit

Permalink
Make sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies
Browse files Browse the repository at this point in the history
Let's make sure we always use the extra mkfs options configured in
these environment variables.

We also stop filtering the environment we pass to systemd-repart.
  • Loading branch information
DaanDeMeyer committed Jan 9, 2024
1 parent f4b1621 commit dbce89a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 2 additions & 7 deletions mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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]),
)

Expand Down
9 changes: 7 additions & 2 deletions mkosi/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dbce89a

Please sign in to comment.