In EAPI 6 ebuilds can apply patches in default_src_prepare by assigning the PATCHES variable in global scope. For example: PATCHES=( "${DISTDIR}"/foo.patch ) Similar to FILESDIR, DISTDIR should have the same value in global scope as it has in the src_* phases. Otherwise, PATCHES could contain a file that is not in ${A}, which defeats the purpose of having a fake DISTDIR.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=8aa99e78bb89615bb25044183e160a7bf7facc2d commit 8aa99e78bb89615bb25044183e160a7bf7facc2d Author: Michał Górny <mgorny@gentoo.org> AuthorDate: 2018-01-25 08:29:07 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2018-01-26 14:58:59 +0000 portage.package.ebuild.config: Override DISTDIR unconditionally Ensure that DISTDIR is always defined to the path to the shadow directory. This ensures that PMS rules for consistent value are followed, and that no global scope calls should be able to access the distfile directory. This also ensures that global-scope assignments (e.g. in PATCHES) do not work around the shadow directory. Bug: https://bugs.gentoo.org/612972 Reviewed-by: Zac Medico <zmedico@gentoo.org> pym/portage/package/ebuild/config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)}