From: Daan De Meyer Date: Mon, 29 Jul 2024 17:57:53 +0000 (+0200) Subject: Don't use .cache if HOME=/ X-Git-Tag: v24.3~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd05c4e383d6566685fcf26466b076073fce5945;p=thirdparty%2Fmkosi.git Don't use .cache if HOME=/ If the user's home directory is /, don't use .cache but use /var/cache instead. --- diff --git a/mkosi/user.py b/mkosi/user.py index b92670344..8a37f675a 100644 --- a/mkosi/user.py +++ b/mkosi/user.py @@ -77,7 +77,11 @@ class INVOKING_USER: def cache_dir(cls) -> Path: if (env := os.getenv("XDG_CACHE_HOME")) or (env := os.getenv("CACHE_DIRECTORY")): cache = Path(env) - elif cls.is_regular_user() and (Path.cwd().is_relative_to(INVOKING_USER.home()) or not cls.invoked_as_root): + elif ( + cls.is_regular_user() and + INVOKING_USER.home() != Path("/") and + (Path.cwd().is_relative_to(INVOKING_USER.home()) or not cls.invoked_as_root) + ): cache = INVOKING_USER.home() / ".cache" else: cache = Path("/var/cache")