summaryrefslogtreecommitdiff
blob: 8e1918d16d491f7cc0565772de8b22ebd3ebd9fb (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
\chapter{Ebuild-defined Functions}
\label{ebuild-functions}

\section{List of Functions}
\label{functions}

The following is a list of functions that an ebuild, or eclass, may define, and which will be called
by the package manager as part of the build and/or install process. In all cases the package manager
must provide a default implementation of these functions; unless otherwise stated this must be a
no-op. Most functions must assume only that they have write access to the package's working
directory (the \t{WORKDIR} environment variable; see section~\ref{env-var-WORKDIR}), and the
temporary directory \t{T}; exceptions are noted below. All functions may assume that they have read
access to all system libraries, binaries and configuration files that are accessible to normal
users.

Some functions may assume that their initial working directory is set to a particular location;
these are noted below. If no initial working directory is mandated, it may be set to anything and
the ebuild must not rely upon a particular location for it.

The environment for functions run outside of the build sequence (that is, \t{pkg\_config},
\t{pkg\_info}, \t{pkg\_prerm} and \t{pkg\_postrm}) must be the environment used for the build of the
package, not the current configuration.

Ebuilds must not call nor assume the existence of any phase functions.

\subsection{pkg\_setup}
\label{pkg-setup-function}
The \t{pkg\_setup} function sets up the ebuild's environment for all following functions, before
the build process starts. Further, it checks whether any necessary prerequisites not covered
by the package manager, e.g.\ that certain kernel configuration options are fulfilled.

\t{pkg\_setup} must be run with full filesystem permissions, including the ability to add new users
and/or groups to the system.

\subsection{src\_unpack}
\label{src-unpack-function}

The \t{src\_unpack} function extracts all of the package's sources, applies patches and sets up the
package's build system for further use.

The initial working directory must be \t{WORKDIR}, and the default implementation used when
the ebuild lacks the \t{src\_unpack} function shall behave as:

\begin{verbatim}
src_unpack() {
    if [[ -n ${A} ]]; then
        unpack ${A}
    fi
}
\end{verbatim}

\subsection{src\_compile}
\label{src-compile-function}

The \t{src\_compile} function configures the package's build environment and builds the package.

The initial working directory must be \t{S} if that exists, falling back to \t{WORKDIR} otherwise.

For EAPIs not listed in table~\ref{src-compile-table} as being \t{ECONF\_SOURCE} aware, the default
implementation used when the ebuild lacks the \t{src\_compile} function shall behave as:

\begin{verbatim}
src_compile() {
    if [[ -x ./configure ]]; then
        econf
    fi
    if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then
        emake || die "emake failed"
    fi
}
\end{verbatim}

For EAPIs listed in table~\ref{src-compile-table} as being \t{ECONF\_SOURCE} aware, the default
implementation used when the ebuild lacks the \t{src\_compile} function shall behave as:

\begin{verbatim}
src_compile() {
    if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
        econf
    fi
    if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then
        emake || die "emake failed"
    fi
}
\end{verbatim}

\begin{centertable}{EAPIs supporting \t{ECONF\_SOURCE} in \t{src\_compile}} \label{src-compile-table}
\IFKDEBUILDELSE
{
    \begin{tabular}{ l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{Supports \t{ECONF\_SOURCE}?}} \\
        \midrule
    \t{0} & No \\
    \t{1} & Yes \\
    \t{kdebuild-1} & Yes \\
    \bottomrule
    \end{tabular}
}{
    \begin{tabular}{ l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{Supports \t{ECONF\_SOURCE}?}} \\
        \midrule
    \t{0} & No \\
    \t{1} & Yes \\
    \bottomrule
    \end{tabular}
}
\end{centertable}

\subsection{src\_test}
\label{src-test-function}

The \t{src\_test} function runs unit tests for the newly built but not yet installed package as
provided.

The initial working directory must be \t{S} if that exists, falling back to \t{WORKDIR} otherwise.
The default implementation used when the ebuild lacks the \t{src\_test} function must, if tests are
enabled, run \t{make check} if and only if such a target is available, or if not run \t{make test},
if and only such a target is available. In both cases, if make returns non-zero the build must be
aborted.

The \t{src\_test} function may be disabled by \t{RESTRICT}. See section~\ref{restrict}.

\IFKDEBUILDELSE
{
    In some EAPIs, \t{src\_test} should only be run at user option (and never if restrictions are in
    place). In others, it must always be run (excepting restrictions). See table~\ref{test-required-table}
    for which EAPIs fit into which category.

    \begin{centertable}{EAPIs requiring \t{src\_test}} \label{test-required-table}
    \begin{tabular}{ l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{Requires \t{src\_test}?}} \\
        \midrule
    \t{0} & At user option \\
    \t{1} & At user option \\
    \t{kdebuild-1} & Required \\
    \bottomrule
    \end{tabular}

    \end{centertable}
}{
}

\subsection{src\_install}
\label{src-install-function}

The \t{src\_install} function installs the package's content to a directory specified in
\t{\${D}}.

The initial working directory must be \t{S} if that exists, falling back to \t{WORKDIR} otherwise.
The default implementation used when the ebuild lacks the \t{src\_install} function is a no-op.

\subsection{pkg\_preinst}
\label{pkg-preinst-function}

The \t{pkg\_preinst} function performs any special tasks that are required immediately before
merging the package to the live filesystem. It must not write outside of the directories specified
by the \t{ROOT} and \t{D} environment variables.

\t{pkg\_preinst} must be run with full access to all files and directories below that specified by
the \t{ROOT} and \t{D} environment variables.

\subsection{pkg\_postinst}
\label{pkg-postinst-function}

The \t{pkg\_postinst} function performs any special tasks that are required immediately after
merging the package to the live filesystem. It must not write outside of the directory specified
in the \t{ROOT} environment variable.

\t{pkg\_postinst}, like, \t{pkg\_preinst}, must be run with full access to all files and directories
below that specified by the \t{ROOT} environment variable.

\subsection{pkg\_prerm}
\label{pkg-prerm-function}

The \t{pkg\_prerm} function performs any special tasks that are required immediately before
unmerging the package from the live filesystem. It must not write outside of the directory specified
by the \t{ROOT} environment variable.

\t{pkg\_prerm} must be run with full access to all files and directories below that specified by
the \t{ROOT} environment variable.

\subsection{pkg\_postrm}
\label{pkg-postrm-function}

The \t{pkg\_postrm} function performs any special tasks that are required immediately after
unmerging the package from the live filesystem. It must not write outside of the directory specified
by the \t{ROOT} environment variable.

\t{pkg\_postrm} must be run with full access to all files and directories below that specified by
the \t{ROOT} environment variable.

\subsection{pkg\_config}
\label{pkg-config-function}

The \t{pkg\_config} function performs any custom steps required to configure a package after it has been
fully installed. It is the only ebuild function which may be interactive and prompt for user input.

\t{pkg\_config} must be run with full access to all files and directories inside of \t{ROOT}.

\subsection{pkg\_info}
\label{pkg-info-function}

\IFKDEBUILDELSE
{
    The \t{pkg\_info} function may be called by the package manager when displaying information about an
    installed package. In EAPIs listed in table~\ref{pkg-info-table} as supporting \t{pkg\_info} on
    uninstalled packages, it may also be called by the package manager when displaying information
    about an uninstalled package. In this case, ebuild authors should note that dependencies may not be
    installed.
}{
    The \t{pkg\_info} function may be called by the package manager when displaying information about an
    installed package.
}

\t{pkg\_info} must not write to the filesystem.

\IFKDEBUILDELSE
{
    \begin{centertable}{EAPIs supporting \t{pkg\_info} on uninstalled packages} \label{pkg-info-table}
    \begin{tabular}{ l l }
        \toprule
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{Supports \t{pkg\_info} on uninstalled packages?}} \\
        \midrule
    \t{0} & No \\
    \t{1} & No \\
    \t{kdebuild-1} & Yes \\
    \bottomrule
    \end{tabular}
    \end{centertable}
}{
}

