User:Waldo Lemmer//etc/portage

From Gentoo Wiki
Jump to:navigation Jump to:search

This article demonstrates a way to keep the Portage configuration under /etc/portage/ organized.

Warning
Do not copy the compiler flags on this page. Most of these will produce binaries that are not runnable, and the rest can cause hard-to-diagnose build and runtime failures and are unsupported by Gentoo. See the Safe CFLAGS article for safer compiler flags.

package.accept_keywords/

These files are divided such that all irrelevant flags can be omitted when setting up a new system by only copying files over that are relevant. For example, if power saving applications are needed, the following files can be copied to /etc/portage:

  • package.accept_keywords/power-saving
  • package.use/power-saving
  • sets/power-saving
FILE package.accept_keywords/anki
# 2024-06-03
# required by anki
=app-misc/anki-24.04.1 ~amd64
=dev-python/protobuf-python-4.23.3 ~amd64

# required by dev-libs/protobuf-23.3-r2::gentoo
=dev-cpp/abseil-cpp-20230802.0 ~amd64
# required by dev-python/protobuf-python-4.23.3::gentoo
=dev-libs/protobuf-23.3-r2 ~amd64
FILE package.accept_keywords/zz-autounmask
# `emerge --autounmask-write` appends lines to the last file in
# 'package.accept_keywords' (lexicographically).
# This file catches these.

package.env and env/

package.env allows per-package overrides of MAKEOPTS, CFLAGS and other variables typically defined in make.conf.

FILE package.env
# Disables -Ofast and -flto for certain packages. See the warning at the top of this page if you consider using -Ofast and -flto yourself.
app-crypt/tpm2-tss               -O3
app-emulation/wine-proton        -O3
dev-lang/duktape                 -O3
dev-lang/luajit                  -O3
dev-libs/double-conversion       -O3
dev-qt/qtbase                    -O3
dev-qt/qtcore                    -O3
dev-qt/qtdeclarative             -O3
dev-qt/qtwebengine               --jobs=9
dev-util/intel-graphics-compiler -distcc # Build failure
dev-util/spirv-tools             -fno-lto
net-libs/nodejs                  -O3
sys-apps/systemd                 no-Ofast -O3
sys-auth/polkit                  -O3
sys-boot/plymouth                -O3
FILE env/-O3
COMMON_FLAGS="${COMMON_FLAGS} -O3"
CFLAGS="${CFLAGS} -O3"
CXXFLAGS="${CXXFLAGS} -O3"
FCFLAGS="${FCFLAGS} -O3"
FFLAGS="${FFLAGS} -O3"
LDFLAGS="${LDFLAGS} -O3 -Wl,-O3"
FILE env/-distcc
FEATURES="-distcc"
FILE env/--jobs=9
MAKEOPTS="${MAKEOPTS} --jobs=9"
FILE env/meaningful-backtraces
FEATURES="${FEATURES} splitdebug"

# This does not need to be this messy.
COMMON_FLAGS="${COMMON_FLAGS} -O2 -ggdb -fno-omit-frame-pointer"
CFLAGS="${CFLAGS} -O2 -ggdb -fno-omit-frame-pointer"
CXXFLAGS="${CFLAGS} -O2 -ggdb -fno-omit-frame-pointer"
FCFLAGS="${FCFLAGS} -O2 -ggdb -fno-omit-frame-pointer"
FFLAGS="${FFLAGS} -O2 -ggdb -fno-omit-frame-pointer"
LDFLAGS="${LDFLAGS} -O2 -Wl,-O2 -ggdb -fno-omit-frame-pointer"

package.use/

It is typically preferred to configure USE flags in package.use instead of in make.conf.

The scheme followed here is similar to that of package.accept_keywords/ above. Package atoms are prefixed with = instead of the default >= in order to avoid flags being applied to newer versions of packages where they are no longer needed. Note that this creates extra work after updates and requires the ability to deal with any conflicts emerge might throw at the user.

FILE package.use/00-waldo
*/* custom-cflags jumbo-build lto pgo

sys-auth/pambase -passwdqc # The default password requirements are terrible. See
                           # https://explainxkcd.com/wiki/index.php/936:_Password_Strength
app-alternatives/sh -* dash
sys-kernel/linux-firmware savedconfig
FILE package.use/1335u
# Generated with cpuid2cpuflags
# This is tailored to a specific system. Using these flags on
# a different system will render it unusable.
*/* cpu_flags_x86: -* aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 ssse3 vpclmulqdq
*/* video_cards: -* intel
FILE package.use/anki
# required by (app-misc/anki-23.12.1:0/0::gentoo, installed) USE="gui -debug -qt6 -test" ABI_X86="(64)" PYTHON_SINGLE_TARGET="python3_11 -python3_10 -python3_12"
dev-qt/qtgui:5 jpeg

# required by (dev-qt/qtwebengine-5.15.13_p20240322:5/5.15::gentoo, ebuild scheduled for merge) USE="jumbo-build pulseaudio screencast system-icu widgets -alsa -bindist -debug -designer -geolocation -kerberos -test" ABI_X86="(64)"
dev-libs/libxml2 icu

# to avoid dejavu dependency
=media-video/vlc-3.0.20 fontconfig

Arranging package atoms by date helps to identify stale flags. This is demonstrated in package.use/wine-proton below.

FILE package.use/wine-proton
# required by wine-proton
=media-libs/vulkan-loader-1.3.280.0 X

# required by a bunch of stuff
# 2024-05-12
=app-arch/bzip2-1.0.8-r5                 abi_x86_32
=app-arch/lz4-1.9.4                      abi_x86_32
# -- dozens of similar lines  --
=x11-libs/pixman-0.43.4                  abi_x86_32
=x11-libs/xcb-util-keysyms-0.4.1         abi_x86_32

# 2024-05-15
=dev-libs/libusb-1.0.27-r1               abi_x86_32

# 2024-05-16
=media-libs/mesa-24.0.7                  abi_x86_32
FILE package.use/zz-autounmask
# `emerge --autounmask-write` appends lines to the last file in
# 'package.use' (lexicographically).
# This file catches these.

sets/

FILE sets/00-waldo
app-admin/sudo
app-editors/neovim
app-eselect/eselect-repository
dev-vcs/git
sys-apps/lsd
sys-devel/distcc
sys-kernel/linux-firmware
FILE sets/anki
app-misc/anki
dev-python/orjson # for faster database operations