Gentoolkit Matt Butcher John P. Davis Erwin Gentoolkit is a suite of tools to ease the administration of a Gentoo system. This document covers the basics of some of the tools present in Gentoolkit. 1.3 December 1, 2003 Introduction
What is Gentoolkit?

Gentoo is a unique distribution, and presents some complexities that simply don't exist for other distributions. As Gentoo developers and contributors discovered some of these complexities, they also wrote tools to help users and administrators work around them. Many of these tools have been contributed to the Gentoo project, and are included in the package app-portage/gentoolkit.

Gentoolkit contains a whole bunch of useful tools to help manage Portage and the ebuild architecture. Most users -- particularly those who update systems often -- will benefit from having gentoolkit installed.

Installation

Just as with any Gentoo package, installation is just a simple emerge.

# emerge gentoolkit
Many of the tools in gentoolkit reveal important information about your system or require root permissions. For that reason, some of the programs may only be executed (or only function properly) if run by a user with root permissions.
Finding Documentation

At the time of this writing, not all of the programs in gentoolkit are well documented. Some have man pages, but not all. Any documentation that a program might have (other than man pages) is stored in /usr/doc/gentoolkit-[version]/[program-name]/.

Querying Package Data with qpkg
Introduction

qpkg is a flexible tool for determining information about ebuilds, whether installed or not. It can provide information about what files belong to which ebuilds, whether multiple versions of the same package are installed, and what a particular ebuild does.

Calling qpkg with no arguments prints a list of all ebuilds, with asterisks (*) next to the packages that are installed on the system.

By default, qpkg prints output in color. To turn this off on the command line, use the --no-color or -nc flag.
Querying Package Information

One of the most common uses for qpkg is determining what a given package is. For instance, while looking through net-misc, I saw a package called neon. Having no idea what it was, I ran qpkg.

