From 6a3b6af43583312b18dcae4d63d4f40737eff771 Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Sun, 15 Jan 2006 12:10:43 +0000 Subject: Indented chapter 04. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7275 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter04/settingenviron.xml | 121 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 61 deletions(-) (limited to 'chapter04/settingenviron.xml') diff --git a/chapter04/settingenviron.xml b/chapter04/settingenviron.xml index 574526392..561e30381 100644 --- a/chapter04/settingenviron.xml +++ b/chapter04/settingenviron.xml @@ -1,40 +1,41 @@ - %general-entities; ]> + -Setting Up the Environment - + + + Setting Up the Environment -Set up a good working environment by creating two new startup -files for the bash shell. While logged in as user -lfs, issue the -following command to create a new .bash_profile: + Set up a good working environment by creating two new startup files + for the bash shell. While logged in as user + lfs, issue the following command + to create a new .bash_profile: cat > ~/.bash_profile << "EOF" exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash EOF -When logged on as user lfs, the -initial shell is usually a login shell which reads the -/etc/profile of the host (probably containing -some settings and environment variables) and then -.bash_profile. The exec env --i.../bin/bash command in the -.bash_profile 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 the build environment. The technique used here achieves the goal -of ensuring a clean environment. + When logged on as user lfs, + the initial shell is usually a login shell which reads + the /etc/profile of the host (probably containing some + settings and environment variables) and then .bash_profile. + The exec env -i.../bin/bash command in the + .bash_profile 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 the build environment. The technique used here achieves the goal of + ensuring a clean environment. -The new instance of the shell is a non-login -shell, which does not read the /etc/profile or -.bash_profile files, but rather reads the -.bashrc file instead. Create the -.bashrc file now: + The new instance of the shell is a non-login + shell, which does not read the /etc/profile or + .bash_profile files, but rather reads the + .bashrc file instead. Create the + .bashrc file now: cat > ~/.bashrc << "EOF" set +h @@ -45,48 +46,46 @@ PATH=/tools/bin:/bin:/usr/bin export LFS LC_ALL PATH EOF -The set +h command turns off -bash's hash function. Hashing is ordinarily a useful -feature—bash uses a hash table to remember the -full path of executable files to avoid searching the PATH 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 PATH when a program is -to be run. As such, the shell will find the newly compiled -tools in $LFS/tools as soon as -they are available without remembering a previous version of the same -program in a different location. + The set +h command turns off + bash's hash function. Hashing is ordinarily a useful + feature—bash uses a hash table to remember the + full path of executable files to avoid searching the PATH + 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 PATH when a program is to + be run. As such, the shell will find the newly compiled tools in + $LFS/tools as soon as they are + available without remembering a previous version of the same program in a + different location. -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). + 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). -The LFS variable should be set to the -chosen mount point. + The LFS variable should be set to the chosen mount + point. -The LC_ALL 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 LC_ALL set to something other than -POSIX or C (during this chapter) may -cause issues if you exit the chroot environment and wish to return -later. Setting LC_ALL to POSIX -or C (the two are equivalent) ensures that -everything will work as expected in the chroot environment. + The LC_ALL 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 + LC_ALL set to something other than POSIX or + C (during this chapter) may cause issues if you exit the chroot + environment and wish to return later. Setting LC_ALL to + POSIX or C (the two are equivalent) ensures that + everything will work as expected in the chroot environment. -By putting /tools/bin ahead of the -standard PATH, all the programs installed in are picked up by the shell immediately after -their installation. This, combined with turning off hashing, limits the risk -that old programs are used from the host when the same programs are available in -the chapter 5 environment. + By putting /tools/bin ahead of the + standard PATH, all the programs installed in are picked up by the shell immediately after + their installation. This, combined with turning off hashing, limits the risk + that old programs are used from the host when the same programs are available in + the chapter 5 environment. -Finally, to have the environment fully prepared for building the -temporary tools, source the just-created user profile: + Finally, to have the environment fully prepared for building the + temporary tools, source the just-created user profile: source ~/.bash_profile - -- cgit v1.2.3-54-g00ecf