From: Daan De Meyer Date: Thu, 9 Feb 2023 17:03:03 +0000 (+0100) Subject: Fix cache directory X-Git-Tag: v15~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=966971a3479b1e0ada664484bbb05ff3e73e1a5a;p=thirdparty%2Fmkosi.git Fix cache directory Make sure to use state.cache where applicable. Also get rid of setup_package_cache() since it comes down to a one liner --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 313cab883..bb12edbc7 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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, diff --git a/mkosi/distributions/arch.py b/mkosi/distributions/arch.py index 0c6491d3c..ef5a96e88 100644 --- a/mkosi/distributions/arch.py +++ b/mkosi/distributions/arch.py @@ -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