How to list packages from a ppa/source in command line?

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.


I would just check directly on the server-side, like that:

$ curl -s http://extras.ubuntu.com/ubuntu/dists/maverick/main/binary-i386/Packages.gz |
  gzip -d | grep Package
Package: news
Package: suspended-sentence

I made a terrible script for that:

#!/bin/bash
clear
##array aufbauen
declare -a repoList=()
for i in $(ls /var/lib/apt/lists/ | grep _Packages)
do
    #echo $i
    repoList=("${repoList[@]}" "$i")
done

repoAnzahl=${#repoList[@]}
echo "Anzahl der Repos: " $repoAnzahl

for ((i=0;$i<$repoAnzahl;i++))
do
    if [[ "${repoList[$i]}" =~ "archive.ubuntu" ]]
    then
    rname=${repoList[$i]##*archive.ubuntu}
    echo "$i RepoName: " "${rname%%_binary*}"
    elif [[ "${repoList[$i]}" =~ "ubuntu" ]]
    then
    echo "$i RepoName: " "${repoList[$i]%%_ubuntu*}"
    else
    echo "$i RepoName: " "${repoList[$i]%%_dist*}"
    fi
done

read -p "Gib die RepoNummer ein: " repoNummer

packages=()
for i in $(cat /var/lib/apt/lists/${repoList[$repoNummer]} | grep Package)
do
    if ! [[ "$i" =~ "Package" ]]
    then
    packages=("${packages[@]}" "$i")
    fi
done

paketAnzahl=${#packages[@]}
echo "Anzahl der pakete: " $paketAnzahl

function listPackages () {
    for ((i=0;$i<$paketAnzahl;i++))
    do
    echo ${packages[$i]}
    done
}

if test $paketAnzahl -gt 20
then
    listPackages | less
else
    listPackages
fi

echo "Anzahl der Pakete: " $paketAnzahl