Functionality of Portage

Updated 8 Septembre 2019

Portage features

Portage provides some additional features. Many of them are backed up by specific applications that increase productivity, reliability, safety, etc.

To enable or disable Portage features, you must edit the /etc/portage/make.conf/custom variable in the FEATURES+, which lists space-separated feature keywords. Sometimes it is necessary to install additional utilities to be able to use the features you need.

This is only a brief overview of Portage features. To read the full list, refer to the make.conf man page.

To find out which features are enabled by default, run emerge --info and look for the FEATURES variable (or filter with grep):

emerge --info | grep FEATURES

Distributed compilation

Using distcc

distcc is a tool that distributes the compilation process to several, not necessarily identical, network computers. The distcc client sends all relevant data to the available distcc servers (which, in their turn, call distccd) so that they can compile some parts of the source code for the client. What you gain is a faster compilation time.

Installing distcc

Distcc comes with a graphical monitor, which is a control tool that allows you to track the compilation tasks performed by your computer. If you are a Gnome user, add "gnome" to the USE values. If you are not a Gnome user but still want to use its graphical environment, add "gtk" to USE.

Install distcc:

emerge distcc

Enabling support for Portage

Add distcc to the FEATURES variablе in /etc/portage/make.conf/custom. Then edit the MAKEOPTS value at your convenience. Известная рекомендация - указывать директиву "-jX", где X - число центральных процессоров, на которых работает distccd (включая текущий компьютер) плюс один. However, you can also achieve improved experience with other values.

Now run distcc-config and enter the list of available distcc servers. To simplify, let the available DistCC servers be 192.168.1.102 (current computer), 192.168.1.103 and 192.168.1.104 (two "remote" computers):

distcc-config --set-hosts "192.168.1.102 192.168.1.103 192.168.1.104"

Launch the distccd daemon:

rc-update add distccd default

/etc/init.d/distccd start

Cached compilation

About the ccache tool

ccache is a fast compiler cache. When you compile a program, it caches intermediate results so that whenever you recompile the same program, the compilation time is significantly reduced. In typical cases, the total compilation time can be reduced by 5 to 10 times.

More information about ccache can be found on the project website.

Installing ccache

To install ccache, run emerge ccache:

emerge ccache

Enabling support for Portage

Open /etc/portage/make.conf/custom and add ccache to FEATURES. Then add a new variable named CCACHE_SIZE and set it to "2G":

CCACHE_SIZE="2G"

To check ask for ccache stats:

ccache -s

Since Portage uses a different home directory for ccache, you must also set the CCACHE_DIR variable:

CCACHE_DIR="/var/tmp/ccache"

The default home directory of ccache is /var/tmp/ccache. To modify this, define the CCACHE_DIR variable in /etc/portage/make.conf/custom.

However, the default directory, ${HOME}/.ccache, is used when starting ccache, so the CCACHE_DIR variable must be defined when requesting Portage statistics for ccache.

Using ccache for non-Portage compilation in C

If you want to use ccache for non-Portage compilations, add /usr/lib/ccache/bin at the beginning of your PATH variable value (before /usr/bin). This can be done by editing /etc/env.d/00basic, which is the first file in the environment where the PATH variable is defined:

PATH="/usr/lib/ccache/bin:/opt/bin"

Binary support

Creating prebuilt (binary) packages

Installing prebuilt packages is also supported by Portage. Although most Calculate Linux flavours come with prebuilt packages, the number of packages is limited. Or else you may also need to include packages with customized USE flags.

To create a binary package, you can use quickpkg if the package is already installed on your system, or emerge with either the --buildpkg or --buildpkgonly option.

If you want Portage to create binary packages for each package you install, add buildpkg to the FEATURES variable in /etc/make.conf.

Installing binary packages

Calculate Linux uses binary repositories for update, which contain packages included in the respective system image. Each of Calculate flavours has both a source profile and a (default) binary profile. The binary profile provides one stable version only for each binary package.

Note that you must update portage with the cl-update command before installing a binary package from the repository.

Other than masking, the profile sets the FEATURES+ variable to getbinpkg, thus giving priority to binary packages.

The path to the storage is set in the PORTAGE_BINHOST variable of your Calculate profile. For instance, /etc/portage/make.conf/custom contains paths to alternative storage hosts.

You can also install prebuilt packages within a common profile. To do this, specify the -g (or --getbinpkg) parameter together with -k (or --usepkg) when running emerge. The first option tells emerge to download the specified binary from the previously defined server, and the second option advises emerge to try installing the binary first before fetching the source code and compiling it.

For instance, if you want to install a prebuilt version of gnumeric:

emerge -kg gnumeric

To learn more on the installation parameters applicable related to prebuilt packages, refer to the emerge man page.