aboutsummaryrefslogtreecommitdiffstats
path: root/chapter05
diff options
context:
space:
mode:
Diffstat (limited to 'chapter05')
-rw-r--r--chapter05/creatingdirs.xml66
-rw-r--r--chapter05/installasroot.xml20
-rw-r--r--chapter05/installasuser.xml55
3 files changed, 121 insertions, 20 deletions
diff --git a/chapter05/creatingdirs.xml b/chapter05/creatingdirs.xml
new file mode 100644
index 000000000..8c0c369a5
--- /dev/null
+++ b/chapter05/creatingdirs.xml
@@ -0,0 +1,66 @@
+<sect1 id="ch05-creatingdirs">
+<title>Creating directories</title>
+<?dbhtml filename="creatingdirs.html" dir="chapter05"?>
+
+<para>Let's now create the directory tree on the LFS partition based on
+the FHS standard, which can be found at
+<ulink url="http://www.pathname.com/fhs/">http://www.pathname.com/fhs/</ulink>.
+Issuing the following commands will create a default directory layout:</para>
+
+<para><screen><userinput>cd $LFS &amp;&amp;
+mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt &amp;&amp;
+for dirname in $LFS/usr $LFS/usr/local
+<literal>&nbsp;&nbsp;&nbsp;do</literal>
+&nbsp;&nbsp;&nbsp;mkdir $dirname
+&nbsp;&nbsp;&nbsp;cd $dirname
+&nbsp;&nbsp;&nbsp;mkdir bin etc include lib sbin share src var
+&nbsp;&nbsp;&nbsp;ln -s share/man
+&nbsp;&nbsp;&nbsp;ln -s share/doc
+&nbsp;&nbsp;&nbsp;ln -s share/info
+&nbsp;&nbsp;&nbsp;cd $dirname/share
+&nbsp;&nbsp;&nbsp;mkdir dict doc info locale man nls misc terminfo zoneinfo
+&nbsp;&nbsp;&nbsp;cd $dirname/share/man
+&nbsp;&nbsp;&nbsp;mkdir man{1,2,3,4,5,6,7,8}
+done &amp;&amp;
+cd $LFS/var &amp;&amp;
+mkdir -p lock log mail run spool tmp opt cache lib/misc local &amp;&amp;
+cd $LFS/opt &amp;&amp;
+mkdir bin doc include info lib man &amp;&amp;
+cd $LFS/usr &amp;&amp;
+ln -s ../var/tmp</userinput></screen></para>
+
+<para>Normally, directories are created with permission mode 755, which isn't
+desired for all directories. The first change is a mode 0750 for the
+$LFS/root directory. This is to make sure that not just everybody can
+enter the /root directory (the same a user would do with /home/username
+directories). The second change is a mode 1777 for the tmp
+directories. This way, any user can write data to the /tmp or /var/tmp
+directory but cannot remove another user's files (the latter is caused
+by the so-called "sticky bit" - bit 1 of the 1777 bit mask).</para>
+
+<para><screen><userinput>cd $LFS &amp;&amp;
+chmod 0750 root &amp;&amp;
+chmod 1777 tmp var/tmp</userinput></screen></para>
+
+<para>Now that the directories are created, copy the source files that were
+downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you
+will need to create the desired directory yourself).</para>
+
+<sect2>
+<title>FHS compliance notes</title>
+
+<para>The FHS stipulates that the /usr/local directory should contain the
+bin, games,include, lib, man, sbin, and share subdirectories. You can
+alter your /usr/local directory yourself if you want your system
+to be FHS-compliant.</para>
+
+<para>Also, the standard says that there should exist a /usr/share/games
+directory, which we don't much like for a base system. But feel free to
+make your system FHS-compliant if you wish. The FHS isn't precise as
+to the structure of the /usr/local/share subdirectories, so we took the
+liberty of creating the directories that we felt needed.</para>
+
+</sect2>
+
+</sect1>
+
diff --git a/chapter05/installasroot.xml b/chapter05/installasroot.xml
deleted file mode 100644
index e959ca853..000000000
--- a/chapter05/installasroot.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<sect1 id="ch05-installasroot">
-<title>Install all software as user root</title>
-<?dbhtml filename="installasroot.html" dir="chapter05"?>
-
-<para>It's best to log in as root or su's to root when installing the
-packages. That way you are assured that all files are owned by user and
-group root (and not owned by the userid of the non-root user), and if a
-package wants to set special permissions, it can do so without problems
-due to non-root access.</para>
-
-<para>The documentation that comes with Glibc, Gcc, and other
-packages recommend not to compile the packages as user root. We
-feel it's safe to ignore that recommendation and compile as user root
-anyway. Hundreds of people using LFS have done so without any problems
-whatsoever, and we haven't encountered any bugs in the compile processes
-that cause harm. So it's pretty safe (never can be 100% safe though, so
-it's up to you what you end up doing).</para>
-
-</sect1>
-
diff --git a/chapter05/installasuser.xml b/chapter05/installasuser.xml
new file mode 100644
index 000000000..4fff1a36e
--- /dev/null
+++ b/chapter05/installasuser.xml
@@ -0,0 +1,55 @@
+<sect1 id="ch05-installasuser">
+<title>Install all software as an unprivileged user</title>
+<?dbhtml filename="installasuser.html" dir="chapter05"?>
+
+<para>When you are logged in as root during chapter 5, it is possible
+that some files of your host system will be overwritten by the ones
+you'll build in chapter 5. There can be all kinds of reasons for this
+to happen, for example because the $LFS environment variable is not
+set. Overwriting some files from your host system will most likely
+cause all kinds of problems, so it's a good idea to be logged in as
+an unprivileged user during chapter 5. To make sure the environment
+is as clean as possible, we'll create a new user lfs that can be
+used while building the static installation. Issuing the following
+commands as root will create a new user "lfs":</para>
+
+<para><screen><userinput>useradd -s /bin/bash -m lfs
+passwd lfs</userinput></screen></para>
+
+<para>Now it's time to change the permissions on your LFS partitions
+so user "lfs" will have write access to it. Run the following command
+as root to change the ownership of the LFS partition to user "lfs":</para>
+
+<para><screen><userinput>chown lfs $LFS</userinput></screen></para>
+
+<para>Now you can login as user "lfs". You can do this two ways: either
+the normal way through the console or the display manager, or with
+<userinput>su - lfs</userinput>. When you're working as user "lfs", type
+the following commands to setup a good environment to work in:</para>
+
+<para><screen><userinput>cat >~/.bash_profile <<"EOF"
+#!/bin/sh
+umask 022
+
+LFS=/mnt/lfs
+LC_ALL=POSIX
+export LFS LC_ALL
+EOF
+source ~/.bash_profile</userinput></screen></para>
+
+<para>This profile makes sure the umask is set to 022 so newly created
+files and directories will have the correct permission. It is advisable
+to keep this setting throughout your LFS installation. Also, the $LFS
+and $LC_ALL environment variables are set. $LFS has been explained in
+previous chapters already. $LC_ALL is a variable that is used for
+internationalization.</para>
+
+<para>When your host distribution uses a glibc version older than 2.2.4,
+having $LC_ALL set to something else than "C" or "POSIX" while working
+through chapter 5 may cause trouble when you've exited the chrooted
+environment of chapter 6 and try to return to it. By setting this to
+"POSIX" ("C" is an alias for "POSIX") we ensure that everything will
+work as expected in the chrooted environment.</para>
+
+</sect1>
+