]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/: improve version detection
authorIker Pedrosa <ipedrosa@redhat.com>
Tue, 1 Apr 2025 07:35:46 +0000 (09:35 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 21 May 2025 08:04:42 +0000 (10:04 +0200)
Alpine Linux versions also contain the revision, and this needs to be
taken into account when detecting it.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
tests/system/framework/hosts/base.py

index 764c15aff3e74812b07bb1522a19af4f51bfcb69..9146c7d4e0debee862a808bde86cd66589a03157 100644 (file)
@@ -47,6 +47,7 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]):
         self._distro_name: str = "unknown"
         self._distro_major: int = 0
         self._distro_minor: int = 0
+        self._revision: int = 0
 
     def _distro_information(self):
         """
@@ -60,9 +61,13 @@ class BaseLinuxHost(MultihostHost[ShadowMultihostDomain]):
             self._distro_name = self._os_release["NAME"]
         if "VERSION_ID" not in self._os_release:
             return
-        if "." in self._os_release["VERSION_ID"]:
-            self._distro_major = int(self._os_release["VERSION_ID"].split(".", maxsplit=1)[0])
-            self._distro_minor = int(self._os_release["VERSION_ID"].split(".", maxsplit=1)[1])
+        if self._os_release["VERSION_ID"].count(".") == 2:
+            self._distro_major = int(self._os_release["VERSION_ID"].split(".")[0])
+            self._distro_minor = int(self._os_release["VERSION_ID"].split(".")[1])
+            self._revision = int(self._os_release["VERSION_ID"].split(".")[2])
+        elif self._os_release["VERSION_ID"].count(".") == 1:
+            self._distro_major = int(self._os_release["VERSION_ID"].split(".")[0])
+            self._distro_minor = int(self._os_release["VERSION_ID"].split(".")[1])
         else:
             self._distro_major = int(self._os_release["VERSION_ID"])