mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-03-05 22:04:48 +00:00
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
This commit is contained in:
parent
5bf7f02e3f
commit
538aa7a11c
@ -35,6 +35,9 @@
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
|
||||
<listitem><para>November 19th, 2003 [greg]: Chapter 6: - Setting up the
|
||||
environment: Reworked the Bash startup files to enforce a clean environment.
|
||||
Closes Bug 714.</para></listitem>
|
||||
|
||||
<listitem><para>November 17th, 2003 [jeremy]: Upgraded Man-Pages to 1.63</para></listitem>
|
||||
|
||||
|
@ -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 > ~/.bash_profile << "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 > ~/.bashrc << "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>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user