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

Contents of /xml/htdocs/doc/en/handbook/hb-working-features.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (show annotations) (download) (as text)
Sat Aug 28 11:30:43 2004 UTC (9 years, 7 months ago) by swift
Branch: MAIN
Changes since 1.13: +30 -1 lines
File MIME type: application/xml
#60176 - Adding SLOT and depclean to the Gentoo Handbook

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: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-features.xml,v 1.13 2004/08/22 22:49:38 neysx Exp $ -->
8
9 <sections>
10 <section>
11 <title>DistCC</title>
12 <subsection>
13 <title>What is DistCC?</title>
14 <body>
15
16 <p>
17 <c>distcc</c> is a program to distribute compilations across several, not
18 necessarily identical, machines on a network. The <c>distcc</c> client sends all
19 necessary information to the available DistCC servers (running <c>distccd</c>)
20 so they can compile pieces of source code for the client. The net result is a
21 faster compilation time.
22 </p>
23
24 <p>
25 You can find more elaborate information about <c>distcc</c> (and information on
26 how to have it work with Gentoo) in our <uri link="/doc/en/distcc.xml">Gentoo
27 Distcc Documentation</uri>.
28 </p>
29
30 </body>
31 </subsection>
32 <subsection>
33 <title>Installing DistCC</title>
34 <body>
35
36 <p>
37 Distcc ships with a graphical monitor to monitor tasks that your computer is
38 sending away for compilation. If you use Gnome then put 'gnome' in your
39 <c>USE</c> setting. However, if you don't use Gnome and would still like to have
40 the monitor then you should put 'gtk' in your <c>USE</c> setting.
41 </p>
42
43 <p>
44 Installing distcc is, as is with all software available through Gentoo's
45 Portage, extremely easy:
46 </p>
47
48 <note>
49 From now on, as you now know how to install binary packages if you want, we will
50 omit the <c>--usepkg</c> option throughout the rest of the Gentoo Handbook.
51 </note>
52
53 <pre caption="Installing Distcc">
54 # <i>emerge distcc</i>
55 </pre>
56
57 <p>
58 Now setup distcc to use 2G of caching space:
59 </p>
60
61 <pre caption="Setting up distcc">
62 # <i>ccache -M 2G</i>
63 </pre>
64
65 </body>
66 </subsection>
67 <subsection>
68 <title>Activating Portage Support</title>
69 <body>
70
71 <p>
72 Well, if installation is easy, the rest should be easy too :) So let us quickly
73 activate the Portage support for <c>distcc</c>.
74 </p>
75
76 <p>
77 First, open <path>/etc/make.conf</path> and edit the <c>FEATURES</c> variable so
78 it contains the <c>distcc</c> keyword. Next, edit the <c>MAKEOPTS</c> variable
79 so it reads <c>-jX</c> with <c>X</c> the number of CPUs that run <c>distccd</c>
80 (including the current host) plus one:
81 </p>
82
83 <pre caption="Possible MAKEOPTS setting in /etc/make.conf">
84 <comment># Suppose you have 2 single-CPU distccd hosts excluding this host:</comment>
85 MAKEOPTS="-j4"
86 </pre>
87
88 <p>
89 Now run <c>distcc-config</c> and enter the list of available DistCC servers. For
90 a simple example we assume that the available DistCC servers are
91 <c>192.168.1.102</c> (the current host), <c>192.168.1.103</c> and
92 <c>192.168.1.104</c> (two "remote" hosts):
93 </p>
94
95 <pre caption="Configuring distcc to use three available DistCC servers">
96 # <i>distcc-config --set-hosts "192.168.1.102 192.168.1.103 192.168.1.104"</i>
97 </pre>
98
99 <p>
100 Of course, don't forget to run the <c>distccd</c> daemon too:
101 </p>
102
103 <pre caption="Starting the distcc daemon">
104 # <i>/etc/init.d/distccd start</i>
105 </pre>
106
107 <p>
108 Congratulations, your system will now use distributed compiling! For more
109 in-depth information about DistCC and Gentoo, please read our <uri
110 link="/doc/en/distcc.xml">Gentoo DistCC Documentation</uri>.
111 </p>
112
113 </body>
114 </subsection>
115 </section>
116 <section>
117 <title>ccache</title>
118 <subsection>
119 <title>What is ccache?</title>
120 <body>
121
122 <p>
123 <c>ccache</c> is a fast compiler cache. When you compile a program, it will
124 cache intermediate results so that, when you ever recompile the same program,
125 the compilation time is greatly reduced. In common compilations this can result
126 in 5 to 10 times faster compilation times.
127 </p>
128
129 <p>
130 If you are interested in the ins and outs of <c>ccache</c>, please visit the
131 <uri link="http://ccache.samba.org">ccache homepage</uri>.
132 </p>
133
134 </body>
135 </subsection>
136 <subsection>
137 <title>Installing ccache</title>
138 <body>
139
140 <p>
141 Installing <c>ccache</c> with Gentoo is a breeze. Just emerge it and you're done
142 :)
143 </p>
144
145 <pre caption="Installing ccache">
146 # <i>emerge ccache</i>
147 </pre>
148
149 </body>
150 </subsection>
151 <subsection>
152 <title>Tweaking ccache</title>
153 <body>
154
155 <p>
156 Portage will automatically use ccache if it's installed. However, you can alter
157 the default cache size used by ccache by providing a <c>CCACHE_SIZE</c> variable
158 in <path>/etc/make.conf</path>:
159 </p>
160
161 <pre caption="Editing CCACHE_SIZE in /etc/make.conf">
162 CCACHE_SIZE="2G"
163 </pre>
164
165 <p>
166 As of now, Portage will use <c>ccache</c> to speed up compilations where
167 possible. If you are uncertain that <c>ccache</c> works, you can run <c>ccache
168 -s</c> to view the <c>ccache</c> statistics:
169 </p>
170
171 <pre caption="Viewing ccache statistics">
172 # <i>ccache -s</i>
173 </pre>
174
175 </body>
176 </subsection>
177 <subsection>
178 <title>Using ccache for non-Portage C compiling</title>
179 <body>
180
181 <p>
182 If you would like to use ccache for non-Portage compilations, add
183 <path>/usr/lib/ccache/bin</path> to the beginning of your <c>PATH</c> variable
184 (before <path>/usr/bin</path>). This can be accomplished by editing
185 <path>/etc/env.d/00basic</path>:
186 </p>
187
188 <pre caption="Editing 00basic">
189 # <i>nano -w /etc/env.d/00basic</i>
190 # <i>env-update &amp;&amp; source /etc/profile</i>
191 </pre>
192
193 </body>
194 </subsection>
195 </section>
196 <section>
197 <title>Binary Packages</title>
198 <subsection>
199 <title>Creating binary packages</title>
200 <body>
201
202 <p>
203 We have already discussed how to work with prebuilt packages, but how do you
204 create your own prebuilt packages?
205 </p>
206
207 <p>
208 If the package is already installed, you can use the <c>quickpkg</c> command
209 which will make a tarball of the installed files. This is very interesting for
210 backup purposes!
211 </p>
212
213 <pre caption="Using quickpkg">
214 # <i>quickpkg gnumeric</i>
215 </pre>
216
217 <p>
218 If the package isn't installed yet, you can install it using <c>emerge</c> and
219 ask to build a binary package too. <c>emerge</c> uses the <c>--buildpkg</c>
220 option (<c>-b</c> in short) for this:
221 </p>
222
223 <pre caption="Installing gnumeric and building binary packages too">
224 # <i>emerge --buildpkg gnumeric</i>
225 </pre>
226
227 <p>
228 If you want Portage to do this by default, you should set the <c>buildpkg</c>
229 keyword in the <c>FEATURES</c> variable declared in <path>/etc/make.conf</path>.
230 </p>
231
232 <pre caption="Automatically creating binary packages">
233 FEATURES="buildpkg"
234 </pre>
235
236 <p>
237 If you don't want to install the software, but only build the package, you can
238 use the <c>--buildpkgonly</c> option (<c>-B</c> in short):
239 </p>
240
241 <pre caption="Building a binary package for gnumeric">
242 # <i>emerge --buildpkgonly gnumeric</i>
243 </pre>
244
245 </body>
246 </subsection>
247 </section>
248 <section>
249 <title>Security Related Features</title>
250 <subsection>
251 <title>Sandbox</title>
252 <body>
253
254 <p>
255 While building and installing packages, Portage uses a <e>sandbox</e> to protect
256 your live system. This means that, as long as the package isn't installed on
257 your system, the package cannot touch any file outside the sandbox. This
258 ensures that Portage knows what files are created and modified by a package.
259 </p>
260
261 <p>
262 When the package compilation is finished, Portage will "preinstall" the package
263 in the sandbox, registering what files are placed and where. It will then move
264 those files from the sandbox on your live system.
265 </p>
266
267 </body>
268 </subsection>
269 <subsection>
270 <title>User Privileges</title>
271 <body>
272
273 <p>
274 Portage also supports building packages as non-root user (more precisely, as
275 user "portage", group "portage"). This improves the security during the
276 build process. You can opt to use user privileges with or without sandboxing. Of
277 course, it goes without saying that user privileges and sandboxing is the most
278 preferred method :)
279 </p>
280
281 </body>
282 </subsection>
283 <subsection>
284 <title>Activating sandbox and/or userpriv</title>
285 <body>
286
287 <p>
288 Portage will use <c>sandbox</c> per default. If you want <c>userpriv</c>, you
289 should add it to the <c>FEATURES</c> variable. Note that activating
290 <c>userpriv</c> will drop <c>sandbox</c> support, unless you also activate
291 <c>usersandbox</c>:
292 </p>
293
294 <pre caption="Activating userpriv and usersandbox">
295 FEATURES="userpriv usersandbox"
296 </pre>
297
298 <warn>
299 Do <e>not</e> remove <c>sandbox</c> from the <c>FEATURES</c> variable!
300 </warn>
301
302 </body>
303 </subsection>
304 <subsection>
305 <title>Strict Checking</title>
306 <body>
307
308 <p>
309 Portage can be asked to react strongly to possibly dangerous conditions (such as
310 missing or incorrect Manifest files). To activate this strict checking, add the
311 <c>strict</c> keyword to the <c>FEATURES</c> variable:
312 </p>
313
314 <pre caption="Activating strict checking">
315 FEATURES="strict"
316 </pre>
317
318 </body>
319 </subsection>
320 <subsection>
321 <title>Smart File System Permissions</title>
322 <body>
323
324 <p>
325 Portage can be told to automatically deal with potentially dangerous file
326 permissions that could pose a security risk. It does this by removing the
327 "group" and "other" readable bits on setuid files and removing the "other"
328 readable bit on setgid files in the pre install phase. To activate the
329 smart file permissions, add the <c>sfperms</c> keyword to the
330 <c>FEATURES</c> variable:
331 </p>
332
333 <pre caption="Activating smart file system permissions">
334 FEATURES="sfperms"
335 </pre>
336
337 </body>
338 </subsection>
339 </section>
340 <section>
341 <title>SLOT'ed Software Titles</title>
342 <subsection>
343 <title>SLOT ?</title>
344 <body>
345
346 <p>
347 Occasionally you need to have several versions of a software title installed at
348 the same time to satisfy your system's dependencies. Whereas most distributions
349 allow this by having their packages called to the version (such as
350 <c>freetype</c> and <c>freetype2</c>) Portage uses the concept of <e>SLOT</e>s.
351 </p>
352
353 <p>
354 A <e>SLOT</e> is a (part of a) version number that tells Portage that all
355 equally named packages with a different SLOT are able to coexist on the same
356 system. Portage is able to track both branches of a certain package and update
357 them if updates to the respective branches are available.
358 </p>
359
360 <p>
361 When you perform an update Portage will only automatically unmerge the old
362 instance of a package if it uses the same SLOT. This is why kernel sources are
363 never automatically unmerged as their SLOT is the complete version.
364 </p>
365
366 </body>
367 </subsection>
368 </section>
369 <section>
370 <title>Other Features</title>
371 <subsection>
372 <title>Portage Help</title>
373 <body>
374
375 <p>
376 There are several other keywords you can place in the <c>FEATURES</c> variable.
377 Most of them are targeted towards developers and less interesting for the casual
378 user. If you are interested in learning more about these features (or Portage
379 generally), don't forget to read the <path>make.conf</path> manpage we provide.
380 </p>
381
382 <pre caption="More Portage-related information">
383 # <i>man make.conf</i>
384 </pre>
385
386 </body>
387 </subsection>
388 </section>
389 </sections>

  ViewVC Help
Powered by ViewVC 1.1.20