summaryrefslogtreecommitdiff
blob: 1ae981b8b6633ac6293219ffe2f53db283d26cfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
.TH "EBUILD" "5" "Aug 2008" "Portage 2.1.6" "Portage"
.SH "NAME"
ebuild \- the internal format, variables, and functions in an ebuild script
.SH "DESCRIPTION"
The
.BR ebuild (1)
program accepts a single ebuild script as an argument.  This script
contains variables and commands that specify how to download, unpack,
patch, compile, install and merge a particular software package from
its original sources.  In addition to all of this, the ebuild script
can also contain pre/post install/remove commands, as required.  All
ebuild scripts are written in bash.
.SH "EXAMPLES"
Here's a simple example ebuild:

.DS
.nf
# Copyright 1999\-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit some_eclass another_eclass

DESCRIPTION="Super\-useful stream editor (sed)"
HOMEPAGE="http://www.gnu.org/software/sed/sed.html"
SRC_URI="ftp://alpha.gnu.org/pub/gnu/${PN}/${P}.tar.gz"

LICENSE="GPL\-2"
SLOT="0"
KEYWORDS="~x86"
IUSE=""

RDEPEND=""
DEPEND="nls? ( sys-devel/gettext )"

src_compile() {
	econf \\
		\-\-bindir=/bin
	emake || die "emake failed"
}

src_install() {
	emake install DESTDIR="${D}" || die "Install failed"
	dodoc NEWS README* THANKS AUTHORS BUGS ChangeLog || die "dodoc failed"
}
.fi
.SH "VARIABLES"
.TP
.B MISC USAGE NOTES
\- All variables defined in \fBmake.conf\fR(5) are available for use in
ebuilds (such as the PORTAGE* and PORTDIR* variables)
.br
\- When assigning values to variables in ebuilds, you \fBcannot have a
space\fR between the variable name and the equal sign.
.br
\- Variable values should only contain characters that are members of the
\fBascii\fR(7) character set. This requirement is mandated by \fBGLEP 31\fR.
.TP
.B P
This variable contains the package name without the ebuild revision.
This variable must NEVER be modified.
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$P\fR=='\fIxfree\-4.2.1\fR'
.TP
.B PN
Contains the name of the script without the version number.
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PN\fR=='\fIxfree\fR'
.TP
.B PV
Contains the version number without the revision.
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PV\fR=='\fI4.2.1\fR'
.TP
.B PR
Contains the revision number or 'r0' if no revision number exists.
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PR\fR=='\fIr2\fR'
.TP
.B PVR
Contains the version number with the revision.
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PVR\fR=='\fI4.2.1\-r2\fR'
.TP
.B PF
Contains the full package name \fI[PN]\-[PVR]\fR
.br
\fBxfree\-4.2.1\-r2.ebuild\fR \-\-> \fB$PF\fR=='\fIxfree\-4.2.1\-r2\fR'
.TP
.B CATEGORY
Contains the package category name.
.TP
.B A
Contains all source files required for the package.  This variable must
not be defined. It is autogenerated from the \fISRC_URI\fR variable.
.TP
\fBWORKDIR\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/work"\fR
Contains the path to the package build root.  Do not modify this variable.
.TP
\fBFILESDIR\fR = \fI"${PORTDIR}/${CATEGORY}/${PN}/files"\fR
Contains the path to the 'files' sub folder in the package specific
location in the portage tree.  Do not modify this variable.
.TP
\fBS\fR = \fI"${WORKDIR}/${P}"\fR
Contains the path to the temporary \fIbuild directory\fR.  This variable
is used by the functions \fIsrc_compile\fR and \fIsrc_install\fR.  Both
are executed with \fIS\fR as the current directory.  This variable may
be modified to match the extraction directory of a tarball for the package.
.TP
\fBT\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/temp"\fR
Contains the path to a \fItemporary directory\fR.  You may use this for
whatever you like.
.TP
\fBD\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/image"\fR
Contains the path to the temporary \fIinstall directory\fR.  Every write
operation that does not involve the helper tools and functions (found below)
should be prefixed with ${D}.  Do not modify this variable.
.TP
.B PORTAGE_LOG_FILE
Contains the path of the build log. If \fBPORT_LOGDIR\fR variable is unset then
\fBPORTAGE_LOG_FILE\fR=\fB"${T}/build.log"\fR.
.TP
\fBROOT\fR = \fI"/"\fR
Contains the path that portage should use as the root of the live filesystem.
When packages wish to make changes to the live filesystem, they should do so in
the tree prefixed by ${ROOT}.  Do not modify this variable.
.TP
\fBDESCRIPTION\fR = \fI"A happy little package"\fR
Should contain a short description of the package.
.TP
\fBEAPI\fR = \fI"0"\fR
Defines the ebuild API version to which this package conforms. If not
defined then it defaults to "0". If portage does not recognize the
EAPI value then it will mask the package and refuse to perform any
operations with it since this means that a newer version of portage
needs to be installed first. For maximum backward compatiblity, a
package should conform to the lowest possible EAPI. Note that anyone
who uses the \fBebuild\fR(1) and \fBrepoman\fR(1) commands with this
package will be required to have a version of portage that recognizes
the EAPI to which this package conforms.
.TP
\fBSRC_URI\fR = \fI"http://happy.com/little/${P}.tar.gz"\fR
Contains a list of URI's for the required source files.  It can contain
multiple URI's for a single source file.  The list is processed in order
if the file was not found on any of the \fIGENTOO_MIRRORS\fR.
Beginning with \fBEAPI 2\fR, the output file name of a given URI may be
customized with a "->" operator on the right hand side, followed by the
desired output file name. All tokens, including the operator and output
file name, should be separated by whitespace.
.TP
\fBHOMEPAGE\fR = \fI"http://happy.com/"\fR
Should contain a list of URL's for the sources main sites and other further
package dependent information.
.TP
\fBKEYWORDS\fR = \fI[\-~][x86,ppc,sparc,mips,alpha,arm,hppa]\fR
Should contain appropriate list of arches that the ebuild is know to
work/not work.  By default if you do not know if an ebuild runs under
a particular arch simply omit that KEYWORD.  If the ebuild will not
work on that arch include it as \-ppc for example.  If the ebuild is
being submitted for inclusion, it must have ~arch set for architectures
where it has been PROVEN TO WORK.  (Packages KEYWORDed this way may be
unmasked for testing by setting ACCEPT_KEYWORDS="~arch" on the command
line, or in \fBmake.conf\fR(5)) For an authoritative list please review
/usr/portage/profiles/arch.list.  Please keep this list in alphabetical order.
.TP
\fBSLOT\fR
This sets the SLOT for packages that may need to have multiple versions
co\-exist.  By default you should set \fBSLOT\fR="0".  If you are unsure, then
do not fiddle with this until you seek some guidance from some guru.  This
value should \fINEVER\fR be left undefined.
.TP
\fBLICENSE\fR
This should be a space delimited list of licenses that the package falls
under.  This \fB_must_\fR be set to a matching license in
/usr/portage/licenses/. If the license does not exist in portage yet, you
must add it first.
.TP
\fBIUSE\fR
This should be a list of any and all USE flags that are leveraged within
your build script.  The only USE flags that should not be listed here are
arch related flags (see \fBKEYWORDS\fR). Beginning with \fBEAPI 1\fR, it
is possible to prefix flags with + or - in order to create default settings
that respectively enable or disable the corresponding \fBUSE\fR flags. For
details about \fBUSE\fR flag stacking order, refer to the \fBUSE_ORDER\fR
variable in \fBmake.conf\fR(5). Given the default \fBUSE_ORDER\fR setting,
negative IUSE default settings are ineffective since profile and user
configuration settings override them.
.TP
\fBDEPEND\fR
This should contain a list of all packages that are required for the
program to compile.
.RS
.TP
.B DEPEND Atoms
A depend atom is simply a dependency that is used by portage when calculating
relationships between packages.  Please note that if the atom has not already
been emerged, then the latest version available is matched.
.RS
.TP
.B Atom Bases
The base atom is just a full category/packagename.  Hence, these are base atoms:

.nf
.I sys\-apps/sed
.I sys\-libs/zlib
.I net\-misc/dhcp
.fi
.TP
.B Atom Versions
It is nice to be more specific and say that only certain versions of atoms are
acceptable.  Note that versions must be combined with a prefix (see below).  
Hence you may add a version number as a postfix to the base:

.nf
sys\-apps/sed\fI\-4.0.5\fR
sys\-libs/zlib\fI\-1.1.4\-r1\fR
net\-misc/dhcp\fI\-3.0_p2\fR
.fi

Versions are normally made up of two or three numbers separated by periods, such
as 1.2 or 4.5.2.  This string may be followed by a character such as 1.2a or 
4.5.2z.  Note that this letter is \fBnot\fR meant to indicate alpha, beta, 
etc... status.  For that, use the optional suffix; either _alpha, _beta, _pre 
(pre\-release), _rc (release candidate), or _p (patch).  This means for the 
3rd pre\-release of a package, you would use something like 1.2_pre3.  The 
suffixes here can be arbitrarily chained without limitation.
.TP
.B Atom Prefix Operators [> >= = <= <]
Sometimes you want to be able to depend on general versions rather than specifying
exact versions all the time.  Hence we provide standard boolean operators:

.nf
\fI>\fRmedia\-libs/libgd\-1.6
\fI>=\fRmedia\-libs/libgd\-1.6
\fI=\fRmedia\-libs/libgd\-1.6
\fI<=\fRmedia\-libs/libgd\-1.6
\fI<\fRmedia\-libs/libgd\-1.6
.fi
.TP
.B Extended Atom Prefixes [!~] and Postfixes [*]
Now to get even fancier, we provide the ability to define blocking packages and
version range matching.  Also note that these extended prefixes/postfixes may
be combined in any way with the atom classes defined above.  Here are some common
examples you may find in the portage tree:

.nf
\fI!\fRapp\-text/dos2unix
=dev\-libs/glib\-2\fI*\fR
\fI!\fR=net\-fs/samba\-2\fI*\fR
\fI~\fRnet\-libs/libnet\-1.0.2a
\fI!!\fR<sys\-apps/portage\-2.1.4_rc1\fI\fR
.fi

\fI!\fR means block packages from being installed at the same time.
.br
\fI!!\fR means block packages from being installed at the same time
and explicitly disallow them from being temporarily installed
simultaneously during a series of upgrades. This syntax is supported
beginning with \fBEAPI 2\fR.
.br
\fI*\fR means match any version of the package so long as the specified base
is matched.  So with a version of '2*', we can match '2.1', '2.2', '2.2.1',
etc... and not match version '1.0', '3.0', '4.1', etc...
.br
\fI~\fR means match any revision of the base version specified.  So in the
above example, we would match versions '1.0.2a', '1.0.2a\-r1', '1.0.2a\-r2',
etc...
.TP
.B Atom Slots
Beginning with \fBEAPI 1\fR, any atom can be constrained to match a specific
\fBSLOT\fR. This is accomplished by appending a colon followed by a
\fBSLOT\fR:

.nf
x11\-libs/qt:3
\fI~\fRx11\-libs/qt-3.3.8:3
\fI>=\fRx11\-libs/qt-3.3.8:3
\fI=\fRx11\-libs/qt-3.3*:3
.fi
.TP
.B Atom USE
Beginning with \fBEAPI 2\fR, any atom can be constrained to match specific
\fBUSE\fR flag settings. When used together with \fBSLOT\fR dependencies,
\fBUSE\fR dependencies appear on the right hand side of \fBSLOT\fR
dependencies.

.RS
.TP
.B Unconditional USE Dependencies
.TS
l l
__
l l.
Example	Meaning

foo[bar]	foo must have bar enabled
foo[bar,baz]	foo must have both bar and baz enabled
foo[\-bar,baz]	foo must have bar disabled and baz enabled
.TE

.TP
.B Conditional USE Dependencies
.TS
l l
__
l l.
Compact Form	Equivalent Expanded Form

foo[bar?]	bar? ( foo[bar] ) !bar? ( foo )
foo[!bar?]	bar? ( foo ) !bar? ( foo[\-bar] )
foo[bar=]	bar? ( foo[bar] ) !bar? ( foo[\-bar] )
foo[!bar=]	bar? ( foo[\-bar] ) !bar? ( foo[bar] )
.TE
.RE
.RE
.TP
.B Dynamic DEPENDs
Sometimes programs may depend on different things depending on the USE
variable.  Portage offers a few options to handle this.  Note that when
using the following syntaxes, each case is considered as 1 Atom in the
scope it appears.  That means that each Atom both conditionally include
multiple Atoms and be nested to an infinite depth.
.RS
.TP
.B usevar? ( DEPEND Atom )
To include the jpeg library when the user has jpeg in \fBUSE\fR, simply use the
following syntax:
.br
.B jpeg? ( media\-libs/jpeg )
.TP
.B !usevar? ( Atom )
If you want to include a package only if the user does not have a certain option
in their \fBUSE\fR variable, then use the following syntax:
.br
.B !nophysfs? ( dev\-games/physfs )
.br
This is often useful for those times when you want to want to add optional support
for a feature and have it enabled by default.
.TP
.B usevar? ( Atom if true ) !usevar? ( Atom if false )
For functionality like the tertiary operator found in C you must use
two statements, one normal and one inverted.  If a package uses
GTK2 or GTK1, but not both, then you can handle that like this:
.br
.B gtk2? ( =x11\-libs/gtk+\-2* ) !gtk2? ( =x11\-libs/gtk+\-1* )
.br
That way the default is the superior GTK2 library.
.TP
.B || ( Atom Atom ... )
When a package can work with a few different packages but a virtual is not
appropriate, this syntax can easily be used.
.nf
.B || (
.B 	app\-games/unreal\-tournament
.B 	app\-games/unreal\-tournament\-goty
.B )
.fi
Here we see that unreal\-tournament has a normal version and it has a goty
version.  Since they provide the same base set of files, another package can
use either.  Adding a virtual is inappropriate due to the small scope of it.
.br
Another good example is when a package can be built with multiple video 
interfaces, but it can only ever have just one.
.nf
.B || (
.B 	sdl? ( media\-libs/libsdl )
.B 	svga? ( media\-libs/svgalib )
.B 	opengl? ( virtual/opengl )
.B 	ggi? ( media\-libs/libggi )
.B 	virtual/x11
.B )
.fi
Here only one of the packages will be chosen, and the order of preference is
determined by the order in which they appear.  So sdl has the best chance of
being chosen, followed by svga, then opengl, then ggi, with a default of X if
the user does not specify any of the previous choices.
.br
Note that if any of the packages listed are already merged, the package manager
will use that to consider the dependency satisfied.
.RE

