aboutsummaryrefslogtreecommitdiff
blob: e43390c838bb91381da55a2dd6df088d29a93ed1 (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
<?xml version="1.0"?>
<guide self="general-concepts/dependencies/">
<chapter>
<title>Dependencies</title>

<body>

<p>
  Automatic dependency resolution is one of the most useful features provided by
  <c>emerge</c>.
</p>

<section>
<title>Build Dependencies</title>
<body>

<p>
The <c>DEPEND</c> ebuild variable should specify any dependencies which are
required to unpack, patch, compile or install the package (but see
<uri link="::general-concepts/dependencies#Implicit System Dependency"/> for
exemptions).
</p>

</body>
</section>

<section>
<title>Runtime Dependencies</title>
<body>

<p>
The <c>RDEPEND</c> ebuild variable should specify any dependencies which are
required at runtime. This includes libraries (when dynamically linked), any data
packages and (for interpreted languages) the relevant interpreter. In EAPI=3 or
older, if this variable is not specified it defaults to the value of
<c>DEPEND</c>, however the implicit usage is frowned upon. In EAPI=4, the
implicit behaviour was removed and the assignment is always explicit.
</p>

<p>
Note that when installing from a binary package, only <c>RDEPEND</c> will be
checked. It is therefore necessary to include items even if they are also listed
in <c>DEPEND</c>.
</p>

<p>
Items which are in <c>RDEPEND</c> but not <c>DEPEND</c> could <e>in theory</e> be merged
<e>after</e> the target package. Portage does not currently do this.
</p>

</body>
</section>

<section>
<title>Post-Merge Dependencies</title>
<body>

<p>
The <c>PDEPEND</c> variable specifies dependencies that should be
merged <e>after</e> the package, but which may be merged at any time,
if the former is not possible. This is sometimes used for plugins
that have a dependency upon the package being merged. Generally
<c>PDEPEND</c> should be avoided in favour of <c>RDEPEND</c> except
where this will create circular dependency chains.
</p>

</body>
</section>

<section>
<title>Implicit System Dependency</title>
<body>

<p>
All packages have an implicit compile-time and runtime dependency upon the
entire <c>system</c> target. It is therefore not necessary, nor advisable, to
specify dependencies upon toolchain packages like <c>gcc</c>, <c>libc</c> and
so on, except where specific versions or packages (for example, <c>glibc</c>
over <c>uclibc</c>) are required.  Note that this rule also needs consideration
for packages like <c>flex</c>, <c>zlib</c> and <c>libtool</c>, which aren't in
the <c>system</c> target for every profile.  For example, the embedded profile
doesn't have <c>zlib</c> in <c>system</c> target, the <c>libtool</c> ABI might
change and break building order and <c>flex</c> might get removed from the
<c>system</c> target in future.
</p>

<p>
However, packages which are included in the <c>system</c> target, or are
dependencies of <c>system</c> target packages, should generally include a complete
dependency list (excluding bootstrap packages). This makes <c>emerge -e system</c>
possible when installing from a stage 1 or stage 2 tarball.
</p>

</body>
</section>

<section>
<title>Basic Dependency Syntax</title>
<body>

<p>
A basic <c>DEPEND</c> specification might look like the following:
</p>

<codesample lang="ebuild">
DEPEND="dev-lang/ruby
	dev-ruby/ruby-gtk2
	dev-ruby/mysql-ruby"
</codesample>

<p>
Each <e>package dependency specification</e> is the full category and name of
a package. Dependency specifications are separated by arbitrary whitespace <d/>
convention is to have one specification per line for readability purposes.
When specifying names, the category part should be treated as mandatory.
</p>

</body>
</section>

<section>
<title>Version Dependencies</title>
<body>

<p>
Sometimes a particular version of a package is needed. Where this is known, it
should be specified. A simple example:
</p>

<codesample lang="ebuild">
DEPEND=">=dev-libs/openssl-0.9.7d"
</codesample>

<p>
This states that at least version 0.9.7d of <c>openssl</c> is required.
</p>

<subsection>
<title>Version Specifiers</title>
<body>

<p>
Available version specifiers are:
</p>

<p>
<table>
  <tr>
    <th>Specifier</th>
    <th>Meaning</th>
  </tr>
  <tr>
    <ti><c>>=app-misc/foo-1.23</c></ti>
    <ti>Version 1.23 or later is required.</ti>
  </tr>
  <tr>
    <ti><c>>app-misc/foo-1.23</c></ti>
    <ti>A version strictly later than 1.23 is required.</ti>
  </tr>
  <tr>
    <ti><c>~app-misc/foo-1.23</c></ti>
    <ti>Version 1.23 (or any <c>1.23-r*</c>) is required.</ti>
  </tr>
  <tr>
    <ti><c>=app-misc/foo-1.23</c></ti>
    <ti>
      Exactly version 1.23 is required. If at all possible,
      use the <c>~</c> form to simplify revision bumps.
    </ti>
  </tr>
  <tr>
    <ti><c>&lt;=app-misc/foo-1.23</c></ti>
    <ti>Version 1.23 or older is required.</ti>
  </tr>
  <tr>
    <ti><c>&lt;app-misc/foo-1.23</c></ti>
    <ti>A version strictly before 1.23 is required.</ti>
  </tr>
</table>
</p>

</body>
</subsection>

<subsection>
<title>Ranged Dependencies</title>
<body>

<p>
To specify "version 2.x (not 1.x or 3.x)" of a package, it is necessary to use
the asterisk postfix. This is most commonly seen in situations like:
</p>

<codesample lang="ebuild">
DEPEND="gtk? ( =x11-libs/gtk+-1.2* )"
</codesample>

<p>
Note that the equals sign is mandatory, and that there is no dot before the
asterisk. Also note that when selecting all versions in a specific
<c>SLOT</c>, <c>SLOT</c> dependencies should be used (see below).
</p>

</body>
</subsection>

<subsection>
<title>Blockers</title>
<body>

<p>
When two packages (package slots, versions) can not be installed
simultaneously, blockers can be used to expose such a conflict
to the package manager.
</p>

<p>
The following description applies to all EAPIs starting with EAPI 2.
</p>

<p>
There are two kinds of blockers: soft blockers and hard blockers.
</p>

<p>A soft blocker is defined using the following syntax:</p>

<codesample lang="ebuild">
RDEPEND="!app-misc/foo"
</codesample>

<p>
The package manager will try to resolve this conflict automatically.
The package blocked by a soft blocker can be uninstalled <e>after</e>
installing the package blocking it. However, it exempts the common
files from file collision checks. Soft blockers are usually used
to solve file collisions between packages and are meaningful only
in <c>RDEPEND</c>.
</p>

<warning>
Soft blockers that are pure <c>DEPEND</c> <e>do not work correctly</e>.
While Portage seemingly queues the package for removal, it <e>does not</e>
exempt their contents from file collision checks. Always include your
soft blockers in <c>RDEPEND</c>!
</warning>

<p>
If it is strictly necessary to resolve the blocker before the package
is built (installed), a hard blocker must be used instead. Hard blockers
are expressed using the following syntax:
</p>

<codesample lang="ebuild">
RDEPEND="!!app-misc/foo"
</codesample>

<p>
Hard blockers apply accordingly to the dependency type defining them.
Blockers defined in <c>RDEPEND</c> are enforced as long as the package
is installed (but do not prevent building binary packages). Blockers
defined purely in <c>DEPEND</c> are enforced only for building
the package from source, and may not apply once the package is installed
or when it is installed from a binary package.
</p>

<p>
Specific versions can also be blocked:
</p>

<codesample lang="ebuild">
RDEPEND="!&lt;app-misc/foo-1.3"
</codesample>

<p>
Blockers can be optional based upon <c>USE</c> flags as per normal
dependencies.
</p>

<p>
Blockers added to older ebuilds should not be expected to be retroactive.  If
the user already has the ebuild installed, any changes to the ebuild should not
be expected to make any difference.  This means that you should add the
blockers to whichever ebuild is the newest (even if it means that logically it
would seem backwards).  For example, certain versions of portage don't like
some versions of bash, but the blocker was put into bash because that was the
newer package that caused the issues.
</p>

</body>
</subsection>

</body>
</section>

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

<p>
In order to depend on a package in a specific <c>SLOT</c> you must specify
at least <c>EAPI=1</c>.
</p>

<p>
To depend on a specific <c>SLOT</c>, <c>:SLOT</c> should be appended to
the package name, where 'SLOT' is the <c>SLOT</c> of the package wanted:
</p>

<codesample lang="ebuild">
DEPEND="qt3? ( x11-libs/qt:3 )
	gtk? ( x11-libs/gtk+:2 )
</codesample>

<p>
To depend on a specific version or version-range within a SLOT we use:
</p>

<codesample lang="ebuild">
DEPEND="qt3? ( ~x11-libs/qt-3.3.8:3 )
	gtk? ( >=x11-libs/gtk+-2.24.9:2 )
</codesample>

<subsection>
<title>Slot Operators</title>
<body>

<p>
In <c>EAPI=5</c> and higher, you can use slot operators appended to the package
name to declare whether or not your package should be rebuilt after the versions
satisfying its runtime dependencies are updated to versions with a different slot
or <uri link="::general-concepts/slotting#Sub-Slots">sub-slot</uri>:
</p>

<ul>
  <li><c>:=</c> means that any slot is acceptable, and that your package should be
  rebuilt if the version best matching the runtime dependency is updated to a
  version with a different slot or subslot;</li>
  <li><c>:*</c> means that any slot is acceptable, and explicitly declares that
  changes in the slot or sub-slot can be ignored;</li>
  <li><c>:SLOT=</c> means that only the 'SLOT' slot is acceptable, and that your
  package should be rebuilt if the version matching the runtime dependency is
  updated to another version with this slot but with a different subslot;</li>
  <li><c>:SLOT</c> means that only the 'SLOT' slot is acceptable, and that changes
  in the sub-slot can be ignored (like in previous EAPIs).</li>
  <li><c>:SLOT/SUBSLOT</c> means a dependency on a specific slot and sub-slot pair,
  which can be useful for packages installing pre-built binaries that require a
  library with a particular soname version corresponding to the sub-slot.</li>
</ul>

<p>
For example:
</p>

<codesample lang="ebuild">
RDEPEND="media-libs/cogl:1.0=
	gnutls? ( &gt;=net-libs/gnutls-2.8:= )"
</codesample>

</body>
</subsection>

</body>
</section>

<section>
<title>USE-Conditional Dependencies</title>
<body>

<p>
To depend upon a certain package if and only if a given <c>USE</c> flag is set:
</p>

<codesample lang="ebuild">
DEPEND="perl? ( dev-lang/perl )
	ruby? ( &gt;=dev-lang/ruby-1.8 )
	python? ( dev-lang/python )"
</codesample>

<p>
It is also possible to depend upon a certain package if a given <c>USE</c> flag is
<e>not</e> set:
</p>

<codesample lang="ebuild">
RDEPEND="!crypt? ( net-misc/netkit-rsh )"
</codesample>

<p>
This should <b>not</b> be used for disabling a certain <c>USE</c> flag on a given
architecture. In order to do this, the architecture team should add the <c>USE</c>
flag to their <c>use.mask</c> file in the <c>profiles/arch</c>
directory of the Gentoo repository.
</p>

<p>
This can be nested:
</p>

<codesample lang="ebuild">
DEPEND="!build? (
	gcj? (
		gtk? (
			x11-libs/libXt
			x11-libs/libX11
			x11-libs/libXtst
			x11-proto/xproto
			x11-proto/xextproto
			>=x11-libs/gtk+-2.2
			x11-libs/pango
		)
		>=media-libs/libart_lgpl-2.1
	)
	>=sys-libs/ncurses-5.2-r2
	nls? ( sys-devel/gettext )
)"
</codesample>

