# We mount both the YUM and the DNF cache in this case, as YUM might
# just be redirected to DNF even if we invoke the former
cache_paths = ["var/cache/yum", "var/cache/dnf"]
- elif state.config.distribution == Distribution.gentoo:
- cache_paths = ["var/cache/binpkgs"]
else:
cache_paths = []
run_workspace_command(state, cmdline)
-@complete_step("Installing Gentoo…")
-def install_gentoo(state: MkosiState) -> None:
- from .gentoo import Gentoo
-
- # this will fetch/fix stage3 tree and portage confgired for mkosi
- gentoo = Gentoo(state)
-
- if gentoo.pkgs_fs:
- gentoo.invoke_emerge(state, pkgs=gentoo.pkgs_fs)
-
- if not state.do_run_build_script and state.config.bootable:
- # The gentoo stage3 tarball includes packages that may block chosen
- # pkgs_boot. Using Gentoo.EMERGE_UPDATE_OPTS for opts allows the
- # package manager to uninstall blockers.
- gentoo.invoke_emerge(state, pkgs=gentoo.pkgs_boot, opts=Gentoo.EMERGE_UPDATE_OPTS)
-
- if state.config.packages:
- gentoo.invoke_emerge(state, pkgs=state.config.packages)
-
- if state.do_run_build_script:
- gentoo.invoke_emerge(state, pkgs=state.config.build_packages)
-
-
def install_distribution(state: MkosiState, cached: bool) -> None:
if cached:
return
Distribution.fedora: install_fedora,
Distribution.mageia: install_mageia,
Distribution.openmandriva: install_openmandriva,
- Distribution.gentoo: install_gentoo,
}[state.config.distribution]
with mount_cache(state):
if state.installer is not None:
kimg = state.installer.kernel_image(kver.name, state.config.architecture)
- elif state.config.distribution == Distribution.gentoo:
- from .gentoo import ARCHITECTURES
-
- _, kimg_path = ARCHITECTURES[state.config.architecture]
-
- kimg = Path(f"usr/src/linux-{kver.name}") / kimg_path
else:
kimg = Path("lib/modules") / kver.name / "vmlinuz"
MkosiState,
OutputFormat,
PartitionIdentifier,
+ complete_step,
die,
root_home,
run_workspace_command,
safe_tar_extract,
)
+from mkosi.distributions import DistributionInstaller
from mkosi.install import copy_path, open_close
ARCHITECTURES = {
network=True,
nspawn_params=self.DEFAULT_NSPAWN_PARAMS,
)
+
+
+class GentooInstaller(DistributionInstaller):
+ @classmethod
+ def cache_path(cls) -> List[str]:
+ return ["var/cache/binpkgs"]
+
+ @staticmethod
+ def kernel_image(name: str, architecture: str) -> Path:
+ _, kimg_path = ARCHITECTURES[architecture]
+ return Path(f"usr/src/linux-{name}") / kimg_path
+
+ @classmethod
+ @complete_step("Installing Gentoo…")
+ def install(cls, state: "MkosiState") -> None:
+ # this will fetch/fix stage3 tree and portage confgired for mkosi
+ gentoo = Gentoo(state)
+
+ if gentoo.pkgs_fs:
+ gentoo.invoke_emerge(state, pkgs=gentoo.pkgs_fs)
+
+ if not state.do_run_build_script and state.config.bootable:
+ # The gentoo stage3 tarball includes packages that may block chosen
+ # pkgs_boot. Using Gentoo.EMERGE_UPDATE_OPTS for opts allows the
+ # package manager to uninstall blockers.
+ gentoo.invoke_emerge(state, pkgs=gentoo.pkgs_boot, opts=Gentoo.EMERGE_UPDATE_OPTS)
+
+ if state.config.packages:
+ gentoo.invoke_emerge(state, pkgs=state.config.packages)
+
+ if state.do_run_build_script:
+ gentoo.invoke_emerge(state, pkgs=state.config.build_packages)