# Apply *.diff patches under ${PORTAGE_PATCHDIR} for the current package. # *.patch files are skipped to avoid double application if the ebuild # calls {epatch,eapply}_user. Requires a copy of the now-obsolete # epatch.eclass in /etc/portage, which can be fetched from # . # # Written by Andrew Church # Last updated 2025-12-10 # Based on comments in _my_epatch_user() { if test -f "${T}/.portage_user_patches_applied"; then return fi >>"${T}/.portage_user_patches_applied" if test -z "${PORTAGE_PATCHDIR}" || test ! -d "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}"; then return fi if test "$(type -t epatch)" != "function"; then eval "$(sed -n '/^epatch()/,/^}/p' /etc/portage/epatch.eclass)" fi __vecho ">>> Applying custom patches..." ( if cd "$S"; then for patch in "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}"/* \ "${PORTAGE_PATCHDIR}/${CATEGORY}/${PN}/${PV}"/*; do test -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 test "${EAPI-0}" -lt 2; then _my_epatch_user fi } post_src_prepare() { if test "${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