<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE sections SYSTEM "/dtd/book.dtd">

<!-- The content of this document is licensed under the CC-BY-SA license -->
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->

<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/Attic/hb-install-mips-system.xml,v 1.1 2006/08/30 22:52:28 nightmorph Exp $ -->

<sections>

<version>7.0</version>
<date>2006-08-30</date>

<section>
<title>Chrooting</title>
<!--<subsection>	MIPS install media doesn't include mirrorselect
<title>Optional: Selecting Mirrors</title>
<body>

<p>
In order to download source code quickly it is recommended to select a fast
mirror. Portage will look in your <path>make.conf</path> file for the
GENTOO_MIRRORS variable and use the mirrors listed therein. You can surf to
our <uri link="/main/en/mirrors.xml">mirror list</uri> and search
for a mirror (or mirrors) close to you (as those are most frequently the 
fastest ones), but we provide a nice tool called <c>mirrorselect</c> which
provides you with a nice interface to select the mirrors you want.
</p>
  
<pre caption="Using mirrorselect for the GENTOO_MIRRORS variable">
# <i>mirrorselect -i -o &gt;&gt; /mnt/gentoo/etc/make.conf</i>
</pre>

<warn>
Do not select any IPv6 mirrors. Our stages currently do not support IPv6.
</warn>

<p>
A second important setting is the SYNC setting in <path>make.conf</path>. This
variable contains the rsync server you want to use when updating your Portage
tree (the collection of ebuilds, scripts containing all the information Portage
needs to download and install software). Although you can manually enter a SYNC
server for yourself, <c>mirrorselect</c> can ease that operation for you:
</p>

<pre caption="Selecting an rsync mirror using mirrorselect">
# <i>mirrorselect -i -r -o &gt;&gt; /mnt/gentoo/etc/make.conf</i>
</pre>

<p>
After running <c>mirrorselect</c> it is adviseable to double-check the settings
in <path>/mnt/gentoo/etc/make.conf</path> !
</p>

</body>
</subsection>-->
<subsection>
<title>Copy DNS Info</title>
<body>

<p>
One thing still remains to be done before we enter the new environment and that
is copying over the DNS information in <path>/etc/resolv.conf</path>. You need
to do this to ensure that networking still works even after entering the new
environment. <path>/etc/resolv.conf</path> contains the nameservers for your
network.
</p>

<pre caption="Copy over DNS information">
<comment>(The "-L" option is needed to make sure we don't copy a symbolic link)</comment>
# <i>cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf</i>
</pre>

</body>
</subsection>
<subsection>
<title>Mounting the /proc and /dev Filesystems</title>
<body>

<p>
Mount the <path>/proc</path> filesystem on <path>/mnt/gentoo/proc</path> to
allow the installation to use the kernel-provided information within the
chrooted environment, and then mount-bind the <path>/dev</path> filesystem.
</p>

<pre caption="Mounting /proc and /dev">
# <i>mount -t proc none /mnt/gentoo/proc</i>
# <i>mount -o bind /dev /mnt/gentoo/dev</i>
</pre>

</body>
</subsection>
<subsection>
<title>Entering the new Environment</title>
<body>

<p>
Now that all partitions are initialized and the base environment
installed, it is time to enter our new installation environment by
<e>chrooting</e> into it. This means that we change from the current
installation environment (Installation CD or other installation medium) to your
installation system (namely the initialized partitions).
</p>

<p>
This chrooting is done in three steps. First we will change the root
from <path>/</path> (on the installation medium) to <path>/mnt/gentoo</path> 
(on your partitions) using <c>chroot</c>. Then we will create a new environment
using <c>env-update</c>, which essentially creates environment variables.
Finally, we load those variables into memory using <c>source</c>.
</p>

<pre caption = "Chrooting into the new environment">
# <i>chroot /mnt/gentoo /bin/bash</i>
# <i>env-update</i>
>> Regenerating /etc/ld.so.cache...
# <i>source /etc/profile</i>
# <i>export PS1="(chroot) $PS1"</i>
</pre>

<p>
Congratulations! You are now inside your own Gentoo Linux environment.
Of course it is far from finished, which is why the installation still
has some sections left :-)
</p>

