List Packages from PPA/Source in Command Line – How to

aptcommand linedpkg

I want to list all the files from a source, say extras.ubuntu.com from the command line. What is the command for that?

dpkg --list lists all files or just the filename.

Best Answer

Find the relevant file in /var/lib/apt/lists/ ending in Packages, and perform this command:

# example for deb http://security.ubuntu.com/ubuntu natty-security multiverse
awk '$1 == "Package:" { print $2 }' /var/lib/apt/lists/security*multiverse*Packages

By the way, my extras.ubuntu.com_ubuntu_dists_natty_main_binary-i386_Packages is empty.

EDIT

You could also parse apt-cache output. This script lists all packages with server and repo information:

#!/bin/bash

apt-cache policy $(dpkg -l | awk 'NR >= 6 { print $2 }') |
  awk '/^[^ ]/    { split($1, a, ":"); pkg = a[1] }
    nextline == 1 { nextline = 0; printf("%-40s %-50s %s\n", pkg, $2, $3) }
    /\*\*\*/      { nextline = 1 }'

Sorting conveniently the output you can get the infos you're looking for.