106

is there a command to see what packages are available from a certain ppa repository?

0

6 Answers 6

72

Simple:

 grep -h -P -o "^Package: \K.*" /var/lib/apt/lists/ppa.launchpad.net_*_Packages | sort -u

Or more flexible:

grep-dctrl -sPackage . /var/lib/apt/lists/ppa.launchpad.net_*_Packages 

For fancier querying, use apt-cache policy and aptitude as described here:

aptitude search '~O LP-PPA-gstreamer-developers'
2
  • Use xzcat /var/lib/apt/lists/ppa.launchpad.net_*_Packages.xz | grep '^Package:' if that package file is compressed. Mar 21, 2019 at 18:24
  • You should put single quotes ' around that ^Package:. On zsh ^ has a special meaning.
    – Philippe
    Apr 29, 2020 at 15:35
26
grep Package /var/lib/apt/lists/(repo name)_Packages
2
  • ls /var/lib/apt/lists/*_binary-amd64_Packages | sed -E 's/.*\/([^\/_]*).*/\1/' | sort -u Apr 12, 2020 at 3:09
  • cat /var/lib/apt/lists/AAA.BBB.com_*_Packages | grep '^Package: ' | cut -c 10- | sort -u | nl Apr 12, 2020 at 3:13
8

I don't know if this is what you're looking for:

https://superuser.com/questions/132346/find-packages-installed-from-a-certain-repository-with-aptitude

Like it says, Synaptic Package Manager allows you to search by "origin". This isn't programmatic, but it should give you what you're looking for.

4

Just for fun or if you do not trust the caches, you can query a source's declared packages from, well, the source. The repositories are pretty much websites, either HTTP or FTP.

Your system has source URLs, which you can query for specific architectures and binary/source parameters. Then you can query the specific architecture's package lists.

E.g., I use an excellent jRiver's media player MediaCenter on Pop!_OS. To query their stable repository, which I have configured, first find out the URL:

$ cat /etc/apt/sources.list.d/mediacenter26.list 
#MC
deb [arch=i386,amd64,armhf] http://dist.jriver.com/stable/mediacenter/ jessie main

Then grab the list location for the architecture which interests you. Note that the URL is formed following the pattern <archive_url>/dists/<distro>/Release:

$ curl -s http://dist.jriver.com/stable/mediacenter/dists/jessie/Release |
> grep "amd64/Packages$" |
> cut -d" " -f 4 |
> sort -u
main/binary-amd64/Packages

Finally, append the architecture's list path to the distribution and extract the package names from the lists of signatures:

$ curl -s http://dist.jriver.com/stable/mediacenter/dists/jessie/main/binary-amd64/Packages |
> grep "^Package: " |
> cut -d" " -f2 |
> sort -u
mediacenter21
mediacenter22
mediacenter23
mediacenter24
mediacenter25

Naturally, tune or remove the grep|cut|sort filters to your taste. Remove -s (silent) parameter from curl to see diagnostics if needed.

... or use a Synaptic package manager.

1
  • This is a very nice wrap up on repo architecture, coming in very useful, when you try to look into a repo from a non debian system. Thanks! Jul 22, 2020 at 23:06
3

Old thread, but thought it might help. Use awk, sort and uniq to grab only the packages and discard the Package repo checksums.

grep ^Package /var/lib/apt/lists/<repo you are interested in>* | awk '{print $2}' | sort | uniq
1
  • awk '/^Package: / {print $2}' /var/lib/apt/lists/PACKAGE_REPO | sort -u should do the same
    – Six
    Sep 20, 2020 at 15:43
1

For my use case I wanted a list of packages from multiple repos matching the same dist release, specifically Jessie. This host has multiple jessie repos configured, Dell's linux repo and the Debian archives for some dependencies.

I wound up with this, ahem, one-liner:

for p in $(dpkg -l | awk '/ii/{ print $2 }'); do for i in $(apt-cache policy "$p" | awk '/Installed/{ print $2}'); do apt-cache policy "$p" | grep -A1 '\*\*\*\ '$i'' | if grep -q jessie; then echo $p; fi; done; done

Quite ugly, as we need to run apt-cache twice, once to get the installed version of a package and a second time to match that installed version against the target repo, which conveniently can be matched by just "jessie" in this case.

If you remove the 'grep -q' you'll get output of the matched repo line as well for confirmation, or otherwise. You could adapt this match syntax to regex to match on multiple repos.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .