aboutsummaryrefslogtreecommitdiff
blob: d3754220967f84cb22039d62079174602dba5272 (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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
<?xml version="1.0"?>
<guide self="ebuild-writing/eapi/">
<chapter>
<title>EAPI Usage and Description</title>

<body>
<p>
The Package Manager Specification (PMS) is a standardization
effort to ensure that the ebuild file format, the ebuild repository format
(of which the Gentoo repository is Gentoo's main incarnation) as well as behavior
of the package managers interacting with these ebuilds is properly written
down and agreed upon.
</p>

<p>
EAPI is a version defined in ebuilds and other package manager related files
which informs the package manager about the file syntax and content. It is,
in effect, the version of the package manager specification (PMS) that the
file adheres to.
</p>

<p>
This section provides usage and descriptions of the different EAPIs.
</p>

<section>
<title>Usage of EAPIs</title>
<body>
<important>
An overview about the important features of each EAPI is provided in the
appendix of the Package Manager Specification.  The two-page leaflet
can be printed out, consulted for reference and is available
as <c>app-doc/pms</c> in the main tree.
</important>
<p>
If EAPI is undefined in an ebuild, then EAPI=0 is selected.  You should
set the EAPI variable, by specifying it at the top of the ebuild:
</p>

<note>
Most developers prefer to set the EAPI version without quotes. However, the PMS allows single and double quotes as well.
</note>

<codesample lang="ebuild">
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6
</codesample>

<important>
EAPI must only be defined in ebuild files, not eclasses. (eclasses may have
EAPI-conditional code)
</important>

<p>
When writing new ebuilds developers can choose whathever EAPI they think
is the best.  Using the features of the latest EAPI is encouraged.
</p>

</body>
</section>

<section>
<title>EAPI=1</title>
<body>

<ul>
	<li>
		<p><b>Default src_compile Phase Function</b></p>
		<p>
		Support for the <c>ECONF_SOURCE</c> variable, which is also supported by
		<c>econf</c>, has been added to the default <c>src_compile</c> implementation.
		</p>
		<codesample lang="ebuild">
src_compile() {
	if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
		econf
	fi
	if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ] ; then
		emake || die "emake failed"
	fi
}
		</codesample>
	</li>
	<li>
		<p><b>SLOT dependencies</b></p>
		<p>
		Any valid package dependency specification can be constrained to match
		a specific SLOT. This is accomplished by appending a colon to the
		specification, followed by a SLOT value.
		</p>
		<p>
		<b>SLOT dependency examples:</b>
		<ul>
			<li><c>x11-libs/qt:3</c></li>
			<li><c>~x11-libs/qt-3.3.8:3</c></li>
			<li><c>&gt;=x11-libs/qt-3.3.8:3</c></li>
			<li><c>=x11-libs/qt-3.3*:3</c></li>
		</ul>
		</p>
	</li>
	<li>
		<p><b>IUSE defaults</b></p>
		<p>
		Add + or - before the name of the use flag in IUSE to turn it on or off by
		default.
		</p>

		<important>
		The default USE-ordering is <c>USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d"</c>
		(see man make.conf)
		</important>
		<important>
		Disabling default IUSE is pretty much useless as it does not
		override the profile and user config (make.conf and package.use)
		</important>

		<codesample lang="ebuild">
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=1

IUSE="foo +bar"

		</codesample>
	</li>
</ul>

</body>
</section>


<section>
<title>EAPI=2</title>
<body>

<subsection>
<title>Helpers</title>
<body>
<ul>
	<li>
		<p><b>doman Language Support</b></p>
		<p>
		<c>doman</c> automatically detects language codes and puts it in the
		appropriate directory.
		<codesample lang="ebuild">
doman foo.1
# will go into /usr/share/man/man1/foo.1
doman foo.lang.1
# will go into /usr/share/man/lang/man1/foo.1 with EAPI=2
		</codesample>
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Metadata</title>
<body>
<ul>
	<li>
		<p><b>Blockers</b></p>
		<p>
		<ul>
			<li>
				<p><b>New Meaning for Old Syntax</b></p>
				<p>
				Blockers which use the previously existing <c>!</c> syntax
				now have a slightly different meaning. These so-called
				<e>weak blocks</e> indicate that conflicting packages may
				be temporarily installed simultaneously. When temporary
				simultaneous installation of conflicting packages occurs, the
				installation of a newer package may overwrite any colliding
				files that belong to an older package which is explicitly
				blocked. When such file collisions occur, the colliding files
				cease to belong to the older package, and they remain installed
				after the older package is eventually uninstalled. The older
				package is uninstalled only after any newer blocking packages
				have been merged on top of it.
			</p>
			</li>
			<li>
				<p><b>New <c>!!</c> Operator</b></p>
				<p>
				A new <c>!!</c> operator for <e>strong blocks</e> is now
				supported, for use in special cases for which temporary
				simultaneous installation of conflicting packages should not be
				allowed. If both weak and strong blocks match a given package,
				the strong block takes precedence.
				</p>
			</li>
		</ul>
		</p>
	</li>
	<li>
		<p><b>USE Dependencies</b></p>
		<p>
		It is possible to depend on USE-flags of packages.
		</p>
		<p>Examples:
		<ul>
			<li><c>foo[bar]</c> means that package foo must have USE-flag bar
			enabled</li>
			<li><c>foo[bar,baz]</c> means that the package foo must have both
				the bar and baz USE-flags enabled
			</li>
			<li><c>foo[-bar,baz]</c> means that the package foo must have the
				bar USE-flag disabled and baz USE-flag enabled</li>
			<li><c>foo[bar?]</c> means <c>bar? ( foo[bar] ) !bar? ( foo )</c></li>
			<li><c>foo[!bar?]</c> means <c>bar? ( foo ) !bar? ( foo[-bar] )</c></li>
			<li><c>foo[bar=]</c> means <c>bar? ( foo[bar] ) !bar? ( foo[-bar] )</c></li>
			<li><c>foo[!bar=]</c> means <c>bar? ( foo[-bar] ) !bar? ( foo[bar] )</c></li>
		</ul>
		</p>
	</li>
	<li>
		<p><b>Customization of Output File Names in SRC_URI</b></p>
		<p>
		A new syntax is supported which allows customization of the output
		file name for a given URI. In order to customize the output file
		name, a given URI should be followed by a "<c>-&gt;</c>" operator which, in
		turn, should be followed by the desired output file name. As
		usual, all tokens, including the operator and output file name,
		should be separated by whitespace.
		</p>
		<p>Example:</p>
		<codesample lang="ebuild">
SRC_URI="https://dl.google.com/earth/client/GE4/release_4_3/GoogleEarthLinux.bin
                        -&gt; GoogleEarthLinux-${PV}.bin"
		</codesample>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Phases</title>
<body>
<ul>
	<li>
		<p><b>New <c>src_prepare</c> Phase Function</b></p>
		<p>
		A new src_prepare function is called after the <c>src_unpack</c>
		function, with cwd initially set to <c>$S</c>.
		</p>
	</li>
	<li>
		<p><b>New <c>src_configure</c> Phase Function</b></p>
		<p>
		The configure portion of the <c>src_compile</c> function has been split
		into a separate function which is named <c>src_configure</c>. The
		<c>src_configure</c> function is called in-between the <c>src_prepare</c> and
		<c>src_compile</c> functions.
		</p>
		<p>The default <c>src_configure</c> and <c>src_compile</c>
		functions in EAPI=2:
		<codesample lang="ebuild">
src_configure() {
	if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
		econf
	fi
}

src_compile() {
	if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ] ; then
		emake || die "emake failed"
	fi
}
		</codesample>
		</p>
	</li>
	<li>
		<p><b>Execution Order of Phase Functions</b></p>
		<p>
		<ul>
			<li><c>pkg_setup</c></li>
			<li><c>src_unpack</c></li>
			<li><c>src_prepare</c></li>
			<li><c>src_configure</c></li>
			<li><c>src_compile</c></li>
			<li><c>src_test</c></li>
			<li><c>src_install</c></li>
			<li><c>pkg_preinst</c></li>
			<li><c>pkg_postinst</c></li>
			<li><c>pkg_prerm</c></li>
			<li><c>pkg_postrm</c></li>
		</ul>
		</p>
	</li>
	<li>
		<p><b>Default Phase Functions</b></p>
		<p>
		The default <c>pkg_nofetch</c> and <c>src_*</c> phase functions are now
		accessible via a function having a name that begins with <c>default_</c>
		and ends with the respective phase function name. For example, a
		call to a function with the name <c>default_src_compile</c> is equivalent
		to a call to the default <c>src_compile</c> implementation.
		</p>
		<p>The default phase functions are:
		<ul>
			<li><c>default_pkg_nofetch</c></li>
			<li><c>default_src_unpack</c></li>
			<li><c>default_src_prepare</c></li>
			<li><c>default_src_configure</c></li>
			<li><c>default_src_compile</c></li>
			<li><c>default_src_test</c></li>
		</ul>
		</p>
	</li>
	<li>
		<p><b>Default Phase Function Alias</b></p>
		<p>
		A function named "<c>default</c>" is redefined for each phase so that it
		will call the <c>default_*</c> function corresponding to the current
		phase. For example, a call to the function named "<c>default</c>" during
		the <c>src_compile</c> phase is equivalent to a call to the function
		named <c>default_src_compile</c>.
		</p>
	</li>
</ul>
</body>
</subsection>

</body>
</section>
<section>
<title>EAPI=3</title>
<body>

<ul>
	<li>
		<p><b>Gentoo Prefix support</b></p>
		<p>
			Support for the <c>EPREFIX</c>, <c>EROOT</c>, and <c>ED</c>
			variables. If an ebuild uses one of these, it must be EAPI3 aware.
			See <uri link="https://www.gentoo.org/proj/en/gentoo-alt/prefix/techdocs.xml#doc_chap2">Gentoo Prefix Techdocs</uri> for more information.
		</p>
	</li>
	<li>
		<p><b>unpack supports .xz and .tar.xz</b></p>
		<p>
			The <c>unpack</c> command supports xz-archives and xz-compressed tar
			files.
		</p>
	</li>
</ul>

</body>
</section>

<section>
<title>EAPI=4</title>
<body>

<subsection>
<title>Helpers</title>
<body>
<ul>
	<li>
		<p><b>utilities die on their own, unless the nonfatal command is used</b></p>
		<p>
			<!-- TODO link auf fuunction-reference -->
			Ebuild functions all die on their own in EAPI=4. In case that this
			non-zero exit status is expected, you may call <c>nonfatal function
			[arg,...]</c>.
		</p>
		<p>Example:</p>
		<codesample lang="ebuild">
