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

Before EAPI 6, the default implementation did nothing:

src_prepare() {
	true
}

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

src_prepare() {
	if [[ $(declare -p PATCHES 2>/dev/null) == "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.