Quantcast
Channel: How to list files of a Debian package without install - Super User
Viewing all articles
Browse latest Browse all 10

Answer by notpeter for How to list files of a Debian package without install

$
0
0

I took @baldoz's http idea and generalized it for Ubuntu and Debian, added a little sed and wrapped it in a bash function one-liner:

function deb_list () { curl -s $(lsb_release -si | sed -e 's Ubuntu https://packages.ubuntu.com ' -e 's Debian https://packages.debian.org ')/$(lsb_release -sc)/all/$1/filelist | sed -n -e '/<pre>/,/<\/pre>/p' | sed -e 's/<[^>]\+>//g' -e '/^$/d'; }

Usage:

$ deb_list curl/usr/bin/curl/usr/share/doc/curl/changelog.Debian.gz/usr/share/doc/curl/copyright/usr/share/doc/curl/NEWS.Debian.gz/usr/share/man/man1/curl.1.gz

Same function on multiple lines:

function deb_list () {    curl -s $(lsb_release -si \                | sed -e 's Ubuntu https://packages.ubuntu.com ' \                      -e 's Debian https://packages.debian.org '              )/$(lsb_release -sc)/all/$1/filelist \      | sed -n -e '/<pre>/,/<\/pre>/p' \      | sed -e 's/<[^>]\+>//g' -e '/^$/d';}

Explained:

  1. lsb_release -si returns "Ubuntu" or "Debian" replace that with the base url https://packages.ubuntu.com or https://packages.debian.org
  2. lsb_Release -sc returns the codename (e.g. "trusty", "sid", etc) use that to build the full URL: https://packages.ubuntu.com/trusty/all/curl/filelist
  3. Fetch that URL with curl and pipe the html through three sed commands. First captures only the file list (what's between <pre> and </pre> tags); second strips out any html tags; third removes any blank lines.

Note: It doesn't search PPAs, alternate apt sources repos and only queries official packages available for the release of debian/ubuntu you are running.


Viewing all articles
Browse latest Browse all 10

Trending Articles