LFS 学习日记(第五章构建临时系统之 Grep 至 本章结束 )

2010年07月06日 星期二
对于软件包具体命令的学习程度退而求其次,原先计划基本上要把每个命令弄懂,并基本上会应用,但是前几天看了一下coreutils、gawk、gettext 等软件包的命令,都非常多,如果都要弄明白,恐怕一个软件包的命令学10天也不一定能学到好深。因为我的最初计划就是学习定制 Linux 系统,只要能达成这个目的,具体命令的学习可以求其次。现在,我对自己的要求是:知道每个软件包在定制 Linux 系统中的作用,深刻理解使用某个软件包的原因( http://www.linuxfromscratch.org/lfs/view/6.6/prologue/package-choices.html ),每个软件包都包括些什么命令,可以用来做什么,与定制系统相关的重点命令的基本用法。然后,以后有需要时再具体学习具体命令的用法。

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/grep.html
5.22. Grep-2.5.4

question:  --without-included-regex

    The configure check for Glibc's regex library is broken when building against Glibc-2.11.1. This switch forces the use of Glibc's regex library.

./configure --help
  --without-included-regex don't compile regex; this is the default on
                          systems with version 2 of the GNU C library
                          (use with caution on other system)

经过试验,如果不要这个--without-included-regex 参数,确实会使用的grep 的 ./lib/regex.c 。因为如果使用了这个参数,在 config.log 中会出现:configure:9895: WARNING: Included lib/regex.c not used 。但是 ./configure --help 说的是,在2.*(这里是2.11.1)的glibc的系统上默认值是不使用这个参数的,可能这里加上这个参数的原因正是 configure 检测不到 glibc 2.11.1 的 regex 库(本来是该检测到的),误以后系统中没有 glibc 的 regex 库就会转而使用 grep 中的 regex 库。所以,加上这个参数强迫使用 glibc 的regex 库。

lfs:/mnt/lfs/sources/grep-2.5.4$ time { ./configure --prefix=/tools     --disable-perl-regexp     --without-included-regex && make && make install; }

real    0m31.068s
user    0m10.197s
sys    0m24.534s

todo: egrep, fgrep, grep 的区别和命令的详细用法。

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/gzip.html
5.23. Gzip-1.4

lfs:/mnt/lfs/sources/gzip-1.4$ time { ./configure --prefix=/tools && make && make install; }

real    0m45.669s
user    0m15.117s
sys    0m33.306s

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/m4.html
5.24. M4-1.4.13

lfs:/mnt/lfs/sources/m4-1.4.13$ time { ./configure --prefix=/tools && make && make install; }

real    0m28.157s
user    0m9.797s
sys    0m20.901s
据我初步的理解,M4可以根据它定义的宏,在一个文本模板中用宏替换文本模板的相应项目生成具体文本文件。并且在定义的宏中可以调用系统命令等进行灵活的处理:比如加入系统日期。

参考资料:
M4 示例: http://blog.chinaunix.net/u2/83284/showart.php?id=2067724
Building text files with m4 macros: http://www.sistina.com/mirrors/LDP/linuxfocus/English/September1999/article111.html

translation: The m4 program can be used either as a front-end to a compiler or as a macro processor in its own right.

in one's own right 凭本身的权利(头衔或能力等)http://dict.cn/in+one%27s+own+right

todo: m4 作为处理模板化的文本文件不错,以后有需要时可深入学习。

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/make.html
5.25. Make-3.81
todo: Makefile 的编写或生成。

lfs:/mnt/lfs/sources/make-3.81$ time { ./configure --prefix=/tools && make && make install; }
real    0m19.143s
user    0m6.436s
sys    0m13.741s

lfs:/mnt/lfs/sources/patch-2.6.1$ time { ./configure --prefix=/tools && make && make install; }

real    0m9.631s
user    0m4.716s
sys    0m6.556s

lfs:/mnt/lfs/sources/perl-5.10.1$ time { sh Configure -des -Dprefix=/tools                   -Dstatic_ext='Data/Dumper Fcntl IO POSIX' && make perl utilities ext/Errno/pm_to_blib && cp -v perl pod/pod2man /tools/bin && mkdir -pv /tools/lib/perl5/5.10.1 && cp -Rv lib/* /tools/lib/perl5/5.10.1; }

real    1m7.304s
user    0m52.987s
sys    0m39.610s

todo: pod 格式的文件是什么样的

lfs:/mnt/lfs/sources/sed-4.2.1$ time { ./configure --prefix=/tools && make && make install; }

real    0m19.266s
user    0m5.784s
sys    0m14.209s

lfs:/mnt/lfs/sources/tar-1.22$ time { ./configure --prefix=/tools && make && make install; }

real    0m38.853s
user    0m15.385s
sys    0m28.570s

lfs:/mnt/lfs/sources/texinfo-4.13$ time { ./configure --prefix=/tools && make && make install; }

real    0m24.356s
user    0m14.569s
sys    0m15.985s

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/stripping.html
5.31. Stripping
因为我编译LFS的空间比较富余(8G),没有进行这步剥离的操作。剥离这一步可以节省约100M的空间。

http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/changingowner.html
5.32. Changing Ownership
从这步开始直到结束,都是用root 操作了。

question: 这里要求 root 设置 $LFS 环境变量,那么是否像前面的lfs 用户一样在 .bash_profile 和 .bashrc 中进行设置呢?是否还要设置其它环境变量呢?像前面的 MAKEFLAGS='-j 2' 在哪里设置呢?

把$LFS/tools 的拥有者改为 root:root 后,用 sudo cp tools tools.end5 -a 和 sudo tar -cpjf tools.end5.tar.bz2 tools (tar 命令选项如果有-的话,f选项后面必须跟档案名;没有-可以不论;-p是保留权限属性)命令作了复制备份和压缩包备份。第五章临时系统编译任务完成。

question: tar 命令的全面应用,例如:-p 选项的使用。