setting-environment.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <sect1 id="ch05-settingenviron">
  2. <title>Setting up the environment</title>
  3. <?dbhtml filename="settingenvironment.html" dir="chapter05"?>
  4. <para>While logged in as user <emphasis>lfs</emphasis>, issue the
  5. following commands to set up a good work environment:</para>
  6. <para><screen><userinput>cat &gt; ~/.bash_profile &lt;&lt; "EOF"</userinput>
  7. set +h
  8. umask 022
  9. LFS=/mnt/lfs
  10. LC_ALL=POSIX
  11. PATH=/tools/bin:$PATH
  12. export LFS LC_ALL PATH
  13. <userinput>EOF
  14. source ~/.bash_profile</userinput></screen></para>
  15. <para>The <userinput>set +h</userinput> command turns off
  16. <userinput>bash</userinput>'s hash function. Normally hashing is a useful
  17. feature: <userinput>bash</userinput> uses a hash table to remember the
  18. full pathnames of executable files to avoid searching the PATH time and time
  19. again to find the same executable. However, we'd like the new tools to be
  20. used as soon as they are installed. By switching off the hash function, our
  21. "interactive" commands (<userinput>make</userinput>,
  22. <userinput>patch</userinput>, <userinput>sed</userinput>,
  23. <userinput>cp</userinput> and so forth) will always use
  24. the newest available version during the build process.</para>
  25. <para>Setting the user file-creation mask to 022 ensures that newly created
  26. files and directories are only writable for their owner, but readable and
  27. executable for anyone.</para>
  28. <para>The LFS variable should of course be set to the mount point you
  29. chose.</para>
  30. <para>The LC_ALL variable controls the localization of certain programs,
  31. making their messages follow the conventions of a specified country. If your
  32. host system uses a version of <emphasis>glibc</emphasis> older than 2.2.4,
  33. having LC_ALL set to something other than "POSIX" or "C" during this chapter
  34. may cause trouble if you exit the chroot environment and wish to return later.
  35. By setting LC_ALL to "POSIX" (or "C", the two are equivalent) we ensure that
  36. everything will work as expected in the chroot environment.</para>
  37. <para>We prepend <filename>/tools/bin</filename> to the standard PATH so
  38. that, as we move along through this chapter, the tools we build will get used
  39. during the rest of the building process.</para>
  40. <para>Now, after sourcing the just-created profile, we're all set to begin
  41. building the temporary tools that will support us in later chapters.</para>
  42. </sect1>