Bug 865377 - Invalid result of compare_nvr
Invalid result of compare_nvr
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: kobo (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Daniel Mach
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 854258
  Show dependency treegraph
 
Reported: 2012-10-11 05:59 EDT by Martin Magr
Modified: 2012-10-11 06:51 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-10-11 06:21:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Magr 2012-10-11 05:59:10 EDT
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
Comment 1 Martin Magr 2012-10-11 06:05:39 EDT
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
Comment 2 Daniel Mach 2012-10-11 06:21:32 EDT
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
Comment 3 Peter Schiffer 2012-10-11 06:51:46 EDT
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..

Note You need to log in before you can comment on or make changes to this bug.