diff --git a/pleskdistup/common/src/version.py b/pleskdistup/common/src/version.py index dc94520..44bd6c8 100644 --- a/pleskdistup/common/src/version.py +++ b/pleskdistup/common/src/version.py @@ -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 diff --git a/pleskdistup/common/tests/versiontests.py b/pleskdistup/common/tests/versiontests.py index ed7fd20..4f3655e 100644 --- a/pleskdistup/common/tests/versiontests.py +++ b/pleskdistup/common/tests/versiontests.py @@ -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")