</body>
</subsection>
</section>

<section>
<title>Configuring Portage</title>
<subsection>
<title>Updating the Portage tree</title>
<body>

<p>
You should now update your Portage tree to the latest version. <c>emerge 
--sync</c> does this for you.
</p>

<pre caption="Updating the Portage tree">
# <i>emerge --sync</i>
<comment>(If you're using a slow terminal like some framebuffers or a serial
console, you can add the --quiet option to speed up this process:)</comment>
# <i>emerge --sync --quiet</i>
</pre>

<p>
If you are behind a firewall that blocks rsync traffic, you can use
<c>emerge-webrsync</c> which will download and install a portage snapshot for
you.
</p>

<p>
If you are warned that a new Portage version is available and that you should
update Portage, you should do it now using <c>emerge portage</c> command.
</p>

</body>
</subsection>
<subsection>
<title>Choosing the Right Profile</title>
<body>

<p>
First, a small definition is in place.
</p>

<p>
A profile is a building block for any Gentoo system. Not only does it specify
default values for CHOST, CFLAGS and other important variables, it also locks
the system to a certain range of package versions. This is all maintained by the
Gentoo developers.
</p>

<p>
Since 2006.0, there has been a re-shuffle regarding the profiles for MIPS
systems.  These profiles set various options including USE flags, which affect
what patchsets are enabled with various system-critical packages (notably,
<c>gcc</c> and <c>mips-sources</c>).
</p>

<p>
Previously, such a profile was barely touched by the user. However, x86, hppa
and alpha users can choose between two profiles, one for a 2.4 kernel and one
for a 2.6 kernel. This requirement has been imposed to improve the integration
of the 2.6 kernels. The ppc and ppc64 architectures have several profiles
available as well. We will talk about those later.
</p>

<p>
Thus, care needs to be taken to ensure the correct profile is selected for your
system type.  As of Gentoo/MIPS 2006.1, the profiles are:
</p>

