Gentoo Ebuilds 101 Arun Raghavan Foss.in – November 30, 2005 Abstract A basic introduction to Gentoo Linux’ ebuild scripts, what they contain, how they work, and most importantly – how to write one. Overview • What this talk provides 4 An introduction to what ebuilds are 4 A quick guide to starting off on your own ebuilds, or modifying existing ones • What it isn’t 8 1 A detailed list of all the variables, function, eclasses you can use 8 Going to tell you how to do the more esoteric things that you can • The idea is to get you on your way to hacking ebuilds, not to bog you down with minutiae 1 We’ll just get to eclasses in a bit • The information is not always complete if I’m trying to keep things simple What is this ebuild you speak of? • Basically just a bash script • Set of commands to fetch, unpack, compile, and install a package • . . . and then some ;-) • File name looks like <package-name>-<version>[-revision-number].ebuild • Organized by category under /usr/portage/<category>/<package>, like media-video/mplayer and sys-kernel/gentoo-sources • Subdirectory files for additional files, like patches • metadata.xml to list the maintainer and herd for this package • Manifest – automatically created set of MD5 to verify all associated files Peeping Under The Hood What the little pixie gnomes do when you run emerge ... 1. Calculate the set of packages (specified and dependencies) to be installed 2. For each package: (a) Create PORTAGE TMPDIR/portage/full-package-name, subdirectories work, temp and image (b) Fetch any files that require fetching (c) Check MD5 digests (d) Perform setup operations (e) Unpack the package (f) Compile the package (g) Perform test steps if defined (h) Install into image directory (i) Merge from the image directory to your system Ebuild Contents: The Header • A header – only needs to be touched for new ebuilds • Can be copied from /usr/portage/header.txt # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ Ebuild Contents: Predefined Variables P, PN, PV, . . . Provide various combinations of the package name, version, revision, etc. D Path to install image of the package T Directory where the ebuild can create temporary files WORKDIR Path to the work directory where the package will be built – this is where you are when the ebuild script runs FILESDIR Path to the files subdirectory DISTDIR Path to the portage distfiles Ebuild Contents: Required Variables DESCRIPTION A short description of the package SRC URI URI from where the package files can be downloaded HOMEPAGE Website of the package KEYWORDS Specify the architectures the package has been tested on, and the degree of stability SLOT Defines a “slot”. This allows multiple versions of a package to coexist (think GTK+ v1 and v2). Set to 0 if there are no slots
Description: