]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
centos: Remove "-stream" from releases
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 17 Jan 2023 19:41:35 +0000 (20:41 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 18 Jan 2023 09:02:09 +0000 (10:02 +0100)
We don't support non centos stream releases anymore, so let's remove
the "-stream" suffix from centos releases.

NEWS.md
mkosi/__init__.py
mkosi/distributions/alma.py
mkosi/distributions/centos.py
mkosi/distributions/rocky.py

diff --git a/NEWS.md b/NEWS.md
index 26662efc721f5321a81cd3b8b47557c8606d547d..d089e549380099400e4900bb1b13f75aa3cc0b21 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -36,6 +36,8 @@
   repositories. Specifically, it cannot be used on Arch Linux anymore to add new repositories.
 - The `_epel` distributions were removed. Use `--repositories=epel` instead to enable
   the EPEL repository.
+- Removed `-stream` from CentOS release specifiers. Instead of specifying `8-stream`,
+  you know just specify `8`.
 
 ## v14
 
index fb787c96990994e4bc778093b061b9612d345b49..46d8f7e2d71ff1448b47778e7874aa0aa54de188 100644 (file)
@@ -495,11 +495,6 @@ def remove_files(state: MkosiState) -> None:
         remove_glob(*paths)
 
 
-def parse_epel_release(release: str) -> int:
-    fields = release.split(".")
-    return int(fields[0].removesuffix("-stream"))
-
-
 def install_distribution(state: MkosiState, cached: bool) -> None:
     if cached:
         return
@@ -2785,7 +2780,7 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
         if args.distribution == Distribution.fedora:
             args.release = "36"
         elif args.distribution == Distribution.centos:
-            args.release = "9-stream"
+            args.release = "9"
         elif args.distribution == Distribution.rocky:
             args.release = "9"
         elif args.distribution == Distribution.alma:
index 9e08f6c8741173cd4bb0aa51a48ad2ded303e9a2..9486f9cbeda6d1eae00fff29afd171299519f811 100644 (file)
@@ -7,14 +7,14 @@ from mkosi.distributions.centos import CentosInstaller
 
 class AlmaInstaller(CentosInstaller):
     @staticmethod
-    def _gpg_locations(epel_release: int) -> tuple[Path, str]:
+    def _gpg_locations(release: int) -> tuple[Path, str]:
         return (
             Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-$releasever"),
             "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever",
         )
 
     @staticmethod
-    def _extras_gpg_locations(epel_release: int) -> tuple[Path, str]:
+    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
         return (
             Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-$releasever"),
             "https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-$releasever",
index 4a67577ae6a9401937bba4f31a1219ddc092e9a4..71e11d3d2c1159041f088345f17a0c1ff44213cf 100644 (file)
@@ -43,19 +43,19 @@ class CentosInstaller(DistributionInstaller):
     @classmethod
     @complete_step("Installing CentOS…")
     def install(cls, state: "MkosiState") -> None:
-        epel_release = cls._parse_epel_release(state.config.release)
+        release = int(state.config.release)
 
-        if epel_release <= 7:
+        if release <= 7:
             die("CentOS 7 or earlier variants are not supported")
-        elif epel_release <= 8 or not "-stream" in state.config.release:
-            repos = cls._variant_repos(state.config, epel_release)
+        elif release == 8 or state.config.distribution != Distribution.centos:
+            repos = cls._variant_repos(state.config, release)
         else:
-            repos = cls._stream_repos(state.config, epel_release)
+            repos = cls._stream_repos(state.config, release)
 
         setup_dnf(state, repos)
 
-        if "-stream" in state.config.release:
-            state.workspace.joinpath("vars/stream").write_text(state.config.release)
+        if state.config.distribution == Distribution.centos:
+            state.workspace.joinpath("vars/stream").write_text(f"{state.config.release}-stream")
 
         packages = {*state.config.packages}
         add_packages(state.config, packages, "systemd", "dnf")
@@ -70,7 +70,7 @@ class CentosInstaller(DistributionInstaller):
             add_packages(state.config, packages, "epel-release")
             if state.config.netdev:
                 add_packages(state.config, packages, "systemd-networkd", conditional="systemd")
-            if state.config.distribution != Distribution.centos and epel_release >= 9:
+            if state.config.distribution != Distribution.centos and release >= 9:
                 add_packages(state.config, packages, "systemd-boot", conditional="systemd")
 
         install_packages_dnf(state, packages)
@@ -84,7 +84,7 @@ class CentosInstaller(DistributionInstaller):
         # backend instead. Because newer RPM releases have dropped support for the
         # bdb backend completely, we check if rpm is installed and use
         # run_workspace_command() to rebuild the rpm db.
-        if epel_release <= 8 and state.root.joinpath("usr/bin/rpm").exists():
+        if release <= 8 and state.root.joinpath("usr/bin/rpm").exists():
             cmdline = ["rpm", "--rebuilddb", "--define", "_db_backend bdb"]
             run_workspace_command(state, cmdline)
 
@@ -93,12 +93,7 @@ class CentosInstaller(DistributionInstaller):
         invoke_dnf(state, 'remove', remove)
 
     @staticmethod
-    def _parse_epel_release(release: str) -> int:
-        fields = release.split(".")
-        return int(fields[0].removesuffix("-stream"))
-
-    @staticmethod
-    def _gpg_locations(epel_release: int) -> tuple[Path, str]:
+    def _gpg_locations(release: int) -> tuple[Path, str]:
         return (
             Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial"),
             "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official"
@@ -112,7 +107,7 @@ class CentosInstaller(DistributionInstaller):
         )
 
     @staticmethod
-    def _extras_gpg_locations(epel_release: int) -> tuple[Path, str]:
+    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
         return (
             Path("/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512"),
             "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-Extras"
@@ -127,11 +122,11 @@ class CentosInstaller(DistributionInstaller):
         return f"http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo={repo}"
 
     @classmethod
-    def _variant_repos(cls, config: MkosiConfig, epel_release: int) -> list[Repo]:
+    def _variant_repos(cls, config: MkosiConfig, release: int) -> list[Repo]:
         # Repos for CentOS Linux 8, CentOS Stream 8 and CentOS variants
 
         directory = cls._mirror_directory()
-        gpgpath, gpgurl = cls._gpg_locations(epel_release)
+        gpgpath, gpgurl = cls._gpg_locations(release)
         epel_gpgpath, epel_gpgurl = cls._epel_gpg_locations()
 
         if config.local_mirror:
@@ -141,7 +136,7 @@ class CentosInstaller(DistributionInstaller):
             appstream_url = f"baseurl={config.mirror}/{directory}/$stream/AppStream/$basearch/os"
             baseos_url = f"baseurl={config.mirror}/{directory}/$stream/BaseOS/$basearch/os"
             extras_url = f"baseurl={config.mirror}/{directory}/$stream/extras/$basearch/os"
-            if epel_release >= 9:
+            if release >= 9:
                 crb_url = f"baseurl={config.mirror}/{directory}/$stream/CRB/$basearch/os"
                 powertools_url = None
             else:
@@ -152,7 +147,7 @@ class CentosInstaller(DistributionInstaller):
             appstream_url = f"mirrorlist={cls._mirror_repo_url('AppStream')}"
             baseos_url = f"mirrorlist={cls._mirror_repo_url('BaseOS')}"
             extras_url = f"mirrorlist={cls._mirror_repo_url('extras')}"
-            if epel_release >= 9:
+            if release >= 9:
                 crb_url = f"mirrorlist={cls._mirror_repo_url('CRB')}"
                 powertools_url = None
             else:
@@ -175,12 +170,12 @@ class CentosInstaller(DistributionInstaller):
         return repos
 
     @classmethod
-    def _stream_repos(cls, config: MkosiConfig, epel_release: int) -> list[Repo]:
+    def _stream_repos(cls, config: MkosiConfig, release: int) -> list[Repo]:
         # Repos for CentOS Stream 9 and later
 
-        gpgpath, gpgurl = cls._gpg_locations(epel_release)
+        gpgpath, gpgurl = cls._gpg_locations(release)
         epel_gpgpath, epel_gpgurl = cls._epel_gpg_locations()
-        extras_gpgpath, extras_gpgurl = cls._extras_gpg_locations(epel_release)
+        extras_gpgpath, extras_gpgurl = cls._extras_gpg_locations(release)
 
         if config.local_mirror:
             appstream_url = f"baseurl={config.local_mirror}"
index d4181303867e510a27602ff160993b5746406e00..c0242a80189914cb7e293240bb94652fdfe09d69 100644 (file)
@@ -7,16 +7,16 @@ from mkosi.distributions.centos import CentosInstaller
 
 class RockyInstaller(CentosInstaller):
     @staticmethod
-    def _gpg_locations(epel_release: int) -> tuple[Path, str]:
-        keyname = "Rocky-$releasever" if epel_release >= 9 else "rockyofficial"
+    def _gpg_locations(release: int) -> tuple[Path, str]:
+        keyname = "Rocky-$releasever" if release >= 9 else "rockyofficial"
         return (
              Path(f"/etc/pki/rpm-gpg/RPM-GPG-KEY-{keyname}"),
              f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"
         )
 
     @staticmethod
-    def _extras_gpg_locations(epel_release: int) -> tuple[Path, str]:
-        keyname = "Rocky-$releasever" if epel_release >= 9 else "rockyofficial"
+    def _extras_gpg_locations(release: int) -> tuple[Path, str]:
+        keyname = "Rocky-$releasever" if release >= 9 else "rockyofficial"
         return (
              Path(f"/etc/pki/rpm-gpg/RPM-GPG-KEY-{keyname}"),
              f"https://download.rockylinux.org/pub/rocky/RPM-GPG-KEY-{keyname}"