.RE
.TP
\fBRDEPEND\fR
This should contain a list of all packages that are required for this
program to run (aka runtime depend).  If this is not set, then it
defaults to the value of \fBDEPEND\fR.
.br
You may use the same syntax to vary dependencies as seen above in \fBDEPEND\fR.
.TP
\fBPDEPEND\fR
This should contain a list of all packages that should be merged after this one,
but may be merged before if need be.
.br
You may use the same syntax to vary dependencies as seen above in \fBDEPEND\fR.
.TP
\fBRESTRICT\fR = \fI[strip,mirror,fetch,userpriv]\fR
This should be a space delimited list of portage features to restrict.
You may use conditional syntax to vary restrictions as seen above in DEPEND.
.PD 0
.RS
.TP
.I binchecks
Disable all QA checks for binaries.  This should ONLY be used in packages
for which binary checks make no sense (linux\-headers and kernel\-sources, for
example, can safely be skipped since they have no binaries).  If the binary
checks need to be skipped for other reasons (such as proprietary binaries),
see the \fBQA CONTROL VARIABLES\fR section for more specific exemptions.
.TP
.I bindist
Distribution of built packages is restricted.
.TP
.I fetch
like \fImirror\fR but the files will not be fetched via \fBSRC_URI\fR either.
.TP
.I installsources
Disables installsources for specific packages. This is for packages with
binaries that are not compatible with debugedit.
.TP
.I mirror
files in \fBSRC_URI\fR will not be downloaded from the \fBGENTOO_MIRRORS\fR.
.TP
.I primaryuri
fetch from URL's in \fBSRC_URI\fR before \fBGENTOO_MIRRORS\fR.
.TP
.I strip
final binaries/libraries will not be stripped of debug symbols.
.TP
.I test
do not run src_test even if user has \fBFEATURES\fR=test.
.TP
.I userpriv
Disables userpriv for specific packages.
.RE
.PD 1
.TP
\fBPROPERTIES\fR = \fI[interactive]\fR
A space delimited list of properties, with conditional syntax support.
.PD 0
.RS
.TP
.I interactive
One or more ebuild phases will produce a prompt that requires user interaction.
.RE
.PD 1
.TP
\fBPROVIDE\fR = \fI"virtual/TARGET"\fR
This variable should only be used when a package provides a virtual target.
For example, blackdown\-jdk and sun\-jdk provide \fIvirtual/jdk\fR.  This
allows for packages to depend on \fIvirtual/jdk\fR rather than on blackdown
or sun specifically.
.SH "QA CONTROL VARIABLES"
.TP
.B USAGE NOTES
Several QA variables are provided which allow an ebuild to manipulate some
of the QA checks performed by portage.  Use of these variables in ebuilds
should be kept to an absolute minimum otherwise they defeat the purpose
of the QA checks, and their use is subject to agreement of the QA team.
They are primarily intended for use by ebuilds that install closed\-source
binary objects that cannot be altered.
.br
Note that objects that violate these rules may fail on some architectures.
.TP
\fBQA_TEXTRELS\fR
This variable can be set to a list of file paths, relative to the image
directory, of files that contain text relocations that cannot be eliminated.
The paths may contain regular expressions.
.br
This variable is intended to be used on closed\-source binary objects that
cannot be altered.
.TP
\fBQA_EXECSTACK\fR
This should contain a list of file paths, relative to the image directory, of
objects that require executable stack in order to run.
The paths may contain regular expressions.
.br
This variable is intended to be used on objects that truly need executable
stack (i.e. not those marked to need it which in fact do not).
.TP
\fBQA_WX_LOAD\fR
This should contain a list of file paths, relative to the image directory, of
files that contain writable and executable segments.  These are rare.
The paths may contain regular expressions.
.TP
\fBQA_DT_HASH\fR
This should contain a list of file paths, relative to the image directory, of
files that contain .hash sections. The paths may contain regular expressions
with escape\-quoted special characters.
.TP
\fBQA_PRESTRIPPED\fR
This should contain a list of file paths, relative to the image directory, of
files that contain pre-stripped binaries. The paths may contain regular
expressions with escape\-quoted special characters.
.SH "PORTAGE DECLARATIONS"
.TP
.B inherit
Inherit is portage's maintenance of extra classes of functions that are
external to ebuilds and provided as inheritable capabilities and data. They
define functions and set data types as drop\-in replacements, expanded, and
simplified routines for extremely common tasks to streamline the build
process.  Inherit may only be called once in an ebuild and it may \fBnever be
wrapped within any conditionals\fR of any kind.  Specification of the eclasses
contains only their name and not the \fI.eclass\fR extension.  Also note that
the inherit statement must come before other variable declarations.
.SH "PHASE FUNCTIONS"
.TP
.B pkg_nofetch
If you turn on \fIfetch\fR in \fBRESTRICT\fR, then this function will be
run when the files in \fBSRC_URI\fR cannot be found.  Useful for
displaying information to the user on *how* to obtain said files.  All
you have to do is output a message and let the function return.  Do not
end the function with a call to \fBdie\fR.
.TP
.B pkg_setup
This function can be used if the package needs specific setup actions or
checks to be preformed before anything else.
.br
Initial working directory of ${PORTAGE_TMPDIR}.
.TP
.B src_unpack
This function is used to unpack all the sources in \fIA\fR to \fIWORKDIR\fR.
If not defined in the \fIebuild script\fR it calls \fIunpack ${A}\fR. Any
patches and other pre configure/compile modifications should be done here.
.br
Initial working directory of $WORKDIR.
.TP
.B src_prepare
All preparation of source code, such as application of patches, should be done
here. This function is supported beginning with \fBEAPI 2\fR.
.br
Initial working directory of $S.
.TP
.B src_configure
All necessary steps for configuration should be done here. This function is
supported beginning with \fBEAPI 2\fR.
.br
Initial working directory of $S.
.TP
.B src_compile
With less than \fBEAPI 2\fR, all necessary steps for both configuration and
compilation should be done here. Beginning with \fBEAPI 2\fR, only compilation
steps should be done here.
.br
Initial working directory of $S.
.TP
.B src_test
Run all package specific test cases.  The default is to run 'make check'
followed 'make test'.
.br
Initial working directory of $S.
.TP
.B src_install
Should contain everything required to install the package in the temporary
\fIinstall directory\fR.
.br
Initial working directory of $S.
.TP
.B pkg_preinst pkg_postinst
All modifications required on the live\-filesystem before and after the
package is merged should be placed here. Also commentary for the user
should be listed here as it will be displayed last.
.br
Initial working directory of $PWD.
.TP
.B pkg_prerm pkg_postrm
Like the pkg_*inst functions but for unmerge.
.br
Initial working directory of $PWD.
.TP
.B pkg_config
This function should contain optional basic configuration steps.
.br
Initial working directory of $PWD.
.SH "HELPER FUNCTIONS: PHASES"
.TP
.B default
Calls the default phase function implementation for the currently executing
phase. This function is supported beginning with \fBEAPI 2\fR.
.TP
.B default_*
Beginning with \fBEAPI 2\fR, the default pkg_nofetch and src_* phase
functions are accessible via a function having a name that begins with
default_ and ends with the respective phase function name. For example,
a call to a function with the name default_src_compile is equivalent to
a call to the default src_compile implementation.

