Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Creating Unique Environment Variables Per Package

From Funtoo
Jump to navigation Jump to search

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.