]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 9 Jan 2024 12:12:37 +0000 (13:12 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 9 Jan 2024 12:54:39 +0000 (13:54 +0100)
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.

mkosi/__init__.py
mkosi/qemu.py

index c883f6af0fc7b2cfae76f482f9ba843b85955b66..be8e46cd47f9d5cbc052a0194501bf2a822266f9 100644 (file)
@@ -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]),
             )
 
index fa3d518f12d064758411f116b1a27edc5b49d743..8284c98c35d37dd960750dbc762d514d169c55d2 100644 (file)
@@ -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",