EAPI=2
...
src_test() {
	if ! emake check ; then
		local a
		eerror "Tests failed. Looking for files for you to add to your bug report..."
		while IFS='' read -r -d $'\0' a ; do
			eerror "    ${a}"
		done &lt; &lt;(find "${S}" -type f '(' -name '*.epicfail' -o -name '*.log' ')' -print0)
		die "Make check failed"
	fi
}
		</codesample>
		<codesample lang="ebuild">
EAPI=4
...
src_test() {
	if ! nonfatal emake check ; then
		local a
		eerror "Tests failed. Looking for files for you to add to your bug report..."
		while IFS='' read -r -d $'\0' a ; do
			eerror "    ${a}"
		done &lt; &lt;(find "${S}" -type f '(' -name '*.epicfail' -o -name '*.log' ')' -print0)
		die "Make check failed"
	fi
}
		</codesample>
	</li>
	<li>
		<p><b>recursive dodoc</b></p>
		<p>
			<c>dodoc</c> supports <c>-r</c> as the first argument, which leads
			<c>dodoc</c> to install the specified documentation directory
			recursively into the docdir.
		</p>
		<p>Example:</p>
		<codesample lang="ebuild">
src_install() {
	default
	dodoc ChangeLog
	dodoc -r doc/
}
		</codesample>
	</li>
	<li>
		<p><b>doins symlink supports</b></p>
		<p>
			Within EAPI=4, <c>doins</c> supports installing symlinks as symlinks
			when installing recursively. For older EAPIs, the symlink behaviour
			is undefined.
		</p>
	</li>
	<li>
		<p><b>dosed and dohard are banned</b></p>
		<p>
			The <c>dosed</c> and <c>dohard</c> commands are banned in this EAPI.
		</p>
	</li>
	<li>
		<p><b>econf adds --disable-dependency-tracking</b></p>
		<p>
			Within EAPI=4, <c>econf</c> adds
			<c>--disable-dependency-tracking</c> to the default configure
			options.
		</p>
	</li>
	<li>
		<p><b>controllable compression via docompress</b></p>
		<p>
			To compress files in the destination-folder <c>${D}</c>, the
			<c>docompress</c> command may be used in <c>src_install</c>.
			To control which items should be compressed and which shouldn't
			be compressed, you may include or exclude directories or plain
			files. The default inclusion list contains:
			<ul>
				<li><c>/usr/share/doc</c></li>
				<li><c>/usr/share/info</c></li>
				<li><c>/usr/share/man</c></li>
			</ul>
			The default exclusion list contains:
			<ul>
				<li><c>/usr/share/doc/${PF}/html</c></li>
			</ul>
			When a directory is in- or excluded, all files and directories in
			the given directories shall be added to the corresponding list.
			If a file is in- or excluded, the file shall be added to the
			corresponding list (exclusion is stronger than inclusion <d/>
			if a file is in both lists, the inclusion will be ignored).
		</p>
		<p>
			If the first argument of <c>docompress</c> is <c>-x</c>, the items
			specified will be added to the exclusion list, otherwise they will
			be added to the inclusion list.
		</p>
		<note>
			When <c>docompress</c> is called, it is <e>not</e> required that
			the paths specified as its arguments are pointing to existing files
			or directories. However, if a file still doesn't exist when
			<c>src_install</c> has completed, it will be ignored with a
			warning.
		</note>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Metadata</title>
