From: Daan De Meyer Date: Thu, 9 Oct 2025 06:50:44 +0000 (+0200) Subject: Don't unconditionally sync when PackageCacheDirectory=/var X-Git-Tag: v26~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=611c8b46c84095833feae9d5aa0ef0a656b032ca;p=thirdparty%2Fmkosi.git Don't unconditionally sync when PackageCacheDirectory=/var If PackageCacheDirectory=/var and a cache directory is not configured (like in mkosi-initrd), then we'd always sync repository metadata, regardless of the value of CacheOnly=. Let's fix that by disallowing CacheOnly=metadata|always if a cache directory is not configured and only syncing if CacheOnly=never|auto, regardless if a cache directory is configured or not. Fixes #3946 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 3eb22c224..250ad84b5 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2651,6 +2651,13 @@ def check_inputs(config: Config) -> None: hint="Use Profile= to configure the profile ID", ) + if ( + config.cacheonly not in (Cacheonly.never, Cacheonly.auto) + and not config.cache_dir + and config.package_cache_dir_or_default() != Path("/var") + ): + die(f"A cache directory must be configured in order to use CacheOnly={config.cacheonly}") + def check_tool(config: Config, *tools: PathString, reason: str, hint: Optional[str] = None) -> Path: tool = config.find_binary(*tools) @@ -4690,10 +4697,8 @@ def sync_repository_metadata( (last.package_cache_dir_or_default() / "cache" / subdir).mkdir(parents=True, exist_ok=True) # Sync repository metadata unless explicitly disabled. - if ( - not last.cache_dir - or last.cacheonly == Cacheonly.never - or (last.cacheonly == Cacheonly.auto and not any(have_cache(config) for config in images)) + if last.cacheonly == Cacheonly.never or ( + last.cacheonly == Cacheonly.auto and not any(have_cache(config) for config in images) ): with setup_workspace(args, last) as workspace: context = Context(