[dcff046] | 1 | <chapter id="chapter-building-system" xreflabel="Chapter 6">
|
---|
[6370fa6] | 2 | <title>Installing basic system software</title>
|
---|
[576e206] | 3 | <?dbhtml filename="chapter06.html" dir="chapter06"?>
|
---|
[6370fa6] | 4 |
|
---|
[d322394] | 5 |
|
---|
[3be4d97] | 6 | <sect1 id="ch-system-introduction">
|
---|
[d322394] | 7 | <title>Introduction</title>
|
---|
| 8 | <?dbhtml filename="introduction.html" dir="chapter06"?>
|
---|
| 9 |
|
---|
| 10 | <para>In this chapter we enter the building site, and start
|
---|
| 11 | constructing our LFS system in earnest. That is, we chroot into
|
---|
| 12 | our temporary mini Linux system, create some auxiliary things,
|
---|
| 13 | and then start installing all the packages, one by one.</para>
|
---|
| 14 |
|
---|
| 15 | <para>The installation of all this software is pretty straightforward,
|
---|
| 16 | and you will probably think it would be much shorter to give here
|
---|
| 17 | the generic installation instructions and explain in full only the
|
---|
| 18 | installation of those packages that require an alternate method.
|
---|
| 19 | Although we agree with that, we nevertheless choose to give the
|
---|
| 20 | full instructions for each and every package, simply to minimize
|
---|
| 21 | the possibilities for mistakes.</para>
|
---|
| 22 |
|
---|
[5888299] | 23 | <para>The key to learning what makes a Linux system work is to know
|
---|
| 24 | what each package is used for and why the user (or the system) needs it.
|
---|
| 25 | For this purpose for every installed package a summary of its content is
|
---|
| 26 | given followed by concise descriptions of each program and library it
|
---|
| 27 | installed.</para>
|
---|
| 28 |
|
---|
[d322394] | 29 | <para>If you plan to use compiler optimizations in this chapter, take a look at
|
---|
| 30 | the optimization hint at <ulink url="&hints-root;optimization.txt"/>. Compiler
|
---|
| 31 | optimizations can make a program run slightly faster, but they may also cause
|
---|
| 32 | compilation difficulties and even problems when running the program. If a
|
---|
| 33 | package refuses to compile when using optimization, try to compile it without
|
---|
| 34 | optimization and see if the problem goes away. Even if the package does compile
|
---|
| 35 | when using optimization, there is the risk it may have been compiled incorrectly
|
---|
| 36 | due to complex interactions between the code and build tools. In short, the
|
---|
| 37 | small potential gains achieved in using compiler optimization are generally
|
---|
| 38 | outweighed by the risk. First time builders of LFS are encouraged to build
|
---|
| 39 | without custom optimizations. Your system will still be very fast and very
|
---|
| 40 | stable at the same time.</para>
|
---|
| 41 |
|
---|
| 42 | <para>The order in which packages are installed in this chapter has
|
---|
| 43 | to be strictly followed, to ensure that no program gets a path referring
|
---|
| 44 | to <filename class="directory">/tools</filename> hard-wired into it.
|
---|
| 45 | For the same reason, <emphasis>do not </emphasis> compile packages
|
---|
| 46 | in parallel. Compiling in parallel may save you some time (especially on
|
---|
| 47 | dual-CPU machines), but it could result in a program containing a
|
---|
| 48 | hard-wired path to <filename class="directory">/tools</filename>,
|
---|
| 49 | which will cause the program to stop working when that directory
|
---|
| 50 | is removed.</para>
|
---|
| 51 |
|
---|
[bfa54edc] | 52 | <para>Before the installation instructions each installation page gives some
|
---|
| 53 | information about the package: a concise description of what it contains, how
|
---|
| 54 | long it will approximately take to build it, how much disk space it needs
|
---|
| 55 | during this building process, the official download location of the package
|
---|
| 56 | (in case you just want to update a few of them), and which other packages it
|
---|
| 57 | needs in order to be built successfully. After the installation instructions
|
---|
| 58 | follows a list of programs and libraries that the package installs, together
|
---|
| 59 | with a series of short descriptions of these.</para>
|
---|
| 60 |
|
---|
[d322394] | 61 | </sect1>
|
---|
| 62 |
|
---|
[342b176] | 63 |
|
---|
| 64 | <sect1 id="ch-system-proc">
|
---|
| 65 | <title>Mounting the proc and devpts file systems</title>
|
---|
| 66 | <?dbhtml filename="proc.html" dir="chapter06"?>
|
---|
| 67 |
|
---|
| 68 | <para>In order for certain programs to function properly, the
|
---|
| 69 | <emphasis>proc</emphasis> and <emphasis>devpts</emphasis> file systems must be
|
---|
| 70 | available within the chroot environment. The proc file system is the process
|
---|
| 71 | information pseudo file system through which the kernel provides information
|
---|
| 72 | about the status of the system. And the devpts file system is nowadays the most
|
---|
| 73 | common way pseudo terminals (PTYs) are implemented. Since kernel version 2.4, a
|
---|
| 74 | file system can be mounted as many times and in as many places as you like,
|
---|
| 75 | thus it's not a problem that these file systems are already mounted on your
|
---|
| 76 | host system, especially so because they are virtual file systems.</para>
|
---|
| 77 |
|
---|
| 78 | <para>First become <emphasis>root</emphasis>, as only <emphasis>root</emphasis>
|
---|
| 79 | can mount file systems in unusual places. Then check again that the LFS
|
---|
| 80 | environment variable is set correctly by running <userinput>echo
|
---|
| 81 | $LFS</userinput> and making sure it shows the path to your LFS partition's
|
---|
| 82 | mount point, which is <filename class="directory">/mnt/lfs</filename> if you
|
---|
| 83 | followed our example.</para>
|
---|
| 84 |
|
---|
| 85 | <para>Now make the mount points for these filesystems:</para>
|
---|
| 86 |
|
---|
| 87 | <screen><userinput>mkdir -p $LFS/{proc,dev/pts}</userinput></screen>
|
---|
| 88 |
|
---|
| 89 | <para>Mount the <emphasis>proc</emphasis> file system with:</para>
|
---|
| 90 |
|
---|
| 91 | <screen><userinput>mount proc $LFS/proc -t proc</userinput></screen>
|
---|
| 92 |
|
---|
| 93 | <para>And mount the <emphasis>devpts</emphasis> file system with:</para>
|
---|
| 94 |
|
---|
| 95 | <screen><userinput>mount devpts $LFS/dev/pts -t devpts</userinput></screen>
|
---|
| 96 |
|
---|
| 97 | <para>This last command might fail with an error like:</para>
|
---|
| 98 |
|
---|
| 99 | <blockquote><screen>filesystem devpts not supported by kernel</screen></blockquote>
|
---|
| 100 |
|
---|
| 101 | <para>The most likely cause for this is that your host system's kernel was
|
---|
[e1c7e32] | 102 | compiled without support for the devpts file system (you can check which file
|
---|
| 103 | systems your kernel supports with <command>cat /proc/filesystems</command>,
|
---|
| 104 | for example). A few PTYs are needed to be able to run the suites for Binutils
|
---|
| 105 | and GCC later on. If your kernel does not support devpts, do not worry, there
|
---|
| 106 | is another way to get them working inside the chroot environment. We'll cover
|
---|
| 107 | this shortly in the <xref linkend="ch-system-MAKEDEV"/> section.</para>
|
---|
[342b176] | 108 |
|
---|
| 109 | <para>Remember that if for any reason you stop working on your LFS, and start
|
---|
| 110 | again later, it's important to check that these file systems are mounted again
|
---|
| 111 | before entering the chroot environment, otherwise problems could occur.</para>
|
---|
| 112 |
|
---|
| 113 | </sect1>
|
---|
| 114 |
|
---|
[d322394] | 115 |
|
---|
[3be4d97] | 116 | <sect1 id="ch-system-chroot">
|
---|
[d322394] | 117 | <title>Entering the chroot environment</title>
|
---|
| 118 | <?dbhtml filename="chroot.html" dir="chapter06"?>
|
---|
| 119 |
|
---|
[fe5b13b] | 120 | <para>It is time to enter the chroot environment in order to begin building
|
---|
[91e8861] | 121 | and installing your final LFS system. Still as <emphasis>root</emphasis> run
|
---|
| 122 | the following command to enter the small world that is, at the moment,
|
---|
| 123 | populated with only the temporary tools:</para>
|
---|
[d322394] | 124 |
|
---|
| 125 | <screen><userinput>chroot $LFS /tools/bin/env -i \
|
---|
| 126 | HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
|
---|
| 127 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
---|
[a195a6c] | 128 | /tools/bin/bash --login +h</userinput></screen>
|
---|
[d322394] | 129 |
|
---|
[90e3cb3] | 130 | <para>The <emphasis>-i</emphasis> option given to the
|
---|
| 131 | <command>env</command> command will clear all variables of the chroot
|
---|
[d322394] | 132 | environment. After that, only the HOME, TERM, PS1 and PATH variables are
|
---|
| 133 | set again. The TERM=$TERM construct will set the TERM variable inside chroot
|
---|
| 134 | to the same value as outside chroot; this variable is needed for programs
|
---|
[90e3cb3] | 135 | like <command>vim</command> and <command>less</command> to operate
|
---|
[d322394] | 136 | properly. If you need other variables present, such as CFLAGS or CXXFLAGS,
|
---|
| 137 | this is a good place to set them again.</para>
|
---|
| 138 |
|
---|
| 139 | <para>From this point on there's no need to use the LFS variable anymore,
|
---|
| 140 | because everything you do will be restricted to the LFS file system -- since
|
---|
| 141 | what the shell thinks is <filename class="directory">/</filename> is actually
|
---|
| 142 | the value of <filename class="directory">$LFS</filename>, which was passed to
|
---|
| 143 | the chroot command.</para>
|
---|
| 144 |
|
---|
| 145 | <para>Notice that <filename class="directory">/tools/bin</filename> comes
|
---|
| 146 | last in the PATH. This means that a temporary tool will not be used any more
|
---|
[17476c5] | 147 | as soon as its final version is installed. Well, at least when the shell
|
---|
[d322394] | 148 | doesn't remember the locations of executed binaries -- for this reason hashing
|
---|
[90e3cb3] | 149 | is switched off by passing the <emphasis>+h</emphasis> option to
|
---|
| 150 | <command>bash</command>.</para>
|
---|
[d322394] | 151 |
|
---|
| 152 | <para>You have to make sure all the commands in the rest of this chapter and
|
---|
| 153 | in the following chapters are run from within the chroot environment.
|
---|
| 154 | If you ever leave this environment for any reason (rebooting for example),
|
---|
[fe5b13b] | 155 | you must remember to first mount the proc and devpts file systems (discussed
|
---|
| 156 | in the previous section) <emphasis>and</emphasis> enter chroot again before
|
---|
| 157 | continuing with the installations.</para>
|
---|
[d322394] | 158 |
|
---|
[fe5b13b] | 159 | <para>Note that the bash prompt will say "I have no name!" This is normal, as
|
---|
| 160 | the <filename>/etc/passwd</filename> file has not been created yet.</para>
|
---|
[d322394] | 161 |
|
---|
| 162 | </sect1>
|
---|
| 163 |
|
---|
| 164 |
|
---|
[3be4d97] | 165 | <sect1 id="ch-system-changingowner">
|
---|
[d322394] | 166 | <title>Changing ownership</title>
|
---|
| 167 | <?dbhtml filename="changingowner.html" dir="chapter06"?>
|
---|
| 168 |
|
---|
| 169 | <para>Right now the <filename class="directory">/tools</filename> directory
|
---|
| 170 | is owned by the user <emphasis>lfs</emphasis>, a user that exists only on your
|
---|
| 171 | host system. Although you will probably want to delete the
|
---|
| 172 | <filename class="directory">/tools</filename> directory once you have
|
---|
| 173 | finished your LFS system, you may want to keep it around, for example to
|
---|
| 174 | build more LFS systems. But if you keep the
|
---|
| 175 | <filename class="directory">/tools</filename> directory as it is, you end up
|
---|
| 176 | with files owned by a user ID without a corresponding account. This is
|
---|
| 177 | dangerous because a user account created later on could get this same user ID
|
---|
| 178 | and would suddenly own the <filename class="directory">/tools</filename>
|
---|
| 179 | directory and all the files therein, thus exposing these files to possible
|
---|
| 180 | malicious manipulation.</para>
|
---|
| 181 |
|
---|
| 182 | <para>To avoid this issue, you could add the <emphasis>lfs</emphasis> user to
|
---|
| 183 | your new LFS system later on when creating the <filename>/etc/passwd</filename>
|
---|
| 184 | file, taking care to assign it the same user and group IDs as on your host
|
---|
| 185 | system. Alternatively, you can (and the book assumes you do) assign the
|
---|
| 186 | contents of the <filename class="directory">/tools</filename> directory to
|
---|
| 187 | user <emphasis>root</emphasis> by running the following command:</para>
|
---|
| 188 |
|
---|
| 189 | <screen><userinput>chown -R 0:0 /tools</userinput></screen>
|
---|
| 190 |
|
---|
| 191 | <para>The command uses "0:0" instead of "root:root", because
|
---|
| 192 | <userinput>chown</userinput> is unable to resolve the name "root" until the
|
---|
| 193 | password file has been created.</para>
|
---|
| 194 |
|
---|
| 195 | </sect1>
|
---|
| 196 |
|
---|
| 197 |
|
---|
[3be4d97] | 198 | <sect1 id="ch-system-creatingdirs">
|
---|
[d322394] | 199 | <title>Creating directories</title>
|
---|
| 200 | <?dbhtml filename="creatingdirs.html" dir="chapter06"?>
|
---|
| 201 |
|
---|
| 202 | <para>Let's now create some structure in our LFS file system. Let's create
|
---|
| 203 | a directory tree. Issuing the following commands will create a more or less
|
---|
| 204 | standard tree:</para>
|
---|
| 205 |
|
---|
[b3adaba] | 206 | <screen><userinput>mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc}
|
---|
[d322394] | 207 | mkdir -p /{root,sbin,tmp,usr/local,var,opt}
|
---|
| 208 | for dirname in /usr /usr/local
|
---|
| 209 | do
|
---|
| 210 | mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
|
---|
| 211 | ln -s share/{man,doc,info} $dirname
|
---|
[9c8916b] | 212 | mkdir $dirname/share/{doc,info,locale,man}
|
---|
| 213 | mkdir $dirname/share/{misc,terminfo,zoneinfo}
|
---|
[d322394] | 214 | mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
|
---|
| 215 | done
|
---|
| 216 | mkdir /var/{lock,log,mail,run,spool}
|
---|
| 217 | mkdir -p /var/{tmp,opt,cache,lib/misc,local}
|
---|
| 218 | mkdir /opt/{bin,doc,include,info}
|
---|
| 219 | mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}</userinput></screen>
|
---|
| 220 |
|
---|
| 221 | <para>Directories are, by default, created with permission mode 755, but this
|
---|
| 222 | isn't desirable for all directories. We will make two changes: one to the home
|
---|
| 223 | directory of <emphasis>root</emphasis>, and another to the directories for
|
---|
| 224 | temporary files.</para>
|
---|
| 225 |
|
---|
| 226 | <screen><userinput>chmod 0750 /root
|
---|
| 227 | chmod 1777 /tmp /var/tmp</userinput></screen>
|
---|
| 228 |
|
---|
| 229 | <para>The first mode change ensures that not just anybody can enter the
|
---|
| 230 | <filename class="directory">/root</filename> directory -- the same
|
---|
| 231 | as a normal user would do with his or her home directory.
|
---|
| 232 | The second mode change makes sure that any user can write to the
|
---|
| 233 | <filename class="directory">/tmp</filename> and
|
---|
| 234 | <filename class="directory">/var/tmp</filename> directories, but
|
---|
| 235 | cannot remove other users' files from them. The latter is prohibited
|
---|
| 236 | by the so-called "sticky bit" -- the highest bit in the 1777 bit mask.</para>
|
---|
| 237 |
|
---|
| 238 | <sect2>
|
---|
| 239 | <title>FHS compliance note</title>
|
---|
| 240 |
|
---|
| 241 | <para>We have based our directory tree on the FHS standard (available at
|
---|
| 242 | <ulink url="http://www.pathname.com/fhs/"/>). Besides the above created
|
---|
| 243 | tree this standard stipulates the existence of
|
---|
| 244 | <filename class="directory">/usr/local/games</filename> and
|
---|
| 245 | <filename class="directory">/usr/share/games</filename>, but we don't
|
---|
| 246 | much like these for a base system. However, feel free to make your system
|
---|
| 247 | FHS-compliant. As to the structure of the
|
---|
| 248 | <filename class="directory">/usr/local/share</filename> subdirectory, the FHS
|
---|
| 249 | isn't precise, so we created here the directories that we think are needed.</para>
|
---|
| 250 |
|
---|
| 251 | </sect2>
|
---|
| 252 |
|
---|
| 253 | </sect1>
|
---|
| 254 |
|
---|
| 255 |
|
---|
[3be4d97] | 256 | <sect1 id="ch-system-createfiles">
|
---|
[d322394] | 257 | <title>Creating essential symlinks</title>
|
---|
| 258 | <?dbhtml filename="createfiles.html" dir="chapter06"?>
|
---|
| 259 |
|
---|
| 260 | <para>Some programs hard-wire paths to programs which don't exist yet. In
|
---|
| 261 | order to satisfy these programs, we create a number of symbolic links which
|
---|
| 262 | will be replaced by real files throughout the course of this chapter when
|
---|
| 263 | we're installing all the software.</para>
|
---|
| 264 |
|
---|
| 265 | <screen><userinput>ln -s /tools/bin/{bash,cat,pwd,stty} /bin
|
---|
| 266 | ln -s /tools/bin/perl /usr/bin
|
---|
| 267 | ln -s /tools/lib/libgcc_s.so.1 /usr/lib
|
---|
| 268 | ln -s bash /bin/sh</userinput></screen>
|
---|
| 269 |
|
---|
| 270 | </sect1>
|
---|
| 271 |
|
---|
| 272 |
|
---|
[3be4d97] | 273 | <sect1 id="ch-system-pwdgroup">
|
---|
[b6f86141] | 274 | <title>Creating the passwd, group and log files</title>
|
---|
[d322394] | 275 | <?dbhtml filename="pwdgroup.html" dir="chapter06"?>
|
---|
| 276 |
|
---|
| 277 | <para>In order for <emphasis>root</emphasis> to be able to login and for the
|
---|
| 278 | name "root" to be recognized, there need to be relevant entries in the
|
---|
| 279 | <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files.</para>
|
---|
| 280 |
|
---|
| 281 | <para>Create the <filename>/etc/passwd</filename> file by running the following
|
---|
| 282 | command:</para>
|
---|
| 283 |
|
---|
| 284 | <screen><userinput>cat > /etc/passwd << "EOF"</userinput>
|
---|
| 285 | root:x:0:0:root:/root:/bin/bash
|
---|
| 286 | <userinput>EOF</userinput></screen>
|
---|
| 287 |
|
---|
| 288 | <para>The actual password for <emphasis>root</emphasis> (the "x" here is just a
|
---|
| 289 | placeholder) will be set later.</para>
|
---|
| 290 |
|
---|
| 291 | <para>Create the <filename>/etc/group</filename> file by running the following
|
---|
| 292 | command:</para>
|
---|
| 293 |
|
---|
| 294 | <screen><userinput>cat > /etc/group << "EOF"</userinput>
|
---|
| 295 | root:x:0:
|
---|
| 296 | bin:x:1:
|
---|
| 297 | sys:x:2:
|
---|
| 298 | kmem:x:3:
|
---|
| 299 | tty:x:4:
|
---|
| 300 | tape:x:5:
|
---|
| 301 | daemon:x:6:
|
---|
| 302 | floppy:x:7:
|
---|
| 303 | disk:x:8:
|
---|
| 304 | lp:x:9:
|
---|
| 305 | dialout:x:10:
|
---|
| 306 | audio:x:11:
|
---|
| 307 | <userinput>EOF</userinput></screen>
|
---|
| 308 |
|
---|
[c76accc] | 309 | <para>The created groups aren't part of any standard -- they are some of the
|
---|
| 310 | groups that the <command>make_devices</command> script in the next section
|
---|
[5cd6caa] | 311 | uses. The LSB (<ulink url="http://www.linuxbase.org/">Linux Standard
|
---|
[c76accc] | 312 | Base</ulink>) recommends only that, beside the group "root" with a GID of 0, a
|
---|
| 313 | group "bin" with a GID of 1 be present. All other group names and GIDs can
|
---|
| 314 | be chosen freely by the system administrator, since well-written packages don't
|
---|
| 315 | depend on GID numbers but use the group's name.</para>
|
---|
[d322394] | 316 |
|
---|
[15b6ed4] | 317 | <para>To get rid of the "I have no name!" prompt, we will start a new shell.
|
---|
[c76accc] | 318 | Since we installed a full Glibc in <xref linkend="chapter-temporary-tools"/>,
|
---|
| 319 | and have just created the <filename>/etc/passwd</filename> and
|
---|
[15b6ed4] | 320 | <filename>/etc/group</filename> files, user name and group name resolution
|
---|
| 321 | will now work.</para>
|
---|
[d322394] | 322 |
|
---|
| 323 | <screen><userinput>exec /tools/bin/bash --login +h</userinput></screen>
|
---|
| 324 |
|
---|
[90e3cb3] | 325 | <para>Note the use of the <emphasis>+h</emphasis> directive. This tells
|
---|
| 326 | <command>bash</command> not to use its internal path hashing. Without this
|
---|
| 327 | directive, <command>bash</command> would remember the paths to binaries it
|
---|
[d322394] | 328 | has executed. Since we want to use our newly compiled binaries as soon as
|
---|
| 329 | they are installed, we turn off this function for the duration of this
|
---|
| 330 | chapter.</para>
|
---|
| 331 |
|
---|
[90e3cb3] | 332 | <para>The <command>login</command>, <command>agetty</command> and
|
---|
| 333 | <command>init</command> programs (and some others) use a number of log
|
---|
[b6f86141] | 334 | files to record information such as who was logged into the system and when.
|
---|
| 335 | These programs, however, won't write to the log files if they don't already
|
---|
| 336 | exist. Initialize the log files and give them their proper permissions:</para>
|
---|
| 337 |
|
---|
| 338 | <screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
|
---|
| 339 | chmod 644 /var/run/utmp /var/log/{btmp,lastlog,wtmp}</userinput></screen>
|
---|
| 340 |
|
---|
| 341 | <para>The <filename>/var/run/utmp</filename> file records the users that are
|
---|
| 342 | currently logged in. The <filename>/var/log/wtmp</filename> file records all
|
---|
| 343 | logins and logouts. The <filename>/var/log/lastlog</filename> file records for
|
---|
| 344 | each user when he or she last logged in. The <filename>/var/log/btmp</filename>
|
---|
| 345 | file records the bad login attempts.</para>
|
---|
| 346 |
|
---|
[d322394] | 347 | </sect1>
|
---|
| 348 |
|
---|
| 349 |
|
---|
[4735209] | 350 | &c6-makedev;
|
---|
[2081905] | 351 | &c6-kernel-headers;
|
---|
[6babce5] | 352 | &c6-manpages;
|
---|
[abbd27a5] | 353 | &c6-glibc;
|
---|
[d322394] | 354 |
|
---|
| 355 |
|
---|
[a0b689e] | 356 | <sect1 id="ch-system-readjusting">
|
---|
[d322394] | 357 | <title>Re-adjusting the toolchain</title>
|
---|
[a0b689e] | 358 | <?dbhtml filename="readjusting.html" dir="chapter06"?>
|
---|
| 359 |
|
---|
| 360 | <para>Now that the new and final C libraries have been installed, it's time to
|
---|
| 361 | adjust our toolchain again. We'll adjust it so that it will link any newly
|
---|
[9da62ab] | 362 | compiled program against these new libraries. This is in fact the same thing we
|
---|
| 363 | did in the "Adjusting" phase in the beginning of the previous chapter, even
|
---|
| 364 | though it looks like the reverse: then we guided the chain from the host's
|
---|
| 365 | <filename class="directory">/{,usr/}lib</filename> to the new
|
---|
[a0b689e] | 366 | <filename class="directory">/tools/lib</filename>, now we guide it from that
|
---|
| 367 | same <filename class="directory">/tools/lib</filename>
|
---|
[9da62ab] | 368 | to the LFS's <filename class="directory">/{,usr/}lib</filename>.</para>
|
---|
[a0b689e] | 369 |
|
---|
| 370 | <para>First we adjust the linker. For this we retained the
|
---|
[d322394] | 371 | source and build directories from the second pass over Binutils. Install the
|
---|
| 372 | adjusted linker by running the following from within the
|
---|
| 373 | <filename class="directory">binutils-build</filename> directory:</para>
|
---|
| 374 |
|
---|
| 375 | <screen><userinput>make -C ld INSTALL=/tools/bin/install install</userinput></screen>
|
---|
| 376 |
|
---|
| 377 | <note><para>If you somehow missed the earlier warning to retain the Binutils
|
---|
[15b6ed4] | 378 | source and build directories from the second pass in
|
---|
[dcff046] | 379 | <xref linkend="chapter-temporary-tools"/>, or otherwise accidentally deleted them or just
|
---|
[15b6ed4] | 380 | don't have access to them, don't worry, all is not lost. Just ignore the above
|
---|
| 381 | command. The result will be that the next package, Binutils, will link against
|
---|
[a0b689e] | 382 | the C libraries in <filename class="directory">/tools</filename> rather
|
---|
[9da62ab] | 383 | than in <filename class="directory">/{,usr/}lib</filename>. This is not ideal,
|
---|
[a0b689e] | 384 | however, our testing has shown that the resulting Binutils program binaries
|
---|
| 385 | should be identical.</para></note>
|
---|
[d322394] | 386 |
|
---|
| 387 | <para>From now on every compiled program will link <emphasis>only</emphasis>
|
---|
| 388 | against the libraries in <filename>/usr/lib</filename> and
|
---|
| 389 | <filename>/lib</filename>. The extra
|
---|
[90e3cb3] | 390 | <emphasis>INSTALL=/tools/bin/install</emphasis> is needed because the Makefile
|
---|
[d322394] | 391 | created during the second pass still contains the reference to
|
---|
| 392 | <filename>/usr/bin/install</filename>, which we obviously haven't installed yet.
|
---|
| 393 | Some host distributions contain a <filename class="symlink">ginstall</filename>
|
---|
| 394 | symbolic link which takes precedence in the Makefile and thus can cause a
|
---|
| 395 | problem here. The above command takes care of this also.</para>
|
---|
| 396 |
|
---|
| 397 | <para>You can now remove the Binutils source and build directories.</para>
|
---|
| 398 |
|
---|
| 399 | <para>The next thing to do is to amend our GCC specs file so that it points
|
---|
| 400 | to the new dynamic linker. Just like earlier on, we use a sed to accomplish
|
---|
| 401 | this:</para>
|
---|
| 402 |
|
---|
| 403 | <!-- Ampersands are needed to allow cut and paste -->
|
---|
| 404 |
|
---|
| 405 | <screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
|
---|
| 406 | sed -e 's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g' \
|
---|
| 407 | $SPECFILE > newspecfile &&
|
---|
| 408 | mv -f newspecfile $SPECFILE &&
|
---|
| 409 | unset SPECFILE</userinput></screen>
|
---|
| 410 |
|
---|
| 411 | <para>Again, cutting and pasting the above is recommended. And just like
|
---|
[51fe215] | 412 | before, it is a good idea to visually inspect the specs file to verify the
|
---|
| 413 | intended change was actually made.</para>
|
---|
[d322394] | 414 |
|
---|
| 415 | <important><para>If you are working on a platform where the name of the dynamic
|
---|
| 416 | linker is something other than <filename>ld-linux.so.2</filename>, you
|
---|
| 417 | <emphasis>must</emphasis> substitute <filename>ld-linux.so.2</filename> with the
|
---|
| 418 | name of your platform's dynamic linker in the above commands. Refer back to
|
---|
[3be4d97] | 419 | <xref linkend="ch-tools-toolchaintechnotes"/> if necessary.</para></important>
|
---|
[d322394] | 420 |
|
---|
| 421 | <!-- HACK - Force some whitespace to appease tidy -->
|
---|
| 422 | <literallayout></literallayout>
|
---|
| 423 |
|
---|
| 424 | <caution><para>It is imperative at this point to stop and ensure that the
|
---|
| 425 | basic functions (compiling and linking) of the adjusted toolchain are working
|
---|
| 426 | as expected. For this we are going to perform a simple sanity check:</para>
|
---|
| 427 |
|
---|
| 428 | <screen><userinput>echo 'main(){}' > dummy.c
|
---|
[51fe215] | 429 | cc dummy.c
|
---|
[d322394] | 430 | readelf -l a.out | grep ': /lib'</userinput></screen>
|
---|
| 431 |
|
---|
| 432 | <para>If everything is working correctly, there should be no errors, and the
|
---|
| 433 | output of the last command will be:</para>
|
---|
| 434 |
|
---|
| 435 | <blockquote><screen>[Requesting program interpreter: /lib/ld-linux.so.2]</screen></blockquote>
|
---|
| 436 |
|
---|
[51fe215] | 437 | <para>(Of course allowing for platform specific differences in dynamic linker
|
---|
| 438 | name). Note especially that <filename class="directory">/lib</filename> now
|
---|
| 439 | appears as the prefix of our dynamic linker. If you did not receive the output
|
---|
| 440 | as shown above, or received no output at all, then something is seriously wrong.
|
---|
| 441 | You will need to investigate and retrace your steps to find out where the
|
---|
| 442 | problem is and correct it. There is no point in continuing until this is done.
|
---|
| 443 | Most likely something went wrong with the specs file amendment above.</para>
|
---|
[d322394] | 444 |
|
---|
| 445 | <para>Once you are satisfied that all is well, clean up the test files:</para>
|
---|
| 446 |
|
---|
| 447 | <screen><userinput>rm dummy.c a.out</userinput></screen>
|
---|
| 448 | </caution>
|
---|
| 449 |
|
---|
| 450 | <!-- HACK - Force some whitespace to appease tidy -->
|
---|
| 451 | <literallayout></literallayout>
|
---|
| 452 |
|
---|
| 453 | </sect1>
|
---|
| 454 |
|
---|
| 455 |
|
---|
[bc82645e] | 456 | &c6-binutils;
|
---|
[5e2cb65] | 457 | &c6-gcc;
|
---|
[d322394] | 458 |
|
---|
[bc82645e] | 459 | &c6-coreutils;
|
---|
[24380c7] | 460 | &c6-zlib;
|
---|
[0b6cb04] | 461 | &c6-lfs-utils;
|
---|
[abbd27a5] | 462 | &c6-findutils;
|
---|
[d7abb68] | 463 | &c6-gawk;
|
---|
[abbd27a5] | 464 | &c6-ncurses;
|
---|
| 465 | &c6-vim;
|
---|
[b42fa01] | 466 | &c6-m4;
|
---|
[abbd27a5] | 467 | &c6-bison;
|
---|
| 468 | &c6-less;
|
---|
| 469 | &c6-groff;
|
---|
[5e2cb65] | 470 | &c6-sed;
|
---|
| 471 | &c6-flex;
|
---|
| 472 | &c6-gettext;
|
---|
| 473 | &c6-nettools;
|
---|
[0b6cb04] | 474 | &c6-inetutils;
|
---|
[abbd27a5] | 475 | &c6-perl;
|
---|
| 476 | &c6-texinfo;
|
---|
| 477 | &c6-autoconf;
|
---|
| 478 | &c6-automake;
|
---|
| 479 | &c6-bash;
|
---|
| 480 | &c6-file;
|
---|
| 481 | &c6-libtool;
|
---|
| 482 | &c6-bzip2;
|
---|
[5c6ec43] | 483 | &c6-diffutils;
|
---|
[31bb453] | 484 | &c6-ed;
|
---|
[5df2845] | 485 | &c6-kbd;
|
---|
[abbd27a5] | 486 | &c6-e2fsprogs;
|
---|
| 487 | &c6-grep;
|
---|
[955533b] | 488 | &c6-grub;
|
---|
[abbd27a5] | 489 | &c6-gzip;
|
---|
[5e2cb65] | 490 | &c6-man;
|
---|
[abbd27a5] | 491 | &c6-make;
|
---|
| 492 | &c6-modutils;
|
---|
[31bb453] | 493 | &c6-patch;
|
---|
[abbd27a5] | 494 | &c6-procinfo;
|
---|
| 495 | &c6-procps;
|
---|
| 496 | &c6-psmisc;
|
---|
[2309b72] | 497 | &c6-shadow;
|
---|
[abbd27a5] | 498 | &c6-sysklogd;
|
---|
| 499 | &c6-sysvinit;
|
---|
| 500 | &c6-tar;
|
---|
| 501 | &c6-utillinux;
|
---|
[d0dfce4] | 502 | &c6-gcc-2953;
|
---|
[d322394] | 503 |
|
---|
| 504 |
|
---|
[3be4d97] | 505 | <sect1 id="ch-system-revisedchroot">
|
---|
[d322394] | 506 | <title>Revised chroot command</title>
|
---|
| 507 | <?dbhtml filename="revisedchroot.html" dir="chapter06"?>
|
---|
| 508 |
|
---|
| 509 | <para>From now on when you exit the chroot environment and wish to re-enter
|
---|
| 510 | it, you should run the following modified chroot command:</para>
|
---|
| 511 |
|
---|
| 512 | <screen><userinput>chroot $LFS /usr/bin/env -i \
|
---|
| 513 | HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
|
---|
| 514 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \
|
---|
| 515 | /bin/bash --login</userinput></screen>
|
---|
| 516 |
|
---|
| 517 | <para>The reason being there is no longer any need to use programs from the
|
---|
| 518 | <filename class="directory">/tools</filename> directory. However, we don't
|
---|
| 519 | want to remove the <filename class="directory">/tools</filename> directory
|
---|
| 520 | just yet. There is still some use for it towards the end of the book.</para>
|
---|
| 521 |
|
---|
| 522 | </sect1>
|
---|
| 523 |
|
---|
| 524 |
|
---|
| 525 | &c6-aboutdebug;
|
---|
[6370fa6] | 526 |
|
---|
| 527 | </chapter>
|
---|
| 528 |
|
---|