From: Daan De Meyer Date: Sat, 22 Mar 2025 11:51:12 +0000 (+0100) Subject: user: Make INVOKING_USER.cache_dir() return the user cache directory X-Git-Tag: v26~305^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c96ed37f795fd557e726814d11bac660dabe5d6;p=thirdparty%2Fmkosi.git user: Make INVOKING_USER.cache_dir() return the user cache directory --- diff --git a/mkosi/config.py b/mkosi/config.py index 77d25e997..ee140e873 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -2096,10 +2096,10 @@ class Config: if ( (cache := INVOKING_USER.cache_dir()) - and cache != Path("/var/cache/mkosi") + and cache != Path("/var/cache") and os.access(cache, os.W_OK) ): - return cache + return cache / "mkosi" return Path("/var/tmp") @@ -2107,7 +2107,7 @@ class Config: key = f"{self.distribution}~{self.release}~{self.architecture}" if self.mirror: key += f"-{self.mirror.replace('/', '-')}" - return self.package_cache_dir or (INVOKING_USER.cache_dir() / key) + return self.package_cache_dir or (INVOKING_USER.cache_dir() / "mkosi" / key) def tools(self) -> Path: return self.tools_tree or Path("/") diff --git a/mkosi/user.py b/mkosi/user.py index 78f9bc5f7..3daafc92d 100644 --- a/mkosi/user.py +++ b/mkosi/user.py @@ -42,7 +42,7 @@ class INVOKING_USER: else: cache = Path("/var/cache") - return cache / "mkosi" + return cache @classmethod def runtime_dir(cls) -> Path: diff --git a/tests/__init__.py b/tests/__init__.py index 98a0aec29..f2e3989b5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -34,7 +34,7 @@ class Image: self.config = config def __enter__(self) -> "Image": - if (cache := INVOKING_USER.cache_dir()) and os.access(cache, os.W_OK): + if (cache := INVOKING_USER.cache_dir() / "mkosi") and os.access(cache, os.W_OK): tmpdir = cache else: tmpdir = Path("/var/tmp")