An ebuild is a
bash script which is executed within a special environment.
Files should be simple text files with a
An ebuild should be named in the form
The name section should contain only lowercase non-accented letters, the digits 0-9, hyphens, underscores and plus characters. Uppercase characters are strongly discouraged, but technically valid.
The name must not begin with a hyphen or a plus sign, and must not end in a hyphen followed by anything that could be mistaken for a version.
The version section is more complicated. It consists of one or more numbers
separated by full stop (or period, or dot, or decimal point) characters (eg
20050108). The final number may have a single letter following it
1.2b). This letter should not be used to indicate 'beta' status
1.2b as being a later version than
There can be a suffix to version indicating the kind of release. In the following table, what portage considers to be the 'lowest' version comes first.
||Alpha release (earliest)|
|(no suffix)||Normal release|
Any of these suffixes may be followed by an unsigned integer.
These suffixes can be chained together and will be processed iteratively. To give some examples (the following list is from lowest version to highest):
No integer part of the version may be longer than 18 digits.
Finally, version may have a Gentoo revision number in the form
-r1. The initial
Gentoo version should have no revision suffix, the first revision should be
-r1, the second
-r2 and so on. See Ebuild Revisions.
Revision numbers are distinguished from patch releases by revision bumps being
changes by Gentoo developers, while patch releases are new releases by upstream (with the exception
of snapshots, see below).
Overall, this gives us a filename like
When packaging a snapshot of a source repository, there are two commonly used formats. The first treats the snapshot as a patch to the previous version, and so the ebuild version is in the format $(last-released-version)_pYYYYMMDD. Alternatively, the snapshot may be treated as a pre-release to an upcoming version, usually used when a release is anticipated but not out yet. The format for this is $(upcoming-version)_preYYYYMMDD.
The policy for so-called live ebuilds
is to use
9999 as the version (or as the last version component).
The versionator.eclass may be used to manipulate and extract ebuild version components.
All ebuilds committed to the tree should have a two line header immediately at
the start indicating copyright, followed by an empty line. This must be an
exact copy of the contents of
header.txt in the top directory of the Gentoo repository.
# Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2
$Header$keyword. That line was abolished after conversion to Git by decision of the Gentoo Council on 28 February 2017 and must not be added any more.
Indenting in ebuilds must be done with tabs, one tab per indent level. Each tab represents four spaces. Tabs should only be used for indenting, never inside strings.
Avoid trailing whitespace: repoman will warn you about this if your ebuild contains trailing or leading whitespace (whitespace instead of tabs for indentation) when you commit.
Where possible, try to keep lines no wider than 80 positions. A 'position' is generally the same as a character — tabs are four positions wide, and multibyte characters are just one position wide.
All ebuilds (and eclasses, metadata files and ChangeLogs) must use the UTF-8 character set. See GLEP 31 for details.