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)