当前位置:Linux教程 - 其他服务 - 其他服务 - Linux From Scratch安装学习笔记

其他服务 - Linux From Scratch安装学习笔记

Linux From Scratch安装学习笔记
2004-04-23 15:18 pm
来自:Linux文档
现载:Www.8s8s.coM
地址:无名

LFS -- Linux from Scratch,就是一种从网上直接下载源码,从头编译LINUX的安装方式。它不是发行版,只是一个菜谱,告诉你到哪里去买菜(下载源码),怎么把这些生东西( raw code) 作成符合自己口味的菜肴---个性化的linux,不单单是个性的桌面。

优点:了解Linux工作方式;自定义你的系统;建立袖珍型Linux;安全性

我的LFS计划:
本来计划先通过VMWare在虚拟机中做一下试验,结果编译时间太长了,未果。
所以不太甘心,晚上卸载掉Fedura Core 1,重新安装了一个只带GCC等编译必须软件的最小化Fedura系统,
大概才1G多,腾出来空间划分出一个2G的留给LFS。

机器环境介绍:
Athlon XP 1700+ OC 2000+
512MB PC133内存
80GB ATA100 IDE硬盘
已安装系统: Windows XP, Fedura Core 1
Linux myhost 2.4.22-1.2115.nptl #1 Wed Oct 29 15:31:21 EST 2003 i686 athlon i386 GNU/Linux


关于$LFS: 设定LFS分区路径,使用
export LFS=/mnt/lfs
加载。使用范例:
./configure --prefix=$LFS/tools

关于SBUs: Static Binutils Unittime, 静态 Binutils 单位时间
Binutils是LFS中第一个需要编译的软件包,以它编译的时间作为基准单位,可以估算出其它软件包的编译时间



Chapter 3. 准备新分区

3.1 创建一个新分区:(LFS主分区2G + swap分区)
fdisk /dev/hda
n - 增加分区 t - 更改分区类型 p - 显示分区表 w - 写入磁盘


3.2 在新分区上创建文件系统:(ext2)
mke2fs /dev/hda4
[[email protected] root]# mke2fs /dev/hda4
mke2fs 1.34 (25-Jul-2003)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
251392 inodes, 502031 blocks
25101 blocks (5.00%) reserved for the super user
First data block=0
16 block groups
32768 blocks per group, 32768 fragments per group
15712 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

建立swap分区(由于我的内存比较大 所以没建立swap分区):
mkswap /dev/hda8

附:当前/dev/hda分区情况
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 637 5116671 7 HPFS/NTFS
/dev/hda2 1160 9729 68838525 f Win95 Ext'd (LBA)
/dev/hda3 638 828 1534207+ 83 Linux
/dev/hda4 829 1078 2008125 83 Linux
/dev/hda5 1160 1912 6048441 b Win95 FAT32
/dev/hda6 2015 4564 20482843+ 7 HPFS/NTFS
/dev/hda7 4565 9729 41487831 7 HPFS/NTFS

3.3 加载新的分区
[[email protected] root]# export LFS=/mnt/lfs
[[email protected] root]# mkdir -p $LFS
[[email protected] root]# mount /dev/hda4 $LFS

mkdir -p, --parents: no error if existing, make parent directories as needed

建立sources目录
[[email protected] root]# mkdir $LFS/sources
[[email protected] root]# chmod a+wt $LFS/sources

t: sticky

STICKY DIRECTORIES
When the sticky bit is set on a directory, files in that directory may
be unlinked or renamed only by root or their owner. Without the sticky
bit, anyone able to write to the directory can delete or rename files.
The sticky bit is commonly found on directories, such as /tmp, that are
world-writable.

#---- install script begin ----------------------------------------------------
export LFS=/mnt/lfs
mkdir -p $LFS
mount /dev/hda4 $LFS
mkdir $LFS/sources
chmod a+wt $LFS/sources

#---- install script end ------------------------------------------------------


Chapter 4 安装材料: 包和补丁

4.1 所需软件包及补丁:

使用 Linux From Scratch 官方提供的 LFS 5.0:
http://packages.lfs-es.org/lfs-packages-5.0.tar

中国 linuxsir 镜像:
http://lfs.linuxsir.org/htdocs/files/lfs-packages-5.0.tar

内含软件清单如下:
autoconf-2.57.tar.bz2 inetutils-1.4.2.tar.bz2
automake-1.7.6.tar.bz2 kbd-1.08-more-programs.patch
bash-2.05b-2.patch kbd-1.08.tar.bz2
bash-2.05b.tar.bz2 less-381.tar.bz2
binutils-2.14.tar.bz2 lfs-bootscripts-1.12.tar.bz2
bison-1.875-attribute.patch lfs-utils-0.3.tar.bz2
bison-1.875.tar.bz2 libtool-1.5.tar.bz2
bzip2-1.0.2.tar.bz2 linux-2.4.22.tar.bz2
coreutils-5.0-hostname-2.patch m4-1.4.tar.bz2
coreutils-5.0.tar.bz2 make-3.80.tar.bz2
coreutils-5.0-uname.patch MAKEDEV-1.7.bz2
dejagnu-1.4.3.tar.bz2 man-1.5m2-80cols.patch
diffutils-2.8.1.tar.bz2 man-1.5m2-manpath.patch
e2fsprogs-1.34.tar.bz2 man-1.5m2-pager.patch
ed-0.2-mkstemp.patch man-1.5m2.tar.bz2
ed-0.2.tar.bz2 man-pages-1.60.tar.bz2
expect-5.39.0-spawn.patch modutils-2.4.25.tar.bz2
expect-5.39.0.tar.bz2 ncurses-5.3-etip-2.patch
file-4.04.tar.bz2 ncurses-5.3.tar.bz2
findutils-4.1.20.tar.bz2 ncurses-5.3-vsscanf.patch
flex-2.5.4a.tar.bz2 net-tools-1.60-miitool-gcc33-1.patch
gawk-3.1.3-libexecdir.patch net-tools-1.60.tar.bz2
gawk-3.1.3.tar.bz2 patch-2.5.4.tar.bz2
gcc-2.95.3-2.patch perl-5.8.0-libc-3.patch
gcc-2.95.3-no-fixinc.patch perl-5.8.0.tar.bz2
gcc-2.95.3-returntype-fix.patch procinfo-18.tar.bz2
gcc-2.95.3.tar.bz2 procps-3.1.11-locale-fix.patch
gcc-3.3.1-no_fixincludes-2.patch procps-3.1.11.tar.bz2
gcc-3.3.1-specs-2.patch psmisc-21.3.tar.bz2
gcc-3.3.1-suppress-libiberty.patch sed-4.0.7.tar.bz2
gcc-core-3.3.1.tar.bz2 shadow-4.0.3-newgrp-fix.patch
gcc-g++-3.3.1.tar.bz2 shadow-4.0.3.tar.bz2
gcc-testsuite-3.3.1.tar.bz2 sysklogd-1.4.1.tar.bz2
gettext-0.12.1.tar.bz2 sysvinit-2.85.tar.bz2
glibc-2.3.2-sscanf-1.patch tar-1.13.25.tar.bz2
glibc-2.3.2.tar.bz2 tcl8.4.4-src.tar.bz2
glibc-linuxthreads-2.3.2.tar.bz2 texinfo-4.6.tar.bz2
grep-2.5.1.tar.bz2 util-linux-2.12.tar.bz2
groff-1.19.tar.bz2 vim-6.2.tar.bz2
grub-0.93-gcc33-1.patch zlib-1.1.4.tar.bz2
grub-0.93.tar.bz2 zlib-1.1.4-vsnprintf.patch
gzip-1.3.5.tar.bz2


Chapter 5 创建临时系统

5.1 工具链技术说明

Chapter 5 的目的是提供一个健全的(sane)临时环境,使我们可以通过 chroot 进入,借助它我们可以在 Chapter 6 建立一个干净无误的 LFS 系统。因此我们要尽可能的从主系统分离,建立一个自给自足(self-contained and self-hosted)的工具链(toolchain)。此临时系统安装在 $LFS/tools 下。

关键技术要点:

1. 类似于交叉编译(cross compiling)的原理,把工具装载同一前缀下协同工作,从而发挥一些GNU的“魔力”。
2. 小心处理标准连接库的搜索路径,以保证程序只连接到我们选择的库上。
3. 小心处理GCC的specs文件,来告诉编译器选用正确的动态连接器。

工作平台(work platform / target triplet): i686-pc-linux-gnu

确定方法: 解开 binutils 源码,运行 ./config.guess 并观察结果

动态连接器(动态加载器): /lib/ld-linux.so.2

确定方法: 用下面的命令来检查主系统中的任何一个二进制程序:'readelf -l <name of binary> | grep interpreter'并观察结果
[[email protected] root]# readelf -l /bin/dmesg | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.2]


5.2 创建$LFS/tools目录,并创建符号连接/tools

[[email protected] root]# mkdir $LFS/tools
[[email protected] root]# ln -s $LFS/tools /

5.3 增加lfs用户

[[email protected] /]# useradd -s /bin/bash -m lfs
[[email protected] /]# passwd lfs
[[email protected] /]# chown lfs $LFS/tools
[[email protected] /]# chown lfs $LFS/sources
[[email protected] /]# su - lfs
[[email protected] lfs]$

"-" 让 su 命令启动一个新的,干净的shell

5.4 环境设置

[[email protected] lfs]$ cat >~/.bash_profile << "EOF"
> set +h
> umask 022
> LFS=/mnt/lfs
> LC_ALL=POSIX
> PATH=/tools/bin:$PATH
> export LFS LC_ALL PATH
> unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
> EOF
[[email protected] lfs]$ source ~/.bash_profile

说明:
set +h 关掉bash的 "hash"功能。关掉hash功能,那些交互的命令(make,patch, sed,cp 等等)将总是使用新的程序。
将用户文件创建掩码(umask)设为022。 rwx-r-x-r-x
LC_ALL 变量控制某些软件包的本地化,使它们输出的信息遵守指定国家的规范。设置成 "POSIX" (或"C",它们俩是相同的)我们保证在chroot环境中不会出现任何问题。
我们把 /tools/bin 附加到标准路径前面,是为了在安装过程中,总是能用到已经安装了的临时工具。
CC, CXX, CPP, LD_LIBRARY_PATH 和 LD_PRELOAD 环境变量都有可能破坏我们的工具链,因此这里取消它们的设置,以预防可能的问题。
source 命令读了刚才创建的设置文件。

#---- install script begin ----------------------------------------------------
mkdir $LFS/tools
ln -s $LFS/tools /
useradd -s /bin/bash -m lfs
passwd lfs
chown lfs $LFS/tools
chown lfs $LFS/sources
su - lfs

cat > ~/.bash_profile << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:$PATH
export LFS LC_ALL PATH
unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
EOF

source ~/.bash_profile

#---- install script end ------------------------------------------------------

5.5 安装 Binutils-2.14 第一遍

预计所需编译时间: 1.0SBU
预计所需硬盘空间: 194MB

Binutils 是一组开发工具,包括连接器、汇编器和其它用于生成目标文件和档案的工具。
安装下列程序: addr2line, ar, as, c++filt, gprof, ld, nm, objcopy, objdump, ranlib, readelf, size, strings, strip
安装下列库文件: libiberty.a, libbfd.[a, so], libopcodes.[a, so]

测算时间方法:
time { command seq1 && command seq2 && ... && command seqn; }
注意: 在{后面有一个空格, 在最后一条命令序列后面有一个分号,然后和后面的}只见至少要有一个空格

