Difference between revisions of "Creating Unique Environment Variables Per Package"

From Funtoo
Jump to navigation Jump to search
(Created page with "This article describes how to override the global environment variables on a per package basis. == Synopsis == It is possible to override environment variables normally found...")
 
 
Line 9: Line 9:
# ##i## mkdir -p /etc/portage/env
# ##i## mkdir -p /etc/portage/env
}}
}}
The files we put in {{c|/etc/portage/package.env}} have exactly the same format as your [[Make.conf|{{c|/etc/make.conf}}]] file. However in this example we will only insert a single line because that's all we'll need. Let's create a file named small-build that will contain a new CFLAG variable to cause the package to compile to a small executable:
The files we put in {{c|/etc/portage/env}} have exactly the same format as your [[Make.conf|{{c|/etc/make.conf}}]] file. However in this example we will only insert a single line because that's all we'll need. Let's create a file named small-build that will contain a new CFLAG variable to cause the package to compile to a small executable:
{{console|body=
{{console|body=
# ##i## echo 'CFLAGS="-mtune=native -Os -pipe"' > /etc/portage/env/small-build
# ##i## echo 'CFLAGS="-mtune=native -Os -pipe"' > /etc/portage/env/small-build

Latest revision as of 14:45, December 7, 2016

This article describes how to override the global environment variables on a per package basis.

Synopsis

It is possible to override environment variables normally found in /etc/make.conf for specific packages only. By utilizing the configuration file /etc/portage/package.env and subdirectories found in /etc/portage/env .

Solution

The configuration file /etc/portage/package.env and the directory /etc/portage/env don't exist by default. Lets create the necessary directory that will contain the variable declarations to use:

root #  mkdir -p /etc/portage/env

The files we put in /etc/portage/env have exactly the same format as your /etc/make.conf file. However in this example we will only insert a single line because that's all we'll need. Let's create a file named small-build that will contain a new CFLAG variable to cause the package to compile to a small executable:

root #  echo 'CFLAGS="-mtune=native -Os -pipe"' > /etc/portage/env/small-build

Finally we can create or edit /etc/portage/package.env where we can point specific packages toward the new override file we created:

   /etc/portage/package.env
app-office/libreoffice small-build

After these changes when emerging the package app-office/libreoffice the CFLAGS variable in /etc/make.conf will be overridden by the CFLAGS in your new file /etc/portage/env/small-build.