apt-file: search for files in packages, installed or not
January 24th, 2007 edited by lucasEntry submitted by Paul Sundvall. DPOTD needs your help, please contribute !
Have you ever tried to compile some tar-ball and had to download missing dependencies? In that case, you probably needed to find out which packages were needed to fix those dependencies. Sometimes there is a README which states what you need, but that might not be that helpful sometimes.
One way of finding out which package needs to be installed is to use the debian package search page.
Another way is to use apt-file instead. It works as a local search engine, based on the apt sources you have in /etc/apt/sources.list.
To use apt-file, build the search database by issuing apt-file update as root. Then, as an ordinary user, search for a file with apt-file search file and you get the package names which contain the file you look for. Install them with apt-get, and your missing dependencies are gone with the wind!
apt-file is located in package apt-file in both Debian and Ubuntu.
after install, build the search database with apt-file update.
Example:
I tried to compile a simple pam example, which gave the following output:
pauls@voltaire:~/code/eget/all/pam$ make gcc pamexample.c -o pamexample -lpam -lpam_misc pamexample.c:12:31: error: security/pam_appl.h: Filen eller katalogen finns inte pamexample.c:13:31: error: security/pam_misc.h: Filen eller katalogen finns inte [...]
Seems like I need the (for me) unknown file pam_appl.h. Time to use apt-file!
pauls@voltaire:~/code/eget/all/pam$ apt-file search pam_appl.h libpam-doc: usr/share/doc/libpam-doc/html/pam_appl.html libpam0g-dev: usr/include/security/pam_appl.h lsb-build-base2: usr/include/lsb2/security/pam_appl.h lsb-build-base3: usr/include/lsb3/security/pam_appl.h pauls@voltaire:~/code/eget/all/pam$
It seems like I should install libpam0g-dev
pauls@voltaire:~/code/eget/all/pam$ su - voltaire:~# apt-get install libpam0g-dev Reading package lists... Done Building dependency tree... Done The following NEW packages will be installed libpam0g-dev 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 118kB of archives. After unpacking 365kB of additional disk space will be used. Get: 1 http://merkel.debian.org unstable/main libpam0g-dev 0.79-4 [118kB] Fetched 118kB in 2s (47.9kB/s) Selecting previously deselected package libpam0g-dev. (Reading database … 123647 files and directories currently installed.) Unpacking libpam0g-dev (from …/libpam0g-dev_0.79-4_i386.deb) … Setting up libpam0g-dev (0.79-4) … voltaire:~#logout
let’s try to compile again:
pauls@voltaire:~/code/eget/all/pam$ make gcc pamexample.c -o pamexample -lpam -lpam_misc pauls@voltaire:~/code/eget/all/pam$
It works!
Posted in Debian, Ubuntu | 5 Comments »