/[gentoo]/xml/htdocs/doc/en/handbook/hb-working-use.xml
Gentoo

Diff of /xml/htdocs/doc/en/handbook/hb-working-use.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.44
1<?xml version='1.0' encoding='UTF-8'?>
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3
1<!-- The content of this document is licensed under the CC-BY-SA license --> 4<!-- The content of this document is licensed under the CC-BY-SA license -->
2<!-- See http://creativecommons.org/licenses/by-sa/1.0 --> 5<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
3 6
4<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-use.xml,v 1.1 2003/11/20 10:52:35 swift Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-use.xml,v 1.44 2006/10/28 09:17:55 neysx Exp $ -->
5 8
6<sections> 9<sections>
10
11<abstract>
12USE-flags are a very important aspect of Gentoo. In this chapter, you learn to
13work with USE-flags and understand how USE-flags interact with your system.
14</abstract>
15
16<version>1.35</version>
17<date>2006-10-08</date>
18
7<section> 19<section>
8<title>What are USE-flags?</title> 20<title>What are USE-flags?</title>
9<subsection> 21<subsection>
10<title>The ideas behind USE-flags</title> 22<title>The ideas behind USE-flags</title>
11<body> 23<body>
12 24
25<p>
26When you are installing Gentoo (or any other distribution, or even operating
27system for that matter) you make choices depending on the environment you are
28working with. A setup for a server differs from a setup for a workstation.
29A gaming workstation differs from a 3D rendering workstation.
30</p>
31
32<p>
33This is not only true for choosing what packages you want to install, but also
34what features a certain package should support. If you don't need OpenGL, why
35would you bother installing OpenGL and build OpenGL support in most of your
36packages? If you don't want to use KDE, why would you bother compiling packages
37with KDE-support if those packages work flawlessly without?
38</p>
39
40<p>
41To help users in deciding what to install/activate and what not, we wanted the
42user to specify his/her environment in an easy way. This forces the user into
43deciding what they really want and eases the process for Portage, our package
44management system, to make useful decisions.
45</p>
46
13</body> 47</body>
14</subsection> 48</subsection>
15<subsection> 49<subsection>
16<title>Definition of a USE-flag</title> 50<title>Definition of a USE-flag</title>
17<body> 51<body>
18 52
53<p>
54Enter the USE-flags. Such a flag is a keyword that embodies support and
55dependency-information for a certain concept. If you define a certain USE-flag,
56Portage will know that you want support for the chosen keyword. Of course
57this also alters the dependency information for a package.
58</p>
59
60<p>
61Let us take a look at a specific example: the <c>kde</c> keyword. If you do not
62have this keyword in your <c>USE</c> variable, all packages that have
63<e>optional</e> KDE support will be compiled <e>without</e> KDE support. All
64packages that have an <e>optional</e> KDE dependency will be installed
65<e>without</e> installing the KDE libraries (as dependency). If you have defined
66the <c>kde</c> keyword, then those packages <e>will</e> be compiled with KDE
67support, and the KDE libraries will be installed as dependency.
68</p>
69
70<p>
71By correctly defining the keywords you will receive a system tailored
72specifically to your needs.
73</p>
74
19</body> 75</body>
20</subsection> 76</subsection>
21<subsection> 77<subsection>
22<title>What USE-flags exist?</title> 78<title>What USE-flags exist?</title>
23<body> 79<body>
80
81<p>
82There are two types of USE-flags: <e>global</e> and <e>local</e> USE-flags.
83</p>
84
85<ul>
86 <li>
87 A <e>global</e> USE-flag is used by several packages, system-wide. This is
88 what most people see as USE-flags.
89 </li>
90 <li>
91 A <e>local</e> USE-flag is used by a single package to make package-specific
92 decisions.
93 </li>
94</ul>
95
96<p>
97A list of available global USE-flags can be found <uri
98link="/dyn/use-index.xml">online</uri> or locally in
99<path>/usr/portage/profiles/use.desc</path>.
100</p>
101
102<p>
103A list of available local USE-flags can be found locally in
104<path>/usr/portage/profiles/use.local.desc</path>.
105</p>
24 106
25</body> 107</body>
26</subsection> 108</subsection>
27</section> 109</section>
28<section> 110<section>
29<title>Using USE-flags</title> 111<title>Using USE-flags</title>
30<subsection> 112<subsection>
31<title>Declare permanent USE-flags</title> 113<title>Declare permanent USE-flags</title>
32<body> 114<body>
33 115
116<p>
117In the hope you are convinced of the importance of USE-flags we will now inform
118you how to declare USE-flags.
119</p>
120
121<p>
122As previously mentioned, all USE-flags are declared inside the <c>USE</c>
123variable. To make it easy for users to search and pick USE-flags, we already
124provide a <e>default</e> USE setting. This setting is a collection of USE-flags
125we think are commonly used by the Gentoo users. This default setting is declared
126in the <path>make.defaults</path> files part of your profile.
127</p>
128
129<p>
130The profile your system listens to is pointed to by the
131<path>/etc/make.profile</path> symlink. Each profile works on top of another,
132larger profile, the end result is therefore the sum of all profiles. The top
133profile is the <path>base</path> profile
134(<path>/usr/portage/profiles/base</path>).
135</p>
136
137<p>
138Let us take a look at this default setting for the 2004.3 profile:
139</p>
140
141<pre caption="Cumulative make.defaults USE variable for the 2004.3 profile">
142<comment>(This example is the sum of the settings in base, default-linux,
143 default-linux/x86 and default-linux/x86/2004.3)</comment>
144USE="x86 oss apm arts avi berkdb bitmap-fonts crypt cups encode fortran f77
145 foomaticdb gdbm gif gpm gtk imlib jpeg kde gnome libg++ libwww mad
146 mikmod motif mpeg ncurses nls oggvorbis opengl pam pdflib png python qt
147 quicktime readline sdl spell ssl svga tcpd truetype X xml2 xmms xv zlib"
148</pre>
149
150<p>
151As you can see, this variable already contains quite a lot of keywords. Do
152<b>not</b> alter any <path>make.defaults</path> file to tailor
153the <c>USE</c> variable to your needs: changes in this file will be undone when
154you update Portage!
155</p>
156
157<p>
158To change this default setting, you need to add or remove keywords to the
159<c>USE</c> variable. This is done globally by defining the <c>USE</c> variable
160in <path>/etc/make.conf</path>. In this variable you add the extra USE-flags you
161require, or remove the USE-flags you don't want. This latter is done by
162prefixing the keyword with the minus-sign ("-").
163</p>
164
165<p>
166For instance, to remove support for KDE and QT but add support for ldap, the
167following <c>USE</c> can be defined in <path>/etc/make.conf</path>:
168</p>
169
170<pre caption="An example USE setting in /etc/make.conf">
171USE="-kde -qt3 -qt4 ldap"
172</pre>
173
174</body>
175</subsection>
176<subsection>
177<title>Declaring USE flags for individual packages</title>
178<body>
179
180<p>
181Sometimes you want to declare a certain USE flag for one (or a couple) of
182applications but not system-wide. To accomplish this, you will need to create
183the <path>/etc/portage</path> directory (if it doesn't exist yet) and edit
184<path>/etc/portage/package.use</path>.
185</p>
186
187<p>
188For instance, if you don't want <c>berkdb</c> support globally but you do want
189it for <c>mysql</c>, you would add:
190</p>
191
192<pre caption="/etc/portage/package.use example">
193dev-db/mysql berkdb
194</pre>
195
196<p>
197You can of course also explicitly <e>disable</e> USE flags for a certain
198application. For instance, if you don't want <c>java</c> support in PHP:
199</p>
200
201<pre caption="/etc/portage/package.use 2nd example">
202dev-php/php -java
203</pre>
204
34</body> 205</body>
35</subsection> 206</subsection>
36<subsection> 207<subsection>
37<title>Declare temporary USE-flags</title> 208<title>Declare temporary USE-flags</title>
38<body> 209<body>
39 210
211<p>
212Sometimes you want to set a certain USE-setting only once. Instead of editing
213<path>/etc/make.conf</path> twice (to do and undo the USE-changes) you can just
214declare the USE-variable as environment variable. Remember that, when you
215re-emerge or update this application (either explicitly or as part of a system
216update) your changes will be lost!
217</p>
218
219<p>
220As an example we will temporarily remove java from the USE-setting
221during the installation of mozilla.
222</p>
223
224<pre caption="Using USE as environment variable">
225# <i>USE="-java" emerge mozilla</i>
226</pre>
227
40</body> 228</body>
41</subsection>
42<subsection> 229</subsection>
43<title>Inheriting USE-flags</title> 230<subsection>
231<title>Precedence</title>
232<body>
233
234<p>
235Of course there is a certain precedence on what setting has priority over the
236USE setting. You don't want to declare <c>USE="-java"</c> only to see that
237<c>java</c> is still used due to a setting that has a higher priority.
238The precedence for the USE setting is, ordered
239by priority (first has lowest priority):
240</p>
241
242<ol>
243 <li>
244 Default USE setting declared in the <path>make.defaults</path> files part of
245 your profile
246 </li>
247 <li>
248 User-defined USE setting in <path>/etc/make.conf</path>
249 </li>
250 <li>
251 User-defined USE setting in <path>/etc/portage/package.use</path>
252 </li>
253 <li>
254 User-defined USE setting as environment variable
255 </li>
256</ol>
257
258<p>
259To view the final <c>USE</c> setting as seen by Portage, run <c>emerge
260--info</c>. This will list all relevant variables (including the <c>USE</c>
261variable) with the content used by Portage.
262</p>
263
264<pre caption="Running emerge --info">
265# <i>emerge --info</i>
266</pre>
267
44<body> 268</body>
269</subsection>
270<subsection>
271<title>Adapting your Entire System to New USE Flags</title>
272<body>
273
274<p>
275If you have altered your USE flags and you wish to update your entire system to
276use the new USE flags, use <c>emerge</c>'s <c>--newuse</c> option:
277</p>
278
279<pre caption="Rebuilding your entire system">
280# <i>emerge --update --deep --newuse world</i>
281</pre>
282
283<p>
284Next, run Portage's depclean to remove the conditional dependencies that
285were emerged on your "old" system but that have been obsoleted by the new USE
286flags.
287</p>
288
289<warn>
290Running <c>emerge --depclean</c> is a dangerous operation and should be handled
291with care. Double-check the provided list of "obsoleted" packages to make sure
292it doesn't remove packages you need. In the following example we add the
293<c>-p</c> switch to have depclean only list the packages without removing them.
294</warn>
295
296<pre caption="Removing obsoleted packages">
297# <i>emerge -p --depclean</i>
298</pre>
299
300<p>
301When depclean has finished, run <c>revdep-rebuild</c> to rebuild the
302applications that are dynamically linked against shared objects provided by
303possibly removed packages. <c>revdep-rebuild</c> is part of the
304<c>gentoolkit</c> package; don't forget to emerge it first.
305</p>
306
307<pre caption="Running revdep-rebuild">
308# <i>revdep-rebuild</i>
309</pre>
310
311<p>
312When all this is accomplished, your system is using the new USE flag settings.
313</p>
45 314
46</body> 315</body>
47</subsection> 316</subsection>
48</section> 317</section>
49<section> 318<section>
50<title>Package specific USE-flags</title> 319<title>Package specific USE-flags</title>
51<subsection> 320<subsection>
52<title>Viewing used USE-flags</title> 321<title>Viewing available USE-flags</title>
53<body> 322<body>
323
324<p>
325Let us take the example of <c>mozilla</c>: what USE-flags does it listen to? To
326find out, we use <c>emerge</c> with the <c>--pretend</c> and <c>--verbose</c>
327options:
328</p>
329
330<pre caption="Viewing the used USE-flags">
331# <i>emerge --pretend --verbose mozilla</i>
332These are the packages that I would merge, in order:
333
334Calculating dependencies ...done!
335[ebuild R ] www-client/mozilla-1.7.12-r2 USE="crypt gnome java mozsvg ssl
336truetype xprint -debug -ipv6 -ldap -mozcalendar -mozdevelop -moznocompose
337-moznoirc -moznomail -moznoxft -postgres -xinerama" 0 kB
338</pre>
339
340<p>
341<c>emerge</c> isn't the only tool for this job. In fact, we have a tool
342dedicated to package information called <c>equery</c> which resides in the
343<c>gentoolkit</c> package. First, install <c>gentoolkit</c>:
344</p>
345
346<pre caption="Installing gentoolkit">
347# <i>emerge gentoolkit</i>
348</pre>
349
350<p>
351Now run <c>equery</c> with the <c>uses</c> argument to view the USE-flags of a
352certain package. For instance, for the <c>gnumeric</c> package:
353</p>
354
355<pre caption="Using equery to view used USE-flags">
356# <i>equery uses =gnumeric-1.6.3 -a</i>
357[ Searching for packages matching =gnumeric-1.6.3... ]
358[ Colour Code : <comment>set</comment> <i>unset</i> ]
359[ Legend : Left column (U) - USE flags from make.conf ]
360[ : Right column (I) - USE flags packages was installed with ]
361[ Found these USE variables for app-office/gnumeric-1.6.3 ]
362 U I
363- - <i>debug</i> : Tells configure and the makefiles to build for debugging.
364 Effects vary across packages, but generally it will at
365 least add -g to CFLAGS. Remember to set FEATURES=nostrip too
366- - <i>gnome</i> : Adds GNOME support
367+ + <comment>python</comment> : Adds support/bindings for the Python language
368- - <i>static</i> : !!do not set this during bootstrap!! Causes binaries to be
369 statically linked instead of dynamically
370</pre>
54 371
55</body> 372</body>
56</subsection> 373</subsection>
57</section> 374</section>
58</sections> 375</sections>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.44

  ViewVC Help
Powered by ViewVC 1.1.20