[fcc02767] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-tools-chroot">
|
---|
[febac51] | 9 | <?dbhtml filename="env.html"?>
|
---|
[fcc02767] | 10 |
|
---|
[febac51] | 11 | <title>Setting up the Environment</title>
|
---|
[fcc02767] | 12 |
|
---|
[febac51] | 13 | <para>The standard I/O streams of the initial shell process is connected
|
---|
| 14 | with <filename>/dev/console</filename>. However, the testsuite of some
|
---|
| 15 | packages may expect the standard I/O streams to be connected with a
|
---|
| 16 | <quote>real</quote> TTY device node. Spawn a new shell process on the
|
---|
| 17 | TTY device with <command>agetty</command>:</para>
|
---|
[fcc02767] | 18 |
|
---|
[febac51] | 19 | <screen role="nodump"><userinput>agetty -n -l /bin/bash <replaceable>tty0</replaceable></userinput></screen>
|
---|
| 20 |
|
---|
| 21 | <para>If you are working via a serial console, replace
|
---|
| 22 | <replaceable>tty0</replaceable> with the name of the serial console
|
---|
| 23 | device node, for example <literal>ttyS0</literal>.</para>
|
---|
| 24 |
|
---|
| 25 | <para>The command above spawns a new shell process on the TTY device
|
---|
| 26 | specified in the command, and the initial shell process will run in
|
---|
| 27 | background as an init process with very limited functions. The new shell
|
---|
| 28 | process will output:</para>
|
---|
| 29 |
|
---|
| 30 | <screen role="nodump"><computeroutput>bash: cannot set terminal process group (-1): Inappropriate ioctl for device
|
---|
| 31 | bash: no job control in this shell</computeroutput></screen>
|
---|
| 32 |
|
---|
| 33 | <para>This is normal because the shell is not assigned with a
|
---|
| 34 | controlling terminal yet. Now set up controlling terminal and
|
---|
| 35 | environment variables:</para>
|
---|
| 36 |
|
---|
| 37 | <screen><userinput>exec setsid -c /usr/bin/env -i \
|
---|
[fcc02767] | 38 | HOME=/root \
|
---|
| 39 | TERM="$TERM" \
|
---|
[febac51] | 40 | PS1='(lfs) \u:\w\$ ' \
|
---|
[d7a9421] | 41 | PATH=/usr/bin:/usr/sbin \
|
---|
[490dc153] | 42 | /bin/bash --login</userinput></screen>
|
---|
[fcc02767] | 43 |
|
---|
[febac51] | 44 | <para>The command replace the current shell process with a new shell
|
---|
| 45 | process, with controlling terminal set up.</para>
|
---|
| 46 |
|
---|
[fcc02767] | 47 | <para>The <parameter>-i</parameter> option given to the <command>env</command>
|
---|
[febac51] | 48 | command will clear all variables of the environment. After that, only
|
---|
[fcc02767] | 49 | the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
|
---|
| 50 | <envar>PATH</envar> variables are set again. The
|
---|
| 51 | <parameter>TERM=$TERM</parameter> construct will set the <envar>TERM</envar>
|
---|
[febac51] | 52 | variable to the default value specified by <command>agetty</command>. This variable is
|
---|
[fcc02767] | 53 | needed for programs like <command>vim</command> and <command>less</command>
|
---|
[387a32af] | 54 | to operate properly. If other variables are desired, such as
|
---|
[fcc02767] | 55 | <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
|
---|
| 56 | them again.</para>
|
---|
| 57 |
|
---|
| 58 | <para>Notice that <filename class="directory">/tools/bin</filename> is not
|
---|
[9174a66] | 59 | in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
|
---|
[febac51] | 60 | used on the target machine.</para>
|
---|
[fcc02767] | 61 |
|
---|
| 62 | <para>Note that the <command>bash</command> prompt will say
|
---|
| 63 | <computeroutput>I have no name!</computeroutput> This is normal because the
|
---|
| 64 | <filename>/etc/passwd</filename> file has not been created yet.</para>
|
---|
| 65 |
|
---|
[e8f1927] | 66 | <para>Now set up a temporary hostname, which is required by test suite of
|
---|
| 67 | some packages:</para>
|
---|
| 68 |
|
---|
| 69 | <screen><userinput>hostname lfs</userinput></screen>
|
---|
| 70 |
|
---|
[fcc02767] | 71 | <note>
|
---|
| 72 | <para>It is important that all the commands throughout the remainder of this
|
---|
[febac51] | 73 | chapter and the following chapters are run from within the environment
|
---|
| 74 | we've set. If you leave this environment for any reason (rebooting for
|
---|
[fcc02767] | 75 | example), ensure that the virtual kernel filesystems are mounted as
|
---|
[febac51] | 76 | explained in <xref linkend="ch-tools-kernfsmount"/> and
|
---|
| 77 | <xref linkend="ch-tools-devadjust"/> and set up the environment again before
|
---|
| 78 | continuing with the installation.</para>
|
---|
[fcc02767] | 79 | </note>
|
---|
| 80 |
|
---|
| 81 | </sect1>
|
---|