Functions for manipulating and comparing Debian version strings. Compliant with Debian policy version 3.9.2. and Debian developers reference version 3.4.6
The following functions compare any two strings, that is these functions do not check whether the arguments are really legal debian versions. If the arguments are debian version strings, then the result is as required by debian policy. Note that two strings may be equivalent, that is denote the same debian version, even when they differ in syntax, as for instance "0:1.2.00" and "1.02-0".
trueiff the two strings define the same version. Hence, the result may be true even when the two string differ syntactically.
compare x y returns 0 if x is eqivalent to y, -1 if x is smaller
than y, and 1 if x is greater than y. This is consistent with
Version strings may be the decomposed into epoch, upstream, and revision as described in debian policy section 5.6.12. An epoch is present if the version string contains a colon ':', in this case the leftmost colon separates the epoch from the rest. A revision is present if the string contains a dash '-', in this case the rightmost dash separates the rest from the revision.
A version string that contains no dash (hence, no revision) is called native. Otherwise it is called non-native, in this case the revision may be empty (example: "1.2-") or not.
A suffix of the upstream part of a native version, or the suffix of the revision part of a non-native version, may contain a part indicating a binary NMU (Debian Developers Reference, section 18.104.22.168). A binary NMU part is of the form "+bN" where N is an unsigned integer.
# | Native of string * string * string
# | NonNative of string * string * string * string
result type of the analysis of a version string. The binNMU part, if present, has been removed from the upstream (if native version) or revision (if non-native vesion).
recompose a decomposed version string. For all v:
equal(v,compose(decompose v)) = true. There may, however, be
small syntactic differences between
return a version without its epoch and without its binNMU part
split the debian version into its components. (epoch,upstream,revision,binnmu) = split v v = epoch ^ ":" ^ upstream ^ "-" ^ revision ^ binnmu.
decomposeshould be used instead.
recomposeshould be used instead.
chop the epoch and binnmu component from a version.
strip_epoch_binnmushould be used instead.