I have just followed Ubuntu Backports to activate manual backports and I have a couple of questions. How can I, in the command line (e.g. apt-cacher or aptitude):

  1. list installed packages that have available backport upgrades? (Before, I used apt-show-versions -u for upgradeable packages)
  2. list all available backport packages (installed or not)?

3 Answers 3

  1. list installed packages that have available backport upgrades

    aptitude search '?and(~i, ~Araring-backports)'
  2. list all available backport packages (installed or not)

    aptitude search '~Abackports ?not(~S ~i ~Abackports)'
  • cat /dev/null is faster /s
    – CervEd
    Commented Jan 2, 2022 at 13:33

EDIT: After some experimentation, I found a solution that works perfectly for me! It lists only the packages that have a newer version in the -backports repository, and nothing more (the other solutions listed additional packages.

To list available backports updates, run this command:

aptitude search -t $(lsb_release -sc)-backports '~U ~Abackports'

If you want the list to also display the current and newer version, run this command instead:

aptitude search -t $(lsb_release -sc)-backports -F '%p %v -> %V' '~U ~Abackports'

This will display something like this:

nvidia-settings               331.20-0ubuntu -> 346.59-0ubuntu
screen                        4.1.0~20120320 -> 4.2.1-2~ubuntu
yelp-xsl                      3.10.1-1       -> 3.12.0-1~ubunt

If you don't want to memorize this command, add this to your ~/.bashrc:

alias apt-list-backports="aptitude search -t $(lsb_release -sc)-backports -F '%p %v -> %V' '~U ~Abackports'"

Now you only have to write apt-list-backports!

Original answer

Just found another way:

apt-get upgrade -s -t $(lsb_release -sc)-backports

This will simulate an upgrade and list what packages would be upgraded. But the upgrades to backports are also included (I think normal upgrades are shown too).

You can also add the option -V to show the versions that the packages would be upgraded to.

To view the changelog of a package in the backports, use:

apt-get changelog -t $(lsb_release -sc)-backports PACKAGE_NAME

This information is available in Synaptic, which is not installed by default but can be obtained with,

sudo apt-get install synaptic

Selecting Origin in the left sidebar will allow packages to be browsed by where they come from, such as raring-backports/universe, as well as locally installed packages.

If you are instead interested in a command line solution, I hacked together a quick-and-dirty python script to list packages in backports, though unfortunately it is rather slow.

from __future__ import print_function

import apt

def backport_version(package):
  if package.versions is None:
    return False
  for version in package.versions:
    for origin in version.origins:
      if origin.archive.endswith("backports"):
        return version.version
  return None

with apt.Cache() as cache:
  for package in cache:
    version = backport_version(package)
    if version is not None:
      print(package.fullname, version)
      if package.is_installed:
        print("    Installed:", package.installed.version)

It lists all available backport packages, and the installed version if it is installed.

  • Thanks, you raised my awareness to apt in python, which is definitely very useful. For that I would vote you up if my rep allowed it... But I was rather looking for something built-in. When the official line is to have manual backports, I guess there must be some more natural ways of getting this info
    – ricab
    Commented Jul 1, 2013 at 10:18
  • the synaptic method would answer the question, but I was looking more to apt-cache/aptitude based solution (cmd line)
    – ricab
    Commented Jul 1, 2013 at 11:59
  • 1
    Or: aptitude search '?and(~i, ~Araring-backports)'; to get installed backport packages Commented Jul 1, 2013 at 16:34
  • 3
    thanks for all the replies. Your aptitude solution solves 2. For 1, I had to research a bit more to get to: aptitude search '~i ~Abackports ?not(~S ~i ~Abackports)'. This solves 1 (assuming backports versions are always higher). I wouldn't have gotten it without your help though, so if you want make it an answer and I will select it
    – ricab
    Commented Jul 2, 2013 at 10:23
  • 1
    Might want to add your own answer and select it. I mostly just pointed out the aptitude documentation. Commented Jul 24, 2013 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .