From: Daan De Meyer Date: Thu, 6 Mar 2025 21:45:31 +0000 (+0100) Subject: Drop unnecessary condition X-Git-Tag: v26~325^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f880feb21e3e92861d0f6c09cebc8586775002dd;p=thirdparty%2Fmkosi.git Drop unnecessary condition A few lines earlier, we already short-circuit run_verb() if the verb does not need a build, so no need to check here again. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 6ab11017a..66b703743 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -5119,45 +5119,44 @@ def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None: logging.info(f"Output path {output} exists already. (Use --force to rebuild.)") return - if args.verb.needs_build(): - if args.verb != Verb.build and not args.force and not output.exists(): - die( - f"Image '{last.image}' has not been built yet", - hint="Make sure to build the image first with 'mkosi build' or use '--force'", - ) + if args.verb != Verb.build and not args.force and not output.exists(): + die( + f"Image '{last.image}' has not been built yet", + hint="Make sure to build the image first with 'mkosi build' or use '--force'", + ) - if not last.repart_offline and os.getuid() != 0: - die(f"Must be root to build {last.image} image configured with RepartOffline=no") + if not last.repart_offline and os.getuid() != 0: + die(f"Must be root to build {last.image} image configured with RepartOffline=no") - check_workspace_directory(last) + check_workspace_directory(last) - if last.is_incremental(): - for a, b in itertools.combinations(images, 2): - if a.expand_key_specifiers(a.cache_key) == b.expand_key_specifiers(b.cache_key): - die( - f"Image {a.image} and {b.image} have the same cache key '{a.expand_key_specifiers(a.cache_key)}'", # noqa: E501 - hint="Add the &I specifier to the cache key to avoid this issue", - ) - - if last.is_incremental() and last.incremental == Incremental.strict: - if args.force > 1: + if last.is_incremental(): + for a, b in itertools.combinations(images, 2): + if a.expand_key_specifiers(a.cache_key) == b.expand_key_specifiers(b.cache_key): die( - "Cannot remove incremental caches when building with Incremental=strict", - hint="Build once with '-i yes' to update the image cache", + f"Image {a.image} and {b.image} have the same cache key '{a.expand_key_specifiers(a.cache_key)}'", # noqa: E501 + hint="Add the &I specifier to the cache key to avoid this issue", ) - for config in images: - if have_cache(config): - continue + if last.is_incremental() and last.incremental == Incremental.strict: + if args.force > 1: + die( + "Cannot remove incremental caches when building with Incremental=strict", + hint="Build once with '-i yes' to update the image cache", + ) - die( - f"Strict incremental mode is enabled and cache for image {config.image} is out-of-date", - hint="Build once with '-i yes' to update the image cache", - ) + for config in images: + if have_cache(config): + continue + + die( + f"Strict incremental mode is enabled and cache for image {config.image} is out-of-date", + hint="Build once with '-i yes' to update the image cache", + ) # First, process all directory removals because otherwise if different images share directories # a later image build could end up deleting the output generated by an earlier image build. - if args.verb.needs_build() and (needs_build(args, last) or args.wipe_build_dir): + if needs_build(args, last) or args.wipe_build_dir: for config in images: run_clean(args, config)