Ignore:
Timestamp:
11/20/2003 12:15:47 AM (20 years ago)
Author:
Greg Schafer <greg@…>
Branches:
10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 6.0, 6.1, 6.1.1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, v5_1, v5_1_1, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
Children:
bcd0ce7
Parents:
5bf7f02
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter05/chapter05.xml

    r5bf7f02 r538aa7a  
    347347<?dbhtml filename="settingenvironment.html" dir="chapter05"?>
    348348
    349 <para>While logged in as user <emphasis>lfs</emphasis>, issue the
    350 following commands to set up a good work environment:</para>
     349<para>We're going to set up a good working environment by creating two new
     350startup files for the Bash shell. While logged in as user
     351<emphasis>lfs</emphasis>, issue the following commands to create a new
     352<filename>.bash_profile</filename>:</para>
    351353
    352354<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</userinput>
     355exec env -i TERM=$TERM /bin/bash
     356<userinput>EOF</userinput></screen>
     357
     358<para>The <userinput>exec env -i TERM=$TERM /bin/bash</userinput> command
     359creates a new instance of Bash with a completely empty environment, except for
     360the TERM variable. This is needed to ensure that no unwanted and potentially
     361hazardous environment variables from the host system leak into our build
     362environment. The technique used here is a little non-standard but it achieves
     363the goal of enforcing a clean environment. By way of explanation, the initial
     364shell is a <emphasis>login</emphasis> shell which reads the
     365<filename>.bash_profile</filename>. The new shell instance is a
     366<emphasis>non-login</emphasis> shell which reads the
     367<filename>.bashrc</filename> (created next).</para>
     368
     369<para>Now create a new <filename>.bashrc</filename>:</para>
     370
     371<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"</userinput>
    353372set +h
    354373umask 022
    355374LFS=/mnt/lfs
    356375LC_ALL=POSIX
    357 PATH=/tools/bin:$PATH
     376PATH=/tools/bin:/bin:/usr/bin
    358377export LFS LC_ALL PATH
    359 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
    360 <userinput>EOF
    361 
    362 source ~/.bash_profile</userinput></screen>
     378<userinput>EOF</userinput></screen>
    363379
    364380<para>The <userinput>set +h</userinput> command turns off
     
    392408during the rest of the building process.</para>
    393409
    394 <para>The CC, CXX, CPP, LD_LIBRARY_PATH and LD_PRELOAD environment variables all
    395 have the potential to cause havoc with our Chapter 5 toolchain. We therefore
    396 unset them to prevent any chance of this happening.</para>
    397 
    398 <para>Now, after sourcing the just-created profile, we're all set to begin
     410<para>Finally, source the just-created profile so that we're all set to begin
    399411building the temporary tools that will support us in later chapters.</para>
     412
     413<screen><userinput>source ~/.bash_profile</userinput></screen>
    400414
    401415</sect1>
Note: See TracChangeset for help on using the changeset viewer.