aboutsummaryrefslogtreecommitdiffstats
path: root/chapter04/settingenviron.xml
diff options
context:
space:
mode:
authorMatthew Burgess <matthew@linuxfromscratch.org>2004-05-03 10:59:46 +0000
committerMatthew Burgess <matthew@linuxfromscratch.org>2004-05-03 10:59:46 +0000
commit673b0d84ba9591e07c0bdf0ee49d92eba10f502c (patch)
tree129e27a1450727b440da4378e0117a468eb9c25e /chapter04/settingenviron.xml
parent287ea55da70ceb1f0990554b7db921d525fef816 (diff)
* Merged newxml into HEAD
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3435 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter04/settingenviron.xml')
-rw-r--r--chapter04/settingenviron.xml80
1 files changed, 80 insertions, 0 deletions
diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml
new file mode 100644
index 000000000..79bc3225b
--- /dev/null
+++ b/chapter04/settingenviron.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % general-entities SYSTEM "../general.ent">
+ %general-entities;
+]>
+<sect1 id="ch-tools-settingenviron">
+<title>Setting up the environment</title>
+<?dbhtml filename="settingenvironment.html"?>
+
+<para>We're going to 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>
+
+<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</userinput>
+exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
+<userinput>EOF</userinput></screen>
+
+<para>Normally, when you log on as user <emphasis>lfs</emphasis>,
+the initial shell is a <emphasis>login</emphasis> shell which reads the
+<filename>/etc/profile</filename> of your host (probably containing some
+settings of environment variables) and then <filename>.bash_profile</filename>.
+The <command>exec env -i ... /bin/bash</command> command in the latter file
+replaces the running shell with a new one with a completely empty environment,
+except for the HOME, TERM and PS1 variables. This ensures that no unwanted and
+potentially hazardous environment variables from the host system leak into our
+build environment. The technique used here is a little strange, but it achieves
+the goal of enforcing a clean environment.</para>
+
+<para>The new instance of the shell is a <emphasis>non-login</emphasis> shell,
+which doesn't read the <filename>/etc/profile</filename> or
+<filename>.bash_profile</filename> files, but reads the
+<filename>.bashrc</filename> file instead. Create this latter file now:</para>
+
+<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"</userinput>
+set +h
+umask 022
+LFS=/mnt/lfs
+LC_ALL=POSIX
+PATH=/tools/bin:/bin:/usr/bin
+export LFS LC_ALL PATH
+<userinput>EOF</userinput></screen>
+
+<para>The <command>set +h</command> command turns off
+<command>bash</command>'s hash function. Normally hashing is a useful
+feature: <command>bash</command> uses a hash table to remember the
+full pathnames of executable files to avoid searching the PATH time and time
+again to find the same executable. However, we'd like the new tools to be
+used as soon as they are installed. By switching off the hash function, our
+<quote>interactive</quote> commands (<command>make</command>,
+<command>patch</command>, <command>sed</command>,
+<command>cp</command> and so forth) will always use
+the newest available version during the build process.</para>
+
+<para>Setting the user file-creation mask to 022 ensures that newly created
+files and directories are only writable for their owner, but readable and
+executable for anyone.</para>
+
+<para>The LFS variable should of course be set to the mount point you
+chose.</para>
+
+<para>The LC_ALL variable controls the localization of certain programs,
+making their messages follow the conventions of a specified country. If your
+host system uses a version of Glibc older than 2.2.4,
+having LC_ALL set to something other than <quote>POSIX</quote> or
+<quote>C</quote> during this chapter may cause trouble if you exit the chroot
+environment and wish to return later. By setting LC_ALL to <quote>POSIX</quote>
+(or <quote>C</quote>, the two are equivalent) we ensure that
+everything will work as expected in the chroot environment.</para>
+
+<para>We prepend <filename>/tools/bin</filename> to the standard PATH so
+that, as we move along through this chapter, the tools we build will get used
+during the rest of the building process.</para>
+
+<para>Finally, to have our environment fully prepared for building the
+temporary tools, source the just-created profile:</para>
+
+<screen><userinput>source ~/.bash_profile</userinput></screen>
+
+</sect1>