Basic guide to write Gentoo Ebuilds

This article Article description::contains instructions for beginners on ebuild development.

Ebuilds: Where do they live?
The location of ebuilds from the Gentoo repository (available in the snapshot) are usually at or in  for older installs. The location is determined by the repos.conf file. Custom ebuilds are recommended to be placed in a custom ebuild repository, say.

How to create an ebuild
Users of vim get the basic skeleton automatically (provided by ):

A similar tool is available for users of GNU Emacs or XEmacs (provided by or, respectively).

Users of other editors can manually copy the file located in the Gentoo ebuild repository:

Essential information of the new package should be known and added to the ebuild-defined variables DESCRIPTION, HOMEPAGE, SRC_URI, LICENSE.

Example for a given source tarball
Creating an ebuild for scrub, version 2.6.1 (if it didn't already exist) might read:

It can be tested using the command like:

This should download and unpack the source tarball. In some rare cases the package should work and no further adjustments is needed in the ebuild.

Patching
In case the source code needs to get patched the patch can be created from the unpacked source code as explained in the patches article.

The patch will then be listed in an array called  as is explained in the devmanual.

Adding support for user patches to ebuilds
Since EAPI 6, the support for user patches is provided by. This can be done by putting default on top in the src_prepare function:

EAPI versions prior to EAPI 8 should not be used for new ebuilds.

External resources

 * Gentoo Policy Guide
 * Quickstart Ebuild Guide
 * Gentoo Development guide
 * Michał Górny: Category: Ebuild writing
 * Michał Górny: The ultimate guide to EAPI 7
 * Michał Górny: The ultimate guide to EAPI 8
 * - The ebuild command's man page.
 * - The ebuild file format man page.
 * - To check for QA errors, QA keywords are explained in the last part of.
 * The skel.ebuild
 * Adding new packages via proxy-maint project