.RS
.TS
l
_
l.
Default Phase Functions

default_pkg_nofetch
default_src_unpack
default_src_prepare
default_src_configure
default_src_compile
default_src_test
.TE
.RE
.SH "HELPER FUNCTIONS: GENERAL"
.TP
\fBdie\fR \fI[reason]\fR
Causes the current emerge process to be aborted. The final display will
include \fIreason\fR.
.TP
\fBuse\fR \fI<USE item>\fR
If \fIUSE item\fR is in the \fBUSE\fR variable, the function will silently
return 0 (aka shell true).  If \fIUSE item\fR is not in the \fBUSE\fR
variable, the function will silently return 1 (aka shell false).  \fBusev\fR
is a verbose version of \fBuse\fR.
.RS
.TP
.I Example:
.nf
if use gnome ; then
	guiconf="\-\-enable\-gui=gnome \-\-with\-x"
elif use gtk ; then
	guiconf="\-\-enable\-gui=gtk \-\-with\-x"
elif use X ; then
	guiconf="\-\-enable\-gui=athena \-\-with\-x"
else
	# No gui version will be built
	guiconf=""
fi
.fi
.RE
.TP
\fBuse_with\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]\fR
Useful for creating custom options to pass to a configure script. If \fIUSE
item\fR is in the \fBUSE\fR variable and a \fIconfigure opt\fR is specified,
then the string \fI\-\-with\-[configure name]=[configure opt]\fR will be echoed.
If \fIconfigure opt\fR is not specified, then just \fI\-\-with\-[configure
name]\fR will be echoed.  If \fIUSE item\fR is not in the \fBUSE\fR variable,
then the string \fI\-\-without\-[configure name]\fR will be echoed. If
\fIconfigure name\fR is not specified, then \fIUSE item\fR will be used in
its place.
.RS
.TP
.I Examples:
.nf
USE="opengl"
myconf=$(use_with opengl)
(myconf now has the value "\-\-with\-opengl")

USE="jpeg"
myconf=$(use_with jpeg libjpeg)
(myconf now has the value "\-\-with\-libjpeg")

USE=""
myconf=$(use_with jpeg libjpeg)
(myconf now has the value "\-\-without\-libjpeg")

