Basic guide to write Gentoo Ebuilds

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

Ebuilds: Where do they live?
Ebuilds from the Gentoo ebuild repository (git tree, snapshot) are usually synced to. 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.

Try to run the test suite if possible:

To actually merge it to the system, try:

Patching
In case the source code needs to be patched, a 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.

QA testing
Use or  to check for QA errors in your ebuild:

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