Skip to content

Commit

Permalink
Handle kernel versions with '_' before build number
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Mar 5, 2024
1 parent 5c81772 commit 72776bd
Show file tree
Hide file tree
Showing 2 changed files with 10 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
3 changes: 3 additions & 0 deletions pleskdistup/common/tests/versiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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_kernel_with_underline(self):
self._check_parse("kernel-3.14.43_1-2.x86_64", "3.14.43-1.2.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 72776bd

Please sign in to comment.