]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Stop mounting package caches into images when running scripts
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 12 Mar 2023 15:54:00 +0000 (16:54 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 13 Mar 2023 12:09:29 +0000 (13:09 +0100)
The package manager in the container might be a very different
version than the one running on the host which could cause all
sorts of caching issues. Since we don't need the caches in the
image anymore as we run the package managers outside of the image,
let's stop mounting the cache directory into the image when running
scripts as well.

mkosi/__init__.py
mkosi/distributions/__init__.py
mkosi/distributions/arch.py
mkosi/distributions/centos.py
mkosi/distributions/debian.py
mkosi/distributions/fedora.py
mkosi/distributions/gentoo.py
mkosi/distributions/mageia.py
mkosi/distributions/opensuse.py

index f3c874cedcf7b3c7b71a00daa501c534a5cc2d41..1140734376a5bf75a3063a34e8174b5310713135 100644 (file)
@@ -500,10 +500,6 @@ def configure_serial_terminal(state: MkosiState) -> None:
                           """)
 
 
-def cache_params(state: MkosiState, root: Path) -> list[PathString]:
-    return flatten(("--bind", state.cache, root / p) for p in state.installer.cache_path())
-
-
 def mount_build_overlay(state: MkosiState) -> ContextManager[Path]:
     return mount_overlay(state.root, state.build_overlay, state.workdir, state.root)
 
@@ -519,7 +515,6 @@ def run_prepare_script(state: MkosiState, cached: bool, build: bool) -> None:
     bwrap: list[PathString] = [
         "--bind", state.config.build_sources, "/root/src",
         "--bind", state.config.prepare_script, "/root/prepare",
-        *cache_params(state, Path("/")),
         "--chdir", "/root/src",
     ]
 
@@ -561,7 +556,6 @@ def run_postinst_script(state: MkosiState) -> None:
     with complete_step("Running postinstall script…"):
         bwrap: list[PathString] = [
             "--bind", state.config.postinst_script, "/root/postinst",
-            *cache_params(state, Path("/")),
         ]
 
         run_workspace_command(state, ["/root/postinst", "final"], bwrap_params=bwrap,
index ded241a5951d97fb71f0084403325a2603c5e60f..f32fc486cf531f3ec3ca740eb744a8a2d221b8ee 100644 (file)
@@ -23,10 +23,6 @@ class DistributionInstaller:
     def initrd_path(kver: str) -> Path:
         return Path("boot") / f"initramfs-{kver}.img"
 
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        raise NotImplementedError
-
     @classmethod
     def install_packages(cls, state: "MkosiState", packages: Sequence[str]) -> None:
         raise NotImplementedError
index 867a73e8723b778e2aaa927015bcccb69d9e58f0..faca026cb7d6d6869c9720b39e90baf8ab655ca1 100644 (file)
@@ -11,10 +11,6 @@ from mkosi.types import PathString
 
 
 class ArchInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/pacman/pkg"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "ext4"
index 7a9cb6ddacad9fbfa08f9594b19d541d3162b0df..f33e2e967bcf26b8196be547cde28aa9c852bc13 100644 (file)
@@ -27,9 +27,6 @@ def move_rpm_db(root: Path) -> None:
 
 
 class CentosInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/yum", "var/cache/dnf"]
 
     @classmethod
     def filesystem(cls) -> str:
index 800b40694f4ac77d57e04335c82559b81a646774..a9eafd3297bbb748d1d4ec4c2881ba491ea87b7d 100644 (file)
@@ -33,10 +33,6 @@ class DebianInstaller(DistributionInstaller):
             state.root.joinpath("etc/resolv.conf").unlink(missing_ok=True)
             state.root.joinpath("etc/resolv.conf").symlink_to("../run/systemd/resolve/resolv.conf")
 
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/apt/archives"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "ext4"
index f4fb8127b429e8a6ad2497dc526f3e9594a0aaaf..bd0452b3bbcb7b63560a5621ddc50ab6d362510e 100644 (file)
@@ -29,10 +29,6 @@ FEDORA_KEYS_MAP = {
 
 
 class FedoraInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/dnf"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "btrfs"
index 0ef891eaedb78894e0e757c2efe050b29fb78ccc..0165ff971d797f4c74e11603a7d66e0f5fef0ec7 100644 (file)
@@ -374,10 +374,6 @@ class Gentoo:
 
 
 class GentooInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/binpkgs", "var/cache/distfiles"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "ext4"
index ff02d1926d0510e279e276cf2231836c02192632..ae4f8413cc7e322df0b65acc2e157aff48a223fd 100644 (file)
@@ -10,10 +10,6 @@ from mkosi.log import complete_step
 
 
 class MageiaInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/dnf"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "ext4"
index 54f1cda6302d10b0d57ad283c8b393bc2a11ae44..9beb1519753ea1706421535fca9ac073f618e642 100644 (file)
@@ -13,10 +13,6 @@ from mkosi.types import PathString
 
 
 class OpensuseInstaller(DistributionInstaller):
-    @classmethod
-    def cache_path(cls) -> list[str]:
-        return ["var/cache/zypp/packages"]
-
     @classmethod
     def filesystem(cls) -> str:
         return "btrfs"