Bug 865377 - Invalid result of compare_nvr
Summary: Invalid result of compare_nvr
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: kobo
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Daniel Mach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 854258
TreeView+ depends on / blocked
 
Reported: 2012-10-11 09:59 UTC by Martin Magr
Modified: 2012-10-11 10:51 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-10-11 10:21:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Martin Magr 2012-10-11 09:59:10 UTC
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 10:05:39 UTC
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 10:21:32 UTC
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 10:51:46 UTC
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.