return "https://odcs.fedoraproject.org/composes/production/latest-Fedora-ELN/compose"
elif namespace.distribution == Distribution.gentoo:
return "https://distfiles.gentoo.org"
+ elif namespace.distribution == Distribution.rhel_ubi:
+ return "https://cdn-ubi.redhat.com/content/public/ubi/dist/"
return None
opensuse = enum.auto()
mageia = enum.auto()
centos = enum.auto()
+ rhel_ubi = enum.auto()
openmandriva = enum.auto()
rocky = enum.auto()
alma = enum.auto()
Distribution.fedora,
Distribution.mageia,
Distribution.centos,
+ Distribution.rhel_ubi,
Distribution.openmandriva,
Distribution.rocky,
Distribution.alma,
release = int(state.config.release)
if release <= 7:
- die("CentOS 7 or earlier variants are not supported")
+ die(f"{cls.pretty_name()} 7 or earlier variants are not supported")
setup_dnf(state, cls.repositories(state.config, release))
(state.pkgmngr / "etc/dnf/vars/stream").write_text(f"{state.config.release}-stream\n")
# Make sure glibc-minimal-langpack is installed instead of glibc-all-langpacks.
cls.install_packages(state, ["filesystem", "glibc-minimal-langpack"], apivfs=False)
- # On Fedora, the default rpmdb has moved to /usr/lib/sysimage/rpm so if that's the case we need to
- # move it back to /var/lib/rpm on CentOS.
+ # On Fedora, the default rpmdb has moved to /usr/lib/sysimage/rpm so if that's the case we
+ # need to move it back to /var/lib/rpm on CentOS.
move_rpm_db(state.root)
@classmethod
def remove_packages(cls, state: MkosiState, packages: Sequence[str]) -> None:
invoke_dnf(state, "remove", packages)
- @staticmethod
- def architecture(arch: Architecture) -> str:
+ @classmethod
+ def architecture(cls, arch: Architecture) -> str:
a = {
Architecture.x86_64 : "x86_64",
Architecture.ppc64_le : "ppc64le",
}.get(arch)
if not a:
- die(f"Architecture {a} is not supported by CentOS")
+ die(f"Architecture {a} is not supported by {cls.pretty_name()}")
return a
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1+
+
+from typing import Iterable
+
+from mkosi.config import MkosiConfig
+from mkosi.distributions import centos
+from mkosi.installer.dnf import Repo
+
+
+class Installer(centos.Installer):
+ @classmethod
+ def pretty_name(cls) -> str:
+ return "RHEL UBI"
+
+ @staticmethod
+ def gpgurls() -> 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())
+ else:
+ v = config.release
+ yield Repo(
+ f"ubi-{v}-{repo}-rpms",
+ f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/os')}",
+ cls.gpgurls(),
+ )
+ yield Repo(
+ f"ubi-{v}-{repo}-debug-rpms",
+ f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/debug')}",
+ cls.gpgurls(),
+ enabled=False,
+ )
+ yield Repo(
+ f"ubi-{v}-{repo}-source",
+ f"baseurl={centos.join_mirror(config, f'ubi{v}/{v}/$basearch/{repo}/source')}",
+ cls.gpgurls(),
+ 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(),
+ 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")
: The distribution to install in the image. Takes one of the following
arguments: `fedora`, `debian`, `ubuntu`, `arch`, `opensuse`, `mageia`,
- `centos`, `openmandriva`, `rocky`, `alma`. If not
+ `centos`, `rhel-ubi`, `openmandriva`, `rocky`, `alma`. If not
specified, defaults to the distribution of the host.
`Release=`, `--release=`, `-r`
* *CentOS*
+* *RHEL UBI*
+
* *OpenMandriva*
* *Rocky Linux*
In theory, any distribution may be used on the host for building images
containing any other distribution, as long as the necessary tools are
-available. Specifically, any distribution that packages `apt` may be
-used to build *Debian* or *Ubuntu* images. Any distribution that
-packages `dnf` may be used to build *CentOS*, *Alma Linux*, *Rocky
-Linux*, *Fedora Linux*, *OpenSUSE*, *Mageia* or *OpenMandriva* images.
-Any distro that packages `pacman` may be used to build *Arch Linux*
-images. Any distribution that packages `zypper` may be used to build
-*openSUSE* images.
+available.
+Specifically,
+any distribution that packages `apt` may be used to build *Debian* or *Ubuntu* images.
+Any distribution that packages `dnf` may be used to build images for any of the rpm-based distributions.
+Any distro that packages `pacman` may be used to build *Arch Linux* images.
+Any distribution that packages `zypper` may be used to build *openSUSE* images.
Currently, *Fedora Linux* packages all relevant tools as of Fedora 28.
def test_os_distribution(tmp_path: Path) -> None:
with chdir(tmp_path):
for dist in Distribution:
- _, [config] = parse_config(["-d", dist.name])
+ _, [config] = parse_config(["-d", dist.value])
assert config.distribution == dist
with pytest.raises(tuple((argparse.ArgumentError, SystemExit))):