[[email protected] tools]$ cp $LFS/sources/binutils-2.14.tar.bz2 /tools/
[[email protected] tools]$ bunzip2 binutils-2.14.tar.bz2
[[email protected] tools]$ tar xvf binutils-2.14.tar
[[email protected] tools]$ rm binutils-2.14.tar
[[email protected] tools]$ cd binutils-2.14
[[email protected] binutils-2.14]$ mkdir ../binutils-build
[[email protected] binutils-2.14]$ cd ../binutils-build
[[email protected] binutils-build]$ ../binutils-2.14/configure
> --prefix=/tools --disable-nls
[[email protected] binutils-build]$ make configure-host
[[email protected] binutils-build]$ make LDFLAGS="-all-static"

make configure-host: 强制所有的子目录都进行配置,无此参数,静态连接就会失败
make LDFLAGS="-all-static": 通过libtool将参数传递给连接器,使 Binutils 软件包中所有程序都静态连接

[[email protected] binutils-build]$ make install
[[email protected] binutils-build]$ make -C ld clean
[[email protected] binutils-build]$ make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib

为后面的"锁定"glibc准备连接器脚本:
make -C ld clean: 删除所有编译生成文件,但保留子目录ld
make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib: 重新编译ld子目录中的所有文件

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/binutils-2.14.tar.bz2 /tools/
bunzip2 binutils-2.14.tar.bz2
tar xvf binutils-2.14.tar
rm binutils-2.14.tar
cd binutils-2.14
mkdir ../binutils-build
cd ../binutils-build
time { ../binutils-2.14/configure
--prefix=/tools --disable-nls &&
make configure-host &&
make LDFLAGS="-all-static" &&
make install &&

make -C ld clean &&
make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib;
}

#---- install script end ------------------------------------------------------

real 2m54.436s
user 2m22.380s
sys 0m22.020s


5.6 安装 GCC-3.3.1 第一遍

预计所需编译时间: 4.4SBU
预计所需硬盘空间: 300MB

GCC软件包包含GNU C/C++编译器
安装下列程序: c++, cc(link to gcc), cc1, cc1plus, collect2, cpp, g++, gcc, gccbug, gcov
安装下列库文件: libgcc.a, libgcc_eh.a, libgcc_s.so, libstdc++.[a,so] 和 libsupc++.a

[[email protected] tools]$ cp $LFS/sources/gcc-core-3.3.1.tar.bz2 /tools
[[email protected] tools]$ bunzip2 gcc-core-3.3.1.tar.bz2
[[email protected] tools]$ tar xvf gcc-core-3.3.1.tar
[[email protected] tools]$ rm gcc-core-3.3.1.tar
[[email protected] tools]$ cd gcc-3.3.1
[[email protected] gcc-3.3.1]$ mkdir ../gcc-build
[[email protected] gcc-3.3.1]$ cd ../gcc-build
[[email protected] gcc-build]$ ../gcc-3.3.1/configure --prefix=/tools
> --with-local-prefix=/tools
> --disable-nls --enable-shared
> --enable-languages=c

configure --enable-shared: 这个参数咋一看有点自相矛盾。但只有加上它,才能编译出 libgcc_s.so.1 和 libgcc_eh.a, Glibc(下一个软件包)的配置脚本只有在能找到 libgcc_eh.a 时才能确保产生正确的结果。请注意,gcc的可执行程序仍然会被静态连接,因为这是由后面 BOOT_LDFLAGS 中的 -static来控制的。

[[email protected] gcc-build]$ make BOOT_LDFLAGS="-static" bootstrap

make bootstrap: bootstrap目标不仅仅是编译 GCC,而是重复编译它几次。它用第一次编译生成的程序来第二次编译自己,然后又用第二次编译生成的程序来第三次编译自己,最后比较第二次和第三次编译的结果,以确保编译器能毫无差错的编译自身,这通常表明编译是正确的。

[[email protected] gcc-build]$ make install
[[email protected] gcc-build]$ ln -sf gcc /tools/bin/cc
[[email protected] gcc-build]$ cd ..
[[email protected] tools]$ rm -rf gcc-3.3.1
[[email protected] tools]$ rm -rf gcc-build

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/gcc-core-3.3.1.tar.bz2 /tools
bunzip2 gcc-core-3.3.1.tar.bz2
tar xvf gcc-core-3.3.1.tar
rm gcc-core-3.3.1.tar
cd gcc-3.3.1
mkdir ../gcc-build
cd ../gcc-build
time { ../gcc-3.3.1/configure --prefix=/tools
--with-local-prefix=/tools
--disable-nls --enable-shared
--enable-languages=c &&
make BOOT_LDFLAGS="-static" bootstrap &&
make install &&
ln -sf gcc /tools/bin/cc;
}
cd ..
rm -rf gcc-3.3.1
rm -rf gcc-build

#---- install script end ------------------------------------------------------

real 12m6.969s
user 11m21.500s
sys 0m39.570s


5.7 安装 Linux-2.4.22 头文件

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 186MB

[[email protected] tools]$ cp $LFS/sources/linux-2.4.22.tar.bz2 /tools
[[email protected] tools]$ bunzip2 linux-2.4.22.tar.bz2
[[email protected] tools]$ tar xvf linux-2.4.22.tar
[[email protected] tools]$ rm linux-2.4.22.tar
[[email protected] tools]$ cd linux-2.4.22
[[email protected] linux-2.4.22]$ make mrproper
[[email protected] linux-2.4.22]$ make include/linux/version.h
创建平台相关的 include/asm 符号链接:
[[email protected] linux-2.4.22]$ make symlinks
安装平台相关的内核头文件:
[[email protected] linux-2.4.22]$ mkdir /tools/include/asm
[[email protected] linux-2.4.22]$ cp include/asm/* /tools/include/asm
[[email protected] linux-2.4.22]$ cp -R include/asm-generic /tools/include
安装跨平台的内核头文件:
[[email protected] linux-2.4.22]$ cp -R include/linux /tools/include
还有几个内核头文件要使用 autoconf.h 头文件。因为我们没有配置内核,所以就需要自己创建这个文件,以避免编译错误。创建一个空的 autoconf.h 文件。
[[email protected] linux-2.4.22]$ touch /tools/include/linux/autoconf.h
[[email protected] linux-2.4.22]$ cd ..
[[email protected] tools]$ rm -rf linux-2.4.22

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/linux-2.4.22.tar.bz2 /tools
bunzip2 linux-2.4.22.tar.bz2
tar xvf linux-2.4.22.tar
rm linux-2.4.22.tar
cd linux-2.4.22
time { make mrproper &&
make include/linux/version.h &&
make symlinks &&
mkdir /tools/include/asm &&
cp include/asm/* /tools/include/asm &&
cp -R include/asm-generic /tools/include &&
cp -R include/linux /tools/include &&
touch /tools/include/linux/autoconf.h;
}
cd ..
rm -rf linux-2.4.22

#---- install script end -------------------------------------------------------

real 0m1.932s
user 0m0.180s
sys 0m0.140s


5.8 安装 Glibc-2.3.2

预计所需编译时间: 11.8SBU
预计所需硬盘空间: 800MB

Glibc 是提供系统调用和基本函数的 C 库,比如open, malloc, printf等等。所有动态连接的程序都要用到它。

安装下列程序: catchsegv, gencat, getconf, getent, glibcbug, iconv, iconvconfig, ldconfig, ldd, lddlibc4, locale, localedef, mtrace, nscd, nscd_nischeck, pcprofiledump, pt_chown, rpcgen, rpcinfo, sln, sprof, tzselect, xtrace, zdump 和 zic

安装下列库文件: ld.so, libBrokenLocale.[a,so], libSegFault.so, libanl.[a,so], libbsd-compat.a, libc.[a,so], libc_nonshared.a, libcrypt.[a,so], libdl.[a,so], libg.a, libieee.a, libm.[a,so], libmcheck.a, libmemusage.so, libnsl.a, libnss_compat.so, libnss_dns.so, libnss_files.so, libnss_hesiod.so, libnss_nis.so, libnss_nisplus.so, libpcprofile.so, libpthread.[a,so], libresolv.[a,so], librpcsvc.a, librt.[a,so], libthread_db.so 和 libutil.[a,so]

[[email protected] tools]$ cp $LFS/sources/glibc-2.3.2.tar.bz2 /tools
[[email protected] tools]$ bunzip2 glibc-2.3.2.tar.bz2
[[email protected] tools]$ tar xvf glibc-2.3.2.tar
[[email protected] tools]$ rm glibc-2.3.2.tar
[[email protected] tools]$ cd glibc-2.3.2
[[email protected] glibc-2.3.2]$ cp $LFS/sources/glibc-linuxthreads-2.3.2.tar.bz2 .
[[email protected] glibc-2.3.2]$ tar xvf glibc-linuxthreads-2.3.2.tar
[[email protected] glibc-2.3.2]$ rm glibc-linuxthreads-2.3.2.tar
[[email protected] glibc-2.3.2]$ mkdir /tools/etc
[[email protected] glibc-2.3.2]$ touch /tools/etc/ld.so.conf

修正缺少/tools/etc/ld.so.conf文件的警告

[[email protected] glibc-2.3.2]$ cp $LFS/sources/glibc-2.3.2-sscanf-1.patch .
[[email protected] glibc-2.3.2]$ patch -Np1 -i glibc-2.3.2-sscanf-1.patch

用GCC 3.3.1来编译Glibc时需要修正

[[email protected] glibc-2.3.2]$ mkdir ../glibc-build
[[email protected] glibc-2.3.2]$ cd ../glibc-build
[[email protected] glibc-build]$ ../glibc-2.3.2/configure --prefix=/tools
> --disable-profile --enable-add-ons
> --with-headers=/tools/include
> --with-binutils=/tools/bin
> --without-gd

参数说明:
--disable-profile: 它关掉了 profiling 信息相关的库文件编译
--enable-add-ons: 这个开关打开所有 Glibc的附加包,我们这里是 linuxthreads。
--with-binutils=/tools/bin 和 --with-headers=/tools/include: 这些参数并不是必需的。但它们能保证在编译 Glibc 时不会用错内核头文件和 Binutils 程序。
--without-gd: 这个参数保证我们不编译 memusagestat 程序,该程序会顽固地连接到主系统的库文件(libgd, libpng, libz 等等).

[[email protected] glibc-build]$ make
[[email protected] glibc-build]$ make check

Glibc的测试套件

[[email protected] glibc-build]$ make install
[[email protected] glibc-build]$ make localedata/install-locales

完整安装locale,或者也可以用下面的方法来最小化安装

[[email protected] glibc-build]$ mkdir -p /tools/lib/locale
[[email protected] glibc-build]$ localedef -i de_DE -f ISO-8859-1 de_DE
[[email protected] glibc-build]$ localedef -i [email protected] -f ISO-8859-15 [email protected]
[[email protected] glibc-build]$ localedef -i en_HK -f ISO-8859-1 en_HK
[[email protected] glibc-build]$ localedef -i en_PH -f ISO-8859-1 en_PH
[[email protected] glibc-build]$ localedef -i en_US -f ISO-8859-1 en_US
[[email protected] glibc-build]$ localedef -i es_MX -f ISO-8859-1 es_MX
[[email protected] glibc-build]$ localedef -i fr_FR -f ISO-8859-1 fr_FR
[[email protected] glibc-build]$ localedef -i [email protected] -f ISO-8859-15 [email protected]
[[email protected] glibc-build]$ localedef -i it_IT -f ISO-8859-1 it_IT
[[email protected] glibc-build]$ localedef -i ja_JP -f EUC-JP ja_JP

[[email protected] glibc-build]$ cd ..
[[email protected] tools]$ rm -rf glibc-2.3.2
[[email protected] tools]$ rm -rf glibc-build

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/glibc-2.3.2.tar.bz2 /tools
tar jxvf glibc-2.3.2.tar.bz2
rm glibc-2.3.2.tar.bz2
cd glibc-2.3.2
cp $LFS/sources/glibc-linuxthreads-2.3.2.tar.bz2 .
tar jxvf glibc-linuxthreads-2.3.2.tar.bz2
rm glibc-linuxthreads-2.3.2.tar.bz2
mkdir /tools/etc
touch /tools/etc/ld.so.conf
cp $LFS/sources/glibc-2.3.2-sscanf-1.patch .
patch -Np1 -i glibc-2.3.2-sscanf-1.patch
mkdir ../glibc-build
cd ../glibc-build
../glibc-2.3.2/configure --prefix=/tools
--disable-profile --enable-add-ons
--with-headers=/tools/include
--with-binutils=/tools/bin
--without-gd
time { make; }

make check
make install
make localedata/install-locales
cd ..
rm -rf glibc-2.3.2
rm -rf glibc-build

#---- install script end -------------------------------------------------------

real 18m11.625s
user 15m30.590s
sys 2m2.520s


##############################################
直接解压 .tar.bz2 的两种方法

tar jxvf filename.tar.bz2
bzcat filename.tar.bz2 | tar -xv
##############################################


5.9 "Locking in" Glibc

[[email protected] tools]$ cd /tools/binutils-build
[[email protected] binutils-build]$ make -C ld install

安装调整过的连接器

[[email protected] tools]$ rm -rf binutils-2.14
[[email protected] tools]$ rm -rf binutils-build

[[email protected] tools]$ SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
> sed -e '[email protected] /lib/[email protected] /tools/lib/[email protected]'
> $SPECFILE > tempspecfile
[[email protected] tools]$ mv tempspecfile $SPECFILE &&
> unset SPECFILE

修改 /tools/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/specs,
将"/lib/ld-linux.so.2" 替换成 "/tools/lib/ld-linux.so.2"

[[email protected] tools]$ rm -f /tools/lib/gcc-lib/*/*/include/{pthread.h,bits/sigthread.h}

