Gentoo Logo

Gentoo Prefix Bootstrap Process for Solaris

1.  Bootstrapping on Solaris

Introduction

Bootstrapping on Solaris 10 and higher is relatively simple if you compare it to versions below 10. It comes with bash3 and a gcc-3.4.3 compiler by default, and with the download manager wget. If you still are in the process of installing Solaris, make sure you install wget, to make things easier later on.

Though being relatively simple, Solaris is one of the more "Spartan" platforms to bootstrap on, and for sure not as easy as for instance a Linux distribution or Mac OS X. However, don't despair when things go wrong, it's just known to be hard(er), but not impossible. Feel free to ask in the gentoo-prefix IRC channel, or mailing list.

Bootstrapping

As prerequisite, you have to have gcc and wget installed. If you didn't install wget, you have to acquire the necessary files in another way, e.g. via a brower, NFS, or scp.

Note: wget and gcc are usually 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:

Code Listing 1.1: Export EPREFIX variable

$ export EPREFIX="$HOME/gentoo"
        

Note: 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. Additionally, you need the following paths to find the gnu compiler, linker, make and some other tools: /usr/sfw/bin, /usr/sfw/<arch>-sun-solaris<version>/bin, /usr/bin and /bin.

Code Listing 1.2: Add Prefix and utility paths to your PATH on Solaris 10/x86

$ export PATH="$EPREFIX/usr/bin:$EPREFIX/bin:$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:/usr/sfw/bin:/usr/sfw/i386-sun-solaris2.10/bin:/usr/sfw/sparc-sun-solaris2.10/bin:/usr/bin:/bin"
        

Note: Solaris 11 users need 2.11 instead of 2.10 in xxxx-sun-solaris2.10 in PATH above.

If you want to end up with a 64-bits native Prefix installation, then set your CHOST variable accordingly to either x86_64-pc-solaris2.10 or sparcv9-sun-solaris2.10 for Solaris 10. You only need to do this if you want a 64-bits native Prefix!

Now the path is set, start with downloading the bootstrap script from http://overlays.gentoo.org/proj/alt/browser/trunk/prefix-overlay/scripts/bootstrap-prefix.sh?format=txt. From the directory where the bootstrap script was stored execute the following commands:

Code Listing 1.3: Use the bootstrap script

$ chmod 755 bootstrap-prefix.sh
$ ./bootstrap-prefix.sh $EPREFIX tree
$ ./bootstrap-prefix.sh $EPREFIX/tmp make
$ ./bootstrap-prefix.sh $EPREFIX/tmp wget
$ ./bootstrap-prefix.sh $EPREFIX/tmp sed
$ ./bootstrap-prefix.sh $EPREFIX/tmp coreutils (try coreutils6 if this fails)
$ ./bootstrap-prefix.sh $EPREFIX/tmp findutils5
$ ./bootstrap-prefix.sh $EPREFIX/tmp tar (try tar22 if this fails)
$ ./bootstrap-prefix.sh $EPREFIX/tmp patch
$ ./bootstrap-prefix.sh $EPREFIX/tmp grep
$ ./bootstrap-prefix.sh $EPREFIX/tmp gawk
$ ./bootstrap-prefix.sh $EPREFIX/tmp bash
$ ./bootstrap-prefix.sh $EPREFIX/tmp zlib
$ ./bootstrap-prefix.sh $EPREFIX/tmp python
$ ./bootstrap-prefix.sh $EPREFIX portage
        

Note: Please note that wget, sed, python, etc. are installed in $EPREFIX/tmp!

The script will setup the $EPREFIX directory, download a portage tree snapshot, unpack it and download and install portage. Afterwards it will try to setup some sane defaults. Because we installed some new applications, we will instruct bash to reconsider all paths we have:

Code Listing 1.4: rehash in bash

$ hash -r
        

Note: tcsh users can use the rehash command.

We continue adding some necessary tools which will deal with many errors and warnings you might see during emerging.

Code Listing 1.5: emerge sed

$ emerge --oneshot sed
        

Next, we emerge the bash shell Portage heavily relies on. The same holds for wget, the download manager. Since its dependencies cannot be compiled at this stage, we ignore those for the moment.

Code Listing 1.6: emerge bash

$ emerge --oneshot --nodeps bash (avoid deps that install scripts with shebang /bin/sh)
        

Note: It is safe to ignore the "1 config files in XXX need updating" message that appears till the end of the bootstrap process.

Note: If bash fails with an error message about missing 'yacc' then you can run: ./bootstrap-prefix.sh $EPREFIX/tmp m4 ; ./bootstrap-prefix.sh $EPREFIX/tmp bison

