From: Paymon MARANDI Date: Sat, 13 May 2023 15:05:33 +0000 (-0400) Subject: gentoo: leverage cache for artifacts X-Git-Tag: v15~103^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d83061af712b2019d0c2524dc23d6a04bcac270c;p=thirdparty%2Fmkosi.git gentoo: leverage cache for artifacts this will help to speedup incremental builds as well as initrd same for syncing ebuild repos distfiles (source file for pkgs) also resulting image will not include binpkgs and distfiles which would reduce the size by great deal; this is required for initrd support. Signed-off-by: Paymon MARANDI --- diff --git a/mkosi/distributions/gentoo.py b/mkosi/distributions/gentoo.py index b455119ce..75f0b8a30 100644 --- a/mkosi/distributions/gentoo.py +++ b/mkosi/distributions/gentoo.py @@ -38,7 +38,13 @@ def invoke_emerge( else: emerge_default_opts += ["--quiet-build", "--quiet"] cmd = ["emerge", *pkgs, *emerge_default_opts, *opts, *actions] - run_workspace_command(state.root, cmd, network=True, env=state.environment) + bwrap_params = [ + "--bind", state.cache / "binpkgs", "/var/cache/binpkgs", + "--bind", state.cache / "distfiles", "/var/cache/distfiles", + "--bind", state.cache / "repos", "/var/db/repos", + ] + run_workspace_command(state.root, cmd, bwrap_params=bwrap_params, + network=True, env=state.environment) class Gentoo: @@ -179,6 +185,9 @@ class Gentoo: "USE": " ".join(self.portage_use_flags), } + for d in ("binpkgs", "distfiles", "repos"): + self.state.cache.joinpath(d).mkdir(exist_ok=True) + self.fetch_fix_stage3() self.set_useflags() self.mkosi_conf() @@ -296,7 +305,9 @@ class Gentoo: ) def get_snapshot_of_portage_tree(self) -> None: - run_workspace_command(self.state.root, ["/usr/bin/emerge-webrsync"], network=True, + bwrap_params = ["--bind", self.state.cache / "repos", "/var/db/repos"] + run_workspace_command(self.state.root, ["/usr/bin/emerge-webrsync"], + bwrap_params=bwrap_params, network=True, env=self.state.environment) def update_stage3(self) -> None: