summaryrefslogtreecommitdiff
blob: e82f0aabfec777de5792f7b9e17da520ae912fe1 (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
\label{pkg-mgr-commands}

The following commands will always be available in the ebuild environment, provided by the package
manager. Except where otherwise noted, they may be internal (shell functions or aliases) or external
commands available in \t{PATH}; where this is not specified, ebuilds may not rely upon either
behaviour.

\IFKDEBUILDELSE
{
    \subsubsection{Banned commands}
    \label{banned-commands}

    Some commands are banned in some EAPIs. If a banned command is called, the package manager must
    abort the build process indicating an error.

    \begin{center}
    \topcaption{Banned commands}
    \tablehead{
        \hline
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{3}{c}{\textbf{Command banned?}} \\
        \multicolumn{1}{c}{} &
        \multicolumn{1}{c}{\textbf{\t{dohard}}} &
        \multicolumn{1}{c}{\textbf{\t{dohtml}}} &
        \multicolumn{1}{c}{\textbf{\t{dosed}}} \\
        \hline
    }
    \begin{mpxtabular}{ l l l l } \label{banned-commands-table}
    \t{0} & No & No & No \\
    \t{1} & No & No & No \\
    \t{kdebuild-1} & Yes & Yes & Yes \\
    \hline
    \end{mpxtabular}
    \end{center}
}{
}

\subsubsection{Sandbox commands}
These commands affect the behaviour of the sandbox. Each command takes a single directory as
argument. Ebuilds must not run any of these commands once the current phase function has returned.
\begin{description}
\item[addread] Add a directory to the permitted read list.
\item[addwrite] Add a directory to the permitted write list.
\item[addpredict] Add a directory to the predict list. Any write to a location in this list will be
    denied, but will not trigger access violation messages or abort the build process.
\item[adddeny] Add a directory to the deny list.
\end{description}

\subsubsection{Package manager query commands}
These commands are used to extract information about the host system. Ebuilds must not run any of
these commands in parallel with any other package manager command. Ebuilds must not run any of
these commands once the current phase function has returned.
\begin{description}
\item[has\_version] Takes exactly one package dependency specification as an argument. Returns
    true if a package matching the atom is installed in \t{\$ROOT}, and false otherwise.
\item[best\_version] Takes exactly one package dependency specification as an argument. If a
    matching package is installed, prints the category, package name and version of the highest
    matching version.
\end{description}

\subsubsection{Output commands}
These commands display messages to the user. Unless otherwise stated, the entire argument list is
used as a message, as in the simple invocations of \t{echo}. Ebuilds must not run any of these
commands once the current phase function has returned. Unless otherwise noted, output may be sent to
stdout, stderr or some other appropriate facility.
\begin{description}
\item[einfo] Displays an informational message.
\item[einfon] Displays an informational message without a trailing newline.
\item[elog] Displays an informational message of slightly higher importance. The package
    manager may choose to log \t{elog} messages by default where \t{einfo} messages are not, for
    example.
\item[ewarn] Displays a warning message. Must not go to stdout.
\item[eerror] Displays an error message. Must not go to stdout.
\item[ebegin] Displays an informational message. Should be used when beginning a possibly
    lengthy process, and followed by a call to \t{eend}.
\item[eend] Indicates that the process begun with an \t{ebegin} message has completed. Takes one
    fixed argument, which is a numeric return code, and an optional message in all subsequent
    arguments.  If the first argument is 0, print a success indicator; otherwise, print the message
    followed by a failure indicator.
\end{description}

\subsubsection{Error commands}
These commands are used when an error is detected that will prevent the build process from
completing. Ebuilds must not run any of these commands once the current phase function has returned.
\begin{description}
\item[die] Displays a failure message provided in its first and only argument, and then aborts the
    build process. \t{die} is \e{not} guaranteed to work correctly if called from a subshell
    environment.
\item[assert] Checks the value of the shell's pipe status variable, and if any component is non-zero
    (indicating failure), calls \t{die} with its first argument as a failure message.
\end{description}

\subsubsection{Build commands}
These commands are used during the \t{src\_compile} and \t{src\_install} phases to run the
package's build commands. Ebuilds must not run any of these commands once the current phase function
has returned.

\begin{description}
\item[econf] Calls the program's \t{./configure} script. This is designed to work with GNU
    Autoconf-generated scripts. Any additional parameters passed to \t{econf} are passed directly
    to \t{./configure}. \t{econf} will look in the current working directory for a configure script
    unless the \t{ECONF\_SOURCE} environment variable is set, in which case it is taken to be the
    directory containing it. \t{econf} must pass the following options to the configure script:
    \begin{itemize}
    \item -{}-prefix must default to \t{/usr} unless overridden by \t{econf}'s caller.
    \item -{}-mandir must be \t{/usr/share/man}
    \item -{}-infodir must be \t{/usr/share/info}
    \item -{}-datadir must be \t{/usr/share}
    \item -{}-sysconfdir must be \t{/etc}
    \item -{}-localstatedir must be \t{/var/lib}
    \item -{}-host must be the value of the \t{CHOST} environment variable.
    \item -{}-libdir must be set according to Algorithm~\ref{alg:econf-libdir}.
    \end{itemize}

    \t{econf} must be implemented internally---that is, as a bash function and not an external
    script. Should any portion of it fail, it must abort the build using \t{die}.

\begin{algorithm}
\caption{econf --libdir logic} \label{alg:econf-libdir}
\begin{algorithmic}[1]
\STATE let prefix=/usr
\IF{the caller specified -{}-prefix=\$p}
    \STATE let prefix=\$p
\ENDIF
\STATE let libdir=
\IF{the ABI environment variable is set}
    \STATE let libvar=LIBDIR\_\$ABI
    \IF{the environment variable named by libvar is set}
        \STATE let libdir=the value of the variable named by libvar
    \ENDIF
\ENDIF
\IF{libdir is non-empty}
    \STATE pass -{}-libdir=\$prefix/\$libdir to configure
\ENDIF
\end{algorithmic}
\end{algorithm}

\item[emake] Calls the \t{\$MAKE} program, or GNU make if the \t{MAKE} variable is unset.  Any
    arguments given are passed directly to the make command, as are the user's chosen \t{MAKEOPTS}\@.
    Arguments given to \t{emake} override user configuration. See also
    section~\ref{guaranteed-system-commands}. \t{emake} must be an external program and cannot be a
    function or alias---it must be callable from e.g. \t{xargs}.
\item[einstall] A shortcut for the command given in Listing~\ref{lst:einstall}. Any arguments given
    to \t{einstall} are passed verbatim to \t{emake}, as shown.

\begin{lstlisting}[caption=einstall command,label=lst:einstall]
emake \
   prefix="${D}"/usr \
   mandir="${D}"/usr/share/man \
   infodir="${D}"/usr/share/info \
   libdir="${D}"/usr/$(get_libdir) \
   "$@" \
   install
\end{lstlisting}

\end{description}

\subsubsection{Installation commands}
These commands are used to install files into the staging area, in cases where the package's \t{make
install} target cannot be used or does not install all needed files. Except where otherwise stated,
all filenames created or modified are relative to the staging directory, given by \t{\$\{D\}}. These
commands must all be external programs and not bash functions or aliases---that is, they must be
callable from \t{xargs}. Ebuilds must not run any of these commands once the current phase function
has returned.

