src_prepare

Function src_prepare
Purpose Prepare source packages and do any necessary patching or fixes.
Sandbox Enabled
Privilege user
Called for ebuild

Default src_prepare

Starting from EAPI=2, the src_prepare function is the appropriate area to perform any kind of patching and source code manipulation, instead of src_unpack.

src_prepare() {
	true;
}

Beginning with EAPI=6, the src_prepare function gained a new default implementation:

src_prepare() {
    if declare -p PATCHES | grep -q "^declare -a "; then
        [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}"
    else
        [[ -n ${PATCHES} ]] && eapply ${PATCHES}
    fi
    eapply_user
}

Sample src_prepare

src_prepare() {
	eapply "${FILESDIR}/${PV}/${P}-fix-bogosity.patch"
	eapply "${FILESDIR}/${PV}/${P}-pam.patch"

	eapply_user

	sed -i -e 's/"ispell"/"aspell"/' src/defaults.h || die "Sed failed!"
}

src_prepare Processes

The following subsections cover different topics which often occur when writing src_prepare functions.