For example (not necessarily factual), Gentoo has an ebuild git, which has the default branch name main hardcoded in the source code.

Alice, as a user of Gentoo, would like to change it to master before building, so that the original default branch name may be restored.

While Gentoo may not accept such a patch, Alice might still be able to apply a user-space patch before Portage makes the ebuild.

Is there such a way to achieve it?

2 Answers 2


Sounds like you are looking for the /etc/portage/patches directory. https://wiki.gentoo.org/wiki//etc/portage/patches

Patches placed here (specifically at /etc/portage/patches/${CATEGORY}/${P} tec.) will be applied during build, without (usually) requiring any change to the ebuild. The Wiki page talks about EAPI 5 and 6, but most of the tree is now using EAPI 6 or newer, so you are unlikely to have issues. If you place the patch under the package name (no version), then portage will attempt to apply it to every version of the package which you build.

I've found it really useful for testing upstream fixes before submitting for inclusion, without having to set up a separate development / build environment for major pieces of software like KDE.


A bad example, as git is already using master as the default branch, and selecting a different name as the default will be supported with 2.28.0.

However, to my knowledge there's no easy and straightforward way to achieve what you ask for. My approach would be to copy the current ebuild to a local custom repository (I use /usr/local/portage for this purpose), perhaps increase the revision number (you could start with *-r100 + x to be ahead of the Gentoo releases) and apply your patch there. It's up to you to keep this ebuild updated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .