Thanks to Mike Kelly (package manager provided utilities, section 12.3.3), Danny van Dyk (ebuild functions, section 10), David Leverton (various sections), Petteri Räty (environment state, section 12.2) and Ulrich Müller (various sections) for contributions. Thanks to Christian Faulhammer for fixing some of the more horrible formatting screwups and providing the EAPI cheat sheet. Thanks also to Mike Frysinger and Brian Harring for proof-reading and suggestions for fixes and/or clarification.
The bulk of this document is © 2007, 2008, 2009 Stephen Bennett and Ciaran McCreesh. Contributions are owned by their respective authors, and may have been changed substantially before inclusion.
This document is released under the Creative Commons Attribution-Share Alike 3.0 Licence. The full text of this licence can be found at http://creativecommons.org/licenses/by-sa/3.0/.
Issues (inaccuracies, wording problems, omissions etc.) in this document should be reported via Gentoo Bugzilla using product Gentoo Hosted Projects, component PMS/EAPI and the default assignee. There should be one bug per issue, and one issue per bug.
Patches (in git format-patch form if possible) may be submitted either via Bugzilla or to the gentoo-pms@gentoo.org mailing list. Patches will be reviewed by the PMS team, who will do one of the following:
When reporting issues, remember that this document is not the appropriate place for pushing through changes to the tree or the package manager, except where those changes are bugs.
If any issue cannot be resolved by the PMS team, it may be escalated to the Gentoo Council.
This document aims to fully describe the format of an ebuild repository and the ebuilds therein, as well as certain aspects of package manager behaviour required to support such a repository.
This document is not designed to be an introduction to ebuild development. Prior knowledge of ebuild creation and an understanding of how the package management system works is assumed; certain less familiar terms are explained in the Glossary in chapter 15.
This document does not specify any user or package manager configuration information.
At present the only definition of what an ebuild can assume about its environment, and the only definition of what is valid in an ebuild, is the source code of the latest Portage release and a general consensus about which features are too new to assume availability. This has several drawbacks: not only is it impossible to change any aspect of Portage behaviour without verifying that nothing in the tree relies upon it, but if a new package manager should appear it becomes impossible to fully support such an ill-defined standard.
This document aims to address both of these concerns by defining almost all aspects of what an ebuild repository looks like, and how an ebuild is allowed to behave. Thus, both Portage and other package managers can change aspects of their behaviour not defined here without worry of incompatibilities with any particular repository.
Text in teletype is used for filenames or variable names. Italic text is used for terms with a particular technical meaning in places where there may otherwise be ambiguity.
The term package manager is used throughout this document in a broad sense. Although some parts of this document are only relevant to fully featured package managers, many items are equally applicable to tools or other applications that interact with ebuilds or ebuild repositories.
An EAPI can be thought of as a ‘version’ of this specification to which a package conforms. An EAPI value is a string, and is part of an ebuild’s metadata.
If a package manager encounters a package version with an unrecognised EAPI, it must not attempt to perform any operations upon it. It could, for example, ignore the package version entirely (although this can lead to user confusion), or it could mark the package version as masked. A package manager must not use any metadata generated from a package with an unrecognised EAPI.
The package manager must not attempt to perform any kind of comparison test other than equality upon EAPIs.
EAPIs are also used for profile directories, as described in section 5.2.2.
The following EAPIs are defined by this specification:
Except where explicitly noted, everything in this specification applies to all of the above EAPIs.1
No name may be empty. Package managers must not impose fixed upper boundaries upon the length of any name. A package manager should indicate or reject any name that is invalid according to these rules.
A category name may contain any of the characters [A-Za-z0-9+_.-]. It must not begin with a hyphen or a dot.
Note: A hyphen is not required because of the virtual category. Usually, however, category names will contain a hyphen.
A package name may contain any of the characters [A-Za-z0-9+_-]. It must not begin with a hyphen, and must not end in a hyphen followed by one or more digits.
Note: A package name does not include the category. The term qualified package name is used where a category/package pair is meant.
A slot name may contain any of the characters [A-Za-z0-9+_.-]. It must not begin with a hyphen or a dot.
A USE flag name may contain any of the characters [A-Za-z0-9+_@-]. It must begin with an alphanumeric character. Underscores should be considered reserved for USE_EXPAND, as described in section 12.1.1.
Note: The at-sign is required for LINGUAS.
A repository name may contain any of the characters [A-Za-z0-9_-]. It must not begin with a hyphen.
A keyword name may contain any of the characters [A-Za-z0-9_-]. It must not begin with a hyphen. In contexts where it makes sense to do so, a keyword name may be prefixed by a tilde or a hyphen. In KEYWORDS, -* is also acceptable as a keyword, to indicate that a package will only work on listed targets.
A tilde prefixed keyword is, by convention, used to indicate a less stable package. It is generally assumed that any user accepting keyword ~foo will also accept foo.
The exact meaning of any keywords value is beyond the scope of this specification.
The package manager must not impose fixed limits upon the number of version components. Package managers should indicate or reject any version that is invalid according to these rules.
A version starts with the number part, which is in the form [0-9]+(\.[0-9]+)* (a positive integer, followed by zero or more dot-prefixed positive integers).
This may optionally be followed by one of [a-z] (a lowercase letter).
This may be followed by zero or more of the suffixes _alpha, _beta, _pre, _rc or _p, which themselves may be suffixed by an optional integer.
This may optionally be followed by the suffix -r followed immediately by an integer (the “revision number”). If this suffix is not present, it is assumed to be -r0.
Version specifications are compared component by component, moving from left to right, as detailed in Algorithm 1 and sub-algorithms. If a sub-algorithm returns a decision, then that is the result of the whole comparison; if it terminates without returning a decision, the process continues from the point from which it was invoked.
No two packages in a given repository may have the same qualified package name and equal versions. For example, a repository may not contain more than one of foo-bar/baz-1.0.2, foo-bar/baz-1.0.2-r0 and foo-bar/baz-1.000.2.
This chapter defines the layout on-disk of an ebuild repository. In all cases below where a file or directory is specified, a symlink to a file or directory is also valid. In this case, the package manager must follow the operating system’s semantics for symbolic links and must not behave differently from normal.
An ebuild repository shall occupy one directory on disk, with the following subdirectories:
Each category provided by the repository (see also: the profiles/categories file, section 4.4) shall be contained in one directory, whose name shall be that of the category. Each category directory shall contain:
Category directories may contain additional files, whose purpose is not covered by this specification. Additional directories that are not for a package may not be present, to avoid conflicts with package name directories; an exception is made for filesystem components whose name starts with a dot, which the package manager must ignore, and for any directory named CVS.
It is not required that a directory exists for each category provided by the repository. A category directory that does not exist shall be considered equivalent to an empty category (and by extension, a package manager may treat an empty category as a category that does not exist).
A package directory contains the following:
Any ebuild in a package directory must be named name-ver.suffix, where:
Package managers must ignore any ebuild file that does not match these rules.
A package directory that contains no correctly named ebuilds shall be considered a package with no versions. A package with no versions shall be considered equivalent to a package that does not exist (and by extension, a package manager may treat a package that does not exist as a package with no versions).
A package directory may contain other files or directories, whose purpose is not covered by this specification.
The profiles directory shall contain zero or more profile directories as described in section 5, as well as the following files and directories. In any line-based file, lines beginning with a # character are treated as comments, whilst blank lines are ignored. All contents of this directory, with the exception of repo_name, are optional.
The profiles directory may contain an eapi file. This file, if it exists, must contain a single line with the name of an EAPI. This specifies the EAPI to use when handling the profiles directory; a package manager must not attempt to use any repository whose profile directory requires an EAPI it does not support. If no eapi file is present, EAPI 0 shall be used.
If the repository is not intended to be stand-alone, the contents of these files are to be taken from or merged with the master repository as necessary.
Other files not described by this specification may exist, but may not be relied upon. The package manager must ignore any files in this directory that it does not recognise.
profiles.desc is a line-based file, with the standard commenting rules from section 4.4, containing a list of profiles that are valid for use, along with their associated architecture and status. Each line has the format:
Where:
Fields are whitespace-delimited.
thirdpartymirrors is another simple line-based file, describing the valid mirrors for use with mirror:// URIs in this repository, and the associated download locations. The format of each line is:
Fields are whitespace-delimited. When parsing a URI of the form mirror://name/path/filename, where the path/ part is optional, the thirdpartymirrors file is searched for a line whose first field is name. Then the download URIs in the subsequent fields have path/filename appended to them to generate the URIs from which a download is attempted.
Each mirror name may appear at most once in a file. Behaviour when a mirror name appears multiple times is undefined. Behaviour when a mirror is defined in terms of another mirror is undefined. A package manager may choose to fetch from all of or a subset of the listed mirrors, and may use an order other than the one described.
The mirror with the name equal to the repository’s name (and if the repository has a master, the master’s name) may be consulted for all downloads.
use.desc contains descriptions of every valid global USE flag for this repository. It is a line-based file with the standard rules for comments and blank lines. The format of each line is:
use.local.desc contains descriptions of every valid local USE flag—those that apply only to a small number of packages, or that have different meanings for different packages. Its format is:
Flags must be listed once for each package to which they apply, or if a flag is listed in both use.desc and use.local.desc, it must be listed once for each package for which its meaning differs from that described in use.desc.
The updates directory is used to inform the package manager that a package has moved categories, names, or that a version has changed SLOT. It contains one file per quarter year, named [1-4]Q-[YYYY] for the first to fourth quarter of a given year, for example 1Q-2004 or 3Q-2006. The format of each file is again line-based, with each line having one of the following formats:
The first form, where qpn1 and qpn2 are qualified package names, instructs the package manager that the package qpn1 has changed name, category, or both, and is now called qpn2.
The second form instructs the package manager that any currently installed package version matching package dependency specification spec whose SLOT is set to slot1 should have it updated to slot2.
Any name that has appeared as the origin of a move must not be reused in the future. Any slot that has appeared as the origin of a slot move may not be used by packages matching the spec of that slot move in the future.
The licenses directory shall contain copies of the licenses used by packages in the repository. Each file will be named according to the name used in the LICENSE variable as described in section 8.2, and will contain the complete text of the license in human-readable form. Plain text format is strongly preferred but not required.
The eclass directory shall contain copies of the eclasses provided by this repository. The format of these files is described in section 11. It may also contain, in their own directory, support files needed by these eclasses.
The metadata directory contains various repository-level metadata that is not contained in profiles/. All contents are optional. In this standard only the cache subdirectory is described; other contents are optional but may include security advisories, DTD files for the various XML files used in the repository, and repository timestamps.
The metadata/cache directory may contain a cached form of all important ebuild metadata variables. The contents of this directory are described in section 14.
Generally, a profile defines information specific to a certain ‘type’ of system—it lies somewhere between repository-level defaults and user configuration in that the information it contains is not necessarily applicable to all machines, but is sufficiently general that it should not be left to the user to configure it. Some parts of the profile can be overridden by user configuration, some only by another profile.
The format of a profile is relatively simple. Each profile is a directory containing any number of the files described in this chapter, and possibly inheriting another profile. The files themselves follow a few basic conventions as regards inheritance and format; these are described in the next section. It may also contain any number of subdirectories containing other profiles.
A profile may contain a parent file. Each line must contain a relative path to another profile which will be considered as one of this profile’s parents. Any settings from the parent are inherited by this profile, and can be overridden by it. Precise rules for how settings are combined with the parent profile vary between files, and are described below. Parents are handled depth first, left to right, with duplicate parent paths being sourced for every time they are encountered.
It is illegal for a profile’s parent tree to contain cycles. Package manager behaviour upon encountering a cycle is undefined.
This file must not contain comments, blank lines or make use of line continuations.
A profile directory may contain an eapi file. This file, if it exists, must contain a single line with the name of an EAPI. This specifies the EAPI to use when handling the directory in question; a package manager must not attempt to use any profile using a directory which requires an EAPI it does not support. If no eapi file is present, EAPI 0 shall be used. The EAPI is not inherited via the parent file.
If a profile contains a file named deprecated, it is treated as such. The first line of this file should contain the path from the profiles directory of the repository to a valid profile that is the recommended upgrade path from this profile. The remainder of the file can contain any text, which may be displayed to users using this profile by the package manager. This file is not inherited—profiles which inherit from a deprecated profile are not deprecated.
This file must not contain comments or make use of line continuations.
make.defaults is used to define defaults for various environment and configuration variables. This file is unusual in that it is not combined at a file level with the parent—instead, each variable is combined or overridden individually as described in section 5.3.
The file itself is a line-based key-value format. Each line contains a single VAR="value" entry, where the value must be double quoted. A variable name must start with one of a-zA-Z and may contain a-zA-Z0-9_ only. Additional syntax, which is a small subset of bash syntax, is allowed as follows:
The virtuals file defines default providers for “old-style” virtual packages. It is a simple line-based file, with each line containing two whitespace-delimited tokens. The first is a virtual package name (for example, virtual/alsa) and the second is a qualified package name. Blank lines and those beginning with a # character are ignored. When attempting to resolve a virtual name to a concrete package, the specification defined in the active profile’s virtuals list should be used if no provider is already installed.
The virtuals file is inherited in the simplest manner: all entries from the parent profile are loaded, then entries from the current profile. If a virtual package name appears in both, the entry in the parent profile is discarded.
These files are a simple one-item-per-line list, which is inherited in the following manner: the parent profile’s list is taken, and the current profile’s list appended. If any line begins with a hyphen, then any lines previous to it whose contents are equal to the remainder of that line are removed from the list. Once again, blank lines and those beginning with a # are discarded.
The packages file is used to define the ‘system set’ for this profile. After the above rules for inheritance and comments are applied, its lines must take one of two forms: a package dependency specification prefixed by * denotes that the atom forms part of the system set. A package dependency specification on its own may also appear for legacy reasons, but should be ignored when calculating the system set.
The packages.build file is used by Gentoo’s Catalyst tool to generate stage1 tarballs, and has no relevance to the operation of a package manager. It is thus outside the scope of this document, but is mentioned here for completeness.
package.mask is used to prevent packages from being installed on a given profile. Each line contains one package dependency specification; anything matching this specification will not be installed unless unmasked by the user’s configuration.
Note that the -spec syntax can be used to remove a mask in a parent profile, but not necessarily a global mask (from profiles/package.mask, section 4.4).
Note: Portage currently treats profiles/package.mask as being on the leftmost branch of the inherit tree when it comes to -lines. This behaviour may not be relied upon.
package.provided is used to tell the package manager that a certain package version should be considered to be provided by the system regardless of whether it is actually installed. Because it has severe adverse effects on USE-based and slot-based dependencies, its use is strongly deprecated and package manager support must be regarded as purely optional.
The package.use file may be used by the package manager to override the default USE flags specified by make.defaults on a per package basis. The format is to have a package dependency specification, and then a space delimited list of USE flags to enable. A USE flag in the form of -flag indicates that the package should have the USE flag disabled. The package dependency specification is limited to the forms defined by the directory’s EAPI.
This section covers the four files use.mask, use.force, package.use.mask and package.use.force. They are described together because they interact in a non-trivial manner.
Simply speaking, use.mask and use.force are used to say that a given USE flag must never or always, respectively, be enabled when using this profile. package.use.mask and package.use.force do the same thing on a per-package, or per-version, basis. The precise manner in which they interact is less simple, and is best described in terms of the algorithm used to determine whether a flag is masked for a given package version. This is described in Algorithm 8.
The logic for use.force and package.use.force is identical. If a flag is both masked and forced, the mask is considered to take precedence.
USE_EXPAND values may be forced or masked by using expand_name_value.
A package manager may treat ARCH values that are not the current architecture as being masked.
This section documents variables that have special meaning, or special behaviour, when defined in a profile’s make.defaults file.
Incremental variables must stack between parent and child profiles in the following manner: Beginning with the highest parent profile, tokenise the variable’s value based on whitespace and concatenate the lists. Then, for any token T beginning with a hyphen, remove it and any previous tokens whose value is equal to T with the hyphen removed, or, if T is equal to -*, remove all previous values. Note that because of this treatment, the order of tokens in the final result is arbitrary, not necessarily related to the order of tokens in any given profile. The following variables must be treated in this fashion:
If the package manager supports any EAPI listed in table 5.1 as using profile-defined IUSE injection, the following variables must also be treated incrementally; otherwise, the following variables may or may not be treated incrementally:
Other variables, except where they affect only package-manager-specific functionality (such as Portage’s FEATURES variable), must not be treated incrementally—later definitions shall completely override those in parent profiles.
EAPI | Supports profile-defined IUSE injection?
|
0 | No |
1 | No |
2 | No |
3 | No |
4 | Yes |
The following variables have specific meanings when set in profiles.
In addition, for EAPIs listed in table 5.1 as supporting profile defined IUSE injection, the variables named in USE_EXPAND and USE_EXPAND_UNPREFIXED have special handling as described in section 12.1.1.
Any other variables set in make.defaults must be passed on into the ebuild environment as-is, and are not required to be interpreted by the package manager.
Old-style virtuals are pseudo-packages—they can be depended upon or installed, but do not exist in the ebuild repository. An old-style virtual requires several things in the repository: at least one ebuild must list the virtual in its PROVIDE variable, and there must be at least one entry in a profiles virtuals file listing the default provider for each profile—see sections 8.3 and 5.2.5 for specifics on these two. Old-style virtuals require special handling as regards dependencies; this is described below.
All old-style virtuals must use the category virtual. Not all packages using the virtual category may be assumed to be old style virtuals.
Note: A new-style virtual is simply an ebuild which install no files and use its dependency strings to select providers. By convention, and to ease migration, these are also placed in the virtual category.
When a dependency on a virtual package is encountered, it must be resolved into a real package before it can be satisfied. There are two factors that affect this process: whether a package providing the virtual is installed, and the virtuals file in the active profile (section 5.2.5). If a package is already installed which satisfies the virtual requirement (via PROVIDE), then it should be used to satisfy the dependency. Otherwise, the profiles virtuals file (section 5.2.5) should be consulted to choose an appropriate provider.
Dependencies on old style virtuals must not use any kind of version restriction.
Blocks on provided virtuals have special behaviour documented in section 9.2.4.
The ebuild file format is in its basic form a subset of the format of a bash script. The interpreter is assumed to be GNU bash, version 3.2 or later, see footnote 6 on page 172. The file encoding must be UTF-8 with Unix-style newlines. When sourced, the ebuild must define certain variables and functions (see sections 8 and 10 for specific information), and must not call any external programs, write anything to standard output or standard error, or modify the state of the system in any way.
Note: This section describes variables that may or must be defined by ebuilds. For variables that are passed from the package manager to the ebuild, see section 12.1.
All ebuild-defined variables discussed in this chapter must be defined independently of any system, profile or tree dependent data, and must not vary depending upon the ebuild phase. In particular, ebuild metadata can and will be generated on a different system from that upon which the ebuild will be used, and the ebuild must generate identical metadata every time it is used.
Globally defined ebuild variables without a special meaning must similarly not rely upon variable data.
All ebuilds must define at least the following variables:
IUSE-DEFAULTS
In EAPIs shown in table 8.1 as supporting IUSE defaults, any use flag name in IUSE may be prefixed by at most one of a plus or a minus sign. If such a prefix is present, the package manager may use it as a suggestion as to the default value of the use flag if no other configuration overrides it.
If any of these variables are undefined, or if any of these variables are set to invalid values, the package manager’s behaviour is undefined; ideally, an error in one ebuild should not prevent operations upon other ebuilds or packages.
Ebuilds may define any of the following variables:
PROPERTIES Zero or more properties for this package. See section 9.2.6 for value meanings and section 9 for full syntax. For EAPIs listed in table 8.2 as having optional support, ebuilds must not rely upon the package manager recognising or understanding this variable in any way.
EAPI | Supports PROPERTIES?
|
0 | Optionally |
1 | Optionally |
2 | Optionally |
3 | Optionally |
4 | Yes |
An empty or unset EAPI value is equivalent to 0. Ebuilds must not assume that they will get a particular one of these two values if they are expecting one of these two values.
The package manager must either pre-set the EAPI variable to 0 or ensure that it is unset before sourcing the ebuild for metadata generation. When using the ebuild for other purposes, the package manager must either pre-set EAPI to the value specified by the ebuild’s metadata or ensure that it is unset.
If any of these variables are set to invalid values, the package manager’s behaviour is undefined; ideally, an error in one ebuild should not prevent operations upon other ebuilds or packages.
RDEPEND-DEPEND
In EAPIs listed in table 8.3 as having RDEPEND=DEPEND, if RDEPEND is unset (but not if it is set to an empty string) in an ebuild, the package manager must set its value to be equal to the value of DEPEND.
When dealing with eclasses, only values set in the ebuild itself are considered for this behaviour; any DEPEND or RDEPEND set in an eclass does not change the implicit RDEPEND=DEPEND for the ebuild portion, and any DEPEND value set in an eclass does not get added to RDEPEND.
The following variables must be defined by inherit (see section 11.1, and may be considered to be part of the ebuild’s metadata:
Note: Thus, by extension of section 8.1, inherit may not be used conditionally, except upon constant conditions.
The following are special variables defined by the package manager for internal use and may or may not be exported to the ebuild environment:
DEFINED-PHASES A space separated arbitrarily ordered list of phase names (e.g. configure setup unpack) whose phase functions are defined by the ebuild or an eclass inherited by the ebuild. If no phase functions are defined, a single hyphen is used instead of an empty string. For EAPIs listed in table 8.4 as having optional DEFINED_PHASES support, package managers may not rely upon the metadata cache having this variable defined, and must treat an empty string as “this information is not available”.
Note: Thus, by extension of section 8.1, phase functions must not be defined based upon any variant condition.
EAPI | Supports DEFINED_PHASES?
|
0 | Optionally |
1 | Optionally |
2 | Optionally |
3 | Optionally |
4 | Yes |
There are three classes of dependencies supported by ebuilds:
In addition, SRC_URI, HOMEPAGE, PROVIDE, RESTRICT, PROPERTIES and LICENSE use dependency-style specifications to specify their values.
The following elements are recognised in at least one class of specification. All elements must be surrounded on both sides by whitespace, except at the start and end of the string.
In particular, note that whitespace is not optional.
In an all-of group, all of the child elements must be matched.
In a use-conditional group, if the associated use flag is enabled (or disabled if it has an exclamation mark prefix), all of the child elements must be matched.
It is an error for a flag to be used if it is not included in IUSE_EFFECTIVE as described in section 12.1.1.
Any use-conditional group that is an immediate child of an any-of group, if not enabled (disabled for an exclamation mark prefixed use flag name), is not considered a member of the any-of group for match purposes.
In an any-of group, at least one immediate child element must be matched. A blocker is considered to be matched if its associated package dependency specification is not matched.
An empty any-of group counts as being matched.
A package dependency can be in one of the following base formats. A package manager must warn or error on non-compliant input.
In EAPIs shown in table 9.2 as supporting SLOT dependencies, either of the above formats may additionally be suffixed by a :slot restriction, as described in section 9.2.4. A package manager must warn or error if slot dependencies are used with an EAPI not supporting SLOT dependencies.
USE-DEPS
In EAPIs shown in table 9.3 as supporting 2-style or 4-style USE dependencies, a specification may additionally be suffixed by at most one 2-style or 4-style [use] restriction, as described in section 9.2.4. A package manager must warn or error if this feature is used with an EAPI not supporting use dependencies.
Note: Order is important. The slot restriction must come before use dependencies.
EAPI | Supports SLOT dependencies?
|
0 | No |
1 | Named only |
2 | Named only |
3 | Named only |
4 | Named and operator |
EAPI | Supports USE dependencies?
|
0 | No |
1 | No |
2 | 2-style |
3 | 2-style |
4 | 4-style |
The following operators are available:
If the specification is prefixed with one or two exclamation marks, the named dependency is a block rather than a requirement—that is to say, the specified package must not be installed, with the following exceptions:
BANG-STRENGTH
There are two strengths of block: weak and strong. A weak block may be ignored by the package manager, so long as any blocked package will be uninstalled later on. A strong block must not be ignored. The mapping from one or two exclamation marks to strength is described in table 9.4.
EAPI | ! | !!
|
0 | Unspecified | Forbidden |
1 | Unspecified | Forbidden |
2 | Weak | Strong |
3 | Weak | Strong |
4 | Weak | Strong |
SLOT-DEPS
A named slot dependency consists of a colon followed by a slot name. A specification with a named slot dependency matches only if the slot of the matched package is equal to the slot specified. If the slot of the package to match cannot be determined (e.g. because it is not a supported EAPI), the match is treated as unsuccessful.
SLOT-OPERATOR-DEPS
An operator slot dependency consists of a colon followed by one of the following operators:
To implement the equals slot operator, the package manager will need to store the slot of the best installed version of the matching package. The package manager may do this by appending the appropriate slot after the equals sign when saving the package’s dependencies. This syntax is only for package manager use and must not be used by ebuilds.
A 2-style or 4-style use dependency consists of one of the following:
Multiple requirements may be combined using commas, e.g. [first,-second,third?].
When multiple requirements are specified, all must match for a successful match.
USE-DEP-DEFAULTS
In a 4-style use dependency, the flag name may immediately be followed by a default specified by either (+) or (-). The former indicates that, when applying the use dependency to a package that does not have the flag in question in IUSE_REFERENCEABLE, the package manager shall behave as if the flag were present and enabled; the latter, present and disabled.
Unless a 4-style default is specified, it is an error for a use dependency to be applied to an ebuild which does not have the flag in question in IUSE_REFERENCEABLE.
Note: By extension of the above, a default that could reference an ebuild using an EAPI not supporting profile IUSE injections cannot rely upon any particular behaviour for flags that would not have to be part of IUSE.
It is an error for an ebuild to use a conditional use dependency when that ebuild does not have the flag in IUSE_EFFECTIVE.
The following tokens are permitted inside RESTRICT:
Package managers may recognise other tokens, but ebuilds may not rely upon them being supported.
The following tokens are permitted inside PROPERTIES:
Ebuilds may not rely upon any token being supported.
All filename components that are enabled (i.e. not inside a use-conditional block that is not matched) in SRC_URI must be available in the DISTDIR directory. In addition, these components are used to make the A and AA variables.
If a component contains a full URI with protocol, that download location must be used. Package managers may also consult mirrors for their files.
The special mirror:// protocol must be supported. See section 4.4.2 for mirror details.
If a simple filename rather than a full URI is provided, the package manager can only use mirrors to download the file.
The RESTRICT metadata key can be used to impose additional restrictions upon downloading—see section 9.2.5 for details.
SRC-URI-ARROWS
In EAPIs supporting arrows, if an arrow is used, the filename used when saving to DISTDIR shall instead be the name on the right of the arrow. When consulting mirrors (except for those explicitly listed on the left of the arrow, if mirror:// is used), the filename to the right of the arrow shall be requested instead of the filename in the URI.
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 WORKDIR environment variable; see section 12.1), and the temporary directory 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.
The environment for functions run outside of the build sequence (that is, pkg_config, pkg_info, pkg_prerm and 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.
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 ebuild may assume that the initial working directory for any phase is a trusted location that may only be written to by a privileged user and group.
S-WORKDIR-FALLBACK
Some functions are described as having an initial working directory of S with an error or fallback to WORKDIR. For EAPIs listed in table 10.1 as having the fallback, this means that if S is not a directory before the start of the phase function, the initial working directory shall be WORKDIR instead. For EAPIs where it is a conditional error, if S is not a directory before the start of the phase function, it is a fatal error, unless all of the following conditions are true, in which case the fallback to WORKDIR is used:
EAPI | Fallback to WORKDIR permitted?
|
0 | Always |
1 | Always |
2 | Always |
3 | Always |
4 | Conditional error |
PKG-PRETEND
The pkg_pretend function is only called for EAPIs listed in table 10.2 as supporting it.
The pkg_pretend function may be used to carry out sanity checks early on in the install process. For example, if an ebuild requires a particular kernel configuration, it may perform that check in pkg_pretend and call eerror and then die with appropriate messages if the requirement is not met.
pkg_pretend is run separately from the main phase function sequence, and does not participate in any kind of environment saving. There is no guarantee that any of an ebuild’s dependencies will be met at this stage, and no guarantee that the system state will not have changed substantially before the next phase is executed.
pkg_pretend must not write to the filesystem.
The 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.
pkg_setup must be run with full filesystem permissions, including the ability to add new users and/or groups to the system.
SRC-UNPACK
The src_unpack function extracts all of the package’s sources. In EAPIs lacking src_prepare, it may also apply patches and set up the package’s build system for further use.
The initial working directory must be WORKDIR, and the default implementation used when the ebuild lacks the src_unpack function shall behave as:
SRC-PREPARE
The src_prepare function is only called for EAPIs listed in table 10.3 as supporting it.
The src_prepare function can be used for post-unpack source preparation. The default implementation does nothing.
The initial working directory is S, with an error or fallback to WORKDIR as discussed in section 10.1.1.
SRC-CONFIGURE
The src_configure function is only called for EAPIs listed in table 10.4 as supporting it.
The initial working directory is S, with an error or fallback to WORKDIR as discussed in section 10.1.1.
The src_configure function configures the package’s build environment. The default implementation used when the ebuild lacks the src_configure function shall behave as:
SRC-COMPILE
The src_compile function configures the package’s build environment in EAPIs lacking src_configure, and builds the package in all EAPIs.
The initial working directory is S, with an error or fallback to WORKDIR as discussed in section 10.1.1.
SRC-COMPILE-0
For EAPIs listed in table 10.5 as using format 0, the default implementation used when the ebuild lacks the src_compile function shall behave as:
SRC-COMPILE-1
For EAPIs listed in table 10.5 as using format 1, the default implementation used when the ebuild lacks the src_compile function shall behave as:
SRC-COMPILE-2
For EAPIs listed in table 10.5 as using format 2, the default implementation used when the ebuild lacks the src_compile function shall behave as:
The src_test function runs unit tests for the newly built but not yet installed package as provided.
The initial working directory must be S if that exists, falling back to WORKDIR otherwise. The default implementation used when the ebuild lacks the src_test function must, if tests are enabled, run make check if and only if such a target is available, or if not run make test, if and only such a target is available. In both cases, if make returns non-zero the build must be aborted.
The src_test function may be disabled by RESTRICT. See section 9.2.5.
SRC-INSTALL
The src_install function installs the package’s content to a directory specified in D.
The initial working directory is S, with an error or fallback to WORKDIR as discussed in section 10.1.1.
SRC-INSTALL-4
For EAPIs listed in table 10.6 as using format 4, the default implementation used when the ebuild lacks the src_install function shall behave as:
For other EAPIs, the default implementation used when the ebuild lacks the src_install function is a no-op.
The 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 ROOT and D environment variables.
pkg_preinst must be run with full access to all files and directories below that specified by the ROOT and D environment variables.
The 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 ROOT environment variable.
pkg_postinst, like, pkg_preinst, must be run with full access to all files and directories below that specified by the ROOT environment variable.
The 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 ROOT environment variable.
pkg_prerm must be run with full access to all files and directories below that specified by the ROOT environment variable.
The 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 ROOT environment variable.
pkg_postrm must be run with full access to all files and directories below that specified by the ROOT environment variable.
The 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.
pkg_config must be run with full access to all files and directories inside of ROOT.
PKG-INFO
The pkg_info function may be called by the package manager when displaying information about an installed package. In EAPIs listed in table 10.7 as supporting pkg_info on non-installed packages, it may also be called by the package manager when displaying information about a non-installed package. In this case, ebuild authors should note that dependencies may not be installed.
pkg_info must not write to the filesystem.
EAPI | Supports pkg_info on non-installed packages?
|
0 | No |
1 | No |
2 | No |
3 | No |
4 | Yes |
The 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.
pkg_nofetch must require no write access to any part of the filesystem.
DEFAULT-PHASE-FUNCS
In EAPIs listed in table 10.8 as supporting default_ phase functions, a function named default_(phase) that behaves as the default implementation for that EAPI shall be defined when executing any ebuild phase listed in the table. Ebuilds must not call these functions except when in the phase in question.
EAPI | Supports default_ functions in phases
|
0 | None |
1 | None |
2 | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_test |
3 | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_test |
4 | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_install, src_test |
The call order for installing a package is:
The call order for uninstalling a package is:
The call order for reinstalling a package is:
The call order for upgrading or downgrading a package is:
The pkg_config, pkg_info and pkg_nofetch functions are not called in a normal sequence. The pkg_pretend function is called some unspecified time before a (possibly hypothetical) normal sequence.
For installing binary packages, the src phases are not called.
When building binary packages that are not to be installed locally, the pkg_preinst and pkg_postinst functions are not called.
Eclasses serve to store common code that is used by more than one ebuild, which greatly aids maintainability and reduces the tree size. However, due to metadata cache issues, care must be taken in their use. In format they are similar to an ebuild, and indeed are sourced as part of any ebuild using them. The interpreter is therefore the same, and the same requirements for being parseable hold.
Eclasses must be located in the eclass directory in the top level of the repository—see section 4.6. Each eclass is a single file named <name>.eclass, where <name> is the name of this eclass, used by inherit and EXPORT_FUNCTIONS among other places.
An ebuild wishing to make use of an eclass does so by using the inherit command in global scope. This will cause the eclass to be sourced as part of the ebuild—any function or variable definitions in the eclass will appear as part of the ebuild, with exceptions for certain metadata variables, as described below.
The inherit command takes one or more parameters, which must be the names of eclasses (excluding the .eclass suffix and the path). For each parameter, in order, the named eclass is sourced.
Eclasses may end up being sourced multiple times.
The inherit command must also ensure that:
The IUSE, DEPEND, RDEPEND and PDEPEND variables are handled specially when set by an eclass. They must be accumulated across eclasses, appending the value set by each eclass to the resulting value after the previous one is loaded. Then the eclass-defined value is appended to that defined by the ebuild. In the case of RDEPEND, this is done after the implicit RDEPEND rules in section 8.3.2 are applied.
There is one command available in the eclass environment that is neither available nor meaningful in ebuilds—EXPORT_FUNCTIONS. This can be used to alias ebuild phase functions from the eclass so that an ebuild inherits a default definition whilst retaining the ability to override and call the eclass-defined version from it. The use of it is best illustrated by an example; this is given in listing 11.1 and is a snippet from a hypothetical foo.eclass.
This example defines an eclass src_compile function and uses EXPORT_FUNCTIONS to alias it. Then any ebuild that inherits foo.eclass will have a default src_compile defined, but should the author wish to override it he can access the function in foo.eclass by calling foo_src_compile.
EXPORT_FUNCTIONS must only be used on ebuild phase functions. The function that is aliased must be named eclassname_phasefunctionname, where eclassname is the name of the eclass.
EXPORT_FUNCTIONS must be used at most once per eclass.
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 12.2). For example, EBUILD_PHASE is different for every phase, and ROOT may have changed between the various different pkg_* phases. Ebuilds must recalculate any variable they derive from an inconsistent variable.
Table 12.1: Defined variables | |||
Variable | Legal in | Consistent? | Description
|
P |
all | No1 |
Package name and version, without the revision part. For example, vim-7.0.174. |
PN |
all | ditto |
Package name, for example vim. |
CATEGORY |
all | ditto |
The package’s category, for example app-editors. |
PV |
all | Yes |
Package version, with no revision. For example 7.0.174. |
PR |
all | Yes |
Package revision, or r0 if none exists. |
PVR |
all | Yes |
Package version and revision (if any), for example 7.0.174 or 7.0.174-r1. |
PF |
all | Yes |
Package name, version, and revision (if any), for example vim-7.0.174-r1. |
A |
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 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 SRC_URI ebuild metadata variable. |
AA2 |
src_* | Yes | AA All source files that could be available for the package, including any that are disabled in A because of USE conditionals. The value is calculated from the base names of each element of the SRC_URI ebuild metadata variable. Only for EAPIs listed in table 12.2 as supporting AA. |
FILESDIR |
src_*3 | No |
The full path to the package’s files directory, used for small support files or patches. See section 4.3. 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 FILESDIR points to a non-existent directory. |
PORTDIR |
ditto | No |
The full path to the master repository’s base directory. |
DISTDIR |
ditto | No |
The full path to the directory in which the files in the A variable are stored. |
ECLASSDIR |
ditto | No |
The full path to the master repository’s eclass directory. |
ROOT |
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 ROOT. Also of note is that in a cross-compiling environment, binaries inside of ROOT will not be executable on the build machine, so ebuilds must not call them. ROOT must be non-empty and end in a trailing slash. |
EROOT |
pkg_* | No |
Like ROOT, but with EPREFIX appended. This is a convenience variable. See also the EPREFIX variable. |
T |
All | Partially4 |
The full path to a temporary directory for use by the ebuild. |
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 above. |
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. |
EPREFIX |
All | Yes |
The normalised offset-prefix path of an offset installation. When EPREFIX is not set in the calling environment, EPREFIX defaults to the built-in offset-prefix that was set during installation of the package manager. When a different 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 EPREFIX, akin to ROOT. See also 12.1.3. |
D |
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. |
D (continued) |
pkg_preinst, 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. |
ED |
src_install | See D |
Like D, but with EPREFIX appended. This is a convenience variable. See also the EPREFIX variable. |
IMAGE5 |
pkg_preinst, pkg_postinst | Yes |
Equal to D. |
INSDESTTREE |
src_install | No |
Controls the location where doins installs things. |
USE |
All | Yes |
A whitespace-delimited list of all active USE flags for this ebuild. See section 12.1.1 for details. |
EBUILD_PHASE |
All | No |
Takes one of the values config, setup, nofetch, unpack, prepare, configure, compile, test, install, preinst, postinst, prerm, postrm, info, 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. |
WORKDIR |
src_* | Yes |
The full path to the ebuild’s working directory, in which all build data should be contained. |
KV |
All | Yes | KV The version of the running kernel at the time the ebuild was first executed, as returned by the uname -r command or equivalent. May be modified by ebuilds. Only for EAPIs listed in table 12.2 as supporting KV. |
REPLACING_VERSIONS |
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 12.1.2. Only for EAPIs listed in table 12.2 as supporting REPLACING_VERSIONS. |
REPLACED_BY_VERSION |
pkg_prerm, 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 12.1.2. Only for EAPIs listed in table 12.2 as supporting REPLACED_BY_VERSION. |
EAPI | AA? | KV? | REPLACING_VERSIONS? | REPLACED_BY_VERSION?
|
0 | Yes | Yes | No | No |
1 | Yes | Yes | No | No |
2 | Yes | Yes | No | No |
3 | Yes | Yes | No | No |
4 | No | No | Yes | Yes |
EAPI | EPREFIX? | EROOT? | ED?
|
0 | No | No | No |
1 | No | No | No |
2 | No | No | No |
3 | Yes | Yes | Yes |
4 | Yes | Yes | Yes |
Except where otherwise noted, all variables set in the active profiles’ make.defaults files must be exported to the ebuild environment. CHOST, CBUILD and 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.
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.
GZIP, BZIP, BZIP2, CDPATH, GREP_OPTIONS, GREP_COLOR and GLOBIGNORE must not be set.
This section discusses the handling of four variables:
In all cases, the values of IUSE_REFERENCEABLE and IUSE_EFFECTIVE are undefined during metadata generation.
For EAPIs listed in table 5.1 as not supporting profile defined IUSE injection, IUSE_REFERENCEABLE is equal to the calculated IUSE value. For EAPIs where profile defined IUSE injection is supported, IUSE_REFERENCEABLE is equal to IUSE_EFFECTIVE.
For EAPIs listed in table 5.1 as not supporting profile defined IUSE injection, IUSE_EFFECTIVE contains the following values:
PROFILE-IUSE-INJECTION
For EAPIs listed in table 5.1 as supporting profile defined IUSE injection, IUSE_EFFECTIVE contains the following values:
The USE variable is set by the package manager. For each value in IUSE_EFFECTIVE, 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. In EAPIs listed in table 5.1 as not supporting profile defined IUSE injection, USE may contain other flag names that are not relevant for the ebuild.
For EAPIs listed in table 5.1 as supporting profile defined IUSE injection, the variables named in USE_EXPAND and USE_EXPAND_UNPREFIXED shall have their profile-provided values reduced to contain only those values that are present in IUSE_EFFECTIVE.
For EAPIs listed in table 5.1 as supporting profile defined IUSE injection, the package manager must save the calculated value of IUSE_EFFECTIVE when installing a package. Details are beyond the scope of this specification.
REPLACE-VERSION-VARS
In EAPIs listed in table 12.2 as supporting it, the REPLACING_VERSIONS variable shall be defined in pkg_preinst and pkg_postinst. In addition, it may be defined in pkg_pretend and pkg_setup, although ebuild authors should take care to handle binary package creation and installation correctly when using it in these phases.
REPLACING_VERSIONS is a list, not a single optional value, to handle pathological cases such as installing foo-2:2 to replace foo-2:1 and foo-3:2.
In EAPIs listed in table 12.2 as supporting it, the REPLACED_BY variable shall be defined in pkg_prerm and pkg_postrm. It shall contain at most one value.
OFFSET-PREFIX-VARS
Table 12.4 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, EROOT and ED, are convenience variables using the variable EPREFIX. In EAPIs that do not support an offset-prefix, the installation offset is hardwired to /usr. In offset-prefix supporting EAPIs the installation offset is set as ${EPREFIX}/usr and hence can be adjusted using the variable EPREFIX. Note that the behaviour of offset-prefix aware and agnostic is the same when EPREFIX is set to the empty string in offset-prefix aware EAPIs. The latter do have the variables ED and EROOT properly set, though.
Exported and default scope variables are saved between functions. A non-local variable set in a function earlier in the call sequence must have its value preserved for later functions, including functions executed as part of a later uninstall.
Note: pkg_pretend is not part of the normal call sequence, and does not take part in environment saving.
Variables that were exported must remain exported in later functions; variables with default visibility may retain default visibility or be exported.
Variables with special meanings to the package manager are excluded from this rule.
Global variables must only contain invariant values (see 8.1). If a global variable’s value is invariant, it may have the value that would be generated at any given point in the build sequence.
This is demonstrated by code listing 12.1.
This section documents the commands available to an ebuild. Unless otherwise specified, they may be aliases, shell functions, or executables in the ebuild’s PATH.
When an ebuild is being sourced for metadata querying rather than for a build (that is to say, when none of the src_ or pkg_ functions are to be called), no external command may be executed. The package manager may take steps to enforce this.
Any ebuild not listed in the system set for the active profile(s) may assume the presence of every command that is always provided by the system set for that profile. However, it must target the lowest common denominator of all systems on which it might be installed—in most cases this means that the only packages that can be assumed to be present are those listed in the base profile or equivalent, which is inherited by all available profiles. If an ebuild requires any applications not provided by the system profile, or that are provided conditionally based on USE flags, appropriate dependencies must be used to ensure their presence.
The following commands must always be available in the ebuild environment:
In some cases a package’s build process will require the availability of executables not provided by the core system, a common example being autotools. Commands provided by dependencies are available in the following cases:
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 PATH; where this is not specified, ebuilds may not rely upon either behaviour.
DIE-ON-FAILURE
Where a command is listed as having EAPI dependent failure behaviour, a failure shall either result in a non-zero exit status or abort the build process, as determined by table 12.5.
The following commands affect this behaviour:
NONFATAL Executes the remainder of its arguments as a command, preserving the exit status. If this results in a command being called that would normally abort the build process due to a failure (but not due to an explicit die or assert call), instead a non-zero exit status shall be returned. Only in EAPIs listed in table 12.5 as supporting nonfatal.
EAPI | Command failure behaviour | Supports nonfatal?
|
0 | Non-zero exit | No |
1 | Non-zero exit | No |
2 | Non-zero exit | No |
3 | Non-zero exit | No |
4 | Aborts | Yes |
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.
EAPI | Command banned? | ||
dohard | dosed
| ||
0 | No | No | |
1 | No | No | |
2 | No | No | |
3 | No | No | |
4 | Yes | Yes | |
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.
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.
These commands display messages to the user. Unless otherwise stated, the entire argument list is used as a message, with backslash-escaped characters interpreted as for the echo -e command of bash, notably \t for a horizontal tab, \n for a new line, and \\ for a literal backslash. 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.
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.
These commands are used during the src_compile and 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.
ECONF-OPTIONS
EAPI | --disable-dependency-tracking?
|
0 | No |
1 | No |
2 | No |
3 | No |
4 | Yes |
Note that the ${EPREFIX} component represents the same offset-prefix as described in Table 12.1. It facilitates offset-prefix installations which is supported by EAPIs listed in Table ??. When no offset-prefix installation is in effect, EPREFIX becomes the empty string, making the behaviour of econf equal for both offset-prefix supporting and agnostic EAPIs.
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 die, unless run using nonfatal, in which case it must return non-zero exit status.
The variable ED is defined as in Table 12.1 and depends on the use of an offset-prefix. When such offset-prefix is absent, ED is equivalent to D. ED is always available in EAPIs that support offset-prefix installations as listed in Table 12.3, hence EAPIs lacking offset-prefix support should use D instead of ED in the command given in Listing 12.2.
These commands are used to install files into the staging area, in cases where the package’s 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 including the offset-prefix ED in offset-prefix aware EAPIs, or just the staging directory D in offset-prefix agnostic EAPIs. These commands must all be external programs and not bash functions or aliases—that is, they must be callable from xargs. Ebuilds must not run any of these commands once the current phase function has returned.
DODOC Installs the given files into a subdirectory under /usr/share/doc/${PF}/ with file mode 0644. The subdirectory is set by the most recent call to docinto. If docinto has not yet been called, instead installs to the directory /usr/share/doc/${PF}/. For EAPIs listed in table 12.8 as supporting -r, if the first argument is -r, any subsequent arguments that are directories are installed recursively to the appropriate location; in any other case, it is an error for a directory to be specified. Failure behaviour is EAPI dependent as per section 12.3.3.
Failure behaviour is EAPI dependent as per section 12.3.3.
It is undefined whether a failure shall occur if -r is not specified and a directory is encountered. Ebuilds must not rely upon any particular behaviour.
DOINS Takes any number of files as arguments and installs them into INSDESTTREE, by default with file mode 0644. This can be overridden by setting INSOPTIONS with the insopts function. If the first argument is -r, then operates recursively, descending into any directories given. For EAPIs listed in table 12.9, doins must install symlinks as symlinks; for other EAPIs, behaviour is undefined if any symlink is encountered. Failure behaviour is EAPI dependent as per section 12.3.3.
DOMAN-LANGS
In EAPIs listed in table 12.10 as supporting language codes, a man page with name of the formfoo.lang.1 shall go to /usr/share/man/lang/man1/foo.1, where lang refers to a pair of lower-case ASCII letters optionally followed by an underscore and a pair of upper-case ASCII letters. Failure behaviour is EAPI dependent as per section 12.3.3.
EAPI | doins supports symlinks?
|
0 | No |
1 | No |
2 | No |
3 | No |
4 | Yes |
EAPI | Supports doman languages?
|
0 | No |
1 | No |
2 | Yes |
3 | Yes |
4 | Yes |
The following commands are used to set the various destination trees, all relative to ${ED} in offset-prefix aware EAPIs and relative to ${D} in offset-prefix agnostic EAPIs, 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.
CONTROLLABLE-COMPRESS
In EAPIs listed in table 12.11 as supporting controllable compression, the package manager may optionally compress a subset of the files under the ED directory in offset-prefix aware EAPIs or the D directory in offset-prefix agnostic EAPIs. To control which directories may or may not be compressed, the package manager shall maintain two lists:
The optional compression shall be carried out after src_install has completed, and before the execution of any subsequent phase function. For each item in the inclusion list, pretend it has the value of the ED variable in offset-prefix aware EAPIs or the D variable in offset-prefix agnostic EAPIs prepended, then:
Whether an item is to be excluded is determined as follows: For each item in the exclusion list, pretend it has the value of the ED variable in offset-prefix aware EAPIs or the D variable in offset-prefix agnostic EAPIs prepended, then:
The package manager shall take appropriate steps to ensure that its compression mechanisms behave sensibly even if an item is listed in the inclusion list multiple times, if an item is a symlink, or if a file is already compressed.
The following commands may be used in src_install to alter these lists. It is an error to call any of these functions from any other phase.
EAPI | Supports controllable compression? | Supports docompress?
|
0 | No | No |
1 | No | No |
2 | No | No |
3 | No | No |
4 | Yes | Yes |
These functions provide behaviour based upon set or unset use flags. Ebuilds must not run any of these commands once the current phase function has returned. Ebuilds must not run any of these functions in global scope.
If any of these functions is called with a flag value that is not included in IUSE_EFFECTIVE, either behaviour is undefined or it is an error as decided by table 12.12.
EAPI | Behaviour
|
0 | Undefined |
1 | Undefined |
2 | Undefined |
3 | Undefined |
4 | Error |
These functions check whitespace-separated lists for a particular value.
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.
All arguments to unpack must be either a filename without path, in which case unpack looks in DISTDIR for the file, or start with the string ./, in which case unpack uses the argument as a path relative to the working directory.
Any unrecognised file format shall be skipped silently. If unpacking a supported file format fails, unpack shall abort the build process.
UNPACK-EXTENSIONS
Must be able to unpack the following file formats, if the relevant binaries are available:
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.
DEFAULT-FUNC Calls the default_ function for the current phase (see section 10.1.17). Must not be called if the default_ function does not exist for the current phase in the current EAPI. Only available in EAPIs listed in table 12.14.
EAPI | Supports default function?
|
0 | No |
1 | No |
2 | Yes |
3 | Yes |
4 | Yes |
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.
Except where documented otherwise, all functions and variables that contain any of the following strings (ignoring case) are reserved for package manager use and may not be used or relied upon by ebuilds:
For the sake of this section:
The following exclusivity and invariancy requirements are mandated:
Note: In this chapter, file and regular file have their Unix meanings.
The merge process merges the contents of the D directory onto the filesystem under ROOT. This is not a straight copy; there are various subtleties which must be addressed.
The unmerge process removes an installed package’s files. It is not covered in detail in this specification.
Directories are merged recursively onto the filesystem. The method used to perform the merge is not specified, so long as the end result is correct. In particular, merging a directory may alter or remove the source directory under D.
Ebuilds must not attempt to merge a directory on top of any existing file that is not either a directory or a symlink to a directory.
The owner, group and mode (including set*id and sticky bits) of the directory must be preserved, except as follows:
On SELinux systems, the SELinux context must also be preserved. Other directory attributes, including modification time, may be discarded.
Behaviour upon encountering an empty directory is undefined. Ebuilds must not attempt to install an empty directory.
Regular files are merged onto the filesystem (but see the notes on configuration file protection, below). The method used to perform the merge is not specified, so long as the end result is correct. In particular, merging a regular file may alter or remove the source file under D.
Ebuilds must not attempt to merge a regular file on top of any existing file that is not either a regular file or a symlink to a regular file.
The owner, group and mode (including set*id and sticky bits) of the file must be preserved, except as follows:
On SELinux systems, the SELinux context must also be preserved. Other file attributes may be discarded.
MTIME-PRESERVE
In EAPIs listed in table 13.1, the package manager must preserve modification times of regular files. This includes files being compressed before merging. Exceptions to this are files newly created by the package manager and binary object files being stripped of symbols.
When preserving, the seconds part of every regular file’s mtime must be preserved exactly. The sub-second part must either be set to zero, or set to the greatest value supported by the operating system and filesystem that is not greater than the sub-second part of the original time.
For any given destination filesystem, the package manager must ensure that for any two preserved files a, b in that filesystem the relation mtime(a) ≤ mtime(b) still holds, if it held under the original image directory.
In other EAPIs, the behaviour with respect to file modification times is undefined.
EAPI | mtimes preserved?
|
0 | Undefined |
1 | Undefined |
2 | Undefined |
3 | Yes |
4 | Yes |
The package manager must provide a means to prevent user configuration files from being overwritten by any package updates. The profile variables CONFIG_PROTECT and CONFIG_PROTECT_MASK (section 5.3) control the paths for which this must be enforced.
In order to ensure interoperability with configuration update tools, the following scheme must be used by all package managers when merging any regular file:
Symlinks are merged as symlinks onto the filesystem. The link destination for a merged link shall be the same as the link destination for the link under D, except as noted below. The method used to perform the merge is not specified, so long as the end result is correct; in particular, merging a symlink may alter or remove the symlink under D.
Ebuilds must not attempt to merge a symlink on top of a directory.
Any absolute symlink whose link starts with D must be rewritten with the leading D removed. The package manager should issue a notice when doing this.
A hard link may be merged either as a single file with links or as multiple independent files.
Ebuilds must not attempt to install any other type of file (FIFOs, device nodes etc).
The profiles/metadata/cache directory, if it exists, contains directories whose names are the same as categories in the repository. Each subdirectory may optionally contain one file per package version in that category, named <package>-<version>, in the format described below.
The metadata cache may be incomplete or non-existent, and may contain additional bogus entries.
Each cache file contains the textual values of various metadata keys, one per line, in the following order. Other lines may be present following these; their meanings are not defined here.
Future EAPIs may define new variables, remove existing variables, change the line number or format used for a particular variable, add or reduce the total length of the file and so on. Any future EAPI that uses this cache format will continue to place the EAPI value on line 15 if such a concept makes sense for that EAPI, and will place a value that is clearly not a supported EAPI on line 15 if it does not.
This section contains explanations of some of the terms used in this document whose meaning may not be immediately obvious.
The metadata.xml file is used to contain extra package- or category-level information beyond what is stored in ebuild metadata. Its exact format is strictly beyond the scope of this document, and is described in the DTD file located at http://www.gentoo.org/dtd/metadata.dtd.
The following items are not specified by this document, and must not be relied upon by ebuilds. This is, of course, an incomplete list—it covers only the things that the authors know have been abused in the past.
The items described in this chapter are included for information only. They were deprecated or abandoned long before EAPI was introduced. Ebuilds must not use these features, and package managers should not be changed to support them.
Historically, Portage supported if-else use conditionals, as shown by listing C.1. The block before the colon would be taken if the condition was met, and the block after the colon would be taken if the condition was not met.
This feature was deprecated and removed from the tree long before the introduction of EAPI.
Portage has very crude support for CVS packages. The package foo could contain a file named foo-cvs.1.2.3.ebuild. This version would order higher than any non-CVS version (including foo-2.ebuild). This feature has not seen real world use and breaks versioned dependencies, so it must not be used.
The use.defaults file in the profile directory was used to implement ‘autouse’—switching USE flags on or off depending upon which packages are installed. It was deprecated long ago and finally removed in 2009.
Note: This chapter is informative and for convenience only. Refer to the main text for specifics.
Feature | Reference | EAPIs | ||||
0 | 1 | 2 | 3 | 4
| ||
Profile IUSE injection | profile-iuse-injection p165 | No | No | No | No | Yes |
IUSE defaults | iuse-defaults p74 | No | Yes | Yes | Yes | Yes |
PROPERTIES | properties p78 | Optionally | Optionally | Optionally | Optionally | Yes |
RDEPEND=DEPEND | rdepend-depend p81 | Yes | Yes | Yes | Yes | No |
DEFINED_PHASES | defined-phases p84 | Optionally | Optionally | Optionally | Optionally | Yes |
SRC_URI arrows | src-uri-arrows p106 | No | No | Yes | Yes | Yes |
Slot dependencies | slot-deps p104 | No | Named | Named | Named | Named and Operator |
Use dependencies | use-deps p95 | No | No | 2-style | 2-style | 4-style |
! blockers | bang-strength p101 | Unspecified | Unspecified | Weak | Weak | Weak |
!! blockers | bang-strength p101 | Forbidden | Forbidden | Strong | Strong | Strong |
S to WORKDIR fallback | s-workdir-fallback p109 | Always | Always | Always | Always | Conditional |
pkg_pretend | pkg-pretend p112 | No | No | No | No | Yes |
src_prepare | src-prepare p116 | No | No | Yes | Yes | Yes |
src_configure | src-configure p119 | No | No | Yes | Yes | Yes |
src_compile style | src-compile p123 | 0 | 1 | 2 | 2 | 2 |
src_install style | src-install p129 | no-op | no-op | no-op | no-op | 4 |
pkg_info | pkg-info p134 | Installed | Installed | Installed | Installed | Both |
default_ phase functions | default-phase-funcs p137 | None | None | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_test | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_test | pkg_nofetch, src_unpack, src_prepare, src_configure, src_compile, src_install, src_test |
AA | aa p154 | Yes | Yes | Yes | Yes | No |
KV | kv p157 | Yes | Yes | Yes | Yes | No |
REPLACING_VERSIONS | replace-version-vars p166 | No | No | No | No | Yes |
REPLACED_BY_VERSION | replace-version-vars p166 | No | No | No | No | Yes |
EPREFIX, ED, EROOT | offset-prefix-vars p169 | No | No | No | Yes | Yes |
Most utilities die | die-on-failure p173 | No | No | No | No | Yes |
nonfatal | nonfatal p173 | No | No | No | No | Yes |
dohard | banned-commands p176 | Yes | Yes | Yes | Yes | Banned |
dosed | banned-commands p176 | Yes | Yes | Yes | Yes | Banned |
econf arguments | econf-options p180 | disable dependency tracking | ||||
dodoc -r | dodoc p183 | No | No | No | No | Yes |
doins handles symlinks | doins p184 | No | No | No | No | Yes |
doman languages | doman-langs p185 | No | No | Yes | Yes | Yes |
Controllable compression | controllable-compress p195 | No | No | No | No | Yes |
docompress | controllable-compress p195 | No | No | No | No | Yes |
unpack support for xz? | unpack-extensions p202 | No | No | No | Yes | Yes |
default function | default-func p204 | No | No | Yes | Yes | Yes |
File mtimes preserved | mtime-preserve p212 | Undefined | Undefined | Undefined | Yes | Yes |
Note: This chapter is informative and for convenience only. Refer to the main text for specifics.
EAPI 0 is the base EAPI.
EAPI 1 is EAPI 0 with the following changes:
EAPI 2 is EAPI 1 with the following changes:
EAPI 3 is EAPI 2 with the following changes:
EAPI 4 is EAPI 3 with the following changes:
[1] Marius Mauch. GLEP 44: Manifest2 format. http://glep.gentoo.org/glep-0044.html, December 2005.