On Thu, 2004-07-01 at 16:28, Michal Jaegermann wrote:
How you are using rpmvercmp, say, in a shell script? AFAIK there is no interface which would make that available.
This is off-topic for this list, but I'll answer it here, further discussion should be moved to the fedora list.
You can use the rpm python bindings, see attached script (rpmvercmp.py).
Please note, internally the algorithm is:
name is tested for equality epoch is numerically compared version is passed to rpmvercmp release is passed to rpmvercmp
first definitive answer is returned
rpmvercmp splits the string into alphanumeric substrings, then pairwise compares them, numerically if the leading char is a digit, lexically otherwise, pairwise comparison ends on first definitive result.
Credit and thanks go to Jerry Katz who showed me the python bindings and patiently explained many things to me.
Also attached is a tiny C program I wrote that will operate on strings rather than reading the rpm header's. It's good for when you just want to test rpm names as strings and don't have a full rpm, you can give it a pair of n-v-r, in which case it calls rpmvercmp on version and then release, or you can give it either just a pair of versions or a pair of revisions and it will call rpmvercmp on just that component. It links against rpm so it uses the actual rpmvercmp function.