Presented by Reed Gregory on August 27, 2003
Table of Contents
- 1. Gentoo In My Words
- 2. Even More About Portage
- 2.1. make.globals
- 2.2. make.conf
- 2.3. Portage Tree Structure
- 2.4. Ebuild Files
- 2.5. Building Your Own Ebuilds
- 2.6. Using Emerge
- 2.7. Installing Packages
1. Gentoo In My Words
Gentoo is a source-based distro. The unique thing about gentoo is that
the default package system uses source code and not pre-compiled binaries.
Gentoo lets you built everything and I mean everything on your system with
whatever options you would like. If you install Gentoo from stage1, then
you actually bootstrap your own system buy compiling your own compiler.
Although a fresh install from stage1 will take a good while depending on
your system, I feel like it is a good trade off for getting a system just
the way I like it. The portage system also make it even easier to use your
own packages, and also add ebuilds for packages that are not in the system.
Gentoo allows to have so much control over your system in a nice manageable
way.
2. Even More About Portage
The two main portage config files are /etc/make.globals and
/etc/make.conf.
Included below are examples of both files.
2.1. make.globals
Click here to download the example make.globals.
# Copyright 2002 Daniel Robbins, Gentoo Technologies, Inc.
# System-wide defaults for the Portage system
#
#
# ***************************************************
# **** CHANGES TO make.conf *OVERRIDE* THIS FILE ****
# ***************************************************
# ** Incremental Variables Accumulate Across Files **
# **
# ***************************************************
USE_ORDER="env:conf:auto:defaults"
GENTOO_MIRRORS="http://www.ibiblio.org/pub/Linux/distributions/gentoo"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
# Host-type
CHOST=i686-pc-linux-gnu
PORTAGE_TMPDIR=/var/tmp
PORTDIR=/usr/portage
DISTDIR=$PORTDIR/distfiles
PKGDIR=$PORTDIR/packages
RPMDIR=$PORTDIR/rpm
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config"
CONFIG_PROTECT_MASK="/etc/gconf"
# Options passed to make during the build process
MAKEOPTS="-j2"
# Fetching command (5 tries, passive ftp for firewall compatibility)
FETCHCOMMAND="/usr/bin/wget -t 5 --passive-ftp URI -P DISTDIR"
RESUMECOMMAND="/usr/bin/wget -c -t 5 --passive-ftp URI -P DISTDIR"
CFLAGS="-O2 -mcpu=i686 -pipe"
CXXFLAGS=$CFLAGS
# Debug build -- if defined, binaries won't be stripped
#DEBUGBUILD=true
# Default maintainer options
#FEATURES="digest sandbox noclean noauto buildpkg"
# Default user options
FEATURES="sandbox ccache"
# By default output colored text where possible, set to
# "true" to output only black&white text
NOCOLOR="false"
# By default wait 5 secs before cleaning a package
CLEAN_DELAY="5"
# Set to yes automatically run "emerge clean" after each merge
# Important, as without this you may experience missing symlinks when
# downgrading libraries during a batch (world/system) update.
AUTOCLEAN="yes"
# Number of times 'emerge rsync' will run before giving up.
RSYNC_RETRIES="3"
#
#
# ***************************************************
# **** CHANGES TO make.conf *OVERRIDE* THIS FILE ****
# ***************************************************
# ** Incremental Variables Accumulate Across Files **
# **
# ***************************************************
2.2. make.conf
Click here to download the example make.conf.
# Copyright 2000-2002 Daniel Robbins, Gentoo Technologies, Inc.
# Contains local system settings for Portage system
# Build-time functionality
# ========================
#
# The USE variable is used to enable optional build-time functionality. For
# example, quite a few packages have optional X, gtk or GNOME functionality
# that can only be enabled or disabled at compile-time. Gentoo Linux has a
# very extensive set of USE variables described in our USE variable HOWTO at
# http://www.gentoo.org/doc/use-howto.html
#
# The available list of use flags with descriptions is in your portage tree.
# Use 'less' to view them:
#
# Example:
USE="mmx sse apm oggvorbis pcmcia pnp pda encode pam ssl cups X xv avi imap
fbcon opengl mpeg kde qt arts quicktime oss gnome gtk gtk2 evo dvd gtkhtml xmms sdl
gif jpeg png tiff mozilla spell truetype pdflib tetex java berkdb samba esd dvd
# Host Setting
# ============
#
# If you are using a Pentium Pro or greater processor, leave this line as-is;
# otherwise, change to i586, i486 or i386 as appropriate. All modern systems
# (even Athlons) should use "i686-pc-linux-gnu"
#
CHOST="i686-pc-linux-gnu"
# Host and optimization settings
# ==============================
#
# For optimal performance, enable a CFLAGS setting appropriate for your CPU
#
# -mcpu=
# breaking compatibility with other CPUs.
#
# -march=
# for the particular CPU; this will break compatibility with older CPUs (for
# example, -march=athlon-xp code will not run on a regular Athlon, and
# -march=i686 code will not run on a Pentium Classic.
#
# CPU types supported in gcc-3.2 and higher: athlon-xp, athlon-mp, athlon-4,
# athlon-tbird, athlon, duron, k6, k6-2, k6-3, i386, i486, i586 (Pentium), i686
# (Pentium Pro), pentium, pentium-mmx, pentiumpro, pentium2 (Celeron), pentium3,
# and pentium4. Note that Gentoo Linux 1.4 and higher include at least gcc-3.2.
#
# CPU types supported in gcc-2.95*: k6, i386, i486, i586 (Pentium), i686
# (Pentium Pro), pentium, pentiumpro Gentoo Linux 1.2 and below use gcc-2.95*
#
# Decent examples:
#
#CFLAGS="-mcpu=athlon-xp -O3 -pipe"
CFLAGS="-march=pentium3 -O3 -pipe"
# If you set a CFLAGS above, then this line will set your default C++ flags to
# the same settings. If you don't set CFLAGS above, then comment this line out.
CXXFLAGS="$CFLAGS"
# Advanced Masking
# ================
#
# Gentoo is using a new masking system to allow for easier stability testing
# on packages. KEYWORDS are used in ebuilds to mask and unmask packages based
# on the platform they are set for. A special form has been added that
# indicates packages and revisions that are expected to work, but have not yet
# been approved for the stable set. '~arch' is a superset of 'arch' which
# includes the unstable, in testing, packages. Users of the 'x86' architecture
# would add '~x86' to ACCEPT_KEYWORDS to enable unstable/testing packages.
# '~ppc', '~sparc', '~sparc64' are the unstable KEYWORDS for their respective
# platforms. DO NOT PUT ANYTHING BUT YOUR SPECIFIC ~ARCHITECTURE IN THE LIST.
# IF YOU ARE UNSURE OF YOUR ARCH, OR THE IMPLICATIONS, DO NOT MODIFY THIS.
#
#ACCEPT_KEYWORDS="~arch"
# Portage Directories
# ===================
#
# Each of these settings controls an aspect of portage's storage and file
# system usage. If you change any of these, be sure it is available when
# you try to use portage. *** DO NOT INCLUDE A TRAILING "/" ***
#
# PORTAGE_TMPDIR is the location portage will use for compilations and
#
#
#PORTAGE_TMPDIR=/var/tmp
#
# PORTDIR is the location of the portage tree. This is the repository
#
#
#PORTDIR=/usr/portage
#
# DISTDIR is where all of the source code tarballs will be placed for
#
#
#
#
#DISTDIR=$PORTDIR/distfiles
#
# PKGDIR is the location of binary packages that you can have created
#
#
#PKGDIR=$PORTDIR/packages
#
# PORTDIR_OVERLAY is a directory where local ebuilds may be stored without
#
#
PORTDIR_OVERLAY=/usr/portage.local
# Fetching files
# ==============
#
# If you need to set a proxy for wget or lukemftp, add the appropriate "export
# ftp_proxy=
# all users on your system should use them.
#
# Portage uses wget by default. Here are some settings for some alternate
# downloaders -- note that you need to merge these programs first before they
# will be available.
#
# Lukemftp (BSD ftp):
#FETCHCOMMAND="/usr/bin/lukemftp -s -a -o DISTDIR/FILE URI"
#RESUMECOMMAND="/usr/bin/lukemftp -s -a -R -o DISTDIR/FILE URI"
#
# Prozilla (turbo downloader)
FETCHCOMMAND='/usr/bin/proz --no-getch $URI -P $DISTDIR'
# Advanced Features
# =================
#
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
GENTOO_MIRRORS="http://www.ibiblio.org/pub/Linux/distributions/gentoo"
# MAKEOPTS provides extra options that may be passed to 'make' when a
#
#
#
#MAKEOPTS="-j2"
#
# AUTOCLEAN enables portage to automatically clean out older or overlapping
#
#
#AUTOCLEAN="yes"
#
# FEATURES are settings that affect the functionality of portage. Most of
#
#
#
#
#FEATURES="sandbox ccache buildpkg"
#
# RSYNC_RETRIES sets the number of times portage will attempt to retrieve
#
#
#RSYNC_RETRIES="3"
2.3. Portage Tree Structure
The portage tree divides different packages into categories. For
example wine is in the app-emulation category. This helps to find similar
packages and keeps the structure nice and manageable. This is very similar
to the ports system on BSD machines.
2.4. Ebuild Files
Below is the ebuild file for the libogg-1.0 package. The structure of
ebuild packages are just text files so this makes the portage tree
relatively small. When you rsync your tree with the server, it only has
to download and/or deletes text files in your local portage tree to sync
up.
2.5. Building Your Own Ebuilds
You can easily build your own ebuilds. This is where the local portage
tree comes in real handy. You could put your ebuild files in the main
portage tree but they will be deleted when your rsync the tree. You need
an ebuild file, a Changelog and a "files" directory that will hold the
digest file for the files needed to be downloaded to install your
package.
2.6. Using Emerge
Let’s say I am in the mood to start managing my finances and I know
that gnucash is a good program to use. I need to see if I have it
installed. I can do a search by using the built in search of emerge.
$ emerge search gnucash
Searching...
[ Results for search key : gnucash ]
[ Applications found : 1 ]
*
As you can see above, it says I do have gnucash installed and it is
the latest version available. It also gives me a description of what
the package is. The search method of emerge only searches on the name
of the package. For example if I search for wireless, then kismet will
not show up. But I can browse the portage tree to see packages that are
in the wireless section.
2.7. Installing Packages
Now, I am interested in doing some project management and one of my
friends told me about mrproject. So what do I need to get it installed.
We again use emerge in the following way:
$ emerge --pretend --update mrproject
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild
[ebuild
[ebuild
So it seems to if I do install mrproject, it will first update
libgnomecanvas, then install libmrproject and mrproject in that order.
It is very important to say that this is a short-circuited operation.
If the ebuild of libgnomecanvas breaks, then it will not change the
system. Emerge builds everything in a sandbox and only merges it with
the system if everything checks out ok. This pretends half installed
packages.