Version checking: don't use distutils.version.LooseVersion anymore
Created by: ollieparanoid
Right now we use distutils.version.LooseVersion
from python, because it behaves like the version comparison from abuild (which is the same as in Gentoo, because once upon a time Alpine was built from Gentoo).
The problem is, that this version check throws exceptions in some corner cases:
>>> from distutils.version import LooseVersion
>>> LooseVersion("22.7-r1") < LooseVersion("22.7.3-r1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/distutils/version.py", line 52, in __lt__
c = self._cmp(other)
File "/usr/lib/python3.6/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
>>>
...so it is not really suitable for what we are doing. To be fair, this isn't a public python API, but some internal code we shouldn't be using anyway.
There is already a testcase for version checking, that actually uses abuild
's testcase. Right now we ignore all cases, where we get an exception thrown.
-
Create pmb/helpers/version.py
-
Move the compare_version
function there -
Rewrite all calls to that function to use the new path -
Rewrite the function to not use distutils
-
Test all cases, do not allow exceptions to pass the case