is there a command to see what packages are available from a certain ppa repository?
7 Answers
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'
I don't know if this is what you're looking for:
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.
- 337
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.
- 161
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.
- 11
To display all package origins, you can use the following command:
apt-cache policy | grep -oE "o=[^,]*"
The text after o= is known as the "pkg-origin" not the URL that follows origin in the output of apt-cache policy (that is the "url-origin"). Using apt-cache policy, you can match "pkg-origins" with "url-origins".
To list all packages from a specific "pkg-origin" use:
aptitude search "?origin (<pkg-origin>)"
To list all installed packages from a specific "pkg-origin," use:
aptitude search "?origin (<pkg-origin>) ?installed"
- 11