aboutsummaryrefslogtreecommitdiff
blob: 7e1d37b5a51f9daa11070ee7cdd0b97712d074ae (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
<?xml version="1.0"?>
<guide self="ebuild-writing/variables/">
<chapter>
<title>Variables</title>

<body>
<p>
There are a number of special variables which must be set in ebuilds, and many
more which can optionally be specified. There are also some predefined variables
which are of use throughout the ebuild.
</p>
</body>

<section>
<title>Predefined Read-Only Variables</title>
<body>

<p>
The following variables are defined for you. You must not attempt to
set them. Developers must not rely on package manager specific values
for these variables when writing ebuilds.
</p>

<table>
  <tr>
    <th>Variable</th>
    <th>Purpose</th>
  </tr>
  <tr>
    <ti><c>P</c></ti>
    <ti>Package name and version (excluding revision, if any), for example <c>vim-6.3</c>.</ti>
  </tr>
  <tr>
    <ti><c>PN</c></ti>
    <ti>Package name, for example <c>vim</c>.</ti>
  </tr>
  <tr>
    <ti><c>PV</c></ti>
    <ti>Package version (excluding revision, if any), for example <c>6.3</c>. It should reflect the upstream versioning scheme.</ti>
  </tr>
  <tr>
    <ti><c>PR</c></ti>
    <ti>Package revision, or <c>r0</c> if no revision exists.</ti>
  </tr>
  <tr>
    <ti><c>PVR</c></ti>
    <ti>Package version and revision (if any), for example <c>6.3</c>, <c>6.3-r1</c>.</ti>
  </tr>
  <tr>
    <ti><c>PF</c></ti>
    <ti>Full package name, <c>${PN}-${PVR}</c>, for example <c>vim-6.3-r1</c>.</ti>
  </tr>
  <tr>
    <ti><c>A</c></ti>
    <ti>
      All the source files for the package (excluding those
      which are not available because of <c>USE</c> flags).
    </ti>
  </tr>
  <tr>
    <ti><c>CATEGORY</c></ti>
    <ti>Package's category, for example <c>app-editors</c>.</ti>
  </tr>
  <tr>
    <ti><c>FILESDIR</c></ti>
    <ti>
      Path to the ebuild's <c>files/</c> directory, commonly used
      for small patches and files. For example:
      <c>"${PORTDIR}/${CATEGORY}/${PN}/files"</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>WORKDIR</c></ti>
    <ti>
      Path to the ebuild's root build directory. For example:
      <c>"${PORTAGE_BUILDDIR}/work"</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>T</c></ti>
    <ti>
       Path to a temporary directory which may be used by the
       ebuild. For example: <c>"${PORTAGE_BUILDDIR}/temp"</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>D</c></ti>
    <ti>
      Path to the temporary install directory. For example:
      <c>"${PORTAGE_BUILDDIR}/image"</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>HOME</c></ti>
    <ti>
      Path to a temporary directory for use by any programs invoked by
      an ebuild that may read or modify the home directory. For example:
      <c>"${PORTAGE_BUILDDIR}/homedir"</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>ROOT</c></ti>
    <ti>
      The absolute path to the root directory into which the package is to be
      merged. Only allowed in pkg_* phases. See
      <uri link="::ebuild-writing/variables#ROOT"/>
    </ti>
  </tr>
  <tr>
    <ti><c>DISTDIR</c></ti>
    <ti>
      Contains the path to the directory where all the files
      fetched for the package are stored.
    </ti>
  </tr>
  <tr>
    <ti><c>EPREFIX</c></ti>
    <ti>
      The normalised offset-prefix path of an offset installation.
    </ti>
  </tr>
  <tr>
    <ti><c>ED</c></ti>
    <ti>
      Shorthand for <c>${D%/}${EPREFIX}/</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>EROOT</c></ti>
    <ti>
      Shorthand for <c>${ROOT%/}${EPREFIX}/</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>SYSROOT</c></ti>
    <ti>
      (EAPI=7) The absolute path to the root directory containing build dependencies
		satisfied by <c>DEPEND</c>
    </ti>
  </tr>
  <tr>
    <ti><c>ESYSROOT</c></ti>
    <ti>
      (EAPI=7) Shorthand for <c>${SYSROOT%/}${EPREFIX}/</c>.
    </ti>
  </tr>
  <tr>
    <ti><c>BROOT</c></ti>
    <ti>
      (EAPI=7) The absolute path to the root directory containing build dependencies
		satisfied by <c>BDEPEND</c>, typically executable build tools.
    </ti>
  </tr>
</table>

</body>
</section>

<section>
<title>Ebuild-defined Variables</title>
<body>

<p>
The following variables may or must be defined by every ebuild.
</p>

<table>
  <tr>
    <th>Variable</th>
    <th>Purpose</th>
  </tr>
  <tr>
    <ti><c>EAPI</c></ti>
    <ti>
    The EAPI. See <uri link="::ebuild-writing/eapi"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>DESCRIPTION</c></ti>
    <ti>
    A short (not more than 80 characters) description of the package's
    purpose. Mandatory.
    </ti>
  </tr>
  <tr>
    <ti><c>HOMEPAGE</c></ti>
    <ti>
    Package's homepage(s). Mandatory (except for virtuals), accepts
    multiple values. In some contexts, it is customary to provide
    package tracker and/or code hosting links besides the main homepage
    (e.g. PyPI link for Python packages, GitHub link when code can't
    easily be found on homepage) for convenience. If no homepage for
    the package is available, please set it to
    <c>https://wiki.gentoo.org/wiki/No_homepage</c>.
    Never refer to a variable name in the string; include only raw text.
    </ti>
  </tr>
  <tr>
    <ti><c>SRC_URI</c></ti>
    <ti>
    A list of source URIs for the package. Can contain
    <c>USE</c>-conditional parts, see
    <uri link="::ebuild-writing/variables#SRC_URI"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>LICENSE</c></ti>
    <ti>
    The package's license, corresponding exactly (including case)
    to a file in <c>licenses/</c>. Mandatory (except for virtuals).
    See <uri link="::ebuild-writing/variables#LICENSE"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>SLOT</c></ti>
    <ti>
    The package's <c>SLOT</c>. Mandatory.
    See <uri link="::ebuild-writing/variables#SLOT"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>KEYWORDS</c></ti>
    <ti>
    See <uri link="::ebuild-writing/variables#KEYWORDS"/> and
    <uri link="::keywording/"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>IUSE</c></ti>
    <ti>
    A list of all <c>USE</c> flags (excluding arch flags, but
    including <c>USE_EXPAND</c> flags) used within the ebuild. See
    <uri link="::ebuild-writing/variables#IUSE"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>REQUIRED_USE</c></ti>
    <ti>
    A list of assertions that must be met by the configuration of
    <c>USE</c> flags to be valid for this ebuild. (Requires EAPI>=4.)
    See <uri link="::ebuild-writing/variables#REQUIRED_USE"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>PROPERTIES</c></ti>
    <ti>
    A space-delimited list of properties, with conditional syntax support.
    <c>interactive</c> is the only valid value for now.
    </ti>
  </tr>
  <tr>
    <ti><c>RESTRICT</c></ti>
    <ti>
    A space-delimited list of portage features to restrict.
    Valid values are <c>fetch</c>, <c>mirror</c>, <c>strip</c>, <c>test</c> and
    <c>userpriv</c>. See <c>man 5 ebuild</c> for details.
    </ti>
  </tr>
  <tr>
    <ti><c>DEPEND</c></ti>
    <ti>
    A list of the package's build dependencies.  See
    <uri link="::general-concepts/dependencies"/>.
    Starting with EAPI-7, applies to CHOST only.
    </ti>
  </tr>
  <tr>
    <ti><c>BDEPEND</c></ti>
    <ti>
    (EAPI=7) A list of the package's CBUILD build dependencies.  See
    <uri link="::general-concepts/dependencies"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>RDEPEND</c></ti>
    <ti>
    A list of the package's runtime dependencies. See
    <uri link="::general-concepts/dependencies"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>PDEPEND</c></ti>
    <ti>
    A list of packages to be installed (if possible) after the package
    is merged. Use this only when <c>RDEPEND</c> would cause cyclic
    dependencies. See <uri link="::general-concepts/dependencies"/>.
    </ti>
  </tr>
  <tr>
    <ti><c>S</c></ti>
    <ti>
    Path to the temporary build directory, used by
    <c>src_compile</c> and <c>src_install</c>. Default:
    <c>"${WORKDIR}/${P}"</c>. Ebuilds should <b>not</b> provide a
    value for this variable if it is the same as the default value.
    </ti>
  </tr>
  <tr>
    <ti><c>DOCS</c></ti>
    <ti>
    An array or space-delimited list of documentation files for
    the default src_install function to install using dodoc. If
    undefined, a reasonable default list is used. (Requires
    <uri link="::ebuild-writing/eapi/#eapi=4">EAPI>=4</uri>.)
    </ti>
  </tr>
  <tr>
    <ti><c>HTML_DOCS</c></ti>
    <ti>
    An array or space-delimited list of documentation files or
    directories for the <c>einstalldocs</c> function to install
    recursively. (Requires
    <uri link="::ebuild-writing/eapi/#eapi=6">EAPI>=6</uri>.)
    </ti>
  </tr>
</table>

</body>
</section>

<section>
<title>SLOT</title>
<body>

<p>
When slots are not needed, use <c>SLOT="0"</c>. Do <b>not</b> use <c>SLOT=""</c>, as
this will disable slotting for this package.
</p>

<p>
See <uri link="::general-concepts/slotting/" /> for more information on this variable.
</p>

</body>
</section>

<section>
<title>KEYWORDS</title>
<body>

<p>
The only valid construct involving a <c>*</c> inside <c>KEYWORDS</c> is a <c>-*</c>. Do
<b>not</b> use <c>KEYWORDS="*"</c> or <c>KEYWORDS="~*"</c>.
</p>

<p>
See <uri link="::keywording/"/> for how to handle this variable.
</p>

</body>
</section>

<section>
<title>SRC_URI</title>

<subsection>
<title>Conditional Sources</title>
<body>

<p>
Conditional source files based upon USE flags are allowed using the usual
<c>flag? ( )</c> syntax. This is often useful for arch-specific code or for binary
packages <d/> downloading sparc binaries on ppc would be a waste of bandwidth.
</p>

<codesample lang="ebuild">
SRC_URI="https://example.com/files/${P}-core.tar.bz2
	x86?   ( https://example.com/files/${P}/${P}-sse-asm.tar.bz2 )
	ppc?   ( https://example.com/files/${P}/${P}-vmx-asm.tar.bz2 )
	sparc? ( https://example.com/files/${P}/${P}-vis-asm.tar.bz2 )
	doc?   ( https://example.com/files/${P}/${P}-docs.tar.bz2 )"
</codesample>

</body>
</subsection>

<subsection>
<title>Renaming Sources</title>
<body>

<p>
Sometimes the upstream URI uses generic names that can easily clash with other
packages when creating a single mirror. Using the <c>-&gt;</c> syntax allows
you to rename the file when it's fetched from upstream for storing on mirrors
and in the local distdir.
</p>

<p>
Here we download a file from upstream which has a plain name like
<c>1.0.tar.gz</c> and save/mirror it with a better name like
<c>thepackage-1.0.tar.gz</c>.
</p>

<codesample lang="ebuild">
SRC_URI="https://example.com/files/${PV}.tar.gz -> ${P}.tar.gz"
</codesample>

</body>
</subsection>


<subsection>
<title>Third-party mirrors</title>
<body>

<p>
If the items in <c>SRC_URI</c> are available on multiple third-party mirrors,
and the same set of mirrors is shared across multiple ebuilds, then you
don't have to repeatedly list each of them in every ebuild.
The <c>profiles/thirdpartymirrors</c> file in the <c>::gentoo</c> repository
contains named groups of mirrors, in the format specified by the
Package Manager Specification (PMS), accessible through the
<c>mirror://</c>
pseudo-protocol.
</p>

<p>
One might define a set of &quot;example&quot;
mirrors,
</p>

<!--
  The following isn't ebuild code, but lang="ebuild" works, and no
  other language choice would be accurate either.
-->
<codesample lang="ebuild">
example https://download.example.com https://mirror1.example.org/example
</codesample>

<p>
that can afterwards be referenced through a <c>mirror://</c> URI:
</p>

<codesample lang="ebuild">
SRC_URI="mirror://example/${PN}/${P}.tar.gz"
</codesample>

<p>
There are two valid cases for using <c>thirdpartymirrors</c>:
</p>

<ol>
  <li>
    providing multiple download locations for mirror- or fetch-restricted
    packages,
  </li>

  <li>
    dealing with upstreams that distribute their distfiles via a network
    of mirrors without a primary download location or a bouncer service.
  </li>
</ol>

<p>
In any other case, the primary location must be used instead. The distfiles
will be <uri link="::general-concepts/mirrors">mirrored onto Gentoo
infrastructure</uri>; in that case, the benefit to using third-party mirror
list does not outweigh the burden of maintaining it.
</p>

</body>
</subsection>
</section>

<section>
<title>IUSE</title>
<body>

<p>
Note that the <c>IUSE</c> variable is cumulative, so there is no need to specify
USE flags used only within inherited eclasses within the ebuild's IUSE.
</p>
<note>
You need not assign the IUSE variable in your ebuild if it is empty.
</note>

<p>
Arch USE flags (<c>sparc</c>, <c>mips</c>, <c>x86-fbsd</c> and so on) should not be
listed.
</p>

</body>
</section>

<section>
<title>LICENSE</title>
<body>

<p>
It is possible to specify multiple <c>LICENSE</c> entries, and entries which only
apply if a particular <c>USE</c> flag is set. The format is the same as for
<c>DEPEND</c>. See <uri link="https://www.gentoo.org/glep/glep-0023.html">
GLEP 23</uri> for details.
</p>

</body>
</section>

<section>
<title>ROOT</title>
<body>

<p>
The idea behind <c>ROOT</c> is that one can build a system with
<c>ROOT=/somewhere</c> and then chroot into it or tar up
<c>/somewhere</c> as a system image. It is not designed to allow the
user to run <c>/somewhere/usr/bin/foo</c>.
</p>

<p>
Ebuilds may reference <c>ROOT</c> only during <c>pkg_*</c> phases. It
can't be used correctly in <c>src_*</c> phases, since <c>ROOT</c> may
be different when merging a binary package. For example, a binary
package may be built with <c>ROOT=/</c> and then installed onto a
system using <c>ROOT=/somewhere</c>.
</p>

<p>
When building a package, <c>ROOT</c> should not be used to satisfy the
required dependencies on libraries, headers files etc. Instead, the
files on the build system should be specified using <c>/</c>.
</p>

<p>
In a cross compiling environment, ebuilds must not call any of the
binaries inside <c>ROOT</c> since they may not be executable on the
build system.
</p>

<p>
Below is an example of an ebuild that uses <c>ROOT</c> in
<c>pkg_postinst()</c> to conditionally print an error message if an
old and obsolete configuration file still exists:
</p>

<codesample lang="ebuild">
pkg_postinst() {
	if [[ -e "${ROOT}/etc/oldconfig" ]]; then
		ewarn "You still have the obsolete config file "
		ewarn "    ${ROOT}/etc/oldconfig."
		ewarn "Please migrate your settings to ${ROOT}/etc/newconfig"
		ewarn "and remove ${ROOT}/etc/oldconfig."
	fi
}
</codesample>

</body>
</section>

<section>
<title>Version and Name Formatting Issues</title>
<body>

<p>
Often upstream's tarball versioning or naming format doesn't quite follow Gentoo
conventions. Using capital letters in names or differences in how underscores and hyphens
are used in versions are particularly common. For example, what Gentoo calls <c>foo-1.2.3b</c> may be
expecting a tarball named <c>Foo-1.2-3b.tar.bz2</c>. Rather than hard coding the package string,
it is preferable to make <c>MY_PN</c>, <c>MY_PV</c> and <c>MY_P</c> variables and use those to define the
upstream naming.
EAPI=7 debuted a new set of functions, ver_cut, ver_rs and ver_test.
These were backported into older EAPIs with the <c>eapi7-ver</c> eclass.
The easy way of redefining the version, which should be used unless you are sure
you know what you are doing, is to use these functions:
</p>

<codesample lang="ebuild">
inherit eapi7-ver
MY_PN="Foo"
# Replace the second period separator in PV with -
MY_PV=$(ver_rs 2 '-')
MY_P="${MY_PN}-${MY_PV}"
</codesample>

<p>
This code has the advantage that it will carry on working even if upstream
switches to a format like <c>Foo-1.3-4.5.tar.bz2</c> (yes, this really happens).
</p>

<p>
It is also possible to use bash substitution to achieve the same effect (this is
how eapi7-ver works internally), but this is complicated, error prone and hard
to read.
</p>

<p>
Some ebuilds use calls to <c>sed</c>, <c>awk</c> and / or <c>cut</c> to do this. This
must <e>not</e> be done for any new code, and should be fixed to use either
eapi7-ver or bash substitution where possible. Global scope non-bash code is
highly discouraged.
</p>

<p>
The ver_ functions are used extract particular components
from a version string. See <c>man eapi7-ver.eclass</c> and the eclass source code
for further documentation and examples. A brief summary of the functions
follows.
</p>

<table>
  <tr>
    <th>Function</th>
    <th>Purpose</th>
  </tr>
  <tr>
    <ti><c>ver_rs [range] ' '</c></ti>
    <ti>Get important version components, excluding '.', '-' and '_'.</ti>
  </tr>
  <tr>
    <ti><c>ver_cut 1</c></ti>
    <ti>Get the major version.</ti>
  </tr>
  <tr>
    <ti><c>ver_cut [range]</c></ti>
    <ti>Extract a range of subparts from a version string.</ti>
  </tr>
  <tr>
    <ti><c>ver_cut 2-</c></ti>
    <ti>Get everything after the major version.</ti>
  </tr>
  <tr>
    <ti><c>ver_rs [range] [char]</c></ti>
    <ti>Replace a particular version separator.</ti>
  </tr>
  <tr>
    <ti><c>ver_rs 1- [char]</c></ti>
    <ti>Replace all version separators.</ti>
  </tr>
  <tr>
    <ti><c>ver_rs [range] ''</c></ti>
    <ti>Delete a version separator.</ti>
  </tr>
  <tr>
    <ti><c>ver_rs 1- ''</c></ti>
    <ti>Delete all version separators.</ti>
  </tr>
</table>

</body>
</section>

<section>
<title>Trailing Slashes in Variables</title>
<body>

<p>
The following variables never end with a trailing slash in EAPI 7:
<c>D</c>, <c>ED</c>, <c>ROOT</c>, <c>EROOT</c>. Conversely, in EAPIs
preceeding EAPI 7, these variables are guaranteed to end with a
trailing slash. When working with EAPIs prior to EAPI 7, developers
are encouraged to use the bash suffix removal for the trailing slash
and add an explicit <c>/</c> when joining paths. For example:
<c>${D%/}/</c>, <c>${ED%/}/</c>, <c>${ROOT%/}/</c>,
<c>${EROOT%/}/</c>.
</p>

</body>
</section>

<section>
<title>Use of constant-value variables in ebuilds</title>
<body>

<p>
Variables have significant value in ebuilds, making it possible to avoid
unnecessary repetitions and make maintenance easier.  However,
references to constant-value variables should be used with care as their
excessive use can harm readability and increase maintenance burden (e.g.
when renaming a package). In particular, using variables whose values
have no direct correlation with the expected string should be avoided.
</p>

<p>The examples of beneficial constant-value variable references are:</p>
<ul>
  <li>
    using <c>${PV}</c> and the variables derived from it (<c>${P}</c>,
    <c>${MY_P}</c>…) in <c>SRC_URI</c> and <c>S</c> to avoid having
    to update those variables for every version bump (assuming that
    <c>${PV}</c> is used to indicate the upstream version);
  </li>

  <li>
    using <c>${PF}</c> in <c>--docdir</c> path  this is a canonical
    Gentoo path that is always required to match <c>${PF}</c>.
  </li>
</ul>

<p>The examples of bad constant-value variable references are:</p>
<ul>
  <li>
    using <c>${PN}</c> in <c>HOMEPAGE</c>, <c>EGIT_REPO_URI</c>
    or the domain of <c>SRC_URI</c>  it breaks URL parsing in editors
    and terminals, and makes it hard to copy the link for external use
    (e.g. while reviewing via gitweb),
  </li>

  <li>
    using <c>${HOMEPAGE}</c> in <c>SRC_URI</c>  it breaks when homepage
    changes or additional entry is added,
  </li>

  <li>
    using <c>${PN}</c> (or other unnecessary helper variables)
    excessively in <c>src_install()</c>  it impairs readability for
    little benefit and causes a lot of trouble when the package needs to
    be renamed.
  </li>
</ul>

</body>
</section>

<section>
<title>REQUIRED_USE</title>
<body>
<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>
Essentially, <c>REQUIRED_USE</c> is an analogue of <c>DEPEND</c> style syntax.
For example, to state that some combination is forbidden, i.e. &quot;if foo is set, bar must be unset&quot;:
</p>

<codesample lang="ebuild">
REQUIRED_USE="foo? ( !bar )"
</codesample>
<p>
To state "if foo is set, then at least one of bar, baz, and quux must be activated":
</p>
<codesample lang="ebuild">
REQUIRED_USE="foo? ( || ( bar baz quux ) )"
</codesample>
<p>
To state "exactly one of foo, bar, or baz must be set, but not several":
</p>
<codesample lang="ebuild">
REQUIRED_USE="^^ ( foo bar baz )"
</codesample>
<p>
Note that the last relationship is that of an Exclusive OR (XOR).
While an XOR could be formed from usual DEPEND syntax,
a specific ^^ operator has been added for this case.
</p>
<p>
Finally, to state "at least one of foo, bar, or baz must be set":
</p>
<codesample lang="ebuild">
REQUIRED_USE="|| ( foo bar baz )"
</codesample>
<important>
See section <uri link="::general-concepts/use-flags/#conflicting-use-flags" />
for when (and when not) to use <c>REQUIRED_USE</c>.
</important>
</body>

<subsection>
<title>EAPI 5</title>
<body>
<p>
EAPI 5 added an additional case to simplify conflicting USE flags.
</p>
<p>
To state "zero or one of foo, bar, or baz must be set, but not several":
</p>
<codesample lang="ebuild">
REQUIRED_USE="?? ( foo bar baz )"
</codesample>
<p>In the previous EAPI, this would be the same as:</p>
<codesample lang="ebuild">
REQUIRED_USE="foo? ( !bar !baz ) bar? ( !foo !baz ) baz? ( !foo !bar )"
</codesample>
</body>
</subsection>
</section>

</chapter>
</guide>