installasuser.xml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <sect1 id="ch05-installasuser">
  2. <title>Install all software as an unprivileged user</title>
  3. <?dbhtml filename="installasuser.html" dir="chapter05"?>
  4. <para>When you are logged in as root during Chapter 5, it is possible
  5. that some files of your host system will be overwritten by the ones
  6. you'll build in Chapter 5. There can be all kinds of reasons for this
  7. to happen, for example because the $LFS environment variable is not
  8. set. Overwriting some files from your host system will most likely
  9. cause all kinds of problems, so it's a good idea to be logged in as
  10. an unprivileged user during Chapter 5. To make sure the environment
  11. is as clean as possible, we'll create a new user "lfs" that can be
  12. used while building the static installation. Issuing the following
  13. commands as root will create a new user "lfs":</para>
  14. <para><screen><userinput>useradd -s /bin/bash -m lfs &amp;&amp;
  15. passwd lfs</userinput></screen></para>
  16. <para>Now we need to give proper permissions to the <filename
  17. class="directory">$LFS/static</filename> directory so user "lfs" can write
  18. to it:</para>
  19. <para><screen><userinput>chown -R lfs $LFS/static</userinput></screen></para>
  20. <para>You have to login as user <emphasis>lfs</emphasis> now to continue
  21. with the rest of this chapter. You can do this two ways: either the normal
  22. way through the console or the display manager, or with
  23. <userinput>su - lfs</userinput>. When you're working as user
  24. <emphasis>lfs</emphasis>, type the following commands to set up a good
  25. environment to work in:</para>
  26. <para><screen><userinput>cat &gt; ~lfs/.bash_profile &lt;&lt; "EOF"
  27. umask 022
  28. LFS=/mnt/lfs
  29. LC_ALL=POSIX
  30. CC='gcc -s'
  31. export LFS LC_ALL CC
  32. EOF
  33. source ~/.bash_profile</userinput></screen></para>
  34. <para>This profile makes sure the umask is set to 022 so newly created
  35. files and directories will have the correct permissions. It is advisable
  36. to keep this setting throughout your LFS installation. Also, the $LFS,
  37. $LC_ALL, and $CC environment variables are set. $LFS has been explained
  38. in previous chapters already. $LC_ALL is a variable that is used for
  39. internationalization.</para>
  40. <para>When your host distribution uses a glibc version older than 2.2.4,
  41. having $LC_ALL set to something other than "C" or "POSIX" while working
  42. through Chapter 5 may cause trouble when you exit the chroot environment
  43. of Chapter 6 and try to return to it. By setting this to "POSIX" ("C"
  44. is an alias for "POSIX") we ensure that everything will work as expected
  45. in the chroot environment.</para>
  46. <para>$CC is a variable we set in order to prevent debugging symbols from
  47. being compiled into our static packages. By omitting these symbols during
  48. the linking stage of compilation, we save hard drive space and decrease
  49. our build time.</para>
  50. </sect1>