<body>
<ul>
	<li>
		<p><b>use dependencies default</b></p>
		<p>
			In addition to the use-deps specified in EAPI=2, a <c>(+)</c> or
			<c>(-)</c> may be added to the use-dep to define a default-value in
			case the use-flag does not exist in the given package. The
			<c>(+)</c> means that this use-flag is assumed to be enabled,
			<c>(-)</c> the opposite.
			<p>Example:</p>
			<codesample lang="ebuild">
DEPEND="
	>=dev-libs/boost-1.32[boost(+)]
	sys-devel/gcc[openmp(-)]"
			</codesample>
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Phases</title>
<body>
<ul>
	<li>
		<p><b>new pkg_pretend phase</b></p>
		<p>
			The new <c>pkg_pretend</c> phase can be used to do sanity checks
			before the main phase function sequence is run (meaning this phase is
			executed after the package manager has calculated the dependencies
			and before installing them).
			This phase typically checks for a kernel configuration and may
			<c>eerror</c> and <c>die</c> when needed.
			<important>
				There is no guarantee that the ebuild's dependencies are installed
				when this phase is called.
			</important>
			<important>
				As <c>pkg_pretend</c> is not called in the main phase function
				sequence, environment saving is not guaranteed.
			</important>
		</p>
		<p>Example:</p>
		<codesample lang="ebuild">
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=4
inherit linux-info
...

CONFIG_CHECK="FUSE_FS"
ERROR_FUSE_FS="this is an unrealistic testcase..."

pkg_pretend() {
	if use kernel_linux ; then
		if [[ -e "${ROOT}"/usr/src/linux/.config ]] ; then
			if kernel_is lt 2 6 30 ; then
				check_extra_config
			fi
		fi
	fi
}
		</codesample>
	</li>
	<li>
		<p><b>default src_install is no longer a no-op</b></p>
		<p>
			The default <c>src_install</c> function in EAPI=4:
		</p>
		<codesample lang="ebuild">
src_install() {
	if [[ -f Makefile ]] || [[ -f GNUmakefile]] || [[ -f makefile ]] ; then
		emake DESTDIR="${D}" install
	fi

	if ! declare -p DOCS >/dev/null 2>&amp;1 ; then
		local d
		for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
				FAQ CREDITS CHANGELOG ; do
			[[ -s "${d}" ]] &amp;&amp; dodoc "${d}"
		done
	elif declare -p DOCS | grep -q "^declare -a " ; then
		dodoc "${DOCS[@]}"
	else
		dodoc ${DOCS}
	fi
}
		</codesample>
	</li>
	<li>
		<p><b>pkg_info for non-installed packages</b></p>
		<p>
			The <c>pkg_info</c> function may also be called by the
			package manager for non-installed packages.
			Ebuild writers should note that dependencies may not be
			available.
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Variables</title>
<body>
<ul>
	<li>
		<p><b>REQUIRED_USE</b></p>
		<p>
			The <c>REQUIRED_USE</c> variable contains a list of assertions that
			must be met by the configuration of USE flags to be valid for this
			ebuild. In order to be matched, a USE flag in a terminal element
			must be enabled (or disabled if it has an exclamation mark prefix).
		</p>
		<p>
			See <uri link="::ebuild-writing/variables#REQUIRED_USE"/>
		</p>
	</li>
	<li>
		<p><b>REPLACING_VERSIONS and REPLACED_BY_VERSION</b></p>
		<p>
			The <c>REPLACING_VERSIONS</c> variable contains a
			whitespace-separated list of all versions (<c>PVR</c>) of this
			package that are being replaced (uninstalled or overwritten) as a
			result of this install. It is a list, not a single optional value,
			to handle pathological cases such as installing <c>foo-2:2</c> to
			replace <c>foo-2:1</c> and <c>foo-3:2</c>.
		</p>
		<p>
			<c>REPLACING_VERSIONS</c> is valid in <c>pkg_preinst</c> and
			<c>pkg_postinst</c>. In addition, it may be available in
			<c>pkg_pretend</c> and <c>pkg_setup</c>, although you should take
			care to handle binary package creation and installation correctly
			when using it in these phases.
		</p>
		<p>
			The <c>REPLACED_BY_VERSION</c> variable contains the single version
			(<c>PVR</c>) of this package that is replacing us, if we are being
			uninstalled as part of an install, or an empty string otherwise.
			It is valid in <c>pkg_prerm</c> and <c>pkg_postrm</c>.
		</p>
	</li>
	<li>
		<p><b>MERGE_TYPE</b></p>
		<p>
			The <c>MERGE_TYPE</c> variable contains the type of package that
			is being merged. Possible values are:
			<dl>
				<dt><c>source</c></dt>
				<dd><p>
					if building and installing a package from source,
				</p></dd>
				<dt><c>binary</c></dt>
				<dd><p>
					if installing a binary package,
				</p></dd>
				<dt><c>buildonly</c></dt>
				<dd><p>
					if building a binary package without installing it.
				</p></dd>
			</dl>
		</p>
	</li>
	<li>
		<p><b>DOCS</b></p>
		<p>
			The <c>DOCS</c> variable is an array or whitespace-separated list
			of documentation files for the default <c>src_install</c> function
			to install using <c>dodoc</c>. If undefined, a reasonable default
			list is used. See the default <c>src_install</c> function above.
		</p>
	</li>
	<li>
		<p><b>AA and KV variables are gone</b></p>
		<p>
			The <c>AA</c> and <c>KV</c> variables are no longer set in EAPI=4.
		</p>
	</li>
	<li>
		<p><b>no more RDEPEND="${DEPEND}"</b></p>
		<p>
			When <c>RDEPEND</c> is unset, there will no longer be an automatic
			assignment of <c>RDEPEND="${DEPEND}"</c>.
		</p>
	</li>
</ul>
</body>
</subsection>

</body>
</section>

<section>
<title>EAPI=5</title>
<body>

<subsection>
<title>Metadata</title>
<body>
<ul>
	<li>
		<p><b>REQUIRED_USE supports new at-most-one-of operator</b></p>
		<p>
		The new <b>at-most-one-of</b> operator consists of the string <c>'??'</c>, and is satisfied if zero or one (but no more) of its child elements is matched.
		</p>
	</li>
	<li>
		<p><b>SLOT supports optional "sub-slot" part</b></p>
		<p>
		The <c>SLOT</c> variable may contain an optional <b>sub-slot</b> part that follows the regular slot and is delimited by a <c>/</c> character. The sub-slot must be a valid slot name. The sub-slot is used to represent cases in which an upgrade to a new version of a package with a different sub-slot may require dependent packages to be rebuilt. When the sub-slot part is omitted from the SLOT definition, the package is considered to have an implicit sub-slot which is equal to the regular slot.
		</p>
	</li>
	<li>
		<p><b>Slot operators and sub-slots in dependencies</b></p>
		<p>
		A slot dependency may contain an optional sub-slot part that follows the regular slot and is delimited by a <c>/</c> character. This can be useful for packages installing pre-built binaries that require a library with a specific soname version which corresponds to the sub-slot. For example:
		</p>
		<codesample lang="ebuild">
RDEPEND="dev-libs/foo:0/3"
		</codesample>
		<p>
		Package dependency specifications can use <b>slot operators</b> to
		clarify what should happen if the slot and/or sub-slot of a runtime
		dependency changes:
		</p>
		<ul>
			<li>
			<c>:*</c> Indicates that any slot value is acceptable. In addition, for runtime dependencies, indicates that the package specifying the dependency will not break if the package matching the dependency is replaced by a different matching package with a different slot and/or sub-slot.
			</li>
			<li>
			<c>:=</c> Indicates that any slot value is acceptable. In addition, for runtime dependencies, indicates that the package specifying the dependency will break unless there is available a package matching the dependency and whose slot and sub-slot are equal to the slot and sub-slot of the best installed version that had matched this dependency at the time when the package specifying this dependency had been installed.
			</li>
			<li>
			<c>:slot=</c> Indicates that only a specific slot value is acceptable, and otherwise behaves identically to the <c>:=</c> operator.
				<note>
				use <c>:slot/subslot</c> without a <c>=</c> to depend on a specific slot and sub-slot pair; it's a syntax error to use <c>:slot/subslot=</c> in an ebuild.
				</note>
			</li>
		</ul>
		<p>
		The <c>:slot</c> dependency syntax continues to behave like in EAPI=4 or earlier, i.e. it indicates that only the specific slot value is acceptable, but the package will not break when the version matching the runtime dependency is replaced by a version with a different sub-slot.
		</p>
		<p>
		For example:
		</p>
		<codesample lang="ebuild">
RDEPEND="dev-libs/foo:2=
	&gt;=dev-libs/bar-0.9:=
	media-gfx/baz:*
	x11-misc/wombat:0"
		</codesample>
		<p>
		means that the package should be rebuilt when <c>foo:2</c> or <c>&gt;=bar-0.9</c> are upgraded to versions with different subslots, but that changes in subslots of <c>baz</c> or <c>wombat:0</c> should be ignored.
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Profiles</title>
<body>
<ul>
	<li>
		<p><b>Profile stable USE forcing and masking</b></p>
		<p>
		In profile directories with an EAPI supporting stable masking, new USE configuration files are supported: <c>use.stable.mask</c>, <c>use.stable.force</c>, <c>package.use.stable.mask</c> and <c>package.use.stable.force</c>. These files behave similarly to previously supported USE configuration files, except that they only influence packages that are merged due to a stable keyword.
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Helpers</title>
<body>
<ul>
	<li>
		<p><b>econf adds --disable-silent-rules</b></p>
		<p>
		This option will automatically be passed if <c>--disable-silent-rules</c> occurs in the output of <c>configure --help</c>.
		</p>
	</li>
	<li>
		<p><b>new* commands can read from standard input</b></p>
		<p>
		Standard input is read when the first parameter is <c>-</c> (a hyphen).
		</p>
	</li>
	<li>
		<p><b>New option --host-root for {has,best}_version</b></p>
		<p>
		This option <c>--host-root</c> will cause the query to apply to the host root instead of ROOT.
		</p>
	</li>
	<li>
		<p><b>New doheader helper function</b></p>
		<p>
		Installs the given header files into <c>/usr/include/</c>. If option
		<c>-r</c> is specified, descends recursively into any directories given.
		</p>
	</li>
	<li>
		<p><b>New usex helper function</b></p>
		<p>
		<!-- We probably need an example here -->
		<pre>
