Basic guide to write Gentoo Ebuilds

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

Ebuild repositories
In order for ebuilds to be available to Portage, they are placed in an ebuild repository that is configured for Portage through (see the section on repository management for general information about working with ebuild repositories).

Ebuilds can be installed with the ebuild command, however this is not recommended - this command is for internal Gentoo development.

Create an ebuild repository to experiment in, while following on with this guide, for the sake of example 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 an 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