source: chapter04/settingenviron.xml@ 05616e2

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 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
Last change on this file since 05616e2 was 05616e2, checked in by Manuel Canales Esparcia <manuel@…>, 20 years ago

<qoute> isn't allowed inside <userinput>.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3726 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
6<sect1 id="ch-tools-settingenviron">
7<title>Setting up the environment</title>
8<?dbhtml filename="settingenvironment.html"?>
9
10<para>We're going to set up a good working environment by creating two new
11startup files for the <command>bash</command> shell. While logged in as
12user <emphasis>lfs</emphasis>, issue the following command to create a new
13<filename>.bash_profile</filename>:</para>
14
15<screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"
16exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
17EOF</userinput></screen>
18
19<para>Normally, when you log on as user <emphasis>lfs</emphasis>,
20the initial shell is a <emphasis>login</emphasis> shell which reads the
21<filename>/etc/profile</filename> of your host (probably containing some
22settings of environment variables) and then <filename>.bash_profile</filename>.
23The <command>exec env -i ... /bin/bash</command> command in the latter file
24replaces the running shell with a new one with a completely empty environment,
25except for the HOME, TERM and PS1 variables. This ensures that no unwanted and
26potentially hazardous environment variables from the host system leak into our
27build environment. The technique used here is a little strange, but it achieves
28the goal of enforcing a clean environment.</para>
29
30<para>The new instance of the shell is a <emphasis>non-login</emphasis> shell,
31which doesn't read the <filename>/etc/profile</filename> or
32<filename>.bash_profile</filename> files, but reads the
33<filename>.bashrc</filename> file instead. Create this latter file now:</para>
34
35<screen><userinput>cat &gt; ~/.bashrc &lt;&lt; "EOF"
36set +h
37umask 022
38LFS=/mnt/lfs
39LC_ALL=POSIX
40PATH=/tools/bin:/bin:/usr/bin
41export LFS LC_ALL PATH
42EOF</userinput></screen>
43
44<para>The <command>set +h</command> command turns off
45<command>bash</command>'s hash function. Normally hashing is a useful
46feature: <command>bash</command> uses a hash table to remember the
47full pathnames of executable files to avoid searching the PATH time and time
48again to find the same executable. However, we'd like the new tools to be
49used as soon as they are installed. By switching off the hash function, our
50<quote>interactive</quote> commands (<command>make</command>,
51<command>patch</command>, <command>sed</command>,
52<command>cp</command> and so forth) will always use
53the newest available version during the build process.</para>
54
55<para>Setting the user file-creation mask to 022 ensures that newly created
56files and directories are only writable for their owner, but readable and
57executable for anyone.</para>
58
59<para>The LFS variable should of course be set to the mount point you
60chose.</para>
61
62<para>The LC_ALL variable controls the localization of certain programs,
63making their messages follow the conventions of a specified country. If your
64host system uses a version of Glibc older than 2.2.4,
65having LC_ALL set to something other than <quote>POSIX</quote> or
66<quote>C</quote> during this chapter may cause trouble if you exit the chroot
67environment and wish to return later. By setting LC_ALL to <quote>POSIX</quote>
68(or <quote>C</quote>, the two are equivalent) we ensure that
69everything will work as expected in the chroot environment.</para>
70
71<para>We prepend <filename class="directory">/tools/bin</filename> to the standard PATH so
72that, as we move along through this chapter, the tools we build will get used
73during the rest of the building process.</para>
74
75<para>Finally, to have our environment fully prepared for building the
76temporary tools, source the just-created profile:</para>
77
78<screen><userinput>source ~/.bash_profile</userinput></screen>
79
80</sect1>
Note: See TracBrowser for help on using the repository browser.