Blacklist only one specific version of a package for upgrades

Let's say we have a package mypackage that is available in different versions from different sources. I do not want to disable any of these sources though.

However, the currently latest version of mypackage is buggy on my system, but previous versions ran fine and probably future versions will be fixed again as well.

How can I blacklist only this buggy version of mypackage so that apt does not upgrade to it, but continues receiving upgrades from all sources and will upgrade to the following versions once they are out?

Holding the package back (apt-mark hold mypackage would also prevent future updates until I manually unhold the package, which s not what I want.


You can put this in /etc/apt/preferences to assign priority < 100 to this particular version of the package:

Package: mypackage
Pin: version 1.2-3ubuntu4
Pin-Priority: 99

This will prevent the upgrade to this version, because the currently installed version is assigned priority 100 (and the package with the highest priority gets installed).

For more information, see man apt_preferences or this answer.