# cp doesn't support excluding directories but we can imitate it by bind mounting
# an empty directory over the directories we want to exclude.
exclude = flatten(
- ("--ro-bind", tmp, workdir(p))
+ ("--ro-bind", tmp, workdir(cachedir / p))
for p in config.distribution.package_manager(config).package_subdirs(cachedir)
)
src = last.package_cache_dir_or_default() / "cache" / subdir
for p in last.distribution.package_manager(last).package_subdirs(src):
- p.mkdir(parents=True, exist_ok=True)
+ (src / p).mkdir(parents=True, exist_ok=True)
# If we're in incremental mode and caching metadata is not explicitly disabled, cache the keyring and the
# synced repository metadata so we can reuse them later.
mounts += flatten(
(
"--bind",
- context.config.package_cache_dir_or_default() / d / subdir / p.relative_to(src),
- Path("/var") / d / subdir / p.relative_to(src),
+ context.config.package_cache_dir_or_default() / d / subdir / p,
+ Path("/var") / d / subdir / p,
)
for p in caches
if (
- context.config.package_cache_dir_or_default() / d / subdir / p.relative_to(src)
+ context.config.package_cache_dir_or_default() / d / subdir / p
).exists()
)
@classmethod
def package_subdirs(cls, cache: Path) -> list[Path]:
- return [cache / "archives"]
+ return [Path("archives")]
@classmethod
def state_subdirs(cls, state: Path) -> list[Path]:
@classmethod
def package_subdirs(cls, cache: Path) -> list[Path]:
return [
- p / "packages" for p in cache.iterdir() if p.is_dir() and "-" in p.name and "mkosi" not in p.name
+ (p / "packages").relative_to(cache) for p in cache.iterdir() if p.is_dir() and "-" in p.name and "mkosi" not in p.name
]
@classmethod
@classmethod
def package_subdirs(cls, cache: Path) -> list[Path]:
- return [cache / "pkg"]
+ return [Path("pkg")]
@classmethod
def state_subdirs(cls, state: Path) -> list[Path]:
@classmethod
def package_subdirs(cls, cache: Path) -> list[Path]:
- return [cache / "packages"]
+ return [Path("packages")]
@classmethod
def scripts(cls, context: Context) -> dict[str, list[PathString]]: