USE flags explained: How Gentoo configures software

From LinuxReviews
Jump to navigationJump to search

USE flags explained: How Gentoo configures software Gentoo Linux gives allows you to control how, and with what support, programs are installed by using USE flags to describe how software should be installed.

Open Source means program code can and will be reused. If there is an existing software library that does a job excellent then it is obvious most developers, lazy as they are, will choose to link against it instead of doing it all over from scratch.

Most programs support a large amount of other programs and libraries. Some are required by all, like glibc, others are optional.

Gentoo Linux compiles all your software from source, unlike distributions like Mandrake, Debian, Suse and Redhat who provide ready to use compiled packages (called deb and rpm). Installing software from source takes much longer, but gives you much more control over how things are installed.

The basics of USE flags[edit]

A software package can be configured and compiled in many ways. An audio application may support many formats, but you may not want or need all of them. Portage uses a variable called 'USE' to control how packages are installed. These are set system-wide in /etc/make.conf, and dictate how packages are installed.

A description of most USE flags are available in the file /usr/portage/profiles/use.desc

The standard settings for your USE flags are available in /etc/make.profile/use.defaults

USE flags are set with flag (not +flag) you want and -flag you don't want.

Example[edit]

The GNU Midnight Commander can be compiled with and without support for gpm (Console-based mouse driver), nls (Native Language Support using gettext), samba (suite of SMB and CIFS client/server programs), ncurses (a console display library), X (Xorg) and slang (a text display library).

You can use the -p (--pretend) parameter to view a packages USE flags and depending packages that would be installed without actually installing anything:

emerge -pv package

For MC (app-misc/mc) this may give you the output:

[ebuild U ] app-misc/mc-4.6.0-r2 [4.6.0-r1] +gpm +nls -samba +ncurses +X +slang

If this is not desired and you want MC installed with samba support and without X support you can change the USE= line in /etc/make.conf to USE="samba -X. This would change the output of emerge -pv MC to

[ebuild U ] app-misc/mc-4.6.0-r2 [4.6.0-r1] +gpm +nls +samba +ncurses -X +slang

Setting pr. package USE flags[edit]

You may want system-wide support for X, but do not want MC linked against it. This can be done by setting the flag before the emerge command when installing it:

USE="-X" emerge mc

Be aware that flags set this way are not stored anywhere, if MC is recompiled during a emerge -u world later the system wide settings will be used.

Make your USE flags permanent on a pr. package basis in /etc/portage/package.use[edit]

The configuration file /etc/portage/package.use allows you to set pr. package USE flags. You must create this folder yourself as it is not done for you. The file should contain category/package thisflag -thatflag. Example:

x11-base/xfree -ipv6
app-misc/mc -X gpm

Flags configured in /etc/portage/package.use override flags set in /etc/make.conf for the packages listed.

gentoolkit allows you to view previously used settings[edit]

qpkg (manual page) is a great portage tool for this. It is included in the package gentoolkit package.

ufed - the use flag editor[edit]

ufed (emerge ufed) is a use flag editor (manual page). It lists all available USE flags and lets you select which you want easily.

ufed saves your choices to /etc/make.conf.

Viewing a list of Gentoo USE flags[edit]

Take a look at /usr/portage/profile/use.desc with a pager like less.