def cache_tree_paths(config: MkosiConfig) -> tuple[Path, Path]:
+ assert config.cache_dir
+
# If the image ID is specified, use cache file names that are independent of the image versions, so that
# rebuilding and bumping versions is cheap and reuses previous versions if cached.
- if config.image_id is not None and config.output_dir:
- prefix = config.output_dir / config.image_id
- elif config.image_id:
- prefix = Path(config.image_id)
+ if config.image_id:
+ prefix = config.cache_dir / config.image_id
# Otherwise, derive the cache file names directly from the output file names.
else:
- prefix = config.output
+ prefix = config.cache_dir / config.output.name
return (Path(f"{prefix}.cache"), Path(f"{prefix}.build.cache"))
args.cache_dir = args.cache_dir / f"{args.distribution}~{args.release}"
if args.build_dir:
args.build_dir = args.build_dir / f"{args.distribution}~{args.release}"
- if args.output_dir:
- args.output_dir = args.output_dir / f"{args.distribution}~{args.release}"
if args.sign:
args.checksum = True
if args.overlay and not args.base_trees:
die("--overlay can only be used with --base-tree")
+ if args.incremental and not args.cache_dir:
+ die("A cache directory must be configured in order to use --incremental")
+
# For unprivileged builds we need the userxattr OverlayFS mount option, which is only available in Linux v5.11 and later.
with prepend_to_environ_path(args.extra_search_paths):
if (args.build_script is not None or args.base_trees) and GenericVersion(platform.release()) < GenericVersion("5.11") and os.geteuid() != 0: