]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix cache directory
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Feb 2023 17:03:03 +0000 (18:03 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 9 Feb 2023 18:09:57 +0000 (19:09 +0100)
Make sure to use state.cache where applicable. Also get rid of
setup_package_cache() since it comes down to a one liner

mkosi/__init__.py
mkosi/distributions/arch.py

index 313cab883ef877d1e32f935df3e5b923d9588f1a..bb12edbc7e25b1e136eba22c40e4b298e6f5d67f 100644 (file)
@@ -543,7 +543,7 @@ def configure_serial_terminal(state: MkosiState, cached: bool) -> None:
 
 
 def cache_params(state: MkosiState, root: Path) -> list[PathString]:
-    return flatten(("--bind", state.config.cache_path, root / p) for p in state.installer.cache_path())
+    return flatten(("--bind", state.cache, root / p) for p in state.installer.cache_path())
 
 
 def run_prepare_script(state: MkosiState, cached: bool) -> None:
@@ -1109,15 +1109,6 @@ def print_output_size(config: MkosiConfig) -> None:
         MkosiPrinter.print_step(f"Resulting image size is {size}, consumes {space}.")
 
 
-def setup_package_cache(config: MkosiConfig, workspace: Path) -> Path:
-    if not config.cache_path:
-        cache = workspace / "cache"
-    else:
-        cache = config.cache_path
-
-    return cache
-
-
 def remove_duplicates(items: list[T]) -> list[T]:
     "Return list with any repetitions removed"
     # We use a dictionary to simulate an ordered set
@@ -3009,7 +3000,7 @@ def make_build_dir(state: MkosiState) -> None:
 
 def make_cache_dir(state: MkosiState) -> None:
     """Create the cache directory if set and not existing yet"""
-    run(["mkdir", "-p", state.config.cache_path], user=state.uid, group=state.gid)
+    run(["mkdir", "-p", state.cache], user=state.uid, group=state.gid)
 
 
 def make_install_dir(state: MkosiState) -> None:
@@ -3382,7 +3373,7 @@ def remove_artifacts(state: MkosiState, for_cache: bool = False) -> None:
 def build_stuff(uid: int, gid: int, config: MkosiConfig) -> None:
     workspace = setup_workspace(config)
     workspace_dir = Path(workspace.name)
-    cache = setup_package_cache(config, workspace_dir)
+    cache = config.cache_path or workspace_dir / "cache"
 
     state = MkosiState(
         uid=uid,
index 0c6491d3c3cf9c5d88a1414e98a432ed1f6ce1a5..ef5a96e8871c5c120dbd39901c33d21ef7fe6e8d 100644 (file)
@@ -53,7 +53,7 @@ def install_arch(state: MkosiState) -> None:
                 [options]
                 RootDir = {state.root}
                 LogFile = /dev/null
-                CacheDir = {state.config.cache_path}
+                CacheDir = {state.cache}
                 GPGDir = /etc/pacman.d/gnupg/
                 HookDir = {state.root}/etc/pacman.d/hooks/
                 HoldPkg = pacman glibc