aboutsummaryrefslogtreecommitdiffstats
path: root/chapter05/chapter05.xml
diff options
context:
space:
mode:
authorGreg Schafer <greg@linuxfromscratch.org>2003-11-20 00:15:47 +0000
committerGreg Schafer <greg@linuxfromscratch.org>2003-11-20 00:15:47 +0000
commit538aa7a11ce19920685e26062aec82a94b3e98d3 (patch)
tree922fa3a0c25107dbb00a325b46ff53818c9f4bbc /chapter05/chapter05.xml
parent5bf7f02e3f9b7d543b824688dab7f8768f244ace (diff)
Chapter 6: - Setting up the environment: Reworked the Bash startup files to enforce a clean environment. Closes Bug 714.
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3115 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter05/chapter05.xml')
-rw-r--r--chapter05/chapter05.xml38
1 files changed, 26 insertions, 12 deletions
diff --git a/chapter05/chapter05.xml b/chapter05/chapter05.xml
index 88e71ceb0..6ae7a7d4f 100644
--- a/chapter05/chapter05.xml
+++ b/chapter05/chapter05.xml
@@ -346,20 +346,36 @@ start a new, clean shell.</para>
<title>Setting up the environment</title>
<?dbhtml filename="settingenvironment.html" dir="chapter05"?>
-<para>While logged in as user <emphasis>lfs</emphasis>, issue the
-following commands to set up a good work environment:</para>
+<para>We're going to set up a good working environment by creating two new
+startup files for the Bash shell. While logged in as user
+<emphasis>lfs</emphasis>, issue the following commands to create a new
+<filename>.bash_profile</filename>:</para>
<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</userinput>
+exec env -i TERM=$TERM /bin/bash
+<userinput>EOF</userinput></screen>
+
+<para>The <userinput>exec env -i TERM=$TERM /bin/bash</userinput> command
+creates a new instance of Bash with a completely empty environment, except for
+the TERM variable. This is needed to ensure that no unwanted and potentially
+hazardous environment variables from the host system leak into our build
+environment. The technique used here is a little non-standard but it achieves
+the goal of enforcing a clean environment. By way of explanation, the initial
+shell is a <emphasis>login</emphasis> shell which reads the
+<filename>.bash_profile</filename>. The new shell instance is a
+<emphasis>non-login</emphasis> shell which reads the
+<filename>.bashrc</filename> (created next).</para>
+
+<para>Now create a new <filename>.bashrc</filename>:</para>
+
+<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"</userinput>
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
-PATH=/tools/bin:$PATH
+PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
-unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
-<userinput>EOF
-
-source ~/.bash_profile</userinput></screen>
+<userinput>EOF</userinput></screen>
<para>The <userinput>set +h</userinput> command turns off
<userinput>bash</userinput>'s hash function. Normally hashing is a useful
@@ -391,13 +407,11 @@ everything will work as expected in the chroot environment.</para>
that, as we move along through this chapter, the tools we build will get used
during the rest of the building process.</para>
-<para>The CC, CXX, CPP, LD_LIBRARY_PATH and LD_PRELOAD environment variables all
-have the potential to cause havoc with our Chapter 5 toolchain. We therefore
-unset them to prevent any chance of this happening.</para>
-
-<para>Now, after sourcing the just-created profile, we're all set to begin
+<para>Finally, source the just-created profile so that we're all set to begin
building the temporary tools that will support us in later chapters.</para>
+<screen><userinput>source ~/.bash_profile</userinput></screen>
+
</sect1>