USAGE: usex &lt;USE flag&gt; [true output] [false output] [true suffix] [false suffix]
DESCRIPTION:
If USE flag is set, echo [true output][true suffix] (defaults to "yes"),
 otherwise echo [false output][false suffix] (defaults to "no").
		</pre>
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Phases</title>
<body>
<ul>
	<li>
		<p><b>src_test supports parallel tests</b></p>
		<p>
		Unlike older EAPIs, the default <c>src_test</c> implementation will not pass the -j1 option to emake.
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Variables</title>
<body>
<ul>
	<li>
		<p><b>EBUILD_PHASE_FUNC</b></p>
		<p>
		During execution of an ebuild phase function (such as <c>pkg_setup</c> or <c>src_unpack</c>),
		the <c>EBUILD_PHASE_FUNC</c> variable will contain the name of the phase function that is currently executing.
		</p>
	</li>
</ul>
</body>
</subsection>

</body>
</section>

<section>
<title>EAPI=6</title>
<body>

<subsection>
<title>Bash version</title>
<body>
<p>Ebuilds can use features of Bash version 4.2 (was 3.2 before).</p>
</body>
</subsection>

<subsection>
<title>Ebuild environment</title>
<body>
<ul>
	<li>
		<p><b>Locale settings</b></p>
		<p>
			Behaviour of case modification and collation order (<c>LC_CTYPE</c>
			and <c>LC_COLLATE</c>) are guaranteed to be the same as in the
			C locale, as far as characters in the ASCII range are concerned.
		</p>
	</li>
	<li>
		<p><b><c>failglob</c> enabled</b></p>
		<p>
			For <c>EAPI=6</c>, the <c>failglob</c> option of bash is set in the global scope of ebuilds. If set, failed pattern matches during filename expansion result in an error when the ebuild is being sourced.
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Phases</title>
<body>
<ul>
	<li>
		<p><b>Update default implementation of <c>src_prepare</c></b></p>
		<p>
			This phase is no longer a no-op, it supports applying patches via the <c>PATCHES</c> variable and applying user patches via <c>eapply_user</c>. The default <c>src_prepare</c> looks like this:
			<codesample lang="ebuild">
src_prepare() {
	if declare -p PATCHES | grep -q "^declare -a "; then
		[[ -n ${PATCHES[@]} ]] &amp;&amp; eapply "${PATCHES[@]}"
	else
		[[ -n ${PATCHES} ]] &amp;&amp; eapply ${PATCHES}
	fi
	eapply_user
}
			</codesample>
		</p>
	</li>
	<li>
		<p><b>New <c>src_install</c> Phase Function</b></p>
		<p>
			This phase uses the new <c>einstalldocs</c> function for installation of documentation. The default <c>src_install</c> looks like this:
			<codesample lang="ebuild">
src_install() {
	if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then
		emake DESTDIR="${D}" install
	fi
	einstalldocs
}
			</codesample>
		</p>
	</li>
</ul>
</body>
</subsection>

