RPM and DEB Versioning
RPM (4.7.1) version format
Information taken from:
- the RPM header definition
- the handlePreambleTag routine defined in build/parsePreamble.c file
The RPM version is stored as 3 separated TAGS in the RPM binary file header:
epoch
- Deprecated
- A single (generally small) unsigned integer
- Zero if omitted
- Used for packager versioning mistakes, should not be used regularly
version
- Mandatory
- Characters NOT allowed: - / ~ .. (hyphen, slash, tilde, double dot)
- Spaces not allowed
release
- Optional
- Characters NOT allowed: - / ~ .. (hyphen, slash, tilde, double dot)
- Spaces not allowed
RPM string representation of the version is:
version[-release]
RPM (4.7.1) version comparison algorithm
Information taken form:
- the rpmVersionCompare routine defined in lib/psm.c file
- the rpmvercmp routine defined in lib/rpmvercmp.c file
The comparison order is:
- Numeric comparison of the epoch
- Alphanumeric comparison of the version
- Alphanumeric comparison of the revision
Alphanumeric comparison:
1) The 2 strings are divided in blocks:
- contiguous numbers
- contiguous letters
all not-alphanumeric characters are ignored
Example:
- 1.25a!0056.ABC_36c
- 1.b.34.a6+ABC(22)fg
become:
1 |
25 |
a |
0056 |
ABC |
36 |
c |
1 |
b |
34 |
a |
6 |
ABC |
22 |
fg |
2) The comparison is done block by block left to right
- number block <=> number block (number comparison)
- alpha block <=> alpha block (ASCII comparison)
- number block > alpha block
- any block > no block left
3) At the first inequality the algorithm exits.
RPM (4.7.1) version comparison examples
INTUITIVE:
- 1.2.3-5 > 1.2.3-6
- 1.2.3-b > 1.2.3-a
- 1.2.3 > 1.2
NON-INTUITIVE:
- 1-VDT_1.2_5 > 1-VDT_1.2.4_6
- 1-VDT_1.0 > 1-VDT_1.a
- 1-VDT_1_a > 1-VDT_1_A
- 1.2.3-1 = 1_2_3-1 = 1_2+3-1 = 1+2+3-1 = 1@2^3-1
DEB version format (dpkg 1.14.25)
Information taken form:
The version of a DEB package is stored as a string of the following format:
- [epoch:]version[-revision]
With:
epoch
- a single (generally small) unsigned integer
- Zero if omitted
- Used for packager versioning mistakes, should not be used regularly
version
- Mandatory
- Allowed characters: A-Za-z0-9 and . + - : ~ (dot plus hyphen colon tilde)
- If one or more : (colon) are used, the first one is used as epoch-version delimiter
- If one or more - (hyphen) are used, the last one is used as version-revision delimiter
- Should start with a digit (not enforced)
- Must contain at least one digit
release
- Optional
- Allowed characters: A-Za-z0-9 and . + ~ (dot plus tilde)
- Should restart from 1 when version changes (not enforced)
- If present, must contain at least one digit
DEB version comparison algorithm (dpkg 1.14.25)
Information taken form:
The comparison order is:
- Numeric comparison of the epoch
- Alphanumeric comparison of the version
- Alphanumeric comparison of the revision
The algorithm returns at the first difference found.
The Alphanumeric comparison has the following rules:
- character to character comparison left to right
- if both characters are digit -> consecutive digits are grouped -> numerical comparison
- if one or both is not a digit -> using ALPHA ORDER
ALPHA ORDER:
"~" <
"" =
0-9 <
A-Z <
a-z <
+ (plus) <
- (hyphen) <
. (dot) <
: (column)
DEB version comparison examples (dpkg 1.14.25)
INTUITIVE:
- 1.2.3-5 > 1.2.3-6
- 1.2.3-b > 1.2.3-a
- 1.2.3 > 1.2
NON-INTUITIVE:
- 1.2.3 > 1.2.3~5
- 1-1.a > 1-1.1
- 1-1_a > 1-1_A
- 1.2: > 1.2a:
Differences in format and comparison algorithms
--
LorenzoDini - 08-Oct-2009
Topic revision: r1 - 2009-10-08
- unknown