Now, we will emerge a compiler which will use the gnu linker. This is a requirement for many packages that follow in the bootstrap process, in particular Perl. The gcc compiler shipped by Sun uses the Solaris native linker, which is as "Spartan" as the whole system. The packages to emerge include the baselayout package. Some, if not many, scripts and tools within a Gentoo system assume the availability of the baselayout package for all communication using the Gentoo colour scheme.

Code Listing 1.7: emerge linker and compiler

$ emerge --oneshot --nodeps sys-apps/baselayout-prefix
$ emerge --oneshot --nodeps app-arch/xz-utils
$ emerge --oneshot --nodeps sys-devel/m4
$ emerge --oneshot --nodeps sys-devel/flex
$ emerge --oneshot --nodeps sys-devel/bison
$ emerge --oneshot --nodeps sys-devel/binutils-config
$ emerge --oneshot --nodeps sys-devel/binutils
$ emerge --oneshot --nodeps sys-devel/gcc-config
$ emerge --oneshot --nodeps "=sys-devel/gcc-4.2*"
        

We continue getting more tools in our Prefix. We no longer ignore dependencies all the time, so a lot of packages will be emerged at this stage. Slowly our Prefix gets more robust as we progress here.

Code Listing 1.8: emerge several tools

$ emerge --oneshot sys-apps/coreutils
$ emerge --oneshot sys-apps/findutils
$ emerge --oneshot app-arch/tar
$ emerge --oneshot sys-apps/grep
$ emerge --oneshot sys-devel/patch
$ emerge --oneshot sys-apps/gawk
$ emerge --oneshot sys-devel/make
$ emerge --oneshot sys-libs/zlib
$ emerge --oneshot --nodeps sys-apps/file
$ emerge --oneshot --nodeps app-admin/eselect
$ emerge --oneshot app-misc/pax-utils
$ emerge --oneshot "<net-misc/wget-1.13.4-r1" (until we fix #393277)
        

Now we have a good bunch of programs that Portage needs, we can replace the bootstrapped Portage by a properly installed one, using Portage itself. Also here a few dependencies are first emerged, such as the language Portage is written in: python. We need to temporarily tell Portage that the bootstrapped Portage can be overwritten.

Code Listing 1.9: emerge portage

$ env FEATURES="-collision-protect" emerge --oneshot sys-apps/portage
        

Now we have emerged everything we bootstrapped before, we remove the temporary directory and its use as it is no longer necessary.

Code Listing 1.10: remove tmp directory

$ rm -Rf $EPREFIX/tmp/*
$ hash -r
        

Before we do any further merges, we are going to update our tree. Updating the tree is done using:

Code Listing 1.11: Updating the tree

$ emerge --sync
        

Before we can finish emerging the system set, we need to work around a circular dependency of gcc on mpc, and mpc on gcc.

Code Listing 1.12: emerge an older mpc

$ emerge "<dev-libs/mpc-0.9"
        

Next, we let Portage emerge all packages that complete a system install that we eventually need to finalise this Prefix installation.

Code Listing 1.13: emerge system

$ env USE=-git emerge -u system
        

Now is a good time to set the preferences for our soon to be Prefix. This includes customisations such as general USE-flags, CFLAGS and MAKEOPTS in $EPREFIX/etc/make.conf. Be conservative with CFLAGS! Note that the code below is an example, and is meant for inspiration only.

Code Listing 1.14: Customising the Prefix installation - example

$ echo 'USE="unicode nls"' >> $EPREFIX/etc/make.conf
$ echo 'CFLAGS="-O2 -pipe"' >> $EPREFIX/etc/make.conf
$ echo 'CXXFLAGS="${CFLAGS}"' >> $EPREFIX/etc/make.conf
        

It is likely that you emerged a newer GCC than the 4.2 version we used during the bootstrap. Since we reinstall all packages, we like to take advantage of this newer GCC. By default, this newer GCC will not be enabled. Check the output of gcc-config -l, and make sure that the newest compiler is selected (marked by an asterisk). Another GCC can be selected by running gcc-config <number>.

Code Listing 1.15: activating the most recent compiler

$ gcc-config -l
 [1] i386-pc-solaris2.10-4.2.4 *
 [2] i386-pc-solaris2.10-4.5.3
$ gcc-config 2
 * Switching native-compiler to i386-pc-solaris2.10-4.5.3 ...
$ gcc-config -l
 [1] i386-pc-solaris2.10-4.2.4
 [2] i386-pc-solaris2.10-4.5.3 *
        

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.

Code Listing 1.16: doing the final system installation

$ emerge -e system
        

After 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.

Code Listing 1.17: Creating a start-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!



Print

Page updated January 27, 2012

Summary: How to bootstrap Gentoo Prefix on your Solaris system

Fabian Groffen
Author

Donate to support our development efforts.

Copyright 2001-2012 Gentoo Foundation, Inc. Questions, Comments? Contact us.