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