/var/lib/pacman/local contains the local database of installed packages.
When using "--package-cache-dir /var", we'd end up copying the local
database of the host which means pacman thinks packages are already
installed in the image even though they aren't.
Fix this by not copying /var/lib/pacman/local.
Fixes #2904
logging.debug(f"{src} does not exist, not copying repository metadata from it")
continue
- if d == "cache":
- caches = context.config.distribution.package_manager(context.config).cache_subdirs(src)
- else:
- caches = []
-
with tempfile.TemporaryDirectory() as tmp:
os.chmod(tmp, 0o755)
# 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 = [Mount(tmp, p, ro=True) for p in caches]
+ if d == "cache":
+ exclude = [
+ Mount(tmp, p, ro=True)
+ for p in context.config.distribution.package_manager(context.config).cache_subdirs(src)
+ ]
+ else:
+ exclude = [
+ Mount(tmp, p, ro=True)
+ for p in context.config.distribution.package_manager(context.config).state_subdirs(src)
+ ]
dst = context.package_cache_dir / d / subdir
with umask(~0o755):
def cache_subdirs(cls, cache: Path) -> list[Path]:
return []
+ @classmethod
+ def state_subdirs(cls, state: Path) -> list[Path]:
+ return []
+
@classmethod
def scripts(cls, context: Context) -> dict[str, list[PathString]]:
return {}
def cache_subdirs(cls, cache: Path) -> list[Path]:
return [cache / "pkg"]
+ @classmethod
+ def state_subdirs(cls, state: Path) -> list[Path]:
+ return [state / "local"]
+
@classmethod
def scripts(cls, context: Context) -> dict[str, list[PathString]]:
return {