How can I get a list of all packages available for a specific version of Ubuntu (not necessarily the one I have installed)?

Solution 1:

1. On-line

I prefer use of http://packages.ubuntu.com/ as muru's answer

2. Off-line, Manual

Otherwise looking for an off-line solution then you should be MR. APT and start downloading them from http://archive.ubuntu.com/ubuntu/dists/.

p=$(pwd); for c in main universe multiverse restricted; do for u in "" -security -updates; do for a in binary-amd64 binary-i386; do mkdir trusty${u}_${c}_$a; cd trusty${u}_${c}_$a; wget http://archive.ubuntu.com/ubuntu/dists/trusty$u/$c/$a/Packages.bz2; cd $p; done; done; done;

Results:

$ tree
.
├── trusty_main_binary-amd64
│   └── Packages.bz2
├── trusty_main_binary-i386
│   └── Packages.bz2
├── trusty_multiverse_binary-amd64
│   └── Packages.bz2
├── trusty_multiverse_binary-i386
│   └── Packages.bz2
├── trusty_restricted_binary-amd64
│   └── Packages.bz2
├── trusty_restricted_binary-i386
...

3. Off-line, using apt-cache/overlay-filesystem/chroot

Going bad, advanced setup:

Actually, I'm going to use a custom sources.list* with same apt-cache installed on 16.04, but apt will not overwrite the 16.04 real lists files in /var/lib/apt/lists/, changes will go to the overlay file-system.

Setup:

sudo apt-get install chroot
mkdir sandbox0
cd sandbox0
mkdir upper work merged
sudo mount -t overlay overlay -o lowerdir=/,upperdir=./upper,workdir=./work ./merged
sudo chroot merged/
echo "deb http://archive.ubuntu.com/ubuntu/ trusty universe multiverse main restricted" > /etc/apt/sources.list
rm -r /etc/apt/sources.list.d/*
apt-get update
exit

Use: (you may prepare a script)

sudo mount -t overlay overlay -o lowerdir=/,upperdir=./upper,workdir=./work ./merged
sudo chroot merged/

apt-cache ...

Solution 2:

Use chdist. This command allows you to run apt-get and apt-cache as usual, but for a different release of Ubuntu (or Debian or in fact any other Debian-derived distribution).

It also provides a wrapper around grep-dctrl which easily allows you to search and report on metadata fields.

Solution 3:

You already have the command to list all possible posted, but ok lets go a bit deeper shall we? So apt-cache search . or apt-cache search '' output around 2300+ lines which is in fact the whole amount of all possible packages including different DE versions.

To make it more easy you could only get the names with:

apt-cache search '' | sort -d | awk '{print $1}'

Or is you like more information and dont mind a long long list you could roll that through apt-cache policy:

apt-cache policy $(apt-cache search '' | sort -d | awk '{print $1}')