Updated 4 Juin 2019
What are USE flags?
What USE flags are for
When installing Calculate (or any other distribution, indeed), you select features depending on the environment you will be using. Installing a server requires different setup procedures than installing a workstation, while installing a game station is different as well from installing a 3D rendering platform.
This applies not only to which packages to install, but also to which features of those should be supported. If you do not need OpenGL, why would you install it and enable OpenGL support in your software? If you are not going to use KDE, why build packages with KDE support if they can be used without it?
USE flags are an easy way to define the desktop environment. They help users choose what to install or enable and what not. Thus, the user can decide for themselves what they really need and make it easier to work with the Portage package manager.
Let's look at USE flags. A USE flag is a keyword that includes information about the support and dependencies of a particular environment or function. When you define a USE flag, Portage will know that you need support for a specific function. Of course, this may modify the package's dependencies as well.
Let's look at an example - say, the "kde" USE flag. If your USE values do not include this, then all packages that do not need KDE support will be compiled without it. All packages that do not require KDE are compiled without KDE libraries installed by dependencies. If you set "kde" as a USE flag, these packages will be built with KDE support, and KDE will be installed as if required.
By defining your USE flags wisely, you shape a system that is tailored to your needs.
USE flags can be global or local.
- A global USE flag is used by several packages and is system-wide.
- A local USE flag is used by a specific package, as it defines its finer functionality.
A list of the available global USE flags can be either here on the site or locally on your computer, at /usr/portage/profiles/use.desc.
All local USE flags are stored on your computer, at /usr/portage/profiles/use.local.desc.
Using USE flags
Declare permanent USE flags
As we said earlier, any USE flag must be declared in the USE variable. Each Calculate Linux flavour has its own optimized set of USE flags.
The profile your system refers to is defined by the symlink. Each profile is based on a more global one, so that the final profile results from a hierarchy of profiles. The base profile, (/usr/portage/profiles/base) has the highest priority.
For example, have look at the USE flags of the 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, the USE variable is already pretty well defined by appropriate keywords.
To modify those default values, edit the USE variable by adding or removing keywords. Such adding or removing is done globally, i.e. by redefining the USE variable in make.conf. You can add new USE flags or remove the ones you do not need. To remove a flag, prefix it with a minus symbol («-»).
For instance, if you want to remove KDE and QT support while adding ldap support, you should set the following USE values in /etc/portage/make.conf/custom:
USE="-kde -qt ldap"
By default, Calculate Linux uses a binary profile, ignoring your custom USEs. Use the -N (or --newuse) flag to apply the changes immediately for installing or updating packages. Par exemple:
emerge -uN world
Update USE flags for specific packages
Sometimes you need to define some USE flags for specific packages only, not to interfere with system settings. To do this, create a file in /etc/portage/package.use/ and edit it. Name it as you wish.
For instance: you do not need berkdb supported globally, but you do need it in mysql. Here is an example of /etc/portage/package.use/mysql:
Of course, you can explicitly disable USE flags for a specific package. You may, for instance, be wanting to disable Java support for PHP. Here is an example of /etc/portage/package.use/nojava:
Set temporary USE flags
Sometimes, a modified USE flag needs to be applied only once. Rather than double editing /etc/portage/make.conf/custom (first to add something to USE and then to remove it), you can simply declare the relevant USE as an environment variable. Remember that in this case, if afterwards you reinstall or update an application (either expressly or as part of a system update), your previous changes will be lost.
For example, remove 'java' from the USEs for the time of installing Firefox:
USE="-java" emerge firefox
USE values respect, of course, some priority rules. Indeed, you would not want to set only to check if is still enabled because of the higher priority value. USE values are set in the following (ascending) priority:
- the default USE value, declared in the make.defaults files in your profile;
- the user-defined value found in /etc/portage/make.conf/custom;
- the user-defined value found in files in the /etc/portage/package.use/ directory;
- the value defined by the user as an environment value.
emerge --info to check the effective USE settings. This command outputs the values of all variables (including USE) used by Portage:
Adapting you system to the modified USE flags
If you have edited your USE flags and want to update your entire system to the new USE values, run emerge with the
Here is how you can recompile all of your system:
emerge -uDN world
Now run the Portage depclean function to remove conditional dependencies present in the old system, but no longer needed with the new USE flags.
Warning: Running emerge
--depclean) is a risky operation that should be used with caution. Double-check the list of the "unnecessary" packages to make sure that required packages are not removed. In the following example, the
-a parameter is added to make depclean require confirmation before removal.
To delete unnecessary packages, run:
Once depclean has finished, run revdep-rebuild to rebuild the packages that are dynamically linked to the libraries included in possibly removed packages:
Once this completed, your system will have applied the new USE flags.
Package specific USE flags
Viewing available USE flags
For example, what are the USE flags can be used with? To find out, run emerge with the
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
emergeis not the only option, though Note the equery tool, specially designed to provide information about packages. To view USE flags available for a package, run
equery with the
uses argument. Take, for instance, app-office/gnumeric:
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