0

This is similar to How can I list all files which have been installed by an APT package? However, I want to know which files will be installed as the package has not been installed, yet.

Example: I wanted to list all files which will be installed by APT package xorg. In other words: all files which will possibly be created when I type apt install xorg. However, apt-file listed only the immediate files of xorg - not of its dependencies:

$ apt-file list xorg
xorg: /usr/share/bug/xorg/script
xorg: /usr/share/doc/xorg/changelog.gz
xorg: /usr/share/doc/xorg/copyright
xorg: /usr/share/lintian/overrides/xorg

How can I list all associated files?

(I will add an awful bash pipe combination as an answer. This is what I'm using right now, but its just a loop with many calls to apt-file and therefore very, very slow. I'm looking for a better answer.)

1

This is what I'm using right now, but it might be buggy and is definitely not very performant:

apt-cache depends xorg | grep '..\(Depends\|Recommends\): [^<]' | sed 's/[^:]*: //' | while read LINE; do [[ -z "$LINE" ]] || apt-file list "$LINE"; done | sed 's/[^:]*: //' | sort

Step-by-step:

Get list of packages which will be installed:

apt-cache depends xorg

Select the "depends" and "recommends" entries:

grep '..\(Depends\|Recommends\): [^<]'

Strip everything except the package name:

sed 's/[^:]*: //'

If the line isn't empty, run apt-file with each package name:

while read LINE; do [[ -z "$LINE" ]] || apt-file list "$LINE"; done

apt-file list returns lines where each line begins with the corresponding package name for the file. Remove package name from line, which leaves only the filename:

sed 's/[^:]*: //'

Sort lines:

sort
1

You can feed apt-file list a list of packages to process in one go, using

apt-file -f-

(to read from standard input). My measurements suggest that

apt-get -s install xorg | awk '/^Inst / { print $2 }' | apt-file -f- list

is over twice as fast as the same process with an apt-file loop (using xargs).

I post-process that with sort -k2,2 since I quite like to see the package involved.

Using apt-get -s install instead of post-processing apt-cache depends xorg means that all the packages which would be installed on your system are taken into account, and only those packages, including recursive dependencies. apt-cache depends xorg only shows xorg’s immediate dependencies and your post-processing doesn’t handle alternatives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.