EAPI usage and description
The Package Manager Specification is a standardization effort to ensure that the ebuild file format, the ebuild repository format (of which the Gentoo repository is Gentoo's main incarnation) as well as behaviour of the package managers interacting with these ebuilds is properly written down and agreed upon.
EAPI is a version defined in ebuilds and other package manager related files which informs the package manager about the file syntax and content. It is, in effect, the version of the Package Manager Specification that the file adheres to.
This section provides usage and descriptions of the different EAPIs.
Usage of EAPIs
app-doc/pms in the main tree.
You must set the EAPI variable by specifying it at the top of the ebuild:
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
When writing new ebuilds developers can choose whatever EAPI they think is the best. Using the features of the latest EAPI is encouraged.
Upgrade path
Gentoo policy is to support upgrades for installations at least a year old
with no/little intervention and up to two years old with minor intervention.
To achieve this, developers must avoid using the latest EAPI in ebuilds within
the @system set
(see Implicit system dependency)
or its dependencies.
The Base System project has rules governing their use of newer EAPIs, as does the Python project.
It is also convention that blockers within ebuilds are retained for at least
2 years after the last ebuild matching the block is removed from the tree to
avoid file collisions for users upgrading older systems. pkgcheck has
a warning for this called OutdatedBlocker (or even
NonexistentBlocker for when the match is from pre-git times if using
a non-grafted repository).
EAPIs 0 to 4
EAPIs 0 to 4 are obsolete and must no longer be used. Refer to the Package Manager Specification for details about them.
EAPI 5
EAPI 5 metadata
- REQUIRED_USE supports new at-most-one-of operator
-
The new at-most-one-of operator consists of the string
??, and is satisfied if zero or one (but no more) of its child elements is matched. - SLOT supports optional "sub-slot" part
-
The
SLOTvariable may contain an optional sub-slot part that follows the regular slot and is delimited by a/character. The sub-slot must be a valid slot name. The sub-slot is used to represent cases in which an upgrade to a new version of a package with a different sub-slot may require dependent packages to be rebuilt. When the sub-slot part is omitted from the SLOT definition, the package is considered to have an implicit sub-slot which is equal to the regular slot. - Slot operators and sub-slots in dependencies
-
A slot dependency may contain an optional sub-slot part that follows the regular slot and is delimited by a
/character. This can be useful for packages installing pre-built binaries that require a library with a specific soname version which corresponds to the sub-slot. For example:RDEPEND="dev-libs/foo:0/3"Package dependency specifications can use slot operators to clarify what should happen if the slot and/or sub-slot of a runtime dependency changes:
-
:*Indicates that any slot value is acceptable. In addition, for runtime dependencies, indicates that the package specifying the dependency will not break if the package matching the dependency is replaced by a different matching package with a different slot and/or sub-slot. -
:=Indicates that any slot value is acceptable. In addition, for runtime dependencies, indicates that the package specifying the dependency will break unless there is available a package matching the dependency and whose slot and sub-slot are equal to the slot and sub-slot of the best installed version that had matched this dependency at the time when the package specifying this dependency had been installed. -
:slot=Indicates that only a specific slot value is acceptable, and otherwise behaves identically to the:=operator.Note: use:slot/subslotwithout a=to depend on a specific slot and sub-slot pair; it's a syntax error to use:slot/subslot=in an ebuild.
The
:slotdependency syntax continues to behave like in EAPI=4 or earlier, i.e. it indicates that only the specific slot value is acceptable, but the package will not break when the version matching the runtime dependency is replaced by a version with a different sub-slot.For example:
RDEPEND="dev-libs/foo:2= >=dev-libs/bar-0.9:= media-gfx/baz:* x11-misc/wombat:0"means that the package should be rebuilt when
foo:2or>=bar-0.9are upgraded to versions with different subslots, but that changes in subslots ofbazorwombat:0should be ignored. -
EAPI 5 profiles
- Profile stable USE forcing and masking
-
In profile directories with an EAPI supporting stable masking, new USE
configuration files are supported:
use.stable.mask,use.stable.force,package.use.stable.maskandpackage.use.stable.force. These files behave similarly to previously supported USE configuration files, except that they only influence packages that are merged due to a stable keyword.
EAPI 5 helpers
- econf adds --disable-silent-rules
-
This option will automatically be passed if
--disable-silent-rulesoccurs in the output ofconfigure --help. - new* commands can read from standard input
-
Standard input is read when the first parameter is
-(a hyphen). - New option --host-root for {has,best}_version
-
This option
--host-rootwill cause the query to apply to the host root instead of ROOT. - New doheader helper function
-
Installs the given header files into
/usr/include/. If option-ris specified, descends recursively into any directories given. - New usex helper function
-
USAGE: usex <USE flag> [true output] [false output] [true suffix] [false suffix] DESCRIPTION: If USE flag is set, echo [true output][true suffix] (defaults to "yes"), otherwise echo [false output][false suffix] (defaults to "no").
EAPI 6
EAPI 6 ebuild environment
- Locale settings
-
Behaviour of case modification and collation order (
LC_CTYPEandLC_COLLATE) are guaranteed to be the same as in the C locale, as far as characters in the ASCII range are concerned. -
failglobenabled -
For
EAPI=6, thefailgloboption of bash is set in the global scope of ebuilds. If set, failed pattern matches during filename expansion result in an error when the ebuild is being sourced.
EAPI 6 phases
- Update default implementation of
src_prepare -
This phase is no longer a no-op, it supports applying patches via the
PATCHESvariable and applying user patches viaeapply_user. The defaultsrc_preparelooks like this:src_prepare() { if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}" else [[ -n ${PATCHES} ]] && eapply ${PATCHES} fi eapply_user } - New
src_installPhase Function -
This phase uses the new
einstalldocsfunction for installation of documentation. The defaultsrc_installlooks like this:src_install() { if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]]; then emake DESTDIR="${D}" install fi einstalldocs }
EAPI 6 helpers
-
einstallbanned -
The
einstallhelper has been banned withEAPI=6. -
dohtmldeprecated -
The
dohtmlhelper has been deprecated withEAPI=6. nonfatal die-
When
dieorassertare called under thenonfatalcommand and with the-noption, they will not abort the build process but return with an error. -
eapplysupport -
The
eapplycommand is a simplified substitute forepatch(fromeutils.eclass), implemented in the package manager. The patches from its file or directory arguments are applied using patch-p1, but it acceptspatch(1)options from GNU patch to override default behavior. -
eapply_usersupport -
The
eapply_usercommand permits the package manager to apply user-provided patches. It must be called from everysrc_preparefunction.Note:eapply_userdoesn't need to be called explicitly when defaultsrc_prepareis called. -
econfadds--docdirand--htmldir -
Options
--docdirand--htmldirare passed toconfigure, in addition to the existing options. -
in_iusesupport -
The
in_iusefunction returnstrueif the given parameter is available in the ebuildsUSE. -
unpackchanges -
-
unpacksupports relative paths without leading./(unpack foo/bar.tar.gzis valid as relative path). -
unpacksupports.txz(xz compressed tarball). -
unpackmatches filename extensions case-insensitively.
-
-
einstalldocssupport -
The
einstalldocsfunction will install the files specified by theDOCSvariable (or a default set of files ifDOCSis unset) and by theHTML_DOCSvariable. -
get_libdirsupport -
The
get_libdircommand outputs thelib*directory basename suitable for the current ABI.
EAPI 7
EAPI 7 terminology
Documents may use the following terms to better describe dependency and installation targets.
CHOST- The system that will be running the installed package.
CBUILD- The system used to build packages. When not cross-compiling, CBUILD == CHOST.
CTARGET- Used in certain cross-compilations, often empty value.
EAPI 7 variables
-
PORTDIRandECLASSDIRare removed -
PORTDIRandECLASSDIRare no longer defined and cannot be used in ebuilds to access these directories. -
DESTTREEandINSDESTTREEare removed -
The unintended exported variables
PORTDIRandECLASSDIRcannot be used in ebuilds to manipulate installation paths. Useintoorinsinto, respectively, instead. -
D,ED,ROOT, andEROOTmodified -
These variables no longer contain a trailing slash with
EAPI=7. -
BDEPENDadded -
Previously, all build-time tools and libraries went into the
DEPEND. Now, built-time dependencies are split intoDEPENDandBDEPEND. The difference is simply thatBDEPENDare dependencies to be executed on the CBUILD.DEPENDremains for other dependencies, such as libraries, for the CHOST. This improves the cross-compilation support. -
BROOTadded -
BROOTis the absolute path to the root directory, including any prefix, containing build dependencies satisfied by BDEPEND, typically executable build tools. -
SYSROOTandESYSROOTadded -
SYSROOTis the location of where dependencies inDEPENDare installed.ESYSROOTisSYSROOTwithEPREFIXappended. -
ENV_UNSETadded - A whitespace delimited list of variables to be removed from the build environment.
EAPI 7 metadata
- Empty groupings are banned
-
Groupings which are empty, such as
DEPEND="|| ( ${empty_var} )"will now generate an error. Furthermore, conditions within groupings are more strictly enforced. For example,REQUIRED_USE="|| ( foo? ( bar ) baz? ( zoinks )"would previously work withUSE="-foo -baz"now requires eitherUSE="foo bar"orUSE="baz zoinks".
EAPI 7 profiles
-
package.providedbanned -
Profiles may no longer contain a
package.providedfile withEAPI=7.
EAPI 7 helpers
-
dohtmlbanned -
The
dohtmlhelper has been banned withEAPI=7. -
dolibandliboptsbanned -
The
dolibhelper and the associatedliboptshave been banned withEAPI=7. -
has_versionandbest_versionchanges -
has_versionandbest_versionnow support an optional switch to determine which type of dependencies to check.-
-r(the default) will check runtime dependencies (RDEPEND) -
-dwill check CHOST build-time dependencies (DEPEND) -
-bwill check CBUILD build-time dependencies (BDEPEND)
-
- Version manipulation and comparison commands
-
EAPI=7 introduced three commands for common version number operations.
-
ver_cutobtains substrings of a version string -
ver_rsreplaces separators in a version string -
ver_testcompares two versions
See Version and name formatting issues for examples of common uses or an in-depth look
-
- New function
eqawarn -
The
eqawarnhelper has been added withEAPI=7. This function is to alert developers to a deprecated feature. Previously, this was contained ineutilseclass which is no longer necessary. - New function
dostrip -
The
dostriphelper has been added withEAPI=7. This function controls whether or not to strip a binary.dostrip -x [file]will exclude a binary from being stripped. Conversely, when combined with RESTRICT=strip,dostrip [file]selects a binary file to be stripped. -
dieandassertchanges - These commands are now safe to use in a subshell and act as if they were called in the main process.
-
nonfatalchanges -
The
nonfatalcommand now works for shell functions and subprocesses. -
domobehaviour changed -
domo(for localizations) now ignores theintodirectives. This follows similar commands likedoinfoanddoman. -
econfchanges -
The cross-compilation options
--buildand--targetoptions to specifyCBUILDandCTARGETrespectively have been added and are retro-active to all EAPIs. In addition, if the build supports--with-sysroot, the correct value will be passed such that normal and cross-compilations succeed.
EAPI 8
EAPI 8 tree layout
- Less strict naming rules for updates directory
-
Up to EAPI 7, the files in the
profiles/updatesdirectory had to follow strict naming by quarters like2Q-2021, indicating the quarter and the year when they were added. Such a choice of name had the side effect that lexical sorting of filenames was unsuitable.In EAPI 8, the naming requirement is removed. Eventually, this will allow switching to a more convenient scheme sorted by year. Different lengths of time periods will also be possible.
Note that this change actually requires changing the repository EAPI (found in
profiles/eapi), so it will not affect Gentoo for at least the next two years.
EAPI 8 ebuild format
- Bash version is now 5.0
-
The Bash version used for ebuilds is changed from 4.2 to 5.0. This means not only that ebuilds are now permitted to use features provided by the new Bash version but also the
BASH_COMPATvalue used for the ebuild environment is updated, switching the shell behaviour.The only really relevant difference in behaviour is:
-
Quotes are now removed from the RHS argument of a
"${var/.../"..."}"substitution:var=foo echo "${var/foo/"bar"}"The above snippet yields
"bar"in Bash 4.2 but justbarin 4.3+.
Potentially interesting new features include:
-
Negative subscripts can now be used to set and unset array elements (Bash 4.3+):
$ foo=( 1 2 3 ) $ foo[-1]=4 $ unset 'foo[-2]' $ declare -p foo declare -a foo=([0]="1" [2]="4")
-
Nameref variables are introduced that work as references to other variables (4.3+):
$ foo=( 1 2 3 ) $ declare -n bar=foo $ echo "${bar[@]}" 1 2 3 $ bar[0]=4 $ echo "${foo[@]}" 4 2 3 $ declare -n baz=foo[1] $ echo "${baz}" 2 $ baz=100 $ echo "${bar[@]}" 4 100 3 -
The
[[ -v ... ]]test operator can be used with array indices to test for array elements being set (4.3+). The two following lines are now equivalent:[[ -n ${foo[3]+1} ]] [[ -v foo[3] ]] -
mapfile(AKAreadarray) now accepts a delimiter via-d, with a-toption to strip it from read data (Bash 4.4+). The two following solutions to grab output fromfind(1)are now equivalent:# old solution local x files=() while read -d '' -r x; do files+=( "${x}" ) done < <(find -print0) # new solution local files=() mapfile -d '' -t files < <(find -print0) -
A new set of transformations is available via
${foo@...}parameter expansion (4.4+), e.g. to print a value with necessary quoting:$ var="foo 'bar' baz" $ echo "${var@Q}" 'foo '\''bar'\'' baz'For more details, see:
info bashor the Bash reference manual. -
local -can be used to limit single-letter (mangled viaset) shell option changes to the scope of the function, and restore them upon returning from it (4.4+). The following two functions are now equivalent:# old solution func() { local prev_shopt=$(shopt -p -o noglob) set -o noglob ${prev_shopt} } # new solution func() { local - set -o noglob }The complete information on all changes and new features can be found in the Bash 5.0 (and earlier) release notes.
-
EAPI 8 variables
- Selective fetch/mirror restriction
-
Before EAPI 8, fetch and mirror restrictions applied globally. That is, if you needed to apply the respective restriction to at least one distfile, you had to apply it to them all. However, sometimes packages used a combination of proprietary and free distfiles, the latter including e.g. third party patches, artwork. Until now, they had to be mirror-restricted completely.
EAPI 8 allows undoing fetch and mirror restriction for individual files. To use this, set
RESTRICTas before, then use the specialfetch+prefix to specify URLs that can be fetched from, or themirror+prefix to reenable mirroring of individual files.Similarly to how the
fetchrestriction implies amirrorrestriction, themirroroverride implies afetchoverride.EAPI=8 SRC_URI=" ${P}.tgz fetch+https://example.com/${P}-patch-1.tgz mirror+https://example.com/${P}-fanstuff.tgz" RESTRICT="fetch"The following table summarises the new behaviour:
RESTRICTURI prefix Fetching Mirroring (none) (any) allowed allowed mirror (none) / fetch+ allowed prohibited mirror+ allowed allowed fetch (none) prohibited prohibited fetch+ allowed prohibited mirror+ allowed allowed - Install-time dependencies (
IDEPEND) -
The primary use for install-time dependencies is to specify dependencies that are needed during the
pkg_postinstphase and that can be unmerged afterwards. That's pretty much the same asRDEPEND, except for the unmerging part — and uninstalling a few tools did not seem a goal justifying another dependency type.With cross-compilation support in EAPI 7, a new dependency type focused on the build host (
CBUILD) tools was added —BDEPEND. Unfortunately, this had missed the important use case of running executables installed to the target system when cross-compiling.RDEPENDwas no longer a suitable method of pulling in tools forpkg_postinst; and sinceBDEPENDis not used when installing from a binary package, something new was needed.This is where
IDEPENDcomes in. It is roughly toRDEPENDwhatBDEPENDis toDEPEND. Similarly toBDEPEND, it specifies packages that must be built for theCBUILDtriplet and installed intoBROOT(and therefore queried usinghas_version -b). However, similarly toRDEPEND, it is used when the package is being merged rather than built from source. It is guaranteed to be satisfied throughoutpkg_preinstandpkg_postinst, and it can be uninstalled afterwards.EAPI=8 inherit xdg-utils IDEPEND="dev-util/desktop-file-utils" pkg_postinst() { xdg_desktop_database_update } pkg_postrm() { xdg_desktop_database_update }In the example provided above, the ebuild needs to update the desktop database upon being installed or uninstalled. By placing the respective tool in
IDEPEND, the ebuild requests it to be available at the time ofpkg_postinst. When cross-compiling, the tool will be built forCBUILDand therefore directly executable by the ebuild.The dependency types table for EAPI 8 is presented below.
Dependency type BDEPEND IDEPEND DEPEND RDEPEND PDEPEND Present at build install build install n/a Binary compatible with CBUILD CHOST Base unprefixed path /SYSROOT ROOT Relevant offset-prefix BROOT EPREFIX (unless SYSROOT != ROOT) EPREFIX Path combined with prefix BROOT ESYSROOT EROOT PM query command option -b-d-r -
PROPERTIESandRESTRICTare now accumulated across eclasses -
Up to EAPI 7,
PROPERTIESandRESTRICTwere treated like regular Bash variables when sourcing eclasses. This meant that if an eclass or an ebuild wanted to modify them, they had to explicitly append to them, e.g. via+=. This was inconsistent with how some other variables (but not all) were handled, and confusing to developers. For example, consider the following snippet:EAPI=7 inherit git-r3 PROPERTIES+=" live"Note how you needed to append to
PROPERTIESset by git-r3 eclass, otherwise the ebuild would have overwritten it. In EAPI 8, you can finally do the following instead:EAPI=8 inherit git-r3 PROPERTIES="live"Now the complete list of metadata variables accumulated across eclasses and ebuilds includes:
IUSE,REQUIRED_USE,*DEPEND,PROPERTIES,RESTRICT. Variables that are not treated this way are:EAPI,HOMEPAGE,SRC_URI,LICENSE,KEYWORDS.EAPIandKEYWORDSare not supposed to be set in eclasses; as for the others, there appears to be a valid use case for eclasses providing default values and the ebuilds being able to override them.
EAPI 8 phase functions
-
pkg_*phases now run in a dedicated empty directory -
Before EAPI 8, the initial working directory was specified for
src_*phases only. For other phases (i.e.pkg_*phases), ebuilds were not supposed to assume any particular directory. In EAPI 8, these phases are guaranteed to be started in a dedicated empty directory.The idea of using an empty directory is pretty simple — if there are no files in it, the risk of unexpected and hard to predict interactions of tools with their current working directory is minimized.
-
PATCHESno longer permits options -
The
eapplyinvocation in the defaultsrc_prepareimplementation has been changed to:eapply -- "${PATCHES[@]}"This ensures that all items in the
PATCHESvariable are treated as path names. As a side effect, it is no longer possible to specifypatchoptions via thePATCHESvariable. Such hacks were never used in the Gentoo repository but they have been spotted in user-contributed ebuilds. The following will no longer work:PATCHES=( -p0 "${FILESDIR}"/${P}-foo.patch )Instead, you will need to invoke
eapplyexplicitly, see the example below. Alternatively, rebase the patch level.src_prepare() { eapply -p0 "${FILESDIR}"/${P}-foo.patch eapply_user }
EAPI 8 commands
- New econf-passed options
-
The
econfhelper has been modified to pass two more options to the configure script if the--helptext indicates that they are supported. These are:--datarootdir="${EPREFIX}"/usr/share--disable-static
The former option defines the base directory that is used to determine locations for system/desktop-specific data files, e.g. .desktop files and various kinds of documentation. This is necessary for ebuilds that override
--prefix, as the default path is relative to it.The latter option disables building static libraries by default. This is part of the ongoing effort to disable unconditional install of static libraries ( Gentoo Policy Guide, Installation of static libraries).
-
dosym -rto create relative symlinks -
Relative symlink targets tend to be more reliable. Consider the two following examples:
dosym "${EPREFIX}"/usr/lib/frobnicate/frobnicate /usr/bin/frobnicate dosym ../lib/frobnicate/frobnicate /usr/bin/frobnicateThe first line creates a symlink using an absolute path. The problem with that is if you mount your Gentoo system in a subdirectory of your root filesystem (e.g. for recovery), the symlink will point at the wrong location. Using relative symlinks (as demonstrated on the second line) guarantees that the symlink will work independently of where the filesystem is mounted.
There is also fact that you need to explicitly prepend
${EPREFIX}to the absolute paths passed as the first argument ofdosym. Using a relative target avoids the problem altogether and makes it less likely to forget about the prefix.However, in some instances, determining the relative path could be hard or inconvenient. This is especially the case if one (or both) of the paths comes from an external tool. To make it easier, EAPI 8 adds a new
-roption that makesdosymcreate a relative symlink to the specified path (similarly toln -r):dosym -r /usr/lib/frobnicate/frobnicate /usr/bin/frobnicateNote that in this case, you do not pass
${EPREFIX}. The helper determines the logical relative path to the first argument and creates the appropriate relative symlink. It is very important here to understand that this function does not handle physical paths, i.e. it will work only if there are no directory symlinks along the way that would result in..resolving to a different path. For example, the following will not work:dosym bar/foo /usr/lib/foo dosym -r /usr/lib/zomg /usr/lib/foo/zomgThe logical path from
/usr/lib/foo/zomgto/usr/lib/zomgis../zomg. However, since/usr/lib/foois actually a symlink to/usr/lib/bar/foo,/usr/lib/foo/..resolves to/usr/lib/bar. If you need to account for such directory symlinks, you need to specify the correct path explicitly:dosym bar/foo /usr/lib/foo dosym ../../zomg /usr/lib/foo/zomg -
insoptsandexeoptsnow apply todoinsanddoexeonly -
In previous EAPIs, there was an inconsistency in how
insoptsandexeoptsapplied to various helpers. In particular, the majority of helpers (e.g.dobin,dodocand so on) ignored the options specified via these helpers but a few did not.EAPI 8 changes the behaviour of the following helpers that used to respect
insoptsorexeopts:doconfddoenvddoheaderdoinitd
In EAPI 8, they always use the default options. As a result,
insoptsnow only affectsdoins/newins, andexeoptsonly affectsdoexe/newexe. Furthermore,diroptsdoes not affect the directories implicitly created by these helpers. -
usevnow accepts a second argument -
The
usevhelper was introduced to provide the historical Portage behaviour of outputting the USE flag name on match. In EAPI 8, it has been extended, in order to provide an alternative to three-argumentusexwith an empty third argument (the two-argumentusexvariant uses a default ofnofor the false branch).In other words, the following two calls are now equivalent:
$(usex foo --enable-foo '') $(usev foo --enable-foo)This is particularly useful with custom build systems that accept individual
--enableor--disableoptions but not their counterparts.As a result,
usevandusexcan now be used to achieve all the common (and less common) output needs as summarized in the following table.Variant True False usev flag flag usev flag true true usex flag yesnousex flag true true nousex flag true false true false -
hasq,hasvanduseqfunctions have been banned -
In its early days, the
usehelper would print the USE flag name if it matched, in addition to its boolean exit status. Later, a quietuseqand a verboseusevhelper were added, andusewas made quiet by default. The same changes were applied tohas.Fast forward to EAPI 7, there are still three variants of
useand three variants ofhas. The base variant that is quiet, theuseq/hasqvariant that is equivalent to the base variant, and the verboseusev/hasvvariant.Obviously, adding a second argument to
hasvwas not possible, so its behaviour would have become inconsistent withusevin EAPI 8. Sincehasvwas not used in the Gentoo repository, it has been removed, along withhasqanduseqwhich were considered deprecated since 2011. - unpack removes support for 7-Zip, LHA and RAR formats
-
Support for the least commonly used archive formats from
unpackhas been removed:- 7-Zip (.7z)
- LHA (.lha, .lzh)
- RAR (.rar)
Packages using these format for distfiles must now unpack them manually. Using
unpacker.eclassis recommended for this.
EAPI 9
EAPI 9 profiles
- Default EAPI for profiles
-
Profile directories that don't contain an own
eapifile no longer default to EAPI 0, but to the EAPI specified in the top-levelprofilesdirectory. -
use.stableandpackage.use.stable -
Profile dirs may contain two new files
use.stableandpackage.use.stable. They can be used to override the USE flags specified bymake.defaults, but act only on packages that would be merged due to a stable keyword. The format of theuse.stablefile is simple: Each line contains a USE flag to enable; a minus sign before the flag indicates that the flag should be disabled instead. Thepackage.use.stablefile has the same format aspackage.use(see make.conf(5)).USE_EXPANDvalues may be enabled or disabled by usingexpand_name_value. Flags listed inpackage.use.stabletake precedence over these listed inpackage.use, which in turn take precedence overuse.stable.
EAPI 9 ebuild format
- Bash version is now 5.3
-
Ebuilds can use Bash version 5.3 (was 5.0 before). Some notable new features are:
-
declareandlocalnow have a-Ioption that inherits the attributes and value from of any existing variable with the same name at a surrounding scope. For example, an ebuild could dolocal -Ix ROOTto export the
ROOTvariable to the environment, from where an external could get its value. -
There is a new form of command substitution:
${ command; }or${|command;}to capture the output ofcommandwithout forking a child process and using pipes.${ command; }executescommandin the current execution environment and captures its output. Any side effects ofcommandtake effect immediately in the current execution environment and persist after the command completes. This type of command substitution superficially resembles executing an unnamed shell function: local variables are created as when a shell function is executing, and thereturnbuiltin forcescommandto complete; however, the rest of the execution environment is shared with the caller.The
${|command;}construct expands to the value of theREPLYshell variable aftercommandexecutes, without removing any trailing newlines, and the standard output ofcommandremains the same as in the calling shell. Bash createsREPLYas an initially-unset local variable whencommandexecutes, and restoresREPLYto its old value aftercommandcompletes, as with any local variable.For example, this construct expands to
12345, and leaves the shell variableXunchanged in the current execution environment:${ local X=12345; echo $X; }while the following construct does not require any output to expand to
12345and restoresREPLYto the value it had before the command substitution:${| REPLY=12345; } -
Pattern substitution now duplicates a common
sedidiom: If thepatsub_replacementshell option is enabled (which it is by default), any unquoted&in the replacement string is replaced with the portion of the string that matched the pattern.For instance:
var="foobar" echo "${var/foo/&123}"will print
foo123bar, i.e. the&in the replacement string is replaced with the stringfoothat matched the pattern.A backslash can be used to escape the
&and insert a literal&in the replacement string.
-
EAPI 9 variables
- Variables are no longer exported
-
The package manager no longer exports its defined shell variables to the environment but keeps them as unexported shell variables, namely:
-
CATEGORY,P,PF,PN,PV,PR,PVR A-
FILESDIR,DISTDIR,WORKDIR,S,ROOT,EROOT,SYSROOT,ESYSROOT,BROOT,T,EPREFIX,D,ED USE-
EBUILD_PHASE,EBUILD_PHASE_FUNC MERGE_TYPE-
REPLACING_VERSIONS,REPLACED_BY_VERSION -
ECLASS,INHERITED,DEFINED_PHASES
Important: Exceptions areTMPDIRandHOMEwhich are always exported.The same applies to variables set in
make.defaultsthat have specific meanings or special handling. These are no longer exported to the environment of an EAPI 9 ebuild:ARCH-
CONFIG_PROTECT,CONFIG_PROTECT_MASK -
USE,USE_EXPAND,USE_EXPAND_UNPREFIXED,USE_EXPAND_HIDDEN,USE_EXPAND_IMPLICIT,IUSE_IMPLICIT ENV_UNSET-
All variables named in
USE_EXPANDandUSE_EXPAND_UNPREFIXED -
All
USE_EXPAND_VALUES_${v}variables, where${v}is a value inUSE_EXPAND_IMPLICIT
All other variables set in
make.defaultswill still be exported to the environment.As a consequence, external commands can no longer rely on the value of the
ROOTvariable in the environment. For example,eselectmust be called with the--rootoption in EAPI 9:pkg_postinst() { eselect --root="${ROOT}" emacs update ifunset } -
EAPI 9 commands
-
asserthas been banned -
Our definition of
assertdeviated from the semantics of the command in mainstream programming languages and was a source of confusion. Therefore, use of theassertcommand in ebuilds is no longer allowed.pipestatus(see below) should be used as replacement. -
domohas been banned -
The operation of the
domocommand was unintuitive. It also hardcoded${PN}as the gettext domain, which is often not what is wanted. Therefore, thedomocommand has been banned.insintoplusnewinsshould be used as replacement. pipestatus-
Checks if all commands in the last executed pipeline have returned an exit
status of zero. When the
-voption is specified, also prints the shell's pipe status array.foo | bar | baz pipestatus || die -
ver_replacingop v2 -
Checks if the relation v1 op v2 is true for at least one element v1 of
REPLACING_VERSIONS. op can be any operator that is accepted byver_test. Returns shell true (0) if the specified relation holds for at least one element, shell false (1) otherwise. In particular, shell false is returned whenREPLACING_VERSIONSis empty.Obviously,
ver_replacingis only meaningful in phases whereREPLACING_VERSIONSis defined, i.e. inpkg_preinstandpkg_postinst.pkg_postinst() { if ver_replacing -lt 3; then elog "This is a major upgrade and may break your existing setup!" fi } edo- Outputs its entire argument list as an informational message, then executes it as a simple shell command, with standard failure behaviour.
EAPI 9 merging and unmerging
- Merging of symlinks
-
When merging
DtoROOT, absolute symlinks are now merged as-is. The package manager will no longer strip a leadingDfrom their link targets.In previous EAPIs, any absolute symlink whose link target started with
${D}was rewritten with the leading${D}removed. That behaviour was ill-defined becauseDis not guaranteed to have the same value that it had in thesrc_*phases. For example, when a binary package was merged on a target host withPORTAGE_TMPDIRdifferent from the build host'sPORTAGE_TMPDIR, symlink rewriting would have failed.