删除掉由于GCC的 fixincludes 脚本将主系统中的头文件copy到gcc的头文件中所产生的错误文件

[[email protected] tools]$ echo 'main(){}' > dummy.c
[[email protected] tools]$ gcc dummy.c
[[email protected] tools]$ readelf -l a.out | grep ': /tools'

测试新工具链编译的连接是否正常,如果一切OK,结果如下:
[Requesting program interpreter: /tools/lib/ld-linux.so.2]

[[email protected] tools]$ rm a.out dummy.c

至此完成了工具链的安装,可以用它来编译剩下的工具了。

#---- install script begin ----------------------------------------------------
cd /tools/binutils-build
make -C ld install
rm -rf binutils-2.14
rm -rf binutils-build
SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
sed -e '[email protected] /lib/[email protected] /tools/lib/[email protected]'
$SPECFILE > tempspecfile
mv tempspecfile $SPECFILE &&
unset SPECFILE
rm -f /tools/lib/gcc-lib/*/*/include/{pthread.h,bits/sigthread.h}
echo 'main(){}' > dummy.c
gcc dummy.c
readelf -l a.out | grep ': /tools'
rm a.out dummy.c

#---- install script end ------------------------------------------------------


5.10 安装 Tcl-8.4.4

预计所需编译空间: 0.9SBU
预计所需硬盘空间: 23MB

TCL: Tool Command Language
安装下列程序: tclsh (link to tclsh8.4)
安装下列库文件: libtl8.4.so

[[email protected] tools]$ cp $LFS/sources/tcl8.4.4-src.tar.bz2 .
[[email protected] tools]$ tar jxvf tcl8.4.4-src.tar.bz2
[[email protected] tools]$ rm tcl8.4.4-src.tar.bz2
[[email protected] tools]$ cd tcl8.4.4/unix
[[email protected] unix]$ ./configure --prefix=/tools
[[email protected] unix]$ make
[[email protected] unix]$ TZ=UTC make test

将时区设置为 Coordinated Universal Time (UTC), 又叫GMT,同时进行测试。
根据官方文档,本测试套件总会出错,原因不明。可是我测试通过了。
Tests ended at Sat Nov 22 16:46:51 UTC 2003
all.tcl: Total 10503 Passed 9671 Skipped 832 Failed 0

[[email protected] unix]$ make install
[[email protected] unix]$ ln -s tclsh8.4 /tools/bin/tclsh

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/tcl8.4.4-src.tar.bz2 .
tar jxvf tcl8.4.4-src.tar.bz2
rm tcl8.4.4-src.tar.bz2
cd tcl8.4.4/unix
./configure --prefix=/tools
make
TZ=UTC make test
make install
ln -s tclsh8.4 /tools/bin/tclsh

#---- install script end ------------------------------------------------------


5.11 安装 Expect-5.39.0

预计所需编译时间: 0.1SBU
预计所需编译空间: 3.9MB

Expect 软件包包换一个程序,可以与其他程序交互,以编程方式生成对话框。
安装下列程序: expect
安装下列库文件: libexpect5.39.a

[[email protected] tools]$ cd /tools
[[email protected] tools]$ cp $LFS/sources/expect-5.39.0* .
[[email protected] tools]$ tar jxvf expect-5.39.0.tar.bz2
[[email protected] tools]$ rm expect-5.39.0.tar.bz2
[[email protected] tools]$ cd expect-5.39
[[email protected] expect-5.39]$ patch -Np1 -i ../expect-5.39.0-spawn.patch

修正了Expect中的一个bug,这个bug会使GCC的测试套件运行时产生假错误。

[[email protected] expect-5.39]$ ./configure
> --prefix=/tools
> --with-tcl=/tools/lib
> --with-x=no

[[email protected] expect-5.39]$ make

(测试套件 make test 我没进行)

[[email protected] expect-5.39]$ make SCRIPTS="" install

SCRIPTS="": 禁止安装我们不需要的 expect脚本

[[email protected] tools]$ rm expect-5.39.0-spawn.patch
[[email protected] tools]$ rm -rf expect-5.39
[[email protected] tools]$ rm -rf tcl8.4.4

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/expect-5.39.0* .
tar jxvf expect-5.39.0.tar.bz2
rm expect-5.39.0.tar.bz2
cd expect-5.39
patch -Np1 -i ../expect-5.39.0-spawn.patch
./configure
--prefix=/tools
--with-tcl=/tools/lib
--with-x=no
make
make test
make SCRIPTS="" install
rm expect-5.39.0-spawn.patch
rm -rf expect-5.39
rm -rf tcl8.4.4

#---- install script end ------------------------------------------------------


5.12 安装 DejaGnu-1.4.3

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 8.6MB

DejaGnu包含测试其他程序的工具。
安装下列程序: runtest

[[email protected] tools]$ cp $LFS/sources/dejagnu-1.4.3.tar.bz2 .
[[email protected] tools]$ tar jxvf dejagnu-1.4.3.tar.bz2
[[email protected] tools]$ rm dejagnu-1.4.3.tar.bz2
[[email protected] tools]$ cd dejagnu-1.4.3
[[email protected] dejagnu-1.4.3]$ ./configure --prefix=/tools
[[email protected] dejagnu-1.4.3]$ make install
[[email protected] dejagnu-1.4.3]$ cd ..
[[email protected] tools]$ rm -rf dejagnu-1.4.3

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/dejagnu-1.4.3.tar.bz2 .
tar jxvf dejagnu-1.4.3.tar.bz2
rm dejagnu-1.4.3.tar.bz2
cd dejagnu-1.4.3
./configure --prefix=/tools
make install
cd ..
rm -rf dejagnu-1.4.3

#---- install script end ------------------------------------------------------


5.13 安装 GCC-3.3.1 第二遍

预计所需编译时间: 11.0SBU
预计所需硬盘空间: 274MB

测试GCC和Binutils所必需的工具Tcl, Expect, DejaGnu 已经安装完毕了。
我们重新编译GCC和Binutils,把它们连接到新的Glibc上,并测试正确性。

首先测试主系统中PTY (pseudo 终端) 是否设置正常。
因为测试套件受PTY影响很大,这些PTY由主系统提供,通过 devpts 文件系统实现。
[[email protected] tools]$ expect -c "spawn ls"
spawn ls

如果得到以下回答:
The system has no more ptys. Ask your system administrator to create more.
则PTY设置错误。

[[email protected] tools]$ cp $LFS/sources/gcc-core-3.3.1.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/gcc-g++-3.3.1.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/gcc-testsuite-3.3.1.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/gcc-3.3.1-no_fixincludes-2.patch .
[[email protected] tools]$ cp $LFS/sources/gcc-3.3.1-specs-2.patch .

[[email protected] tools]$ tar jxvf gcc-core-3.3.1.tar.bz2
[[email protected] tools]$ tar jxvf gcc-g++-3.3.1.tar.bz2
[[email protected] tools]$ tar jxvf gcc-testsuite-3.3.1.tar.bz2
[[email protected] tools]$ rm gcc-core-3.3.1.tar.bz2 gcc-g++-3.3.1.tar.bz2 gcc-testsuite-3.3.1.tar.bz2

[[email protected] tools]$ cd gcc-3.3.1
[[email protected] gcc-3.3.1]$ patch -Np1 -i ../gcc-3.3.1-no_fixincludes-2.patch
此补丁禁止GCC中"fixincludes"脚本运行
[[email protected] gcc-3.3.1]$ patch -Np1 -i ../gcc-3.3.1-specs-2.patch
此补丁修改GCC的缺省动态连接器 ld-linux.so.2 的位置,还把 /usr/include 从GCC的头文件搜索路经里去掉

[[email protected] gcc-3.3.1]$ mkdir ../gcc-build
[[email protected] gcc-3.3.1]$ cd ../gcc-build
[[email protected] gcc-build]$ ../gcc-3.3.1/configure --prefix=/tools
> --with-local-prefix=/tools
> --enable-clocale=gnu --enable-shared
> --enable-threads=posix --enable-__cxa_atexit
> --enable-languages=c,c++

参数含义:
--enable-threads=posix:使c++异常能处理多线程代码。
--enable-__cxa_atexit:使用 __cxa_atexit来代替 atexit,用来记录本地和全局的的C++ destructors,这是为了完全符合标准的规定。它还会影响到C++ ABI,因此生成的C++共享库,在其他的Linux发行版上也能使用。
--enable-clocale=gnu: 本参数确保C++库在任何情况下都使用正确的locale模块。如果配置脚本查找到de_DE这个locale,它就会使用正确的gnu模块。然而,有的人没有安装de_DE,就有可能创建出ABI不兼容的C++库文件,这是因为错误的使用了generic作为locale模块。
--enable-languages=c,c++: 本参数编译C和C++语言的编译器。

[[email protected] gcc-build]$ time { make; }

real 8m3.179s
user 7m21.530s
sys 0m37.860s

[[email protected] gcc-build]$ time { make -k check; }

=== g++ Summary ===

# of expected passes 8109
# of unexpected failures 1
# of unexpected successes 1
# of expected failures 94
# of untested testcases 9
# of unsupported tests 14
/mnt/lfs/tools/gcc-build/gcc/testsuite/../g++ version 3.3.1

real 35m30.857s
user 31m3.030s
sys 4m18.870s

[[email protected] gcc-build]$ make install

再进行一次合理性测试
[[email protected] gcc-build]$ cd ..
[[email protected] tools]$ echo 'main(){}' > dummy.c
[[email protected] tools]$ gcc dummy.c
[[email protected] tools]$ readelf -l a.out | grep ': /tools'
[Requesting program interpreter: /tools/lib/ld-linux.so.2]
[[email protected] tools]$ rm a.out dummy.c
[[email protected] tools]$ rm gcc-3.3.1-no_fixincludes-2.patch gcc-3.3.1-specs-2.patch
[[email protected] tools]$ rm -rf gcc-3.3.1
[[email protected] tools]$ rm -rf gcc-build

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/gcc-core-3.3.1.tar.bz2 .
cp $LFS/sources/gcc-g++-3.3.1.tar.bz2 .
cp $LFS/sources/gcc-testsuite-3.3.1.tar.bz2 .
cp $LFS/sources/gcc-3.3.1-no_fixincludes-2.patch .
cp $LFS/sources/gcc-3.3.1-specs-2.patch .
tar jxvf gcc-core-3.3.1.tar.bz2
tar jxvf gcc-g++-3.3.1.tar.bz2
tar jxvf gcc-testsuite-3.3.1.tar.bz2
rm gcc-core-3.3.1.tar.bz2 gcc-g++-3.3.1.tar.bz2 gcc-testsuite-3.3.1.tar.bz2
cd gcc-3.3.1
patch -Np1 -i ../gcc-3.3.1-no_fixincludes-2.patch
patch -Np1 -i ../gcc-3.3.1-specs-2.patch
mkdir ../gcc-build
cd ../gcc-build
../gcc-3.3.1/configure --prefix=/tools
--with-local-prefix=/tools
--enable-clocale=gnu --enable-shared
--enable-threads=posix --enable-__cxa_atexit
--enable-languages=c,c++
make;
make -k check
make install

cd ..
echo 'main(){}' > dummy.c
gcc dummy.c
readelf -l a.out | grep ': /tools'
rm a.out dummy.c
rm gcc-3.3.1-no_fixincludes-2.patch gcc-3.3.1-specs-2.patch
rm -rf gcc-3.3.1
rm -rf gcc-build

#---- install script end ------------------------------------------------------



5.14 安装 Binutils-2.14 第二遍

预计安装所需编译时间: 1.5SBU
预计所需硬盘空间: 108MB

[[email protected] tools]$ cp $LFS/sources/binutils-2.14.tar.bz2 .
[[email protected] tools]$ tar jxvf binutils-2.14.tar.bz2
[[email protected] tools]$ rm binutils-2.14.tar.bz2
[[email protected] binutils-build]$ ../binutils-2.14/configure --prefix=/tools
> --enable-shared --with-lib-path=/tools/lib

参数含义:
--with-lib-path=/tools/lib: 这个参数给配置脚本指定缺省的库搜索路径。我们不希望库搜索路径里包含主系统的目录。

[[email protected] tools]$ make

[[email protected] tools]$ make check
运行测试套件:
这时应该没有unexpected failures, 但expected failures是正常的。

=== ld Summary ===

# of expected passes 192
# of expected failures 1
/mnt/lfs/tools/binutils-build/ld/ld-new 20030612


[[email protected] binutils-build]$ make install

还要再次调整工具链,这里要做一些准备:
[[email protected] binutils-build]$ make -C ld clean
[[email protected] binutils-build]$ make -C ld LIB_PATH=/usr/lib:/lib

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/binutils-2.14.tar.bz2 .
tar jxvf binutils-2.14.tar.bz2
rm binutils-2.14.tar.bz2
../binutils-2.14/configure --prefix=/tools
--enable-shared --with-lib-path=/tools/lib
make
make check

make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib

#---- install script end ------------------------------------------------------


5.15 安装 Gawk-3.1.3

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 17MB

Gawk是awk的一个实现,用来处理文本文件。

安装下列程序: awk (link to gawk), gawk, gawk-3.1.1, grcat, igawk, pgawk, pgawk-3.1.1, pwcat

[[email protected] binutils-build]$ cd /tools
[[email protected] tools]$ cp $LFS/sources/gawk-3.1.3.tar.bz2 .
[[email protected] tools]$ tar jxvf gawk-3.1.3.tar.bz2
[[email protected] tools]$ rm gawk-3.1.3.tar.bz2
[[email protected] tools]$ cd gawk-3.1.3
[[email protected] gawk-3.1.3]$ ./configure --prefix=/tools
[[email protected] gawk-3.1.3]$ make
[[email protected] gawk-3.1.3]$ make check
[[email protected] gawk-3.1.3]$ make install
[[email protected] gawk-3.1.3]$ cd ..
[[email protected] tools]$ rm -rf gawk-3.1.3

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/gawk-3.1.3.tar.bz2 .
tar jxvf gawk-3.1.3.tar.bz2
rm gawk-3.1.3.tar.bz2
cd gawk-3.1.3
./configure --prefix=/tools
make
make check
make install
cd ..
rm -rf gawk-3.1.3

#---- install script end ------------------------------------------------------


5.16 安装 Coreutils-5.0

预计所需编译时间: 0.9SBU
预计所需硬盘空间: 69MB

一整套基本的shell工具
安装下列程序: basename, cat, chgrp, chmod, chown, chroot, cksum, comm, cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo, env, exp和, expr, factor, false, fmt, fold, groups, head, hostid, hostname, id, install, join, kill, link, ln, logname, ls, md5sum, mkdir, mkfifo, mknod, mv, nice, nl, nohup, od, paste, pathchk, pinky, pr, printenv, printf, ptx, pwd, readlink, rm, rmdir, seq, sha1sum, shred, sleep, sort, split, stat, stty, su, sum, sync, tac, tail, tee, test, touch, tr, true, tsort, tty, uname, unexp和, uniq, unlink, uptime, users, vdir, wc, who, whoami 和 yes

[[email protected] tools]$ cp $LFS/sources/coreutils-5.0.tar.bz2 .
[[email protected] tools]$ tar jxvf coreutils-5.0.tar.bz2
[[email protected] tools]$ rm coreutils-5.0.tar.bz2
[[email protected] tools]$ cd coreutils-5.0/
[[email protected] coreutils-5.0]$ ./configure --prefix=/tools

[[email protected] coreutils-5.0]$ make
[[email protected] coreutils-5.0]$ make RUN_EXPENSIVE_TESTS=yes check
[[email protected] coreutils-5.0]$ make install
[[email protected] coreutils-5.0]$ cd ..
[[email protected] tools]$ rm -rf coreutils-5.0

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/coreutils-5.0.tar.bz2 .
tar jxvf coreutils-5.0.tar.bz2
rm coreutils-5.0.tar.bz2
cd coreutils-5.0/
./configure --prefix=/tools
make
make RUN_EXPENSIVE_TESTS=yes check

make install
cd ..
rm -rf coreutils-5.0

#---- install script end ------------------------------------------------------


5.17 安装 Bzip2-1.0.2

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 2.5MB

Bzip2 是块排序文件压缩器,比传统的gzip生成更高压缩比的文件。
安装下列程序: bunzip2 (link to bzip2), bzcat (link to bzip2), bzcmp, bzdiff, bzegrep, bzfgrep, bzgrep, bzip2, bzip2recover, bzless 和 bzmore
安装下列库文件: libbz2.a, libbz2.so (link to libbz2.so.1.0), libbz2.so.1.0 (link to libbz2.so.1.0.2) 和 libbz2.so.1.0.2

[[email protected] tools]$ cp $LFS/sources/bzip2-1.0.2.tar.bz2 .
[[email protected] tools]$ tar jxvf bzip2-1.0.2.tar.bz2
[[email protected] tools]$ rm bzip2-1.0.2.tar.bz2
[[email protected] tools]$ cd bzip2-1.0.2
[[email protected] bzip2-1.0.2]$ make PREFIX=/tools install
[[email protected] bzip2-1.0.2]$ cd ..
[[email protected] tools]$ rm -rf bzip2-1.0.2

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/bzip2-1.0.2.tar.bz2 .
tar jxvf bzip2-1.0.2.tar.bz2
rm bzip2-1.0.2.tar.bz2
cd bzip2-1.0.2
make PREFIX=/tools install
cd ..
rm -rf bzip2-1.0.2

#---- install script end ------------------------------------------------------


5.18 安装 Gzip-1.3.5

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 2.6MB

gzip 包含用Lempel-Ziv编码(LZ77)来压缩和解压文件的程序。
安装下列程序: gunzip (link to gzip), gzexe, gzip, uncompress (link to gunzip), zcat (link to gzip), zcmp, zdiff, zforce, zegrep, zfgrep, zgrep, zmore 和 znew

[[email protected] tools]$ cp $LFS/sources/gzip-1.3.5.tar.bz2 .
[[email protected] tools]$ tar jxvf gzip-1.3.5.tar.bz2
[[email protected] tools]$ rm gzip-1.3.5.tar.bz2
[[email protected] tools]$ cd gzip-1.3.5/
[[email protected] gzip-1.3.5]$ ./configure --prefix=/tools
[[email protected] gzip-1.3.5]$ make
[[email protected] gzip-1.3.5]$ make install
[[email protected] gzip-1.3.5]$ cd ..
[[email protected] tools]$ rm -rf gzip-1.3.5

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/gzip-1.3.5.tar.bz2 .
tar jxvf gzip-1.3.5.tar.bz2
rm gzip-1.3.5.tar.bz2
cd gzip-1.3.5/
./configure --prefix=/tools
make
make install
cd ..
rm -rf gzip-1.3.5

#---- install script end ------------------------------------------------------

5.19 安装 Diffutils-2.8.1

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 7.5MB

这个软件包里的程序向你显示两个文件或目录的差异,常用来生成软件的补丁。
安装下列程序: cmp, diff, diff3 和 sdiff

[[email protected] tools]$ cp $LFS/sources/diffutils-2.8.1.tar.bz2 .
[[email protected] tools]$ tar jxvf diffutils-2.8.1.tar.bz2
[[email protected] tools]$ rm diffutils-2.8.1.tar.bz2
[[email protected] tools]$ cd diffutils-2.8.1/
[[email protected] diffutils-2.8.1]$ ./configure --prefix=/tools
[[email protected] diffutils-2.8.1]$ make
[[email protected] diffutils-2.8.1]$ make install
[[email protected] diffutils-2.8.1]$ cd ..
[[email protected] tools]$ rm -rf diffutils-2.8.1

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/diffutils-2.8.1.tar.bz2 .
tar jxvf diffutils-2.8.1.tar.bz2
rm diffutils-2.8.1.tar.bz2
cd diffutils-2.8.1/
./configure --prefix=/tools
make
make install
cd ..
rm -rf diffutils-2.8.1

#---- install script end ------------------------------------------------------


5.20 安装 Findutils-4.1.20

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 7.6MB

Findutils 包含查找文件的工具,既能即时查找(递归的搜索目录,只显示符合要求的文件),也能在数据库里查找。
安装下列程序: bigram, code, find, frcode, locate, updatedb 和 xargs

[[email protected] tools]$ cp $LFS/sources/findutils-4.1.20.tar.bz2 .
[[email protected] tools]$ tar jxvf findutils-4.1.20.tar.bz2
[[email protected] tools]$ rm findutils-4.1.20.tar.bz2
[[email protected] tools]$ cd findutils-4.1.20/
[[email protected] findutils-4.1.20]$ ./configure --prefix=/tools
[[email protected] findutils-4.1.20]$ make
[[email protected] findutils-4.1.20]$ make check
[[email protected] findutils-4.1.20]$ make install
[[email protected] findutils-4.1.20]$ cd ..
[[email protected] tools]$ rm -rf findutils-4.1.20

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/findutils-4.1.20.tar.bz2 .
tar jxvf findutils-4.1.20.tar.bz2
rm findutils-4.1.20.tar.bz2
cd findutils-4.1.20/
./configure --prefix=/tools
make
make check

make install
cd ..
rm -rf findutils-4.1.20

#---- install script end ------------------------------------------------------


5.21 安装 Make-3.80

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 8.8MB

Make 自动地确定一个大型程序的哪些片段需要重新编译,并且发出命令去重新编译它们。
安装下列程序: make

