]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use GenericVersion() for CentOS version comparisons 1968/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 10 Oct 2023 12:38:10 +0000 (14:38 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 11 Oct 2023 09:11:56 +0000 (11:11 +0200)
This allows using RHEL point releases with --release (e.g. 9.2)

mkosi/distributions/centos.py
mkosi/distributions/rhel.py
mkosi/distributions/rhel_ubi.py

index 899fee249a202fb4b2832c0f179fd5ab83a2bf85..9f91e546c2336901427e5f8270123222d1d923bc 100644 (file)
@@ -12,6 +12,7 @@ from mkosi.installer.dnf import Repo, invoke_dnf, setup_dnf
 from mkosi.log import complete_step, die
 from mkosi.state import MkosiState
 from mkosi.tree import rmtree
+from mkosi.versioncomp import GenericVersion
 
 
 def move_rpm_db(root: Path) -> None:
@@ -95,12 +96,10 @@ class Installer(DistributionInstaller):
 
     @classmethod
     def setup(cls, state: MkosiState) -> None:
-        release = int(state.config.release)
-
-        if release <= 7:
+        if GenericVersion(state.config.release) <= 7:
             die(f"{cls.pretty_name()} 7 or earlier variants are not supported")
 
-        setup_dnf(state, cls.repositories(state, release))
+        setup_dnf(state, cls.repositories(state))
         (state.pkgmngr / "etc/dnf/vars/stream").write_text(f"{state.config.release}-stream\n")
 
     @classmethod
@@ -153,7 +152,7 @@ class Installer(DistributionInstaller):
             yield Repo(repo, f"baseurl={state.config.local_mirror}", cls.gpgurls(state))
 
         elif state.config.mirror:
-            if int(state.config.release) <= 8:
+            if GenericVersion(state.config.release) <= 8:
                 yield Repo(
                     repo.lower(),
                     f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{repo}/$basearch/os')}",
@@ -205,7 +204,7 @@ class Installer(DistributionInstaller):
                     )
 
         else:
-            if int(state.config.release) <= 8:
+            if GenericVersion(state.config.release) <= 8:
                 yield Repo(
                     repo.lower(),
                     f"mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo={repo}",
@@ -259,7 +258,7 @@ class Installer(DistributionInstaller):
                     )
 
     @classmethod
-    def repositories(cls, state: MkosiState, release: int) -> Iterable[Repo]:
+    def repositories(cls, state: MkosiState) -> Iterable[Repo]:
         if state.config.local_mirror:
             yield from cls.repository_variants(state, "AppStream")
         else:
@@ -267,7 +266,7 @@ class Installer(DistributionInstaller):
             yield from cls.repository_variants(state, "AppStream")
             yield from cls.repository_variants(state, "extras")
 
-        if release >= 9:
+        if GenericVersion(state.config.release) >= 9:
             yield from cls.repository_variants(state, "CRB")
         else:
             yield from cls.repository_variants(state, "PowerTools")
@@ -361,7 +360,7 @@ class Installer(DistributionInstaller):
 
             for c in components:
                 if state.config.mirror:
-                    if int(state.config.release) <= 8:
+                    if GenericVersion(state.config.release) <= 8:
                         yield Repo(
                             f"{sig}-{c}",
                             f"baseurl={join_mirror(state.config.mirror, f'centos/$stream/{sig}/$basearch/{c}')}",
@@ -400,7 +399,7 @@ class Installer(DistributionInstaller):
                             enabled=False,
                         )
                 else:
-                    if int(state.config.release) <= 8:
+                    if GenericVersion(state.config.release) <= 8:
                         yield Repo(
                             f"{sig}-{c}",
                             f"mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo={sig}-{c}",
@@ -448,7 +447,7 @@ class Installer(DistributionInstaller):
                         enabled=False,
                     )
 
-                    if int(state.config.release) >= 9:
+                    if GenericVersion(state.config.release) >= 9:
                         yield Repo(
                             f"{sig}-{c}-testing-debuginfo",
                             f"baseurl=https://buildlogs.centos.org/centos/$stream/{sig}/$basearch/{c}",
index cfcd568cbee0024698056b24590ec8eba7c20ab9..a128be12ad9c7ec8a6e8f3e29f151533a1742be6 100644 (file)
@@ -100,7 +100,7 @@ class Installer(centos.Installer):
             )
 
     @classmethod
-    def repositories(cls, state: MkosiState, release: int) -> Iterable[Repo]:
+    def repositories(cls, state: MkosiState) -> Iterable[Repo]:
         yield from cls.repository_variants(state, "baseos")
         yield from cls.repository_variants(state, "appstream")
         yield from cls.repository_variants(state, "codeready-builder")
index ce81e401e5450e39b12509ec70c64cc3290b9e5d..2f1d070a942a7a7e41b258555a28381a2f8ff185 100644 (file)
@@ -43,7 +43,7 @@ class Installer(centos.Installer):
             )
 
     @classmethod
-    def repositories(cls, state: MkosiState, release: int) -> Iterable[Repo]:
+    def repositories(cls, state: MkosiState) -> Iterable[Repo]:
         yield from cls.repository_variants(state, "baseos")
         yield from cls.repository_variants(state, "appstream")
         yield from cls.repository_variants(state, "codeready-builder")