98

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

opensas
  • 1,111
  • 1
  • 7
  • 7

6 Answers6

69

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'
SebMa
  • 275
  • 1
  • 9
Tobu
  • 4,367
  • 1
  • 23
  • 31
25
grep Package /var/lib/apt/lists/(repo name)_Packages
raerek
  • 648
  • 7
  • 12
7

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.

beatgammit
  • 329
  • 1
  • 10
3

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.

Vlad Didenko
  • 131
  • 2
  • 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! – Aiyion.Prime Jul 22 '20 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
Flup
  • 7,688
  • 1
  • 31
  • 43
luksi1
  • 31
  • 1
  • `awk '/^Package: / {print $2}' /var/lib/apt/lists/PACKAGE_REPO | sort -u` should do the same – Six Sep 20 '20 at 15:43
0

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.

bharrison
  • 1
  • 1