Knowledge Base:Overriding environment variables per package
The default environment variables during package builds are declared in
/etc/portage/make.conf, but sometimes you want to override a particular variable (like
PORTAGE_TMPDIR) for a single package.
This article is applicable to all Gentoo Linux installations.
Portage supports per-package environment settings through
/etc/portage/package.env and the
- Inside the
/etc/portage/envdirectory, you create files that have the same syntax as
make.confand give it a sensible name. The filename will be used as the key to override settings.
- Inside the
/etc/portage/package.envfile, you tell which of these files will be used on a per-package basis
First, create the
/etc/portage/env directory structure. This one will host the files that contain the variable declarations we want to use:
Next, create the file(s) needed to override the settings. For instance, assume we need two specific overrides: one is for a package where we want to tweak the CFLAGS and FEATURES resulting in debug symbols to be built and the second one we want to update PORTAGE_TMPDIR as the package has a huge build storage requirement.
Finally, create or edit
/etc/portage/package.env and point towards these override files for the specific packages:
- /etc/portage/env on the Gentoo Wiki