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

65

17

Using APT, you can install a specific version of a package using:

apt-get install package=1.0

But you can't do

apt-get install package=1.*

So, how can I find out which versions are avaliable for package on a specific repository, or in all repositories in my /etc/apt/sources.list?

Camilo Martin

Posted 2012-02-24T17:34:41.447

Reputation: 2 308

Answers

93

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).

lornix

Posted 2012-02-24T17:34:41.447

Reputation: 9 633

Now THAT is an AWESOME tidbit! tells version and repo, I love it! – Dennis – 2015-06-26T06:16:48.200

Can you install package for which line ends with Sources? How can you do it? – nuoritoveri – 2016-05-12T08:28:15.037

1@nuoritoveri The Sources sources are repositories which contain the source code of the various programs and packages. The source code may be downloaded using the apt-get source XYZZY command to download the source for the XYZZY package. See the apt-get man page (man apt-get) for more details. – lornix – 2016-05-12T09:19:47.620

Really, madison? Why not terry? Thanks for this – smac89 – 2017-12-08T21:36:59.873

3Madison? Is that a parameter to apt-cache or a package name? I'm not using an apt-get distro anymore (but +1 just in case) – Camilo Martin – 2012-06-17T19:56:01.503

5parameter. Don't feel bad, it was one of those chance discoveries for me too. There's a web page (app?) on the Debian site which shows the same information, which I suppose was first, and someone coded it for apt-cache. Quite handy. – lornix – 2012-06-17T19:57:50.190

Wow, quite handy indeed. I'll change the accept to this because it's just what I wanted (at the time) and comes built-in without grepping it. – Camilo Martin – 2012-06-18T21:25:45.520

1This doesn't work for all packages. – Cerin – 2014-02-22T15:32:06.603

26

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.

Anil

Posted 2012-02-24T17:34:41.447

Reputation: 558

Thanks, will try out. Is it possible to downgrade? – Camilo Martin – 2012-02-24T17:47:23.193

It seems to work, I just want to know if this would list packages whose versions are lower than what I currently have. – Camilo Martin – 2012-02-24T17:51:58.493

5you can use apt-cache policy if only the version interest you. – Rémi – 2012-02-24T18:11:21.443

@Rémi Thanks!! That command solved my next doubt, how to know where a package will come from. I was even searching already :) – Camilo Martin – 2012-02-24T18:21:17.670

12

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:

Ciro Santilli 新疆改造中心法轮功六四事件

Posted 2012-02-24T17:34:41.447

Reputation: 5 621

1Thanks, this seems more detailed than apt-cache madison (but harder to parse). – Camilo Martin – 2015-07-26T18:26:51.410

2

A command that is specifically intended for this is apt-show-versions. You often have to install it, but then can run apt-show-versions -a and it will show you the version number, the distribution (i.e. testing, stable, unstable, backports, etc.) where that can be found, and finally tell you if the version you have installed is up to date or not.

It does not give you as much information as apt-cache, but gives you pretty much what you need, as you can then install from the correct repository (using aptitude / apt-get -t) or simply install using the correct version number in the form you noted.

ShankarG

Posted 2012-02-24T17:34:41.447

Reputation: 696

+1, but while testing it on my girlfriend's box with an arbitrary example, it misses one of the versions that apt-cache picked: http://i.imgur.com/15be7.png

– Camilo Martin – 2012-03-21T09:37:21.613

That's interesting, it seems to have skipped the oldest one. Perhaps your apt preferences are set to prefer testing? – ShankarG – 2012-03-21T14:14:10.930

I don't know? Where would I look to check if it prefers testing? – Camilo Martin – 2012-03-21T16:18:21.033

Check the file /etc/apt/preferences – ShankarG – 2012-03-22T04:35:16.350