Skip to content

Commit

Permalink
support for parsing versions of kernels installed from the Linode rep…
Browse files Browse the repository at this point in the history
…ository
  • Loading branch information
Mikhail Sandakov committed Jul 24, 2024
1 parent 772fdbc commit 02314de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pleskdistup/common/src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def _extract_no_build(self, version: str) -> None:
if self.patch == "":
self.patch = "0"

def _extract_linode_kernel_version(self, version: str) -> None:
self.build = ""
main_part, self.arch, *_ = version.split("-")
self.major, self.minor, self.patch = main_part.split(".")

def _remove_prefix(self, version: str) -> str:
while not version[0].isdigit():
version = version.split("-", 1)[-1]
Expand All @@ -68,7 +73,9 @@ def __init__(self, version: str):
self.arch = ""

version = self._remove_prefix(version)
if "-" in version:
if "-linode" in version:
self._extract_linode_kernel_version(version)
elif "-" in version:
self._extract_with_build(version)
else:
self._extract_no_build(version)
Expand Down
3 changes: 3 additions & 0 deletions pleskdistup/common/tests/versiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def test_kernel_start_with_prefix(self):
def test_kernel_start_with_plus_prefix(self):
self._check_parse("kernel-plus-3.10.0-327.36.3.el7.centos.plus.x86_64", "3.10.0-327.36.3.el7.centos.plus.x86_64")

def test_linode_kernel_parse(self):
self._check_parse("6.2.9-x86_64-linode160", "6.2.9.x86_64")

def test_kernel_with_underline(self):
kernel = version.KernelVersion("kernel-3.14.43_1-2.x86_64")
self.assertEqual(str(kernel), "3.14.43-1.2.x86_64")
Expand Down

0 comments on commit 02314de

Please sign in to comment.