Skip to content

Commit

Permalink
Support vz format of the kernel version information
Browse files Browse the repository at this point in the history
Unfortiantly it have no information about arch, so we have to skip it.
  • Loading branch information
Mikhail Sandakov committed Jan 2, 2024
1 parent 8dedcfa commit c3e26ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pleskdistup/common/src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def _extract_with_build(self, version: str) -> None:
if secondary_part[iter].isalpha():
self.build = secondary_part[:iter - 1]
suffix = secondary_part[iter:]
self.distro, self.arch = suffix.split(".")
# There is no information about arch when we have vzX suffix
if suffix.startswith("vz"):
self.distro = suffix.split(".")[0]
else:
self.distro, self.arch = suffix.split(".")
break

def _extract_no_build(self, version: str) -> None:
Expand All @@ -45,10 +49,15 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}({attrs})"

def __str__(self) -> str:
if self.build == "":
return f"{self.major}.{self.minor}.{self.patch}.{self.distro}.{self.arch}"
result = f"{self.major}.{self.minor}.{self.patch}"
if self.build != "":
result += f"-{self.build}"

return f"{self.major}.{self.minor}.{self.patch}-{self.build}.{self.distro}.{self.arch}"
result += f".{self.distro}"
if self.arch != "":
result += f".{self.arch}"

return result

def __lt__(self, other) -> bool:
if int(self.major) < int(other.major) or int(self.minor) < int(other.minor) or int(self.patch < other.patch):
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 @@ -22,6 +22,9 @@ def test_kernel_parse_large_build(self):
def test_kernel_parse_no_build(self):
self._check_parse("3.10.0.el7.x86_64", "3.10.0.el7.x86_64")

def test_kernel_parse_virtuozo(self):
self._check_parse("3.10.0-1160.90.1.vz7.200.7", "3.10.0-1160.90.1.vz7")

def test_compare_simple_equal(self):
kernel1 = version.KernelVersion("3.10.0-1160.95.1.el7.x86_64")
kernel2 = version.KernelVersion("3.10.0-1160.95.1.el7.x86_64")
Expand Down

0 comments on commit c3e26ce

Please sign in to comment.