How to find out which versions of a package can I install on APT

Just as an addendum

apt-cache madison <<package name>>

will list the versions available from all your sources.

apt-cache madison vim
   vim | 2:7.3.547-1 | http://debian.mirrors.tds.net/debian/ unstable/main amd64 Packages
   vim | 2:7.3.429-2 | http://debian.mirrors.tds.net/debian/ testing/main amd64 Packages
   vim | 2:7.3.429-2 | http://http.us.debian.org/debian/ testing/main amd64 Packages
   vim | 2:7.3.429-2 | http://debian.mirrors.tds.net/debian/ testing/main Sources
   vim | 2:7.3.547-1 | http://debian.mirrors.tds.net/debian/ unstable/main Sources

madison is an apt-cache subcommand, man apt-cache says:

apt-cache's madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool, madison. It displays available versions of a package in a tabular format. Unlike the original madison, it can only display information for the architecture for which APT has retrieved package lists (APT::Architecture).


The apt-cache show <Package> shows the package descriptions of all the versions your debian installation can install (i.e. from cached list of packages available from the repos listed in sources.list). So I guess you could try something like (for e.g.):

# apt-cache show package | grep Version
Version 1.0
Version 0.9-2squeeze1

The apt-cache show would give you much more info than just versions.


apt-cache policy gdb

Sample output:

gdb:
  Installed: 7.7.1-0ubuntu5~14.04.2
  Candidate: 7.7.1-0ubuntu5~14.04.2
  Version table:
 *** 7.7.1-0ubuntu5~14.04.2 0
        500 http://fr.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     7.7-0ubuntu3 0
        500 http://fr.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

So we see that there are two versions of GDB available:

  • 7.7.1-0ubuntu5~14.04.2
  • 7.7-0ubuntu3

Meaning of the output:

  • https://unix.stackexchange.com/questions/121413/understanding-the-output-of-apt-cache-policy
  • https://askubuntu.com/questions/282602/what-do-the-numbers-in-the-output-of-apt-cache-policy-tell-us