Function pkg_preinst
Purpose Called before image is installed to ${ROOT}
Sandbox Disabled
Privilege root
Called for ebuild, binary

Default pkg_preinst


Sample pkg_preinst

pkg_preinst() {
	enewgroup foo
	enewuser foo -1 /bin/false /dev/null foo

Common pkg_preinst Tasks

There are a few things that are often done in pkg_preinst:

  • Adding users and groups. However, since pkg_preinst may be called after src_compile, pkg_setup is the more suitable location for user creation — see Users and Groups.
  • Modifying the install image for a particular system. This function allows system-specific customisation to be done even when installing from a binary. The most useful example is probably smart configuration file updating — a pkg_preinst could check a configuration file in ${ROOT}/etc/ and create a smart updated version in ${D}/etc/ (see Install Destinations) rather than always trying to install the default configuration file (remember Configuration File Protection).