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:
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.
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
Created attachment 89573 [details] quick fix. We can assume what we a comparing numbers only if str1 and str2 is numbers. not only str1
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 ***
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