How I can list all packages a apt repository serves? Specifically before adding the repository to my system would be preferred.
1 Answer
The best option I know is to reproduce the http get apt generates, by hand, and grep it for packages; something like
Check the deb line of the repository,
$ cat /etc/apt/sources.list.d/<name>.list
deb <url> <dist> <name>
Build a request like: (this can be tricky)
$ curl -H 'User-Agent: Debian APT-HTTP/1.3' <url>/dists/<dist>/Release
# or $ curl -H 'User-Agent: Debian APT-HTTP/1.3' <url>/dists/<dist>/Release.gz | gunzip
Codename: <dist>
Architectures: amd64
Components: <name>
MD5Sum:
......66b4456ffdb000e8208d5d8ee5 287832 <name>/binary-amd64/Packages
......b4b8e5fe8d2d53588e745a3d20 47099 <name>/binary-amd64/Packages.gz
......d98f00b204e9800998ecf8427e 0 <name>/binary-i386/Packages
......9941158dbf2ac8332307610a5b 20 <name>/binary-i386/Packages.gz
...
That will tell you about the releases on this repository server Build a second request:
$ curl -H 'User-Agent: Debian APT-HTTP/1.3' <url>/dists/<dist>/<name>/binary-amd64/Packages | grep Package: | uniq
# or $ curl -H 'User-Agent: Debian APT-HTTP/1.3' <url>/dists/<dist>/<name>/binary-amd64/Packages.gz | gunzip | grep Package: | uniq
Package: mypacakge
Package: myotherpacakge
Change your arch as necessary, the previous release file should describe the paths and architectures well.
this is pretty tedious and heavy lifted, I hope someone can recommended a better option for this kind of check.
-
if anyone is interested in a script that does what this answer says, I committed it here: github.com/knocte/fsx/commit/…– knocteDec 24, 2019 at 3:19
-
1once upon a time
dpkg-query --show --available
would have worked for apt, however the--available
flag was disabled and dpkq-query can no longer enumerate the apt available list anymore. also, bash completion for apt somehow gets a list, so there is probably a robust sample there too Feb 11, 2022 at 23:15