<subsection>
<title>Helpers</title>
<body>
<ul>
	<li>
		<p><b><c>einstall</c> banned</b></p>
		<p>
			The <c>einstall</c> helper has been banned with <c>EAPI=6</c>.
		</p>
	</li>
	<li>
		<p><b><c>dohtml</c> deprecated</b></p>
		<p>
			The <c>dohtml</c> helper has been deprecated with <c>EAPI=6</c>.
		</p>
	</li>
	<li>
		<p><b><c>nonfatal die</c></b></p>
		<p>
			When <c>die</c> or <c>assert</c> are called under the <c>nonfatal</c> command and with the <c>-n</c> option, they will not abort the build process but return with an error.
		</p>
	</li>
	<li>
		<p><b><c>eapply</c> support</b></p>
		<p>
			The <c>eapply</c> command is a simplified substitute for <c>epatch</c> (from <c>eutils.eclass</c>), implemented in the package manager. The patches from its file or directory arguments are applied using patch <c>-p1</c>, but it accepts <c>patch(1)</c> options from GNU patch to override default behavior.
		</p>
	</li>
	<li>
		<p><b><c>eapply_user</c> support</b></p>
		<p>
			The <c>eapply_user</c> command permits the package manager to apply user-provided patches. It must be called from every <c>src_prepare</c> function.
			<note><c>eapply_user</c> doesn't need to be called explicitly when default <c>src_prepare</c> is called.</note>
		</p>
	</li>
	<li>
		<p><b><c>econf</c> adds <c>--docdir</c> and <c>--htmldir</c></b></p>
		<p>
			Options <c>--docdir</c> and <c>--htmldir</c> are passed to <c>configure</c>, in addition to the existing options.
		</p>
	</li>
	<li>
		<p><b><c>in_iuse</c> support</b></p>
		<p>
			The <c>in_iuse</c> function returns <c>true</c> if the given parameter is available in the ebuilds <c>USE</c>.
		</p>
	</li>
	<li>
		<p><b><c>unpack</c> changes</b></p>
		<ul>
			<li><p><c>unpack</c> supports relative paths without leading <c>./</c> (<c>unpack foo/bar.tar.gz</c> is valid as relative path).</p></li>
			<li><p><c>unpack</c> supports <c>.txz</c> (xz compressed tarball).</p></li>
			<li><p><c>unpack</c> matches filename extensions case-insensitively.</p></li>
		</ul>
	</li>
	<li>
		<p><b><c>einstalldocs</c> support</b></p>
		<p>
			The <c>einstalldocs</c> function will install the files specified by the <c>DOCS</c> variable (or a default set of files if <c>DOCS</c> is unset) and by the <c>HTML_DOCS</c> variable.
		</p>
	</li>
	<li>
		<p><b><c>get_libdir</c> support</b></p>
		<p>
			The <c>get_libdir</c> command outputs the <c>lib*</c> directory basename suitable for the current ABI.
		</p>
	</li>
</ul>
</body>
</subsection>


</body>
</section>

<section>
<title>EAPI=7</title>
<body>
<subsection>
<title>Terminology</title>
<body>
<p>Documents may use the following terms to better describe dependency and installation targets.</p>
<ul>
	<li>
		<p><b><c>CHOST</c></b></p>
		<p>The system that will be running the installed package.</p>
	</li>
	<li>
		<p><b><c>CBUILD</c></b></p>
		<p>The system used to build packages. When not cross-compiling, CBUILD == CHOST.</p>
	</li>
	<li>
		<p><b><c>CTARGET</c></b></p>
		<p>Used in certain cross-compliations, often empty value.</p>
	</li>
</ul>
</body>
</subsection>
<subsection>
<title>Variables</title>
<body>
<ul>
	<li>
		<p><b><c>PORTDIR</c> and <c>ECLASSDIR</c> are removed</b></p>
		<p><c>PORTDIR</c> and <c>ECLASSDIR</c> are no longer defined and cannot be used
		in ebuilds to access these directories.</p>
	</li>
	<li>
		<p><b><c>DESTTREE</c> and <c>INSDESTTREE</c> are removed</b></p>
		<p>The unintended exported variables <c>PORTDIR</c> and <c>ECLASSDIR</c>
		cannot be used in ebuilds to manipulate installation paths.
		Use <c>into</c> or <c>insinto</c>, respectively, instead.</p>
	</li>
	<li>
		<p><b><c>D</c>, <c>ED</c>, <c>ROOT</c>, and <c>EROOT</c> modified</b></p>
		<p>These variables no longer contain a trailing slash with <c>EAPI=7</c>.</p>
	</li>
	<li>
		<p><b><c>BDEPEND</c> addded</b></p>
		<p>
			Previously, all build-time tools and libraries went into the <c>DEPEND</c>.
			Now, built-time dependencies are split into <c>DEPEND</c> and <c>BDEPEND</c>.
			The difference is simply that <c>BDEPEND</c> are dependencies to be executed on the CBUILD.
			<c>DEPEND</c> remains for other dependencies, such as libraries, for the CHOST.
			This improves the cross-compliation support.
		</p>
	</li>
	<li>
		<p><b><c>BROOT</c> added</b></p>
		<p><c>BROOT</c> is the absolute path to the root directory, including any prefix, containing build
		dependencies satisfied by BDEPEND, typically executable build tools.</p>
	</li>
	<li>
		<p><b><c>SYSROOT</c> and <c>ESYSROOT</c> added</b></p>
		<p><c>SYSROOT</c> is the location of where dependencies in <c>DEPEND</c> are installed.
		<c>ESYSROOT</c> is <c>SYSROOT</c> with <c>EPREFIX</c> appended.
		</p>
	</li>
	<li>
		<p><b><c>ENV_UNSET</c> added</b></p>
		<p>A whitespace delimited list of variables to be removed from the build environment.</p>
	</li>
