Guia básico para escrever ebuilds Gentoo
Esse artigo contém instruções para iniciantes no desenvolvimento ebuild.
Portage, o coração do Gentoo, executa em ebuilds!
An ebuild file is a text file, usually stored in a repository, which identifies a specific software package and tells the Gentoo package manager how to handle it. Ebuilds use a bash-like syntax style and are standardized through the Package Manager Specification, by adhering to a specific EAPI version.
Ebuilds contain metadata about each version of a piece of available software (name, version number, license, home page address...), dependency information (both build-time and run-time), and instructions on how to build and install the software (configure, compile, build, install, test...).
Ebuilds: Onde eles moram??
The location of ebuilds from the Gentoo repository (available in the snapshot) are usually at /var/db/repos/gentoo[1] or in /usr/portage for older installs. The location is determined by the repos.conf file. Custom ebuilds are recommended to be placed in a custom repository, say /var/db/repos/larry.
Como criar um ebuild
Users of vim get the basic skeleton automatically (provided by app-vim/gentoo-syntax):
root #
vim ./foobar.ebuild
foobar.ebuild
vim starts from the template# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 DESCRIPTION="" HOMEPAGE="" SRC_URI="" LICENSE="" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="" DEPEND="" RDEPEND="${DEPEND}" BDEPEND=""
A similar tool is available for users of GNU Emacs or XEmacs (provided by app-emacs/ebuild-mode or app-xemacs/ebuild-mode, respectively).
Users of other editors manually copy from the skel.ebuild:
root #
cp /var/db/repos/gentoo/skel.ebuild ./foobar.ebuild
Essential information of the new package should be known and added to the ebuild-defined variables DESCRIPTION, HOMEPAGE, SRC_URI, LICENSE.
Exemplo para um determinado fonte tarball
Creating an ebuild for scrub, version 2.6.1 (if it didn't already exist) might read:
root #
mkdir -p /var/db/repos/larry/app-misc/scrub
root #
cd $_
root #
vim ./scrub-2.6.1.ebuild
scrub-2.6.1.ebuild
vim starts from the template# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 DESCRIPTION="Some words here" HOMEPAGE="https://github.com/chaos/scrub" SRC_URI="https://github.com/chaos/scrub/releases/download/2.6.1/scrub-2.6.1.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~amd64 ~x86" IUSE="" DEPEND="" RDEPEND="${DEPEND}" BDEPEND=""
Using
${PN}
variable inside SRC_URI
is allowed, but not suggested. While it may shrink the line, some reasoning why not to use it is worth consideration as well.SRC_URI="https://github.com/chaos/${PN}/releases/download/${PV}/${P}.tar.gz"
It can be tested using the ebuild command like:
root #
ebuild ./scrub-2.6.1.ebuild clean unpack
Appending /var/db/repos/larry to PORTDIR_OVERLAY... >>> Downloading 'https://ftp.halifax.rwth-aachen.de/gentoo/distfiles/scrub-2.6.1.tar.gz' --2019-06-03 16:42:57-- https://ftp.halifax.rwth-aachen.de/gentoo/distfiles/scrub-2.6.1.tar.gz Resolving ftp.halifax.rwth-aachen.de... 137.226.34.46, 2a00:8a60:e012:a00::21 Connecting to ftp.halifax.rwth-aachen.de|137.226.34.46|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 362536 (354K) [application/octet-stream] Saving to: '/usr/portage/distfiles/scrub-2.6.1.tar.gz.__download__' /usr/portage/distfiles/scrub-2.6.1.tar.gz.__download__ 100%[==============================================================================================================================================================>] 354.04K --.-KB/s in 0.08s 2019-06-03 16:42:58 (4.24 MB/s) - '/usr/portage/distfiles/scrub-2.6.1.tar.gz.__download__' saved [362536/362536] * scrub-2.6.1.tar.gz BLAKE2B SHA512 size ;-) ... [ ok ] >>> Unpacking source... >>> Unpacking scrub-2.6.1.tar.gz to /var/tmp/portage/app-misc/scrub-2.6.1/work >>> Source unpacked in /var/tmp/portage/app-misc/scrub-2.6.1/work
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.
user $
cd /var/tmp/portage/app-misc/scrub-2.6.1/work/scrub-2.6.1/
The patch will then be listed in an array called PATCHES
as is explained in the devmanual.
PATCHES=( "${FILESDIR}"/${P}-foo.patch "${FILESDIR}"/${P}-bar.patch ) src_prepare() { default ... }
Adicionando suporte para patches de usuários aos ebuilds
Since EAPI 6, the support for user patches is provided by eapply_user
. This can be done by putting default on top in the src_prepare function:
src_prepare() { default ... }
EAPI versions prior to EAPI 7 should not be used for new ebuilds.
Veja também
- Project:GURU — an official repository of new Gentoo packages that are maintained collaboratively by Gentoo users
- GitHub Pull Requests — how to contribute to Gentoo by creating pull requests on GitHub.
- Notes on ebuilds with GUI
- Project:X11/Ebuild_maintenance
- Project:Proxy_Maintainers/User_Guide/Style_Guide
Recursos externos
- Gentoo Policy Guide
- Quickstart Ebuild Guide
- Gentoo Development guide
- Michał Górny: The ultimate guide to EAPI 7
- man 1 ebuild - The ebuild command's man page.
- man 5 ebuild - The ebuild file format man page.
- repoman metadata && repoman full - To check for QA errors, QA keywords are explained in the last part of man repoman.
- The skel.ebuild
- Adding new packages via proxy-maint project