This is the YGLFS book,
a "patched" LFS book by Yann Guidon (whygee@f-cpu.org).

Revision :
  created april 11th, 2002 from the LFS-BOOK 3.3
  version Fri Apr 12 09:46:48 CEST 2002
  version Fri Apr 12 20:57:23 CEST 2002  bzip2 works :-)))
  version Sun Apr 14 05:09:22 CEST 2002 : updated a flag in diffutils,
     the script works up to grep, Gerard and i try to agree on a way to
     detect the glibc version.
  version Mon Apr 15 05:41:14 CEST 2002 Linux source decompression works !
     i finally found a rather good way to extract the directory name
     from the archive. the glibc chore is left to the user but
     there's a test anyway on /bin/glibcbug.
  version Mon Apr 15 10:35:33 CEST 2002 STEP 1 is almost complete.
     I have to add the group/passwd stuff and i start the chroot scripts.
  version Fri Apr 26 11:08:06 CEST 2002 : glibc is finally compiled.
     I modified the locale and the time zone so it's done automatically.
     Also added nano command file.
  version Fri Apr 26 17:25:56 CEST 2002 : works up to file-3.37
  version Fri Apr 26 18:20:50 CEST 2002 : bzip2 passes.
    I start to realize that there might be incompatibilities
    between chap. 5 and 6 because time has elapsed since i made
    the first scripts... i'll have to check that new packages
    don't conflict.
  version Sat Apr 27 16:57:17 CEST 2002 : BSD init scripts are made.
  version Sat Apr 27 18:50:18 CEST 2002 : Chapter 6 is finally finished !


Overview and definition:
YGLFS means "Whygee's Linux Factory System" and is an obvious
play on the acronym LFS, which (also) means "Linux From Scratch".

YGLFS is a personal effort at automating a LFS for domestic use,
without the XML stuff of ALFS. And it is not exactly a "pure" LFS
because i want to be able to add or remove things easily, the constraint
is not only put on the updates. So i don't/can't use "pure" LFS
scripts or utilities, it must provide a certain degree of customization
and autoconfiguration that is at least this of the raw LFS.

YGLFS is also a mutant virus that has to be able to duplicate itself
semi-automatically (fstab and other things remain the user's work).
May be the term "virus" is inadapted, the process looks more like
a bacteria that replicates itself, but with some possible updates.
So i created a specific directory structure that is located under
/usr/yglfs where the computer (host or target) can mount either
a partition or link to its / for updating itself.

I do this for myself because i need
it terribly (one must be incredibly desperate to do that, so you
figure) but i do follow the "good rules" because :
 - i will probably need to maintain it personally
 - it could be useful to others
So i write this doc, the scripts and the whole damn thing
as if it was a "real" (yet dirty) distro but don't rely on me for anything.
If it is distributed, it is in the spirit of the LFS project :

GNU, open-minded, do-it-yourself, RTFM, and "please respect
the copyrights". It is a "derived work" from LFS so i can't
do much.

YGLFS follows more or less the LFS book so i just stepped into it
and renamed the file :-) Only the differences or important things
remain : read the damn whole original book anyway.

YGLFS is mainly made of bash scripts that automate 90% of the LFS chores :
"checks, decompression, configure, make, make install, erase".
It is also aimed at making results that can be reproduced, so it
can be used on several computers alike and still remain configurable.
It is also a good performance test suite :-) the output files can
give the elapsed time and hint you where your machine lags.

CPU version :
My home contains 2 x 586 and 2 x 686 : I include the uname trick
so the installs can be "optimised" individually. The scripts try to
verify the platform version and desired target to avoid mixing several CPU
versions, but be careful anyway (ie, when going back to the original
platform). This could be even better automated but it's a personal
distro so there's no point yet.

The main scripts will look into src/uname-trick and try to execute
comands.auto which will setup the target CPU. The original script
is called commands.auto.rename so either copy-and-rename it (so you
can change the target platform) or symlink it :
  ln -s commands.auto.rename commands.auto

Program overview :
As it follows the LFS book, the first parts reuse a lot from it
(as well as the BLFS book (?)). However, because i would like to automate
several compiles, i have split the whole thing into several steps and the
temporary results can be stored and retrieved for convenience
(no need to manually rerun the whole compile and chroot things only for
installing a computer with a slightly different option...).

* STEP 0 : check and prepare your computer
check the lib(n)curses, your glibc version, the CPU version
and the archive's integrity and version...

* STEP 1 : compile the static "base" in $YGLFS/root_base/
script : make_base.sh

$YGLFS/root_base/ can be saved and reused later. The necessary
files are copied to the proper directory in the new virtual
system so the whole thing can be restored even when no YGLFS
distro is present on the computer (you could even erase the
original source packages if you run out of room).

* STEP 2 : chroot, compile the base system and prepare the file hierarchy
  in $YGLFS/root_chroot
script : make_chroot

After this step is performed, the whole directory can also be
saved and reused later. We still run in a "virtual system" that
can be copied to another (compliant) platform or a new partition.
You could even put that on a CDROM and boot from this ;-P

* STEP 3 : LILO and reboot.

This must be done by the user because the different computers
have different HDD settings and layouts. No scripts, but some
text files anyway. fstab and some drivers (PCMCIA ? SCSI ?) must be
manually checked here.

* STEP 4 : Base sytem configuration

This represents the end of the LFS book and some parts from
BLFS. Keymap, cdrom, hdparm, clock, mouse, gpm environment variables, ...
a simple SysvInit script (as described in the hints) is nice and
small, easy to understand, so i'll try to hack into it.

* STEP 5 : console mode utilities

network, device drivers, sound...

* STEP 6 : X11 and window manager

graphic display and smiling icons, PostScript and TrueType fonts,
KDE or GNOME ? 9wm of course ;-) I'll give DirectFB a try, otherwise
i'm really forced to install the X11 stuff myself.


