1 |
<?xml version='1.0' encoding='UTF-8'?> |
2 |
<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> |
3 |
|
4 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
5 |
<!-- See http://creativecommons.org/licenses/by-sa/1.0 --> |
6 |
|
7 |
<!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-use.xml,v 1.13 2004/05/07 07:42:53 swift Exp $ --> |
8 |
|
9 |
<sections> |
10 |
<section> |
11 |
<title>What are USE-flags?</title> |
12 |
<subsection> |
13 |
<title>The ideas behind USE-flags</title> |
14 |
<body> |
15 |
|
16 |
<p> |
17 |
When you are installing Gentoo (or any other distribution, or even operating |
18 |
system for that matter) you make choices depending on the environment you are |
19 |
working with. A setup for a server differs from a setup for a workstation. |
20 |
A gaming workstation differs from a 3D rendering workstation. |
21 |
</p> |
22 |
|
23 |
<p> |
24 |
This is not only true for choosing what packages you want to install, but also |
25 |
what features a certain package should support. If you don't need OpenGL, why |
26 |
would you bother installing OpenGL and build OpenGL support in most of your |
27 |
packages? If you don't want to use KDE, why would you bother compiling packages |
28 |
with KDE-support if those packages work flawlessly without? |
29 |
</p> |
30 |
|
31 |
<p> |
32 |
To help users in deciding what to install/activate and what not, we wanted the |
33 |
user to specify his/her environment in an easy way. This forces the user into |
34 |
deciding what they really want and eases the process for Portage, our package |
35 |
managment system, to make useful decisions. |
36 |
</p> |
37 |
|
38 |
</body> |
39 |
</subsection> |
40 |
<subsection> |
41 |
<title>Definition of a USE-flag</title> |
42 |
<body> |
43 |
|
44 |
<p> |
45 |
Enter the USE-flags. Such a flag is a keyword that embodies support and |
46 |
dependency-information for a certain concept. If you define a certain USE-flag, |
47 |
Portage will know that you want support for the chosen keyword. Of course |
48 |
this also alters the dependency information for a package. |
49 |
</p> |
50 |
|
51 |
<p> |
52 |
Let us take a look at a specific example: the <c>kde</c> keyword. If you do not |
53 |
have this keyword in your <c>USE</c> variable, all packages that have |
54 |
<e>optional</e> KDE support will be compiled <e>without</e> KDE support. All |
55 |
packages that have an <e>optional</e> KDE dependency will be installed |
56 |
<e>without</e> installing the KDE libraries (as dependency). If you have defined |
57 |
the <c>kde</c> keyword, then those packages <e>will</e> be compiled with KDE |
58 |
support, and the KDE libraries will be installed as dependency. |
59 |
</p> |
60 |
|
61 |
<p> |
62 |
By correctly defining the keywords you will receive a system tailored |
63 |
specifically to your needs. |
64 |
</p> |
65 |
|
66 |
</body> |
67 |
</subsection> |
68 |
<subsection> |
69 |
<title>What USE-flags exist?</title> |
70 |
<body> |
71 |
|
72 |
<p> |
73 |
There are two types of USE-flags: <e>global</e> and <e>local</e> USE-flags. |
74 |
</p> |
75 |
|
76 |
<ul> |
77 |
<li> |
78 |
A <e>global</e> USE-flag is used by several packages, system-wide. This is |
79 |
what most people see as USE-flags. |
80 |
</li> |
81 |
<li> |
82 |
A <e>local</e> USE-flag is used by a single package to make package-specific |
83 |
decisions. |
84 |
</li> |
85 |
</ul> |
86 |
|
87 |
<p> |
88 |
A list of available global USE-flags can be found <uri |
89 |
link="/dyn/use-index.xml">online</uri> or locally in |
90 |
<path>/usr/portage/profiles/use.desc</path>. A short (<e>very</e> incomplete) |
91 |
snippet: |
92 |
</p> |
93 |
|
94 |
<pre caption="A short snippet of available USE-flags"> |
95 |
gtk - Adds support for x11-libs/gtk+ (The GIMP Toolkit) |
96 |
gtk2 - Use gtk+-2.0.0 over gtk+-1.2 in cases where a program supports both. |
97 |
gtkhtml - Adds support for gnome-extra/gtkhtml |
98 |
guile - Adds support for dev-util/guile (interpreter for Scheme) |
99 |
icc - Use the Intel C++ Compiler if the package supports it |
100 |
icc-pgo - Enable PGO data generation or use when use icc. |
101 |
imap - Adds support for IMAP |
102 |
</pre> |
103 |
|
104 |
</body> |
105 |
</subsection> |
106 |
</section> |
107 |
<section> |
108 |
<title>Using USE-flags</title> |
109 |
<subsection> |
110 |
<title>Declare permanent USE-flags</title> |
111 |
<body> |
112 |
|
113 |
<p> |
114 |
In the hope you are convinced of the importance of USE-flags we will now inform |
115 |
you how to declare USE-flags. |
116 |
</p> |
117 |
|
118 |
<p> |
119 |
As previously mentioned, all USE-flags are declared inside the <c>USE</c> |
120 |
variable. To make it easy for users to search and pick USE-flags, we already |
121 |
provide a <e>default</e> USE setting. This setting is a collection of USE-flags |
122 |
we think are commonly used by the Gentoo users. This default setting is declared |
123 |
in the <path>/etc/make.profile/make.defaults</path> file. Let us take a look at |
124 |
this default setting: |
125 |
</p> |
126 |
|
127 |
<pre caption="/etc/make.profile/make.defaults USE variable on an x86 system"> |
128 |
USE="x86 oss apm arts avi berkdb crypt cups encode foomaticdb gdbm gif gpm |
129 |
gtk gtk2 imlib jpeg kde gnome libg++ libwww mad mikmod motif mpeg ncurses |
130 |
nls oggvorbis opengl pam pdflib png python qt quicktime readline sdl |
131 |
slang spell ssl svga tcpd truetype X xml2 xmms xv zlib" |
132 |
</pre> |
133 |
|
134 |
<p> |
135 |
As you can see, this variable already contains quite a lot of keywords. Do |
136 |
<b>not</b> alter the <path>/etc/make.profile/make.defaults</path> file to tailor |
137 |
the <c>USE</c> variable to your needs: changes in this file will be undone when |
138 |
you update Portage! |
139 |
</p> |
140 |
|
141 |
<p> |
142 |
To change this default setting, you need to add or remove keywords to the |
143 |
<c>USE</c> variable. This is done globally by defining the <c>USE</c> variable |
144 |
in <path>/etc/make.conf</path>. In this variable you add the extra USE-flags you |
145 |
require, or remove the USE-flags you don't want. This latter is done by |
146 |
prefixing the keyword with the minus-sign ("-"). |
147 |
</p> |
148 |
|
149 |
<p> |
150 |
For instance, to remove support for KDE and QT but add support for ldap, the |
151 |
following <c>USE</c> can be defined in <path>/etc/make.conf</path>: |
152 |
</p> |
153 |
|
154 |
<pre caption="An example USE setting in /etc/make.conf"> |
155 |
USE="-kde -qt ldap" |
156 |
</pre> |
157 |
|
158 |
</body> |
159 |
</subsection> |
160 |
<subsection> |
161 |
<title>Declare temporary USE-flags</title> |
162 |
<body> |
163 |
|
164 |
<p> |
165 |
Sometimes you want to set a certain USE-setting only once. Instead of editing |
166 |
<path>/etc/make.conf</path> twice (to do and undo the USE-changes) you can just |
167 |
declare the USE-variable as environment variable. |
168 |
</p> |
169 |
|
170 |
<p> |
171 |
As an example we will temporarily remove java from the USE-setting |
172 |
during the installation of mozilla. |
173 |
</p> |
174 |
|
175 |
<note> |
176 |
The <c>emerge</c> command will be discussed more thoroughly in <uri |
177 |
link="?part=2&chap=2">Portage and Software</uri>. |
178 |
</note> |
179 |
|
180 |
<pre caption="Using USE as environment variable"> |
181 |
# <i>USE="-java" emerge mozilla</i> |
182 |
</pre> |
183 |
|
184 |
</body> |
185 |
</subsection> |
186 |
<subsection> |
187 |
<title>Inheriting USE-flags</title> |
188 |
<body> |
189 |
|
190 |
<p> |
191 |
Some packages don't only listen to USE-flags, but also provide USE-flags. When |
192 |
you install such a package, the USE-flag they provide is added to your USE |
193 |
setting. To view the list of packages that provide a USE-flag, check |
194 |
<path>/etc/make.profile/use.defaults</path>: |
195 |
</p> |
196 |
|
197 |
<pre caption="A snippet from /etc/make.profile/use.defaults"> |
198 |
gnome gnome-base/gnome |
199 |
gtk x11-libs/gtk+ |
200 |
qt x11-libs/qt |
201 |
kde kde-base/kdebase |
202 |
motif x11-libs/openmotif |
203 |
</pre> |
204 |
|
205 |
</body> |
206 |
</subsection> |
207 |
<subsection> |
208 |
<title>Precendence</title> |
209 |
<body> |
210 |
|
211 |
<p> |
212 |
Of course there is a certain precendence on what setting has priority over the |
213 |
USE setting. You don't want to declare <c>USE="-java"</c> only to see that |
214 |
<c>java</c> is declared anyway. The precedence for the USE setting is, ordered |
215 |
by priority (first has lowest priority): |
216 |
</p> |
217 |
|
218 |
<ol> |
219 |
<li> |
220 |
Default USE setting declared in <path>/etc/make.profile/make.defaults</path> |
221 |
</li> |
222 |
<li> |
223 |
Inherited USE setting if a package from |
224 |
<path>/etc/make.profile/use.defaults</path> is installed |
225 |
</li> |
226 |
<li> |
227 |
User-defined USE setting in <path>/etc/make.conf</path> |
228 |
</li> |
229 |
<li> |
230 |
User-defined USE setting as environment variable |
231 |
</li> |
232 |
</ol> |
233 |
|
234 |
<p> |
235 |
To view the final <c>USE</c> setting as seen by Portage, run <c>emerge info</c>. |
236 |
This will list all relevant variables (including the <c>USE</c> variable) with |
237 |
the content used by Portage. |
238 |
</p> |
239 |
|
240 |
<pre caption="Running emerge info"> |
241 |
# <i>emerge info</i> |
242 |
</pre> |
243 |
|
244 |
</body> |
245 |
</subsection> |
246 |
<subsection> |
247 |
<title>Adapting your Entire System to New USE Flags</title> |
248 |
<body> |
249 |
|
250 |
<p> |
251 |
If you have altered your USE flags and you wish to update your entire system to |
252 |
use the new USE flags, you can try following the next steps to accomplish this. |
253 |
Note however that these steps will take a long time to finish and that work is |
254 |
on the way to adjust Portage to handle this behaviour quicker and automatically. |
255 |
</p> |
256 |
|
257 |
<p> |
258 |
First of all, rebuild your entire system using the new USE flags: |
259 |
</p> |
260 |
|
261 |
<pre caption="Rebuilding your entire system"> |
262 |
# <i>emerge --emptytree world</i> |
263 |
</pre> |
264 |
|
265 |
<p> |
266 |
Next, run Portage' depclean to remove the conditional dependencies that |
267 |
were emerged on your "old" system but that have been obsoleted by the new USE |
268 |
flags. |
269 |
</p> |
270 |
|
271 |
<warn> |
272 |
Running <c>emerge depclean</c> is a dangerous operation and should be handled |
273 |
with care. Double-check the provided list of "obsoleted" packages to make sure |
274 |
it doesn't remove packages you need. In the following example we add the |
275 |
<c>-p</c> switch to have depclean only list the packages without removing them. |
276 |
</warn> |
277 |
|
278 |
<pre caption="Removing obsoleted packages"> |
279 |
# <i>emerge -p depclean</i> |
280 |
</pre> |
281 |
|
282 |
<p> |
283 |
When depclean has finished, your system is using the new USE flag settings. |
284 |
</p> |
285 |
|
286 |
</body> |
287 |
</subsection> |
288 |
</section> |
289 |
<section> |
290 |
<title>Package specific USE-flags</title> |
291 |
<subsection> |
292 |
<title>Viewing available USE-flags</title> |
293 |
<body> |
294 |
|
295 |
<p> |
296 |
In the next chapter on <uri link="?part=2&chap=2">Portage and Software</uri> |
297 |
we will explain how to manage your installed software and how to work with |
298 |
<c>emerge</c>. However, we will give you a primer on <c>emerge</c> by showing |
299 |
you how to view what USE-flags a package uses. |
300 |
</p> |
301 |
|
302 |
<p> |
303 |
Let us take the example of <c>mozilla</c>: what USE-flags does it listen to? To |
304 |
find out, we use <c>emerge</c> with the <c>--pretend</c> (don't really do |
305 |
anything) and <c>--verbose</c> (give more output) options: |
306 |
</p> |
307 |
|
308 |
<pre caption="Viewing the used USE-flags"> |
309 |
# <i>emerge --pretend --verbose mozilla</i> |
310 |
These are the packages that I would merge, in order: |
311 |
|
312 |
Calculating dependencies ...done! |
313 |
[ebuild N ] net-www/mozilla-1.5-r1 +java +crypt -ipv6 -gtk2 +ssl +ldap |
314 |
+gnome -debug +mozcalendar -mozaccess -mozxmlterm -moznoirc -moznomail |
315 |
-moznocompose -moznoxft |
316 |
</pre> |
317 |
|
318 |
<p> |
319 |
<c>emerge</c> isn't the only tool for this job. In fact, we have a tool |
320 |
dedicated to package information called <c>etcat</c> which resides in the |
321 |
<c>gentoolkit</c> package. First, install <c>gentoolkit</c>: |
322 |
</p> |
323 |
|
324 |
<pre caption="Installing gentoolkit"> |
325 |
# <i>emerge --usepkg gentoolkit</i> |
326 |
</pre> |
327 |
|
328 |
<p> |
329 |
Now run <c>etcat</c> with the <c>uses</c> argument to view the USE-flags of a |
330 |
certain package. For instance, for the <c>gnumeric</c> package: |
331 |
</p> |
332 |
|
333 |
<pre caption="Using etcat to view used USE-flags"> |
334 |
# <i>etcat uses gnumeric</i> |
335 |
[ Colour Code : <i>set</i> <comment>unset</comment> ] |
336 |
[ Legend : (U) Col 1 - Current USE flags ] |
337 |
[ : (I) Col 2 - Installed With USE flags ] |
338 |
|
339 |
U I [ Found these USE variables in : app-office/gnumeric-1.2.0 ] |
340 |
- - <comment>libgda</comment> : Adds GNU Data Access (CORBA wrapper) support for gnumeric |
341 |
- - <comment>gnomedb</comment> : unknown |
342 |
+ + <i>python</i> : Adds support/bindings for the Python language |
343 |
+ + <i>bonobo</i> : Adds support for gnome-base/bonobo (Gnome CORBA interfaces) |
344 |
</pre> |
345 |
|
346 |
</body> |
347 |
</subsection> |
348 |
</section> |
349 |
</sections> |