by July 22, 2015
onLately I had to fix some gentoo ebuild package - I describe a few possibilities I found how to do that.
The most convenient way is to use portage’s built-in to inject custom patches just before the build process. All you have to do is to place a .patch
file in the appropriate folder in /etc/portage/patches/
.
A custom patch for the x11-wm/dwm
package should be used like this:
$ mkdir -p /etc/portage/patches/x11-wm/dwm-6.0
$ cp 99-bottom-stack.patch /etc/portage/patches/x11-wm/dwm-6.0
Although I am using the gentoo distribution for many years now I dicovered this great way only a few months ago. But there is a catch as I found yesterday - the user patches will only be applied if the ebuild you are dealing with is prepared to do so.
The ebuild you are using has to invoke the epatch_user
command inside its src_prepare
function:
If you are out of luck and the ebuild you are dealing with does not invoke epatch_user
on its own like described above there is another possibility to your rescue. In case the ebuild inherits the eutils eclass you can get your patch applied with a custom bashrc
used for portage.
Place something along the following in your /etc/portage/bashrc
file:
This will inject the epatch_user
function call after the src_prepare
process on ebuilds that inherit eutils
.
If the above does not work for you or the changes you want to do involve more than just applying a patch you may want to create a custom overlay to place your own ebuilds into.
First you have to create the necessary directory structure for the to-be-created overlay (i.e. myoverlay
):
$ mkdir -p /usr/local/portage/{metadata,profiles}
$ echo 'myoverlay' > /usr/local/portage/profiles/repo_name
$ echo 'masters = gentoo' > /usr/local/portage/metadata/layout.conf
$ chown -R portage:portage /usr/local/portage
Now you just have to register the overlay for portage usage - create a local.conf
file inside /etc/portage/repos.conf/
directory:
$ cat /etc/portage/repos.conf/local.conf
[myoverlay]
location = /usr/local/portage
masters = gentoo
auto-sync = no
Now you can go ahead and take for example an existing ebuild and do your modifications:
$ mkdir -p /usr/local/portage/x11-wm/dwm
$ cd /usr/local/portage/x11-wm/dwm
$ cp /usr/portage/x11-wm/dwm/dwm-6.0.ebuild dwm-6.0-r1.ebuild
# fix or modify the ebuild
$ vim dwm-6.0-r1.ebuild
# create the manifest
$ repoman manifest