\begin{description}
\item[dobin] Installs the given files into \t{DESTTREE/bin}, where \t{DESTTREE} defaults to
    \t{/usr}. Gives the files mode \t{0755} and ownership \t{root:root}.

\item[doconfd] Installs the given files into /etc/conf.d/.

\item[dodir] Creates the given directories, by default with file mode \t{0755}. This can be overridden
    by setting \t{DIROPTIONS} with the \t{diropts} function.

\item[dodoc] Installs the given files into a subdirectory under \t{/usr/share/doc/\$PF/}. The
    subdirectory is set by the most recent call to \t{docinto}. If \t{docinto} has not
    yet been called, instead installs to the directory \t{/usr/share/doc/\$PF/}.

\item[doexe] Installs the given files into the directory specified by the most recent
    \t{exedesttree} call. If \t{exedesttree} has not yet been called, behaviour is undefined.

\IFKDEBUILDELSE
{
    \item[dohard] Takes two parameters. Creates a hardlink from the second to the first. In EAPIs
    listed in table~\ref{banned-commands-table}, this command is banned as per
    section~\ref{banned-commands}.
}{
    \item[dohard] Takes two parameters. Creates a hardlink from the second to the first.
}

\IFKDEBUILDELSE
{
    \item[dohtml] \TODO{Write dohtml. It's banned in kdebuild-1.}
}{
    \item[dohtml] \TODO{Write dohtml.}
}

\item[doinfo] Installs a GNU Info file into the \t{/usr/share/info} area.

\item[doinitd] Installs an initscript into \t{/etc/init.d}.

\item[doins] Takes any number of files as arguments and installs them into \t{\$INSDESTTREE}\@. If
    the first argument is \t{-r}, then operates recursively, descending into any directories given.

\item[dolib] For each argument, installs it into the appropriate library directory as determined by
    Algorithm~\ref{ebuild-libdir}. Any symlinks are installed into the same directory as relative
    links to their original target.

\item[dolib.so] As for dolib. Installs the file with mode \t{0755}.

\item[dolib.a] As for dolib. Installs the file with mode \t{0644}.

\begin{algorithm}
\caption{Determining the library directory} \label{ebuild-libdir}
\begin{algorithmic}[1]
\IF{CONF\_LIBDIR\_OVERRIDE is set in the environment}
    \STATE return CONF\_LIBDIR\_OVERRIDE
\ENDIF
\IF{CONF\_LIBDIR is set in the environment}
    \STATE let LIBDIR\_default=CONF\_LIBDIR
\ELSE
    \STATE let LIBDIR\_default=``lib''
\ENDIF
\IF{ABI is set in the environment}
    \STATE let abi=ABI
\ELSIF{DEFAULT\_ABI is set in the environment}
    \STATE let abi=DEFAULT\_ABI
\ELSE
    \STATE let abi=``default''
\ENDIF
\STATE return the value of LIBDIR\_\$abi
\end{algorithmic}
\end{algorithm}

\item[doman] Installs a man page into the appropriate subdirectory of \t{/usr/share/man} depending
    upon its apparent section suffix.

\item[domo] Installs a \t{.mo} file into the appropriate subdirectory of \t{DESTTREE/share/locale},
    generated by taking the basename of the file, removing the \t{.*} suffix, and appending
    \t{/LC\_MESSAGES}.

\item[dosbin] As \t{dobin}, but installs to \t{DESTTREE/sbin}.

\IFKDEBUILDELSE
{
    \item[dosym] Creates a symbolic link named as for its second parameter, pointing to the first. If
        the directory containing the new link does not exist, creates it if EAPI is listed in
        table~\ref{dosym-table} as making the directory, or aborts the build process otherwise.
}{
    \item[dosym] Creates a symbolic link named as for its second parameter, pointing to the first. If
        the directory containing the new link does not exist, creates it.
}

\item[fowners] Acts as for \t{chown}, but takes paths relative to the image directory.

\item[fperms] Acts as for \t{chmod}, but takes paths relative to the image directory.

\item[newbin] As for \t{dobin}, but takes two parameters. The first is the file to install; the
    second is the new filename under which it will be installed.

\item[newconfd] As for \t{doconfd}, but takes two parameters as for \t{newbin}.

\item[newdoc] As above, for \t{dodoc}.

\item[newenvd] As above, for \t{doenvd}.

\item[newexe] As above, for \t{doexe}.

\item[newinitd] As above, for \t{doinitd}.

\item[newins] As above, for \t{doins}.

\item[newman] As above, for \t{doman}.

\item[newsbin] As above, for \t{dosbin}.

\item[keepdir] Creates a directory as for \t{dodir}, and an empty file whose name starts with
    \t{.keep} in that directory to ensure that the directory does not get removed by the
    package manager should it be empty at any point.

\end{description}

\IFKDEBUILDELSE
{
    \begin{center}
    \topcaption{EAPIs where \t{dosym} makes the directory}
    \tablehead{
        \hline
        \multicolumn{1}{c}{\textbf{EAPI}} &
        \multicolumn{1}{c}{\textbf{\t{dosym} makes the directory?}} \\
        \hline
    }
    \begin{mpxtabular}{ l l } \label{dosym-table}
    \t{0} & Yes \\
    \t{1} & Yes \\
    \t{kdebuild-1} & No \\
    \hline
    \end{mpxtabular}
    \end{center}
}{
}

\subsubsection{Commands affecting install destinations}
The following commands are used to set the various destination trees, all relative to \t{\$\{D\}},
used by the above installation commands. They must be shell functions or aliases, due to the need to
set variables read by the above commands. Ebuilds must not run any of these commands once the
current phase function has returned.

\begin{description}

\item[into] Sets the value of \t{DESTTREE} for future invocations of the above utilities.  Creates
the directory under \t{\$\{D\}}, using \t{install -d} with no additional options, if it does not
already exist.

\item[insinto] Sets the value of \t{INSDESTTREE} for future invocations of the above utilities. May
    create the directory, as specified for \t{into}.

\item[exeinto] Sets the install path for \t{doexe} and \t{newexe}. May create the directory, as specified
    for \t{into}.

\item[docinto] Sets the install subdirectory for \t{dodoc} et al. May creates the directory, as specified
    for \t{into}.

\item[insopts] Sets the options passed by \t{doins} et al. to the \t{install} command.

\item[diropts] Sets the options passed by \t{dodir} et al. to the \t{install} command.

\item[exeopts] Sets the options passed by \t{doexe} et al. to the \t{install} command.

\item[libopts] Sets the options passed by \t{dolib} et al. to the \t{install} command.

\end{description}

\subsubsection{List Functions}
These functions work on variables containing whitespace-delimited lists (e.g. \t{USE}). Ebuilds must
not run any of these commands once the current phase function has returned. Ebuilds must not call
any function that operates upon \t{USE} to query a value that is not either listed in \t{IUSE}, a
\t{USE\_EXPAND} value or an \t{ARCH} value; package manager behaviour is undefined if such a call
is made.

\begin{description}
\item[use] Returns shell true (0) if the first argument (a \t{USE} flag name) is enabled, false
    otherwise.  If the flag name is prefixed with \t{!}, returns true if the flag is disabled, and
    false if it is enabled.
\item[usev] The same as \t{use}, but also prints the flag name if it is enabled.
\item[useq] Deprecated synonym for \t{use}.
\\
\item[has] Returns shell true (0) if the first argument (a word) is found in the list of subsequent
    arguments, false otherwise.
\item[hasv] The same as \t{has}, but also prints the first argument if found.
\item[hasq] Deprecated synonym for \t{has}.
\\
\item[use\_with] Has one-, two-, and three-argument forms. The first argument is a USE flag name,
    the second a \t{configure} option name (\t{\$opt}), defaulting to the same as the first argument
    if not provided, and the third is a string value (\t{\$value}), defaulting to nothing. If the
    USE flag is set, outputs \t{--with-\$opt=\$value} if the third argument was provided, and
    \t{--with-\$opt} otherwise. If the flag is not set, then it outputs \t{--without-\$opt}.

\item[use\_enable] Works the same as \t{use\_with()}, but outputs \t{--enable-} or \t{--disable-}
instead of \t{--with-} or \t{--without-}.
\end{description}

\subsubsection{Misc Commands}
The following commands are always available in the ebuild environment, but don't really fit in any
of the above categories. Ebuilds must not run any of these commands once the current phase function
has returned.

\begin{description}
\IFKDEBUILDELSE
{
    \item[dosed] Takes any number of arguments, which can be files or \t{sed} expressions. For each
        argument, if it names, relative to \t{D} a file which exists, then \t{sed} is run with the
        current expression on that file. Otherwise, the current expression is set to the text of the
        argument. The initial value of the expression is \t{s:\$\{D\}::g}. In EAPIs listed in
        table~\ref{banned-commands-table}, this command is banned as per
        section~\ref{banned-commands}.
}{
    \item[dosed] Takes any number of arguments, which can be files or \t{sed} expressions. For each
        argument, if it names, relative to \t{D} a file which exists, then \t{sed} is run with the
        current expression on that file. Otherwise, the current expression is set to the text of the
        argument. The initial value of the expression is \t{s:\$\{D\}::g}.
}

\item[unpack] Unpacks a source archive into the current directory. After unpacking, must
    ensure that all filesystem objects inside the current working directory (but not the current working
    directory itself) have permissions \t{a+r,u+w,go-w} and that all directories under the current
    working directory additionally have permissions \t{a+x}.

    Must be able to unpack the following file formats, if the relevant binaries are available:
    \begin{itemize}
    \item tar files (\t{*.tar})
    \item gzip-compressed tar files (\t{*.tar.gz, *.tgz, *.tar.Z, *.tbz})
    \item bzip2-compressed tar files (\t{*.tar.bz2, *.tbz2, *.tar.bz})
    \item zip files (\t{*.zip, *.ZIP, *.jar}) (with \t{unzip} available)
    \item gzip files (\t{*.gz, *.Z, *.z})
    \item bzip2 files (\t{*.bz, *.bz2})
    \item 7zip files (\t{*.7z, *.7Z})
    \item rar files (\t{*.rar, *.RAR}) (with \t{unrar} available)
    \item LHA archives (\t{*.LHA, *.LHa, *.lha, *.lhz}) (with \t{lha} available)
    \item ar archives (\t{*.a, *.deb})
    \item lzma archives (\t{*.lzma})
    \end{itemize}
    It is up to the ebuild to ensure that the relevant external utilities are available, whether by
    being in the system set or via dependencies.
\end{description}

\subsubsection{Debug Commands}
The following commands are available for debugging. Normally all of these commands should be no ops;
a package manager may provide a special debug mode where these commands instead do something.
Ebuilds must not run any of these commands once the current phase function has returned.

\begin{description}
\item[debug-print] If in a special debug mode, the arguments should be outputted or recorded using
    some kind of debug logging.
\item[debug-print-function] Calls \t{debug-print} with \t{\$1: entering function} as the first
    argument and the remaining arguments as additional arguments.
\item[debug-print-section] Calls \t{debug-print} with \t{now in section \$*}.
\end{description}

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

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