]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Unset TMPDIR in apivfs_cmd()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 17 Aug 2023 18:54:36 +0000 (20:54 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 18 Aug 2023 09:49:26 +0000 (11:49 +0200)
dnf seems to have issues with this as well so let's unset TMPDIR
whenever we set up APIVFS as that's a good indication something is
going to chroot and we should unset TMPDIR.

mkosi/installer/apt.py
mkosi/run.py

index c8804326c90f420d4df4489511e1e8262f0b6984..d84a71a6b92870c7b15d8a626a747677037b5f6b 100644 (file)
@@ -107,6 +107,5 @@ def invoke_apt(
 ) -> None:
     cmd = apivfs_cmd(state.root) if apivfs else []
     bwrap(cmd + apt_cmd(state, command) + [operation, *sort_packages(packages)],
-          # 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),
+          options=flatten(["--bind", d, d] for d in (state.config.workspace_dir, state.config.cache_dir) if d),
           network=True, env=state.config.environment)
index 5efa29015fb503076f127e57d15f4a0ad4e8ed6c..87e8a5a950b0e8c84236b86445b64b4ae6e052a2 100644 (file)
@@ -369,6 +369,8 @@ def apivfs_cmd(root: Path) -> list[PathString]:
         "--proc", root / "proc",
         "--dev", root / "dev",
         "--ro-bind", "/sys", root / "sys",
+        # APIVFS generally means chrooting is going to happen so unset TMPDIR just to be safe.
+        "--unsetenv", "TMPDIR",
     ]
 
     if (root / "etc/machine-id").exists():
@@ -394,7 +396,6 @@ 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")