/etc/portage/patches

The patches directory provides another way to apply user-defined patches. The advantage is if all you want is to apply a patch, you may do so without forking the entire package to an overlay, or defining a hook function, which can make following the upstream ebuild easier.

epatch_user
This isn't a feature that's actually supplied by Portage directly. Ebuilds or eclasses must provide support for patches explicitly by calling  from. This works out well because you can just let the package maintainer determine an appropriate place to apply patches. For example, implements epatch_user directly in the eclass, after programatically applying patches defined by a global PATCHES array. Different ebuilds/eclasses may have their own systems. The function writes a lockfile to, so it isn't a big deal if accidentally called more than once.

epatch_user in bashrc
If an ebuild does not explicitly call, you can still hook this function into the ebuild with help of , as long as the ebuild inherits the eutils class.