# Apply *.diff patches under ${PORTAGE_PATCHDIR} for the current package. # *.patch files are skipped to avoid double application if the ebuild # calls epatch_user. # # Written by Andrew Church # Last updated 2019-02-26 # Based on comments in http://forums.gentoo.org/viewtopic-t-791464.html _my_epatch_user() { if test -f "${T}/.portage_user_patches_applied"; then return fi >>"${T}/.portage_user_patches_applied" if [ -z "${PORTAGE_PATCHDIR}" -o ! -d "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}" ]; then return fi if [ "$(type -t epatch)" != "function" ]; then eval "$(sed -n '/^epatch()/,/^}/p' "${PORTDIR-/usr/portage}/eclass/epatch.eclass")" fi __vecho ">>> Applying custom patches..." ( if cd "$S"; then for patch in "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}"/* \ "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}/${PV}"/*; do [ -f "${patch}" ] || continue # *.patch files are handled by Portage itself. if echo "${patch}" | grep -q '\.patch$'; then continue; fi epatch "${patch}" || die "Failed to apply patch ${patch}" done fi ) } post_src_unpack() { if [ "${EAPI-0}" -lt 2 ]; then _my_epatch_user fi } post_src_prepare() { if [ "${EAPI-0}" -ge 2 ]; then _my_epatch_user fi } # Override EAPI 6's eapply_user to use our routine. eapply_user() { _my_epatch_user; } readonly -f eapply_user # Override eutils.eclass's epatch_user to use our routine. epatch_user() { _my_epatch_user; } readonly -f epatch_user