I am wondering what the behavior of apt is when publishing multiple major versions of the same package. For example, if I have a package called foo
, with a latest version of 1.0.0
, and I publish version 2.0.0
, then publish version 1.1.0
afterwards, which will be regarded as the latest package when running sudo apt update
and sudo apt install foo
: the last package published (in this case 1.1.0
) or the package with the highest version number (in this case 2.0.0
)?
Asked
Active
Viewed 1,170 times
3

oso
- 33
2 Answers
5
By default, apt
downloads the package with highest version number (even if that was not the last published version).
However, if both packages are available in separate repositories, you can install the earlier version with sudo apt install foo=1.1.0
.
Afterward, you can prevent that specific package from upgrading to version 2.0.0, sudo apt-mark hold foo
.
(To revert this behavior, you will have to unhold the package).

Archisman Panigrahi
- 28,338
- 18
- 105
- 212
4
It's based on a several conditions that are evaluated in order:
- Package priority. Higher the priority, that specific package will be preferred, even if that means a "downgrade". If two packages are of the same priority, it will continue to
- Epoch. Is the number before a colon and it's usually meant to express a change in upstream versioning. If no epoch is specified, 0 is assumed.
- Upstream version. Is the bare version of the package, and is usually before the hyphen. It's evaluated as other version schemes that uses dots. Every value is evaluated positionally by groups divided by the dots, from left to right. The exact algorithm is described in the Debian Policy document.
- Debian's version. After the hyphen. Same as upstream version.
In other words, it will always try to install the higher version number, unless you include a different epoch or pin it using priorities. dpkg will ignore all this and only make sure that the dependencies are fulfilled.

Braiam
- 67,791
- 32
- 179
- 269