# qpkg -i net-misc/neon
net-misc/neon-0.15.3-r1
       HTTP and WebDAV client library [ http://www.webdav.org/neon ]
net-misc/neon-0.18.5
       HTTP and WebDAV client library [ http://www.webdav.org/neon ]
net-misc/neon-0.19.2
       HTTP and WebDAV client library [ http://www.webdav.org/neon ]
net-misc/neon-0.19.2-r1
       HTTP and WebDAV client library [ http://www.webdav.org/neon ]
net-misc/neon-0.21.1
       HTTP and WebDAV client library [ http://www.webdav.org/neon ]

qpkg read through the ebuild files for the five net-misc/neon ebuilds and printed out the information stored in DESCRIPTION and HOMEPAGE.

Listing Files Belonging to an Ebuild

qpkg can also list the files that belong to an installed ebuild. I Know that gentoolkit installed several tools, but I don't know what they all are. To find out, I can do a qpkg -l.

# qpkg -l app-portage/gentoolkit
app-portage/gentoolkit-0.1.14-r1 *
CONTENTS:
/usr
/usr/share
/usr/share/gentoolkit
/usr/share/gentoolkit/histogram.awk
/usr/share/doc
/usr/share/doc/gentoolkit-0.1.14-r1
/usr/share/doc/gentoolkit-0.1.14-r1/gentool
/usr/share/doc/gentoolkit-0.1.14-r1/gentool/ChangeLog.gz
/usr/share/doc/gentoolkit-0.1.14-r1/lintool
/usr/share/doc/gentoolkit-0.1.14-r1/lintool/checklist-for-ebuilds.gz
/usr/share/doc/gentoolkit-0.1.14-r1/lintool/ChangeLog.gz
/usr/share/doc/gentoolkit-0.1.14-r1/etc-update
/usr/share/doc/gentoolkit-0.1.14-r1/etc-update/ChangeLog.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/qpkg.1.gz
/usr/share/man/man1/lintool.1.gz
/usr/share/man/man1/etc-update.1.gz
/usr/bin
/usr/bin/gentool-bump-revision
/usr/bin/gentool-total-coverage
/usr/bin/gentool-author-coverage
/usr/bin/gentool-package-count
/usr/bin/qpkg
/usr/bin/pkg-size
/usr/bin/lintool
/usr/sbin
/usr/sbin/pkg-clean
/usr/sbin/mkebuild
/usr/sbin/emerge-webrsync
/usr/sbin/epm
/usr/sbin/etc-update
/etc
/etc/etc-update.conf
Finding the Package from Where a File Came

To find the package that a file came from, use the -f or --find-file flag.

# qpkg -f /usr/lib/mozilla
net-www/mozilla *
Listing Duplicate Packages

Sometimes multiple versions of the same package may exist. qpkg --dup will print a list of duplicate packages. The existence of a duplicate package though may not indicate that the older version may be removed. They may fill different slots. To look for duplicates in the same slot, use qpkg --dups --slot. I just updated KDE from 3.0 to 3.0.2, so I have some duplicates in the same slot.

# qpkg --dups --slot
app-portage/gentoolkit
kde-base/kdeaddons
kde-base/kdeadmin
kde-base/kdeartwork
kde-base/kdebase
kde-base/kdegames
kde-base/kdelibs
kde-base/kdemultimedia
kde-base/kdenetwork
kde-base/kdetoys
kde-base/kdeutils
media-libs/freetype
x11-libs/qt
Verifying Package Integrity

Sometimes it is useful to check a package's integrity to know that files have not been replaced since they were installed. qpkg can verify md5 sums as well as install times to indicate whether or not files for the package might have been corrupted, replaced, or removed.

To check both mtimes and md5 sums, use the -c flag.

# qpkg gnupg -c -v
app-crypt/gnupg-1.0.6 *
/usr/lib/gnupg/rndunix !md5! !mtime!
/usr/lib/gnupg/rndegd !md5! !mtime!
/usr/lib/gnupg/tiger !md5! !mtime!
/usr/bin/gpg !md5! !mtime!
/usr/bin/gpgv !md5! !mtime!
/usr/share/gnupg/options.skel !md5! !mtime!
/usr/share/gnupg/FAQ !md5! !mtime!
/usr/share/gnupg/faq.html !md5! !mtime!
/usr/share/locale/da/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/de/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/eo/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/et/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/fr/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/id/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/it/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/ja/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/nl/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/pl/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/pt_BR/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/sv/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/locale/tr/LC_MESSAGES/gnupg.mo !md5! !mtime!
/usr/share/info/gpgv.info.gz !md5! !mtime!
/usr/share/man/man1/gpg.1.gz !md5! !mtime!
/usr/share/man/man1/gpgv.1.gz !md5! !mtime!
24/92

app-crypt/gnupg-1.0.7 *
0/101

As you can see, I have more than one version of GnuPG installed. qpkg reports that many of the files from the older version have been changed since I installed it. Those packages were most likely modified when I updated from gnupg-1.0.6 to gnupg-1.0.7. Note that the last two lines indicate that 0 of 101 files from gnupg-1.0.7 have been changed since I installed. That is good. If any of them had been changed, I would be worried.

But Wait... There's More

qpkg can be used for other querying tasks that I will not go over here. There is a very complete manpage for qpkg. Consult that for more information.

lintool
Introduction

lintool is a program that checks ebuild scripts for conformance to standards and requirements. It is important for ebuild developers to use lintool to ensure that they are doing things correctly and not requiring the core team to do more than they already have to in order to include the ebuild in the Gentoo repository.

Use

Running lintool will produce a nicely formatted list of checks and results that it performs.

# lintool app-crypt/gnupg/gnupg-1.0.7.ebuild
app-crypt/gnupg/gnupg-1.0.7.ebuild                                     : Not OK

-------------------------------------------------------------------------------
 Summary for all 1 ebuild(s) checked                             # errors/warns
 -------------------------------------------------------------------------------
 Testing for illegal space characters, weird backslash formatting  : 0 / 0
 Testing for malformed headers                                     : 0 / 1
 Testing for occurence of deprecated try                           : 0 / 0
 Testing for superfluous A=${P}.tar.gz                             : 0 / 0
 Testing for empty DEPEND                                          : 0 / 0
 Testing for empty HOMEPAGE                                        : 0 / 0
 Testing for empty DESCRIPTION                                     : 0 / 0
 Testing for presence of env vars                                  : 1 / 1
 Testing for sane USE flag usage                                   : 0 / 0

 Total number of ebuilds with errors                               : 1 (100%)
 Total number of ebuilds with warnings                             : 1 (100%)

The first line summarizes whether the ebuild is okay or not. In the case of gnupg-1.0.7.ebuild, it's not. Reading through the list of checks, we can see that it got a warning for malformed headers and an error for presence of env vars.

Looking at the ebuild, I see that it is missing a couple of required env vars (LICENSE and RDEPEND). Adding those fixes the error. But there are still two warnings -- one for malformed headers and one for env vars. To help me find those, I can run lintool again with --show-details

 
# lintool --show-details ./gnupg-1.0.7.ebuild

-------------------------------------------------------------------------------
# Some data cut for brevity....

 Status for ./gnupg-1.0.7.ebuild
* Testing for malformed headers                                         : passed
- (W) Has illegal or suspect headers:
 |Suspect copyright year: # Copyright 1999-2000 Gentoo Technologies, Inc.
 * Testing for occurence of deprecated try                               : passed
 * Testing for superfluous A=${P}.tar.gz                                 : passed
 * Testing for empty DEPEND                                              : passed
 * Testing for empty HOMEPAGE                                            : passed
 * Testing for empty DESCRIPTION                                         : passed
 * Testing for presence of env vars                                      : passed
 - (W) Missing SLOT=
 * Testing for sane USE flag usage                                       : passed

 -------------------------------------------------------------------------------
  Summary for all 1 ebuild(s) checked                             # errors/warns
  -------------------------------------------------------------------------------
  Testing for illegal space characters, weird backslash formatting  : 0 / 0
  Testing for malformed headers                                     : 0 / 1
  Testing for occurence of deprecated try                           : 0 / 0
  Testing for superfluous A=${P}.tar.gz                             : 0 / 0
  Testing for empty DEPEND                                          : 0 / 0
  Testing for empty HOMEPAGE                                        : 0 / 0
  Testing for empty DESCRIPTION                                     : 0 / 0
  Testing for presence of env vars                                  : 0 / 1
  Testing for sane USE flag usage                                   : 0 / 0

  Total number of ebuilds with errors                               : 0 (0%)
  Total number of ebuilds with warnings                             : 1 (100%)

Now I can see that the year in the ebuild is probably wrong, and that it is missing the SLOT variable. Fixing those eliminates all warnings.

epm
Introduction

epm is a package managing tool that clones Red Hat rpm commands. As it stands now, it does not offer all of the features of rpm, but it offers some of the more powerful rpm query options.

It also handles removing packages, which is not covered here. Use epm --help to learn more about deleting packages with epm.

Querying Packages with epm

epm functions with essentially the same command line functions as Red Hat's rpm. epm -qa lists all packages installed. epm -ql lists all the files from a specific ebuild.

# epm -ql ethereal
/usr/lib/ethereal/plugins/0.8.20/gryphon.so
/usr/lib/ethereal/plugins/0.8.20/gryphon.la
/usr/lib/ethereal/plugins/0.8.20/gryphon.a
/usr/lib/ethereal/plugins/0.8.20/mgcp.so
/usr/lib/ethereal/plugins/0.8.20/mgcp.la
/usr/lib/ethereal/plugins/0.8.20/mgcp.a
/usr/lib/ethereal/plugins/0.8.20/cosnaming.so
/usr/lib/ethereal/plugins/0.8.20/cosnaming.la
/usr/lib/ethereal/plugins/0.8.20/cosnaming.a
/usr/lib/ethereal/plugins/0.8.20/coseventcomm.so
/usr/lib/ethereal/plugins/0.8.20/coseventcomm.la
/usr/lib/ethereal/plugins/0.8.20/coseventcomm.a
/usr/bin/ethereal
/usr/bin/editcap
/usr/bin/mergecap
/usr/bin/tethereal
/usr/bin/text2pcap
/usr/bin/idl2eth
/usr/share/man/man1/idl2eth.1.gz
/usr/share/man/man1/tethereal.1.gz
/usr/share/man/man1/text2pcap.1.gz
/usr/share/man/man1/editcap.1.gz
/usr/share/man/man1/ethereal.1.gz
/usr/share/man/man1/mergecap.1.gz
/usr/share/doc/ethereal-0.8.20/AUTHORS.gz
/usr/share/doc/ethereal-0.8.20/COPYING.gz
/usr/share/doc/ethereal-0.8.20/NEWS.gz
/usr/share/doc/ethereal-0.8.20/ChangeLog.gz
/usr/share/doc/ethereal-0.8.20/README.gz
/usr/share/doc/ethereal-0.8.20/INSTALL.configure.gz
/usr/share/doc/ethereal-0.8.20/TODO.gz
/usr/share/doc/ethereal-0.8.20/README.aix.gz
/usr/share/doc/ethereal-0.8.20/README.bsd.gz
/usr/share/doc/ethereal-0.8.20/README.hpux.gz
/usr/share/doc/ethereal-0.8.20/README.irix.gz
/usr/share/doc/ethereal-0.8.20/README.linux.gz
/usr/share/doc/ethereal-0.8.20/README.tru64.gz
/usr/share/doc/ethereal-0.8.20/README.win32.gz
/usr/share/doc/ethereal-0.8.20/README.vmware.gz
/etc/ethereal/manuf

epm offers a few advanced query options that are not present in qpkg at the time of this writing. For instance, it can query for just configuration files or just documentation files.

# epm -qc ethereal
/etc/ethereal/manuf

# epm -qd ethereal
/usr/share/man/man1/idl2eth.1.gz
/usr/share/man/man1/tethereal.1.gz
/usr/share/man/man1/text2pcap.1.gz
/usr/share/man/man1/editcap.1.gz
/usr/share/man/man1/ethereal.1.gz
/usr/share/man/man1/mergecap.1.gz
/usr/share/doc/ethereal-0.8.20/AUTHORS.gz
/usr/share/doc/ethereal-0.8.20/COPYING.gz
/usr/share/doc/ethereal-0.8.20/NEWS.gz
/usr/share/doc/ethereal-0.8.20/ChangeLog.gz
/usr/share/doc/ethereal-0.8.20/README.gz
/usr/share/doc/ethereal-0.8.20/INSTALL.configure.gz
/usr/share/doc/ethereal-0.8.20/TODO.gz
/usr/share/doc/ethereal-0.8.20/README.aix.gz
/usr/share/doc/ethereal-0.8.20/README.bsd.gz
/usr/share/doc/ethereal-0.8.20/README.hpux.gz
/usr/share/doc/ethereal-0.8.20/README.irix.gz
/usr/share/doc/ethereal-0.8.20/README.linux.gz
/usr/share/doc/ethereal-0.8.20/README.tru64.gz
/usr/share/doc/ethereal-0.8.20/README.win32.gz
/usr/share/doc/ethereal-0.8.20/README.vmware.gz
epm --help lists the options that epm will eventually support. Note, however, that options prefixed with asterisks (*) are not yet implemented.
Others
etc-update

etc-update provides a convenient alternative to updating configuration files by hand. After running an emerge that changes configuration files, you can run etc-update to step you through the process of updating all impacted configuration files.

It is driven by a menu-based interface and includes the ability to view and merge in config files before deciding what to do.

gentool

gentool is a collective name for several small scripts that analyze ebuild statistics. For instance, gentool-total-coverage prints a list of email addresses and the number of ebuilds each has in the portage tree.

pkg-size

pkg-size prints the size of the installed files in a given package.

# pkg-size nmap
net-analyzer/nmap-2.54_beta24-r1 897024 (876KB)
mkebuild

mkebuild simplifies the process of creating a new ebuild by automating as much of the process as possible. Running mkebuild [filename] will create an ebuild for that file. the file should be an archive of some kind. As it works, it will provide feedback about changes you may need to make.

emerge-webrsync

Downloads the daily snapshot over HTTP with wget, and (optionally) syncs with portage.