dpkg programmers' manual - chapter 5
Version numbering

Every package has a version number, in its Version control file field.

dpkg imposes an ordering on version numbers, so that it can tell whether packages are being up- or downgraded and so that dselect can tell whether a package it finds available is newer than the one installed on the system. The version number format has the most significant parts (as far as comparison is concerned) at the beginning.

The version number format is: [epoch:]upstream-version[-debian-revision].

The three components here are:

epoch
This is a single unsigned integer, which should usually be small. It may be omitted, in which case zero is assumed. If it is omitted then the upstream-version may not contain any colons.

It is provided to allow mistakes in the version numbers of older versions of a package, and also a package's previous version numbering schemes, to be left behind.

dpkg will not usually display the epoch unless it is essential (non-zero, or if the upstream-version contains a colon); dselect does not display epochs at all in the main part of the package selection display.

upstream-version
This is the main part of the version. It is usually version number of the original (`upstream') package of which the .deb file has been made, if this is applicable. Usually this will be in the same format as that specified by the upstream author(s); however, it may need to be reformatted to fit into dpkg's format and comparison scheme.

The comparison behaviour of dpkg with respect to the upstream-version is described below. The upstream-version portion of the version number is mandatory.

The upstream-version may contain only alphanumerics and the characters + . - : (full stop, plus, hyphen, colon) and should start with a digit. If there is no debian-revision then hyphens are not allowed; if there is no epoch then colons are not allowed.

debian-revision
This part of the version represents the version of the modifications that were made to the package to make it a Debian binary package. It is in the same format as the upstream-version and dpkg compares it in the same way.

It is optional; if it isn't present then the upstream-version may not contain a hyphen. This format represents the case where a piece of software was written specifically to be turned into a Debian binary package, and so there is only one `debianization' of it and therefore no revision indication is required.

It is conventional to restart the debian-revision at 1 each time the upstream-version is increased.

dpkg will break the upstream-version and debian-revision apart at the last hyphen in the string. The absence of a debian-revision compares earlier than the presence of one (but note that the debian-revision is the least significant part of the version number).

The debian-revision may contain only alphanumerics and the characters + and . (plus and full stop).

The upstream-version and debian-revision parts are compared by dpkg using the same algorithm:

The strings are compared from left to right.

First the initial part of each string consisting entirely of non-digit characters is determined. These two parts (one of which may be empty) are compared lexically. If a difference is found it is returned. The lexical comparison is a comparison of ASCII values modified so that all the letters sort earlier than all the non-letters.

Then the initial part of the remainder of each string which consists entirely of digit characters is determined. The numerical values of these two parts are compared, and any difference found is returned as the result of the comparison. For these purposes an empty string (which can only occur at the end of one or both version strings being compared) counts as zero.

These two steps are repeated (chopping initial non-digit strings and initial digit strings off from the start) until a difference is found or both strings are exhausted.

Note that the purpose of epochs is to allow us to leave behind mistakes in version numbering, and to cope with situations where the version numbering changes. It is not there to cope with version numbers containing strings of letters which dpkg cannot interpret (such as ALPHA or pre-), or with silly orderings (the author of this manual has heard of a package whose versions went 1.1, 1.2, 1.3, 1, 2.1, 2.2, 2 and so forth).

If an upstream package has problematic version numbers they should be converted to a sane form for use in the Version field.


dpkg programmers' manual - Copyright ©1996 Ian Jackson.
Contents; abstract; next; back.
14 August 1996
Ian Jackson ijackson@gnu.ai.mit.edu