LinuxOpen Source SoftwareTutorials

How to enable Debian backports repositories

Debian releases always contain a specific version of each package. Whether this is the Linux Kernel, the Shell (e.g. Bash) or Apache web server, the version itself remains the same. Only security (and very important bug) fixes will be added to that particular package version.

However there are a couple of reasons why a newer package would be preferred:

  • New features
  • Stability or performance improvements
  • Better hardware support
  • Package not available in default repositories

In these situations, newer packages can (often, not always) be installed from the so-called backports repositories.

Enabling backports repositories

The best and easiest way to enable the backports repositories is to create a dedicated list entry/file inside /etc/apt/sources.list.d:

root@buster:~# echo "deb buster-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list.d/backports.list

In this case , the buster-backports are enabled on a Debian Buster machine.

With a simple apt update (or apt-get update) the new repository will be enabled.

root@buster:~# apt-get update
Get:1 buster/updates InRelease [65.4 kB]
Get:2 buster-backports InRelease [46.7 kB]                                                                         
Hit:3 buster InRelease                                                                                                   
Hit:4 buster InRelease                               
Get:5 buster-backports/main amd64 Packages [484 kB]
Get:6 buster-backports/main Translation-en [407 kB]
Get:7 buster-backports/contrib amd64 Packages [9,084 B]
Get:8 buster-backports/contrib Translation-en [8,044 B]
Get:9 buster-backports/non-free amd64 Packages [33.9 kB]
Get:10 buster-backports/non-free Translation-en [38.3 kB]
Get:11 buster/updates/main amd64 Packages [299 kB]
Get:12 buster/updates/main Translation-en [156 kB]
Fetched 1,547 kB in 1s (1,524 kB/s)                                   
Reading package lists... Done

That's it!

Practical example: phpmyadmin package

Let's use phpmyadmin as a hands-on practical example. Strangely this package never made it into the official Buster release:

phpmyadmin package missing in buster release
phpmyadmin package missing in buster release

However it was added into the buster-backports repositories afterwards. Now with the backports repositories enabled, phpmyadmin is installable:

root@buster:~# apt-cache search phpmyadmin
adminer - Web-based database administration tool
phpliteadmin - web-based SQLite database admin tool
phpliteadmin-themes - web-based SQLite database admin tool - themes
phpmyadmin - MySQL web administration tool
php-phpmyadmin-motranslator - translation API for PHP using Gettext MO files
php-phpmyadmin-shapefile - translation API for PHP using Gettext MO files
php-phpmyadmin-sql-parser - validating SQL lexer and parser

Without backports enabled, phpmyadmin would not appear in the list.

Now when trying to install phpmyadmin, a dependency error might show up:

root@buster:~# apt-get install phpmyadmin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 phpmyadmin : Depends: php-twig (> 2.9) but 2.6.2-2 is to be installed
E: Unable to correct problems, you have held broken packages.

This happens because apt is now confused as two different php-twig package versions show up:

root@buster:~# apt-cache show php-twig | egrep "(^Package|Version)"
Package: php-twig
Version: 2.14.3-1~bpo10+1
Package: php-twig
Version: 2.6.2-2

From the version line you can quickly spot the backports (bpo) version. To tell apt to use the php-twig package from the backports repos, define the version:

root@buster:~# apt-get install phpmyadmin php-twig=2.14.3-1~bpo10+1

As an alternative, the backports repositories can be configured with a higher apt pinning (priority). Check out our article Advanced configuration and troubleshooting of APT package manager.

Use caution

Installing packages from backports is mostly hassle-free, especially for smaller packages without a lot of dependencies. But packages which require a lot of dependencies might break existing package installations and applications.

Claudio Kuenzler
Claudio has been writing way over 1000 articles on his own blog since 2008 already. He is fascinated by technology, especially Open Source Software. As a Senior Systems Engineer he has seen and solved a lot of problems - and writes about them.

You may also like

1 Comment

  1. […] If you want to add the "backports" repositories, read our related article How to enable Debian backports repositories. […]

Comments are closed.

More in:Linux