3.2 USE flags

What are USE flags?

The ideas behind USE flags

When you are installing Calculate (or any other distribution for that matter), you make choices depending on the environment you are working with. A setup for a server differs from a setup for a workstation. A gaming workstation differs from a 3D rendering workstation.

This is not only true for choosing what packages you want to install, but also what features a certain package should support. If you don't need OpenGL, why would you bother installing OpenGL and build OpenGL support in most of your packages? If you don't want to use KDE, why would you bother compiling packages with KDE support if those packages work flawlessly without?

USE flags are an easy way to specify the user's environment, helping help users in deciding what to install/activate and what not. This forces the user into deciding what they really want and eases the process for the package management system, Portage.

Definition of a USE flag

Enter the USE flags. USE flag is a keyword that embodies support and dependency-information for a certain concept. If you define a certain USE flag, Portage will know that you want support for the chosen keyword. Of course this also alters the dependency information for a package.

Let us take a look at a specific example: the kde keyword. If you do not have this keyword in your USE variable, all packages that have optional KDE support will be compiled without KDE support. All packages that have an optional KDE dependency will be installed without installing the KDE libraries (as dependency). If you have defined the kde keyword, then those packages will be compiled with KDE support, and the KDE libraries will be installed as dependency.

By correctly defining the keywords you will receive a system tailored specifically to your needs.

What USE flags exist?

There are two types of USE flags: global and local USE flags.

  • A global USE flag is used by several packages, system-wide. This is what most people see as USE flags.
  • A local USE flag is used by a single package to make package-specific decisions.

The list of available global USE flags can be found here or locally in /usr/portage/profiles/use.desc.

The list of local USE flags is stored on your system in /usr/portage/profiles/use.local.desc.

Using USE flags

Declaring permanent USE flags

As previously mentioned, all USE flags are declared inside the USE variable. Each Calculate Linux distro has its collection of USE flags which have been optimized for particular tasks.

The profile your system listens to is pointed to by the /etc/make.profile symlink. Each profile works on top of another, larger profile, the end result is therefore the sum of all profiles. The top profile is the base profile (/usr/portage/profiles/base).

Let us take a look at the default USE flags setting for Calculate Directory Server profile:

...
USE="acl amd64 bash-completion berkdb bittorrent bzip2 cli cracklib crypt cups cxx dri exif foomaticdb fortran ftp gdbm gif gpm iconv imap ipv6 jpeg jpeg2k ldap logrotate maildir mmx modules mudflap multilib ncurses nfs nls nptl nptlonly openmp pam pcre perl png pppd python radius readline samba session sse sse2 ssl sysfs tcpd tiff truetype unicode userlocales xorg zlib" ...

As you can see, this variable already contains quite a lot of keywords.

To change this default setting, you need to add or remove keywords in the USE variable. This is done globally by defining the USE variable in /etc/make.conf. In this variable you add the extra USE flags you require, or remove the USE flags you do not want. This latter is done by prefixing the keyword with the minus-sign («-»).

For instance, to remove support for KDE and QT but add support for ldap, the following USE variable can be defined in /etc/make.conf:

USE="-kde -qt ldap"

Calculate Linux distros use a binary profile by default, which ignores any modifications you make to USE flags. For these modifications to take effect, use the -N (or --newuse) argument when emerging or updating packages. Here is an example:

emerge -uN world

Declaring USE flags for individual packages

Sometimes you want to declare a certain USE flag for one or a couple of applications but not system-wide. To accomplish this, you will need to create a file in the /etc/portage/package.use/ directory and edit it. You can choose any name you like for this file.

For instance, if you do not want berkdb support globally but you do want it for mysql. This is what the /etc/portage/package.use/mysql file would look like:

dev-db/mysql berkdb

You can of course also explicitly disable USE flags for a certain application. For instance, if you do not want java support in PHP, your /etc/portage/package.use/nojava file will look like that:

dev-php/php -java

Declaring temporary USE flags

Sometimes you want to set a certain USE setting only once. Instead of editing /etc/make.conf twice (to do and undo the USE changes) you can just declare the USE variable as environment variable. Remember that when you re-emerge or update this application (either explicitly or as part of a system update) your changes will be lost!

As an example we will temporarily remove java from the USE setting during the installation of firefox:

USE="-java" emerge firefox

Precedence

Of course there is a certain precedence on what setting has priority over the USE setting. You would not want to declare USE="-java" only to see that java is still used due to a setting that has a higher priority. The precedence for the USE setting is, ordered by priority (first has lowest priority):

  • default USE setting declared in the make.defaults files part of your profile
  • user-defined USE setting in /etc/make.conf
  • user-defined USE setting in /etc/portage/package.use
  • user-defined USE setting as environment variable

To view the final USE settings as seen by Portage, run emerge --info. This will list all relevant variables (including the USE variable) with the content used by Portage.

emerge --info

Adapting your entire system to new USE flags

If you have altered your USE flags and you wish to update your entire system to use the new USE flags, use emerge's --newuse option.

To update the whole of your system with the new USE flags, enter:

emerge -uDN world

Next, run emerge --depclean to remove the conditional dependencies that were emerged on your "old" system but that have been obsoleted by the new USE flags.

Warning: Running emerge -c (or emerge --depclean) is a dangerous operation and should be handled with care. Double-check the provided list of "obsoleted" packages to make sure it doesn't remove packages you need. In the following example we add the -a switch to have depclean ask for approval before removing packages.

Removing obsolete packages:

emerge -ac

When depclean has finished, run revdep-rebuild to rebuild the applications that are dynamically linked against libraries provided by possibly removed packages:

revdep-rebuild

When all this is accomplished, your entire system will be using the new USE flag settings.

Package specific USE flags

Viewing available USE flags

Let us take the example of firefox: what USE flags does it listen to? To find out, we use emerge with the -p (or --pretend) and the -v (or --verbose) options:

# emerge -pv firefox
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] www-client/firefox-3.6.13  USE="alsa bindist custom-optimization dbus ipc libnotify -gnome -java -startup-notification -system-sqlite -wifi" LINGUAS="bg de en es fr it pl pt_BR ru uk -af -ar -as -be -bn -bn_BD -bn_IN -ca -cs -cy -da -el -en_GB -en_US -eo -es_AR -es_CL -es_ES -es_MX -et -eu -fa -fi -fy -fy_NL -ga -ga_IE -gl -gu -gu_IN -he -hi -hi_IN -hr -hu -id -is -ja -ka -kk -kn -ko -ku -lt -lv -mk -ml -mr -nb -nb_NO -nl -nn -nn_NO -oc -or -pa -pa_IN -pt -pt_PT -rm -ro -si -sk -sl -sq -sr -sv -sv_SE -ta -ta_LK -te -th -tr -vi -zh_CN -zh_TW" 0 kB

Emerge is not the only tool for this job. There is a tool dedicated to package information called equery. Now run equery with the uses argument to view the USE flags of a certain package. Let it be the gnumeric package:

# equery uses app-office/gnumeric-1.10.13 -a
[ Searching for packages matching app-office/gnumeric-1.10.13... ]
[ Colour Code : set unset ]
[ Legend : Left column  (U) - USE flags from make.conf              ]
[        : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for app-office/gnumeric-1.10.13 ]
 U I
 - - gnome  : Adds GNOME support
 + + perl   : Adds support/bindings for the Perl language
 + + python : Adds support/bindings for the Python language
Thank you!