[[email protected] tools]$ cp $LFS/sources/make-3.80.tar.bz2 .
[[email protected] tools]$ tar jxvf make-3.80.tar.bz2
[[email protected] tools]$ rm make-3.80.tar.bz2
[[email protected] tools]$ cd make-3.80/
[[email protected] make-3.80]$ ./configure --prefix=/tools
[[email protected] make-3.80]$ make
[[email protected] make-3.80]$ make check
[[email protected] make-3.80]$ make install
[[email protected] make-3.80]$ cd ..
[[email protected] tools]$ rm -rf make-3.80

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/make-3.80.tar.bz2 .
tar jxvf make-3.80.tar.bz2
rm make-3.80.tar.bz2
cd make-3.80/
./configure --prefix=/tools
make
make check
make install
cd ..
rm -rf make-3.80

#---- install script end ------------------------------------------------------

5.22 安装 Grep-2.5.1

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 5.8MB

Grep 打印出文件中符合指定模式的行。
安装下列程序: egrep (指向grep的链接), fgrep (指向grep的链接) 和 grep

[[email protected] tools]$ cp $LFS/sources/grep-2.5.1.tar.bz2 .
[[email protected] tools]$ tar jxvf grep-2.5.1.tar.bz2
[[email protected] tools]$ rm grep-2.5.1.tar.bz2
[[email protected] tools]$ cd grep-2.5.1
[[email protected] grep-2.5.1]$ ./configure --prefix=/tools
> --disable-perl-regexp --with-included-regex

--disable-perl-regexp: 它确保grep不会连接到主系统中可能存在的 PCRE 库上,因为主系统中的库在进入chroot环境后就不能用了。
--with-included-regex: 它确保grep使用内建的正则表达式代码。没有这个参数,它会使用glibc中的代码,而那些代码是有些小毛病的。

[[email protected] grep-2.5.1]$ make
[[email protected] grep-2.5.1]$ make check
[[email protected] grep-2.5.1]$ make install
[[email protected] grep-2.5.1]$ cd ..
[[email protected] tools]$ rm -rf grep-2.5.1

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/grep-2.5.1.tar.bz2 .
tar jxvf grep-2.5.1.tar.bz2
rm grep-2.5.1.tar.bz2
cd grep-2.5.1
./configure --prefix=/tools
--disable-perl-regexp --with-included-regex
make
make check

make install
cd ..
rm -rf grep-2.5.1

#---- install script end ------------------------------------------------------


5.23 安装 Sed-4.0.7

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 5.2MB

sed是一个流编辑程序,在一个输入流(从一个文件或者一个管道的输入)上进行基本的文本编辑操作。
安装下列程序: sed

[[email protected] tools]$ cp $LFS/sources/sed-4.0.7.tar.bz2 .
[[email protected] tools]$ tar jxvf sed-4.0.7.tar.bz2
[[email protected] tools]$ rm sed-4.0.7.tar.bz2
[[email protected] tools]$ cd sed-4.0.7/
[[email protected] sed-4.0.7]$ ./configure --prefix=/tools
[[email protected] sed-4.0.7]$ make
[[email protected] sed-4.0.7]$ make check
[[email protected] sed-4.0.7]$ make install
[[email protected] sed-4.0.7]$ cd ..
[[email protected] tools]$ rm -rf sed-4.0.7

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/sed-4.0.7.tar.bz2 .
tar jxvf sed-4.0.7.tar.bz2
rm sed-4.0.7.tar.bz2
cd sed-4.0.7/
./configure --prefix=/tools
make
make check

make install
cd ..
rm -rf sed-4.0.7

#---- install script end ------------------------------------------------------


5.24 安装 Gettext-0.12.1

预计所需编译时间: 1SBU
预计所需硬盘空间: 55MB

Gettext 用于系统的国际化(I18N)和本地化(L10N),可以在编译程序的时候使用本国语言支持(Native Language Support(NLS)),其可以使程序的输出使用用户设置的语言而不是英文.
安装下列程序: autopoint, config.charset, config.rpath, gettext, gettextize, hostname, msgattrib, msgcat, msgcmp, msgcomm, msgconv, msgen, msgexec, msgfilter, msgfmt, msggrep, msginit, msgmerge, msgunfmt, msguniq, ngettext, project-id, team-address, trigger, urlget, user-email 和 xgettext
安装下列库文件: libasprintf[a,so], libgettextlib[a,so] 和 libgettextsrc[a,so]

[[email protected] tools]$ cp $LFS/sources/gettext-0.12.1.tar.bz2 .
[[email protected] tools]$ tar jxvf gettext-0.12.1.tar.bz2
[[email protected] tools]$ rm gettext-0.12.1.tar.bz2
[[email protected] tools]$ cd gettext-0.12.1/
[[email protected] gettext-0.12.1]$ ./configure --prefix=/tools
[[email protected] gettext-0.12.1]$ make
[[email protected] gettext-0.12.1]$ make check (ignored)
[[email protected] gettext-0.12.1]$ make install
[[email protected] gettext-0.12.1]$ cd ..
[[email protected] tools]$ rm -rf gettext-0.12.1

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/gettext-0.12.1.tar.bz2 .
tar jxvf gettext-0.12.1.tar.bz2
rm gettext-0.12.1.tar.bz2
cd gettext-0.12.1/
./configure --prefix=/tools
make
make check

make install
cd ..
rm -rf gettext-0.12.1

#---- install script end ------------------------------------------------------


5.25 安装 Ncurses-5.3

预计所需编译时间: 0.7SBU
预计所需硬盘空间: 26MB

Ncurses 提供字符终端处理库,包括面板和菜单。
安装下列程序: captoinfo (link to tic), clear, infocmp, infotocap (link to tic), reset (link to tset), tack, tic, toe, tput 和 tset
安装下列库文件: libcurses.[a,so] (link to libncurses.[a,so]), libform.[a,so], libmenu.[a,so], libncurses++.a, libncurses.[a,so] 和 libpanel.[a,so]

[[email protected] tools]$ cp $LFS/sources/ncurses-5.3.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/ncurses-5.3-etip-2.patch .
[[email protected] tools]$ cp $LFS/sources/ncurses-5.3-vsscanf.patch .
[[email protected] tools]$ tar jxvf ncurses-5.3.tar.bz2
[[email protected] tools]$ rm ncurses-5.3.tar.bz2
[[email protected] tools]$ cd ncurses-5.3
[[email protected] ncurses-5.3]$ patch -Np1 -i ../ncurses-5.3-etip-2.patch
[[email protected] ncurses-5.3]$ patch -Np1 -i ../ncurses-5.3-vsscanf.patch

第一个补丁修改 etip.h 头文件,第二个补丁防止编译时出现使用旧头文件的编译警告。

[[email protected] ncurses-5.3]$ ./configure --prefix=/tools
> --with-shared --without-debug
> --without-ada --enable-overwrite

--without-ada: 这个参数告诉 Ncurses,即使主系统里有ada编译器,也不要编译成ada绑定的。必须这样,因为在我们进入chroot环境后,就不能使用主系统中的ada了。
--enable-overwrite: 本参数告诉 Ncurses把头文件安装到/tools/include下而不是/tools/include/ncurses目录里,这是为了其他软件包能顺利地找到Ncurses头文件。

[[email protected] ncurses-5.3]$ make
[[email protected] ncurses-5.3]$ make install
[[email protected] ncurses-5.3]$ cd ..
[[email protected] tools]$ rm -rf ncurses-5.3
[[email protected] tools]$ rm ncurses-5.3-etip-2.patch ncurses-5.3-vsscanf.patch

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/ncurses-5.3.tar.bz2 .
cp $LFS/sources/ncurses-5.3-etip-2.patch .
cp $LFS/sources/ncurses-5.3-vsscanf.patch .
tar jxvf ncurses-5.3.tar.bz2
rm ncurses-5.3.tar.bz2
cd ncurses-5.3
patch -Np1 -i ../ncurses-5.3-etip-2.patch
patch -Np1 -i ../ncurses-5.3-vsscanf.patch
./configure --prefix=/tools
--with-shared --without-debug
--without-ada --enable-overwrite
make
make install
cd ..
rm -rf ncurses-5.3
rm ncurses-5.3-etip-2.patch ncurses-5.3-vsscanf.patch

#---- install script end ------------------------------------------------------


5.26 安装 Patch-2.5.4

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 1.9MB

patch程序根据补丁文件的内容来修改原来的文件。补丁文件通常是用 diff 程序创建的,包含如何修改文件的指导。
安装下列程序: patch

[[email protected] tools]$ cp $LFS/sources/patch-2.5.4.tar.bz2 .
[[email protected] tools]$ tar jxvf patch-2.5.4.tar.bz2
[[email protected] tools]$ rm patch-2.5.4.tar.bz2
[[email protected] tools]$ cd patch-2.5.4/
[[email protected] patch-2.5.4]$ CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools

参数 -D_GNU_SOURCE 只在 PowerPC 平台下才需要,在其他平台下你可以省略掉,不过留着也没什么坏处。

[[email protected] patch-2.5.4]$ make
[[email protected] patch-2.5.4]$ make install
[[email protected] patch-2.5.4]$ cd ..
[[email protected] tools]$ rm -rf patch-2.5.4

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/patch-2.5.4.tar.bz2 .
tar jxvf patch-2.5.4.tar.bz2
rm patch-2.5.4.tar.bz2
cd patch-2.5.4/
CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools
make
make install
cd ..
rm -rf patch-2.5.4

#---- install script end ------------------------------------------------------


5.27 安装 Tar-1.13.25

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 10MB

Tar 是一个归档程序,用来保存文件到归档文件或者从给定的tar归档文件中释放文件。
安装下列程序: rmt 和 tar

[[email protected] tools]$ cp $LFS/sources/tar-1.13.25.tar.bz2 .
[[email protected] tools]$ tar jxvf tar-1.13.25.tar.bz2
[[email protected] tools]$ rm tar-1.13.25.tar.bz2
[[email protected] tools]$ cd tar-1.13.25
[[email protected] tar-1.13.25]$ ./configure --prefix=/tools
[[email protected] tar-1.13.25]$ make
[[email protected] tar-1.13.25]$ make check
[[email protected] tar-1.13.25]$ make install
[[email protected] tar-1.13.25]$ cd ..
[[email protected] tools]$ rm -rf tar-1.13.25

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/tar-1.13.25.tar.bz2 .
tar jxvf tar-1.13.25.tar.bz2
rm tar-1.13.25.tar.bz2
cd tar-1.13.25
./configure --prefix=/tools
make
make check
make install
cd ..
rm -rf tar-1.13.25

#---- install script end ------------------------------------------------------


5.28 安装 Texinfo-4.6

预计所需编译时间: 0.2SBU
预计所需硬盘空间: 16MB

Texinfo软件包包含读取、写入和转换 Info 文档的程序,以提供系统文档。
安装下列程序: info, infokey, install-info, makeinfo, texi2dvi 和 texindex

[[email protected] tools]$ cp $LFS/sources/texinfo-4.6.tar.bz2 .
[[email protected] tools]$ tar jxvf texinfo-4.6.tar.bz2
[[email protected] tools]$ rm texinfo-4.6.tar.bz2
[[email protected] tools]$ cd texinfo-4.6/
[[email protected] texinfo-4.6]$ ./configure --prefix=/tools
[[email protected] texinfo-4.6]$ make
[[email protected] texinfo-4.6]$ make check
[[email protected] texinfo-4.6]$ make install
[[email protected] texinfo-4.6]$ cd ..
[[email protected] tools]$ rm -rf texinfo-4.6

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/texinfo-4.6.tar.bz2 .
tar jxvf texinfo-4.6.tar.bz2
rm texinfo-4.6.tar.bz2
cd texinfo-4.6/
./configure --prefix=/tools
make
make check

make install
cd ..
rm -rf texinfo-4.6

#---- install script end ------------------------------------------------------


5.29 安装 Bash-2.05b

预计所需编译时间: 1.2SBU
预计所需硬盘空间: 27MB

Bash是Bourne-Again Shell的缩写,它在UNIX系统中作为命令行解释器被广泛使用。 Bash是一个从标准输入--键盘--中读取命令的程序。用户敲击一个命令,这个程序读取这些命令并且根据命令进行相应的操作(比如运行一个程序)。
安装下列程序: bash, sh (指向bash的链接) 和 bashbug

