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
|
<?xml version="1.0" encoding="UTF-8"?>
<guide self="general-concepts/portage-cache/">
<chapter>
<title>The Portage cache</title>
<body>
<p>
Portage uses a cache for most top-level variables (<c>DEPEND</c>, <c>DESCRIPTION</c>,
<c>SRC_URI</c> and so on). This cache may be generated on a different machine, so
these variables must be either static or generated using only unchanging
'version / name' variables (<c>P</c>, <c>PN</c>, <c>PV</c>, <c>PR</c>, <c>PVR</c> and <c>PF</c>).
</p>
<p>
The cache, when generated, must be identical independent of the used machine
or environment. This concept is referred to as <e>metadata invariance</e>.
</p>
<p>
So, the following will not work:
</p>
<codesample lang="ebuild">
# DO NOT DO THIS!
if ! has_version "x11-libs/gtk+" ; then
DEPEND="${DEPEND}
gtk? ( >=x11-libs/gtk+-2 )
!gtk? ( =x11-libs/gtk+-1.2* )"
fi
</codesample>
<p>
However, the following is legal, since the <c>ver_test</c> function works upon
<c>PV</c>, and the <c>PV</c> and <c>PN</c> variables are both static:
</p>
<codesample lang="ebuild">
if ver_test -ge 7.0 ; then
IUSE="${IUSE} tcltk mzscheme"
DEPEND="${DEPEND}
tcltk? ( dev-lang/tcl )
mzscheme? ( dev-lisp/mzscheme )"
RDEPEND="${RDEPEND}
tcltk? ( dev-lang/tcl )
mzscheme? ( dev-lisp/mzscheme )"
if [[ "${MY_PN}" != "vim-core" ]] ; then
RDEPEND="${RDEPEND} !<app-vim/align-30-r1"
fi
fi
</codesample>
</body>
<section>
<title>Conditional inherits</title>
<body>
<p>
Because eclasses modify various cached variables, conditional inheritance is not
allowed except where the same results will always be obtained on every system.
For example, inherits based upon <c>USE</c> flags are illegal, but inherits based
solely upon <c>PN</c> are allowed.
</p>
<p>
As an example of a legal and possibly useful conditional inherit, some eclasses
or ebuilds do:
</p>
<codesample lang="ebuild">
if [[ ${PV} == 9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/devmanual.git"
else
SRC_URI="https://dev.gentoo.org/~ulm/distfiles/${P}.tar.xz"
KEYWORDS="~amd64 ~arm ~hppa ~ppc ~ppc64 ~sparc ~x86"
fi
</codesample>
<p>
This allows the same eclass (or the same ebuild "template") to be used for both
regular and live packages.
</p>
</body>
</section>
</chapter>
</guide>
|