Portage Advanced Usage

From Elvanör's Technical Wiki
Jump to navigation Jump to search

This article lists some neat things you can do with Portage/emerge.

File locations

/etc/portage directory

This directory contains important configuration files for Portage.

  • package.accept_keywords lets you add keywords for individual packages. To allow unkeyworded packages to be installed, write app-emulation/wine ** in this file. You do not need to write it in package.mask.
  • package.use lets you add local USE flags for certain packages. To add/remove certain languages, you can use expanded USE flags:
USE="linguas_en -linguas_fr"
  • Note that on these two files, each line must contain only the package name and the options. Don't add any comment (comments must use a whole line) after the package name and options.
  • You can use package.env and the env directory to have per package FEATURES. See this page for more information.

Portage world file

It is located in /var/lib/portage/world.

Portage cache

It is located in /var/cache/edb.

revdep-rebuild cache files

They are in /var/cache/revdep-rebuild (no longer in /root).

emerge options

  • --newuse will recompile packages that had their USE flags changed.
  • --depclean will attempt to remove packages that are no longer needed as dependencies.
  • --fetchonly will only fetch the distribution files.
  • -t will display a tree view. It can be very useful to know which package pulls in another one.
  • -O will disable any dependency check (both on the dependencies of the emerged packages, and on already installed packages to see if an upgrade would not satisfy them). It can be a very useful options when there are bugs in the Gentoo tree and you really need to upgrade a package without checking dependencies.
  • To emerge a particular version of a package: emerge =mypackage-0.6.3-r2

Variables

  • CONFIG_PROTECT and CONFIG_PROTECT_MASK can be set in /etc/make.conf and control the behavior of the configuration protection feature. Note that turn it off in /etc, you must set CONFIG_PROTECT_MASK="/etc", it is not enough to set CONFIG_PROTECT="".

Features

  • Collision protection cannot apparently be disabled, even with -collision-protect and -protect-owned. The only way to partly disable it is to use the environment variable COLLISION_IGNORE with a list of directories (those are not recursively ignored).

Disabling test feature

  • You can add a file in /etc/portage/env/dev-python/pygtk (for instance) with the following content:
FEATURES=${FEATURES/test/}

Gentoolkit

  • equery files ebuild_name will list all the files installed by the specified ebuild.
  • qfile /path/to/file will display which package provides that particular file. It can sometimes be useful (it searches in all packages in repository, not only in installed ones).

Profiles

  • Profiles contain default configuration values and settings.
  • For a server machine, don't use the server profile. It is not yet production-ready. Use the generic profile, eg default/linux/x86/2008.0 (for a desktop box, use default/linux/x86/2008.0/desktop).

Updating operations

  • If you update a major Python version (eg, 2.5 to 2.6), you must run python-updater to ensure a smooth transition. Be careful to run python-updater before emerge --depclean, as the remerge is much more difficult if the old python version is not there anymore.

Troubleshooting

  • If an ebuild fails to emerge because of memory issues (not enough RAM), you should change MAKEOPTS="-j9" to MAKEOPTS="-j1" temporarily. This will allow only a single compiling thread to run, thus reducing overall memory usage and solving the issue.

Useful Links