Portage: Gentoo Packages Management System

References

Here is a summary of these documents:

Gentoo Linux is using a packaging system inspired by the BSD ports system, with new advanced features. This system, called Portage allows to install programs, by compiling them automatically from sources, with all the optimizations for your computer, according to your choices.

Some of the advanced features Portage offers are the ability to have multiple versions and revisions of the same package in the tree, conditional dependency resolution and feature support, fine-grained package management, sandboxed safe installation, configuration file protection and profiles.

Gentoo release policy

A strict schedule with a new stable distribution every 4 months, numbered 2004.0 (in february 2004), 2004.1 (in april 2004) and so on. The package repository (portage tree) is evolving continuously. Compiled packages are created for every stable release. Newer packages are automatically compiled on your system when you install them. You can also compile the whole system during installation.

Each Gentoo installation adheres to a certain _profile_ which contains, amongst other information, the list of packages that are required for a system to function normally.

darmstadtium:balat$ ls -ald /etc/make.profile
lrwxrwxrwx  1 root root 48 fv 14 19:00 /etc/make.profile 
         -> ../usr/portage/profiles/default-linux/x86/2004.3
...

Portage

"With its high flexibility and enormous amount of features it is frequently seen as the best software management tool available for Linux."

Written in Python and Bash

The /usr/portage directory contains the _Portage tree_, a collection of _ebuilds_ (informations about packages).

Summary of commands

emerge --sync updates the portage tree

emerge --search and emerge --searchdesc search for packages in the portage tree

emerge emacs installs emacs (downloads source, compiles and installs)

emerge --pretend emacs what will be done if I do emerge emacs

emerge --fetchonly downloads (in /usr/portage/distfiles) whithout installing

emerge --unmerge emacs removes the packages emacs, but not the packages that depend on emacs

emerge --depclean removes orphaned dependencies

emerge --update --deep world Updates the whole system

emerge --update --deep --newuse world Idem when one of the USE-flags have been changed {/pre}

Packages can have the same short name. You must use fully-qualified ebuild names:

emerge dev-libs/aterm

emerge x11-terms/aterm

Install a specific version: emerge --pretend =emacs-21.3-r3

Install a precompiled package: emerge --usepkg --getbinpkg gnumeric

Stub packages: packages without any real content, used to install a collection of packages (ex: kde).

USE flags

When you install a Gentoo system, you need to define a _USE flag_.

USE variables are used to tell portage:

  • what package you want to install
  • what features a certain package should support
E.g. if you don't put the kde keyword in your USE flags,
  • packages that have optional KDE support will be compiled without it
  • packages that have optional KDE dependency will be installed without
installing the KDE libraries (as dependencies).

Default USE-flag is defined in /etc/make.profile/make.defaults:

USE="oss apm arts avi berkdb bitmap-fonts crypt cups encode fortran f77 font-server 
foomaticdb gdbm gif gpm gtk gtk2 imlib jpeg kde gnome libg++ libwww mad mikmod motif 
mpeg ncurses nls oggvorbis opengl pam pdflib png python qt quicktime readline
sdl spell ssl svga tcpd truetype truetype-fonts type1-fonts X xml2 xmms xv zlib"

You can add your own flags in /etc/make.conf, for ex:

USE="-kde -qt msn yahoo jabber"

You can declare USE-flags for individual packages (not system-wide) in the file /etc/portage/package.use.

Or just for a moment: USE="-java" emerge mozilla

List of available USE-flags in /usr/portage/profiles/use.desc:

…
gtk	  - Adds support for x11-libs/gtk+ (The GIMP Toolkit)
gtk2	 - Use gtk+-2.0.0 over gtk+-1.2 in cases where a program supports both.
gtkhtml - Adds support for gnome-extra/gtkhtml
guile	- Adds support for dev-util/guile (interpreter for Scheme)
icc	  - Use the Intel C++ Compiler if the package supports it
icc-pgo - Enable PGO data generation or use when use icc.
imap	 - Adds support for IMAP
…

You can also use _local_ USE-flags (listed in /usr/portage/profiles/use.local.desc):

…
app-editors/emacs:multi-tty - Add multi-tty support
app-editors/emacs:nosendmail - If you do not want to install any MTA
…

Some packages don't only listen to USE-flags, but also provide USE-flags. When you install such a package, the USE-flag they provide is added to your USE setting. (ex: kde provided by kde-base/kdebase)

Ebuilds

Ebuild scripts are the basis for the entire portage system. They contain all the information required to download, unpack, compile and install a set of sources, as well as how to perform any optional pre/post install/removal or configuration steps.

Written in bash.

Naming conventions

