]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix: capturing of loop variable for systemd-dissect call
authorJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 23 Dec 2025 16:12:40 +0000 (17:12 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 23 Dec 2025 17:37:45 +0000 (18:37 +0100)
This fixes B023 [1]. Before only the last loop value would be captured.

[1] https://docs.astral.sh/ruff/rules/function-uses-loop-variable/

mkosi/__init__.py

index ec6a878554b5abc8dfb56dcb665b8a35d23790f7..5299dda1db2dbf74dc3ec436b146e3f22399a597 100644 (file)
@@ -198,7 +198,11 @@ def mount_base_trees(context: Context) -> Iterator[None]:
                     ["systemd-dissect", "--mount", "--mkdir", path, d],
                     env=dict(SYSTEMD_DISSECT_VERITY_EMBEDDED="no", SYSTEMD_DISSECT_VERITY_SIDECAR="no"),
                 )
-                stack.callback(lambda: run(["systemd-dissect", "--umount", "--rmdir", d]))
+
+                def _umount(d: PathString = d) -> None:
+                    run(["systemd-dissect", "--umount", "--rmdir", d])
+
+                stack.callback(_umount)
                 bases += [d]
             else:
                 die(f"Unsupported base tree source {path}")