USE="sdl"
myconf=$(use_with sdl SDL all\-plugins)
(myconf now has the value "\-\-with\-SDL=all\-plugins")
.fi
.RE
.TP
\fBuse_enable\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]\fR
Same as \fBuse_with\fR above, except that the configure options are
\fI\-\-enable\-\fR instead of \fI\-\-with\-\fR and \fI\-\-disable\-\fR instead of
\fI\-\-without\-\fR.
.TP
\fBhas\fR \fI<item>\fR \fI<item list>\fR
If \fIitem\fR is in \fIitem list\fR, then \fIitem\fR is echoed and \fBhas\fR
returns 0.  Otherwise, nothing is echoed and 1 is returned. As indicated with
use, there is a non\-echoing version \fBhasq\fR. Please use \fBhasq\fR in all
places where output is to be disregarded. Never use the output for calculation.
.br
The \fIitem list\fR is delimited by the \fIIFS\fR variable.  This variable
has a default value of ' ', or a space.  It is a \fBbash\fR(1) setting.
.TP
\fBhas_version\fR \fI<category/package\-version>\fR
Check to see if \fIcategory/package\-version\fR is installed on the system.
The parameter accepts all values that are acceptable in the \fBDEPEND\fR
variable.  The function returns 0 if \fIcategory/package\-version\fR is
installed, 1 otherwise.
.TP
\fBbest_version\fR \fI<package name>\fR
This function will look up \fIpackage name\fR in the database of currently
installed programs and echo the "best version" of the package that is
currently installed. 
.RS
.TP
.I Example:
VERINS="$(best_version net\-ftp/glftpd)"
.br
(VERINS now has the value "net\-ftp/glftpd\-1.27" if glftpd\-1.27 is installed)
.RE
.SH "HELPER FUNCTIONS: OUTPUT"
.TP
\fBeinfo\fR \fI"disposable message"\fR
Same as \fBelog\fR, but should be used when the message isn't important to the
user (like progress or status messages during the build process).
.TP
\fBelog\fR \fI"informative message"\fR
If you need to display a message that you wish the user to read and take
notice of, then use \fBelog\fR.  It works just like \fBecho\fR(1), but
adds a little more to the output so as to catch the user's eye. The message
will also be logged by portage for later review.
.TP
\fBewarn\fR \fI"warning message"\fR
Same as \fBeinfo\fR, but should be used when showing a warning to the user.
.TP
\fBeqawarn\fR \fI"QA warning message"\fR
Same as \fBeinfo\fR, but should be used when showing a QA warning to the user.
.TP
\fBeerror\fR \fI"error message"\fR
Same as \fBeinfo\fR, but should be used when showing an error to the user.
.TP
\fBebegin\fR \fI"helpful message"\fR
Like \fBeinfo\fR, we output a \fIhelpful message\fR and then hint that the
following operation may take some time to complete.  Once the task is
finished, you need to call \fBeend\fR.
.TP
\fBeend\fR \fI<status>\fR \fI["error message"]\fR
Followup the \fBebegin\fR message with an appropriate "OK" or "!!" (for
errors) marker.  If \fIstatus\fR is non\-zero, then the additional \fIerror
message\fR is displayed.
.SH "HELPER FUNCTIONS: UNPACK"
.TP
\fBunpack\fR \fI<source>\fR \fI[list of more sources]\fR
This function uncompresses and/or untars a list of sources into the current
directory. The function will append \fIsource\fR to the \fBDISTDIR\fR variable.
.SH "HELPER FUNCTIONS: COMPILE"
.TP
\fBeconf\fR \fI[configure options]\fR
This is used as a replacement for configure.  Performs:
.nf
${\fIECONF_SOURCE\fR:-.}/configure \\
	\-\-prefix=/usr \\
	\-\-host=${CHOST} \\
	\-\-mandir=/usr/share/man \\
	\-\-infodir=/usr/share/info \\
	\-\-datadir=/usr/share \\
	\-\-sysconfdir=/etc \\
	\-\-localstatedir=/var/lib \\
	\fI${EXTRA_ECONF}\fR \\
	\fIconfigure options\fR || die "econf failed"
.fi
Note that the \fIEXTRA_ECONF\fR is for users only, not for ebuild
writers.  If you wish to pass more options to configure, just pass the
extra arguements to \fBeconf\fR. Also note that \fBeconf\fR automatically
calls \fBdie\fR if the configure script fails.
.TP
\fBemake\fR \fI[make options]\fR
This is used as a replacement for make.  Performs 'make ${MAKEOPTS}
\fImake options\fR' (as set in /etc/make.globals), default is MAKEOPTS="\-j2".

\fB***warning***\fR
.br
if you are going to use \fBemake\fR, make sure your build is happy with
parallel makes (make \-j2).  It should be tested thoroughly as parallel
makes are notorious for failing _sometimes_ but not always.  If you determine
that your package fails to build in parallel, and you are unable to resolve
the issue, then you should run '\fBemake\fR \-j1' instead of 'make'.
.SH "HELPER FUNCTIONS: INSTALL"
.TP
\fBeinstall\fR \fI[make options]\fR
This is used as a replacement for make install.  Performs:
.nf
make \\
	prefix=${D}/usr \\
	datadir=${D}/usr/share \\
	infodir=${D}/usr/share/info \\
	localstatedir=${D}/var/lib \\
	mandir=${D}/usr/share/man \\
	sysconfdir=${D}/etc \\
	\fI${EXTRA_EINSTALL}\fR \\
	\fImake options\fR \\
	install
.fi
Please do \fBnot\fR use this in place of 'emake install DESTDIR=${D}'.
That is the preferred way of installing make\-based packages.  Also, do
not utilize the \fIEXTRA_EINSTALL\fR variable since it is for users.

.PD 0
.TP
.B prepall
.TP
.B prepalldocs
.TP
.B prepallinfo
.TP
.B prepallman
.TP
.B prepallstrip
.PD 1
Useful for when a package installs into \fB${D}\fR via scripts
(i.e. makefiles).  If you want to be sure that libraries are executable,
aclocal files are installed into the right place, doc/info/man files are
all compressed, and that executables are all stripped of debugging symbols,
then use these suite of functions.
.RS
.PD 0
.TP
.B prepall:
Runs \fBprepallman\fR, \fBprepallinfo\fR, \fBprepallstrip\fR, sets
libraries +x, and then checks aclocal directories.  Please note this
does \fI*not*\fR run \fBprepalldocs\fR.
.TP
.B prepalldocs:
Compresses all doc files in ${D}/usr/share/doc.
.TP
.B prepallinfo:
Compresses all info files in ${D}/usr/share/info.
.TP
.B prepallman:
Compresses all man files in ${D}/usr/share/man.
.TP
.B prepallstrip:
Strips all executable files of debugging symboles.  This includes libraries.
.RE

