Description of problem: from kobo import rpmlib nvr_old = rpmlib.parse_nvr('man-pages-pl-0.24-13.el7') nvr_new = rpmlib.parse_nvr('man-pages-pl-0.3-2.el7') result = rpmlib.compare_nvr(nvr_new, nvr_old) Version-Release number of selected component (if applicable): kobo-rpmlib-0.3.6-1.fc17.noarch How reproducible: In [1]: from kobo import rpmlib In [2]: nvr_old = rpmlib.parse_nvr('man-pages-pl-0.24-13.el7') In [3]: nvr_new = rpmlib.parse_nvr('man-pages-pl-0.3-2.el7') In [4]: result = rpmlib.compare_nvr(nvr_new, nvr_old) In [5]: result Out[5]: -1 Actual results: 'man-pages-pl-0.3-2.el7' resulting to be older than 'man-pages-pl-0.24-13.el7' Expected results: 'man-pages-pl-0.3-2.el7' resulting to be newer (e.g. result=1) than 'man-pages-pl-0.24-13.el7' Additional info: None
I just found out, that if you fit version length, then result is OK. SO maybe it could be fixed with this: n [1]: from kobo import rpmlib In [2]: nvr_new = rpmlib.parse_nvr('man-pages-pl-0.30-2.el7') In [3]: nvr_old = rpmlib.parse_nvr('man-pages-pl-0.24-13.el7') In [4]: result = rpmlib.compare_nvr(nvr_new, nvr_old) In [5]: result Out[5]: 1
This is expected. RPM splits versions by dots and underscores and compares them part by part. If both parts are numeric, they are compared as numbers. 0.24 > 0.3 because 0 = 0 && 24 > 3
Yes, this is correct, however it is like this: man-pages-pl-0:0.24-13.el7 and man-pages-pl-1:0.3-2.el7 The problem is that comparison is ignoring the epoch number..