Chapter 6. Ebuild

Table of Contents

Ebuild Phases
Interaction with previous installed version
Upgrade/downgrade order used by versions less than 2.1.5 (deprecated)
Upgrade/downgrade order starting with version 2.1.5
Helper Functions
Output
ebegin
eend
einfo
elog
eqawarn
ewarn
EAPI
EAPI 0
Phases
Default src_compile Phase Function
EAPI 1
IUSE defaults
Phases
Default src_compile Phase Function
SLOT Dependencies
EAPI 2_pre1
Helpers
doman
USE Dependencies
Unconditional USE Dependencies
Conditional USE Dependencies
EAPI 2_pre2
Phases
New src_configure Phase Function
Default Phase Functions
Default Phase Function Alias
EAPI 2 Draft
Helpers
doman
Recognition of Language Codes in File Names
Metadata
Dependencies
Blocker Atoms
New Meaning for Old Syntax
New !!atom Syntax
USE Dependencies
Unconditional USE Dependencies
Conditional USE Dependencies
SRC_URI
Customization of Output File Names
Phases
New src_prepare Phase Function
New src_configure Phase Function
Execution Order of Phase Functions
Default Phase Functions
Default Phase Function Alias

Ebuild Phases

Ebuild execution is divided into a series of phases. In order to implement a phase, an ebuild defines a function to serve as an entry point for execution of that phase. This design is similar to the template method pattern that is commonly used in object oriented programming languages. An ebuild can inherit or override a template method from an eclass.

The function names for the ebuild phases, listed in order of execution:

  • pkg_setup
  • src_unpack
  • src_compile
  • src_test
  • src_install
  • pkg_preinst
  • pkg_postinst
  • pkg_prerm
  • pkg_postrm

Interaction with previous installed version

The order for upgrade and downgrade operations changed in version 2.1.5, but the order for reinstall operations remained unchanged.

Upgrade/downgrade order used by versions less than 2.1.5 (deprecated)

  • pkg_preinst
  • pkg_postinst
  • pkg_prerm
  • pkg_postrm

Upgrade/downgrade order starting with version 2.1.5

The new order for upgrades and downgrades is identical to the order used for reinstall operations:

  • pkg_preinst
  • pkg_prerm
  • pkg_postrm
  • pkg_postinst

Now that pkg_postinst is called after all other phases, it's not possible to call has_version in pkg_postinst to detect whether the current install operation is an upgrade or downgrade. If this information is needed during the pkg_postinst phase, do the has_version call in an earlier phase (such as pkg_preinst) and store the result in a global variable to be accessed by pkg_postinst when it is called.