from pathlib import Path
from mkosi.architecture import Architecture
-from mkosi.config import MkosiConfig
from mkosi.distributions import Distribution, DistributionInstaller, PackageType
from mkosi.installer.dnf import Repo, invoke_dnf, setup_dnf
from mkosi.log import complete_step, die
newdb.symlink_to(os.path.relpath(olddb, start=newdb.parent))
-def join_mirror(config: MkosiConfig, link: str) -> str:
- assert config.mirror is not None
- return urllib.parse.urljoin(config.mirror, link)
+def join_mirror(mirror: str, link: str) -> str:
+ return urllib.parse.urljoin(mirror, link)
class Installer(DistributionInstaller):
if release <= 7:
die(f"{cls.pretty_name()} 7 or earlier variants are not supported")
- setup_dnf(state, cls.repositories(state.config, release))
+ setup_dnf(state, cls.repositories(state, release))
(state.pkgmngr / "etc/dnf/vars/stream").write_text(f"{state.config.release}-stream\n")
@classmethod
return a
@staticmethod
- def gpgurls(config: MkosiConfig) -> tuple[str, ...]:
+ def gpgurls(state: MkosiState) -> tuple[str, ...]:
gpgurls = []
for key in ("CentOS-Official", "CentOS-SIG-Extras"):
return tuple(gpgurls)
@classmethod
- def repository_variants(cls, config: MkosiConfig, repo: str) -> Iterable[Repo]:
- if config.local_mirror:
- yield Repo(repo, f"baseurl={config.local_mirror}", cls.gpgurls(config))
+ def repository_variants(cls, state: MkosiState, repo: str) -> Iterable[Repo]:
+ if state.config.local_mirror:
+ yield Repo(repo, f"baseurl={state.config.local_mirror}", cls.gpgurls(state))
- elif config.mirror:
- if int(config.release) <= 8:
+ elif state.config.mirror:
+ if int(state.config.release) <= 8:
yield Repo(
repo.lower(),
- f"baseurl={join_mirror(config, f'centos/$stream/{repo}/$basearch/os')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{repo}/$basearch/os')}",
+ cls.gpgurls(state),
)
yield Repo(
f"{repo.lower()}-debuginfo",
- f"baseurl={join_mirror(config, 'centos-debuginfo/$stream/$basearch')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, 'centos-debuginfo/$stream/$basearch')}",
+ cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"{repo.lower()}-source",
- f"baseurl={join_mirror(config, f'centos/$stream/{repo}/Source')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{repo}/Source')}",
+ cls.gpgurls(state),
enabled=False,
)
else:
if repo == "extras":
yield Repo(
repo.lower(),
- f"baseurl={join_mirror(config, f'SIGs/$stream/{repo}/$basearch/extras-common')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'SIGs/$stream/{repo}/$basearch/extras-common')}",
+ cls.gpgurls(state),
)
yield Repo(
f"{repo.lower()}-source",
- f"baseurl={join_mirror(config, f'SIGs/$stream/{repo}/source/extras-common')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'SIGs/$stream/{repo}/source/extras-common')}",
+ cls.gpgurls(state),
enabled=False,
)
else:
yield Repo(
repo.lower(),
- f"baseurl={join_mirror(config, f'$stream/{repo}/$basearch/os')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'$stream/{repo}/$basearch/os')}",
+ cls.gpgurls(state),
)
yield Repo(
f"{repo.lower()}-debuginfo",
- f"baseurl={join_mirror(config, f'$stream/{repo}/$basearch/debug/tree')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'$stream/{repo}/$basearch/debug/tree')}",
+ cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"{repo.lower()}-source",
- f"baseurl={join_mirror(config, f'$stream/{repo}/source/tree')}",
- cls.gpgurls(config),
+ f"baseurl={join_mirror(state.config.mirror, f'$stream/{repo}/source/tree')}",
+ cls.gpgurls(state),
enabled=False,
)
else:
- if int(config.release) <= 8:
+ if int(state.config.release) <= 8:
yield Repo(
repo.lower(),
f"mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo={repo}",
- cls.gpgurls(config),
+ cls.gpgurls(state),
)
# These can't be retrieved from the mirrorlist.
yield Repo(
f"{repo.lower()}-debuginfo",
"baseurl=http://debuginfo.centos.org/$stream/$basearch",
- cls.gpgurls(config),
+ cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"{repo.lower()}-source",
f"baseurl=https://vault.centos.org/centos/$stream/{repo}/Source",
- cls.gpgurls(config),
+ cls.gpgurls(state),
enabled=False,
)
else:
yield Repo(
repo.lower(),
f"{url}?arch=$basearch&repo=centos-extras-sig-extras-common-$stream",
- cls.gpgurls(config),
+ cls.gpgurls(state),
)
yield Repo(
f"{repo.lower()}-source",
f"{url}?arch=source&repo=centos-extras-sig-extras-common-source-$stream",
- cls.gpgurls(config),
+ cls.gpgurls(state),
enabled=False,
)
else:
yield Repo(
repo.lower(),
f"{url}?arch=$basearch&repo=centos-{repo.lower()}-$stream",
- cls.gpgurls(config),
+ cls.gpgurls(state),
)
yield Repo(
f"{repo.lower()}-debuginfo",
f"{url}?arch=$basearch&repo=centos-{repo.lower()}-debug-$stream",
- cls.gpgurls(config),
+ cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"{repo.lower()}-source",
f"{url}?arch=source&repo=centos-{repo.lower()}-source-$stream",
- cls.gpgurls(config),
+ cls.gpgurls(state),
enabled=False,
)
@classmethod
- def repositories(cls, config: MkosiConfig, release: int) -> Iterable[Repo]:
- if config.local_mirror:
- yield from cls.repository_variants(config, "AppStream")
+ def repositories(cls, state: MkosiState, release: int) -> Iterable[Repo]:
+ if state.config.local_mirror:
+ yield from cls.repository_variants(state, "AppStream")
else:
- yield from cls.repository_variants(config, "BaseOS")
- yield from cls.repository_variants(config, "AppStream")
- yield from cls.repository_variants(config, "extras")
+ yield from cls.repository_variants(state, "BaseOS")
+ yield from cls.repository_variants(state, "AppStream")
+ yield from cls.repository_variants(state, "extras")
if release >= 9:
- yield from cls.repository_variants(config, "CRB")
+ yield from cls.repository_variants(state, "CRB")
else:
- yield from cls.repository_variants(config, "PowerTools")
+ yield from cls.repository_variants(state, "PowerTools")
- yield from cls.epel_repositories(config)
- yield from cls.sig_repositories(config)
+ yield from cls.epel_repositories(state)
+ yield from cls.sig_repositories(state)
@classmethod
- def epel_repositories(cls, config: MkosiConfig) -> Iterable[Repo]:
- gpgpath = Path(f"/usr/share/distribution-gpg-keys/centos/RPM-GPG-KEY-EPEL-{config.release}")
+ def epel_repositories(cls, state: MkosiState) -> Iterable[Repo]:
+ gpgpath = Path(f"/usr/share/distribution-gpg-keys/centos/RPM-GPG-KEY-EPEL-{state.config.release}")
if gpgpath.exists():
gpgurls = (f"file://{gpgpath}",)
else:
- gpgurls = (f"https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{config.release}",)
+ gpgurls = (f"https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{state.config.release}",)
- if config.local_mirror:
+ if state.config.local_mirror:
return
- if config.mirror:
+ if state.config.mirror:
for repo, dir in (
("epel", "epel"),
("epel-next", "epel/next"),
):
yield Repo(
repo,
- f"baseurl={join_mirror(config, f'{dir}/$releasever/Everything/$basearch')}",
+ f"baseurl={join_mirror(state.config.mirror, f'{dir}/$releasever/Everything/$basearch')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{repo}-debuginfo",
- f"baseurl={join_mirror(config, f'{dir}/$releasever/Everything/$basearch/debug')}",
+ f"baseurl={join_mirror(state.config.mirror, f'{dir}/$releasever/Everything/$basearch/debug')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{repo}-source",
- f"baseurl={join_mirror(config, f'{dir}/$releasever/Everything/source/tree')}",
+ f"baseurl={join_mirror(state.config.mirror, f'{dir}/$releasever/Everything/source/tree')}",
gpgurls,
enabled=False,
)
)
@classmethod
- def sig_repositories(cls, config: MkosiConfig) -> Iterable[Repo]:
- if config.local_mirror:
+ def sig_repositories(cls, state: MkosiState) -> Iterable[Repo]:
+ if state.config.local_mirror:
return
sigs = (
gpgurls = tuple(gpgurls)
for c in components:
- if config.mirror:
- if int(config.release) <= 8:
+ if state.config.mirror:
+ if int(state.config.release) <= 8:
yield Repo(
f"{sig}-{c}",
- f"baseurl={join_mirror(config, f'centos/$stream/{sig}/$basearch/{c}')}",
+ f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{sig}/$basearch/{c}')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{sig}-{c}-debuginfo",
- f"baseurl={join_mirror(config, f'$stream/{sig}/$basearch')}",
+ f"baseurl={join_mirror(state.config.mirror, f'$stream/{sig}/$basearch')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{sig}-{c}-source",
- f"baseurl={join_mirror(config, f'centos/$stream/{sig}/Source')}",
+ f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{sig}/Source')}",
gpgurls,
enabled=False,
)
else:
yield Repo(
f"{sig}-{c}",
- f"baseurl={join_mirror(config, f'SIGs/$stream/{sig}/$basearch/{c}')}",
+ f"baseurl={join_mirror(state.config.mirror, f'SIGs/$stream/{sig}/$basearch/{c}')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{sig}-{c}-debuginfo",
- f"baseurl={join_mirror(config, f'SIGs/$stream/{sig}/$basearch/{c}/debug')}",
+ f"baseurl={join_mirror(state.config.mirror, f'SIGs/$stream/{sig}/$basearch/{c}/debug')}",
gpgurls,
enabled=False,
)
yield Repo(
f"{sig}-{c}-source",
- f"baseurl={join_mirror(config, f'SIGs/$stream/{sig}/source/{c}')}",
+ f"baseurl={join_mirror(state.config.mirror, f'SIGs/$stream/{sig}/source/{c}')}",
gpgurls,
enabled=False,
)
else:
- if int(config.release) <= 8:
+ if int(state.config.release) <= 8:
yield Repo(
f"{sig}-{c}",
f"mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo={sig}-{c}",
enabled=False,
)
- if int(config.release) >= 9:
+ if int(state.config.release) >= 9:
yield Repo(
f"{sig}-{c}-testing-debuginfo",
f"baseurl=https://buildlogs.centos.org/centos/$stream/{sig}/$basearch/{c}",
from collections.abc import Iterable
-from mkosi.config import MkosiConfig
from mkosi.distributions import centos
from mkosi.installer.dnf import Repo
+from mkosi.state import MkosiState
class Installer(centos.Installer):
return "RHEL UBI"
@staticmethod
- def gpgurls(config: MkosiConfig) -> tuple[str, ...]:
+ def gpgurls(state: MkosiState) -> tuple[str, ...]:
return ("https://access.redhat.com/security/data/fd431d51.txt",)
@classmethod
- def repository_variants(cls, config: MkosiConfig, repo: str) -> Iterable[Repo]:
- if config.local_mirror:
- yield Repo(repo, f"baseurl={config.local_mirror}", cls.gpgurls(config))
+ def repository_variants(cls, state: MkosiState, repo: str) -> Iterable[Repo]:
+ if state.config.local_mirror:
+ yield Repo(repo, f"baseurl={state.config.local_mirror}", cls.gpgurls(state))
else:
- v = config.release
+ assert state.config.mirror
+
+ v = state.config.release
yield Repo(
f"ubi-{v}-{repo}-rpms",
- f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/os')}",
- cls.gpgurls(config),
+ f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
+ cls.gpgurls(state),
)
yield Repo(
f"ubi-{v}-{repo}-debug-rpms",
- f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/debug')}",
- cls.gpgurls(config),
+ f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/debug')}",
+ cls.gpgurls(state),
enabled=False,
)
yield Repo(
f"ubi-{v}-{repo}-source",
- f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/source')}",
- cls.gpgurls(config),
+ f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/source')}",
+ cls.gpgurls(state),
enabled=False,
)
if repo == "codeready-builder":
yield Repo(
f"ubi-{v}-{repo}",
- f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/os')}",
- cls.gpgurls(config),
+ f"baseurl={centos.join_mirror(state.config.mirror, f'ubi{v}/{v}/$basearch/{repo}/os')}",
+ cls.gpgurls(state),
enabled=False,
)
@classmethod
- def repositories(cls, config: MkosiConfig, release: int) -> Iterable[Repo]:
- yield from cls.repository_variants(config, "baseos")
- yield from cls.repository_variants(config, "appstream")
- yield from cls.repository_variants(config, "codeready-builder")
+ def repositories(cls, state: MkosiState, release: int) -> Iterable[Repo]:
+ yield from cls.repository_variants(state, "baseos")
+ yield from cls.repository_variants(state, "appstream")
+ yield from cls.repository_variants(state, "codeready-builder")