Knowledge Base:Overriding environment variables per package

Synopsis
The default environment variables during package builds are declared in, but sometimes it is desirable to override a particular variable (like CFLAGS or PORTAGE_TMPDIR ) for a single package.

Environment
This article is applicable to all Gentoo Linux installations.

Analysis
Portage supports per-package environment settings through and the  subdirectories.


 * Inside the directory create files that have the same syntax as  and give it a sensible name. The filename will be used as the key to override settings.
 * Inside the file define which of these files will be used on a per-package basis

Resolution
First, create the directory structure. This one will host the files that contain the variable declarations to use:

Next, create the file(s) needed to override the settings. For instance, presume two specific overrides are needed: one is for a package where a slight tweak in the CFLAGS and FEATURES variables results in debug symbols to be built and the other is to update the PORTAGE_TMPDIR value for a package that has a huge build storage requirement:

Finally, create or edit and point towards these override files for the specific packages: