Knowledge Base:Overriding environment variables per package

Synopsis
The default environment variables during package builds are declared in, but sometimes you want to override a particular variable (like   or  ) 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, you 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, you tell 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 we want to use:

Next, create the file(s) needed to override the settings. For instance, assume we need to specific overrides: one is for a package where we want to tweak the CFLAGS for, the second one we want to update PORTAGE_TMPDIR as the package has a huge build storage requirement.

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