.TP
\fBprepinfo\fR \fI[dir]\fR
.TP
\fBprepman\fR \fI[dir]\fR
.TP
\fBprepstrip\fR \fI[dir]\fR
.PD 1
Similiar to the \fBprepall\fR functions, these are subtle in their differences.
.RS
.PD 0
.TP
.B prepinfo:
If a \fIdir\fR is not specified, then \fBprepinfo\fR will assume the dir
\fIusr\fR. \fBprepinfo\fR will then compress all the files in
${D}/\fIdir\fR/info.
.TP
.B prepman:
If a \fIdir\fR is not specified, then \fBprepman\fR will assume the dir
\fIusr\fR. \fBprepman\fR will then compress all the files in
${D}/\fIdir\fR/man/*/.
.TP
.B prepstrip:
All the files found in ${D}/\fIdir\fR will be stripped.  You may specify
multiple directories.
.RE
.PD 1
.TP
\fBdosed\fR \fI"s:orig:change:g" <filename>\fR
Performs sed in place on \fIfilename\fR inside ${D}. If no expression is
given then \fI"s:${D}::g"\fR is used as the default expression.
.br
.BR 'dosed\ "s:/usr/local:/usr:g"\ /usr/bin/some\-script'
runs sed on ${D}/usr/bin/some\-script
.TP
\fBdodir\fR \fI<path>\fR
Creates a directory inside of ${D}.
.br
.BR 'dodir\ /usr/lib/apache'
creates ${D}/usr/lib/apache.  Note that the do* functions will run
\fBdodir\fR for you.
.TP
\fBdiropts\fR \fI[options for install(1)]\fR
Can be used to define options for the install function used in
\fBdodir\fR.  The default is \fI\-m0755\fR.
.TP
\fBinto\fR \fI<path>\fR
Sets the root (\fIDESTTREE\fR) for other functions like \fBdobin\fR,
\fBdosbin\fR, \fBdoman\fR, \fBdoinfo\fR, \fBdolib\fR.
.br
The default root is /usr.
.TP
\fBkeepdir\fR \fI<path>\fR
Tells portage to leave a directory behind even if it is empty.  Functions
the same as \fBdodir\fR.
.TP
\fBdobin\fR \fI<binary> [list of more binaries]\fR
Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/bin.
Creates all necessary dirs.
.TP
\fBdosbin\fR \fI<binary> [list of more binaries]\fR
Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/sbin.
Creates all necessary dirs.
.TP
\fBdoinitd\fR \fI<init.d script> [list of more init.d scripts]\fR
Install Gentoo \fIinit.d scripts\fR.  They will be installed into the
correct location for Gentoo init.d scripts (/etc/init.d/).  Creates all
necessary dirs.
.TP
\fBdoconfd\fR \fI<conf.d file> [list of more conf.d file]\fR
Install Gentoo \fIconf.d files\fR.  They will be installed into the
correct location for Gentoo conf.d files (/etc/conf.d/).  Creates all
necessary dirs.
.TP
\fBdoenvd\fR \fI<env.d entry> [list of more env.d entries]\fR
Install Gentoo \fIenv.d entries\fR.  They will be installed into the
correct location for Gentoo env.d entries (/etc/env.d/).  Creates all
necessary dirs.

.PD 0
.TP
\fBdolib\fR \fI<library>\fR \fI[list of more libraries]\fR
.TP
\fBdolib.a\fR \fI<library>\fR \fI[list of more libraries]\fR
.TP
\fBdolib.so\fR \fI<library>\fR \fI[list of more libraries]\fR
.PD 1
Installs a library or a list of libraries into \fIDESTTREE\fR/lib.
Creates all necessary dirs.
.TP
\fBlibopts\fR \fI[options for install(1)]\fR
Can be used to define options for the install function used in
the \fBdolib\fR functions.  The default is \fI\-m0644\fR.
.TP
\fBdoman\fR \fI[\-i18n=<locale>]\fR \fI<man\-page> [list of more man\-pages]\fR
Installs manual\-pages into /usr/share/man/man[0\-9n] depending on the
manual file ending.  The files are compressed if they are not already.  You
can specify locale\-specific manpages with the \fI\-i18n\fR option.  Then the
man\-page will be installed into /usr/share/man/\fI<locale>\fR/man[0\-9n].
Beginning with \fBEAPI 2\fR, a locale\-specific manpage which contains a locale
in the file name will be installed in /usr/share/man/\fI<locale>\fR/man[0\-9n],
with the locale portion of the file name removed, and the \fI\-i18n\fR option
has no effect. For example, with \fBEAPI 2\fR, a manpage named
foo.\fI<locale>\fR.1 will be installed as
/usr/share/man/\fI<locale>\fR/man1/foo.1.
.PD 0
.TP
\fBdohard\fR \fI<filename> <linkname>\fR
.TP
\fBdosym\fR \fI<filename> <linkname>\fR
.PD 1
Performs the ln command as either a hard link or symlink.
.TP
\fBdohtml\fR \fI [\-a filetypes] [\-r] [\-x list\-of\-dirs\-to\-ignore] [list\-of\-files\-and\-dirs]\fR
Installs the files in the list of files (space\-separated list) into
/usr/share/doc/${PF}/html provided the file ends in .htm, .html, .css, .js, .gif, .jpeg, .jpg, or .png.
Setting \fI\-a\fR limits what types of files will be included,
\fI\-A\fR appends to the default list, setting \fI\-x\fR sets which dirs to
exclude (CVS excluded by default), \fI\-p\fR sets a document prefix, \fI\-r\fR sets recursive.
.TP
\fBdoinfo\fR \fI<info\-file> [list of more info\-files]\fR
Installs info\-pages into \fIDESTDIR\fR/info.  Files are automatically
gzipped.  Creates all necessary dirs.
.TP
\fBdomo\fR \fI<locale\-file> [list of more locale\-files] \fR
Installs locale\-files into \fIDESTDIR\fR/usr/share/locale/[LANG]
depending on local\-file's ending.  Creates all necessary dirs.

.PD 0
.TP
\fBfowners\fR \fI<permissions> <file> [files]\fR
.TP
\fBfperms\fR \fI<permissions> <file> [files]\fR
.PD 1
Performs chown (\fBfowners\fR) or chmod (\fBfperms\fR), applying
\fIpermissions\fR to \fIfiles\fR.
.TP
\fBinsinto\fR \fI[path]\fR
Sets the destination path for the \fBdoins\fR function.
.br
The default path is /.
.TP
\fBinsopts\fR \fI[options for install(1)]\fR
Can be used to define options for the install function used in
\fBdoins\fR.  The default is \fI\-m0644\fR.
.TP
\fBdoins\fR \fI<file> [list of more files]\fR
Installs files into the path controlled by \fBinsinto\fR.  This function
uses \fBinstall\fR(1).  Creates all necessary dirs.
.TP
\fBexeinto\fR \fI[path]\fR
Sets the destination path for the \fBdoexe\fR function.
.br
The default path is /.
.TP
\fBexeopts\fR \fI[options for install(1)]\fR
Can be used to define options for the install function used in \fBdoexe\fR.
The default is \fI\-m0755\fR.
.TP
\fBdoexe\fR \fI<executable> [list of more executables]\fR
Installs executables into the path controlled by \fBexecinto\fR.  This function
uses \fBinstall\fR(1).  Creates all necessary dirs.
.TP
\fBdocinto\fR \fI[path]\fR
Sets the subdir used by \fBdodoc\fR and \fBdohtml\fR
when installing into the document tree
(based in /usr/share/doc/${PF}/).  Default is no subdir, or just "".
.TP
\fBdodoc\fR \fI<document> [list of more documents]\fR
Installs a document or a list of documents into /usr/share/doc/${PF}/\fI<docinto path>\fR.
Documents are marked for compression.  Creates all necessary dirs.

.PD 0
.TP
\fBnewbin\fR \fI<old file> <new filename>\fR
.TP
\fBnewsbin\fR \fI<old file> <new filename>\fR
.TP
\fBnewinitd\fR \fI<old file> <new filename>\fR
.TP
\fBnewconfd\fR \fI<old file> <new filename>\fR
.TP
\fBnewenvd\fR \fI<old file> <new filename>\fR
.TP
\fBnewlib\fR \fI<old file> <new filename>\fR
.TP
\fBnewlib.so\fR \fI<old file> <new filename>\fR
.TP
\fBnewlib.a\fR \fI<old file> <new filename>\fR
.TP
\fBnewman\fR \fI<old file> <new filename>\fR
.TP
\fBnewinfo\fR \fI<old file> <new filename>\fR
.TP
\fBnewins\fR \fI<old file> <new filename>\fR
.TP
\fBnewexe\fR \fI<old file> <new filename>\fR
.TP
\fBnewdoc\fR \fI<old file> <new filename>\fR
.PD 1
All these functions act like the do* functions, but they only work with one
file and the file is installed as \fI[new filename]\fR.
.SH "REPORTING BUGS"
Please report bugs via http://bugs.gentoo.org/
.SH "AUTHORS"
.nf
Achim Gottinger <achim@gentoo.org>
Mark Guertin <gerk@gentoo.org>
Nicholas Jones <carpaski@gentoo.org>
Mike Frysinger <vapier@gentoo.org>
Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA@gmail.com>
.fi
.SH "FILES"
.TP
The \fI/usr/sbin/ebuild.sh\fR script.
.TP
The helper apps in \fI/usr/lib/portage/bin\fR.
.TP
.B /etc/make.conf
Contains variables for the build\-process and overwrites those in make.defaults.
.TP
.B /etc/make.globals
Contains the default variables for the build\-process, you should edit
\fI/etc/make.conf\fR instead.
.TP
.B /etc/portage/color.map
Contains variables customizing colors.
.SH "SEE ALSO"
.BR ebuild (1),
.BR make.conf (5),
.BR color.map (5)