Version comparison of ports

Anders F Björklund afb at macports.org
Fri Aug 12 02:33:32 PDT 2011


I renamed* the old pextlib function called "rpm-vercomp" to just "vercmp",
(and fixed the spelling of it too, while I was at it, rhymes with strcmp)
since the "compatibility" would depend on your RPM version and/or config.
It also allows for changing sort order in e.g. MacPorts 2.1, if desired...

Most (if not all) uses now simply compare versions like 4.0 and 4.1, and
there it wouldn't matter much. The edge cases was mostly when comparing
alphas and digits, like "a" and "1". For historical reasons, digits win
- even if alphas would win with a more straight-forward string compare...


Once MacPorts 2.0.2 is out (plus some two weeks or so - for good measure),
the 50 or so places in ports (a couple more for xcodeversion) will change.

I also added a test case, where one could document all the quirks of the
desired version comparison. Like the current "digits-beats-alpha" rule ?

--anders

*
  http://trac.macports.org/changeset/82291 (trunk)
  http://trac.macports.org/changeset/82292 (2.0.x)



More information about the macports-dev mailing list