]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Move default release logic to per distribution installer class
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 2 Sep 2023 12:10:26 +0000 (14:10 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 4 Sep 2023 11:27:36 +0000 (13:27 +0200)
mkosi/config.py
mkosi/distributions/__init__.py
mkosi/distributions/arch.py
mkosi/distributions/centos.py
mkosi/distributions/debian.py
mkosi/distributions/fedora.py
mkosi/distributions/gentoo.py
mkosi/distributions/mageia.py
mkosi/distributions/openmandriva.py
mkosi/distributions/opensuse.py
mkosi/distributions/ubuntu.py

index 2da833d8cf9b7db72977a5efb416096b9e029bf7..486e260aecbb6a02488e35fd73fdccf501f63bb3 100644 (file)
@@ -290,18 +290,7 @@ def config_default_release(namespace: argparse.Namespace) -> str:
     if namespace.distribution == hd and hr is not None:
         return hr
 
-    return {
-        Distribution.fedora: "38",
-        Distribution.centos: "9",
-        Distribution.rocky: "9",
-        Distribution.alma: "9",
-        Distribution.mageia: "cauldron",
-        Distribution.debian: "testing",
-        Distribution.ubuntu: "lunar",
-        Distribution.opensuse: "tumbleweed",
-        Distribution.openmandriva: "cooker",
-        Distribution.gentoo: "17.1",
-    }.get(namespace.distribution, "rolling")
+    return cast(str, namespace.distribution.default_release())
 
 
 def config_default_mirror(namespace: argparse.Namespace) -> Optional[str]:
index 20d4d215b3d6c274aabd019af8ac94988374b145..7e2d837b984e8bcea50df4ae5b6f8ac995047614 100644 (file)
@@ -50,6 +50,10 @@ class DistributionInstaller:
     def package_type(cls) -> PackageType:
         raise NotImplementedError()
 
+    @classmethod
+    def default_release(cls) -> str:
+        raise NotImplementedError()
+
 
 class Distribution(StrEnum):
     fedora       = enum.auto()
@@ -101,6 +105,9 @@ class Distribution(StrEnum):
     def package_type(self) -> PackageType:
         return self.installer().package_type()
 
+    def default_release(self) -> str:
+        return self.installer().default_release()
+
     def installer(self) -> Type[DistributionInstaller]:
         try:
             mod = importlib.import_module(f"mkosi.distributions.{self}")
index c182ddfc0fb2e1f7263b3d938ba68b3b2e97eb8f..9585a2336325492b87796227669225c74422d78a 100644 (file)
@@ -18,6 +18,10 @@ class ArchInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.pkg
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "rolling"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         setup_pacman(state)
index b547e3e534b8d19fcede20b0d238da6d8fbe0e80..5fe9447430ce67e508d7da5211cf734235e6838e 100644 (file)
@@ -38,6 +38,10 @@ class CentosInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.rpm
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "9"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         release = int(state.config.release)
index b72aaf74bd3efcdf2ac2433ca0d1aa0f5f6d8bfb..803d0f253e24e56256f3e06b8138215752ab7235 100644 (file)
@@ -24,6 +24,10 @@ class DebianInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.deb
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "testing"
+
     @staticmethod
     def repositories(state: MkosiState, local: bool = True) -> list[str]:
         assert state.config.mirror
index 45d62e88f48da01bb33d8060cb17bf67bd4dc78a..76e15b3fbdfd2bccacb672e194835142e3073019 100644 (file)
@@ -19,6 +19,10 @@ class FedoraInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.rpm
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "38"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         # See: https://fedoraproject.org/security/
index fde88233f465db18fe5bb8f36dc15a103beff352..f354a9dca7e7d414948e6c0ee56f270c79d341d1 100644 (file)
@@ -66,6 +66,10 @@ class GentooInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.ebuild
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "17.1"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         pass
index b01484f0057730796a3c8920d41b1b69bbd120ed..f8db15c5f73963193f4dc1f27fe41cb6014de22c 100644 (file)
@@ -18,6 +18,10 @@ class MageiaInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.rpm
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "cauldron"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         release = state.config.release.strip("'")
index 6cc66e24bdd6e85cbb1fc1110933dc3624bcb304..a036948b8d28ba1d1485118a99a425278ac0ab17 100644 (file)
@@ -18,6 +18,10 @@ class OpenmandrivaInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.rpm
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "cooker"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         release = state.config.release.strip("'")
index 3a7e11b59421c001a2ee8a109d20d8ba9166c0ec..6d267023fcc61a772c86242d6df31509e68142df 100644 (file)
@@ -22,6 +22,10 @@ class OpensuseInstaller(DistributionInstaller):
     def package_type(cls) -> PackageType:
         return PackageType.rpm
 
+    @classmethod
+    def default_release(cls) -> str:
+        return "tumbleweed"
+
     @classmethod
     def setup(cls, state: MkosiState) -> None:
         release = state.config.release
index 495a53cd7f962c7ea7f0f1a8d2e7028bbb4910ec..8d3c724f11e574a0795ba84d1b9be43d76f3a051 100644 (file)
@@ -6,6 +6,10 @@ from mkosi.state import MkosiState
 
 
 class UbuntuInstaller(DebianInstaller):
+    @classmethod
+    def default_release(cls) -> str:
+        return "lunar"
+
     @staticmethod
     def repositories(state: MkosiState, local: bool = True) -> list[str]:
         if state.config.local_mirror and local: