From 44e1984dd70fd51280f9cea31d357ecf6c8349c7 Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Thu, 15 Feb 2024 13:43:45 +0200 Subject: [PATCH] Support parsing kernel versions with prefix strings Now we can parce "kernel-*", "kernel-plus-*", "kernel-rt-core-*" strings as kernel versions as well. --- pleskdistup/common/src/version.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pleskdistup/common/src/version.py b/pleskdistup/common/src/version.py index 1c189f2..3a83a89 100644 --- a/pleskdistup/common/src/version.py +++ b/pleskdistup/common/src/version.py @@ -30,6 +30,11 @@ def _extract_no_build(self, version: str) -> None: self.build = "" self.major, self.minor, self.patch, self.distro, self.arch = version.split(".") + def _remove_prefix(self, version: str) -> str: + while not version[0].isdigit(): + version = version.split("-", 1)[-1] + return version + def __init__(self, version: str): """Initialize a KernelVersion object.""" self.major = "0" @@ -39,6 +44,7 @@ def __init__(self, version: str): self.distro = "" self.arch = "" + version = self._remove_prefix(version) if "-" in version: self._extract_with_build(version) else: @@ -109,6 +115,7 @@ def __init__(self, to_extract: str): if to_extract.startswith("plesk-php"): self._extract_from_plesk_package(to_extract) + elif to_extract.startswith("PHP "): self._extract_from_desc(to_extract) elif to_extract[0].isdigit():