list all packages from a repository in ubuntu / debian

120,426

Solution 1

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'

Solution 2

grep Package /var/lib/apt/lists/(repo name)_Packages

Solution 3

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.

Solution 4

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

Solution 5

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.

Share:
120,426

Related videos on Youtube

opensas
Author by

opensas

Updated on September 18, 2022

Comments

  • opensas
    opensas over 1 year

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

  • randomness2077
    randomness2077 about 5 years
    Use xzcat /var/lib/apt/lists/ppa.launchpad.net_*_Packages.xz | grep '^Package:' if that package file is compressed.
  • Mathieu CAROFF
    Mathieu CAROFF about 4 years
    ls /var/lib/apt/lists/*_binary-amd64_Packages | sed -E 's/.*\/([^\/_]*).*/\1/' | sort -u
  • Mathieu CAROFF
    Mathieu CAROFF about 4 years
    cat /var/lib/apt/lists/AAA.BBB.com_*_Packages | grep '^Package: ' | cut -c 10- | sort -u | nl
  • Philippe
    Philippe about 4 years
    You should put single quotes ' around that ^Package:. On zsh ^ has a special meaning.
  • Aiyion.Prime
    Aiyion.Prime almost 4 years
    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!
  • Six
    Six over 3 years
    awk '/^Package: / {print $2}' /var/lib/apt/lists/PACKAGE_REPO | sort -u should do the same