deb-version(7)

πŸ’… deb-version β€” Debian package version number format

okay bestie, so this is deb-version from the dpkg suite, and it's literally just the tea on how Debian package version numbers are shaped. Buckle up πŸŽ€


✨ SYNOPSIS ✨

[epoch:]upstream-version[-debian-revision]

🌸 DESCRIPTION 🌸

So a version number β€” the kind used for Debian binary and source packages β€” is made of three components. Three! It's giving trinity. Let's meet them 🫢

🧚 epoch

This one is a single (usually small) unsigned integer. It's optional, and if you don't write it, zero is assumed. BUT β€” and this is the catch β€” if you omit it, then the upstream-version may not contain any colons. No colons. None. πŸ’€

Why does it even exist? It's there so you can leave behind mistakes in the version numbers of older versions of a package, and also old version numbering schemes a package used to have. Basically it's the "we don't talk about that era" button. πŸ™ˆ

πŸ‘‘ upstream-version

This is the main character part of the version number. It's usually the version number of the original ("upstream") package that the .deb file was made from, if that applies to you. Usually it'll be in the same format the upstream author(s) specified β€” but sometimes it needs to be reformatted so it fits into the package management system's format and comparison scheme. Glow-up required sometimes, ngl.

How the package management system compares the upstream-version is described below. And heads up: the upstream-version portion of the version number is mandatory. Can't skip it.

It may contain only alphanumerics (A-Za-z0-9) and the characters . + - : ~ (full stop, plus, hyphen, colon, tilde), and it should start with a digit. Also: if there's no debian-revision, then hyphens are not allowed; if there's no epoch, then colons are not allowed. Rules are rules πŸ’…

πŸ¦‹ debian-revision

This part says which version of the Debian package it is, based on the upstream version. It may contain only alphanumerics and the characters + . ~ (plus, full stop, tilde), and it's compared in exactly the same way the upstream-version is.

It's optional β€” but if it isn't there, then the upstream-version may not contain a hyphen. This format is for the case where a piece of software was written specifically to be turned into a Debian package, so there's only one "debianization" of it and no revision indication is required. Built different, no notes ✨

Convention says: restart the debian-revision at 1 every time the upstream-version goes up. Cute, consistent, iconic.

Dpkg will break the version number apart at the last hyphen in the string (if there is one) to figure out the upstream-version and the debian-revision. And 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, so don't let it get too big for its boots. 😌


πŸ”₯ Sorting algorithm πŸ”₯

The upstream-version and debian-revision parts get compared by the package management system using the same algorithm. Same algorithm, both parts. Periodt.

The strings are compared from left to right.

Step one: first, the initial part of each string that's made entirely of non-digit characters gets determined. These two parts (one of which may be empty) are compared lexically. If a difference is found, it's returned. Now, this lexical comparison is a comparison of ASCII values β€” but modified so that all the letters sort earlier than all the non-letters, and so that a tilde sorts before anything, even the end of a part. For example, here are those parts in sorted order:

'~~', '~~a', '~', the empty part, 'a'

See how the tilde is out here beating everything? Sneaky little icon. 🐍

Step two: then, the initial part of the remainder of each string that's made entirely of digit characters gets 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. Zero. Nothing. Nada.

These two steps β€” comparing and removing initial non-digit strings, and initial digit strings β€” are repeated until a difference is found or both strings are exhausted. Round and round until somebody wins or we run out of string πŸŒ€

Lowkey important note: the whole purpose of epochs is to let us leave behind mistakes in version numbering, and to cope with situations where the version numbering scheme changes. It is not intended to cope with version numbers containing strings of letters that the package management system cannot interpret (such as ALPHA or pre-), or with silly orderings. Don't try it, bestie. It won't slay, it'll just break. 😭

⭐ NOTES ⭐

The tilde character and its special sorting properties were introduced in dpkg 1.10, and some parts of the dpkg build scripts only gained support for it later in the 1.10.x series. So like... it arrived, and then the rest of the crew caught up. Fashionably late, honestly. πŸ’œ


🌈 SEE ALSO 🌈


and that's the whole vibe check, bestie β€” go forth and version responsibly πŸ“

sign-off time: this little masterpiece is from version 1.23.11-dirty, dated 2026-09-09, and it's the deb-version(7) page from the dpkg suite. mwah πŸ’‹

πŸ“¦ where this page comes from