Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Portage

From atl.wiki
Portage
Release Status Maintained
Last Release portage-3.0.65 (2024-06-04)[1]
Language(s) Bash, Python
Developer(s) Gentoo
Website wiki.gentoo.org/wiki/Project:Portage
A binary version of the package 'git' being installed via portage.

Portage is considered the heart of every Gentoo and Gentoo-based distribution and it performs most key functions on Gentoo systems. A part of Portage is also the package manager, although every package is managed by emerge. Every package installed using Portage is compiled from source, which optimizes it for your system and allows them to be more secure, although binaries are available if the user likes.

Configuration

Configuration of Portage is done through various configuration files and folders found in /etc/portage, which allows configuration of features such as USE flags, default options, masked packages and more.

make.conf

make.conf is the main configuration file for Portage. It allows the configuration of system-wide USE flags, Portage features, accepted licenses and more. This file is regularly edited during the Gentoo installation process and during ordinary use of it, so it's very important to get the options right for it. Below are some of the most relevant ones.

COMMON_FLAGS, CFLAGS, CXXFLAGS, FCFFLAGS and FFLAGS

These variables determine the build and compile flags that will be used for all package compilations. The CFLAGS variable is for C applications, while the CXXFLAGS one is meant for C++ ones. Most users will keep these variables identical.

A "safe" configuration to avoid compilation errors should look like this:

COMMON_FLAGS="-march=native -O2 -pipe"

CFLAGS="${COMMON_FLAGS}"

CXXFLAGS="${COMMON_FLAGS}"

FCFLAGS="${COMMON_FLAGS}"

FFLAGS="${COMMON_FLAGS}"

MAKEOPTS

The MAKEOPTS variable is used to specify arguments that will be passed to Make during compilation.

A good rule of thumb is to set the -j argument to about half your RAM size and the -l argument to the thread count of your CPU, which can be found by running nproc. For example, if you have 4 GB of RAM and a 6th generation Intel Core i3, your MAKEOPTS variable should look something like this:

MAKEOPTS="-j2 -l4"

GENTOO_MIRRORS

The GENTOO_MIRRORS variable tells Portage what mirror(s) to download the packages from. It can be set manually by editing the variable with a link to the mirror(s) of your liking available here, or automatically via mirrorselect, which can select the fastest mirror(s) for you.

It's highly recommended to set this variable to a mirror close to you, for example, if you want to use an Italian mirror you would have to edit the variable like this:

GENTOO_MIRRORS="https://gentoo.mirror.garr.it/"

FEATURES

The FEATURES variable contains a list of features that you can enable which notably alters the behavior of Portage. For example, if you want to use binary packages and verify their signatures, you would have to set the variable like this:

FEATURES="getbinpkg binpkg-request-signature"

EMERGE_DEFAULT_OPTS

The EMERGE_DEFAULT_OPTS variable contains the options that will be automatically set when running Portage every time. For example, if you want Portage to ask for confirmation and verbose output, you would set the variable to this:

EMERGE_DEFAULT_OPTS="--ask --verbose"

USE

The USE variable allows the system-wide enabling or disabling of USE flags. An example of this variable may look like this:

USE="pulseaudio X systemd dbus policykit udisks dist-kernel -alsa -wayland xwayland"

USE_EXPAND

USE_EXPAND is a set of variables that serve to extend the capabilities of USE flags. Below are the most relevant ones.

VIDEO_CARDS

VIDEO_CARDS is a variable that serves to specify the drivers you wish to install for your GPUs. For example, if you want to install the drivers for AMD and Intel graphics, you would set the variable to this:

VIDEO_CARDS="amdgpu radeonsi intel"

CPU_FLAGS_*

The CPU_FLAGS_* variables specify the available features that your CPU has to optimize compiling packages. The currently available variables are CPU_FLAGS_X86 (for x86 and x86_64 architectures), CPU_FLAGS_ARM (for ARM and ARM64 architectures) and CPU_FLAGS_PPC (for PowerPC and PowerPC64 architectures).

The cpuid2cpuflags utility can be used to find these flags. The output of this command may look something like this:

CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sse sse2 sse3 sse4_1 sse4_2 ssse3

The output can then be copied to make.conf.

ACCEPT_LICENSE

The ACCEPT_LICENSE variable can be used to tell Portage which type of licenses are allowed.

Generally, it's preferred to not accept proprietary software licenses. To allow every license except proprietary ones, you can set the variable to this:

ACCEPT_LICENSE="* -@EULA"