From: Daan De Meyer Date: Tue, 28 Jan 2025 19:18:36 +0000 (+0100) Subject: Replace check_uid with a "tools" image check in have_cache() X-Git-Tag: v25.3~6^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b6121a08a4d5a1edf34f2abb113b29a0dddf0cf;p=thirdparty%2Fmkosi.git Replace check_uid with a "tools" image check in have_cache() We have access to the config object in have_cache() and this argument is specifically intended to be used whenever we pass the default tools tree to have_cache(), so let's just do the check based on config.image in have_cache() itself. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 694deb357..d7bfcf30d 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3068,7 +3068,7 @@ def save_cache(context: Context) -> None: ) -def have_cache(config: Config, check_uid: bool = True) -> bool: +def have_cache(config: Config) -> bool: if not config.incremental or config.base_trees or config.overlay: return False @@ -3077,7 +3077,7 @@ def have_cache(config: Config, check_uid: bool = True) -> bool: logging.debug(f"{final} does not exist, not reusing cached images") return False - if check_uid and (uid := final.stat().st_uid) != os.getuid(): + if config.image != "tools" and (uid := final.stat().st_uid) != os.getuid(): logging.debug( f"{final} uid ({uid}) does not match user uid ({os.getuid()}), not reusing cached images" ) @@ -4794,7 +4794,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: tools and ( not (tools.output_dir_or_cwd() / tools.output).exists() - or (tools.incremental and not have_cache(tools, check_uid=False)) + or (tools.incremental and not have_cache(tools)) ) and (args.verb != Verb.build or last.output_format == OutputFormat.none) and not args.force @@ -4808,8 +4808,7 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: # If we're doing an incremental build and the cache is not out of date, don't clean up the # tools tree so that we can reuse the previous one. if tools and ( - not tools.incremental - or ((args.verb == Verb.build or args.force > 0) and not have_cache(tools, check_uid=False)) + not tools.incremental or ((args.verb == Verb.build or args.force > 0) and not have_cache(tools)) ): if tools.incremental == Incremental.strict: die(