pkg-ver{_suf{#}}{-r#}.ebuild where _suf is one of _alpha < _beta < _pre < _rc < (no suffix) < _p and -r# is gentoo specific revision number.

For ex linux-2.4.0_pre10-r2.ebuild

Content of ebuilds

Header

Variables (see some of them below)

Bash functions

You can define: pkg_setup, src_unpack, src_compile, src_install, src_test, pkg_preinst, pkg_postinst, pkg_config, etc.

using predefined function...

More info here.

example of ebuild (attchement) : emacs-21.4-r1.ebuild

Dependencies

DEPEND are build dependencies, RDEPEND run-time dependencies.

Example, for libbonobo:

IUSE="doc"

RDEPEND=">=dev-libs/glib-2.0.1 >=gnome-base/orbit-2.8 >=dev-libs/libxml2-2.4.20 !gnome-base/bonobo-activation" DEPEND="${RDEPEND} >=dev-util/pkgconfig-0.12.0 >=dev-util/intltool-0.17 doc? ( >=dev-util/gtk-doc-0.10 )"

For emacs:

IUSE="X Xaw3d gnome leim lesstif motif nls nosendmail"

RDEPEND="sys-libs/ncurses sys-libs/gdbm X? ( virtual/x11 >=media-libs/libungif-4.1.0.1b >=media-libs/jpeg-6b-r2 >=media-libs/tiff-3.5.5-r3 >=media-libs/libpng-1.2.1 !arm? ( Xaw3d? ( x11-libs/Xaw3d ) motif? ( lesstif? ( x11-libs/lesstif ) !lesstif? ( >=x11-libs/openmotif-2.1.30 ) ) gnome? ( gnome-base/gnome-desktop ) ) ) nls? ( sys-devel/gettext ) !nosendmail? ( virtual/mta )" DEPEND="${RDEPEND} >=sys-devel/autoconf-2.58"

SLOTs

With Portage different versions of a single package can coexist on a system. Other distributions are using different names (freetype and freetype2 e.g.). Portage is using slots. E.g. freetype has ebuilds with SLOT="1", and ebuilds with SLOT="2".

Virtuals

Several packages can provide the same functionality. For example, metalogd, sysklogd and syslog-ng are all declaring PROVIDE="virtual/logger"

Masked packages

All packages, even unstable are in the portage tree, but till they are not considered stable, they are masked by keywords. E.g. KEYWORDS="x86 ppc ~alpha -hppa ~amd64" (avalaible on x86 and ppc, not available on hppa, not tested sufficiently on alpha and amd64, not tested on other architectures)

Other ways to have packages masked:

  • put there names in the file package.mask
  • package not compatible with your profile (see file /etc/make.profile/packages).
Packages with keyword x86 belong to the stable branch of the distribution for x86 architecture, packages with keyword ~x86 belong to the testing branch, etc.

To install the package mldonkey from testing:

ACCEPT_KEYWORDS="~x86" emerge mldonkey

Or you can use:

  • the file /etc/portage/package.keywords to accept some keywords for specific packages
  • the file /etc/portage/package.unmask to install masked packages
  • the file /etc/portage/package.mask to mask packages yourself

Configuration file protection

CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.3/env 
/usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/share/config 
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ 
/usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"

A file that would be written in such a protected location is renamed and the user is warned about the presence of a newer version of the (presumable) configuration file.

eclasses

When writing ebuilds, you can use _eclasses_. eclasses are modules of shared code. They are written in bash and have the same syntax as ordinary ebuilds, and are sourced ('inherited') by ebuilds and other eclasses, to provide default settings and functionality across many similar ebuilds.

This is used to ensure maximum code reuse among similar ebuilds.

More info here

Metadata

In every package directory of the portage tree, there is a file called metadata.xml containing informations about the package (maintainer, email, name, description...).

Other portage features

  • Distributed compiling
  • Caching compilation

Other portage tools

etc-update

etc-update is a tool to help updating config file. Run-it after installing or updating a package.

dispatch-conf

Using dispatch-conf you are able to merge updates to your configuration files while keeping track of all changes. dispatch-conf stores the differences between the configuration files as patches or by using the RCS revision system.

quickpkg

With quickpkg you can create archives of the packages that are already merged on your system. (for ex to create prebuilt packages)

quickpkg curl arts procps

ebuild

The ebuild application is a lower level interface to the Portage system. Using this application you can execute specific actions against a given ebuild. For instance, you can perform the individual merging steps by yourself.

    • Main.VincentBalat - 23 Feb 2005
{metadata}

Topics Wp2

{metadata}

Version 1.13 last modified by StephaneLauriere on 10/11/2005 at 17:17

Comments 0

No comments for this document

Attachments 1

BIN
emacs-21.4-r1.ebuild 1.1
PostedBy: VincentBalat on 26/09/2005 (4kb )

Creator: VincentBalat on 2005/05/12 21:49
Copyright EDOS Consortium
1.1.1