The Enterprise Linux Resource

Title    Gentoo Portage secrets
Date    2006.08.11 4:01
Author    StoneLion

Gentoo Linux is perhaps the most-used source-based Linux distribution. One secret to its success is the powerful and handy Portage package management system. While Gentoo comes with extensive documentation covering most aspects of using Portage, the techniques described in Gentoo's handbook and other documentation are not always the most effective ones. Here are some insider tips that can greatly increase your productivity.

Search faster

Before you install a package, you usually look for it via Portage's search capabilities. Portage's emerge utility has --search and --searchdesc options, but using them is not enjoyable, because they take a long time to run. That's why we've seen the emergence of third-party search front ends for Portage, such as esearch and eix. Their common idea is to use their own search indexes to speed up searches. When using either utility, you have to rebuild the index after updating the Portage tree, and after installing and uninstalling software.

Of the two, eix works faster and has more capabilities. You can get information on the utility from its man page or by invoking eix --help. To use eix to search for a package whose name contains foo, simply invoke eix foo.

Eix is a very flexible tool. It can give you more information on packages than esearch or emerge -s. It can search through different fields (e.g. package name, category, or description), it can search for regular expressions or wildcard patterns, or do fuzzy searches, and its output can be configured for use in scripts.

Optimizing traffic usage

Updating your software can take a lot of network bandwidth. There are tools that help you decrease Portage's appetite. The most effective and well-known such tool is Deltup, which allows you to download deltas, or the differences between new and old versions of package source. That approach can save you up to 90% of the download size. The procedure for installing deltup is described in the Gentoo wiki.

Using Deltup has its drawbacks, however. Deltup will not resume fetching a delta if you lose a connection. Sometimes, the server generating the deltas is overloaded, and you must wait for a long time for it to generate your delta. Sometimes Deltup gets confused about which versions of packages you have. And, of course, generating a new package takes some CPU time. Still, Deltup should not break your system, so you should not be afraid to give it a try.

KDE maintainers generate the deltas for their packages themselves. This HOWTO describes using these deltas in Gentoo. There was a period when Portage supported a kdexdeltas USE flag, so you did not need to patch your sources manually, but after KDE 3.5 this functionality was not updated, so the kdexdeltas flag will not give you any advantage these days. Note that if you receive errors that report "digest verification failed" when using manually updated KDE sources, you can still install new KDE packages by using the emerge --digest command.

You can use the power of deltas not only when updating source packages, but also when updating your Portage tree. Emerge-delta-webrsync allows you to download daily patches to the Portage tree, which is less traffic-consuming than using emerge --sync. Just invoke emerge emerge-delta-webrsync, and next time you need to sync your Portage tree, run emerge-delta-webrsync

The Gentoo wiki provides more tips for users with poor Internet connections.

A new feature that came in Portage 2.1 can also help speed downloads. If you add the string parallel-fetch to the FEATURES variable in /etc/make.conf, emerge will download some packages' source code while compiling others that are in the queue. This reduces installation time, especially if you emerge many packages.

Faster package compilation

Every time you install or update some software under Gentoo, you need to wait until its source is compiled. Portage supports a set of tools that try to decrease the compiling time of your packages.

One of the ways to speed up compilation on a slow machine is to distribute the compiling task to another host. This is what Distcc aims to do. You can even use Windows boxes to assist in the task.

Ccache makes it possible to speed up compilation of the same code by caching compilation results. Confcache is a similar tool for caching results of test configuration scripts (./configure). It appeared at the same time as Portage 2.1, and still lacks full documentation, but it has been mentioned in the Gentoo Linux Newsletter. After spending some time in the unstable branch, it is now hardmasked, which means that confcache has some unresolved issues; if you try using the current confcache version (0.4.2) you will sometimes need to install some packages with the confcache feature turned off, or clean the confcache cache (rm -rf /var/tmp/confcache).

All the tools mentioned in this section can be used for any compilation tasks. See the appropriate documentation for Distcc, ccache, and confcache (coming later).

Managing logs and configuration files

Another new feature in Portage 2.1 is the new logging framework. Many packages show notices while you emerge them, but you may not see them if you do not watch the emerge process. Now you just need to turn on elog, by adding these lines to /etc/make.conf:
# This sets what to log
PORTAGE_ELOG_CLASSES="warn error log"
# And this is how to do it
and creating the /var/log/portage/elog directory. Now, each package's emerge log will be saved in a separate file in the specified directory. You can find more info on configuring elog by inspecting the /etc/make.conf.example file. There are already GTK and QT graphical front ends for viewing these logs.

After updating some packages you sometimes need to update their configuration files. The standard tool for this is etc-update, but there is a more handy and advanced utility -- dispatch-conf. It automatically updates configuration files that have easy changes to comments, or that have not been changed between updates. It also allows you to redo any changes you made to configuration files by placing them into a version control system.

Would you like to know more?

If these few brief tips have whetted your appetite, you can learn more about most aspects of Portage from its handbook, official documentation, and the Gentoo wiki. If you have any further questions, you may find an answer on the Gentoo forums.


  1. "esearch" -
  2. "eix" -
  3. "Deltup" -
  4. "described" -
  5. "This HOWTO" -
  6. "more tips" -
  7. "Distcc" -
  8. "Windows boxes" -
  9. "Ccache" -
  10. "mentioned in the Gentoo Linux Newsletter" -
  11. "Distcc" -
  12. "ccache" -
  13. "graphical front ends" -
  14. "dispatch-conf" -
  15. "handbook" -
  16. "official documentation" -
  17. "Gentoo wiki" -
  18. "Gentoo forums" -

Copyright 2006 - LiNUX.COM, All Rights Reserved

printed from, Gentoo Portage secrets on 2006-08-24 15:31:23