2011-07-07

How to apply User patches in portage

After years of tinkering with gentoo and feeding my custom overlay I discovered today the "user patches" feature of portage.

This is really awesome !

The Use Case :
You want to just try out a patch for something already in portage.

Instead of creating another ebuild in an overlay you can put your patch in :
/etc/portage/patches/{category}/{package_name}/

For example :
mkdir -p /etc/portage/patches/sys-libs/glibc-2.13-r3/
wget -O /etc/portage/patches/sys-libs/glibc-2.13-r3/fix1.patch "https://bugs.gentoo.org/attachment.cgi?id=279269"
emerge -1 glibc


To check if your patch applied you should see the following just after the standard batch of patches:
 * Applying user patches from /etc/portage/patches/sys-libs/glibc-2.13-r3 ...
 *   fix1.patch ...                                                                                 [ ok ]
 * Done with patching