</body>
</section>

<section>
<title>
Any of Many Dependencies
</title>
<body>

<p>
To depend on either <c>foo</c> or <c>bar</c>:
</p>

<codesample lang="ebuild">
DEPEND="|| ( app-misc/foo app-misc/bar )"
</codesample>

<p>
To depend on either <c>foo</c> or <c>bar</c> if the <c>baz</c> <c>USE</c> flag is set:
</p>

<codesample lang="ebuild">
DEPEND="baz? ( || ( app-misc/foo app-misc/bar ) )"
</codesample>

<subsection>
<title>Any of Many Versus USE</title>
<body>

<p>
Say <c>fnord</c> can be built against either <c>foo</c> or <c>bar</c>. Then a <c>USE</c>
flag is not necessary if and only if all of the following hold:
</p>

<ul>
  <li>
    <c>fnord</c> is merged on a system which has <c>foo</c> and not <c>bar</c> installed.
    <c>foo</c> is then unmerged, and <c>bar</c> is installed. <c>fnord</c> must continue to
    work correctly.
  </li>
  <li>
    A binary package of <c>fnord</c> made on a system with <c>foo</c> and not <c>bar</c>
    can be taken and installed on a system with <c>bar</c> and not <c>foo</c>.
  </li>
</ul>

</body>
</subsection>

