On Fri, Mar 13, 2009, Gerry Reno wrote:
Manuel, 'bdist_rpm' is NOT broken. What is broken is packagers misuse of the 'version' and 'release' strings. They do stupid things like put version='3.0' and release='rc1' and then wonder why their final release cannot update the release candidate. THIS IS A TRAINING ISSUE...
This is a pretty good description of the cause of the problem, but doesn't address a solution that may be used in software.
I deal mostly with building RPMs used under the OpenPKG portable package management system which generally uses sane naming conventions, at least as far as the release designations while versions depend on the original package versions.
The attached bit of code is basically what we use to determine the most recent packages, and works by splitting the version and release into tuples of numeric and non-numeric parts, then comparing these tuples. This is based on a recipe in the O'Reilly Python Cookbook to sort file names containing numerics.
This seems to solve most of the problems of sorting RPM packages on version and release, but might fail in places where there are issues of case-sensitivity.