Bug 82639 - Bad values returned from rpmvercmp from rpmlib
Summary: Bad values returned from rpmvercmp from rpmlib
Keywords:
Status: CLOSED DUPLICATE of bug 50977
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-01-24 10:44 UTC by Alexander Kanevskiy
Modified: 2007-04-18 16:50 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-01-24 15:54:56 UTC
Embargoed:


Attachments (Terms of Use)
quick fix. (525 bytes, patch)
2003-01-24 15:03 UTC, Alexander Kanevskiy
no flags Details | Diff

Description Alexander Kanevskiy 2003-01-24 10:44:08 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.2.1) Gecko/20021224

Description of problem:
I'm try to idntify in own program what rpm version is newer
seem's what rpmvercmp function works incorrectly if
some alpha letters present in Release tag

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
[kad@pylesos kad]$ python
>>> import rpm
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2asp'), ('0', '9.2.1', '1.asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1.asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>>
>>> rpm.labelCompare(('0', '9.2.1', '1'), ('0', '9.2.1', '1.7x.2'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2'), ('0', '9.2.1', '1'))
1
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2a'), ('0', '9.2.1', '1a'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1a'), ('0', '9.2.1', '1.7x.2a'))
-1
>>>

Actual Results:  In case compare 9.2.1-1 and 9.2.1-1.7x.2 Version/Release pair -- 
rpm works correctly. In case s1=9.2.1-1aaa and s2=9.2.1-1.7x.2aaa
rpmvercmp return always -1 in any case rpmvercmp(s1,s2) or rpmvercmp(s2,s1)


Expected Results:  9.2.1-1.7x.2aaa must be newer than 9.2.1-1aaa


Additional info:

Comment 1 Jeff Johnson 2003-01-24 11:48:07 UTC
rpmvercmp does what it does, has always done what it has done,
cannot and will not change.

Yes there are odd corner cases comparing alpha with digit strings.
See #50973 (from memory) for gory details.

Comment 2 Alexander Kanevskiy 2003-01-24 15:01:02 UTC
I fix this function to work more gracefully in case Release consist 
versions and numbers.

Here is test. return: - is patched result, rh: is original result.
Fix me if I wrong.
Patch will be attached.

return 
 1: a is newer than b
 0: a and b are the same version
-1: b is newer than a

a: 1.asp      b: 1.7x.2asp  return:  -1 rh:  -1
a: 1.7x.2asp  b: 1.asp      return:   1 rh:  -1
a: asp1       b: asp1.7x.2  return:  -1 rh:  -1
a: asp1.7x.2  b: asp1       return:   1 rh:   1
a: 1          b: asp1.7x.2  return:   1 rh:  -1
a: asp1.7x.2  b: 1          return:  -1 rh:  -1
a: asp1       b: 1.7x.2     return:  -1 rh:  -1
a: 1.7x.2     b: asp1       return:   1 rh:  -1
a: 1          b: 1.7x.2     return:  -1 rh:  -1
a: 1.7x.2     b: 1          return:   1 rh:   1
a: 1.asp      b: 1.asp      return:   0 rh:   0
a: 1.asp      b: 0.7.3      return:   1 rh:   1
a: 3asp       b: 3.asp      return:   0 rh:   0
a: 9.0        b: 10.0       return:  -1 rh:  -1
a: 9asp       b: 10         return:  -1 rh:  -1
a: 9          b: 15.asp     return:  -1 rh:  -1
a: owl1       b: 1asp       return:  -1 rh:  -1
a: alt1       b: 1asp       return:  -1 rh:  -1
a: alt2       b: 1          return:  -1 rh:  -1
a: 0.7.2.asp  b: 0.7.3asp   return:  -1 rh:  -1
a: 0.7.2.asp  b: 0.7.2asp   return:   0 rh:   0
a: asp1       b: alt1       return:   1 rh:   1
a: ipl4mdk    b: alt0.8     return:   1 rh:   1
a: alt0.8     b: ipl4mdk    return:  -1 rh:  -1



Comment 3 Alexander Kanevskiy 2003-01-24 15:03:26 UTC
Created attachment 89573 [details]
quick fix.

We can assume what we a comparing numbers only if str1 and str2 is numbers. not
only str1

Comment 4 Jeff Johnson 2003-01-24 15:11:25 UTC
Again, there is no such thing as a "quick fix" for
rpmvercmp. See details at #50977.

*** This bug has been marked as a duplicate of 50977 ***

Comment 5 Alexander Kanevskiy 2003-01-24 15:54:56 UTC
Yes, I agree. :)
Sorry, I don't found bug 50977.
Peter Bowen and me release same idea but in different ways.
His patch and mine produces one output. 

 
Thanks for fix in 4.2-0.55




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