</body>
</section>

<section>
<title>Built with USE Dependencies</title>
<body>

<p>
In order to use built with use dependencies you must specify <c>EAPI=2</c>.
</p>

<p>
Available specifiers are:
</p>

<table>
  <tr>
    <th>Specifier</th>
    <th>Meaning</th>
  </tr>
  <tr>
    <ti><c>app-misc/foo[bar]</c></ti>
    <ti>foo must have bar enabled.</ti>
  </tr>
  <tr>
    <ti><c>app-misc/foo[bar,baz]</c></ti>
    <ti>foo must have both bar and baz enabled.</ti>
  </tr>
  <tr>
    <ti><c>app-misc/foo[-bar,baz]</c></ti>
    <ti>foo must have bar disabled and baz enabled.</ti>
  </tr>
</table>

<p>
There are also shortcuts for conditional situations:
</p>

<table>
  <tr>
    <th>Compact form</th>
    <th>Equivalent expanded form</th>
  </tr>
  <tr>
    <ti><c>app-misc/foo[bar?]</c></ti>
    <ti><c>bar? ( app-misc/foo[bar] ) !bar? ( app-misc/foo )</c></ti>
  </tr>
  <tr>
    <ti><c>app-misc/foo[!bar?]</c></ti>
    <ti><c>bar? ( app-misc/foo ) !bar? ( app-misc/foo[-bar] )</c></ti>
  </tr>
  <tr>
    <ti><c>app-misc/foo[bar=]</c></ti>
    <ti><c>bar? ( app-misc/foo[bar] ) !bar? ( app-misc/foo[-bar] )</c></ti>
  </tr>
  <tr>
    <ti><c>app-misc/foo[!bar=]</c></ti>
    <ti><c>bar? ( app-misc/foo[-bar] ) !bar? ( app-misc/foo[bar] )</c></ti>
  </tr>
</table>

<subsection>
<title>Use dependency defaults</title>
<body>

<p>
If a dependency is introducing or removing a <c>USE</c> flag in new versions, a use
dependency default may be used. Appending a <c>(+)</c> or <c>(-)</c> suffix will indicate
whether the absence of the flag from a particular version should indicate its
presence or absence.
</p>
<p>
<c>>=dev-libs/boost-1.48[threads(+)]</c> will treat all versions without <c>threads</c> as having it set.
</p>

</body>
</subsection>

</body>
</section>

<section>
<title>Legacy Inverse USE-Conditional Dependency Syntax</title>
<body>

<p>
	Once upon a time the <c>:</c> conditional operator was allowed in <c>*DEPEND</c>:
</p>

<codesample lang="ebuild">
DEPEND="use-flag? ( app-misc/foo ) : ( app-misc/bar )"
</codesample>

<p>
<b>This syntax is no longer permitted</b>. It is exactly equivalent to the
following, which should be used instead:
</p>

<codesample lang="ebuild">
DEPEND="use-flag?  ( app-misc/foo )
	!use-flag? ( app-misc/bar )"
</codesample>

<p>
It is useful to recognise the legacy syntax and to know that it is no longer
valid.
</p>

</body>
</section>

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