\subsection{pkg\_nofetch}
\label{pkg-nofetch-function}

The \t{pkg\_nofetch} function is run when the fetch phase of an fetch-restricted ebuild is run, and
the relevant source files are not available. It should direct the user to download all relevant
source files from their respective locations, with notes concerning licensing if applicable.

\t{pkg\_nofetch} must require no write access to any part of the filesystem.

\section{Call Order}

The call order for installing a package is:

\begin{compactitem}
\item \t{pkg\_setup}
\item \t{src\_unpack}
\item \t{src\_compile}
\item \t{src\_test} (except if \t{RESTRICT=test})
\item \t{src\_install}
\item \t{pkg\_preinst}
\item \t{pkg\_postinst}
\end{compactitem}

The call order for uninstalling a package is:

\begin{compactitem}
\item \t{pkg\_prerm}
\item \t{pkg\_postrm}
\end{compactitem}

The call order for reinstalling a package is:

\begin{compactitem}
\item \t{pkg\_setup}
\item \t{src\_unpack}
\item \t{src\_compile}
\item \t{src\_test} (except if \t{RESTRICT=test})
\item \t{src\_install}
\item \t{pkg\_preinst}
\item \t{pkg\_prerm} for the package being replaced
\item \t{pkg\_postrm} for the package being replaced
\item \t{pkg\_postinst}
\end{compactitem}

The call order for upgrading or downgrading a package is:

\begin{compactitem}
\item \t{pkg\_setup}
\item \t{src\_unpack}
\item \t{src\_compile}
\item \t{src\_test} (except if \t{RESTRICT=test})
\item \t{src\_install}
\item \t{pkg\_preinst}
\item \t{pkg\_postinst}
\item \t{pkg\_prerm} for the package being replaced
\item \t{pkg\_postrm} for the package being replaced
\end{compactitem}

The \t{pkg\_config}, \t{pkg\_info} and \t{pkg\_nofetch} functions are not called in a normal
sequence.

For installing binary packages, the \t{src} phases are not called.

When building binary packages that are not to be installed locally, the \t{pkg\_preinst}
and \t{pkg\_postinst} functions are not called.

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

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "pms"
%%% End: