"--format", str(format),
"--output", output,
"--workspace-dir=/var/tmp",
- "--cache-dir=/var/cache",
+ "--cache-dir=/var",
"--output-dir", context.staging_area,
"--extra-tree", f"/usr/lib/modules/{context.kernel_version}:/usr/lib/modules/{context.kernel_version}",
"--extra-tree=/usr/lib/firmware:/usr/lib/firmware",
if remove_package_cache:
if config.cache_dir and config.cache_dir.exists() and any(config.cache_dir.iterdir()):
with complete_step("Clearing out package cacheā¦"):
- empty_directory(config.cache_dir)
+ rmtree(*(
+ config.cache_dir / p / d
+ for p in ("cache", "lib")
+ for d in ("apt", "dnf", "libdnf5", "pacman", "zypp")
+ ))
def cache_tree_paths(config: MkosiConfig) -> tuple[Path, Path, Path]:
(state.root / "var/lib/dpkg").mkdir(parents=True, exist_ok=True)
(state.root / "var/lib/dpkg/status").touch()
+ (state.cache_dir / "lib/apt").mkdir(exist_ok=True, parents=True)
+ (state.cache_dir / "cache/apt").mkdir(exist_ok=True, parents=True)
+
# We have a special apt.conf outside of pkgmngr dir that only configures "Dir::Etc" that we pass to APT_CONFIG to
# tell apt it should read config files from /etc/apt in case this is overridden by distributions. This is required
# because apt parses CLI configuration options after parsing its configuration files and as such we can't use CLI
"-o", "APT::Get::Allow-Change-Held-Packages=true",
"-o", "APT::Get::Allow-Remove-Essential=true",
"-o", "APT::Sandbox::User=root",
- "-o", f"Dir::Cache={state.cache_dir / 'apt'}",
- "-o", f"Dir::State={state.cache_dir / 'apt'}",
+ "-o", f"Dir::Cache={state.cache_dir / 'cache/apt'}",
+ "-o", f"Dir::State={state.cache_dir / 'lib/apt'}",
"-o", f"Dir::State::Status={state.root / 'var/lib/dpkg/status'}",
"-o", f"Dir::Etc::Trusted={trustedkeys}",
"-o", f"Dir::Log={state.workspace}",
f"--releasever={state.config.release}",
f"--installroot={state.root}",
"--setopt=keepcache=1",
- f"--setopt=cachedir={state.cache_dir / ('libdnf5' if dnf.endswith('dnf5') else 'dnf')}",
+ f"--setopt=cachedir={state.cache_dir / 'cache' / ('libdnf5' if dnf.endswith('dnf5') else 'dnf')}",
+ f"--setopt=persistdir={state.cache_dir / 'lib' / ('libdnf5' if dnf.endswith('dnf5') else 'dnf')}",
f"--setopt=install_weak_deps={int(state.config.with_recommends)}",
"--setopt=check_config_file_age=0",
"--disable-plugin=*" if dnf.endswith("dnf5") else "--disableplugin=*",
"--config=/etc/dnf/dnf.conf",
"--setopt=reposdir=/etc/yum.repos.d",
"--setopt=varsdir=/etc/dnf/vars",
- "--setopt=persistdir=/var/lib/dnf",
]
return cmdline
with umask(~0o755):
(state.root / "var/lib/pacman").mkdir(exist_ok=True, parents=True)
+ (state.cache_dir / "cache/pacman/pkg").mkdir(parents=True, exist_ok=True)
+
config = state.pkgmngr / "etc/pacman.conf"
if config.exists():
return
def pacman_cmd(state: MkosiState) -> list[PathString]:
- with umask(~0o755):
- (state.cache_dir / "pacman/pkg").mkdir(parents=True, exist_ok=True)
-
return [
"pacman",
"--root", state.root,
"--logfile=/dev/null",
- "--cachedir", state.cache_dir / "pacman/pkg",
+ "--cachedir", state.cache_dir / "cache/pacman/pkg",
"--hookdir", state.root / "etc/pacman.d/hooks",
"--arch", state.config.distribution.architecture(state.config.architecture),
"--color", "auto",
"HOME=/",
"zypper",
f"--installroot={state.root}",
- f"--cache-dir={state.cache_dir / 'zypp'}",
+ f"--cache-dir={state.cache_dir / 'cache/zypp'}",
"--gpg-auto-import-keys" if state.config.repository_key_check else "--no-gpg-checks",
"--non-interactive",
]