Before copying to the virtual system, the YGLFS scripts are available
at $YGLFS/src/* and then copied to $YGLFS/root_xxx/usr/lfs
(from the non-chrooted point of view).
By correctly playing with $YGLFS, the transition of the system
to the new platform (and back) should not even be noticed. It's really
nice because i usually use a HDD rack for cloning the system
so I just have to care about the $YGLFS variable.


Updating YGLFS :
  This certainly involves checking the LFS changelog, downloading
new files and verifying modifications of the individual package
scripts. If new packages are added, they must conform to the general
YGLFS layout, their name and parameters must be added to the
"database" (a few text files that are interpreted by the scripts).
That's some manual manipulations, yes, but there's no dependency
hell like with rpm/deb packages.


Before we start, here is a checklist :

Though YGLFS tries to automate things as much as possible, a lot of
things remain the user's task ! After all, LFS is not all about doing
things by hand but also checking and setting things up.

 * verify your system setup ! detecting the glibc version might be
easier for the user than the scripts. If the script hangs when
searching glibc, make a file called /bin/glibcbug
containing the line VERSION="X.Y.Z" (with your computer's settings).
However, at the early stages, glibc version chores are left to the
user, particularly when dealing with the different command versions



This "Book" :
YGLFS is heavily based on the LFS book but i took things away from this
file because they are either redundant, pointless or obvious. Refer
to the most recent LFS files for the missing parts. And don't forget
that we can automate something that we have already done by hand
so take the time to do it yourself before using YGLFS.

Here comes the rip-off :
*********************************************************************

Linux From Scratch

Version 3.3

Gerard Beekmans

   Copyright  1999-2002 by Gerard Beekmans

   This book describes the process of creating a Linux system from
   scratch from an already installed Linux distribution, using nothing
   but the sources of the software that we use.

   Copyright (c) 1999-2002, Gerard Beekmans

   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:

     * Redistributions in any form must retain the above copyright
       notice, this list of conditions and the following disclaimer.
     * Neither the name of "Linux From Scratch" nor the names of its
       contributors may be used to endorse or promote products derived
       from this material without specific prior written permission.
     * Any material derived from Linux From Scratch must contain a
       reference to the "Linux From Scratch" project.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     _________________________________________________________________

BIG SNIP by YG
     _________________________________________________________________

About $LFS

   Please read the following carefully: throughout this book the variable
   $LFS will be used frequently. $LFS must at all times be replaced with
   the directory where the partition that contains the LFS system is
   mounted. How to create and where to mount the partition will be
   explained in full detail in chapter 4. For example, let's assume that
   the LFS partition is mounted on /mnt/lfs.

   For example when you are told to run a command like ./configure
   --prefix=$LFS you actually have to execute ./configure
   --prefix=/mnt/lfs

   It's important that this is done no matter where it is read; be it in
   commands entered in a shell, or in a file edited or created.

   A possible solution is to set the environment variable LFS. This way
   $LFS can be entered literally instead of replacing it with /mnt/lfs.
   This is accomplished by running:

   export LFS=/mnt/lfs

   Now, if you are told to run a command like ./configure --prefix=$LFS
   you can type that literally. Your shell will replace $LFS with
   /mnt/lfs when it processes the command line (meaning when you hit
   enter after having typed the command).

   If you plan to use $LFS, do not forget to set the $LFS variable at all
   times. If the variable is not set and is used in a command, $LFS will
   be ignored and whatever is left will be executed. A command like echo
   "root:x:0:0:root:/root:/bin/bash" > $LFS/etc/passwd without the $LFS
   variable set will re-create your host system's /etc/passwd file.
   Simply put: it will destroy your current password database file.

   One way to make sure that $LFS is set at all times is adding it to the
   /root/.bash_profile and /root/.bashrc files so that every time you
   login as user root, or you 'su' to user root, the $LFS variable is
   set.
     _________________________________________________________________

Actually, with YGLFS, $LFS is set by the scripts, which create
$LFS from $YGLFS. It is set by default to /LFS (don't add any
trailing '/'), which can be a symlink to the real location.
You can also preset it by writing "export YGLFS=/home/your/dir"
for example. The scripts check whether the variables are correctly
set (to a certain limited extent, don't expect too much either).
The idea is that with a simple symlink from the root directory,
you don't have to remember the exact location all the time.

     _________________________________________________________________

How to download the software

   Throughout this document, we will assume that all the packages that
   were downloaded are placed somewhere in $LFS/usr/src.

   A convention you could use is having a $LFS/usr/src/sources directory.
   Under sources, you can create the directory 0-9 and the directories a
   through z. A package like sysvinit-2.84.tar.bz2 is stored under
   $LFS/usr/src/sources/s/. A package like bash-2.05a.tar.bz2 is stored
   under $LFS/usr/src/sources/b/, and so forth.

   The next chapter contains the list of all the packages that need to be
   downloaded, but the partition that is going to contain our LFS system
   isn't created yet. Therefore, you should store the files somewhere
   else and later on move them to $LFS/usr/src/ when the chapter in which
   the new partition is prepared has been finished.
     _________________________________________________________________

The YGLFS sources are all located under $YGLFS/src/pkgs, "as is"
(that's at least 300MB but who cares) and they are unpacked
"on demand" by the scripts. They are later copied to the
$YGLFS/root_base/usr/yglfs/src/pkgs directory before the chroot step.
There is a single directory because it eases the scripts, which can
easily find its files with a simple regular expression ("basename*")

This $YGLFS/src/pkgs directory can be symlinked or hardlinked,
but the files may not be linked (i'm not sure the script would
apreciate, you know, i'm a beginner at this scripting sport).

Usually, if you want to customize or update the distro,
you just put your new file there and eventually remove
the old version. Because it uses regular expressions to find
the correct source package, be careful with the basename !
It must be unique (no "basenae-a" and "basename-b" in the same
directory) or the script will hang. I told you i'm a beginner.

It allows one to update the source package with a simple
file copy to src/pkgs, without having to update something else.
Adding a new source file consists in registering it in the correct
script's database (there are several steps and the new package
is probably useful in only one or two of them).
     _________________________________________________________________

   Before you can actually start doing something with a package, you need
   to unpack it first. Often the package files are tar'ed and gzip'ed or
   bzip2'ed. We're not going to write down every time how to unpack an
   archive. We'll explain how to do that once, in this section.
(SNIP)
   After a package has been installed, two things can be done with it:
   either the directory that contains the sources can be deleted, or it
   can be kept. We highly recommend deleting it. If you don't do this and
   try to re-use the same source later on in the book (for example
   re-using the source trees from chapter 5 for use in chapter 6), it may
   not work as you expect it to. Source trees from chapter 5 will have
   your host distribution's settings, which don't always apply to the LFS
   system after you enter the chroot'ed environment. Even running
   something like make clean doesn't always guarantee a clean source
   tree.

   So, save yourself a lot of hassle and just remove the source directory
   immediately after you have installed it.

   There is one exception; the kernel source tree. Keep it around as you
   will need it later in this book when building a kernel. Nothing will
   use the kernel tree so the source tree won't be in your way. If,
   however, you are short of disk space, you can remove the kernel tree
   and re-untar it later when required.
     _________________________________________________________________

This part is (should be) automatically done.
 - A source package is not extracted unless required
 - The patches are automatically done (one patch per package only, though)
 - The compression format is automatically recognized
 - The source directory is erased after use.

When an error occurs, the uncompressed source tree is not removed,
but will probably be erased when the script restarts, so be careful
when you debug.
     _________________________________________________________________

Which Platform?

   LFS intends to be as far as possible platform independent. Having said
   that, the main LFS development work occurs on the x86 platform. We
   attempt to include information where possible on differences for other
   platforms such as PPC. If you come across a problem compiling which is
   not related to the x86 platform, still feel free to ask for help on
   the mailing lists. Even better, if you come up with a solution to a
   particular problem related to one of the other platforms, please let
   us know at the lfs-dev mailing list. We will then (subject to
   confirming it works) include that in the book.
     _________________________________________________________________

There is a uname module that "patches" the kernel's CPU ID
so if you want to use it, go to the src/uname-trick directory,
update the target to your desired one and rename the "commands" file
to commands.auto so that the scripts will execute it during the first
steps. This is limited to x86, though. I haven't yet found a way to
cross-compile for the F-CPU or any other platform.
     _________________________________________________________________

II. Part II - Installing the LFS system
     _________________________________________________________________

That's where it becomes interesting ;-D
     _________________________________________________________________

Chapter 3. Packages that need to be downloaded
     _________________________________________________________________

Introduction

   Below is a list of all the packages that are needed to download for
   building the basic system. The version numbers printed correspond to
   versions of the software that is known to work and which this book is
   based on. If you experience problems which you can't solve yourself,
   then please download the version that is assumed in this book (in case
   you downloaded a newer version).

   All the URL's below are to the ftp.linuxfromscratch.org server. We
   have a couple of FTP mirrors available from which you can download the
   files as well. The addresses of the mirror sites can be found in
   [268]Chapter 1 - Book Version.
     _________________________________________________________________

To update YGLFS, simply go to the LFS site and update your sources
packages, the book, the hints and the latest commands. Take care
however, if the conventions change between LFS and YGLFS.

At this time of writing, the available lfs-commands are not synchronized
with the new LFS-BOOK 3.3 so i have manually patched a few lfs-commands to
reflect the latest changes.
     _________________________________________________________________

   Please note that all files downloaded from the LFS FTP archive are
   files compressed with bzip2 instead of gz. If you don't know how to
   handle bz2 files, check out [270]Chapter 2 - How to install the
   software.
     _________________________________________________________________

YGLFS contains additional files that are provided by other sites,
for example those indicated by the BLFS book. Mixed GZIP and BZ2
files are correctly managed (that's most of the LFS chore).

A YGLFS "distro" could however contain the whole source tree
that is re-compressed only with bzip2 for uniformity and saving
room, but it's only an idea yet.
     _________________________________________________________________

Packages that need to be downloaded
     _________________________________________________________________

It should come with the YGLFS archive but you can check the LFS site
or the links from BLFS as a starting point.
     _________________________________________________________________

Chapter 4. Preparing a new partition
     _________________________________________________________________

YGLFS is first compiled and chrooted to a directory so it can be copied
to a number of partitions later. LILO is configured and called by the
user, to prevent any script problem/collision.

Usually you would extract the original YGLFS archive to a directory
where you have enough room (at least 1 GB maybe) and make a symlink
to this from /LFS or update your environment variable $YGLFS.

Creating partitions etc. is left for the end user on a case-by-case
basis, read the original book and some HOWTOs if you're not sure.
Like in the original LFS.

In fact, YGLFS does not care a lot if you're using in a chrooted
environment or as a real booted way, but be careful anyway during
the first "bootstrap steps" (1 to 3). Later, the environment
can be chrooted or not, in the host's rack or in the target
computer, it doesn't change much (but don't forget to keep uname
and $YGLFS up to date !)
     _________________________________________________________________

   Now that we have created a file system, it is ready for use. All we
   have to do to be able to access the partition (as in reading data from
   and writing data to) is mount it. If it is mounted under /mnt/lfs,
   this partition can be accessed by cd'ing to the /mnt/lfs directory.
   This book will assume that the partition was mounted under /mnt/lfs.
   It doesn't matter which directory is chosen, just make sure you
   remember what you chose.

   Create the /mnt/lfs directory by running:

   mkdir -p /mnt/lfs

   Now mount the LFS partition by running:

   mount /dev/xxx /mnt/lfs

   Replace "xxx" by the partition's designation (like hda11).

   This directory (/mnt/lfs) is the $LFS variable you have read about
   back in chapter 2. If you were planning to make use of the $LFS
   environment variable, export LFS=/mnt/lfs has to be executed now.

   If you decided to create multiple partitions for LFS (say $LFS and
   $LFS/usr), mount them like this:

mkdir -p /mnt/lfs &&
mount /dev/xxx /mnt/lfs &&
mkdir /mnt/lfs/usr &&
mount /dev/yyy /mnt/lfs/usr

   Of course, replace /dev/xxx and /dev/yyy with the appropriate
   partition designations.
     _________________________________________________________________

Notice that wether we use /mnt/lfs, usr/src/lfs or something else
does not matter much as long as YGLFS is correctly set. This allows
the system to work well in all cases : when creatin the chroot
environment, when installing the base system (in chroot) or when
updating the remaining stuff.
To a certain point (in chroot and later in native mode),
'/usr/yglfs/root' could be a symlink to '/'. Updating the system becomes
easy, then.
     _________________________________________________________________

Chapter 5. Preparing the LFS system
     _________________________________________________________________

That's the "static" part, or "step 1".
     _________________________________________________________________

   The key to learning what makes Linux tick is to know exactly what
   packages are used for and why a user or the system needs them.
   Descriptions of the package content are provided after the
   Installation subsection of each package and in Appendix A as well.
     _________________________________________________________________

I removed the descriptions to make this file smaller, not repeating useless
stuff and taking the risk to make deprecated stuff (in the future)
==> check the LFS project.
     _________________________________________________________________

   Before we start, make sure the LFS environment variable is setup
   properly if you decided to make use of it. Run the following:

   echo $LFS

   Check to make sure the output contains the correct directory to the
   LFS partition's mount point (/mnt/lfs for example).
     _________________________________________________________________

That's done (more or less) by the scripts.
     _________________________________________________________________

Install all software as an unprivileged user
     _________________________________________________________________

That's not necessary, the script (even in development stage)
is meant to work and avoid these problems. But since it's still
a proto, be careful anyway.
     _________________________________________________________________

   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 su -
   lfs. When you're working as user "lfs", type the following commands to
   setup a good environment to work in:

cat > ~/.bash_profile << "EOF"
umask 022

LFS=/mnt/lfs
LC_ALL=POSIX
export LFS LC_ALL
EOF
source ~/.bash_profile

   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.
     _________________________________________________________________

ok, copy&pasted.
     _________________________________________________________________

Creating directories

   Let's now create the directory tree on the LFS partition based on the
   FHS standard, which can be found at [394]http://www.pathname.com/fhs/.
     _________________________________________________________________

The script is sourced from $YGLFS/lfs-commands/chapter4/creating-dirs
     _________________________________________________________________

   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).
     _________________________________________________________________

This is done to the $YGL/usr/yglfs/src/pkgs directory.
In fact, almost everything is copied there, except of course
the root_*** directories (which might contain LFS images
at a certain points of maturation).

I have added a flag that shortens the test times :
$YGLFS_TEST, when non void, simply links the directory.
I have measured around 30 seconds for the duplication of 300MB,
that's for what it's worth.

And now, we are really entering in the matter.
     _________________________________________________________________

Installing Bash-2.05a

   Before you attempt to install Bash, you have to check to make sure
   your distribution has the /usr/lib/libcurses.a and
   /usr/lib/libncurses.a files. If your host distribution is an LFS
   system, all files will be present if you followed the instructions of
   the book version you read exactly.
     _________________________________________________________________

argfh, my SuSE is not correctly configured. There's /usr/lib/libncurses.a
but no libcurses.a :-/ Thank you, LFS.
     _________________________________________________________________

   If both of the files are missing, you have to install the ncurses
   development package. This package is often called something like
   ncurses-dev. If this package is already installed, or you just
   installed it, check for the two files again. Often the libcurses.a
   file is (still) missing. If so, then create libcurses.a as a symlink
   by running the following commands as user root:

cd /usr/lib &&
ln -s libncurses.a libcurses.a
     _________________________________________________________________

it's both easy and painful to do this by hand... but when it works...
     _________________________________________________________________

   Now we can continue. Install Bash by running the following commands:
     _________________________________________________________________

this is in lfs-commands/chapter5/bash-2.05a
     _________________________________________________________________

   If the make install phase ends with something along the lines of

install-info: unknown option `--dir-file=/mnt/lfs/usr/info/dir'
usage: install-info [--version] [--help] [--debug] [--maxwidth=nnn]
        [--section regexp title] [--infodir=xxx] [--align=nnn]
        [--calign=nnn] [--quiet] [--menuentry=xxx]
        [--info-dir=xxx]
        [--keep-old] [--description=xxx] [--test]
        [--remove] [--] filename
make[1]: *** [install] Error 1
make[1]: Leaving directory `/mnt/lfs/usr/src/bash-2.05a/doc'
make: [install] Error 2 (ignored)

   then that means that you are probably using Debian, and that you have
   an old version of the texinfo package. This error is not severe by any
   means: the info pages will be installed when we recompile bash
   dynamically in chapter 6, so you can ignore it.

   When we tested it with the latest Debian version, the last two
   commands were executed because the install process didn't return with
   a value larger than 0. But you would do good to check if you have the
   $LFS/bin/sh symlink on your LFS partition. If not, run the last two
   commands manually now.
     _________________________________________________________________

mmmm just for the sport, i check that in the script.
bash compiles fine, uname_trick works.
     _________________________________________________________________

Installation of Binutils

   This package is known to behave badly when you have changed its
   default optimization flags (including the -march and -mcpu options).
     _________________________________________________________________

it seems that uname_trick works. if not, it fakes it nicely.
     _________________________________________________________________

   Binutils is best left alone, so we recommend you unsetting CFLAGS,
   CXXFLAGS and other such variables/settings that would change the
   default optimization that it comes with.

   Install Binutils by running the following commands:
     _________________________________________________________________

cf lfs-commands/chapter5/binutils-2.11.2

There seems however to be a difference with the commands-3.2
where the mkdir command is not included. so i have manually
cut&pasted a binutils-2.12 file and removed binutils-2.11.2
from my commands directory.
For easing the recovery of failed compilations, i have also added a -p
to the initial mkdir command.
     _________________________________________________________________

Command explanations

   mkdir ../binutils-build: The installation instructions for Binutils
   recommend creating a seperate build directory instead of compiling the
   package inside the source tree. So, we create a binutils-build
   directory and work from there.
     _________________________________________________________________

hmmmmmmmmm.... that's annoying when we're trying to make a generic
script that loops over the different packages...
I'll have to hack into it, and the -p parameter to mkdir is only a
beginning.
     _________________________________________________________________

   tooldir=$LFS/usr: Normally, the tooldir (the directory where the
   executables from binutils end up in) is set to
   $(exec_prefix)/$(target_alias) which expands into, for example,
   /usr/i686-pc-linux-gnu. Since we only build for our own system, we
   don't need this target specific directory in $LFS/usr. That setup
   would be used if the system was used to cross-compile (for example
   compiling a package on the Intel machine that generates code that can
   be executed on Apple PowerPC machines).
     _________________________________________________________________

i should remember that for F-CPU.

And now, something easier :-)
     _________________________________________________________________

Installation of Bzip2
     _________________________________________________________________

cf lfs-commands/chapter5/bzip2-1.0.1
looks harmless.
     _________________________________________________________________

Installation of Diffutils

   When installing Diffutils using glibc-2.1.x on your base system, it
   may be necessary to use a fix to prevent a variable name conflict. The
   following commands can be used in this case. Note that these commands
   can also be used for other glibc versions so if you aren't sure, then
   use the first version.

export CPPFLAGS=-Dre_max_failures=re_max_failures2 &&
./configure --prefix=$LFS/usr --disable-nls &&
unset CPPFLAGS &&
make LDFLAGS=-static &&
make install

   If you are using a newer glibc version (2.2.x), you can use the
   following commands to install Diffutils:

./configure --prefix=$LFS/usr --disable-nls &&
make LDFLAGS=-static &&
make install
     _________________________________________________________________

I have modified the script diffutils-2.7 but i'm not sure that
my grep hack is nice. Please correct me if i'm wrong.

a CVS version of the book writes :
> Installing Diffutils-2.8.1
> ./configure --prefix=$LFS/usr --bindir=$LFS/bin \
>    --disable-nls --disable-perl-regexp &&
>
>    --disable-perl-regexp: This configure option makes sure Grep is not
>    linked against the PCRE library, which is often only available as a
>    shared library in distributions. Not using this option might result in
>    a compilation error.

i haven't had any problem (it's normal because i have not chrooted
yet) but i updated the corresponding script.
     _________________________________________________________________

Installation of Fileutils

   The programs from a statically linked fileutils package may cause
   segmentation faults on certain systems, if your distribution has
   Glibc-2.2.3 or higher installed. It also seems to happen mostly on
   machines powered by an AMD CPU, but there is a case or two where an
   Intel system is affected as well. If your system falls under this
   category, try the following fix.

   Note that in some cases using these sed commands will result in
   problems not being able to compile this package at all, even when your
   system has an AMD CPU and has Glibc-2.2.3 (or higher) installed. If
   that's the case, you'll need to remove the fileutils-4.1 directory and
   unpack it again from the tarball before continuing. We believe this
   may be the case when your distribution has altered Glibc-2.2.3
   somehow, but details are unavailable at the time.

   To fix this package to compile properly on AMD/Glibc-2.2.3 machines,
   run the following commands. Do not attempt this fix if you don't have
   Glibc-2.2.3 installed. It will more than likely result in all kinds of
   compile time problems.
     _________________________________________________________________

I added a conditional code.
     _________________________________________________________________

   Once you have installed fileutils, you can test whether the
   segmentation fault problem has been avoided by running $LFS/bin/ls. If
   this works, then you are OK. If not, then you need to re-do the
   installation using the sed commands if you didn't use them, or without
   the sed commands if you did use them.
     _________________________________________________________________

I can do the exec, the user will have to do the rest if it fails.
     _________________________________________________________________

Installing Gawk-3.1.0
     _________________________________________________________________

note : Gawk is new and was not present in LFS v3.2.
     _________________________________________________________________

   Warning: do NOT run make uninstall on this package if you apply the
   sed fix to change the libexec directory definition. The uninstall rule
   in the Makefile file runs a command like rm -rf <libexecdir>/* Since
   we change the libexec directory to /usr/bin it'll run rm -rf
   /usr/bin/*

   When installing Gawk using glibc-2.1.x on your base system, it may be
   necessary to use a fix to prevent a variable name conflict. The
   following commands can be used in this case. Note that these commands
   can also be used for other glibc versions so if you aren't sure, then
   use the first version.
<snip>
   If you are using a newer glibc version (2.2.x), you can use the
   following commands to install Gawk:
     _________________________________________________________________

cut & pasted + hacked in gawk-3.1.0
     _________________________________________________________________

Installing GCC-2.95.3

   This package is known to behave badly when you have changed its
   default optimization flags (including the -march and -mcpu options).
   GCC is best left alone, so we recommend you unsetting CFLAGS, CXXFLAGS
   and other such variables/settings that would change the default
   optimization that it comes with.

   Install GCC by running the following commands:

<snip>
rmdir $LFS/usr/*-gnu/include &&
rmdir $LFS/usr/*-gnu

   rmdir $LFS/usr/*-gnu/include and rmdir $LFS/usr/*-gnu: These
   directories are created as empty directories by GCC and serve
   absolutely no purpose whatsoever. It's related to cross-compilers but
   that doesn't apply to us and it's considered a bug in GCC that you
   can't turn that off, especially since they end up being empty
   directories. So we remove them manually.
     _________________________________________________________________

these last two lines were absent from the 3.2 lfs-commands -> updated.
     _________________________________________________________________

Installing Grep-2.5

   When installing Grep using glibc-2.1.x on your base system, it may be
   necessary to use a fix to prevent a variable name conflict. The
   following commands can be used in this case. Note that these commands
   can also be used for other glibc versions so if you aren't sure, then
   use the first version.

export CPPFLAGS=-Dre_max_failures=re_max_failures2 &&
./configure --prefix=$LFS/usr --disable-nls --bindir=$LFS/bin &&
unset CPPFLAGS &&
make LDFLAGS=-static &&
make install

   If you are using a newer glibc version (2.2.x), you can use the
   following commands to install Grep:

./configure --prefix=$LFS/usr --disable-nls \
   --bindir=$LFS/bin &&
make LDFLAGS=-static &&
make install
     _________________________________________________________________

I have renamed and updated the command file.
     _________________________________________________________________

Installing Gzip-1.2.4a

   Before Gzip is installed, the patch file may need to be applied. This
   patch file is necessary to avoid a conflict of variable names with
   Glibc-2.0 systems when compiling and linking statically and so is only
   required if your base system runs Glibc-2.0. It is however safe to
   apply the patch even if you are running a different glibc version, so
   if you aren't sure, it's best to apply it.

   Apply the patch by running the following command:

   patch -Np1 -i ../gzip-1.2.4a.patch

   Install Gzip by running the following commands:

./configure --prefix=$LFS/usr &&
make LDFLAGS=-static &&
make install &&
cp $LFS/usr/bin/gunzip $LFS/usr/bin/gzip $LFS/bin &&
rm $LFS/usr/bin/gunzip $LFS/usr/bin/gzip
     _________________________________________________________________

Command explanations

   cp $LFS/usr/bin/gunzip $LFS/usr/bin/gzip $LFS/bin && rm
   $LFS/usr/bin/gunzip $LFS/usr/bin/gzip: The reason we don't simply use
   "mv" to move the files to the new location is because gunzip is a
   hardlink to gzip. On older distributions you can't move a hardlink to
   another partition (and it's very possible that $LFS and $LFS/usr are
   separate partitions). With more recent distributions this isn't a
   problem. If you run mv to move hardlinks across partitions it'll just
   do a regular "cp" and discard the hardlink. But, we can't assume that
   every host distribution has a new enough kernel and fileutils that
   works this way.
     _________________________________________________________________

     _________________________________________________________________

Installing Linux Kernel-2.4.18

   We won't be compiling a new kernel image yet. We'll do that after we
   have finished the installation of the basic system software in this
   chapter. But because certain software needs the kernel header files,
   we're going to unpack the kernel archive now and set it up so that we
   can compile the packages that need the kernel.

   The kernel configuration file is created by running the following
   command:
     _________________________________________________________________

<snip> ok
     _________________________________________________________________

Installing Make-3.79.1

   Install Make by running the following commands:
     _________________________________________________________________

<snip> ok, no problem at all.
     _________________________________________________________________

Installing Patch-2.5.4

Command explanations

   CPPFLAGS=-D_GNU_SOURCE: Adding -D_GNU_SOURCE to CPPFLAGS command
   before we configure patch fixes installation of the package on PPC and
   m68k platforms (that we know of). It also doesn't hurt compilation on
   other platforms (such as x86) so we do it by default.
     _________________________________________________________________

ok, i updated the command. Nothing to notice otherwise.
     _________________________________________________________________

Installing Sed-3.02

   When installing Sed using glibc-2.1.x on your base system, it may be
   necessary to use a fix to prevent a variable name conflict. The
   following commands can be used in this case. Note that these commands
   can also be used for other glibc versions so if you aren't sure, then
   use the first version.
     _________________________________________________________________

ok, split into 2 files. nothing to remark.
     _________________________________________________________________

Installing Sh-utils-2.0

   Before Sh-utils is installed, the sh-utils patch file may need to be
   applied. This patch is needed to avoid a conflict of variable names
   with certain Glibc versions (usually glibc-2.1.x) when compiling
   sh-utils statically. It is however safe to apply the patch even if you
   are running a different glibc version, so if you aren't sure, it's
   best to apply it.
     _________________________________________________________________

ok, i split the file. nothing to say.
     _________________________________________________________________

Installing Tar-1.13

   To be able to directly use bzip2 files with tar, use the tar patch
   available from the LFS FTP site. This patch will add the -j option to
   tar which works the same as the -z option to tar (which can be used
   for gzip files).
     _________________________________________________________________

command is modified, patch applied.
     _________________________________________________________________

Installing Texinfo-4.1
     _________________________________________________________________

I just renamed the texinfo-4.0 command to 4.1.
     _________________________________________________________________

Installing Textutils-2.0
     _________________________________________________________________

nothing to say.

Chapter 5 is almost finished, yeah !
So let's simply add a "tag" to the new filesystem under $LFS/usr/yglfs/.step1 !
     _________________________________________________________________

Creating passwd and group files
     _________________________________________________________________

   Create a new file $LFS/etc/passwd by running the following command:
   Create a new file $LFS/etc/group by running the following command:
     _________________________________________________________________

inserted in the script. I could have programmed a "cp" but that's simpler.
     _________________________________________________________________

Copying old NSS library files

   If your normal Linux system runs Glibc-2.0, you need to copy the NSS
   library files to the LFS partition. Certain statically linked programs
   still depend on the NSS library, especially programs that need to
   lookup usernames, userid's and groupid's. You can check which C
   library version your normal Linux system uses by simply executing the
   library, like this:

   /lib/libc.so.6

   The first line will give you the release version. Following lines
   contain interesting information. If you have Glibc-2.0.x installed on
   your starting distribution, copy the NSS library files by running:

   cp -av /lib/libnss* $LFS/lib
     _________________________________________________________________

Added a conditional code for this.
However, because Gerard told me there was a risk of running /lib/libc.so.6
directly, i leave the "safe" glibc detection code as is.
     _________________________________________________________________

Mounting $LFS/proc file system

chown root.root $LFS/proc &&
mount proc $LFS/proc -t proc
     _________________________________________________________________

This is inserted inside the script make_chown.sh now.
     _________________________________________________________________

Chapter 6. Installing basic system software
     _________________________________________________________________

Introduction

<snip>

   Now would be a good time to take a look at the optimization hint at
   [395]http://hints.linuxfromscratch.org/hints/optimization.txt if you
   plan on using compiler optimization for the packages installed in the
   following chapter. Compiler optimization can make a program run
   faster, but may also cause some compilation problems. If you run into
   problems after having used optimization, always try it without
   optimizing to see if the problem persists.
     _________________________________________________________________

These "optimisations" are not taken into account (yet).
     _________________________________________________________________

About debugging symbols

   To remove debugging symbols from a binary (must be an a.out or ELF
   binary) run strip --strip-debug filename. Wildcards can be used to
   strip debugging symbols from multiple files (use something like strip
   --strip-debug $LFS/usr/bin/*). Most people will probably never use a
   debugger on software, so by removing those symbols a lot of disk space
   can be regained.

   For your convenience, chapter 9 includes one simple command to strip
   all debugging symbols from all programs and libraries on your system.
     _________________________________________________________________

strip will be run later.
     _________________________________________________________________

Creating $LFS/root/.bash_profile
     _________________________________________________________________

integrated in the script.
     _________________________________________________________________

Entering the chroot'ed environment

cd $LFS &&
chroot $LFS /usr/bin/env -i HOME=/root \
   TERM=$TERM /bin/bash --login
     _________________________________________________________________

Now it's done in a new script. After running cp_chroot.sh,
which copies the base and the source packages to root_chroot,
enter_chroot.sh enters in the chrooted environment and runs a central
script (under_chroot.sh) in this environment. Why something so
complex ? Because the build of the GLIBC was really difficult
and the usualy approach of a single script makes everything fail.
maybe the inclusion of yglfs_functions.sh defines things it shouldn't ?
But now it works. bear with it.
     _________________________________________________________________

   Now that we are inside a chroot'ed environment, we can continue to
   install all the basic system software. You have to make sure all the
   following commands in this and following chapters are run from within
   the chroot'ed environment. If you ever leave this environment for any
   reason (when rebooting for example) please remember to mount $LFS/proc
   again and re-enter chroot before continuing with the book.
     _________________________________________________________________

if you rerun enter_chroot.sh, it will care for this.
     _________________________________________________________________

Changing ownership of the LFS partition

cd / &&
chown 0.0 . proc &&
chown -R 0.0 bin boot dev etc home lib mnt opt root sbin tmp usr var
     _________________________________________________________________

done.
     _________________________________________________________________

   Depending on the filesystem you created on the LFS partition, you may
   have a /lost+found directory. If so, run:

   chown 0.0 lost+found
     _________________________________________________________________

not done. It should be done when the new partition is created.
     _________________________________________________________________

Creating the /etc/mtab symlink

   The next thing to do is to create a symlink pointing from /etc/mtab to
   /proc/mounts. This is done using the following command:

   ln -s /proc/mounts /etc/mtab
     _________________________________________________________________

conditionally coded.
     _________________________________________________________________

Installing Glibc-2.2.5
     _________________________________________________________________

If you think (like me) that compiling the kernel is difficult,
you have probably not tried compiling glibc. I almost gave up
on this part, but hacked my way through it anyway. It works
but lost the advantages of LFS and YGLFS : filenames are almost
hardcoded and if a new version appears, you'll have to patch
the script.
     _________________________________________________________________

   Before starting to install glibc, you must cd into the glibc-2.2.5
   directory and unpack glibc-linuxthreads inside the glibc-2.2.5
   directory, not in /usr/src as you normally would do.
     _________________________________________________________________

argh, this makes the script more complex.
Because compiling glibc is so tedious, it is in a specific file
and the commands have been more or less hardcoded.
     _________________________________________________________________

   exec /bin/bash:This command will start a new bash shell which will
   replace the current shell. This is done to get rid of the "I have no
   name!" message in the command prompt, which was caused by bash's
   inability to resolve a userid to a username (which in turn was caused
   by the missing Glibc installation).
     _________________________________________________________________

Note : this is unnecessary for a script.
     _________________________________________________________________

Creating devices (Makedev-1.4)

   Note: the MAKEDEV-1.4.bz2 file you have unpacked is not an archive, so
   it won't create a directory for you to cd into.
     _________________________________________________________________

it's hardcoded in chroot_cmds.sh for convenience.
     _________________________________________________________________

   Now, depending on whether you are going to use devpts or not, you can
   run one of two commands:

   If you do not intend to use devpts, run:

   ./MAKEDEV -v generic

   If you do intend to use devpts, then run:

   ./MAKEDEV -v generic-nopty

   Note that if you aren't sure, it's best to use the ./MAKEDEV -v
   generic command as this will ensure you have the devices you need. If
   you are sure you are going to use devpts however, the other command
   makes sure that you don't create a set of devices which you don't
   require.
     _________________________________________________________________

the default behaviour is used.
     _________________________________________________________________

Installing Man-pages-1.48
     _________________________________________________________________

now the only command is "make install", but the LFS v3.2 used another
script. this corrected.
     _________________________________________________________________

Installing Findutils-4.1

   Before Findutils is installed the findutils patch file has to be
   unpacked.
     _________________________________________________________________

FHS compliance notes

   By default, the location of the updatedb database is in /usr/var. If
   you would rather be FHS compliant, you may wish to use another
   location. The following commands use the database file
   /var/lib/misc/locatedb which is FHS compliant.
     _________________________________________________________________

I use the provided command file which doesn't care about FHS.
Nothing to remark.
     _________________________________________________________________

Installing Gawk-3.1.0

   Warning: do NOT run make uninstall on this package if you apply the
   sed fix to change the libexec directory definition. The uninstall rule
   in the Makefile file runs a command like rm -rf <libexecdir>/* Since
   we change the libexec directory to /usr/bin it'll run rm -rf
   /usr/bin/*
     _________________________________________________________________

since the build is automated, the result directory (containing the
whole chrooted system) can be simply erased, though you'll spend
another 20 minutes to recompile the previous stuffs, and more if
you didn't backup the root_base directory.
Compiles smoothly, otherwise.
     _________________________________________________________________

Installing Ncurses-5.2
     _________________________________________________________________

nothing to say.
     _________________________________________________________________

Installing Vim-6.1

   If you don't like vim to be installed as an editor on the LFS system,
   you may want to download an alternative and install an editor you
   prefer. There are a few hints how to install different editors
   available at [397]http://hints.linuxfromscratch.org/hints/. The hints
   which are currently available are for Emacs, Joe and nano.
     _________________________________________________________________

nano is also provided and it compiles fine.
However i had problems with detecting the version of vim, vim-6.0
is provided but the command file must be updated if another version
of the source is used.
     _________________________________________________________________

   Install Vim by running the following commands:

./configure --prefix=/usr &&
make CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\" &&
make install &&
cd /usr/bin &&
ln -sf vim vi
     _________________________________________________________________

i had a problem, i have an older (6.0) version of vim, i had to hack it.
i also put the FHS stuff in comments.
     _________________________________________________________________

At this point, i install nano-1.0.8. It is installed under /usr/bin
but i then move it to /bin/ (naughty hack again). The use-mouse and
no-wrap-around options are set with a wrapper : the executable file
is moved to /bin/nano.renamed so the script can be called nano.
     _________________________________________________________________

Installing GCC-2.95.3

   This package is known to behave badly when you have changed its
   default optimization flags (including the -march and -mcpu options).
   GCC is best left alone, so we recommend you unsetting CFLAGS, CXXFLAGS
   and other such variables/settings that would change the default
   optimization that it comes with.
     _________________________________________________________________

This is usually not set at all, unless you modify /root/.profile.
     _________________________________________________________________

patch -Np1 -i ../gcc-2.95.3-2.patch &&
mkdir ../gcc-build &&
cd ../gcc-build &&
../gcc-2.95.3/configure --prefix=/usr --enable-shared \
   --enable-languages=c,c++ --enable-threads=posix &&
make bootstrap &&
make install &&
cd /lib &&
ln -sf ../usr/bin/cpp &&
cd /usr/lib &&
ln -sf ../bin/cpp &&
cd /usr/bin &&
ln -sf gcc cc &&
rmdir /usr/*-gnu/include &&
rmdir /usr/*-gnu
     _________________________________________________________________

The command script is updated.
     _________________________________________________________________

Installing Bison-1.35
     _________________________________________________________________

   Some programs don't know about bison and try to find the yacc program
   (bison is a (better) alternative for yacc). So to please those few
   programs out there we'll create a yacc script that calls bison and
   have it emulate yacc's output file name conventions.

   Create a new file /usr/bin/yacc by running the following:

cat > /usr/bin/yacc << "EOF"
#!/bin/sh
# Begin /usr/bin/yacc

exec /usr/bin/bison -y "$@"

# End /usr/bin/yacc
EOF
chmod 755 /usr/bin/yacc
     _________________________________________________________________

added to the command script.
     _________________________________________________________________

Installing Less-374
     _________________________________________________________________

runs fine.
     _________________________________________________________________

Installing Groff-1.17.2

   Install Groff by running the following commands:

./configure --prefix=/usr &&
make &&
make install &&
cd /usr/bin &&
ln -s soelim zsoelim &&
ln -s eqn geqn &&
ln -s tbl gtbl
     _________________________________________________________________

updated the command with the links.
     _________________________________________________________________

Installing Man-1.5j
     _________________________________________________________________

little problem here : the "base name" "collides" with
man-pages-1.48.tar.bz2. The trick here is to change the base name
and create a symlink to the archive. the new base name is "man-progs".
under_chroot.sh is in charge of creating the symlink if it doesn't
exist.
     _________________________________________________________________

Installing Perl-5.6.1
     _________________________________________________________________

i had to comment out some (duplicated) parts of the commands file.
I also forgot the -d and -e options to Configure : the script seemed to
hang but in fact Configure was waiting for user input. heh.
     _________________________________________________________________

Installing M4-1.4
     _________________________________________________________________

nothing to add.
     _________________________________________________________________

Installing Texinfo-4.1
     _________________________________________________________________

The current CVS version is 4.2 and the command is 4.0 but there is
nothing to change.
     _________________________________________________________________

Installing Autoconf-2.53
Installing Automake-1.6
     _________________________________________________________________

no surprise.
     _________________________________________________________________

Installing Bash-2.05a
     _________________________________________________________________

The command file is modified :
 * bash is not executed at the end
 * the link is already tested by install_functions.sh
     _________________________________________________________________

Installing Flex-2.5.4a

   Some programs don't know about flex and try to find the lex program
   (flex is a (better) alternative for lex). So to please those few
   programs out there we'll create a lex script that calls flex and have
   it emulate lex.
     _________________________________________________________________

The lex wrapper is already included in the command flex-2.5.4a,
nothing to do.
     _________________________________________________________________

Installing File-3.37
     _________________________________________________________________

I had to update my files to 3.37 and it runs ok.
     _________________________________________________________________

Installing Libtool-1.4.2

   Install Libtool by running the following commands:

./configure --prefix=/usr &&
make &&
make install
     _________________________________________________________________

it looks easy.
     _________________________________________________________________

Installing Bin86-0.16.2

   This package is only needed if you decide to use Lilo on your LFS
   system. If you're going to use something else like Grub you won't need
   bin86. Check the documentation for your favorite boot loader to see if
   you need the bin86 package (usually only ld86 and/or as86 from this
   package are required).

   Keep in mind, though, that it's not just boot loaders that use the
   bin86 package. There is always the chance that some other package
   needs programs from this package, so keep that in mind if you decide
   to skip this.
     _________________________________________________________________

i'll install it anyway.
     _________________________________________________________________

   Install Bin86 by running the following commands:

make &&
make PREFIX=/usr install
     _________________________________________________________________

version 0.16.0 is present on my system but it's the same commands.
     _________________________________________________________________

Installing Binutils-2.12

mkdir ../binutils-build &&
cd ../binutils-build &&
../binutils-2.12/configure --prefix=/usr --enable-shared &&
make tooldir=/usr &&
make tooldir=/usr install &&
make tooldir=/usr install-info
     _________________________________________________________________

my binutils command version is 2.11.2, i have to update it.
     _________________________________________________________________

Installing Bzip2-1.0.2
     _________________________________________________________________

my commands are upgraded to 1.0.2.
however, i have to add a -f flag to rm because it hangs on
removing a file that doesn't exist.
     _________________________________________________________________

Installing Ed-0.2

   Ed isn't something you would personally use. It's installed here
   because it can be used by the patch program if you encounter an
   ed-based patch file. This happens rarely because diff-based patches
   are preferred these days.
     _________________________________________________________________

So i install it but it could be removed if a small install is needed.
     _________________________________________________________________

Installing Gettext-0.11.1
     _________________________________________________________________

command file version is 0.10.4 but the contents is identical.
     _________________________________________________________________

Installing Kbd-1.06

   patch -Np1 -i ../kbd-1.06-2.patch: This patch fixes two problems. The
   first one is the loadkeys -d behaviour which is broken in current kbd
   versions. It is necessary to fix this, because the boot scripts rely
   on a proper loadkeys -d. The second part of the patch changes a
   Makefile so some utilities (setlogcons, setvesablank and getunimap)
   that are not installed by default, are installed as well.
     _________________________________________________________________

The patch command was not performed in the previous commands. updated.
     _________________________________________________________________

Installing Diffutils-2.8
     _________________________________________________________________

current version is 2.8.1 and command file version is 2.7 but they are
all identical.
     _________________________________________________________________

Installing E2fsprogs-1.27
     _________________________________________________________________

current version is 1.27, command file updated.
     _________________________________________________________________

Installing Fileutils-4.1
     _________________________________________________________________

command file updated.
     _________________________________________________________________

Installing Grep-2.5

./configure --prefix=/usr --bindir=/bin &&
make &&
rm /bin/egrep /bin/fgrep &&
make install
     _________________________________________________________________

it works fine, but let's add a -f to rm, just in case.
     _________________________________________________________________

Installing Gzip-1.2.4a
     _________________________________________________________________

curiously, i find a patch file but it is not used, even on the CVS
version of the BOOK. I also added a -f to rm (same reason as above).
     _________________________________________________________________

Installing Lilo-22.2
     _________________________________________________________________

renamed the command from 22.1 to 22.2 (same contents)
     _________________________________________________________________

Installing Make-3.79.1
     _________________________________________________________________

updated the script with the chmod/chgrp stuff.
     _________________________________________________________________

Installing Modutils-2.4.15
     _________________________________________________________________

renamed the script 2.4.12 to 2.4.15
     _________________________________________________________________

Installing Netkit-base-0.17
     _________________________________________________________________

no modification necessary. However it must be customised one day.
     _________________________________________________________________

Installing Patch-2.5.4
     _________________________________________________________________

CPPFLAG stuff in the command file : updated
     _________________________________________________________________

Installing Procinfo-18
     _________________________________________________________________

ok.
     _________________________________________________________________

Installing Procps-2.0.7
     _________________________________________________________________

ok
     _________________________________________________________________

Installing Psmisc-20.2
     _________________________________________________________________

source and command version are 20.1, but the command is the same.
     _________________________________________________________________

   psmisc installs the /usr/share/man/man1/pidof.1 man page, but psmisc's
   pidof program isn't installed by default. Generally that isn't a
   problem because we install the sysvinit package later on which
   provides us with a better pidof program.

   It's up to you now to decide if you are going to use the sysvinit
   package which provides a pidof program, or not. If you are going to,
   you should remove psmisc's pidof man page by running:

   rm /usr/share/man/man1/pidof.1

   If you're not going to use sysvinit, you should complete this
   package's installation by creating the /bin/pidof symlink by running:

cd /bin
ln -s killall pidof
     _________________________________________________________________

I think i'll use SysVInit but only execute the command file
(no rm or ln either).
     _________________________________________________________________

Installing Reiserfsprogs-3.x.1b

   Reiserfsprogs only needs to be installed if you intend on using the
   reiserfs filesystem.
     _________________________________________________________________

It's not used at all. Source and command files are not present
at this time in the YGLFS distro.
     _________________________________________________________________

Installing Sed-3.02
     _________________________________________________________________

it works.
     _________________________________________________________________

Installing Sh-utils-2.0

FHS compliance notes

   There is a command installed in this package which is named test. It
   is often used in shell scripts to evaluate conditions, but is more
   often encountered in the form of [ condition ]. These brackets are
   built into the bash interpreter, but the FHS dictates that there
   should be a [ binary. We create that in this way, while still in the
   /bin directory:

cd /bin &&
ln -sf test [
     _________________________________________________________________

ok it is put in the command file. However i see a patch file but
it's not used in the commands :-/
     _________________________________________________________________

Installing Net-tools-1.60

   If you want to accept all the default answers, you can run these
   commands instead:

yes "" | make &&
make update

   If you don't know what to answer to all the questions asked during the
   make phase, then just accept the defaults, which will be just in fine
   in the majority of the cases. What you are asked here are a bunch of
   questions relating to the kind of network protocols that you have
   enabled in your kernel.

   The default answers will enable the tools from this package to work
   with the most common protocols such as TCP, PPP and a bunch of others.
   You still need to actually enable these protocols in the kernel. What
   you do here is merely telling the programs to be able to use those
   protocols but it's up to the kernel to make it available to the
   system.
     _________________________________________________________________

the "yes" form is used in the commands.
     _________________________________________________________________

Installing Shadow-4.0.3

   Before you install this package, you may want to have a look at the
   [401]http://hints.linuxfromscratch.org/hints/shadowpasswd_plus.txt lfs
   hint. It discusses how you can make your system more secure regarding
   passwords and how to get the most out of this Shadow package.
     _________________________________________________________________

the command file is updated, with a -f option to rm.
     _________________________________________________________________

Installing Sysklogd-1.4.1
     _________________________________________________________________

ok
     _________________________________________________________________

Installing Sysvinit-2.84

   When run levels are changed (for example when going to shutdown the
   system) the init program is going to send the TERM and KILL signals to
   all the processes that init started. But init prints a message to the
   screen saying "sending all processes the TERM signal" and the same for
   the KILL signal. This implies that init sends this signal to all the
   currently running processes, which isn't the case. To avoid this
   confusion, you change the init.c file so that the sentence reads
   "sending all processes started by init the TERM signal" by running the
   following commands. If you don't want to change it, skip it.

cp src/init.c src/init.c.backup &&
sed 's/\(.*\)\(Sending processes\)\(.*\)/\1\2 started by init\3/' \
   src/init.c.backup > src/init.c
     _________________________________________________________________

The command is not exactly this one, but is updated anyway and added
a trailing && after sed.
     _________________________________________________________________

Installing Tar-1.13

   Apply the patch by running the following command:

   patch -Np1 -i ../tar-1.13.patch
     _________________________________________________________________

the trailing && is missing.
     _________________________________________________________________

Installing Textutils-2.0
     _________________________________________________________________

ok
     _________________________________________________________________

Installing Util-linux-2.11o

   The FHS recommends that we use /var/lib/hwclock as the location of the
   adjtime file, instead of the usual /etc. To make hwclock, which is
   part of the util-linux package, FHS-compliant, run the following.
     _________________________________________________________________

FHS compliant command version is upgraded to 2.11o
     _________________________________________________________________

Installing LFS-Bootscripts-1.9

   We will be using SysV style init scripts. We have chosen this style
   because it is widely used and we feel comfortable with it. If you want
   to try something else, someone has written an LFS-Hint on BSD style
   init scripts at http://hints.linuxfromscratch.org/hints/bsd-init.txt.

   If you decide to use BSD style, or some other style scripts, you can
   skip chapter 7 when you arive at it and move on to chapter 8.
     _________________________________________________________________

I decide to use BSDinit but keep the SysVinit files around, just in
case. BSD looks much simpler (hence faster) and easy to manage but SysV
contains a lot of useful functions that could be copied/pasted in the
BSD scripts.

BSDinit-fr is used instead of LFS-Bootscripts.
     _________________________________________________________________

Removing old NSS library files

   rm /lib/libnss*.so.1 /lib/libnss*2.0*
     _________________________________________________________________

it's not done in the script.
     _________________________________________________________________

Configuring essential software
     _________________________________________________________________

Configuring Vim

   By default Vim runs in vi compatible mode. Some people might like
   this, but we have a high preference to run vim in vim mode (else we
   wouldn't have included Vim in this book but the original Vi). Create
   the /root/.vimrc by running the following:
     _________________________________________________________________

the .vimrc is then moved to /etc and a link is created from /root.
     _________________________________________________________________

Configuring Glibc

   The tzselect script has to be run and the questions regarding your
   timezone have to be answered. When you're done, the script will give
   the location of the needed timezone file.
     _________________________________________________________________

the script is saved under configure-glibc-fr because the time zone is
set to Europe/Paris.
     _________________________________________________________________

Configuring Dynamic Loader
Configuring Sysklogd
     _________________________________________________________________

nothing to remark, except that these scripts are not very verbose...
     _________________________________________________________________

Configuring Shadow Password Suite

   To enable shadow'ed passwords, run the following command:

   /usr/sbin/pwconv
     _________________________________________________________________

This must be done by the user. Shadow is present and compiled but
not extensively used.
     _________________________________________________________________

Configuring Sysvinit
     _________________________________________________________________

/etc/inittab is created by the BSDinit script.
     _________________________________________________________________

Configuring your keyboard

   Nothing is more annoying than using Linux with a wrong keymap loaded
   for your keyboard. If you have a default US keyboard, you can skip
   this section. The US keymap file is the default if you don't change
   it.
     _________________________________________________________________

That's the point : i use a french locale :-)
     _________________________________________________________________

   To set the default keymap file, create the
   /usr/share/kbd/keymaps/defkeymap.map.gz symlink by running the
   following commands:

cd /usr/share/kbd/keymaps &&
ln -s <path/to/keymap> defkeymap.map.gz

   Replace <path/to/keymap> with the your keyboard's map file. For
   example, if you have a Dutch keyboard, you would run:

   ln -s i386/qwerty/nl.map.gz defkeymap.map.gz
     _________________________________________________________________

This time, i have simply copied /etc/defkeymap.map from my existing
linux box to the chapter 6 's command directory. So i'm sure i'm not
confused :-) I also rename the keymap directory to keep loadkey from
searching there.
     _________________________________________________________________

Creating the /var/run/utmp, /var/log/wtmp and /var/log/btmp files
     _________________________________________________________________

ok.
     _________________________________________________________________

Creating root password

   Choose a password for user root and create it by running the following
   command:

   passwd root
     _________________________________________________________________

errr, i simply rewrite the /etc/passwd and leave it blank.
It must be modified later by the user. I also added a shutdown login.

YEAH !!! it's the end of chapt. 6 !!!

     _________________________________________________________________

Chapter 7. Setting up system boot scripts
     _________________________________________________________________

Introduction

   This chapter will setup the bootscripts that you installed in chapter
   6. Most of these scripts will work without needing to modify them, but
   a few do require additional configuration files setup as they deal
   with hardware dependant information.
     _________________________________________________________________

BSDinit is used but needs some customisation.
     _________________________________________________________________

Configuring the sysklogd script

   The sysklogd script invokes the syslogd program with the -m 0 option.
   This option turns off the periodic timestamp mark that syslogd writes
   to the log files every 20 minutes by default. If you want to turn on
   this periodic timestamp mark, edit the sysklogd script and make the
   changes accordingly. See man syslogd for more information.
     _________________________________________________________________

bsdinit-fr is modified to take that into account.

Note that this is the reason why most files in /etc/sysconfig
or /etc/rc.d/init.d are not relevant.

Note also that the network is not configured yet. The remaining text
is left here just in case.
     _________________________________________________________________

Creating the /etc/hosts file

   If a network card is to be configured, you have to decide on the
   IP-address, FQDN and possible aliases for use in the /etc/hosts file.
   The syntax is:

   <IP address> myhost.mydomain.org aliases

   You should made sure that the IP-address is in the private network
   IP-address range. Valid ranges are:

        Class Networks
        A     10.0.0.0
        B     172.16.0.0 through 172.31.0.0
        C     192.168.0.0 through 192.168.255.0

   A valid IP address could be 192.168.1.1. A valid FQDN for this IP
   could be www.linuxfromscratch.org

   If you aren't going to use a network card, you still need to come up
   with a FQDN. This is necessary for certain programs to operate
   correctly.

   If a network card is not going to be configured, create the /etc/hosts
   file by running:

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (no network card version)

127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost

# End /etc/hosts (no network card version)
EOF

   If a network card is to be configured, create the /etc/hosts file by
   running:

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)

127.0.0.1 localhost.localdomain localhost
192.168.1.1 www.mydomain.org <value of HOSTNAME>

# End /etc/hosts (network card version)
EOF

   Of course, the 192.168.1.1 and www.mydomain.org have to be changed to
   your liking (or requirements if assigned an IP-address by a
   network/system administrator and this machine is planned to be
   connected to an existing network).
     _________________________________________________________________

Configuring default gateway

   If you're on a network you may need to setup the default gateway for
   this machine. This is done by adding the proper values to the
   /etc/sysconfig/network file by running the following:

cat >> /etc/sysconfig/network << "EOF"
GATEWAY=192.168.1.2
GATEWAY_IF=eth0
EOF

   The values for GATEWAY and GATEWAY_IF need to be changed to match your
   network setup. GATEWAY contains the IP address of the default gateway,
   and GATEWAY_IF contains the network interface through which the
   default gateway can be reached.
     _________________________________________________________________

Creating network interface configuration files

   Which interfaces are brought up and down by the network script depends
   on the files in the /etc/sysconfig/network-devices directory. This
   directory should contain files in the form of ifconfig.xyz, where xyz
   is a network interface name (such as eth0 or eth0:1)

   If you decide to rename or move this /etc/sysconfig/network-devices
   directory, make sure you update the /etc/sysconfig/rc file as well and
   update the network_devices by providing it with the new path.

   Now, new files are created in that directory containing the following.
   The following command creates a sample ifconfig.eth0 file:

cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"
ONBOOT=yes
IP=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
EOF

   Of course, the values of those variables have to be changed in every
   file to match the proper setup. If the ONBOOT variable is set to yes,
   the network script will bring it up during boot up of the system. If
   set to anything else but yes it will be ignored by the network script
   and thus not brought up.
     _________________________________________________________________

Chapter 8. Making the LFS system bootable

   This chapter will make LFS bootable. This chapter deals with creating
   a new fstab file, building a new kernel for the new LFS system and
   adding the proper entries to LILO so that the LFS system can be
   selected for booting at the LILO: prompt.
     _________________________________________________________________

This part is highly target-specific : the user must be able to configure
whatever it is possible to do. The scripts will prepare the files but they
must be modified before the user reboots the computer.
     _________________________________________________________________

Creating the /etc/fstab file
     _________________________________________________________________

custom tables are needed.
I also remark that USB entries in /dev are not done.
     _________________________________________________________________

Installing linux-2.4.18

   Something you could do, is take the .config file from your host
   distribution's kernel source tree and copy it to $LFS/usr/src/linux.
   This way you don't have to configure the entire kernel from scratch
   and can use your current values. If you choose to do this, first run
   the make mrproper command below, then copy the .config file over, then
   run make menuconfig followed by the rest of the commands (make
   oldconfig may be better in some situations. See the README file for
   more details when to use make oldconfig).

   The following commands are run to build the kernel:

cd /usr/src/linux &&
make mrproper &&
make menuconfig &&
make dep &&
make bzImage &&
make modules &&
make modules_install &&
cp arch/i386/boot/bzImage /boot/lfskernel &&
cp System.map /boot

   Note: the arch/i386/boot/bzImage path may vary on different platforms.
     _________________________________________________________________

Making the LFS system bootable

   In order to be able to boot the LFS system, we need to update our
   bootloader. We're assuming that your host system is using Lilo (since
   that's the most commonly used boot loader at the moment).

   We will not be running the lilo program inside chroot. Running lilo
   inside chroot can have fatal side-effects which render your MBR
   useless and you'd need a boot disk to be able to start any Linux
   system (either the host system or the LFS system).

   First we'll exit chroot and copy the lfskernel file to the host
   system:

logout
cp $LFS/boot/lfskernel /boot

   The next step is adding an entry to /etc/lilo.conf so that we can
   choose LFS when booting the computer:

cat >> /etc/lilo.conf << "EOF"
image=/boot/lfskernel
        label=lfs
        root=<partition>
        read-only
EOF

   <partition> must be replaced with the LFS partition's designation.

   Also note that if you are using reiserfs for your root partition, the
   line read-only should be changed to read-write.

   Now, update the boot loader by running:

   /sbin/lilo -v

   The last step is synchronizing the host system's lilo configuration
   files with the LFS system's:

cp /etc/lilo.conf $LFS/etc &&
cp $(grep "image.*=" /etc/lilo.conf | cut -f 2 -d "=") $LFS/boot
     _________________________________________________________________

Chapter 9. The End
     _________________________________________________________________

The End

   Well done! You have finished installing your LFS system. It may have
   been a long process but it was well worth it. We wish you a lot of fun
   with your new shiny custom built Linux system.

   Now would be a good time to strip all debug symbols from the binaries
   on your LFS system. If you are not a programmer and don't plan on
   debugging your software, then you will be happy to know that you can
   reclaim a few tens of megs by removing debug symbols. This process
   causes no inconvenience other than not being able to debug the
   software fully anymore, which is not an issue if you don't know how to
   debug.

   Disclaimer: 98% of the people who use the command mentioned below
   don't experience any problems. But do make a backup of your LFS system
   before you run this command. There's a slight chance it may backfire
   on you and render your system unusable (mostly by destroying your
   kernel modules and dynamic & shared libraries). This is more often
   caused by typo's than by a problem with the command used.

   Having said that, the --strip-debug option we use to strip is quite
   harmless under normal circumstances. It doesn't strip anything vital
   from the files. It also is quite safe to use --strip-all on regular
   programs (don't use that on libraries - they will be destroyed) but
   it's not as safe and the space you gain is not all that much. But if
   you're tight on disk space every little bit helps, so decide yourself.
   Please refer to the strip man page for other strip options you can
   use. The general idea is to not run strip on libraries (other than
   --strip-debug) just to be on the safe side.

find $LFS/{,usr/,usr/local/}{bin,sbin,lib} -type f \
   -exec /usr/bin/strip --strip-debug '{}' ';'

   It may be a good idea to create the $LFS/etc/lfs-3.3 file. By having
   this file it is very easy for you (and for us if you are going to ask
   for help with something at some point) to find out which LFS version
   you have installed on your system. This can just be a null-byte file
   by running:

   touch $LFS/etc/lfs-3.3
     _________________________________________________________________

Get Counted

   Want to be counted as an LFS user now that you have finished the book?
   Head over to [404]http://linuxfromscratch.org/cgi-bin/lfscounter.cgi
   and register as an LFS user by entering your name and the first LFS
   version you have used.

   Let's reboot into LFS now...
     _________________________________________________________________

Rebooting the system

   Now that all software has been installed, bootscripts have been
   created, it's time to reboot the computer. Before we reboot let's
   unmount $LFS/proc and the LFS partition itself by running:

umount $LFS/proc &&
umount $LFS

   And you can reboot your system by running something like:

   /sbin/shutdown -r now

   At the LILO: prompt make sure that you tell it to boot lfs and not the
   default entry which will boot your host system again.

   After you have rebooted, your LFS system is ready for use and you can
   start adding your own software.

   One final thing you may want to do is run lilo, now that you are
   booted into LFS. This way you will put the LFS version of LILO in the
   MBR rather than the one that's there right now from your host system.
   Depending on how old your host distribution is, the LFS version may
   have more advanced features you need/could use.

   Either way, run the following to make the lilo version installed on
   LFS active:

   /sbin/lilo

   Again, we thank you for using the LFS Book and hope you found this
   book useful and worth your time.
     _________________________________________________________________

No doubt :-) LFS is a great thing. I've burnt Red Hat, SuSE,
Debian and Mandrake which break easily alone anyway.
I'm currently writing this on a SuSE 7.2 that was really badly
"installed" by a so-called "friendly" hacker. X does not even work.
So i do this with half a dozen VTs in raw text mode and it works.

