From 0237ebaba5a3af535c07c48752a453db6300a6cc Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 25 Apr 2023 13:41:42 +0200 Subject: [PATCH] Remove distro specific output directory Let's move the cache images to mkosi.cache/ and go back to non distro specific output directories. This gives us a stable path for the build outputs that doesn't depend on the specific distro or version used. --- mkosi/__init__.py | 10 +++++----- mkosi/config.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 3950e9bde..f554f2553 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -998,15 +998,15 @@ def unlink_output(args: MkosiArgs, config: MkosiConfig) -> None: 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")) diff --git a/mkosi/config.py b/mkosi/config.py index 553ead9e7..d2352b6d8 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1903,8 +1903,6 @@ def load_config(args: argparse.Namespace) -> MkosiConfig: 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 @@ -1999,6 +1997,9 @@ def load_config(args: argparse.Namespace) -> MkosiConfig: 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: -- 2.47.3