Skip to content

Commit

Permalink
Merge pull request #15 from plesk/fix-kernel-version-with-underlining
Browse files Browse the repository at this point in the history
Handle kernel versions with '_' before build number
  • Loading branch information
SandakovMM authored Mar 13, 2024
2 parents 1da00af + 0a798c8 commit db94532
Show file tree
Hide file tree
Showing 2 changed files with 17 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 @@ -15,6 +15,13 @@ def _extract_with_build(self, version: str) -> None:

self.major, self.minor, self.patch = main_part.split(".")

# Sometimes packages split patch and build with "_", which looks
# really weird.
if "_" in self.patch:
self.patch, self.build = self.patch.split("_")
self.distro, self.arch = secondary_part.split(".")
return

# Short format of kernel version without distro and arch mentioned
if secondary_part.isnumeric():
self.build = secondary_part
Expand Down
10 changes: 10 additions & 0 deletions pleskdistup/common/tests/versiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ 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_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")
self.assertEqual(kernel.major, "3")
self.assertEqual(kernel.minor, "14")
self.assertEqual(kernel.patch, "43")
self.assertEqual(kernel.build, "1")
self.assertEqual(kernel.distro, "2")
self.assertEqual(kernel.arch, "x86_64")

def test_kernel_parse_plus(self):
kernel = version.KernelVersion("3.10.0-327.36.3.el7.centos.plus.x86_64")
self.assertEqual(str(kernel), "3.10.0-327.36.3.el7.centos.plus.x86_64")
Expand Down

0 comments on commit db94532

Please sign in to comment.