</ul>
</body>
</subsection>
<subsection>
<title>Metadata</title>
<body>
<ul>
	<li>
		<p><b>Empty groupings are banned</b></p>
		<p>Groupings which are empty, such as <c>DEPEND="|| ( ${empty_var} )"</c> will now generate an error.
		Furthermore, conditions within groupings are more strictly enforced.
		Eg. <c>REQUIRED_USE="|| ( foo? ( bar ) baz? ( zoinks )"</c> would previously work with <c>USE="-foo -baz"</c> now requires
		either <c>USE="foo bar"</c> or <c>USE="baz zoinks"</c>.
		</p>
	</li>
</ul>
</body>
</subsection>
<subsection>
<title>Profiles</title>
<body>
<ul>
	<li>
		<p><b><c>package.provided</c> banned</b></p>
		<p>Profiles may no longer contain a <c>package.provided</c> file with <c>EAPI=7</c>.</p>
	</li>
</ul>
</body>
</subsection>
<subsection>
<title>Helpers</title>
<body>
<ul>
	<li>
		<p><b><c>dohtml</c> banned</b></p>
		<p>
			The <c>dohtml</c> helper has been banned with <c>EAPI=7</c>.
		</p>
	</li>
	<li>
		<p><b><c>dolib</c> and <c>libopts</c> banned</b></p>
		<p>
			The <c>dolib</c> helper and the associated <c>libopts</c> have been banned with <c>EAPI=7</c>.
		</p>
	</li>
	<li>
		<p><b><c>has_version</c> and <c>best_version</c> changes</b></p>
		<p>
			<c>has_version</c> and <c>best_version</c> now support an optional switch
			to determine which type of dependencies to check.
		</p>
		<ul>
			<li><p><c>-r</c> (the default) will check runtime dependencies (RDEPEND)</p></li>
			<li><p><c>-d</c> will check CHOST build-time dependencies (DEPEND)</p></li>
			<li><p><c>-b</c> will check CBUILD build-time dependencies (BDEPEND)</p></li>
		</ul>
	</li>
	<li>
		<p><b>Version manipulation and comparision commands</b></p>
		<p>
			EAPI=7 introduced three commands for common version number operations.
		</p>
		<ul>
			<li><p><c>ver_cut</c> obtains substrings of a version string</p></li>
			<li><p><c>ver_rs</c> replaces separators in a version string</p></li>
			<li><p><c>ver_test</c> compares two versions</p></li>
		</ul>
		<p>See <uri link="::ebuild-writing/variables#version-and-name-formatting-issues">Version and Name Formatting Issues</uri>
		for examples of common uses or
		<uri link="https://dev.gentoo.org/~mgorny/articles/the-ultimate-guide-to-eapi-7.html#version-manipulation-and-comparison-commands">
		an in-depth look</uri></p>
	</li>
	<li>
		<p><b>New function <c>eqawarn</c></b></p>
		<p>
			The <c>eqawarn</c> helper has been added with <c>EAPI=7</c>.
			This function is to alert developers to a deprecated feature.
			Previously, this was contained in <c>eutils</c> eclass which is no longer necessary.
		</p>
	</li>
	<li>
		<p><b>New function <c>dostrip</c></b></p>
		<p>
			The <c>dostrip</c> helper has been added with <c>EAPI=7</c>.
			This function controls whether or not to strip a binary.<br />
			<c>dostrip -x [file]</c> will exclude a binary from being stripped.<br />
			Conversely, when combined with RESTRICT=strip, <c>dostrip [file]</c> selects a binary
			file to be stripped.
		</p>
	</li>
	<li>
		<p><b><c>die</c> and <c>assert</c> changes</b></p>
		<p>These commands are now safe to use in a subshell and act as if they were called in the main process.</p>
	</li>
	<li>
		<p><b><c>nonfatal</c> changes</b></p>
		<p>The <c>nonfatal</c> command now works for shell functions and subprocesses.</p>
	</li>
	<li>
		<p><b><c>domo</c> behaviour changed</b></p>
		<p><c>domo</c> (for localizations) now ignores the <c>into</c> directives.
		This follows similar commands like <c>doinfo</c> and <c>doman</c>.</p>
	</li>
	<li>
		<p><b><c>econf</c> changes</b></p>
		<p>The cross-compilation options <c>--build</c> and <c>--target</c> options
		to specify <c>CBUILD</c> and <c>CTARGET</c> respectively have been added and are retro-active to all EAPIs.
		In addition, if the build supports <c>--with-sysroot</c>, the correct value will be passed
		such that normal and cross-compliations succeed.
		</p>
	</li>
</ul>
</body>
</subsection>
</body>
</section>

</body>
</chapter>
</guide>