]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use INVOKING_USER.home to find home in the workspace logic
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 9 Nov 2023 13:58:51 +0000 (14:58 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Nov 2023 14:44:45 +0000 (15:44 +0100)
mkosi/config.py

index 487a5274999ae2ef1cba6f6ac8cc790803e66d0a..37851bf01088562ca60e81ebe16892712062cbeb 100644 (file)
@@ -896,15 +896,15 @@ class MkosiConfig:
         # If we're running from /home and there's a cache or output directory in /home, we want to use a workspace
         # directory in /home as well as /home might be on a separate partition or subvolume which means that to take
         # advantage of reflinks and such, the workspace directory has to be on the same partition/subvolume.
-        if Path.cwd().is_relative_to("/home") and len(Path.cwd().parents) >= 3:
-            home = Path.cwd().parents[-3]
-
-            if (
-                (self.cache_dir and self.cache_dir.is_relative_to(home) or
-                self.output_dir and self.output_dir.is_relative_to(home)) and
-                (home / ".cache").exists()
-            ):
-                return home / ".cache"
+        if (
+            Path.cwd().is_relative_to(INVOKING_USER.home) and
+            (INVOKING_USER.home / ".cache").exists() and
+            (
+                self.cache_dir and self.cache_dir.is_relative_to(INVOKING_USER.home) or
+                self.output_dir and self.output_dir.is_relative_to(INVOKING_USER.home)
+            )
+        ):
+            return INVOKING_USER.home / ".cache"
 
         return Path("/var/tmp")