[[email protected] tools]$ cp $LFS/sources/bash-2.05b.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/bash-2.05b-2.patch .
[[email protected] tools]$ tar jxvf bash-2.05b.tar.bz2
[[email protected] tools]$ rm bash-2.05b.tar.bz2
[[email protected] tools]$ cd bash-2.05b
[[email protected] bash-2.05b]$ patch -Np1 -i ../bash-2.05b-2.patch
[[email protected] bash-2.05b]$ ./configure --prefix=/tools
[[email protected] bash-2.05b]$ make
[[email protected] bash-2.05b]$ make tests
[[email protected] bash-2.05b]$ make install
[[email protected] bash-2.05b]$ cd ..
[[email protected] tools]$ rm -rf bash-2.05b
[[email protected] tools]$ rm bash-2.05b-2.patch
[[email protected] tools]$ ln -s bash /tools/bin/sh

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/bash-2.05b.tar.bz2 .
cp $LFS/sources/bash-2.05b-2.patch .
tar jxvf bash-2.05b.tar.bz2
rm bash-2.05b.tar.bz2
cd bash-2.05b
patch -Np1 -i ../bash-2.05b-2.patch
./configure --prefix=/tools
make
make tests

make install
cd ..
rm -rf bash-2.05b
rm bash-2.05b-2.patch
ln -s bash /tools/bin/sh

#---- install script end ------------------------------------------------------


5.30 安装 Util-linux-2.12

预计所需编译时间: 0.1SBU
预计所需硬盘空间: 8MB

Util-linux 软件包包含许多工具。其中比较重要的是加载、卸载、格式化、分区和管理硬盘驱动器,打开 tty 端口和得到内核消息。
安装下列程序: agetty, arch, blockdev, cal, cfdisk, chkdupexe, col, colcrt, colrm, column, ctrlaltdel, cytune, ddate, dmesg, elvtune, fdformat, fdisk, fsck.cramfs, fsck.minix, getopt, hexdump, hwclock, ipcrm, ipcs, isosize, kill, line, logger, look, losetup, mcookie, mkfs, mkfs.bfs, mkfs.cramfs, mkfs.minix, mkswap, more, mount, namei, parse.bash, parse.tcsh, pg, pivot_root, ramsize (link to rdev), raw, rdev, readprofile, rename, renice, rev, rootflags (link to rdev), script, setfdprm, setsid, setterm, sfdisk, swapoff (link to swapon), swapon, test.bash, test.tcsh, tunelp, ul, umount, vidmode (link to rdev), whereis 和 write

[[email protected] tools]$ cp $LFS/sources/util-linux-2.12.tar.bz2 .
[[email protected] tools]$ tar jxvf util-linux-2.12.tar.bz2
[[email protected] tools]$ rm util-linux-2.12.tar.bz2
[[email protected] tools]$ cd util-linux-2.12/
[[email protected] util-linux-2.12]$ cp configure configure.backup
[[email protected] util-linux-2.12]$ sed "[email protected]/usr/[email protected]/tools/[email protected]" configure.backup > configure
[[email protected] util-linux-2.12]$ ./configure
[[email protected] util-linux-2.12]$ make -C lib
[[email protected] util-linux-2.12]$ make -C mount mount umount
[[email protected] util-linux-2.12]$ make -C text-utils more
[[email protected] util-linux-2.12]$ cp mount/{,u}mount text-utils/more /tools/bin
[[email protected] util-linux-2.12]$ cd ..
[[email protected] tools]$ rm -rf util-linux-2.12/

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/util-linux-2.12.tar.bz2 .
tar jxvf util-linux-2.12.tar.bz2
rm util-linux-2.12.tar.bz2
cd util-linux-2.12/
cp configure configure.backup
sed "[email protected]/usr/[email protected]/tools/[email protected]" configure.backup > configure
./configure
make -C lib
make -C mount mount umount
make -C text-utils more
cp mount/{,u}mount text-utils/more /tools/bin
cd ..
rm -rf util-linux-2.12

#---- install script end ------------------------------------------------------


5.31 安装 Perl-5.8.0

预计所需编译时间: 0.8SBU
预计所需硬盘空间: 74MB

Perl软件包包换的perl是 Practical Extraction and Report Language的缩写。Perl 将 C, sed, awk 和 sh 的最佳特性集于一身,是一种强大的编程语言。

安装下列程序: a2p, c2ph, dprofpp, enc2xs, find2perl, h2ph, h2xs, libnetcfg, perl, perl5.8.0 (link to perl), perlbug, perlcc, perldoc, perlivp, piconv, pl2pm, pod2html, pod2latex, pod2man, pod2text, pod2usage, podchecker, podselect, psed (link to s2p), pstruct (link to c2ph), s2p, splain and xsubpp
安装下列库文件: (太多了,数不过来)

