[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[fcc02767] | 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 |
|
---|
[a08f031] | 13 | <para>The current shell is also the <command>init</command> process,
|
---|
| 14 | so exiting from it will cause kernel panic. Prevent exiting from the
|
---|
| 15 | shell accidentally:</para>
|
---|
| 16 |
|
---|
| 17 | <screen role="nodump"><userinput>enable -n exit
|
---|
| 18 | readonly IGNOREEOF=1000</userinput></screen>
|
---|
| 19 |
|
---|
[febac51] | 20 | <para>The standard I/O streams of the initial shell process is connected
|
---|
| 21 | with <filename>/dev/console</filename>. However, the testsuite of some
|
---|
| 22 | packages may expect the standard I/O streams to be connected with a
|
---|
| 23 | <quote>real</quote> TTY device node. Spawn a new shell process on the
|
---|
| 24 | TTY device with <command>agetty</command>:</para>
|
---|
[fcc02767] | 25 |
|
---|
[febac51] | 26 | <screen role="nodump"><userinput>agetty -n -l /bin/bash <replaceable>tty0</replaceable></userinput></screen>
|
---|
| 27 |
|
---|
| 28 | <para>If you are working via a serial console, replace
|
---|
| 29 | <replaceable>tty0</replaceable> with the name of the serial console
|
---|
| 30 | device node, for example <literal>ttyS0</literal>.</para>
|
---|
| 31 |
|
---|
| 32 | <para>The command above spawns a new shell process on the TTY device
|
---|
| 33 | specified in the command, and the initial shell process will run in
|
---|
| 34 | background as an init process with very limited functions. The new shell
|
---|
| 35 | process will output:</para>
|
---|
| 36 |
|
---|
| 37 | <screen role="nodump"><computeroutput>bash: cannot set terminal process group (-1): Inappropriate ioctl for device
|
---|
| 38 | bash: no job control in this shell</computeroutput></screen>
|
---|
| 39 |
|
---|
| 40 | <para>This is normal because the shell is not assigned with a
|
---|
[e49e2ea] | 41 | controlling terminal yet. Now set up the controlling terminal and
|
---|
| 42 | some environment variables:</para>
|
---|
[febac51] | 43 |
|
---|
| 44 | <screen><userinput>exec setsid -c /usr/bin/env -i \
|
---|
[fcc02767] | 45 | HOME=/root \
|
---|
| 46 | TERM="$TERM" \
|
---|
[febac51] | 47 | PS1='(lfs) \u:\w\$ ' \
|
---|
[d7a9421] | 48 | PATH=/usr/bin:/usr/sbin \
|
---|
[95ebbb4] | 49 | MAKEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
|
---|
| 50 | TESTSUITEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
|
---|
[490dc153] | 51 | /bin/bash --login</userinput></screen>
|
---|
[fcc02767] | 52 |
|
---|
[e49e2ea] | 53 | <para>The command replaces the current shell process with a new shell
|
---|
[febac51] | 54 | process, with controlling terminal set up.</para>
|
---|
| 55 |
|
---|
[95ebbb4] | 56 | <para>
|
---|
[798e18b] | 57 | If you don't want to use all available logical cores, replace
|
---|
| 58 | <replaceable>$(nproc)</replaceable> with the number of logical cores you
|
---|
| 59 | want to use for building packages in this chapter and the following
|
---|
| 60 | chapters. The test suites of some packages (notably Autoconf, Libtool,
|
---|
| 61 | and Tar) in &ch-final; are not affected by <envar>MAKEFLAGS</envar>, they
|
---|
| 62 | use a <envar>TESTSUITEFLAGS</envar> environment variable instead. We
|
---|
[f16cc36] | 63 | set that here as well for running these test suites with multiple cores.
|
---|
[95ebbb4] | 64 | </para>
|
---|
| 65 |
|
---|
[fcc02767] | 66 | <para>The <parameter>-i</parameter> option given to the <command>env</command>
|
---|
[b59b371] | 67 | command will clear all the variables in the environment. After that, only
|
---|
[fcc02767] | 68 | the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
|
---|
| 69 | <envar>PATH</envar> variables are set again. The
|
---|
| 70 | <parameter>TERM=$TERM</parameter> construct will set the <envar>TERM</envar>
|
---|
[febac51] | 71 | variable to the default value specified by <command>agetty</command>. This variable is
|
---|
[ebecd08] | 72 | needed so programs like <command>vim</command> and <command>less</command>
|
---|
| 73 | can operate properly. If other variables are desired, such as
|
---|
[fcc02767] | 74 | <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
|
---|
[ebecd08] | 75 | them.</para>
|
---|
[fcc02767] | 76 |
|
---|
| 77 | <para>Notice that <filename class="directory">/tools/bin</filename> is not
|
---|
[9174a66] | 78 | in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
|
---|
[ebecd08] | 79 | used.</para>
|
---|
[fcc02767] | 80 |
|
---|
[798e18b] | 81 | <para>Also note that the <command>bash</command> prompt will say
|
---|
[fcc02767] | 82 | <computeroutput>I have no name!</computeroutput> This is normal because the
|
---|
| 83 | <filename>/etc/passwd</filename> file has not been created yet.</para>
|
---|
| 84 |
|
---|
[e8f1927] | 85 | <para>Now set up a temporary hostname, which is required by test suite of
|
---|
| 86 | some packages:</para>
|
---|
| 87 |
|
---|
| 88 | <screen><userinput>hostname lfs</userinput></screen>
|
---|
| 89 |
|
---|
[fcc02767] | 90 | <note>
|
---|
| 91 | <para>It is important that all the commands throughout the remainder of this
|
---|
[febac51] | 92 | chapter and the following chapters are run from within the environment
|
---|
| 93 | we've set. If you leave this environment for any reason (rebooting for
|
---|
[fcc02767] | 94 | example), ensure that the virtual kernel filesystems are mounted as
|
---|
[febac51] | 95 | explained in <xref linkend="ch-tools-kernfsmount"/> and
|
---|
| 96 | <xref linkend="ch-tools-devadjust"/> and set up the environment again before
|
---|
| 97 | continuing with the installation.</para>
|
---|
[fcc02767] | 98 | </note>
|
---|
| 99 |
|
---|
| 100 | </sect1>
|
---|