]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Detect home directories outside of /home properly
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Nov 2024 10:27:09 +0000 (11:27 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Nov 2024 11:32:35 +0000 (12:32 +0100)
Fixes #3191

mkosi/util.py

index 82499ea35610be26349ea4ab74b370e7fb642be4..ba1a9ab88541fd711111294925cf0116e5982742 100644 (file)
@@ -244,6 +244,9 @@ def current_home_dir() -> Optional[Path]:
     if Path.cwd().is_relative_to("/root"):
         return Path("/root")
 
+    if (home := os.getenv("HOME")) and Path.cwd().is_relative_to(home):
+        return Path(home)
+
     if Path.cwd().is_relative_to("/home"):
         # `Path.parents` only supports slices and negative indexing from Python 3.10 onwards.
         # TODO: Remove list() when we depend on Python 3.10 or newer.