[[email protected] tools]$ cp $LFS/sources/perl-5.8.0.tar.bz2 .
[[email protected] tools]$ cp $LFS/sources/perl-5.8.0-libc-3.patch .
[[email protected] tools]$ tar jxvf perl-5.8.0.tar.bz2
[[email protected] tools]$ rm perl-5.8.0.tar.bz2
[[email protected] tools]$ cd perl-5.8.0
[[email protected] perl-5.8.0]$ patch -Np1 -i ../perl-5.8.0-libc-3.patch
[[email protected] perl-5.8.0]$ chmod u+w hints/linux.sh
[[email protected] perl-5.8.0]$ echo 'static_ext="IO re Fcntl"' >> hints/linux.sh
[[email protected] perl-5.8.0]$ ./configure.gnu --prefix=/tools
[[email protected] perl-5.8.0]$ make perl utilities
[[email protected] perl-5.8.0]$ cp perl pod/pod2man /tools/bin
[[email protected] perl-5.8.0]$ mkdir -p /tools/lib/perl5/5.8.0
[[email protected] perl-5.8.0]$ cp -R lib/* /tools/lib/perl5/5.8.0
[[email protected] perl-5.8.0]$ cd ..
[[email protected] tools]$ rm -rf perl-5.8.0
[[email protected] tools]$ rm perl-5.8.0-libc-3.patch

#---- install script begin ----------------------------------------------------
cd /tools
cp $LFS/sources/perl-5.8.0.tar.bz2 .
cp $LFS/sources/perl-5.8.0-libc-3.patch .
tar jxvf perl-5.8.0.tar.bz2
rm perl-5.8.0.tar.bz2
cd perl-5.8.0
patch -Np1 -i ../perl-5.8.0-libc-3.patch
chmod u+w hints/linux.sh
echo 'static_ext="IO re Fcntl"' >> hints/linux.sh
./configure.gnu --prefix=/tools
make perl utilities
cp perl pod/pod2man /tools/bin
mkdir -p /tools/lib/perl5/5.8.0
cp -R lib/* /tools/lib/perl5/5.8.0
cd ..
rm -rf perl-5.8.0
rm perl-5.8.0-libc-3.patch

#---- install script end ------------------------------------------------------


5.32 Stripping(去掉调试符号)

[[email protected] tools]$ strip --strip-unneeded /tools/{,s}bin/*
[[email protected] tools]$ strip --strip-debug /tools/lib/*
[[email protected] tools]$ rm -rf /tools/{,share/}{doc,info,man}

#---- install script begin ----------------------------------------------------
strip --strip-unneeded /tools/{,s}bin/*
strip --strip-debug /tools/lib/*
rm -rf /tools/{,share/}{doc,info,man}

#---- install script end ------------------------------------------------------

此时已经完成了 Chapter 5 所有的编译任务。

现在, LFS 分区上应该至少有850MB以上的空间,才能顺利的在 Chapter 6 里安装上Glibc。

[[email protected] tools]$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 1510060 1100180 333172 77% /
none 257292 0 257292 0% /dev/shm
/dev/hda4 1976524 384124 1491996 21% /mnt/lfs

##############################################
我打包备份了此时刻的 $LFS 下的内容:
lfs_version_5_windix_1.tar.bz2 (56,032,802 bytes)

##############################################



Chapter 6 安装基本系统软件

6.1 进入chroot环境

检查环境变量:
[[email protected] tools]$ echo $LFS
/mnt/lfs

[[email protected] tools]$ su
[[email protected] tools]# chroot $LFS /tools/bin/env -i
> HOME=/root TERM=$TERM PS1='u:w$ '
> PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
> /tools/bin/bash --login
I have no name!:/#

env 命令的 -i 参数将把chroot环境中的变量全部清除。这之后,只有 HOME, TERM, PS1 和 PATH 变量再次被设置。TERM=$TERM这一句会将chroot环境内的$TERM值设置成与chroot外的相同,这样可以使象vim和less等程序可以正常运行。如果你需要其它的变量,比如 CFLAGS 或 CXXFLAGS,就在这里把它们设好。
从现在开始,$LFS变量就不再需要了,因为现在shell已经把 $LFS 看成 / ,也就是chroot命令的第一个参数。
注意,bash提示中会包含"I have no name!",这个很正常,因为 /etc/passwd 文件还没创建呢。

您必须确保本章和以后章节中的所有命令都是在虚拟根环境下执行的。如果已经离开了这个环境(如重启动等原因),请记住一定要在继续工作以前重新进入chroot并且重新加载proc和devpts(马上就将讨论到)。

#---- install script begin ----------------------------------------------------
chroot $LFS /tools/bin/env -i
HOME=/root TERM=$TERM PS1='u:w$ '
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
/tools/bin/bash --login

#---- install script end ------------------------------------------------------


6.2 改变所有者

I have no name!:/# chown -R 0:0 /tools

#---- install script begin ----------------------------------------------------
chown -R 0:0 /tools

#---- install script end ------------------------------------------------------


6.3 创建目录

我们的目录树遵循FHS标准

I have no name!:/# mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc} I have no name!:/# mkdir -p /{root,sbin,tmp,usr/local,var,opt}
I have no name!:/# for dirname in /usr /usr/local
> do
> mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
> ln -s share/{man,doc,info} $dirname
> mkdir $dirname/share/{dict,doc,info,locale,man}
> mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}
> mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
> done
I have no name!:/# mkdir /var/{lock,log,mail,run,spool}
I have no name!:/# mkdir -p /var/{tmp,opt,cache,lib/misc,local}
I have no name!:/# mkdir /opt/{bin,doc,include,info}
I have no name!:/# mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}
I have no name!:/#

在缺省情况下创建的目录的访问权限为755,但有些目录的访问权限不能设置成这样。我们将做两个修改:一个是root的主目录,另一个是临时文件放置的目录。命令如下:

I have no name!:/# chmod 0750 /root
I have no name!:/# chmod 1777 /tmp /var/tmp

第一个命令确保不是所有的用户可以进入/root目录(其他用户主目录有同样的访问权限)。第二个修改是对$LFS目录下的所有tmp目录的访问权限设置为1777,以使所有用户可以写入数据到/tmp或/var/tmp目录,但是不能删除其他用户创建的文件,不能删除其他用户的目录是由sticky位,也就是1777的1来设定的)。

#---- install script begin ----------------------------------------------------
mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc}
mkdir -p /{root,sbin,tmp,usr/local,var,opt}
for dirname in /usr /usr/local
do
mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
ln -s share/{man,doc,info} $dirname
mkdir $dirname/share/{dict,doc,info,locale,man}
mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}
mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
done
mkdir /var/{lock,log,mail,run,spool}
mkdir -p /var/{tmp,opt,cache,lib/misc,local}
mkdir /opt/{bin,doc,include,info}
mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}

chmod 0750 /root
chmod 1777 /tmp /var/tmp

#---- install script end ------------------------------------------------------


6.4 加载 proc 和 devpts 文件系统

proc 文件系统表示 process information pseudo文件系统,内核用它来提供系统状态信息。
我们把 proc 文件系统加载到/proc目录下,命令如下:
I have no name!:/# mount proc /proc -t proc
warning: can't open /etc/fstab: No such file or directory

devpts 文件系统前面提到过,是目前最常见的 pseudo 终端(PTYs)实现方式。
devpts 文件系统加载在 /dev/pts ,命令如下:
I have no name!:/# mount devpts /dev/pts -t devpts

记住,如果出于种种原因,你中止了LFS系统的安装,后来又要继续安装时,要检查一些这两个文件系统是不是还加载在chroot环境中,如果没有的话,就会出问题,需要再次加载。

#---- install script begin ----------------------------------------------------
mount proc /proc -t proc
mount devpts /dev/pts -t devpts

#---- install script end ------------------------------------------------------


6.5 创建重要的符号链接

I have no name!:/# ln -s /tools/bin/{bash,cat,pwd,stty} /bin
I have no name!:/# ln -s /tools/bin/perl /usr/bin
I have no name!:/# ln -s /tools/lib/libgcc_s.so.1 /usr/lib
I have no name!:/# ln -s bash /bin/sh

#---- install script begin ----------------------------------------------------
ln -s /tools/bin/{bash,cat,pwd,stty} /bin
ln -s /tools/bin/perl /usr/bin
ln -s /tools/lib/libgcc_s.so.1 /usr/lib
ln -s bash /bin/sh

#---- install script end ------------------------------------------------------


6.6 创建 passwd 和 group 文件

创建 /etc/passwd 文件的命令如下:
I have no name!:/# cat > /etc/passwd << "EOF"
> root:x:0:0:root:/root:/bin/bash
> EOF

root用户的真正密码(这里的“x“只是一个占位符)后面会设置。

创建 /etc/group 文件的命令如下:
I have no name!:/# cat > /etc/group << "EOF"
> root:x:0:
> bin:x:1:
> sys:x:2:
> kmem:x:3:
> tty:x:4:
> tape:x:5:
> daemon:x:6:
> floppy:x:7:
> disk:x:8:
> lp:x:9:
> dialout:x:10:
> audio:x:11:
> EOF

重新登录

I have no name!:/# exec /tools/bin/bash --login +h
root:/#


#---- install script begin ----------------------------------------------------
cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
EOF

cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
EOF

exec /tools/bin/bash --login +h

#---- install script end ------------------------------------------------------


6.7 创建设备 (Makedev-1.7)

MAKEDEV 脚本创建静态的设备节点,通常位于/dev目录下。关于设备节点的详细信息可以在 Linux 内核源码中的Documentation/devices.txt文件里找到。
安装下列脚本: MAKEDEV

root:/# cd tools
root:/tools# cp /sources/MAKEDEV-1.7.bz2 .
root:/tools# bzcat MAKEDEV-1.7.bz2 >/dev/MAKEDEV
root:/tools# chmod 754 /dev/MAKEDEV
root:/tools# rm MAKEDEV-1.7.bz2
root:/tools# cd /dev
root:/dev# ./MAKEDEV -v generic-nopty

-v:它告诉MAKEDEV脚本以多语方式运行。
generic-nopty: 它告诉 MAKEDEV 创建常见的设备文件,除了ptyXX 和 ttyXX 文件以外。我们不需要这些文件,因为我们将通过 devpts 文件系统使用 Unix98 PTYs.
如果某个你要的设备如zzz少了,就试一下运行./MAKEDEV -v zzz. 另一个选择,你也可以用mknod程序来创建设备。请参考 mknod的man和info页,以得到更多的信息。

#---- install script begin ----------------------------------------------------
cd tools
cp /sources/MAKEDEV-1.7.bz2 .
bzcat MAKEDEV-1.7.bz2 >/dev/MAKEDEV
chmod 754 /dev/MAKEDEV
rm MAKEDEV-1.7.bz2
cd /dev
./MAKEDEV -v generic-nopty

#---- install script end ------------------------------------------------------


6.8 安装 Linux-2.4.22 headers

root:/dev# cd /tools
root:/tools# cp /sources/linux-2.4.22.tar.bz2 .
root:/tools# tar jxvf linux-2.4.22.tar.bz2
root:/tools# rm linux-2.4.22.tar.bz2
root:/tools# chown -R 0:0 linux-2.4.22
root:/tools# cd linux-2.4.22/
root:/tools/linux-2.4.22# make mrproper

root:/tools/linux-2.4.22# make include/linux/version.h
创建特定平台的符号链接 include/asm
root:/tools/linux-2.4.22# make symlinks
安装特定平台的头文件
root:/tools/linux-2.4.22# cp -HR include/asm /usr/include
root:/tools/linux-2.4.22# cp -R include/asm-generic /usr/include
安装跨平台的内核头文件
root:/tools/linux-2.4.22# cp -R include/linux /usr/include
创建一个空的autoconf.h文件, 以避免编译错误
root:/tools/linux-2.4.22# touch /usr/include/linux/autoconf.h
root:/tools/linux-2.4.22# cd ..
root:/tools# rm -rf linux-2.4.22

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/linux-2.4.22.tar.bz2 .
tar jxvf linux-2.4.22.tar.bz2
rm linux-2.4.22.tar.bz2
chown -R 0:0 linux-2.4.22
cd linux-2.4.22/
make mrproper
make include/linux/version.h
make symlinks
cp -HR include/asm /usr/include
cp -R include/asm-generic /usr/include
cp -R include/linux /usr/include
touch /usr/include/linux/autoconf.h
cd ..
rm -rf linux-2.4.22

#---- install script end ------------------------------------------------------


6.9 安装 Glibc-2.3.2

root:/tools# cd /tools
root:/tools# cp /sources/glibc-2.3.2.tar.bz2 .
root:/tools# tar jxvf glibc-2.3.2.tar.bz2
root:/tools# rm glibc-2.3.2.tar.bz2
root:/tools# cd glibc-2.3.2/
root:/tools/glibc-2.3.2# cp /sources/glibc-linuxthreads-2.3.2.tar.bz2 .
root:/tools/glibc-2.3.2# tar jxvf glibc-linuxthreads-2.3.2.tar.bz2
root:/tools/glibc-2.3.2# touch /etc/ld.so.conf
root:/tools/glibc-2.3.2# cp /sources/glibc-2.3.2-sscanf-1.patch .
root:/tools/glibc-2.3.2# patch -Np1 -i glibc-2.3.2-sscanf-1.patch
root:/tools/glibc-2.3.2# mkdir ../glibc-build
root:/tools/glibc-2.3.2# cd ../glibc-build/
root:/tools/glibc-build# ../glibc-2.3.2/configure --prefix=/usr
> --disable-profile --enable-add-ons
> --libexecdir=/usr/bin --with-headers=/usr/include

--libexecdir=/usr/bin: 将 pt_chown 程序安装到 /usr/bin 目录下。
--with-headers=/usr/include: 确保本次编译使用 /usr/include 里的内核头文件。如果你不指定这个参数,可能会用到/tools/include里的头文件,就不太完美了(尽管它们其实是一样的)。用这个参数还有个好处,如果你忘了在 /usr/include 目录下安装内核头文件,马上就能知道。

root:/tools/glibc-build# make
root:/tools/glibc-build# make check

real 31m56.844s
user 24m43.000s
sys 3m18.650s

root:/tools/glibc-build# make install
root:/tools/glibc-build# make localedata/install-locales

root:/tools/glibc-build# make -C ../glibc-2.3.2/linuxthreads/man
root:/tools/glibc-build# make -C ../glibc-2.3.2/linuxthreads/man install

建立 /etc/nsswitch.conf
root:/tools/glibc-build# cat > /etc/nsswitch.conf << "EOF"
> # Begin /etc/nsswitch.conf
>
> passwd: files
> group: files
> shadow: files
>
> publickey: files
>
> hosts: files dns
> networks: files
>
> protocols: db files
> services: db files
> ethers: db files
> rpc: db files
>
> netgroup: db files
>
> # End /etc/nsswitch.conf
> EOF

root:/tools/glibc-build# tzselect
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

root:/tools/glibc-build# cp --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

配置动态链接库加载程序
root:/tools/glibc-build# cat > /etc/ld.so.conf << "EOF"
> # Begin /etc/ld.so.conf
>
> /usr/local/lib
> /opt/lib
>
> # End /etc/ld.so.conf
> EOF

root:/tools/glibc-build# cd ..
root:/tools# rm -rf glibc-2.3.2
root:/tools# rm -rf glibc-build

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/glibc-2.3.2.tar.bz2 .
tar jxvf glibc-2.3.2.tar.bz2
rm glibc-2.3.2.tar.bz2
cd glibc-2.3.2
cp /sources/glibc-linuxthreads-2.3.2.tar.bz2 .
tar jxvf glibc-linuxthreads-2.3.2.tar.bz2
touch /etc/ld.so.conf
cp /sources/glibc-2.3.2-sscanf-1.patch .
patch -Np1 -i glibc-2.3.2-sscanf-1.patch
mkdir ../glibc-build
cd ../glibc-build/
../glibc-2.3.2/configure --prefix=/usr
--disable-profile --enable-add-ons
--libexecdir=/usr/bin --with-headers=/usr/include
make
make check

make install
make localedata/install-locales
make -C ../glibc-2.3.2/linuxthreads/man
make -C ../glibc-2.3.2/linuxthreads/man install
cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

publickey: files

hosts: files dns
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

netgroup: db files

# End /etc/nsswitch.conf
EOF
tzselect

cp --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/usr/local/lib
/opt/lib

# End /etc/ld.so.conf
EOF

cd ..
rm -rf glibc-2.3.2
rm -rf glibc-build

#---- install script end ------------------------------------------------------


6.10 再次调整工具链

root:/tools/binutils-build# make -C ld INSTALL=/tools/bin/install install

root:/tools/binutils-build# cd ..
root:/tools# rm -rf binutils-2.14
root:/tools# rm -rf binutils-build

修正GCC specs:
root:/tools# SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
> sed -e '[email protected] /tools/lib/[email protected] /lib/[email protected]'
> $SPECFILE > newspecfile &&
> mv -f newspecfile $SPECFILE
root:/tools# unset SPECFILE

合理性检查:
root:/tools# echo 'main(){}' > dummy.c
root:/tools# gcc dummy.c
root:/tools# readelf -l a.out | grep ': /lib'
[Requesting program interpreter: /lib/ld-linux.so.2]

root:/tools# rm dummy.c a.out

#---- install script begin ----------------------------------------------------
cd /tools/binutils-build
make -C ld INSTALL=/tools/bin/install install
cd ..
rm -rf binutils-2.14
rm -rf binutils-build
SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
sed -e '[email protected] /tools/lib/[email protected] /lib/[email protected]'
$SPECFILE > newspecfile &&
mv -f newspecfile $SPECFILE
unset SPECFILE
echo 'main(){}' > dummy.c
gcc dummy.c
readelf -l a.out | grep ': /lib'
rm dummy.c a.out

#---- install script end ------------------------------------------------------


6.11 安装Binutils-2.14

测试chroot环境中,PTYS是否工作正常
root:/tools# expect -c "spawn ls"
spawn ls

如果输出为:
The system has no more ptys. Ask your system administrator to create more.

则说明Chroot环境没有设置好PTY。

(由于死机原安装笔记未存盘,所以从本节开始,只给出安装脚本)

#---- install script begin ----------------------------------------------------
expect -c "spawn ls"

cd /tools
cp /sources/binutils-2.14.tar.bz2 .
tar jxvf binutils-2.14.tar.bz2
rm binutils-2.14.tar.bz2
cd binutils-2.14
mkdir ../binutils-build
cd ../binutils-build
../binutils-2.14/configure
--prefix=/usr --enable-shared
make tooldir=/usr
make check

make tooldir=/usr install
cp ../binutils-2.14/include/libiberty.h /usr/include
cd ..
rm -rf binutils-2.14

#---- install script end ------------------------------------------------------


6.12 安装 GCC-3.3.1

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/gcc-core-3.3.1.tar.bz2 .
cp /sources/gcc-g++-3.3.1.tar.bz2 .
cp /sources/gcc-testsuite-3.3.1.tar.bz2 .
cp /sources/gcc-3.3.1-no_fixincludes-2.patch .
cp /sources/gcc-3.3.1-suppress-libiberty.patch .
tar jxvf gcc-core-3.3.1.tar.bz2
rm gcc-core-3.3.1.tar.bz2
tar jxvf gcc-g++-3.3.1.tar.bz2
rm gcc-g++-3.3.1.tar.bz2
tar jxvf gcc-testsuite-3.3.1.tar.bz2
rm gcc-testsuite-3.3.1.tar.bz2
cd gcc-3.3.1
patch -Np1 -i ../gcc-3.3.1-no_fixincludes-2.patch
patch -Np1 -i ../gcc-3.3.1-suppress-libiberty.patch
mkdir ../gcc-build
cd ../gcc-build
../gcc-3.3.1/configure --prefix=/usr
--enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
--enable-languages=c,c++
make
make -k check

make install
ln -s ../usr/bin/cpp /lib
ln -s gcc /usr/bin/cc
cd ..
rm -rf gcc-3.3.1
rm -rf gcc-build
rm gcc-3.3.1-no_fixincludes-2.patch gcc-3.3.1-suppress-libiberty.patch

#---- install script end ------------------------------------------------------


6.13 安装 Coreutils-5.0

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/coreutils-5.0.tar.bz2 .
cp /sources/coreutils-5.0-hostname-2.patch .
cp /sources/coreutils-5.0-uname.patch .
tar jxvf coreutils-5.0.tar.bz2
rm coreutils-5.0.tar.bz2
cd coreutils-5.0/
patch -Np1 -i ../coreutils-5.0-uname.patch
patch -Np1 -i ../coreutils-5.0-hostname-2.patch
./configure --prefix=/usr
make
make install-root
echo "dummy1:x:1000" >> /etc/group
echo "dummy2:x:1001:dummy" >> /etc/group
echo "dummy:x:1000:1000:::/bin/bash" >> /etc/passwd
make check-root
su dummy -c "make RUN_EXPENSIVE_TESTS=yes check"
sed -i.bak '/dummy/d' /etc/passwd /etc/group
make install
mv /usr/bin/{basename,cat,chgrp,chmod,chown,cp,dd,df} /bin
mv /usr/bin/{dir,dircolors,du,date,echo,false,head} /bin
mv /usr/bin/{install,ln,ls,mkdir,mkfifo,mknod,mv,pwd} /bin
mv /usr/bin/{rm,rmdir,shred,sync,sleep,stty,su,test} /bin
mv /usr/bin/{touch,true,uname,vdir} /bin
mv /usr/bin/chroot /usr/sbin
ln -s test /bin/[
ln -s ../../bin/install /usr/bin
cd ..
rm coreutils-5.0-hostname-2.patch coreutils-5.0-uname.patch
rm -rf coreutils-5.0

#---- install script end ------------------------------------------------------


6.14 安装 Zlib-1.1.4

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/zlib-1.1.4.tar.bz2 .
cp /sources/zlib-1.1.4-vsnprintf.patch .
tar jxvf zlib-1.1.4.tar.bz2
rm zlib-1.1.4.tar.bz2
cd zlib-1.1.4
patch -Np1 -i ../zlib-1.1.4-vsnprintf.patch
./configure --prefix=/usr --shared
make
make install
make clean
./configure --prefix=/usr
make
make test
make install
mv /usr/lib/libz.so.* /lib
ln -sf ../../lib/libz.so.1 /usr/lib/libz.so
cp zlib.3 /usr/share/man/man3
cd ..
rm -rf zlib-1.1.4
rm zlib-1.1.4-vsnprintf.patch

#---- install script end ------------------------------------------------------


6.15 安装 Lfs-Utils-0.3

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/lfs-utils-0.3.tar.bz2 .
tar jxvf lfs-utils-0.3.tar.bz2
rm lfs-utils-0.3.tar.bz2
cd lfs-utils-0.3
make
make install
cp etc/{services,protocols} /etc
cd ..
rm -rf lfs-utils-0.3

#---- install script end ------------------------------------------------------


6.16 安装 Findutils-4.1.20

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/findutils-4.1.20.tar.bz2 .
tar jxvf findutils-4.1.20.tar.bz2
rm findutils-4.1.20.tar.bz2
cd findutils-4.1.20/
./configure --prefix=/usr --libexecdir=/usr/bin
make
make check
make install
cd ..
rm -rf findutils-4.1.20

#---- install script end ------------------------------------------------------


6.17 安装 Gawk-3.1.3

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/gawk-3.1.3.tar.bz2 .
cp /sources/gawk-3.1.3-libexecdir.patch .
tar jxvf gawk-3.1.3.tar.bz2
rm gawk-3.1.3.tar.bz2
cd gawk-3.1.3
patch -Np1 -i ../gawk-3.1.3-libexecdir.patch
./configure --prefix=/usr --libexecdir=/usr/bin
make
make check

make install
cd ..
rm -rf gawk-3.1.3
rm gawk-3.1.3-libexecdir.patch

#---- install script end ------------------------------------------------------


6.18 安装 Ncurses-5.3

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/ncurses-5.3.tar.bz2 .
cp /sources/ncurses-5.3-etip-2.patch .
cp /sources/ncurses-5.3-vsscanf.patch .
tar jxvf ncurses-5.3.tar.bz2
rm ncurses-5.3.tar.bz2
cd ncurses-5.3
patch -Np1 -i ../ncurses-5.3-etip-2.patch
patch -Np1 -i ../ncurses-5.3-vsscanf.patch
./configure --prefix=/usr
--with-shared --without-debug
make
make install
chmod 755 /usr/lib/*.5.3
chmod 644 /usr/lib/libncurses++.a
mv /usr/lib/libncurses.so.5* /lib
ln -sf ../../lib/libncurses.so.5 /usr/lib/libncurses.so
ln -sf libncurses.so /usr/lib/libcurses.so
cd ..
rm -rf ncurses-5.3
rm ncurses-5.3-etip-2.patch ncurses-5.3-vsscanf.patch

#---- install script end ------------------------------------------------------


6.19 安装 Vim-6.2

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/vim-6.2.tar.bz2 .
tar jxvf vim-6.2.tar.bz2
rm vim-6.2.tar.bz2
cd vim62
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
echo '#define SYS_GVIMRC_FILE "/etc/gvimrc"' >> src/feature.h
./configure --prefix=/usr
make
make install
ln -s vim /usr/bin/vi
cat > /root/.vimrc << "EOF"
" Begin /root/.vimrc

set nocompatible
set bs=2

" End /root/.vimrc
EOF
cd ..
rm -rf vim62

#---- install script end ------------------------------------------------------


6.20 安装 M4-1.4

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/m4-1.4.tar.bz2 .
tar jxvf m4-1.4.tar.bz2
rm m4-1.4.tar.bz2
cd m4-1.4
./configure --prefix=/usr
make
make check

make install
cd ..
rm -rf m4-1.4

#---- install script end ------------------------------------------------------


6.21 安装 Bison-1.875

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/bison-1.875.tar.bz2 .
cp /sources/bison-1.875-attribute.patch .
tar jxvf bison-1.875.tar.bz2
rm bison-1.875.tar.bz2
cd bison-1.875
patch -Np1 -i ../bison-1.875-attribute.patch
./configure --prefix=/usr
make
make check
make install
cd ..
rm -rf bison-1.875
rm bison-1.875-attribute.patch

#---- install script end ------------------------------------------------------


6.22 安装 Less-381

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/less-381.tar.bz2 .
tar jxvf less-381.tar.bz2
rm less-381.tar.bz2
cd less-381
./configure --prefix=/usr --bindir=/bin --sysconfdir=/etc
make
make install
cd ..
rm -rf less-381

#---- install script end ------------------------------------------------------


6.23 安装 Groff-1.19

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/groff-1.19.tar.bz2 .
tar jxvf groff-1.19.tar.bz2
rm groff-1.19.tar.bz2
cd groff-1.19
PAGE=A4 ./configure --prefix=/usr
make
make install
ln -s soelim /usr/bin/zsoelim
ln -s eqn /usr/bin/geqn
ln -s tbl /usr/bin/gtbl
cd ..
rm -rf groff-1.19

#---- install script end ------------------------------------------------------


6.24 安装 Sed-4.0.7

#---- install script begin ----------------------------------------------------
cp /sources/sed-4.0.7.tar.bz2 .
tar jxvf sed-4.0.7.tar.bz2
rm sed-4.0.7.tar.bz2
cd sed-4.0.7/
./configure --prefix=/usr --bindir=/bin
make
make check
make install
cd ..
rm -rf sed-4.0.7

#---- install script end ------------------------------------------------------


6.25 安装 Flex-2.5.4a

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/flex-2.5.4a.tar.bz2 .
tar jxvf flex-2.5.4a.tar.bz2
rm flex-2.5.4a.tar.bz2
cd flex-2.5.4
./configure --prefix=/usr
make
make bigcheck
make install
ln -s libfl.a /usr/lib/libl.a
cat > /usr/bin/lex << "EOF"
#!/bin/sh
# Begin /usr/bin/lex

exec /usr/bin/flex -l "[email protected]"

# End /usr/bin/lex
EOF
chmod 755 /usr/bin/lex
cd ..
rm -rf flex-2.5.4

#---- install script end ------------------------------------------------------


6.26 安装 Gettext-0.12.1

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/gettext-0.12.1.tar.bz2 .
tar jxvf gettext-0.12.1.tar.bz2
rm gettext-0.12.1.tar.bz2
cd gettext-0.12.1/
./configure --prefix=/usr
make
make check
make install
cd ..
rm -rf gettext-0.12.1

#---- install script end ------------------------------------------------------


6.27 安装 Net-tools-1.60

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/net-tools-1.60.tar.bz2 .
cp /sources/net-tools-1.60-miitool-gcc33-1.patch .
tar jxvf net-tools-1.60.tar.bz2
rm net-tools-1.60.tar.bz2
cd net-tools-1.60
patch -Np1 -i ../net-tools-1.60-miitool-gcc33-1.patch
make config

make
make update
cd ..
rm -rf net-tools-1.60
rm net-tools-1.60-miitool-gcc33-1.patch

#---- install script end ------------------------------------------------------


6.28 安装 Inetutils-1.4.2

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/inetutils-1.4.2.tar.bz2 .
tar jxvf inetutils-1.4.2.tar.bz2
rm inetutils-1.4.2.tar.bz2
cd inetutils-1.4.2
./configure --prefix=/usr --disable-syslogd
--libexecdir=/usr/sbin --disable-logger
--sysconfdir=/etc --localstatedir=/var
--disable-whois --disable-servers
make
make install
mv /usr/bin/ping /bin
cd ..
rm -rf inetutils-1.4.2

#---- install script end ------------------------------------------------------


6.29 安装 Perl-5.8.0

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/perl-5.8.0.tar.bz2 .
tar jxvf perl-5.8.0.tar.bz2
rm perl-5.8.0.tar.bz2
cd perl-5.8.0
./configure.gnu --prefix=/usr
make
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
make test
make install
cd ..
rm -rf perl-5.8.0

#---- install script end ------------------------------------------------------


6.30 安装 Textinfo-4.6

#---- install script begin ----------------------------------------------------
cd /tools
cp /sources/texinfo-4.6.tar.bz2 .
tar jxvf texinfo-4.6.tar.bz2
rm texinfo-4.6.tar.bz2
cd texinfo-4.6