<table>
  <tr>
    <th>System</th>
    <th>Profile</th>
    <th>Userland</th>
    <th>Status/Notes</th>
  </tr>

  <tr>
    <ti>Cobalt Qube/RaQ</ti>
    <ti>default-linux/mips/2006.1/cobalt/o32</ti>
    <ti>32-bit Linuxthreads</ti>
    <ti>Recommended</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/cobalt/o32/nptl</ti>
    <ti>32-bit NPTL</ti>
    <ti>In Testing (1)</ti>
  </tr>

  <tr>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>

  <tr>
    <ti>
      Generic Big Endian<br />
      <e>Including SGI Indy, Indigo2 (R4x00), Challenge S and O2</e>
    </ti>
    <ti>default-linux/mips/2006.1/generic-be/o32</ti>
    <ti>32-bit Linuxthreads</ti>
    <ti>Recommended</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/generic-be/o32/nptl</ti>
    <ti>32-bit NPTL</ti>
    <ti>In Testing (1)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/generic-be/n32</ti>
    <ti>N32 Linuxthreads</ti>
    <ti>Highly Experimental (2)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/generic-be/n32/nptl</ti>
    <ti>N32 NPTL</ti>
    <ti>Highly Experimental (1) (2)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/generic-be/n64</ti>
    <ti>N64 Linuxthreads</ti>
    <ti>Unsupported (3)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/generic-be/n64/nptl</ti>
    <ti>N64 NPTL</ti>
    <ti>Unsupported (1) (3)</ti>
  </tr>

  <tr>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>

  <tr>
    <ti>SGI Origin 200/2000</ti>
    <ti>default-linux/mips/2006.1/ip27/o32</ti>
    <ti>32-bit Linuxthreads</ti>
    <ti>Recommended</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip27/o32/nptl</ti>
    <ti>32-bit NPTL</ti>
    <ti>In Testing (1)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip27/n32</ti>
    <ti>N32 Linuxthreads</ti>
    <ti>Highly Experimental (2)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip27/n32/nptl</ti>
    <ti>N32 NPTL</ti>
    <ti>Highly Experimental (1) (2)</ti>
  </tr>

  <tr>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>

  <tr>
    <ti>SGI Indigo2 Impact R10000</ti>
    <ti>default-linux/mips/2006.1/ip28/o32</ti>
    <ti>32-bit Linuxthreads</ti>
    <ti>Recommended</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip28/o32/nptl</ti>
    <ti>32-bit NPTL</ti>
    <ti>In Testing (1)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip28/n32</ti>
    <ti>N32 Linuxthreads</ti>
    <ti>Highly Experimental (2)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip28/n32/nptl</ti>
    <ti>N32 NPTL</ti>
    <ti>Highly Experimental (1) (2)</ti>
  </tr>

  <tr>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
  
  <tr>
    <ti>SGI Octane/Octane2</ti>
    <ti>default-linux/mips/2006.1/ip30/o32</ti>
    <ti>32-bit Linuxthreads</ti>
    <ti>Recommended</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip30/o32/nptl</ti>
    <ti>32-bit NPTL</ti>
    <ti>In Testing (1)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip30/n32</ti>
    <ti>N32 Linuxthreads</ti>
    <ti>Highly Experimental (2)</ti>
  </tr>
  <tr>
    <ti>"</ti>
    <ti>default-linux/mips/2006.1/ip30/n32/nptl</ti>
    <ti>N32 NPTL</ti>
    <ti>Highly Experimental (1) (2)</ti>
  </tr>
</table>

<impo>
(1) NPTL is in-testing on MIPS at this stage, requiring 
<c>gcc-4.1</c> and <c>glibc-2.4</c>.  These profiles
are a work-in-progress, and are not guaranteed to work.  It is recommended that
people do not use these profiles until all the issues have been resolved.
</impo>

<warn>
(2) n32 Userland is highly experimental, a lot of software has problems with
this ABI, and thus it is practically guaranteed that you will run into stability
problems at some point.  Work is being done to improve the situation, however,
no support is offered if you use this profile, unless you're willing to help
fix problems by submitting patches.
</warn>

<warn>
(3) n64 Userland at present is completely unsupported on all systems.  At this
time there are no stages available that support n64, and this isn't likely to
change in the near future.
</warn>

<p>
You can see what profile you are currently using with the following command:
</p>

<pre caption="Verifying system profile">
# <i>ls -FGg /etc/make.profile</i>
lrwxrwxrwx  1 48 Apr  8 18:51 /etc/make.profile -> ../usr/portage/profiles/default-linux/mips/2006.1/generic-be/o32/
</pre>

<p>
Having looked through the profiles above, and decided which one is the most
appropriate, you need to adjust your <path>make.profile</path> symlink to
reflect this.  By default, the profiles are in
<path>/usr/portage/profiles</path>, so if you've moved your portage tree
elsewhere (not recommended), adjust the commands below accordingly.
</p>

<pre caption="Setting the profile">
<comment>(Delete the old profile symlink)</comment>
# <i>rm -f /etc/make.profile</i>

<comment>(Create a new symlink pointing to your chosen profile     )
(For example, this is what one would use on an Indy or O2.)</comment>
# <i>ln -s /usr/portage/profiles/default-linux/mips/2006.1/generic-be/o32</i>
</pre>

<note>
A tip for those not familiar with the Bourne Again Shell... If you partially
type a filename or command, then hit the TAB key, it will automatically fill out
the command/filename until the last common character.  E.g. typing
<c>/usr/portage/profiles/def&lt;TAB&gt;</c>, <c>bash</c> will automatically put
down <c>default-</c>.  Pressing TAB a couple of more times will reveal the
possibilities, <c>default-linux</c>, <c>default-darwin</c> and
<c>default-bsd</c>.  Give it a try, you'll find it very handy for navigating the
command line.
</note>

