]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove distro specific output directory
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 25 Apr 2023 11:41:42 +0000 (13:41 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 25 Apr 2023 15:53:21 +0000 (17:53 +0200)
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
mkosi/config.py

index 3950e9bde15a681f0a9d5fcc5189aded0665aedb..f554f25535f196fbbd42d77dce5ce02819a5f4b3 100644 (file)
@@ -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"))
 
index 553ead9e794ea6a1419b0a0d2243271887eb5fd7..d2352b6d80ee97ed2a58fba35c956a8157b0d434 100644 (file)
@@ -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: