GentoolkitMatt Butcher
John P. Davis
ErwinShyam ManiXavier NeysKarl TrygveJosé Luis RiveroJoshua Saddler
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.
22010-10-03IntroductionWhat 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.

As of now, there are two versions of gentoolkit: app-portage/gentoolkit
and app-portage/gentoolkit-dev. While the former contains administration
scripts, the latter contains scripts specific to help development on Gentoo.
If you are a developer, you can have your scripts included into
gentoolkit-dev by contacting the Gentoolkit maintainer. This document
discusses gentoolkit only.

Gentoolkit contains a whole bunch of useful tools to help manage your packages
and keep track of what is going on in your system. 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 privilege. For that reason, some of the programs may only be
executed (or only function properly) if run by a user with root permission.
Finding Documentation

Any documentation that a program might have (other than man pages) is stored in
/usr/share/doc/gentoolkit-[version]/[program-name]/.

equeryIntroduction

equery is a tool that displays a great deal of useful information about
the packages on your system and much more. equery --help gives you the
full set of options.

Not all features listed by equery --help have been implemented yet.
Those that have not been, are mentioned clearly. You will also see that
every command has a short option, e.g. b instead of belongs.
Be aware that equery currently changes the format of the output if it is sent
through a pipe. The piped format is intended to be easier to parse by tools, but
you can also turn it off by adding the --no-pipe option. If you write
scripts that employ equery, you should be aware of this.
Finding the Package That a File Came From

equery also provides the functionality of finding the package that a
file came from, using belongs command (or just b).

equery is capable of giving us a dependency graph for a specified
package. The dependency graph gives a listing of all the packages that have
direct and indirect dependencies on the package in question.

For example, while glibc is a direct dependency for cdrtools,linux-headers
are an indirect dependency. Note that the output also includes information
about virtual packages. In the example above, cdrtools is actually
written to require virtual/libc, not sys-libs/glibc, but on the given
system in the example sys-libs/glibc provides virtual/libc.

Listing Files Belonging to an Ebuild

equery can list the files that belong to an installed ebuild. If I
don't know the files that Gentoolkit has installed on the system, I will
use equery to show them.

The standard query will search our installed packages for the name given.
If found, the following info will be displayed: the package location between
the first square brackets (I for Installed packages, P for Portage, O for
Overlay), the possible masks between the second (~ by keyword, - by arch or
M hard masked), then the category and complete name and last of all, the slot
in which the package is stored.

Another example, this time we are going to use the local options in order
to look for packages in our portage tree and overlay.

Ever been curious to find out how much space a specific package is occupying?
Since a package could have its files over a number of directories, the usual
du -hc might not give you the correct figure. Not to worry, here comes
equery to the rescue!

As you can see, equery prints the total space used in kilobytes and
also lists the total number of files the package has.

Package-wise list of USE Flags

equery can be used to give us information about what USE flags
are being used by a specific package. It also tells us what our current USE
flags are for a package and also what USE flags are available for the package.

I have installed wireshark with only the gtk and ssl flags set, but there are
several other USE flags for wireshark still available. For more information on
USE flags, please refer to the USE Flags
chapter of the Gentoo Handbook.

Where's the ebuild?

We can also find out which ebuild is being used for a specific package using
equery. This is done by using the equery which command which
displays the full path to the ebuild.

euse is a tool to see, set and unset USE flags at various places. For
more information on USE flags, please refer to the USE Flags.
Please see euse -h for complete help and all options.

Viewing, Setting and Unsetting USE Flags

The euse -a command reads the current active USE flags and displays
them.

There are 5 "columns" that euse now uses to show whether a
flag is set/unset and where all the flag has been set. The columns are as
follows -- +/-, set in the Environment, set in make.Conf, set in make.Defaults,
and set in make.Globals. The output looks like [+ECDG].

Similarly you can use the euse -a -g command to only view active global
USE flags. The euse -a -l command does the same for active local USE
flags.-g & -l are suboptions to euse and need an
option before them (like -a) to function correctly.

We can also use euse to set or unset use flags. The commands used for
this are euse -E flagname (enable a flag) and euse -D flagname
(disable a flag).

Do not use the euse -E or euse -D commands by themselves (without
a flag). It will set/unset ALL USE flags in /etc/make.conf. Although a
backup is kept at /etc/make.conf.euse_backup, please be careful
while using euse -E or euse -D.

euse does not physically remove the flag from make.conf. It just adds a
- (minus) before the flag to unset it. You may have to manually clean up your
make.conf to avoid unwanted variables.
Other toolsrevdep-rebuild

This tool is Gentoo's Reverse Dependency rebuilder. It will scan your installed
ebuilds to find packages that have become broken as a result of an upgrade of a
package they depend on. It can emerge those packages for you but it can also
happen that a given package does not work anymore with the currently installed
dependencies, in which case you should upgrade the broken package to a more
recent version. revdep-rebuild will pass flags to emerge which lets you use the
--pretend flag to see what is going to be emerged again before you go any
further.

If you need to rebuild some packages, you may run revdep-rebuild without
the -p flag and the listed packages will be emerged again.

glsa-check

glsa-check is mainly a test tool that keeps track of the various GLSAs
(Gentoo Linux Security Advisory) and will eventually be integrated into
emerge and equery.

eread

eread is a simple utility to display elog files produced by
>=portage-2.1. You can set the saving of elog files by setting a couple
of variables in /etc/make.conf:

PORTAGE_ELOG_CLASSES="log"
PORTAGE_ELOG_SYSTEM="save"

This is just one way of saving elog messages. For more information on how
Portage's elog system works, please refer to the appropriate page in the Portage
Handbook.

Once you've set up elog to your satisfaction, just run eread to view your
log files.

$ eread
This is a list of portage log items. Choose a number to view that file or type
q to quit.
1) app-portage:gentoolkit-0.2.4_pre2:20070320-000256.log
2) app-portage:gentoolkit-0.2.4_pre2:20070320-000258.log
3) app-portage:gentoolkit-0.2.4_pre2:20070320-000319.log
4) app-portage:gentoolkit-0.2.3:20070320-000408.log
Choice?

Select a number and the file will be displayed using the paging program
specified in the PAGER environment variable. If PAGER is not set, it will use
less.

After displaying the elog item, you will be prompted if you want to delete the
file.

eclean

eclean is a tool to remove old source files and old binary packages from
your system.

When you build and install packages, the source files are downloaded and
preserved in DISTDIR, usually /usr/portage/distfiles. This can
accumulate several gigs of material over time if you don't clean it
periodically. You can run eclean-dist to clean only source files from
DISTDIR.

You can create archives of installed packages by using quickpg or
FEATURES="buildpkg". These archived packages are kept in PKGDIR, usually
/usr/portage/packages. When you no longer need to keep them around,
or if they're too old, you can run eclean-pkg to remove them from PKGDIR.
It's a good way to ensure that any binary packages you have are only the latest
versions.

For more information on eclean and tips on maintaining a cruft-free
system, please read man eclean.