]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make sure the temporary directory is recalculated when we modify TMPDIR
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 1 Aug 2023 16:44:49 +0000 (18:44 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 1 Aug 2023 16:44:49 +0000 (18:44 +0200)
mkosi/__init__.py

index 1583054c1c41a4436fc783398d8bfa9da967bc85..d2ca7c625af1de495daa57229a51135f2ebf2436 100644 (file)
@@ -1628,6 +1628,10 @@ def build_image(args: MkosiArgs, config: MkosiConfig) -> None:
     # Make sure tmpfiles' aging doesn't interfere with our workspace
     # while we are working on it.
     with MkosiState(args, config) as state, scopedenv({"TMPDIR" : str(state.workspace)}):
+        # python caches the default temporary directory so when we modify TMPDIR we have to make sure it gets
+        # recalculated (see https://docs.python.org/3/library/tempfile.html#tempfile.tempdir).
+        tempfile.tempdir = None
+
         install_package_manager_trees(state)
 
         with mount_image(state):