]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure we pass through TMPDIR to run()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 14 Aug 2023 18:57:30 +0000 (20:57 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Tue, 15 Aug 2023 08:17:47 +0000 (10:17 +0200)
mkosi/installer/apt.py
mkosi/run.py

index d84a71a6b92870c7b15d8a626a747677037b5f6b..c8804326c90f420d4df4489511e1e8262f0b6984 100644 (file)
@@ -107,5 +107,6 @@ def invoke_apt(
 ) -> None:
     cmd = apivfs_cmd(state.root) if apivfs else []
     bwrap(cmd + apt_cmd(state, command) + [operation, *sort_packages(packages)],
-          options=flatten(["--bind", d, d] for d in (state.config.workspace_dir, state.config.cache_dir) if d),
+          # dpkg doesn't seem to unset TMPDIR when chrooting so we unset it for dpkg.
+          options=["--unsetenv", "TMPDIR"] + flatten(["--bind", d, d] for d in (state.config.workspace_dir, state.config.cache_dir) if d),
           network=True, env=state.config.environment)
index 96290b5ae05bb1b781eeb7397b5799b67c777278..5efa29015fb503076f127e57d15f4a0ad4e8ed6c 100644 (file)
@@ -180,6 +180,9 @@ def run(
         LANG="C.UTF-8",
     ) | env
 
+    if "TMPDIR" in os.environ:
+        env["TMPDIR"] = os.environ["TMPDIR"]
+
     if ARG_DEBUG.get():
         env["SYSTEMD_LOG_LEVEL"] = "debug"
 
@@ -391,6 +394,7 @@ def chroot_cmd(root: Path, *, options: Sequence[PathString] = ()) -> list[PathSt
         "--setenv", "container", "mkosi",
         "--setenv", "HOME", "/",
         "--setenv", "PATH", "/usr/bin:/usr/sbin",
+        "--unsetenv", "TMPDIR",
     ]
 
     resolve = Path("etc/resolv.conf")