Package version number comparisons (for conditional logic)
Kevin P. Fleming
kpfleming at linuxfromscratch.org
Sat Feb 7 09:32:45 PST 2004
After thinking about this for a few days, I'm not happy with
implementing the version number comparisons as detailed in the current
syntax document. Specifically, it would annoy me greatly if my profiles
did not consider version "2.0.10" to be greater than "2.0.9".
While we certainly cannot cover all the possibilities (like -pre/-rc
suffixes that are lesser versions, for example), I'd rather implement it
- Break each version number into its components, which would be defined
as sections separated by ., -, _ or : characters.
- For each component, attempt to convert it to a number (strtol).
- If the numeric conversion succeeds with no leftover characters, do
comparisons for that component numerically, not alphanumerically.
- If the numeric conversion succeeds but leaves leftover characters
(like ".05b" would leave "b"), compare the numeric portions numerically
and the leftovers alphanumerically (only if the numeric portions were
- If the numeric conversion fails, compare the components alphanumerically.
- If either version number to be compared has more components than the
other, and the components-in-common are equal, then the number with the
additional components is considered to be a "greater than" version number.
Anyone have any objections?
More information about the alfs-discuss