Author: manuel Date: 2005-06-03 12:05:01 -0600 (Fri, 03 Jun 2005) New Revision: 5629
Modified: branches/cross-lfs/BOOK/final-preps/settingenviron.xml Log: Indented final-preps/settingenviron.xml Modified: branches/cross-lfs/BOOK/final-preps/settingenviron.xml =================================================================== --- branches/cross-lfs/BOOK/final-preps/settingenviron.xml 2005-06-03 17:58:00 UTC (rev 5628) +++ branches/cross-lfs/BOOK/final-preps/settingenviron.xml 2005-06-03 18:05:01 UTC (rev 5629) @@ -1,40 +1,42 @@ <?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ +<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" + "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ <!ENTITY % general-entities SYSTEM "../general.ent"> %general-entities; ]> + <sect1 id="ch-final-preps-settingenviron"> -<title>Setting Up the Environment</title> -<?dbhtml filename="settingenvironment.html"?> + <?dbhtml filename="settingenvironment.html"?> -<para>Set up a good working environment by creating two new startup -files for the <command>bash</command> shell. While logged in as user -<emphasis>lfs</emphasis>, issue the -following command to create a new <filename>.bash_profile</filename>:</para> + <title>Setting Up the Environment</title> + <para>Set up a good working environment by creating two new startup + files for the <command>bash</command> shell. While logged in as user + <systemitem class="username">lfs</systemitem>, issue the following + command to create a new <filename>.bash_profile</filename>:</para> + <screen><userinput>cat > ~/.bash_profile << "EOF" <literal>exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash</literal> EOF</userinput></screen> -<para>When logged on as user <emphasis>lfs</emphasis>, the -initial shell is usually a <emphasis>login</emphasis> shell which reads the -<filename>/etc/profile</filename> of the host (probably containing -some settings and environment variables) and then -<filename>.bash_profile</filename>. The <command>exec env --i.../bin/bash</command> command in the -<filename>.bash_profile</filename> file replaces the running shell -with a new one with a completely empty environment, except for the -<envar>HOME</envar>, <envar>TERM</envar>, and -<envar>PS1</envar> variables. This ensures that no unwanted and -potentially hazardous environment variables from the host system leak -into the build environment. The technique used here achieves the goal -of ensuring a clean environment.</para> + <para>When logged on as user <systemitem class="username">lfs</systemitem>, + the initial shell is usually a <emphasis>login</emphasis> shell which + reads the <filename>/etc/profile</filename> of the host (probably + containing some settings and environment variables) and then + <filename>.bash_profile</filename>. The + <command>exec env -i.../bin/bash</command> command in the + <filename>.bash_profile</filename> file replaces the running shell with + a new one with a completely empty environment, except for the + <envar>HOME</envar>, <envar>TERM</envar>, and <envar>PS1</envar> variables. + This ensures that no unwanted and potentially hazardous environment + variables from the host system leak into the build environment. The + technique used here achieves the goal of ensuring a clean environment.</para> -<para>The new instance of the shell is a <emphasis>non-login</emphasis> -shell, which does not read the <filename>/etc/profile</filename> or -<filename>.bash_profile</filename> files, but rather reads the -<filename>.bashrc</filename> file instead. Create the -<filename>.bashrc</filename> file now:</para> + <para>The new instance of the shell is a <emphasis>non-login</emphasis> + shell, which does not read the <filename>/etc/profile</filename> or + <filename>.bash_profile</filename> files, but rather reads the + <filename>.bashrc</filename> file instead. Create the + <filename>.bashrc</filename> file now:</para> <screen><userinput>cat > ~/.bashrc << "EOF" <literal>set +h @@ -45,50 +47,47 @@ export LFS LC_ALL PATH</literal> EOF</userinput></screen> -<para>The <command>set +h</command> command turns off -<command>bash</command>'s hash function. Hashing is ordinarily a useful -feature—<command>bash</command> uses a hash table to remember the -full path of executable files to avoid searching the <envar>PATH</envar> time -and again to find the same executable. However, the new tools -should be used as soon as they are installed. By switching off the -hash function, the shell will always search the <envar>PATH</envar> when a program is -to be run. As such, the shell will find the newly compiled -tools in <filename class="directory">$LFS/tools</filename> as soon as -they are available without remembering a previous version of the same -program in a different location.</para> + <para>The <command>set +h</command> command turns off + <command>bash</command>'s hash function. Hashing is ordinarily a useful + feature—<command>bash</command> uses a hash table to remember the + full path of executable files to avoid searching the <envar>PATH</envar> + time and again to find the same executable. However, the new tools should + be used as soon as they are installed. By switching off the hash function, + the shell will always search the <envar>PATH</envar> when a program is to + be run. As such, the shell will find the newly compiled tools in + <filename class="directory">$LFS/tools</filename> as soon as they are + available without remembering a previous version of the same program in a + different location.</para> + <para>Setting the user file-creation mask (umask) to 022 ensures that + newly created files and directories are only writable by their owner, + but are readable and executable by anyone (assuming default modes are + used by the open(2) system call, new files will end up with permission + mode 644 and directories with mode 755).</para> -<para>Setting the user file-creation mask (umask) to 022 ensures that newly -created files and directories are only writable by their owner, but -are readable and executable by anyone (assuming default modes are used -by the open(2) system call, new files will end up with permission mode -644 and directories with mode 755).</para> + <para>The <envar>LFS</envar> variable should be set to the + chosen mount point.</para> -<para>The <envar>LFS</envar> variable should be set to the -chosen mount point.</para> + <para>The <envar>LC_ALL</envar> variable controls the localization of + certain programs, making their messages follow the conventions of a + specified country. If the host system uses a version of Glibc older + than 2.2.4, having <envar>LC_ALL</envar> set to something other than + <quote>POSIX</quote> or <quote>C</quote> (during this chapter) may cause + issues if you exit the chroot environment and wish to return later. + Setting <envar>LC_ALL</envar> to <quote>POSIX</quote> or <quote>C</quote> + (the two are equivalent) ensures that everything will work as expected in + the chroot environment.</para> -<para>The <envar>LC_ALL</envar> variable controls the -localization of certain programs, making their messages follow the -conventions of a specified country. If the host system uses a version -of Glibc older than 2.2.4, having <envar>LC_ALL</envar> set to something other than -<quote>POSIX</quote> or <quote>C</quote> (during this chapter) may -cause issues if you exit the chroot environment and wish to return -later. Setting <envar>LC_ALL</envar> to <quote>POSIX</quote> -or <quote>C</quote> (the two are equivalent) ensures that -everything will work as expected in the chroot environment.</para> + <para>By putting <filename class="directory">/tools/bin</filename> ahead + of the standard <envar>PATH</envar>, all the programs installed in + <xref linkend="chapter-temporary-tools"/> are picked up by the shell + immediately after their installation. This, combined with turning off + hashing, limits the risk that old programs from the host are being used + when they should not be used any longer.</para> -<para>By putting <filename class="directory">/tools/bin</filename> -ahead of the standard <envar>PATH</envar>, all the programs installed in <xref -linkend="chapter-temporary-tools"/> are picked up by the shell -immediately after their installation. This, combined with turning off -hashing, limits the risk that old programs from -the host are being used when they should not be used any -longer.</para> + <para>Finally, to have the environment fully prepared for building the + temporary tools, source the just-created user profile:</para> -<para>Finally, to have the environment fully prepared for building the -temporary tools, source the just-created user profile:</para> - <screen><userinput>source ~/.bash_profile</userinput></screen> </sect1> - -- http://linuxfromscratch.org/mailman/listinfo/lfs-book FAQ: http://www.linuxfromscratch.org/lfs/faq.html Unsubscribe: See the above information page
