Add EAPI 3 conditionals for prefix variables.
[portage.git] / man / ebuild.5
1 .TH "EBUILD" "5" "Aug 2008" "Portage 2.2" "Portage"
2 .SH "NAME"
3 ebuild \- the internal format, variables, and functions in an ebuild script
4 .SH "DESCRIPTION"
5 The
6 .BR ebuild (1)
7 program accepts a single ebuild script as an argument.  This script
8 contains variables and commands that specify how to download, unpack,
9 patch, compile, install and merge a particular software package from
10 its original sources.  In addition to all of this, the ebuild script
11 can also contain pre/post install/remove commands, as required.  All
12 ebuild scripts are written in bash.
13 .SH "EXAMPLES"
14 Here's a simple example ebuild:
15
16 .DS
17 .nf
18 # Copyright 1999\-2009 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Header: $
21
22 EAPI="3"
23
24 inherit some_eclass another_eclass
25
26 DESCRIPTION="Super\-useful stream editor (sed)"
27 HOMEPAGE="http://www.gnu.org/software/sed/sed.html"
28 SRC_URI="ftp://alpha.gnu.org/pub/gnu/${PN}/${P}.tar.gz"
29
30 LICENSE="GPL\-2"
31 SLOT="0"
32 KEYWORDS="~x86"
33 IUSE=""
34
35 RDEPEND=""
36 DEPEND="nls? ( sys-devel/gettext )"
37
38 src_configure() {
39         econf \\
40                 \-\-bindir="${EPREFIX}"/bin
41 }
42
43 src_install() {
44         emake install DESTDIR="${D}" || die "Install failed"
45         dodoc NEWS README* THANKS AUTHORS BUGS ChangeLog || die "dodoc failed"
46 }
47 .fi
48 .SH "VARIABLES"
49 .TP
50 .B MISC USAGE NOTES
51 \- All variables defined in \fBmake.conf\fR(5) are available for use in
52 ebuilds (such as the PORTAGE* and PORTDIR* variables)
53 .br
54 \- When assigning values to variables in ebuilds, you \fBcannot have a
55 space\fR between the variable name and the equal sign.
56 .br
57 \- Variable values should only contain characters that are members of the
58 \fBascii\fR(7) character set. This requirement is mandated by \fBGLEP 31\fR.
59 .TP
60 .B P
61 This variable contains the package name without the ebuild revision.
62 This variable must NEVER be modified.
63 .br
64 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$P\fR=='\fIxfree\-4.2.1\fR'
65 .TP
66 .B PN
67 Contains the name of the script without the version number.
68 .br
69 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PN\fR=='\fIxfree\fR'
70 .TP
71 .B PV
72 Contains the version number without the revision.
73 .br
74 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PV\fR=='\fI4.2.1\fR'
75 .TP
76 .B PR
77 Contains the revision number or 'r0' if no revision number exists.
78 .br
79 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PR\fR=='\fIr2\fR'
80 .TP
81 .B PVR
82 Contains the version number with the revision.
83 .br
84 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PVR\fR=='\fI4.2.1\-r2\fR'
85 .TP
86 .B PF
87 Contains the full package name \fI[PN]\-[PVR]\fR
88 .br
89 \fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PF\fR=='\fIxfree\-4.2.1\-r2\fR'
90 .TP
91 .B CATEGORY
92 Contains the package category name.
93 .TP
94 .B A
95 Contains all source files required for the package.  This variable must
96 not be defined. It is autogenerated from the \fISRC_URI\fR variable.
97 .TP
98 \fBWORKDIR\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/work"\fR
99 Contains the path to the package build root.  Do not modify this variable.
100 .TP
101 \fBFILESDIR\fR = \fI"${PORTDIR}/${CATEGORY}/${PN}/files"\fR
102 Contains the path to the 'files' sub folder in the package specific
103 location in the portage tree.  Do not modify this variable.
104 .TP
105 .B EPREFIX
106 Beginning with \fBEAPI 3\fR, contains the offset
107 that this Portage was configured for during
108 installation.  The offset is sometimes necessary in an ebuild or eclass,
109 and is available in such cases as ${EPREFIX}.  EPREFIX does not contain
110 a trailing slash, therefore an absent offset is represented by the empty
111 string.  Do not modify this variable.
112 .TP
113 \fBS\fR = \fI"${WORKDIR}/${P}"\fR
114 Contains the path to the temporary \fIbuild directory\fR.  This variable
115 is used by the functions \fIsrc_compile\fR and \fIsrc_install\fR.  Both
116 are executed with \fIS\fR as the current directory.  This variable may
117 be modified to match the extraction directory of a tarball for the package.
118 .TP
119 \fBT\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/temp"\fR
120 Contains the path to a \fItemporary directory\fR.  You may use this for
121 whatever you like.
122 .TP
123 \fBD\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/image/"\fR
124 Contains the path to the temporary \fIinstall directory\fR.  Every write
125 operation that does not involve the helper tools and functions (found below)
126 should be prefixed with ${D}.  Often the offset prefix needs to be taken
127 into account here, for which the variable ${ED} is provided (see below).
128 Do not modify this variable.
129 .TP
130 \fBED\fT = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/image/${EPREFIX}/"\fR
131 Beginning with \fBEAPI 3\fR, contains the path
132 "${D%/}${EPREFIX}/" for convenience purposes.
133 Do not modify this variable.
134 .TP
135 .B PORTAGE_LOG_FILE
136 Contains the path of the build log. If \fBPORT_LOGDIR\fR variable is unset then
137 \fBPORTAGE_LOG_FILE\fR=\fB"${T}/build.log"\fR.
138 .TP
139 \fBROOT\fR = \fI"/"\fR
140 Contains the path that portage should use as the root of the live filesystem.
141 When packages wish to make changes to the live filesystem, they should do so in
142 the tree prefixed by ${ROOT}.  Often the offset prefix needs to be taken
143 into account here, for which the variable ${EROOT} is provided (see
144 below).  Do not modify this variable.
145 .TP
146 \fBEROOT\fR = \fI"${ROOT%/}${EPREFIX}/"\fR
147 Beginning with \fBEAPI 3\fR, contains
148 "${ROOT%/}${EPREFIX}/" for convenience
149 purposes. Do not modify this variable.
150 .TP
151 \fBDESCRIPTION\fR = \fI"A happy little package"\fR
152 Should contain a short description of the package.
153 .TP
154 \fBEAPI\fR = \fI"0"\fR
155 Defines the ebuild API version to which this package conforms. If not
156 defined then it defaults to "0". If portage does not recognize the
157 EAPI value then it will mask the package and refuse to perform any
158 operations with it since this means that a newer version of portage
159 needs to be installed first. For maximum backward compatiblity, a
160 package should conform to the lowest possible EAPI. Note that anyone
161 who uses the \fBebuild\fR(1) and \fBrepoman\fR(1) commands with this
162 package will be required to have a version of portage that recognizes
163 the EAPI to which this package conforms.
164 .TP
165 \fBSRC_URI\fR = \fI"http://happy.com/little/${P}.tar.gz"\fR
166 Contains a list of URIs for the required source files.  It can contain
167 multiple URIs for a single source file.  The list is processed in order
168 if the file was not found on any of the \fIGENTOO_MIRRORS\fR.
169 Beginning with \fBEAPI 2\fR, the output file name of a given URI may be
170 customized with a "->" operator on the right hand side, followed by the
171 desired output file name. All tokens, including the operator and output
172 file name, should be separated by whitespace.
173 .TP
174 \fBHOMEPAGE\fR = \fI"http://happy.com/"\fR
175 Should contain a list of URIs for the sources main sites and other further
176 package dependent information.
177 .TP
178 \fBKEYWORDS\fR = \fI[\-~][x86,ppc,sparc,mips,alpha,arm,hppa]\fR
179 Should contain appropriate list of arches that the ebuild is know to
180 work/not work.  By default if you do not know if an ebuild runs under
181 a particular arch simply omit that KEYWORD.  If the ebuild will not
182 work on that arch include it as \-ppc for example.  If the ebuild is
183 being submitted for inclusion, it must have ~arch set for architectures
184 where it has been PROVEN TO WORK.  (Packages KEYWORDed this way may be
185 unmasked for testing by setting ACCEPT_KEYWORDS="~arch" on the command
186 line, or in \fBmake.conf\fR(5)) For an authoritative list please review
187 /usr/portage/profiles/arch.list.  Please keep this list in alphabetical order.
188 .TP
189 \fBSLOT\fR
190 This sets the SLOT for packages that may need to have multiple versions
191 co\-exist.  By default you should set \fBSLOT\fR="0".  If you are unsure, then
192 do not fiddle with this until you seek some guidance from some guru.  This
193 value should \fINEVER\fR be left undefined.
194 .TP
195 \fBLICENSE\fR
196 This should be a space delimited list of licenses that the package falls
197 under.  This \fB_must_\fR be set to a matching license in
198 /usr/portage/licenses/. If the license does not exist in portage yet, you
199 must add it first.
200 .TP
201 \fBIUSE\fR
202 This should be a list of any and all USE flags that are leveraged within
203 your build script.  The only USE flags that should not be listed here are
204 arch related flags (see \fBKEYWORDS\fR). Beginning with \fBEAPI 1\fR, it
205 is possible to prefix flags with + or - in order to create default settings
206 that respectively enable or disable the corresponding \fBUSE\fR flags. For
207 details about \fBUSE\fR flag stacking order, refer to the \fBUSE_ORDER\fR
208 variable in \fBmake.conf\fR(5). Given the default \fBUSE_ORDER\fR setting,
209 negative IUSE default settings are ineffective since profile and user
210 configuration settings override them.
211 .TP
212 \fBDEPEND\fR
213 This should contain a list of all packages that are required for the
214 program to compile.
215 .RS
216 .TP
217 .B DEPEND Atoms
218 A depend atom is simply a dependency that is used by portage when calculating
219 relationships between packages.  Please note that if the atom has not already
220 been emerged, then the latest version available is matched.
221 .RS
222 .TP
223 .B Atom Bases
224 The base atom is just a full category/packagename.  Hence, these are base atoms:
225
226 .nf
227 .I sys\-apps/sed
228 .I sys\-libs/zlib
229 .I net\-misc/dhcp
230 .fi
231 .TP
232 .B Atom Versions
233 It is nice to be more specific and say that only certain versions of atoms are
234 acceptable.  Note that versions must be combined with a prefix (see below).  
235 Hence you may add a version number as a postfix to the base:
236
237 .nf
238 sys\-apps/sed\fI\-4.0.5\fR
239 sys\-libs/zlib\fI\-1.1.4\-r1\fR
240 net\-misc/dhcp\fI\-3.0_p2\fR
241 .fi
242
243 Versions are normally made up of two or three numbers separated by periods, such
244 as 1.2 or 4.5.2.  This string may be followed by a character such as 1.2a or 
245 4.5.2z.  Note that this letter is \fBnot\fR meant to indicate alpha, beta, 
246 etc... status.  For that, use the optional suffix; either _alpha, _beta, _pre 
247 (pre\-release), _rc (release candidate), or _p (patch).  This means for the 
248 3rd pre\-release of a package, you would use something like 1.2_pre3.  The 
249 suffixes here can be arbitrarily chained without limitation.
250 .TP
251 .B Atom Prefix Operators [> >= = <= <]
252 Sometimes you want to be able to depend on general versions rather than specifying
253 exact versions all the time.  Hence we provide standard boolean operators:
254
255 .nf
256 \fI>\fRmedia\-libs/libgd\-1.6
257 \fI>=\fRmedia\-libs/libgd\-1.6
258 \fI=\fRmedia\-libs/libgd\-1.6
259 \fI<=\fRmedia\-libs/libgd\-1.6
260 \fI<\fRmedia\-libs/libgd\-1.6
261 .fi
262 .TP
263 .B Extended Atom Prefixes [!~] and Postfixes [*]
264 Now to get even fancier, we provide the ability to define blocking packages and
265 version range matching.  Also note that these extended prefixes/postfixes may
266 be combined in any way with the atom classes defined above.  Here are some common
267 examples you may find in the portage tree:
268
269 .nf
270 \fI!\fRapp\-text/dos2unix
271 =dev\-libs/glib\-2\fI*\fR
272 \fI!\fR=net\-fs/samba\-2\fI*\fR
273 \fI~\fRnet\-libs/libnet\-1.0.2a
274 \fI!!\fR<sys\-apps/portage\-2.1.4_rc1\fI\fR
275 .fi
276
277 \fI!\fR means block packages from being installed at the same time.
278 .br
279 \fI!!\fR means block packages from being installed at the same time
280 and explicitly disallow them from being temporarily installed
281 simultaneously during a series of upgrades. This syntax is supported
282 beginning with \fBEAPI 2\fR.
283 .br
284 \fI*\fR means match any version of the package so long as the specified base
285 is matched.  So with a version of '2*', we can match '2.1', '2.2', '2.2.1',
286 etc... and not match version '1.0', '3.0', '4.1', etc...
287 .br
288 \fI~\fR means match any revision of the base version specified.  So in the
289 above example, we would match versions '1.0.2a', '1.0.2a\-r1', '1.0.2a\-r2',
290 etc...
291 .TP
292 .B Atom Slots
293 Beginning with \fBEAPI 1\fR, any atom can be constrained to match a specific
294 \fBSLOT\fR. This is accomplished by appending a colon followed by a
295 \fBSLOT\fR:
296
297 .nf
298 x11\-libs/qt:3
299 \fI~\fRx11\-libs/qt-3.3.8:3
300 \fI>=\fRx11\-libs/qt-3.3.8:3
301 \fI=\fRx11\-libs/qt-3.3*:3
302 .fi
303 .TP
304 .B Atom USE
305 Beginning with \fBEAPI 2\fR, any atom can be constrained to match specific
306 \fBUSE\fR flag settings. When used together with \fBSLOT\fR dependencies,
307 \fBUSE\fR dependencies appear on the right hand side of \fBSLOT\fR
308 dependencies.
309
310 .RS
311 .TP
312 .B Unconditional USE Dependencies
313 .TS
314 l l
315 __
316 l l.
317 Example Meaning
318
319 foo[bar]        foo must have bar enabled
320 foo[bar,baz]    foo must have both bar and baz enabled
321 foo[\-bar,baz]  foo must have bar disabled and baz enabled
322 .TE
323
324 .TP
325 .B Conditional USE Dependencies
326 .TS
327 l l
328 __
329 l l.
330 Compact Form    Equivalent Expanded Form
331
332 foo[bar?]       bar? ( foo[bar] ) !bar? ( foo )
333 foo[!bar?]      bar? ( foo ) !bar? ( foo[\-bar] )
334 foo[bar=]       bar? ( foo[bar] ) !bar? ( foo[\-bar] )
335 foo[!bar=]      bar? ( foo[\-bar] ) !bar? ( foo[bar] )
336 .TE
337 .RE
338 .RE
339 .TP
340 .B Dynamic DEPENDs
341 Sometimes programs may depend on different things depending on the USE
342 variable.  Portage offers a few options to handle this.  Note that when
343 using the following syntaxes, each case is considered as 1 Atom in the
344 scope it appears.  That means that each Atom both conditionally include
345 multiple Atoms and be nested to an infinite depth.
346 .RS
347 .TP
348 .B usevar? ( DEPEND Atom )
349 To include the jpeg library when the user has jpeg in \fBUSE\fR, simply use the
350 following syntax:
351 .br
352 .B jpeg? ( media\-libs/jpeg )
353 .TP
354 .B !usevar? ( Atom )
355 If you want to include a package only if the user does not have a certain option
356 in their \fBUSE\fR variable, then use the following syntax:
357 .br
358 .B !nophysfs? ( dev\-games/physfs )
359 .br
360 This is often useful for those times when you want to want to add optional support
361 for a feature and have it enabled by default.
362 .TP
363 .B usevar? ( Atom if true ) !usevar? ( Atom if false )
364 For functionality like the tertiary operator found in C you must use
365 two statements, one normal and one inverted.  If a package uses
366 GTK2 or GTK1, but not both, then you can handle that like this:
367 .br
368 .B gtk2? ( =x11\-libs/gtk+\-2* ) !gtk2? ( =x11\-libs/gtk+\-1* )
369 .br
370 That way the default is the superior GTK2 library.
371 .TP
372 .B || ( Atom Atom ... )
373 When a package can work with a few different packages but a virtual is not
374 appropriate, this syntax can easily be used.
375 .nf
376 .B || (
377 .B      app\-games/unreal\-tournament
378 .B      app\-games/unreal\-tournament\-goty
379 .B )
380 .fi
381 Here we see that unreal\-tournament has a normal version and it has a goty
382 version.  Since they provide the same base set of files, another package can
383 use either.  Adding a virtual is inappropriate due to the small scope of it.
384 .br
385 Another good example is when a package can be built with multiple video 
386 interfaces, but it can only ever have just one.
387 .nf
388 .B || (
389 .B      sdl? ( media\-libs/libsdl )
390 .B      svga? ( media\-libs/svgalib )
391 .B      opengl? ( virtual/opengl )
392 .B      ggi? ( media\-libs/libggi )
393 .B      virtual/x11
394 .B )
395 .fi
396 Here only one of the packages will be chosen, and the order of preference is
397 determined by the order in which they appear.  So sdl has the best chance of
398 being chosen, followed by svga, then opengl, then ggi, with a default of X if
399 the user does not specify any of the previous choices.
400 .br
401 Note that if any of the packages listed are already merged, the package manager
402 will use that to consider the dependency satisfied.
403 .RE
404
405 .RE
406 .TP
407 \fBRDEPEND\fR
408 This should contain a list of all packages that are required for this
409 program to run (aka runtime depend).  If this is not set, then it
410 defaults to the value of \fBDEPEND\fR.
411 .br
412 You may use the same syntax to vary dependencies as seen above in \fBDEPEND\fR.
413 .TP
414 \fBPDEPEND\fR
415 This should contain a list of all packages that should be merged after this one,
416 but may be merged before if need be.
417 .br
418 You may use the same syntax to vary dependencies as seen above in \fBDEPEND\fR.
419 .TP
420 \fBRESTRICT\fR = \fI[strip,mirror,fetch,userpriv]\fR
421 This should be a space delimited list of portage features to restrict.
422 You may use conditional syntax to vary restrictions as seen above in DEPEND.
423 .PD 0
424 .RS
425 .TP
426 .I binchecks
427 Disable all QA checks for binaries.  This should ONLY be used in packages
428 for which binary checks make no sense (linux\-headers and kernel\-sources, for
429 example, can safely be skipped since they have no binaries).  If the binary
430 checks need to be skipped for other reasons (such as proprietary binaries),
431 see the \fBQA CONTROL VARIABLES\fR section for more specific exemptions.
432 .TP
433 .I bindist
434 Distribution of built packages is restricted.
435 .TP
436 .I fetch
437 like \fImirror\fR but the files will not be fetched via \fBSRC_URI\fR either.
438 .TP
439 .I installsources
440 Disables installsources for specific packages. This is for packages with
441 binaries that are not compatible with debugedit.
442 .TP
443 .I mirror
444 files in \fBSRC_URI\fR will not be downloaded from the \fBGENTOO_MIRRORS\fR.
445 .TP
446 .I primaryuri
447 fetch from URIs in \fBSRC_URI\fR before \fBGENTOO_MIRRORS\fR.
448 .TP
449 .I strip
450 final binaries/libraries will not be stripped of debug symbols.
451 .TP
452 .I test
453 do not run src_test even if user has \fBFEATURES\fR=test.
454 .TP
455 .I userpriv
456 Disables userpriv for specific packages.
457 .RE
458 .PD 1
459 .TP
460 \fBPROPERTIES\fR = \fI[interactive]\fR
461 A space delimited list of properties, with conditional syntax support.
462 .PD 0
463 .RS
464 .TP
465 .I interactive
466 One or more ebuild phases will produce a prompt that requires user interaction.
467 .RE
468 .PD 1
469 .TP
470 \fBPROVIDE\fR = \fI"virtual/TARGET"\fR
471 This variable should only be used when a package provides a virtual target.
472 For example, blackdown\-jdk and sun\-jdk provide \fIvirtual/jdk\fR.  This
473 allows for packages to depend on \fIvirtual/jdk\fR rather than on blackdown
474 or sun specifically.
475 .SH "QA CONTROL VARIABLES"
476 .TP
477 .B USAGE NOTES
478 Several QA variables are provided which allow an ebuild to manipulate some
479 of the QA checks performed by portage.  Use of these variables in ebuilds
480 should be kept to an absolute minimum otherwise they defeat the purpose
481 of the QA checks, and their use is subject to agreement of the QA team.
482 They are primarily intended for use by ebuilds that install closed\-source
483 binary objects that cannot be altered.
484 .br
485 Note that objects that violate these rules may fail on some architectures.
486 .TP
487 \fBQA_TEXTRELS\fR
488 This variable can be set to a list of file paths, relative to the image
489 directory, of files that contain text relocations that cannot be eliminated.
490 The paths may contain fnmatch patterns.
491 .br
492 This variable is intended to be used on closed\-source binary objects that
493 cannot be altered.
494 .TP
495 \fBQA_EXECSTACK\fR
496 This should contain a list of file paths, relative to the image directory, of
497 objects that require executable stack in order to run.
498 The paths may contain fnmatch patterns.
499 .br
500 This variable is intended to be used on objects that truly need executable
501 stack (i.e. not those marked to need it which in fact do not).
502 .TP
503 \fBQA_WX_LOAD\fR
504 This should contain a list of file paths, relative to the image directory, of
505 files that contain writable and executable segments.  These are rare.
506 The paths may contain fnmatch patterns.
507 .TP
508 \fBQA_DT_HASH\fR
509 This should contain a list of file paths, relative to the image directory, of
510 files that contain .hash sections. The paths may contain regular expressions
511 with escape\-quoted special characters.
512 .br
513 This variable is intended to be used on files of binary packages which ignore
514 LDFLAGS variable.
515 .TP
516 \fBQA_PRESTRIPPED\fR
517 This should contain a list of file paths, relative to the image directory, of
518 files that contain pre-stripped binaries. The paths may contain regular
519 expressions with escape\-quoted special characters.
520 .TP
521 \fBQA_SONAME\fR
522 This should contain a list of file paths, relative to the image directory, of
523 shared libraries that lack SONAMEs. The paths may contain regular expressions
524 with escape\-quoted special characters.
525 .TP
526 \fBQA_DT_NEEDED\fR
527 This should contain a list of file paths, relative to the image directory, of
528 shared libraries that lack NEEDED entries. The paths may contain regular
529 expressions with escape\-quoted special characters.
530 .SH "PORTAGE DECLARATIONS"
531 .TP
532 .B inherit
533 Inherit is portage's maintenance of extra classes of functions that are
534 external to ebuilds and provided as inheritable capabilities and data. They
535 define functions and set data types as drop\-in replacements, expanded, and
536 simplified routines for extremely common tasks to streamline the build
537 process. Call to inherit cannot depend on conditions which can vary in given
538 ebuild. Specification of the eclasses contains only their name and not the
539 \fI.eclass\fR extension. Also note that the inherit statement must come
540 before other variable declarations unless these variables are used in global
541 scope of eclasses.
542 .SH "PHASE FUNCTIONS"
543 .TP
544 .B pkg_nofetch
545 If you turn on \fIfetch\fR in \fBRESTRICT\fR, then this function will be
546 run when the files in \fBSRC_URI\fR cannot be found.  Useful for
547 displaying information to the user on *how* to obtain said files.  All
548 you have to do is output a message and let the function return.  Do not
549 end the function with a call to \fBdie\fR.
550 .TP
551 .B pkg_setup
552 This function can be used if the package needs specific setup actions or
553 checks to be preformed before anything else.
554 .br
555 Initial working directory of ${PORTAGE_TMPDIR}.
556 .TP
557 .B src_unpack
558 This function is used to unpack all the sources in \fIA\fR to \fIWORKDIR\fR.
559 If not defined in the \fIebuild script\fR it calls \fIunpack ${A}\fR. Any
560 patches and other pre configure/compile modifications should be done here.
561 .br
562 Initial working directory of $WORKDIR.
563 .TP
564 .B src_prepare
565 All preparation of source code, such as application of patches, should be done
566 here. This function is supported beginning with \fBEAPI 2\fR.
567 .br
568 Initial working directory of $S.
569 .TP
570 .B src_configure
571 All necessary steps for configuration should be done here. This function is
572 supported beginning with \fBEAPI 2\fR.
573 .br
574 Initial working directory of $S.
575 .TP
576 .B src_compile
577 With less than \fBEAPI 2\fR, all necessary steps for both configuration and
578 compilation should be done here. Beginning with \fBEAPI 2\fR, only compilation
579 steps should be done here.
580 .br
581 Initial working directory of $S.
582 .TP
583 .B src_test
584 Run all package specific test cases.  The default is to run 'make check'
585 followed 'make test'.
586 .br
587 Initial working directory of $S.
588 .TP
589 .B src_install
590 Should contain everything required to install the package in the temporary
591 \fIinstall directory\fR.
592 .br
593 Initial working directory of $S.
594 .TP
595 .B pkg_preinst pkg_postinst
596 All modifications required on the live\-filesystem before and after the
597 package is merged should be placed here. Also commentary for the user
598 should be listed here as it will be displayed last.
599 .br
600 Initial working directory of $PWD.
601 .TP
602 .B pkg_prerm pkg_postrm
603 Like the pkg_*inst functions but for unmerge.
604 .br
605 Initial working directory of $PWD.
606 .TP
607 .B pkg_config
608 This function should contain optional basic configuration steps.
609 .br
610 Initial working directory of $PWD.
611 .SH "HELPER FUNCTIONS: PHASES"
612 .TP
613 .B default
614 Calls the default phase function implementation for the currently executing
615 phase. This function is supported beginning with \fBEAPI 2\fR.
616 .TP
617 .B default_*
618 Beginning with \fBEAPI 2\fR, the default pkg_nofetch and src_* phase
619 functions are accessible via a function having a name that begins with
620 default_ and ends with the respective phase function name. For example,
621 a call to a function with the name default_src_compile is equivalent to
622 a call to the default src_compile implementation.
623
624 .RS
625 .TS
626 l
627 _
628 l.
629 Default Phase Functions
630
631 default_pkg_nofetch
632 default_src_unpack
633 default_src_prepare
634 default_src_configure
635 default_src_compile
636 default_src_test
637 .TE
638 .RE
639 .SH "HELPER FUNCTIONS: GENERAL"
640 .TP
641 \fBdie\fR \fI[reason]\fR
642 Causes the current emerge process to be aborted. The final display will
643 include \fIreason\fR.
644 .TP
645 \fBuse\fR \fI<USE item>\fR
646 If \fIUSE item\fR is in the \fBUSE\fR variable, the function will silently
647 return 0 (aka shell true).  If \fIUSE item\fR is not in the \fBUSE\fR
648 variable, the function will silently return 1 (aka shell false).  \fBusev\fR
649 is a verbose version of \fBuse\fR.
650 .RS
651 .TP
652 .I Example:
653 .nf
654 if use gnome ; then
655         guiconf="\-\-enable\-gui=gnome \-\-with\-x"
656 elif use gtk ; then
657         guiconf="\-\-enable\-gui=gtk \-\-with\-x"
658 elif use X ; then
659         guiconf="\-\-enable\-gui=athena \-\-with\-x"
660 else
661         # No gui version will be built
662         guiconf=""
663 fi
664 .fi
665 .RE
666 .TP
667 \fBuse_with\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]\fR
668 Useful for creating custom options to pass to a configure script. If \fIUSE
669 item\fR is in the \fBUSE\fR variable and a \fIconfigure opt\fR is specified,
670 then the string \fI\-\-with\-[configure name]=[configure opt]\fR will be echoed.
671 If \fIconfigure opt\fR is not specified, then just \fI\-\-with\-[configure
672 name]\fR will be echoed.  If \fIUSE item\fR is not in the \fBUSE\fR variable,
673 then the string \fI\-\-without\-[configure name]\fR will be echoed. If
674 \fIconfigure name\fR is not specified, then \fIUSE item\fR will be used in
675 its place.
676 .RS
677 .TP
678 .I Examples:
679 .nf
680 USE="opengl"
681 myconf=$(use_with opengl)
682 (myconf now has the value "\-\-with\-opengl")
683
684 USE="jpeg"
685 myconf=$(use_with jpeg libjpeg)
686 (myconf now has the value "\-\-with\-libjpeg")
687
688 USE=""
689 myconf=$(use_with jpeg libjpeg)
690 (myconf now has the value "\-\-without\-libjpeg")
691
692 USE="sdl"
693 myconf=$(use_with sdl SDL all\-plugins)
694 (myconf now has the value "\-\-with\-SDL=all\-plugins")
695 .fi
696 .RE
697 .TP
698 \fBuse_enable\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]\fR
699 Same as \fBuse_with\fR above, except that the configure options are
700 \fI\-\-enable\-\fR instead of \fI\-\-with\-\fR and \fI\-\-disable\-\fR instead of
701 \fI\-\-without\-\fR.
702 .TP
703 \fBhas\fR \fI<item>\fR \fI<item list>\fR
704 If \fIitem\fR is in \fIitem list\fR, then \fIitem\fR is echoed and \fBhas\fR
705 returns 0.  Otherwise, nothing is echoed and 1 is returned. As indicated with
706 use, there is a non\-echoing version \fBhasq\fR. Please use \fBhasq\fR in all
707 places where output is to be disregarded. Never use the output for calculation.
708 .br
709 The \fIitem list\fR is delimited by the \fIIFS\fR variable.  This variable
710 has a default value of ' ', or a space.  It is a \fBbash\fR(1) setting.
711 .TP
712 \fBhas_version\fR \fI<category/package\-version>\fR
713 Check to see if \fIcategory/package\-version\fR is installed on the system.
714 The parameter accepts all values that are acceptable in the \fBDEPEND\fR
715 variable.  The function returns 0 if \fIcategory/package\-version\fR is
716 installed, 1 otherwise.
717 .TP
718 \fBbest_version\fR \fI<package name>\fR
719 This function will look up \fIpackage name\fR in the database of currently
720 installed programs and echo the "best version" of the package that is
721 currently installed. 
722 .RS
723 .TP
724 .I Example:
725 VERINS="$(best_version net\-ftp/glftpd)"
726 .br
727 (VERINS now has the value "net\-ftp/glftpd\-1.27" if glftpd\-1.27 is installed)
728 .RE
729 .SH "HELPER FUNCTIONS: HOOKS"
730 .TP
731 \fBregister_die_hook\fR \fI[list of function names]\fR
732 Register one or more functions to call when the ebuild fails for any reason,
733 including file collisions with other packages.
734 .TP
735 \fBregister_success_hook\fR \fI[list of function names]\fR
736 Register one or more functions to call when the ebuild builds and/or installs
737 successfully.
738 .TP
739 .RE
740 .SH "HELPER FUNCTIONS: OUTPUT"
741 .TP
742 \fBeinfo\fR \fI"disposable message"\fR
743 Same as \fBelog\fR, but should be used when the message isn't important to the
744 user (like progress or status messages during the build process).
745 .TP
746 \fBelog\fR \fI"informative message"\fR
747 If you need to display a message that you wish the user to read and take
748 notice of, then use \fBelog\fR.  It works just like \fBecho\fR(1), but
749 adds a little more to the output so as to catch the user's eye. The message
750 will also be logged by portage for later review.
751 .TP
752 \fBewarn\fR \fI"warning message"\fR
753 Same as \fBeinfo\fR, but should be used when showing a warning to the user.
754 .TP
755 \fBeqawarn\fR \fI"QA warning message"\fR
756 Same as \fBeinfo\fR, but should be used when showing a QA warning to the user.
757 .TP
758 \fBeerror\fR \fI"error message"\fR
759 Same as \fBeinfo\fR, but should be used when showing an error to the user.
760 .TP
761 \fBebegin\fR \fI"helpful message"\fR
762 Like \fBeinfo\fR, we output a \fIhelpful message\fR and then hint that the
763 following operation may take some time to complete.  Once the task is
764 finished, you need to call \fBeend\fR.
765 .TP
766 \fBeend\fR \fI<status>\fR \fI["error message"]\fR
767 Followup the \fBebegin\fR message with an appropriate "OK" or "!!" (for
768 errors) marker.  If \fIstatus\fR is non\-zero, then the additional \fIerror
769 message\fR is displayed.
770 .SH "HELPER FUNCTIONS: UNPACK"
771 .TP
772 \fBunpack\fR \fI<source>\fR \fI[list of more sources]\fR
773 This function uncompresses and/or untars a list of sources into the current
774 directory. The function will append \fIsource\fR to the \fBDISTDIR\fR variable.
775 .SH "HELPER FUNCTIONS: COMPILE"
776 .TP
777 \fBeconf\fR \fI[configure options]\fR
778 This is used as a replacement for configure.  Performs:
779 .nf
780 ${\fIECONF_SOURCE\fR:-.}/configure \\
781         \-\-prefix="${EPREFIX}"/usr \\
782         \-\-host="${EPREFIX}${CHOST} \\
783         \-\-mandir="${EPREFIX}"/usr/share/man \\
784         \-\-infodir="${EPREFIX}"/usr/share/info \\
785         \-\-datadir="${EPREFIX}"/usr/share \\
786         \-\-sysconfdir="${EPREFIX}"/etc \\
787         \-\-localstatedir="${EPREFIX}"/var/lib \\
788         \fI${EXTRA_ECONF}\fR \\
789         \fIconfigure options\fR || die "econf failed"
790 .fi
791 Note that the \fIEXTRA_ECONF\fR is for users only, not for ebuild
792 writers.  If you wish to pass more options to configure, just pass the
793 extra arguments to \fBeconf\fR. Also note that \fBeconf\fR automatically
794 calls \fBdie\fR if the configure script fails.
795 .TP
796 \fBemake\fR \fI[make options]\fR
797 This is used as a replacement for make.  Performs 'make ${MAKEOPTS}
798 \fImake options\fR' (as set in /etc/make.globals), default is MAKEOPTS="\-j2".
799
800 \fB***warning***\fR
801 .br
802 if you are going to use \fBemake\fR, make sure your build is happy with
803 parallel makes (make \-j2).  It should be tested thoroughly as parallel
804 makes are notorious for failing _sometimes_ but not always.  If you determine
805 that your package fails to build in parallel, and you are unable to resolve
806 the issue, then you should run '\fBemake\fR \-j1' instead of 'make'.
807 .SH "HELPER FUNCTIONS: INSTALL"
808 .TP
809 \fBeinstall\fR \fI[make options]\fR
810 This is used as a replacement for make install.  Performs:
811 .nf
812 make \\
813         prefix=${ED}/usr \\
814         datadir=${ED}/usr/share \\
815         infodir=${ED}/usr/share/info \\
816         localstatedir=${ED}/var/lib \\
817         mandir=${ED}/usr/share/man \\
818         sysconfdir=${ED}/etc \\
819         \fI${EXTRA_EINSTALL}\fR \\
820         \fImake options\fR \\
821         install
822 .fi
823 Please do \fBnot\fR use this in place of 'emake install DESTDIR=${D}'.
824 That is the preferred way of installing make\-based packages.  Also, do
825 not utilize the \fIEXTRA_EINSTALL\fR variable since it is for users.
826
827 .PD 0
828 .TP
829 .B prepall
830 .TP
831 .B prepalldocs
832 .TP
833 .B prepallinfo
834 .TP
835 .B prepallman
836 .TP
837 .B prepallstrip
838 .PD 1
839 Useful for when a package installs into \fB${D}\fR via scripts
840 (i.e. makefiles).  If you want to be sure that libraries are executable,
841 aclocal files are installed into the right place, doc/info/man files are
842 all compressed, and that executables are all stripped of debugging symbols,
843 then use these suite of functions.
844 .RS
845 .PD 0
846 .TP
847 .B prepall:
848 Runs \fBprepallman\fR, \fBprepallinfo\fR, \fBprepallstrip\fR, sets
849 libraries +x, and then checks aclocal directories.  Please note this
850 does \fI*not*\fR run \fBprepalldocs\fR.
851 .TP
852 .B prepalldocs:
853 Compresses all doc files in ${ED}/usr/share/doc.
854 .TP
855 .B prepallinfo:
856 Compresses all info files in ${ED}/usr/share/info.
857 .TP
858 .B prepallman:
859 Compresses all man files in ${ED}/usr/share/man.
860 .TP
861 .B prepallstrip:
862 Strips all executable files of debugging symboles.  This includes libraries.
863 .RE
864
865 .TP
866 \fBprepinfo\fR \fI[dir]\fR
867 .TP
868 \fBprepman\fR \fI[dir]\fR
869 .TP
870 \fBprepstrip\fR \fI[dir]\fR
871 .PD 1
872 Similiar to the \fBprepall\fR functions, these are subtle in their differences.
873 .RS
874 .PD 0
875 .TP
876 .B prepinfo:
877 If a \fIdir\fR is not specified, then \fBprepinfo\fR will assume the dir
878 \fIusr\fR. \fBprepinfo\fR will then compress all the files in
879 ${ED}/\fIdir\fR/info.
880 .TP
881 .B prepman:
882 If a \fIdir\fR is not specified, then \fBprepman\fR will assume the dir
883 \fIusr\fR. \fBprepman\fR will then compress all the files in
884 ${ED}/\fIdir\fR/man/*/.
885 .TP
886 .B prepstrip:
887 All the files found in ${ED}/\fIdir\fR will be stripped.  You may specify
888 multiple directories.
889 .RE
890 .PD 1
891 .TP
892 \fBdosed\fR \fI"s:orig:change:g" <filename>\fR
893 Performs sed in place on \fIfilename\fR inside ${ED}. If no expression is
894 given then \fI"s:${D}::g"\fR is used as the default expression.  Note
895 that this expression does \fBNOT\fR use the offset prefix.
896 .br
897 .BR 'dosed\ "s:/usr/local:/usr:g"\ /usr/bin/some\-script'
898 runs sed on ${ED}/usr/bin/some\-script
899 .TP
900 \fBdodir\fR \fI<path>\fR
901 Creates a directory inside of ${ED}.
902 .br
903 .BR 'dodir\ /usr/lib/apache'
904 creates ${ED}/usr/lib/apache.  Note that the do* functions will run
905 \fBdodir\fR for you.
906 .TP
907 \fBdiropts\fR \fI[options for install(1)]\fR
908 Can be used to define options for the install function used in
909 \fBdodir\fR.  The default is \fI\-m0755\fR.
910 .TP
911 \fBinto\fR \fI<path>\fR
912 Sets the root (\fIDESTTREE\fR) for other functions like \fBdobin\fR,
913 \fBdosbin\fR, \fBdoman\fR, \fBdoinfo\fR, \fBdolib\fR.
914 .br
915 The default root is /usr.
916 .TP
917 \fBkeepdir\fR \fI<path>\fR
918 Tells portage to leave a directory behind even if it is empty.  Functions
919 the same as \fBdodir\fR.
920 .TP
921 \fBdobin\fR \fI<binary> [list of more binaries]\fR
922 Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/bin.
923 Creates all necessary dirs.
924 .TP
925 \fBdosbin\fR \fI<binary> [list of more binaries]\fR
926 Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/sbin.
927 Creates all necessary dirs.
928 .TP
929 \fBdoinitd\fR \fI<init.d script> [list of more init.d scripts]\fR
930 Install Gentoo \fIinit.d scripts\fR.  They will be installed into the
931 correct location for Gentoo init.d scripts (/etc/init.d/).  Creates all
932 necessary dirs.
933 .TP
934 \fBdoconfd\fR \fI<conf.d file> [list of more conf.d file]\fR
935 Install Gentoo \fIconf.d files\fR.  They will be installed into the
936 correct location for Gentoo conf.d files (/etc/conf.d/).  Creates all
937 necessary dirs.
938 .TP
939 \fBdoenvd\fR \fI<env.d entry> [list of more env.d entries]\fR
940 Install Gentoo \fIenv.d entries\fR.  They will be installed into the
941 correct location for Gentoo env.d entries (/etc/env.d/).  Creates all
942 necessary dirs.
943
944 .PD 0
945 .TP
946 \fBdolib\fR \fI<library>\fR \fI[list of more libraries]\fR
947 .TP
948 \fBdolib.a\fR \fI<library>\fR \fI[list of more libraries]\fR
949 .TP
950 \fBdolib.so\fR \fI<library>\fR \fI[list of more libraries]\fR
951 .PD 1
952 Installs a library or a list of libraries into \fIDESTTREE\fR/lib.
953 Creates all necessary dirs.
954 .TP
955 \fBlibopts\fR \fI[options for install(1)]\fR
956 Can be used to define options for the install function used in
957 the \fBdolib\fR functions.  The default is \fI\-m0644\fR.
958 .TP
959 \fBdoman\fR \fI[\-i18n=<locale>]\fR \fI<man\-page> [list of more man\-pages]\fR
960 Installs manual\-pages into /usr/share/man/man[0\-9n] depending on the
961 manual file ending.  The files are compressed if they are not already.  You
962 can specify locale\-specific manpages with the \fI\-i18n\fR option.  Then the
963 man\-page will be installed into /usr/share/man/\fI<locale>\fR/man[0\-9n].
964 Beginning with \fBEAPI 2\fR, a locale\-specific manpage which contains a locale
965 in the file name will be installed in /usr/share/man/\fI<locale>\fR/man[0\-9n],
966 with the locale portion of the file name removed, and the \fI\-i18n\fR option
967 has no effect. For example, with \fBEAPI 2\fR, a manpage named
968 foo.\fI<locale>\fR.1 will be installed as
969 /usr/share/man/\fI<locale>\fR/man1/foo.1.
970 .PD 0
971 .TP
972 \fBdohard\fR \fI<filename> <linkname>\fR
973 .TP
974 \fBdosym\fR \fI<filename> <linkname>\fR
975 .PD 1
976 Performs the ln command as either a hard link or symlink.
977 .TP
978 \fBdohtml\fR \fI [\-a filetypes] [\-r] [\-x list\-of\-dirs\-to\-ignore] [list\-of\-files\-and\-dirs]\fR
979 Installs the files in the list of files (space\-separated list) into
980 /usr/share/doc/${PF}/html provided the file ends in .htm, .html, .css, .js, .gif, .jpeg, .jpg, or .png.
981 Setting \fI\-a\fR limits what types of files will be included,
982 \fI\-A\fR appends to the default list, setting \fI\-x\fR sets which dirs to
983 exclude (CVS excluded by default), \fI\-p\fR sets a document prefix, \fI\-r\fR sets recursive.
984 .TP
985 \fBdoinfo\fR \fI<info\-file> [list of more info\-files]\fR
986 Installs info\-pages into \fIDESTDIR\fR/info.  Files are automatically
987 gzipped.  Creates all necessary dirs.
988 .TP
989 \fBdomo\fR \fI<locale\-file> [list of more locale\-files] \fR
990 Installs locale\-files into \fIDESTDIR\fR/usr/share/locale/[LANG]
991 depending on local\-file's ending.  Creates all necessary dirs.
992
993 .PD 0
994 .TP
995 \fBfowners\fR \fI<permissions> <file> [files]\fR
996 .TP
997 \fBfperms\fR \fI<permissions> <file> [files]\fR
998 .PD 1
999 Performs chown (\fBfowners\fR) or chmod (\fBfperms\fR), applying
1000 \fIpermissions\fR to \fIfiles\fR.
1001 .TP
1002 \fBinsinto\fR \fI[path]\fR
1003 Sets the destination path for the \fBdoins\fR function.
1004 .br
1005 The default path is /.
1006 .TP
1007 \fBinsopts\fR \fI[options for install(1)]\fR
1008 Can be used to define options for the install function used in
1009 \fBdoins\fR.  The default is \fI\-m0644\fR.
1010 .TP
1011 \fBdoins\fR \fI<file> [list of more files]\fR
1012 Installs files into the path controlled by \fBinsinto\fR.  This function
1013 uses \fBinstall\fR(1).  Creates all necessary dirs.
1014 .TP
1015 \fBexeinto\fR \fI[path]\fR
1016 Sets the destination path for the \fBdoexe\fR function.
1017 .br
1018 The default path is /.
1019 .TP
1020 \fBexeopts\fR \fI[options for install(1)]\fR
1021 Can be used to define options for the install function used in \fBdoexe\fR.
1022 The default is \fI\-m0755\fR.
1023 .TP
1024 \fBdoexe\fR \fI<executable> [list of more executables]\fR
1025 Installs executables into the path controlled by \fBexecinto\fR.  This function
1026 uses \fBinstall\fR(1).  Creates all necessary dirs.
1027 .TP
1028 \fBdocinto\fR \fI[path]\fR
1029 Sets the subdir used by \fBdodoc\fR and \fBdohtml\fR
1030 when installing into the document tree
1031 (based in /usr/share/doc/${PF}/).  Default is no subdir, or just "".
1032 .TP
1033 \fBdodoc\fR \fI<document> [list of more documents]\fR
1034 Installs a document or a list of documents into /usr/share/doc/${PF}/\fI<docinto path>\fR.
1035 Documents are marked for compression.  Creates all necessary dirs.
1036
1037 .PD 0
1038 .TP
1039 \fBnewbin\fR \fI<old file> <new filename>\fR
1040 .TP
1041 \fBnewsbin\fR \fI<old file> <new filename>\fR
1042 .TP
1043 \fBnewinitd\fR \fI<old file> <new filename>\fR
1044 .TP
1045 \fBnewconfd\fR \fI<old file> <new filename>\fR
1046 .TP
1047 \fBnewenvd\fR \fI<old file> <new filename>\fR
1048 .TP
1049 \fBnewlib\fR \fI<old file> <new filename>\fR
1050 .TP
1051 \fBnewlib.so\fR \fI<old file> <new filename>\fR
1052 .TP
1053 \fBnewlib.a\fR \fI<old file> <new filename>\fR
1054 .TP
1055 \fBnewman\fR \fI<old file> <new filename>\fR
1056 .TP
1057 \fBnewinfo\fR \fI<old file> <new filename>\fR
1058 .TP
1059 \fBnewins\fR \fI<old file> <new filename>\fR
1060 .TP
1061 \fBnewexe\fR \fI<old file> <new filename>\fR
1062 .TP
1063 \fBnewdoc\fR \fI<old file> <new filename>\fR
1064 .PD 1
1065 All these functions act like the do* functions, but they only work with one
1066 file and the file is installed as \fI[new filename]\fR.
1067 .SH "REPORTING BUGS"
1068 Please report bugs via http://bugs.gentoo.org/
1069 .SH "AUTHORS"
1070 .nf
1071 Achim Gottinger <achim@gentoo.org>
1072 Mark Guertin <gerk@gentoo.org>
1073 Nicholas Jones <carpaski@gentoo.org>
1074 Mike Frysinger <vapier@gentoo.org>
1075 Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@gmail.com>
1076 Fabian Groffen <grobian@gentoo.org>
1077 .fi
1078 .SH "FILES"
1079 .TP
1080 The \fI/usr/sbin/ebuild.sh\fR script.
1081 .TP
1082 The helper apps in \fI/usr/lib/portage/bin\fR.
1083 .TP
1084 .B /etc/make.conf
1085 Contains variables for the build\-process and overwrites those in make.defaults.
1086 .TP
1087 .B /etc/make.globals
1088 Contains the default variables for the build\-process, you should edit
1089 \fI/etc/make.conf\fR instead.
1090 .TP
1091 .B /etc/portage/color.map
1092 Contains variables customizing colors.
1093 .SH "SEE ALSO"
1094 .BR ebuild (1),
1095 .BR make.conf (5),
1096 .BR color.map (5)