Gentoo Development Guide

Ebuild Functions

When installing packages from source, the function call order is pkg_setup, src_unpack, src_prepare, src_compile, src_test (optional, FEATURES="test"), src_install, pkg_preinst, pkg_postinst. When installing packages from a binary, the function call order is pkg_setup, pkg_preinst, pkg_postinst. As some phases haven't been introduced from the beginning, you can have a look at EAPI Usage and Description for an overview, what have been introduced in which EAPI.

How the ebuild functions are processed

The pkg_prerm and pkg_postrm functions are called when uninstalling a package. The pkg_config function is used for any special package configuration — it is only run when explicitly requested by the user. The pkg_nofetch function is used when a RESTRICT="fetch" package needs to obtain some SRC_URI components.

Between the transition from pkg_preinst to pkg_postinst, files are copied over to the live filesystem from the sandboxed temporary installation location, and Portage records digests of the files installed.

When testing or debugging, you can instruct Portage to execute a specific function from an ebuild by using the ebuild command, see the ebuild(1) manual page for further information.