Configuring your system with variables

Updated 25 September 2019

Configuring Portage

As we mentioned [earlier] (files_and_directories), Portage can be configured with many variables, to be set in the /etc/portage/make.conf file.

Compilation options

Configuration and compilation

When Portage builds applications, the following variables are passed to the compiler and to the configuration script:

  • CFLAGS and CXXFLAGS define the desired compilation flags for C and C++
  • CHOST provides platform information for the configuration script
  • MAKEOPTS+ is passed to the make command and is usually used to set the level of parallel compilation. More detailed information about the parameters of make can be found on the make main page.

The USE variable is also used in configuration and compilation. It is covered in detail in previous chapters.

Installation options

When Portage installs (merges) a new version of software, older versions are removed from the system. Portage gives user five seconds before actually deleting the older versions. These 5 seconds are defined by CLEAN_DELAY.

Protection of configuration files

Locations protected by Portage

Portage writes files provided by the newer version of a package on top of the old ones, unless those are located in a protected location. Which directories to protect is defined by the CONFIG_PROTECT variable. This is usually where configuration files are located. Directories must be space-separated.

The file to be written to a protected directory is renamed and the user is warned if there is a new version (usually) of the configuration file.

To find out the current value of CONFIG_PROTECT, read the output of emerge --info:

emerge --info | grep 'CONFIG_PROTECT='

To learn more about how Portage protects configuration files, use the emerge command:

emerge --help config

Excluded directories

Use CONFIG_PROTECT_MASK to unprotect specific subdirectories in a protected directory.

Download options

Server location

If the requested information or data is not available on your system, Portage looks for it online. The following variables define the locations for information channels:

  • GENTOOO_MIRRORS stores the list of servers providing source code, or Distfiles.
  • PORTAGE_BINHOST defines the location of the server that hosts prebuilt (binary) packages for your system

The third variable stores the location of the rsync server, which is used to update your Portage tree:

  • SYNC defines the server where Portage retrieves the Portage tree from.

Variables GENTOO_MIRRORS and SYNC can also be set automatically by mirrorselect. Install it first, by running emerge mirrorselect. For information, refer to the mirrorselect help page:

mirrorselect --help

If you have to use a proxy server, you can edit HTTP_PROXY, FTP_PROXY and RSYNC_PROXY to set its address.

Commands for extraction

When Portage needs to extract source code, wget is used by default. This behaviour can be modified by editing the FETCHCOMMAND value.

Portage can resume previously aborted fetching source code. The default is wget, but this can be modified by editing RESUMECOMMAND.

Make sure that FETCHCOMMAND and RESUMECOMMAND save the code in the right place. Inside these variables, use \${URI} and \${DISTDIR} to define the location of the source code and the distfiles, respectively.

It is also possible to edit specific protocol settings: consider editing FETCHCOMMAND_HTTP, FETCHCOMMAND_FTP, RESUMECOMMAND_HTTP, RESUMECOMMAND_FTP, etc.

Rsync configuration

The rsync command that Portage uses to update the Portage tree cannot be replaced, but it is possible to edit variables that define its behavior:

  • RSYNC_EXCLUDEFROM+ contains the path to the list of the packages and/or categories that rsync must ignore when updating.
  • RSYNC_RETRIES defines how often rsync must try connecting to the mirror specified in the SYNC variable. The default value is 3.
  • RSYNC_TIMEOUT+ defines how long (in seconds) a rsync connection can remain idle before it is considered to have exceeded the waiting time. The default value is 180, but if you are using a modem connection or have an old computer, you may want to set this variable to 300 or more.

Gentoo configuration

Selecting a branch

You can switch between branches by redefining ACCEPT_KEYWORDS. By default, stable is used. Your architecture will be detected automatically. More information about Gento branches can be found in the next chapter.

Portage functionality

To finely tune Portage functionality, feel free to edit the FEATURES variable. The functionality of Portage has been discussed in previous chapters, such as [Portage Features] (portage_features).

How Portage behaves

Resource allocation

The PORTAGE_NICENESS+ variable is used to increase or decrease the nice value applied to Portage. The PORTAGE_NICENESS value _is added to the current nice value.

To learn more about nice parameters, refer to the man page:

man nice

Output configuration

The NOCOLOR variable ("false" by default) defines whether Portage turns off coloring in its messages.