Before
Gentoo Linux emerged (pun
intended) as a powerful force on the Linux distribution scene, software
installation on most distributions was a subject of much controversy
and frequent criticism. The RPM package manager was often at the
receiving end of the blame due to its complex dependency structures;
typing "rpm dependency hell" into Google's search engine returns over
700 entries. Debian's implementation of its own package management was
often seen as technically superior to those found in RPM-based
distributions, but many potential users were put off by Debian's other
complexities and a lack of graphical installation and configuration
utilities. And while Slackware's own package management does not suffer
from dependency issues (simply because it doesn't care about them),
many will argue that its
pkgtool and other package utilities
are rather too basic to qualify as a package management tool in the
true sense of the word.
Enter the world of Gentoo Linux. With one short command, a user can
install any application, without ever having to worry about libraries
and other dependencies. The command will download the source code of
the requested package, it will also download the source codes of all
the dependent packages (if any), then it will configure, compile and
install the package(s) without any further intervention on the user's
part. Because the vast majority of packages are compiled directly from
source code (with some exceptions, such as OpenOffice, Java, Opera,
etc.), the user has complete control over package versions,
optimizations, even optional dependencies, in some cases. In fact, the
only drawbacks when compared to binary package management tools are
longer installation times and fairly stringent hardware requirements -
the pleasure of using Gentoo Linux rises exponentially with the power
of the CPU at hand.
Portage. The main force behind Gentoo's convenient
package management is Portage. Written in Python, Portage not only
provides the all-important "emerge" command, it also groups all
packages, or ebuilds in Gentoo speak, into a logical tree-like
structure in /usr/portage/. Ebuilds can be unmasked, masked or
hard masked, with unmasked ebuilds considered stable and well-tested,
while masked ebuilds are stable, but not yet tested extensively. Hard
masked ebuilds are usually reserved for alpha or beta packages. Only
unmasked packages are installed by default, but this can be overridden
either in /etc/make.conf or on the command line like
this:
# ACCEPT_KEYWORDS="~x86" emerge packagename
The list of current masked packages is stored in
/usr/portage/profiles/package.mask. To see the available
versions of a package and their masked status in a nicely colored
output, we can use the etcat command (part of the gentoolkit
package):
# etcat -v mozilla
USE-flags. The USE-flags is a very clever concept,
serving as a central place to configure some of the most basic aspects
of the operating system and its behavior. As an example, if you prefer
to have support for ALSA for all the relevant applications, you have to
specify it as a USE-flag. Once done, these applications will be
compiled with ALSA support included. If you don't specify it centrally
in /etc/make.conf, you would have to compile the applications
with the following command:
# USE="alsa" emerge xmms
The above example is still useful in case a user wants to override the
global setting. There are over 200 USE-flags listed in
/usr/portage/profiles/use.desc; they provide many "uses" that
range from Java and SELinux support to specifying the default Japanese
input server or enabling potentially offensive items in packages. The
USE-flags also specify one of the CPU architectures - the currently
available choices include x86, ppc, ppc64, sparc, alpha, mips, hppa,
arm and amd64.
CFLAGS. Much has been said about CFLAGS on various
forums, especially by those who never read the GCC manual. Probably the
most important decision here is the use of march or
mcpu when specifying the type of processor. The former will
result in faster binaries at the expense of compatibility, while the
latter will be produce somewhat slower binaries, but will cover a wider
range of processors. As an example, specifying -mcpu=i586 will
result in binaries optimized for i586, but they will also execute on
i386; however specifying -march=i586 means that the binaries
will only execute on i586, but not on i386 CPUs. Another common CFLAG
is -O, which specifies a level of optimization ranging from
-Os (optimized for small binaries) to -O1,
-O2 or -O3 (optimized for speed). GCC provides over a
hundred different CFLAGS.
Examples. Finally, let's have a look at some practical
examples to illustrate the range of available options in Portage. The
handful of the commands listed below are just a tip of the
iceberg.
# emerge-webrsync
This is the same as emerge sync (it synchronizes the local
portage tree with the latest available portage tree on official
repositories), but useful for those users who are behind a firewall
blocking the standard rsync port 873
# nice -n19 emerge -u world
This is the same as emerge -u world (it updates all installed
packages to their latest available versions), but with a low priority
so that the compilation process has a limited effect on the user's
ability, in terms of processor resources, to perform other
tasks.
# emerge -pv packagename
Lists packages that are dependent, but not yet installed, on
packagename.
# emerge /mnt/cdrom/packagename*tbz2
Installs a binary package packagename from the mounted
CD-ROM.
# emerge info
Lists all the Portage-specific variables, such as USE, CFLAGS, COMPILER,
GENTOO_MIRRORS, etc.
If you are used to the rpm command, you can install Gentoo's
epm to query packages. It takes many of the same arguments as
rpm itself:
# epm -q packagename
Returns the installed version of packagename
# epm -qa
Returns all installed packages
# epm -qi packagename
Returns information about packagename
# epm -Va
Checks the integrity of all installed packages and reports
conflicts
# epm -e packagename
Uninstalls packagename, same as emerge unmerge
packagename
Learning about Portage is a journey in itself, a road paved with many
pleasant surprises behind every turn. There is no doubt that Portage is
one of the most powerful package management utilities available today.
(
Log in to post comments)