gentoo.LinuxHowtos.orgedit this article

Using qpkg

This tip demonstrates some basic uses of the "query package" (qpkg) which allows you to perform get information about installed or uninstalled packages on your system. It can be used to find package ownership of files, to find duplicate packages, to list the files installed by a package, and more.

To get qpkg you need to install app-portage/gentoolkit.

Code Listing 1: Installing gentoolkit

# emerge app-portage/gentoolkit

Now that you have qpkg installed, you can start using it to examine your system. The first example is figuring out which package owns which file. This is done with the --find-file (or alternatively --find-pattern option.

Note: To get a complete list of packages and the version installed on your machine use the command qpkg --installed --verbose.

Code Listing 2: Finding the package that owns a file

// Which package owns /etc/crontab? 
% qpkg --find-file /etc/crontab 
sys-apps/vcron * 
 
// What version of vcron? (--verbose) 
% qpkg --find-file --verbose /etc/crontab 
sys-apps/vcron-3.0.1-r1 * 
 
// Where's the ebuild for this file? (--verbose --verbose) 
% qpkg --find-file --verbose --verbose /etc/crontab 
   /var/db/pkg/sys-apps/vcron-3.0.1-r1/vcron-3.0.1-r1.ebuild 
sys-apps/vcron-3.0.1-r1 *

To list all the files a package installed, use the --list option.

Code Listing 3: Listing all the files installed by a package

% qpkg --list units 
// Directories were snipped for brevity 
app-sci/units-1.74 * 
CONTENTS: 
/usr/bin/units 
/usr/share/doc/units-1.74 
/usr/share/doc/units-1.74/README.gz 
/usr/share/doc/units-1.74/NEWS.gz 
/usr/share/doc/units-1.74/INSTALL.gz 
/usr/share/doc/units-1.74/COPYING.gz 
/usr/share/doc/units-1.74/ChangeLog.gz 
/usr/share/man/man1/units.1.gz 
/usr/share/info/units.info.gz 
/usr/share/units/units.dat

The last example shows you how to find which packages depend on a specified package using --query-deps.

Code Listing 4: Finding dependencies

% qpkg --installed --query-deps mozilla 
net-www/mozilla-1.4-r3 * 
DEPENDED ON BY: 
        net-mail/evolution-1.4.3 
        net-www/galeon-1.3.9

Note: Not specifying --installed causes qpkg to look inside the entire Portage tree which is probably not what you want.

This should get you started with qpkg. For more options see qpkg --help or man 1 qpkg.

From http://www.gentoo.org/news/en/gwn/20031006-newsletter.xml


rate this article:
current rating: average rating: 1.0 (206 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back