Pinning packages with APT

We all know that we should really, really keep our systems up to date so we should always use the latest version of a package right?

Obviously the answer to this question is yes, except on the rare occasion when it isn’t. If you absolutely have to continue to use an older version of a package and do not want it to be upgraded automatically then you can.

Now before I go any further I should point out that pinning packages that have even a few dependencies is going to result in a whole load of pain at some point (or at least a whole load of rather cryptic error messages) when an updated package that shares one or more of these dependencies can’t be installed because the it isn’t updated.

If you really don’t want a particular package to be upgraded automatically then the solution is to pin the package you want to a particular version by creating a new file to store these preferences. You can use a separate file for each package you want to pin or combine the settings in a single file, it is entirely up to you, but in this case I’m using a single file to pin two separate packages.

nano /etc/apt/preferences.d/10-pinned-packages

The first is the package that includes the desktop icons used by the Adwaita theme – there is nothing technically wrong with the latest version I just don’t like the appearance of the new icons as much as the older version. The second is the UEFI firmware package for QEMU which I’ve pinned on Debian 11 (bullseye) as the latest version doesn’t work when installing VMS on QEMU.

/etc/apt/preferences.d/10-pinned-packages
Package: adwaita-icon-theme Pin: version 3.30.* Pin-Priority: 999 # Package: ovmf Pin: version 0~20181115.85588389-3+deb10u3 Pin-Priority: 999 # 

Each section in the file needs to include the package name, the version of the package to be pinned (which may include a wild card), and the priority (which needs to be higher than the default).

Note the blank line between the two sections which I found was necessary for both packages to be pinned.

Lastly I found that for the changes to take effect you need to update the available packages.

apt-get update
Hit:1 http://ftp.uk.debian.org/debian bullseye InRelease
Hit:2 http://ftp.uk.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done
# 
This entry was posted in Debian, Ubuntu and tagged . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.