summaryrefslogtreecommitdiff
blob: eb235e7a49cd5729ee6a9f99091ff036eb8cebdc (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
\section{Defined Variables}
\label{sec:ebuild-env-vars}

The package manager must define the following environment variables. Not all variables are
meaningful in all phases; variables that are not meaningful in a given phase may be unset or set to
any value. Ebuilds must not attempt to modify any of these variables, unless otherwise specified.

Because of their special meanings, these variables may not be preserved consistently across all
phases as would normally happen due to environment saving (see~\ref{sec:ebuild-env-state}). For example,
\t{EBUILD\_PHASE} is different for every phase, and \t{ROOT} may have changed between the various
different \t{pkg\_*} phases. Ebuilds must recalculate any variable they derive from an inconsistent
variable.

\begin{landscape}
\begin{longtable}{l p{0.15\textwidth} l p{0.5\textwidth}}
\caption{Defined variables\label{tab:defined_vars}}\\
\toprule
\multicolumn{1}{c}{\b{Variable}} &
\multicolumn{1}{c}{\b{Legal in}} &
\multicolumn{1}{c}{\b{Consistent?}} &
\multicolumn{1}{c}{\b{Description}} \\
\midrule
\endfirsthead
\midrule
\multicolumn{1}{c}{\b{Variable}} &
\multicolumn{1}{c}{\b{Legal in}} &
\multicolumn{1}{c}{\b{Consistent?}} &
\multicolumn{1}{c}{\b{Description}} \\
\midrule
\endhead
\midrule
\endfoot
\bottomrule
\endlastfoot
\t{P} &
    all &
    No\footnote{May change if a package has been updated (see~\ref{sec:updates-dir})} &
    Package name and version, without the revision part. For example, \t{vim-7.0.174}. \\
\t{PN} &
    all &
    ditto &
    Package name, for example \t{vim}. \\
\t{CATEGORY} &
    all &
    ditto &
    The package's category, for example \t{app-editors}. \\
\t{PV} &
    all &
    Yes &
    Package version, with no revision. For example \t{7.0.174}. \\
\t{PR} &
    all &
    Yes &
    Package revision, or \t{r0} if none exists. \\
\t{PVR} &
    all &
    Yes &
    Package version and revision (if any), for example \t{7.0.174} or \t{7.0.174-r1}. \\
\t{PF} &
    all &
    Yes &
    Package name, version, and revision (if any), for example \t{vim-7.0.174-r1}. \\
\t{A} &
    \t{src\_*} &
    Yes &
    All source files available for the package, whitespace separated with no leading or trailing
    whitespace, and in the order in which the item first appears in a matched component of
    \t{SRC\_URI}\@. Does not include any that are disabled because of USE conditionals. The value is
    calculated from the base names of each element of the \t{SRC\_URI} ebuild metadata variable. \\
\t{AA}\footnote{This variable is generally considered deprecated. However, ebuilds must still
    assume that the package manager sets it. For example, a few configure scripts use this variable
    to find the \t{aalib} package; ebuilds calling such configure scripts must thus work around
    this.} &
    \t{src\_*} &
    Yes &
    \featurelabel{aa} All source files that could be available for the package, including any that
    are disabled in \t{A} because of USE conditionals. The value is calculated from the base names
    of each element of the \t{SRC\_URI} ebuild metadata variable. Only for EAPIs listed in
    table~\ref{tab:env-vars-table} as supporting \t{AA}. \\
\t{FILESDIR} &
    \t{src\_*}\footnote{Not necessarily present when installing from a binary package} &
    No &
    The full path to the package's files directory, used for small support files or
    patches. See section~\ref{sec:package-dirs}. May or may not exist; if a repository provides no
    support files for the package in question then an ebuild must be prepared for the situation
    where \t{FILESDIR} points to a non-existent directory. \\
\t{PORTDIR} &
    ditto &
    No &
    The full path to the master repository's base directory. \\
\t{DISTDIR} &
    ditto &
    No &
    The full path to the directory in which the files in the \t{A} variable are stored. \\
\t{ECLASSDIR} &
    ditto &
    No &
    The full path to the master repository's eclass directory. \\
\t{ROOT} &
   \t{pkg\_*} &
   No &
   The absolute path to the root directory into which the package is to be merged.  Phases which run
   with full filesystem access must not touch any files outside of the directory given in
   \t{ROOT}\@. Also of note is that in a cross-compiling environment, binaries inside of \t{ROOT}
   will not be executable on the build machine, so ebuilds must not call them. \t{ROOT} must be
   non-empty and end in a trailing slash. \\
\t{EROOT} &
    \t{pkg\_*} &
    No &
    Like \t{ROOT}, but with \t{EPREFIX} appended. This is a convenience variable. See also the
    \t{EPREFIX} variable. \\
\t{T} &
    All &
    Partially\footnote{Consistent and preserved across a single connected sequence of install or
    uninstall phases, but not between install and uninstall. When reinstalling a package, this
    variable must have different values for the install and the replacement.} &
    The full path to a temporary directory for use by the ebuild. \\
\t{TMPDIR} &
    All &
    Ditto &
    Must be set to the location of a usable temporary directory, for any applications
    called by an ebuild. Must not be used by ebuilds directly; see \t{T} above. \\
\t{HOME} &
    All &
    Ditto &
    The full path to an appropriate temporary directory for use by any programs invoked by the
    ebuild that may read or modify the home directory. \\
\t{EPREFIX} &
    All &
    Yes &
    The normalised offset-prefix path of an offset installation.  When \t{EPREFIX} is not set in the
    calling environment, \t{EPREFIX} defaults to the built-in offset-prefix that was set during
    installation of the package manager. When a different \t{EPREFIX} value than the built-in value is set
    in the calling environment, a cross-prefix build is performed where using the existing utilities, a
    package is built for the given \t{EPREFIX}, akin to \t{ROOT}. See also~\ref{sec:offset-vars}. \\
\t{D} &
    \t{src\_install} &
    No &
    Contains the full path to the image directory into which the package should be installed.
    Must be non-empty and end in a trailing slash. \\
\t{D} (continued) &
    \t{pkg\_preinst}, \t{pkg\_postinst} &
    Yes &
    Contains the full path to the image that is about to be or has just been merged. Must be
    non-empty and end in a trailing slash. \\
\t{ED} &
    \t{src\_install}, \t{pkg\_preinst}, \t{pkg\_postinst} &
    See \t{D} &
    Like \t{D}, but with \t{EPREFIX} appended. This is a convenience variable. See also the
    \t{EPREFIX} variable. \\
\t{IMAGE}\footnote{Deprecated in favour of \t{D}.} &
    \t{pkg\_preinst}, \t{pkg\_postinst} &
    Yes &
    Equal to \t{D}. \\
\t{INSDESTTREE} &
    \t{src\_install} &
    No &
    Controls the location where doins installs things. \\
\t{USE} &
    All &
    Yes &
    A whitespace-delimited list of all active USE flags for this ebuild. See
    section~\ref{sec:use-iuse-handling} for details. \\
\t{EBUILD\_PHASE} &
    All &
    No &
    Takes one of the values \t{config}, \t{setup}, \t{nofetch}, \t{unpack}, \t{prepare},
    \t{configure}, \t{compile}, \t{test}, \t{install}, \t{preinst}, \t{postinst}, \t{prerm},
    \t{postrm}, \t{info}, \t{pretend} according to the top level ebuild function that was executed
    by the package manager. May be unset or any single word that is not any of the above when the
    ebuild is being sourced for other (e.\,g.\ metadata or QA) purposes. \\
\t{WORKDIR} &
    \t{src\_*} &
    Yes &
    The full path to the ebuild's working directory, in which all build data should be
    contained. \label{env-var-WORKDIR} \\
\t{KV} &
    All &
    Yes &
    \featurelabel{kv} The version of the running kernel at the time the ebuild was first executed,
    as returned by the \t{uname~-r} command or equivalent.  May be modified by ebuilds.  Only for
    EAPIs listed in table~\ref{tab:env-vars-table} as supporting \t{KV}. \\
\t{MERGE\_TYPE} &
    \t{pkg\_*} &
    No &
    \featurelabel{merge-type} The type of package that is being merged. Possible values are:
    \t{source} if building and installing a package from source, \t{binary} if installing a binary
    package, and \t{buildonly} if building a binary package without installing it. Only for EAPIs
    listed in table~\ref{tab:env-vars-table} as supporting \t{MERGE\_TYPE}. \\
\t{REPLACING\_VERSIONS} &
    \t{pkg\_*} (see text) &
    Yes &
    A whitespace-separated list of versions of this package (including revision, if specified) that
    are being replaced (uninstalled or overwritten) as a result of this install. See
    section~\ref{sec:replacing-versions}.  Only for EAPIs listed in table~\ref{tab:env-vars-table}
    as supporting \t{REPLACING\_VERSIONS}. \\
\t{REPLACED\_BY\_VERSION} &
    \t{pkg\_prerm}, \t{pkg\_postrm} &
    Yes &
    The single version of this package (including revision, if specified) that is replacing us, if
    we are being uninstalled as part of an install, or an empty string otherwise. See
    section~\ref{sec:replacing-versions}.  Only for EAPIs listed in table~\ref{tab:env-vars-table}
    as supporting \t{REPLACED\_BY\_VERSION}.
\end{longtable}
\end{landscape}

\begin{centertable}{EAPIs supporting various env variables} \label{tab:env-vars-table}
    \begin{tabular}{ l l l l l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{\t{AA}?}} &
        \multicolumn{1}{c}{\textbf{\t{KV}?}} &
        \multicolumn{1}{c}{\textbf{\t{MERGE\_TYPE}?}} &
        \multicolumn{1}{c}{\textbf{\t{REPLACING\_VERSIONS}?}} &
        \multicolumn{1}{c}{\textbf{\t{REPLACED\_BY\_VERSION}?}} \\
        \midrule
    \t{0} & Yes & Yes & No & No & No \\
    \t{1} & Yes & Yes & No & No & No \\
    \t{2} & Yes & Yes & No & No & No \\
    \t{3} & Yes & Yes & No & No & No \\
    \t{4} & No & No & Yes & Yes & Yes \\
    \bottomrule
    \end{tabular}
\end{centertable}

\begin{centertable}{EAPIs supporting offset-prefix env variables}
    \label{tab:offset-env-vars-table}
    \begin{tabular}{ l l l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{\t{EPREFIX}?}} &
        \multicolumn{1}{c}{\textbf{\t{EROOT}?}} &
        \multicolumn{1}{c}{\textbf{\t{ED}?}} \\
        \midrule
        \t{0} & No & No & No \\
        \t{1} & No & No & No \\
        \t{2} & No & No & No \\
        \t{3} & Yes & Yes & Yes \\
        \t{4} & Yes & Yes & Yes \\
        \bottomrule
    \end{tabular}
\end{centertable}

Except where otherwise noted, all variables set in the active profiles' \t{make.defaults} files must
be exported to the ebuild environment. \t{CHOST}, \t{CBUILD} and \t{CTARGET}, if not set by
profiles, must contain either an appropriate machine tuple (the definition of appropriate is beyond
the scope of this specification) or be unset.

\t{PATH} must be initialized by the package manager to a ``usable'' default.  The exact value here
is left up to interpretation, but it should include the equivalent ``sbin'' and ``bin'' and any
package manager specific directories.

\t{GZIP}, \t{BZIP}, \t{BZIP2}, \t{CDPATH}, \t{GREP\_OPTIONS}, \t{GREP\_COLOR} and \t{GLOBIGNORE}
must not be set.

\subsection{USE and IUSE Handling}
\label{sec:use-iuse-handling}

This section discusses the handling of four variables:

\begin{description}
\item[IUSE] is the variable calculated from the \t{IUSE} values defined in ebuilds and eclasses.
\item[IUSE\_REFERENCEABLE] is a variable calculated from \t{IUSE} and a variety of other sources
    described below. It is purely a conceptual variable; it is not exported to the ebuild
    environment. Values in \t{IUSE\_REFERENCEABLE} may legally be used in queries from other
    packages about an ebuild's state (for example, for use dependencies).
\item[IUSE\_EFFECTIVE] is another conceptual, unexported variable. Values in \t{IUSE\_EFFECTIVE} are
    those which an ebuild may legally use in queries about itself (for example, for the \t{use}
    function, and for use in dependency specification conditional blocks).
\item[USE] is a variable calculated by the package manager and exported to the ebuild environment.
\end{description}

In all cases, the values of \t{IUSE\_REFERENCEABLE} and \t{IUSE\_EFFECTIVE} are undefined during
metadata generation.

\t{IUSE\_REFERENCEABLE} is equal to the calculated \t{IUSE} value.

\t{IUSE\_EFFECTIVE} contains the following values:

\begin{compactitem}
\item All values in the calculated \t{IUSE} value.
\item All possible values for the \t{ARCH} variable.
\item All legal use flag names whose name starts with the lowercase equivalent of any value in
    the profile \t{USE\_EXPAND} variable followed by an underscore.
\end{compactitem}

The \t{USE} variable is set by the package manager. For each value in \t{IUSE\_EFFECTIVE}, \t{USE}
shall contain that value if the flag is to be enabled for the ebuild in question, and shall not
contain that value if it is to be disabled. \t{USE} may contain other flag names that are not
relevant for the ebuild.

\subsection{\t{REPLACING\_VERSIONS} and \t{REPLACED\_BY\_VERSION}}
\label{sec:replacing-versions}

\featurelabel{replace-version-vars} In EAPIs listed in table~\ref{tab:env-vars-table} as supporting
it, the \t{REPLACING\_VERSIONS} variable shall be defined in \t{pkg\_preinst} and \t{pkg\_postinst}.
In addition, it \e{may} be defined in \t{pkg\_pretend} and \t{pkg\_setup}, although ebuild authors
should take care to handle binary package creation and installation correctly when using it in these
phases.

\t{REPLACING\_VERSIONS} is a list, not a single optional value, to handle pathological cases such as
installing \t{foo-2:2} to replace \t{foo-2:1} and \t{foo-3:2}.

In EAPIs listed in table~\ref{tab:env-vars-table} as supporting it, the \t{REPLACED\_BY\_VERSION}
variable shall be defined in \t{pkg\_prerm} and \t{pkg\_postrm}. It shall contain at most one value.

\subsection{Offset-prefix variables \t{EPREFIX}, \t{EROOT} and \t{ED}}
\label{sec:offset-vars}

\begin{centertable}{EAPIs supporting offset-prefix}
    \label{tab:offset-support-table}
    \begin{tabular}{ l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{Supports offset-prefix?}}\\
        \midrule
        \t{0} & No \\
        \t{1} & No \\
        \t{2} & No \\
        \t{3} & Yes \\
        \t{4} & Yes \\
        \bottomrule
    \end{tabular}
\end{centertable}

\featurelabel{offset-prefix-vars} Table~\ref{tab:offset-support-table} lists the EAPIs which support
offset-prefix installations. This support was initially added in EAPI 3, in the form of three extra
variables.  Two of these, \t{EROOT} and \t{ED}, are convenience variables using the variable
\t{EPREFIX}. In EAPIs that do not support an offset-prefix, the installation offset is hardwired to
\t{/usr}. In offset-prefix supporting EAPIs the installation offset is set as \t{\$\{EPREFIX\}/usr}
and hence can be adjusted using the variable \t{EPREFIX}. Note that the behaviour of offset-prefix
aware and agnostic is the same when \t{EPREFIX} is set to the empty string in offset-prefix aware
EAPIs.  The latter do have the variables \t{ED} and \t{EROOT} properly set, though.

% vim: set filetype=tex fileencoding=utf8 et tw=100 spell spelllang=en :

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "pms"
%%% LaTeX-indent-level: 4
%%% LaTeX-item-indent: 0
%%% TeX-brace-indent-level: 4
%%% End: