IMPORTANT: this document is probably out of date, use as hints for bootstrapping only!
How to bootstrap Gentoo Prefix on your UNIX-like system
Bootstrapping on a UNIX-like system can range from being fairly simple to just a downright disaster. Systems that typically belong to the "simple" group, are Mac OS X, FreeBSD and recent distributions of Linux not being SuSE or Ubuntu. The "disaster" systems are NetBSD, OpenBSD and Ubuntu: they are NOT supported. Somewhere in the middle is Solaris 10, with OpenIndiana being a shift towards the "simple" group.
Don't let yourself be scared away immediately by this. For instance, a bootstrap on Solaris 10 may be quite flawless, because many went ahead of you, and ironed out a smooth path.
In general, when bootstrapping, make sure you have a clean and lean environment. Exclude any software providing repositories such as Blastwave, Fink, MacPorts, Homebrew, ports, etc. by default, e.g. make sure your shell doesn't automatically load any environment variables that setup those repositories. Think of
PKG_CONFIG_PATH and the always harmful
LD_LIBRARY_PATH. This is important, because Prefix tends to be very sensitive about this. Afterall, it's whole purpose is to provide all of those tools by itself without external help!
If you happen to run into trouble, don't despair (immediately). Feel free to ask in the
gentoo-prefix IRC channel, or the gentoo-alt mailing list.
IMPORTANT: Gentoo Prefix does NOT require root-privileges. You don't have to be root to bootstrap a Prefix installation. In fact, we highly discourage people to bootstrap as root-user!
As prerequisite, you have to have a working compiler, e.g.
make installed. Without a compiler, linker and all that is required by those to compile a program such as system headers and libraries, any Prefix bootstrap will fail almost immediately.
On Mac OS X systems, the compiler, linker, system headers and libraries are provided by Xcode, or the Xcode command line tools, available through the AppStore and ADC respectively.
On OpenIndiana, you need the a compiler, system headers and more installed using
pkg. Perform the following two commands as super user:
pkg set-publisher -p http://pkg.openindiana.org/sfe/and
pkg install sfe/developer/gcc developer/library/lint system/header. The compiler and many useful other utilities will be available in
On Solaris systems many useful utilities such as
gccare located in /usr/sfw/bin.
The first step is to choose a path to install into. We refer to this path as "Prefix path", stored in the variable
EPREFIX. Some suggestion for your Prefix path is $HOME/gentoo. Whatever you chose, make sure you set it in your environment:
$ export EPREFIX="$HOME/gentoo"
tcsh users can use
setenv EPREFIX "$HOME/gentoo"instead.
Next, add the following paths in your soon to be Prefix to your
PATH environment. $EPREFIX/bin, $EPREFIX/usr/bin, $EPREFIX/tmp/bin and $EPREFIX/tmp/usr/bin. Adding these paths makes sure that they will be available later on in the process.
$ export PATH="$EPREFIX/usr/bin:$EPREFIX/bin:$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:/usr/bin:/bin"
On Solaris you need the add the following paths to find the GNU compiler, linker,
makeand some other tools: /usr/sfw/bin, /usr/sfw/<arch>-sun-solaris<version>/bin. Use
export PATH="$PATH:/usr/sfw/bin:/usr/sfw/i386-sun-solaris2.10/bin"for x86-based Solaris 10. Similar for sparc-based Solaris 10, use
sparc-sun-solaris2.10instead. Solaris 11 users have to replace the
Most notably on Mac OS X and Solaris systems, both 32-bits and 64-bits modes are possible. These are so-called multilib systems. If you know what this means, and you don't like the default chosen by the bootstrap script, you can set your
CHOSTenvironment variable to your liking. Solaris/OpenSolaris/OpenIndiana systems always default to 32-bits, so if you want to end up with a 64-bits native Prefix installation, then set your
CHOSTvariable accordingly to either
sparcv9-sun-solaris2.10for Solaris 10, use
2.11for versions later, including OpenIndiana. Mac OS X Intel-based systems before Lion (10.7) always default to 32-bits. From Lion and on, the default is 64-bits. If you want a 64-bits native Prefix on pre-Lion systems, set your
x86_64-apple-darwin9for Leopard, or
x86_64-apple-darwin10for Snow Leopard. If you want to end up with a 32-bits native Prefix installation on Lion, set your
PATH is set, start with downloading the bootstrap script from . This script needs bash. If you don't have bash on your system (typically BSD users don't), you'll have to bootstrap bash first, using . You can use
ftp if they are available. Downloading them with a web-browser is also fine.
If your system lacks bash by default, bootstrap it, using:
chmod 755 bootstrap-bash.sh; ./bootstrap-bash.sh $EPREFIX/tmpand rehash afterwards:
hash -r(sh) or
From the directory where the bootstrap script was stored execute the following commands:
$ chmod 755 bootstrap-prefix.sh $ ./bootstrap-prefix.sh $EPREFIX stage1
The stage1 should have installed some basic packages necessary to run Portage, without Portage's help. When stage1 finished successfully, a Portage can be installed.
The Portage tree installed by default is a known to be good snapshot. This can, however, for various reasons not be good enough, in which case the lastest snapshot available can be used instead. Only use this when you have problems with the known to be good snapshot. If you want to use the lastest snapshot when bootstrapping, export LATEST_TREE_YES=1 in your environment before running the following:
$ ./bootstrap-prefix.sh $EPREFIX stage2
We continue with emerging some of the core toolchain packages that make sure we compile and link everything taking the Prefix into account. Next to that this step emerges the full set of applications and that Portage needs and removes the tools installed by stage1. It finishes things by getting an up-to-date tree (removing any hacks stage2 applied to the activated profile) and emerging everything in the
$ ./bootstrap-prefix.sh $EPREFIX stage3
Because we installed some new applications, most notably Portage, we will instruct bash to reconsider all paths we have:
$ hash -r
tcsh users can use the
Now is a good time to set the preferences for your Prefix. This includes customisations such as general
MAKEOPTS in $EPREFIX/etc/portage/make.conf. Be conservative with
CFLAGS! The stage3 function already set some moderate defaults.
You can consider adding CPU-specific tuning flags to
CFLAGS. If you don't know what your CPU is, or what this would be good for, just skip this note. Intel-based Mac OS X users (e.g. MacBook, CoreDuo) should at least have
-march=prescotthere to avoid compilation errors due to SSE instructions not being enabled. Core2Duo users can use
-march=core2. Mac OS X PPC users can use their CPU's alias to enable CPU specific tuning, e.g.
-mcpu=G5 -mtune=G5. For other systems, you might simply want to use
-march=<your-cpu>. Google the right value, or just forget about this setting. Note that setting a wrong value breaks things.
Since we have everything in place for a self-catered rebuild, we can start the final stage to install the Prefix system. This final stage recompiles everything in the system, but now all packages can be compiled with tools from the Prefix, instead of those from the host system.
$ emerge -e system
system has emerged successfully, your Prefix will be set up properly, and you can emerge the whichever tools you choose from the Prefix tree.
Using the Prefix
To use your bootstrapped Prefix environment, you best start a shell from the Prefix, such that your path and other environment variables are set correctly. To facilitate in this, a small helper script can be created by the bootstrap script.
$ cd $EPREFIX/usr/portage/scripts $ ./bootstrap-prefix.sh $EPREFIX startscript
After running this, a script
startprefix will be present in
$EPREFIX. You can freely move the script to e.g. your homedir for convenience. Running the script will drop you into a Prefix shell, where for example
emerge is directly at your disposal. Enjoy your Prefix!
We would like to thank the following authors and editors for their contributions to this guide:
- Fabian Groffen