</body>
</subsection>
<subsection id="configure_USE">
<title>Configuring the USE variable</title>
<body>

<p>
<c>USE</c> is one of the most powerful variables Gentoo provides to its users.
Several programs can be compiled with or without optional support for certain
items. For instance, some programs can be compiled with gtk-support, or with
qt-support. Others can be compiled with or without SSL support. Some programs
can even be compiled with framebuffer support (svgalib) instead of X11 support
(X-server).
</p>

<p>
Most distributions compile their packages with support for as much as possible,
increasing the size of the programs and startup time, not to mention an enormous
amount of dependencies. With Gentoo you can define what options a package 
should be compiled with. This is where <c>USE</c> comes into play.
</p>

<p>
In the <c>USE</c> variable you define keywords which are mapped onto
compile-options. For instance, <e>ssl</e> will compile ssl-support in the
programs that support it. <e>-X</e> will remove X-server support (note the minus
sign in front). <e>gnome gtk -kde -qt</e> will compile your programs with gnome
(and gtk) support, and not with kde (and qt) support, making your system fully
tweaked for GNOME.
</p>

<p>
The default <c>USE</c> settings are placed in the <path>make.defaults</path> 
files of your profile. You will find <path>make.defaults</path> files in the
directory which <path>/etc/make.profile</path> points to and all parent 
directories as well. The default <c>USE</c> setting is the sum of all <c>USE</c>
settings in all <path>make.defaults</path> files. What you place in
<path>/etc/make.conf</path> is calculated against these defaults settings. If
you add something to the <c>USE</c> setting, it is added to the default list. If
you remove something from the <c>USE</c> setting (by placing a minus sign in
front of it) it is removed from the default list (if it was in the default list
at all). <e>Never</e> alter anything inside the <path>/etc/make.profile</path>
directory; it gets overwritten when you update Portage!
</p>

<p>
A full description on <c>USE</c> can be found in the second part of the Gentoo
Handbook, <uri link="?part=2&amp;chap=2">USE flags</uri>. A full description on
the available USE flags can be found on your system in
<path>/usr/portage/profiles/use.desc</path>. 
</p>

<pre caption="Viewing available USE flags">
# <i>less /usr/portage/profiles/use.desc</i>
<comment>(You can scroll using your arrow keys, exit by pressing 'q')</comment>
</pre>

<p>
As an example we show a <c>USE</c> setting for a KDE-based system with DVD, ALSA
and CD Recording support:
</p>

<pre caption="Opening /etc/make.conf">
# <i>nano -w /etc/make.conf</i>
</pre>

<pre caption="USE setting">
USE="-gtk -gnome qt kde dvd alsa cdr"
</pre>

</body>
</subsection>
<subsection>
<title>Optional: GLIBC Locales</title>
<body>

<p>
You will probably only use one or maybe two locales on your system. You can
specify locales you will need in <path>/etc/locale.gen</path>.
</p>

<pre caption="Opening /etc/locale.gen">
# <i>nano -w /etc/locale.gen</i>
</pre>

<p>
The following locales are an example to get both English (United States) and
German (Germany) with the accompanying character formats (like UTF-8).
</p>

<pre caption="Specify your locales">
en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
</pre>

<p>
The next step is to run <c>locale-gen</c>. It will generate all the locales you
have specified in the <path>/etc/locale.gen</path> file.
</p>

<note>
<c>locale-gen</c> is available in <c>glibc-2.3.6-r4</c> and newer. If you have
an older version of glibc, you should update it now.
</note>

<p>
Now continue with <uri link="?part=1&amp;chap=7">Configuring the Kernel</uri>.
</p>

</body>
</subsection>
</section>
</sections>
