此博客PDF格式文档下载地址 http://down.51cto.com/data/596015 概述 LFS ( Linux From Scratch http://www.linuxfromscratch.org ) 此篇博客是一个 LFS 的制作手册 , 内容涵盖使用宿主系统或 liveCD 来制作 LFS 的详
此博客PDF格式文档下载地址 http://down.51cto.com/data/596015
概述
LFS ( Linux From Scratch http://www.linuxfromscratch.org )此篇博客是一个LFS的制作手册, 内容涵盖使用宿主系统或liveCD来制作LFS的详细过程.从开始到结束手把手教你制作属于你自己的linux系统.也能帮助你更清楚的知道linux系统是如何组成的, 这里就简单的说下LFS ,什么linux开机流程,linux系统原理等等网上都有说明,这里就不说了,至于linux系统的组成,将文档从头做到尾你就知道linux系统是怎么组成的啦,嘿嘿!
这是一个比较漫长的旅途,需要做的是细心,耐心,再细心, 这里提醒下使用VMware虚拟机制作的朋友,快照才是王道,在此旅途中确定在此之前的操作是无误并制作正确的, 可以做下快照备份下当前虚拟机状态,以免后面不小心的操作而导致不可恢复性的错误,所以请务必阶段性的做快照。当然如果使用物理机制作的朋友就是细心,小心啦........
制作的过程需要编译大量的源码,而编译源代码需要占用大量的CPU时钟周期,建议大家使用配置相对比较好的计算机,如果有PC Server的话建议在PC Server上面制作.我的环境是在一台8核CPU,4G内存的PC Server上装了一个虚拟机,(虚拟机分配的资源是8核CPU,2G内存),在这样的配置下我编译一个GCC跟glibc花了1个小时,所以建议大家有好的资源不要浪费啊.嘿嘿
好了,闲话不多说, Are you ready
准备工作
如果使用liveCD作为宿主系统的朋友需要去LFS官方下载liveCD镜像包,里面包含制作过程中所需的软件包,等,当然如果使用原有的操作系统来作为宿主系统的朋友也需要去LFS官方下载liveCD镜像,为什么呢?因为liveCD里面包含有制作过程中所需要的软件包,这样我们就不用一个一个去互联网上下载了,呵呵,
这里介绍下我的环境,在一台8核CPU 4G内存的PCserver上装了一个VMware虚拟机工具,然后在虚拟机上装了个rhel5.4 32位系统(8核CPU/2G内存),我是通过现有的系统来制作的,那有些朋友说了,使用liveCD跟现有的宿主系统制作的步骤都是一眼的吗? 没错,步骤是一样的, 无论使用liveCD或者现有的宿主系统在制作过程上没有什么差别,
liveCD的下载地址
http://ftp.osuosl.org/pub/lfs-livecd/lfslivecd-x86_64-6.3-r2145.iso
1,添加硬盘
关闭虚拟机添加一块10G大小的IDE接口的虚拟硬盘,并将虚拟硬盘存为一个文件,步骤见下图.
创建一块新硬盘
选择虚拟硬盘的类型为IDE
设置虚拟硬盘的大小并设置将虚拟硬盘存储为1个文件
选择虚拟硬盘的存储位置,根据自己需要定义
磁盘添加完成后启动计算机待开机完成后安装基本开发库及GCC编译器
#使用liveCD制作的不需要执行此蓝色字体的命令
#yum –y groupinstall "Development Libraries" "Development Tools"
#yum –y install gcc*
#然后将下载好的liveCD的镜像文件放入虚拟光驱中,并挂载使用
#mount /dev/cdrom /media
#cp –avf /media/lfs-sources /
2,分区并格式化
fdisk /dev/hda n p 1 +300 n p 2 +7G w mkfs.ext3 /dev/hda1 #/boot分区 mkfs.ext3 /dev/hda2 #/分区
3,建立制作车间
mkdir /mnt/lfs mount /dev/hda2 /mnt/lfs mkdir -pv /mnt/lfs/{sources,tools} chmod -v a+wt /mnt/lfs/sources ln -s /mnt/lfs/tools /
4,制作的用户
groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs passwd lfs chown lfs /mnt/lfs/* su - lfs cat > ~/.bash_profile <<EOF内容如下 exec env -i HOME=${HOME} TERM=${TERM} PS1='\u:\w\$' /bin/bash EOF cat > ~/.bashrc <<EOF set +h umask 022 LC_ALL=POSIX PATH=/tools/bin:/bin:/usr/bin export PATH LC_ALL EOF source ~/.bash_profile
5,安装汇编连接器(binutils)
cd /mnt/lfs/sources tar xvf /lfs-sources/binutils-2.17.tar.bz2 mkdir /mnt/lfs/sources/binutils-build cd /mnt/lfs/sources/binutils-build CC="gcc -B/usr/bin/" ../binutils-2.17/configure --prefix=/tools \--disable-nls --disable-werror make make install make -C ld clean make -C ld LIB_PATH=/tools/lib cp ld/ld-new /tools/bin/ cd .. rm -rf /mnt/lfs/sources/binutils-build rm -rf /mnt/lfs/sources/binutils-2.17
6,安装编译器(GCC)
cd /mnt/lfs/sources tar -xvf /lfs-sources/gcc-4.1.2.tar.bz2 mkdir /mnt/lfs/sources/gcc-build cd /mnt/lfs/sources/gcc-build CC="gcc -B/usr/bin/" ../gcc-4.1.2/configure --prefix=/tools \ --with-local-prefix=/tools --disable-nls \ --enable-shared --enable-languages=c make bootstrap make install ln -vs gcc /tools/bin/cc cd .. rm -rf /mnt/lfs/sources/gcc-build rm -rf /mnt/lfs/sources/gcc-4.1.2
7,安装内核头文件
cd /mnt/lfs/sources tar xvf /lfs-sources/linux-2.6.22.5.tar.bz2 cd linux-2.6.22.5 make mrproper make headers_check make INSTALL_HDR_PATH=dest headers_install cp -rv dest/include/* /tools/include cd .. rm -rf linux-2.6.22.5
8,安装基本C库(glibc)
cd /mnt/lfs/sources tar xvf /lfs-sources/glibc-2.5.1.tar.bz2 mkdir /mnt/lfs/sources/glibc-build cd /mnt/lfs/sources/glibc-build ./glibc-2.5.1/configure --prefix=/tools \ --disable-profile --enable-add-ons \ --enable-kernel=2.6.0 --with-binutils=/tools/bin \ --without-gd --with-headers=/tools/include \ --without-selinux make mkdir /tools/etc touch /tools/etc/ld.so.conf make install cd .. rm -rf /mnt/lfs/sources/glibc-2.5.1 rm -rf /mnt/lfs/sources/glibc-build
9,调整工具链
mv -v /tools/bin/{ld,ld-old} mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} mv -v /tools/bin/{ld-new,ld} ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld gcc -dumpspecs | sed 's@^/lib/ld-linux.so.2@/tools&@g' > `dirname $(gcc -print-libgcc-file-name)`/specs GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include && find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; && rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` && unset GCC_INCLUDEDIR
10,测试工具链
echo 'main() {}' > dummy.c cc dummy.c readelf -l a.out | grep 'tools' 如果有Requesting program interpreter: /tools/lib/ld-linux.so.2则说明成功 rm -rf aa.out dummy.c
11,安装测试工具(tcl expect dejagnu)
cd /mnt/lfs/sources tar xvf /lfs-sources/tcl8.4.15-src.tar.gz cd tcl8.4.15/unix /configure --prefix=/tools make make install make install-private-headers ln -sv tclsh8.4 /tools/bin/tchsh cd /mnt/lfs/sources tar xvf /lfs-sources/expect-5.43.0.tar.gz cd expect-5.43 patch -Np1 -i /lfs-sources/expect-5.43.0-spawn-1.patch cp configure{,.bak} sed 's:/usr/local/bin:/bin:' configure.bak > configure /configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=/tools/include \--with-x=no make make SCRIPTS="" install cd /mnt/lfs/sources tar xvf /lfs-sources/dejagnu-1.4.4.tar.gz cd dejagnu-1.4.4 /configure --prefix=/tools make install cd .. rm -rf /mnt/lfs/sources/tcl8.4.15 rm -rf /mnt/lfs/sources/expect-5.43 rm -rf /mnt/lfs/sources/dejagnu-1.4.4
12,安装汇编工具(binutils)
cd /mnt/lfs/sources tar xvf /lfs-sources/binutils-2.17.tar.bz2 mkdir /mnt/lfs/sources/binutils-build cd /mnt/lfs/sources/binutils-build ./binutils-2.17/configure --prefix=/tools --disable-nls \ --with-lib-path=/tools/lib make make install make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib cp ld/ld-new /tools/bin cd .. rm -rf /mnt/lfs/sources/binutils-build rm -rf /mnt/lfs/sources/binutils-2.17
13,安装GCC
cd /mnt/lfs/sources/ tar xvf /lfs-sources/gcc-4.1.2.tar.bz2 cd gcc-4.1.2 cp gcc/Makefile.in{,.orig} sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in cp -v gcc/Makefile.in{,.tmp} sed 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp > gcc/Makefile.in patch -Np1 -i /lfs-sources/gcc-4.1.2-specs-1.patch mkdir /mnt/lfs/sources/gcc-build cd /mnt/lfs/sources/gcc-build ./gcc-4.1.2/configure --prefix=/tools \ --with-local-prefix=/tools \ --enable-clocale=gnu --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-languages=c,c++ --disable-libstdcxx-pch make make install cd .. rm -rf /mnt/lfs/sources/gcc-build rm -rf /mnt/lfs/sources/gcc-4.1.2
14,测试工具链
echo 'main() {}' > dummy.c cc dummy.c readelf -l a.out | grep 'tools' 如果有Requesting program interpreter: /tools/lib/ld-linux.so.2则说明成功 rm -rf a.out dummy.c
15,安装文本交互函数库(ncurses)
cd /mnt/lfs/sources tar xvf /lfs-sources/ncurses-5.6.tar.gz cd ncurses-5.6 /configure --prefix=/tools --with-shared --without-debug --without-ada --enable-overwrite make make install cd .. rm -rf /mnt/lfs/sources/ncurses-5.6
16,安装命令解释器(bash)
cd /mnt/lfs/sources tar xvf /lfs-sources/bash-3.2.tar.gz cd bash-3.2 patch -Np1 -i /lfs-sources/bash-3.2-fixes-5.patch /configure --prefix=/tools --without-bash-malloc make make install ln -sv bash /tools/bin/sh cd .. rm -rf bash-3.2
17,安装压缩工具(bzip2)
cd /mnt/lfs/sources/ tar xvf /lfs-sources/bzip2-1.0.4.tar.gz cd bzip2-1.0.4 make make PREFIX=/tools install cd .. rm -rf bzip2-1.0.4
18,安装常用命令集(Coreutils)
cd /mnt/lfs/sources tar xvf /lfs-sources/coreutils-6.9.tar.bz2 cd coreutils-6.9 /configure --prefix=/tools make make install cp src/su /tools/bin/su-tools cd .. rm -rf coreutils-6.9
19,安装文件比较工具(diffutils)
cd /mnt/lfs/sources tar xvf /lfs-sources/diffutils-2.8.1.tar.gz cd diffutils-2.8.1 /configure --prefix=/tools make make install cd .. rm -rf diffutils-2.8.1
cd /mnt/lfs/sources tar xvf /lfs-sources/findutils-4.2.31.tar.gz cd findutils-4.2.31 /configure --prefix=/tools make make install cd .. rm -rf findutils-4.2.31
20,安装查找工具(findutils)
cd /mnt/lfs/sources tar xvf /lfs-sources/findutils-4.2.31.tar.gz cd findutils-4.2.31 /configure --prefix=/tools make make install cd .. rm -rf findutils-4.2.31
21,安装文本处理工具(gawk)
cd /mnt/lfs/sources tar xvf /lfs-sources/gawk-3.1.5.tar.bz2 cd gawk-3.1.5 /configure --prefix=/tools make make install cd .. rm -rf gawk-3.1.5
22,安装国际语言支持工具(gettext)
cd /mnt/lfs/sources tar xvf /lfs-sources/gettext-0.16.1.tar.gz cd gettext-0.16.1/gettext-tools /configure --prefix=/tools --disable-shared make -C gnulib-lib make -C src msgfmt cp src/msgfmt /tools/bin cd ../../ rm -rf gettext-0.16.1
23,安装文件过滤工具(grep)
cd /mnt/lfs/sources tar xvf /lfs-sources/grep-2.5.1a.tar.bz2 cd grep-2.5.1a /configure --prefix=/tools --disable-perl-regexp make make install cd .. rm -rf grep-2.5.1a
24,安装压缩工具(gzip)
cd /mnt/lfs/sources tar xvf /lfs-sources/gzip-1.3.12.tar.gz cd gzip-1.3.12 /configure --prefix=/tools make make install cd .. rm -rf gzip-1.3.12
25,安装宏处理工具(M4)
cd /mnt/lfs/sources tar xvf /lfs-sources/m4-1.4.10.tar.bz2 cd m4-1.4.10 /configure --prefix=/tools make make install cd .. rm -rf m4-1.4.10
26,安装语法分析工具(bison)
cd /mnt/lfs/sources tar xvf /lfs-sources/bison-2.3.tar.bz2 cd bison-2.3 /configure --prefix=/tools make make install cd .. rm -rf bison-2.3
27,安装编译过程控制工具(make)
cd /mnt/lfs/sources tar xvf /lfs-sources/make-3.81.tar.bz2 cd make-3.81 /configure --prefix=/tools make make install cd .. rm -rf make-3.81
28,安装补丁工具(patch)
cd /mnt/lfs/sources tar xvf /lfs-sources/patch-2.5.4.tar.gz cd patch-2.5.4 /configure --prefix=/tools make make install cd .. rm -rf patch-2.5.4
29,安装脚本语言(perl)
cd /mnt/lfs/sources tar xvf /lfs-sources/perl-5.8.8.tar.bz2 cd perl-5.8.8 patch -Np1 -i /lfs-sources/perl-5.8.8-libc-2.patch /configure.gnu --prefix=/tools -Destatic_ext='Data/Dumper Fcntl IO POSIX' make perl utilities cp perl pod/pod2man /tools/bin mkdir -pv /tools/lib/perl5/5.8.8 cp -Rv lib/* /tools/lib/perl5/5.8.8 cd .. rm -rf perl-5.8.8
30,文件处理工具(sed)
cd /mnt/lfs/sources tar xvf /lfs-sources/sed-4.1.5.tar.gz cd sed-4.1.5 /configure --prefix=/tools make make install cd .. rm -rf sed-4.1.5
31,安装打包工具(tar)
cd /mnt/sources tar xvf /lfs-sources/tar-1.18.tar.bz2 cd tar-1.18 /configure --prefix=/tools make make install cd .. rm -rf tar-1.18
32,安装信息阅读工具(Texinfo)
cd /mnt/lfs/sources tar xvf /lfs-sources/texinfo-4.9.tar.bz2 /configure --prefix=/tools make make install cd .. rm -rf texinfo-4.9
33,安装工具集(util-linux)
cd /mnt/lfs/sources tar xvf /lfs-sources/util-linux-2.12r.tar.bz2 cd util-linux-2.12r sed -i 's@/usr/include@/tools/include@g' 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.12r
34,退出lfs用户
exit
目标系统
35,设置环境变量等
chown -R root:root /mnt/lfs/tools mkdir -pv /mnt/lfs/{dev,proc,sys} mknod -m 600 /mnt/lfs/dev/console c 5 1 mknod -m 666 /mnt/lfs/dev/null c 1 3 mount --bind /dev /mnt/lfs/dev mount -t devpts devpts /mnt/lfs/dev/pts mount -t tmpfs shm /mnt/lfs/dev/shm mount -t proc proc /mnt/lfs/proc mount -t sysfs sysfs /mnt/lfs/sys cp -a /lfs-sources/* /mnt/lfs/sources/ chroot "/mnt/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 +h
36,建立目标系统的目录结构
mkdir -pv /{bin,boot,etc/opt,home,lib,mnt,opt} mkdir -pv /{media/{floppy,cdrom},sbin,srv,var} install -dv -m 0750 /root install -dv -m 1777 /tmp /var/tmp mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} mkdir -pv /usr/{,local/}share/{doc,info,locale,man} mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo} mkdir -pv /usr/{,local/}share/man/man{1..8} for dir in /usr /usr/local; do ln -sv share/{man,doc,info} $dir done mkdir -pv /var/{lock,log,mail,run,spool} mkdir -pv /var/{opt,cache,lib/{misc,locate},local} ln -sv /tools/bin/{bash,cat,echo,grep,pwd,stty} /bin ln -sv /tools/bin/perl /usr/bin ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib ln -sv bash /bin/sh touch /etc/mtab mount /dev/hda1 /boot
37,创建目标系统的用户及组
cat > /etc/passwd << EOF root:x:0:0:root:/root:/bin/bash nobody:x:99:99:Unprivileged User:/dev/null:/bin/false 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: video:x:12: utmp:x:13: usb:x:14: cdrom:x:15: mail:x:34: nogroup:x:99: EOF 重新加载bash exec /tools/bin/bash --login +h
38,建立临时文件和日志文件
touch /var/run/utmp /var/log/{btmp,lastlog,wtmp} chgrp -v utmp /var/run/utmp /var/log/lastlog chmod -v 664 /var/run/utmp /var/log/lastlog
目标系统工具链制作
39,安装linux内核头文件(linux-header)
cd /sources tar xvf linux-2.6.22.5.tar.bz2 cd linux-2.6.22.5 make mrproper make headers_check make INSTALL_HDR_PATH=dest headers_install cp -rv dest/include/* /usr/include cd .. rm -rf linux-2.6.22.5
40,安装基本C库(glibc)
cd /sources tar xvf glibc-2.5.1.tar.bz2 cd glibc-2.5.1 tar xvf /sources/glibc-libidn-2.5.1.tar.gz mv glibc-libidn-2.5.1 libidn sed -i '/vi_VN.TCVN/d' localedata/SUPPORTED sed -i \ 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.2 -o|' \ scripts/test-installation.pl sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in mkdir ../glibc-build cd ../glibc-build ./glibc-2.5.1/configure --prefix=/usr \ --disable-profile --enable-add-ons \ --enable-kernel=2.6.0 --libexecdir=/usr/lib/glibc make make -k check 2>&1 | tee glibc-check-log grep Error glibc-check-log touch /etc/ld.so.conf make install make localedata/install-locales cat > /etc/nsswitch.conf <<EOF passwd: files group: files shadow: files hosts: files dns networks: files protocols: files services: files ethers: files rpc: files EOF cp -v --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime cat > /etc/ld.so.conf <<EOF /usr/local/lib /opt/lib EOF rm -rf /sources/glibc-build rm -rf /sources/glibc-2.5.1
41,调整工具链
mv -v /tools/bin/{ld,ld-old} mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} mv -v /tools/bin/{ld-new,ld} ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld gcc -dumpspecs | sed \ -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \ -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ `dirname $(gcc --print-libgcc-file-name)`/specs
42,正确性检查
echo 'main(){}' > dummy.c cc dummy.c -v -Wl,--verbose &> dummy.log readelf -l a.out | grep '/lib' 如果显示[Requesting program interpreter: /lib/ld-linux.so.2]表示调整成功,动态库已经连接到了目标系统的/lib下 grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log 打印信息如下 /usr/lib/crt1.o succeeded /usr/lib/crti.o succeeded /usr/lib/crtn.o succeeded grep -B1 '^ /usr/include' dummy.log 打印信息如下 #include <...> search starts here: /usr/include grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' 打印信息如下 SEARCH_DIR("/tools/i686-pc-linux-gnu/lib") SEARCH_DIR("/usr/lib") SEARCH_DIR("/lib"); grep "/lib/libc.so.6 " dummy.log 打印信息如下 attempt to open /lib/libc.so.6 succeeded grep found dummy.log 打印信息如下 found ld-linux.so.2 at /lib/ld-linux.so.2 上面的信息均显示正常,则OK! rm -v dummy.c a.out dummy.log
43,安装汇编器(binutils)
cd /sources tar xvf binutils-2.17.tar.bz2 mkdir binutils-build cd binutils-build ./binutils-2.17/configure --prefix=/usr --enable-shared make tooldir=/usr make check make tooldir=/usr install cp -v ../binutils-2.17/include/libiberty.h /usr/include cd .. rm -rf binutils-build rm -rf binutils-2.17
44,安装GCC
cd /sources tar xvf gcc-4.1.2.tar.bz2 cd gcc-4.1.2 sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in sed -i 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in mkdir -v ../gcc-build cd ../gcc-build ./gcc-4.1.2/configure --prefix=/usr \ --libexecdir=/usr/lib --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-clocale=gnu --enable-languages=c,c++ make make -k check make install ln -sv ../usr/bin/cpp /lib ln -sv gcc /usr/bin/cc cd .. rm -rf gcc-build rm -rf gcc-4.1.2
45,检测gcc是否安装正确
echo 'main(){}' >dummy.c cc dummy.c -v -Wl,--verbose &> dummy.log readelf -l a.out | grep 'lib' 打印信息为以下内容则表示链接位置正确, Requesting program interpreter: /lib/ld-linux.so.2] grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log 打印信息为以下 /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crt1.o succeeded /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crti.o succeeded /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../crtn.o succeeded grep -B3 '^ /usr/include' dummy.log 打印信息为 #include <...> search starts here: /usr/local/include /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include /usr/include grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' 打印信息为 SEARCH_DIR("/usr/i686-pc-linux-gnu/lib") SEARCH_DIR("/usr/local/lib") SEARCH_DIR("/lib") SEARCH_DIR("/usr/lib"); grep "/lib/libc.so.6 " dummy.log 打印信息为 attempt to open /lib/libc.so.6 succeeded grep found dummy.log 打印信息为 found ld-linux.so.2 at /lib/ld-linux.so.2 上面信息显示正常则表示工具链ok rm -rf dummy.c a.out dummy.log
46,安装高性能数据库(berkeley DB)
cd /sources tar xvf db-4.5.20.tar.gz cd db-4.5.20 patch -Np1 -i /sources/db-4.5.20-fixes-1.patch cd build_unix ./dist/configure --prefix=/usr --enable-compat185 --enable-cxx make make docdir=/usr/share/doc/db-4.5.20 install chown -R root:root /usr/share/doc/db-4.5.20 cd /sources rm -rf db-4.5.20
47,阶段性检查,
type -p gcc cc g++ c++ ld ar ranlib 打印信息如下表示正常 /usr/bin/gcc /usr/bin/cc /usr/bin/g++ /usr/bin/c++ /usr/bin/ld /usr/bin/ar /usr/bin/ranlib find /{,usr/}{bin,sbin,lib}/* -type f -exec ldd '{}' ';' 2>/dev/null | grep tools 没有任何打印信息表示正常
48,安装文本处理工具(sed)
cd /sources tar xvf sed-4.1.5.tar.gz cd sed-4.1.5 /configure --prefix=/usr --bindir=/bin make make install cd .. rm -rf sed-4.1.5
49,安装ext文件系统管理工具(e2fsprogs)
cd /sources tar xvf e2fsprogs-1.40.2.tar.gz cd e2fsprogs-1.40.2 sed -i -e 's@/bin/rm@/tools&@' lib/blkid/test_probe.in mkdir build cd build ./configure --prefix=/usr --with-root-prefic="" \ --enable-elf-shlibs --sysconfdir=/etc make make install make install-libs cd ../../ rm -rf e2fsprogs-1.40.2 # 49步在make的时候可能会出现找不到makeinfo命令, # 我的解决办法是从宿主机上找到makeinfo命令然后cp到/mnt/lfs/tools/bin/目录下然后再运行make
50,安装常用命令集(coreutils)
cd /sources tar xvf coreutils-6.9.tar.bz2 cd coreutils-6.9 /configure --prefix=/usr make make install mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin mv -v /usr/bin/{false,hostname,ln,ls,mkdir,mknod,mv,pwd,readlink,rm} /bin mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin mv -v /usr/bin/chroot /usr/sbin mv -v /usr/bin/{head,sleep,nice} /bin cd .. rm -rf coreutils-6.9
51,安装端口及协议文件(nana-etc)
cd /sources tar xvf iana-etc-2.20.tar.bz2 cd iana-etc-2.20 make make install cd .. rm -rf iana-etc-2.20
52,安装宏处理工具(m4)
cd /sources tar xvf m4-1.4.10.tar.bz2 cd m4-1.4.10 /configure --prefix=/usr make make install cd .. rm -rf m4-1.4.10
53,安装语法分析工具(bison)
cd /sources tar xvf bison-2.3.tar.bz2 cd bison-2.3 /configure --prefix=/usr echo '#define YYENABLE_NLS 1' >> config.h make make install cd .. rm -rf bison-2.3
54,安装交互式函数库(ncurses)
cd /sources tar xvf ncurses-5.6.tar.gz cd ncurses-5.6 patch -Np1 -i /sources/ncurses-5.6-coverity_fixes-1.patch /configure --prefix=/usr --with-shared --without-debug --enable-widec make make install chmod -v 644 /usr/lib/libncurses++w.a mv -v /usr/lib/libncursesw.so.5* /lib ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so for lib in curses ncurses form panel menu ; do \ rm -vf /usr/lib/lib${lib}.so ; \ echo "INPUT(-l${lib}w)" >/usr/lib/lib${lib}.so ; \ ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a ; \ done ln -sfv libncurses++w.a /usr/lib/libncurses++.a rm -vf /usr/lib/libcursesw.so echo "INPUT(-lncursesw)" >/usr/lib/libcursesw.so ln -sfv libncurses.so /usr/lib/libcurses.so ln -sfv libncursesw.a /usr/lib/libcursesw.a ln -sfv libncurses.a /usr/lib/libcurses.a cd .. rm -rf ncurses-5.6
55,安装进程管理工具(procps)
cd /sources tar xvf procps-3.2.7.tar.gz cd procps-3.2.7 make make install cd .. rm -rf procps-3.2.7
56,安装通用支持库工具(libtools)
cd /sources tar xvf libtool-1.5.24.tar.gz cd libtool-1.5.24 /configure --prefix=/usr make make install cd .. rm -rf libtool-1.5.24
57,安装脚本语言(perl)
cd /sources tar xvf perl-5.8.8.tar.bz2 cd perl-5.8.8 echo "127.0.0.1 localhost $(hostname)" >/etc/hosts /configure.gnu --prefix=/usr \ -Dman1dir=/usr/share/man/man1 \ -Dman3dir=/usr/share/man/man3 \ -Dpager="/usr/bin/less -isR" make make install cd .. rm -rf perl-5.8.8
58,安装行编辑支持工具(readline)
cd /sources tar xvf readline-5.2.tar.gz cd readline-5.2 sed -i '/MV.*old/d' Makefile.in sed -i '/{OLDSUFF}/c:' support/shlib-install patch -Np1 -i /sources/readline-5.2-fixes-3.patch /configure --prefix=/usr --libdir=/lib make SHLIB_XLDFLAGS=-lncurses make install mv -v /lib/lib{readline,history}.a /usr/lib rm -v /lib/lib{readline,history}.so ln -sfv ../../lib/libreadline.so.5 /usr/lib/libreadline.so ln -sfv ../../lib/libhistory.so.5 /usr/lib/libhistory.so cd .. rm -rf readline-5.2
59,安装zip格式支持库(zlib)
cd /sources tar xvf zlib-1.2.3.tar.gz cd zlib-1.2.3 /configure --prefix=/usr --shared --libdir=/lib make make install rm -v /lib/libz.so ln -sfv ../../lib/libz.so.1.2.3 /usr/lib/libz.so make clean /configure --prefix=/usr make make install chmod 644 /usr/lib/libz.a cd .. rm -rf zlib-1.2.3
60,安装自动化脚本生成工具(autoconf)
cd /sources tar xvf autoconf-2.61.tar.bz2 cd autoconf-2.61 /configure --prefix=/usr make make install cd .. rm -rf autoconf-2.61
61,安装自动编译脚本生成工具(automake)
cd /sources tar xvf automake-1.10.tar.bz2 cd automake-1.10 /configure --prefix=/usr make make install cd .. rm -rf automake-1.10
62,安装命令解释器(bash)
cd /sources tar xvf bash-3.2.tar.gz cd bash-3.2 sed -i "s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.2|" Makefile.in patch -Np1 -i /sources/bash-3.2-fixes-5.patch /configure --prefix=/usr --bindir=/bin --without-bash-malloc --with-installed-readline make make install cd .. rm -rf bash-3.2
63,使用刚刚编译好的bash
exec /bin/bash --login +h
64,安装压缩工具(bzip2)
cd /sources tar xvf bzip2-1.0.4.tar.gz cd bzip2-1.0.4 patch -Np1 -i /sources/bzip2-1.0.4-install_docs-1.patch make -f Makefile-libbz2_so make clean make make PREFIX=/usr install cp -v bzip2-shared /bin/bzip2 cp -av libbz2.so* /lib ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so rm -v /usr/bin/{bunzip2,bzcat,bzip2} ln -sv bzip2 /bin/bunzip2 ln -sv bzip2 /bin/bzcat cd .. rm -rf bzip2-1.0.4
65,安装文件比较工具(diffutils)
cd /sources tar xvf diffutils-2.8.1.tar.gz cd diffutils-2.8.1 patch -Np1 -i /sources/diffutils-2.8.1-i18n-1.patch touch man/diff.1 /configure --prefix=/usr make make install cd .. rm -rf diffutils-2.8.1
由于博客限制一篇博客不能超过8W字符,余下内容见下面的链接
http://ant595.blog.51cto.com/5074217/1054407