Skip to content

Commit

Permalink
Support parsing kernel versions with prefix strings
Browse files Browse the repository at this point in the history
Now we can parce "kernel-*", "kernel-plus-*", "kernel-rt-core-*" strings
as kernel versions as well.
  • Loading branch information
Mikhail Sandakov committed Feb 15, 2024
1 parent e3e6b63 commit 44e1984
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pleskdistup/common/src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 44e1984

Please sign in to comment.