LLI Wiki — My Digital Knowledge Base

APT pinning: mixing stable, testing and backports

Configure APT pin priorities to install selected packages from testing or backports while staying on stable.

APT pinning assigns a priority to each repository. With low priorities, apt only installs a package from testing or unstable when it is requested explicitly. This lets you take a few packages from a newer repository without moving the whole system.

The examples use Debian with the stable, testing, unstable and experimental repositories. Release names change over time: adapt the codenames to the release in use.

Priorities (/etc/apt/preferences.d/)

File Selection Priority
security.pref origin Debian-Security 1000
stable.pref a=stable 900
testing.pref a=testing 750
unstable.pref a=unstable 50
experimental.pref a=experimental 1

Example stable.pref:

Package: *
Pin: release a=stable
Pin-Priority: 900

Repositories (/etc/apt/sources.list.d/)

Example stable.list (the other files have the same content with the release name replaced):

deb http://deb.debian.org/debian/ stable main contrib non-free
deb-src http://deb.debian.org/debian/ stable main contrib non-free

security.list:

deb http://security.debian.org/ stable/updates main contrib non-free
deb http://security.debian.org/ testing/updates main contrib non-free

After creating these files:

sudo apt-get update

Install one package from a backports repository

To install a single package from backports while keeping the rest on stable:

sudo apt-get install package-name -t wheezy-backports

Return to stable

Check the configured repositories first:

cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/

To force the stable packages, even when a newer version exists elsewhere, use a priority above 1000 in /etc/apt/preferences.d/stable.pref:

Package: *
Pin: release a=stable
Pin-Priority: 1001

Then update, checking each step:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Notes

Mastodon LLIMastodon SocialFosstodon