13.构建LFS系统──安装系统基础软件(五)
时间:2006-11-17 来源:anima
十三、构建LFS系统──安装系统基础软件(五)
13.Berkeley DB-4.4.20
Berkeley DB 包含一些程序和工具,供其他的一些程序来在做数据库相关函数时调用。
预计编译时间: 1.2 SBU
所需磁盘空间: 77 MB
Other Installation Possibilities
如果你需要建立一个 RPC 服务器或者是附加语言绑定编译,在BLFS手册中有一些编译这个软件包的说明。附加语言的绑定编译还需要一些额外的软件包。参见 http://www.linuxfromscratch.org/blfs/view/svn/server/databases.html#db的安装说明
另外,GDBM 可以 被用来代替 Berkeley DB 来满足数据库需求。但是,因为在LFS构建过程中,Berkeley DB 被认为是一个核心部分,无法列出在BLFS手册中把它作为依赖的软件(太多了)。同样,很多时候我们测试的是安装了Berkeley DB的LFS系统,而不是 GDBM。如果你清楚的了解了使用 GDBM 的风险和好处,仍然想要采用它,可以参考BLFS手册中的说明 http://www.linuxfromscratch.org/blfs/view/svn/general/gdbm.html
安装Berkeley DB
root:/sources/gcc-build# tar -zxvf $LFS/sources/db-4.4.20.tar.gz -C $LFS/sources
root:/sources/gcc-build# cd $LFS/sources/db-4.4.20
修补软件包来防止一些潜在的陷井时间:
root:/sources/db-4.4.20# patch -Np1 -i ../db-4.4.20-fixes-1.patch
patching file db/db_cam.c
patching file mp/mp_fget.c
patching file qam/qam_files.c
patching file txn/txn.c
root:/sources/db-4.4.20# cd build_unix &&
> ../dist/configure --prefix=/usr --enable-compat185 --enable-cxx
配置选项的含义:
--enable-compat185 这个选项指定编译 Berkeley DB 1.85 向上兼容性API。 --enable-cxx 这个选项指定编译 C++ API 库。
编译软件包:
root:/sources/db-4.4.20/build_unix# make && date +%c (开始于2006-11-14 12:09:55)
……
……
……
cc -c -I. -I../dist/.. -D_GNU_SOURCE -D_REENTRANT -O2 ../dist/../db_upgrade/db_upgrade.c -o db_upgrade.o >/dev/null 2>&1
/bin/sh ./libtool --mode=link cc -O2 -o db_upgrade \
db_upgrade.lo util_sig.lo libdb-4.4.la -lpthread
cc -O2 -o .libs/db_upgrade .libs/db_upgrade.o .libs/util_sig.o ./.libs/libdb-4.4.so -lpthread
creating db_upgrade
/bin/sh ./libtool --mode=execute true db_upgrade
/bin/sh ./libtool --mode=compile cc -c -I. -I../dist/.. -D_GNU_SOURCE -D_REENTRANT -O2 ../dist/../db_verify/db_verify.c
cc -c -I. -I../dist/.. -D_GNU_SOURCE -D_REENTRANT -O2 ../dist/../db_verify/db_verify.c -fPIC -DPIC -o .libs/db_verify.o
cc -c -I. -I../dist/.. -D_GNU_SOURCE -D_REENTRANT -O2 ../dist/../db_verify/db_verify.c -o db_verify.o >/dev/null 2>&1
/bin/sh ./libtool --mode=link cc -O2 -o db_verify \
db_verify.lo util_cache.lo util_sig.lo libdb-4.4.la -lpthread
cc -O2 -o .libs/db_verify .libs/db_verify.o .libs/util_cache.o .libs/util_sig.o ./.libs/libdb-4.4.so -lpthread
creating db_verify
/bin/sh ./libtool --mode=execute true db_verify
Tue Nov 14 04:16:38 2006 (结束于2006-11-14 12:16:38)
root:/sources/db-4.4.20/build_unix#
现在测试软件包是没有意义的,因为这将会导致 TCL 捆绑编译。TCL不能被准确的编译,因为 TCL 还是链接到 /tools 下的 Glibc,而不是 /usr 目录下的Glibc。
安装软件包:
root:/sources/db-4.4.20/build_unix# make docdir=/usr/share/doc/db-4.4.20 install
Installing DB include files: /usr/include ...
Installing DB library: /usr/lib ...
cp -p .libs/libdb-4.4.so /usr/lib/libdb-4.4.so
cp -p .libs/libdb-4.4.lai /usr/lib/libdb-4.4.la
cp -p .libs/libdb_cxx-4.4.so /usr/lib/libdb_cxx-4.4.so
cp -p .libs/libdb_cxx-4.4.lai /usr/lib/libdb_cxx-4.4.la
cp -p .libs/libdb-4.4.a /usr/lib/libdb-4.4.a
ranlib /usr/lib/libdb-4.4.a
chmod 644 /usr/lib/libdb-4.4.a
cp -p libdb.a /usr/lib/libdb.a
ranlib /usr/lib/libdb.a
chmod 644 /usr/lib/libdb.a
cp -p .libs/libdb_cxx-4.4.a /usr/lib/libdb_cxx-4.4.a
ranlib /usr/lib/libdb_cxx-4.4.a
chmod 644 /usr/lib/libdb_cxx-4.4.a
cp -p libdb_cxx.a /usr/lib/libdb_cxx.a
ranlib /usr/lib/libdb_cxx.a
chmod 644 /usr/lib/libdb_cxx.a
PATH="$PATH:/sbin" ldconfig -n /usr/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing DB utilities: /usr/bin ...
cp -p .libs/db_archive /usr/bin/db_archive
cp -p .libs/db_checkpoint /usr/bin/db_checkpoint
cp -p .libs/db_deadlock /usr/bin/db_deadlock
cp -p .libs/db_dump /usr/bin/db_dump
cp -p .libs/db_hotbackup /usr/bin/db_hotbackup
cp -p .libs/db_load /usr/bin/db_load
cp -p .libs/db_printlog /usr/bin/db_printlog
cp -p .libs/db_recover /usr/bin/db_recover
cp -p .libs/db_stat /usr/bin/db_stat
cp -p .libs/db_upgrade /usr/bin/db_upgrade
cp -p .libs/db_verify /usr/bin/db_verify
Installing documentation: /usr/share/doc/db-4.4.20 ...
root:/sources/db-4.4.20/build_unix#
make 参数的含义:
docdir=... 这条安装命令将db的文档安装到正确的位置。
修改安装文件的属主:
root:/sources/db-4.4.20/build_unix# chown -v root:root /usr/bin/db_* \
> /usr/lib/libdb* /usr/include/db* &&
> chown -Rv root:root /usr/share/doc/db-4.4.20
Berkeley DB 的内容
安装的程序: db_archive, db_checkpoint, db_deadlock, db_dump, db_hotbackup, db_load, db_printlog, db_recover, db_stat, db_upgrade, db_verify
安装的库: libdb.{so,ar}and libdb_cxx.r{o,ar}
简要描述
db_archive |
打印出不再使用的日志文件路径名 |
db_checkpoint |
监视和检查数据库日志的守护进程 |
db_deadlock |
当死锁发生时,退出锁定要求 |
db_dump |
把数据库文件转换成 db_load 能认出的文本文件 |
db_hotbackup |
创建 "hot backup" 或者是 "hot failover" 的 Berkeley DB 数据库镜像。 |
db_load |
从db_dump产生的文本文件中创建出数据库文件 |
db_printlog |
把数据库日志文件转换成人能读懂的文本 |
db_recover |
在发生错误后,把数据库恢复到一致的状态 |
db_stat |
显示数据库环境统计 |
db_upgrade |
把数据库文件转换成新版本的Berkley DB格式 |
db_verify |
对数据库文件进行一致性检查 |
libdb.{so,a} |
包含db处理相关函数的C库 |
libdb_cxx.{so,a} |
包含db处理相关函数的C++库 |
14.Coreutils-5.96
Coreutils 软件包包括一套显示、设置基本系统属性的工具。
预计编译时间: 1.1 SBU
所需磁盘空间: 58.3 MB
安装Coreutils
root:/sources/db-4.4.20/build_unix# mv $LFS/sources/coreutils-5.96 $LFS/sources/old2
root:/sources/db-4.4.20/build_unix# tar -jxvf $LFS/sources/coreutils-5.96.tar.bz2 -C $LFS/sources
root:/sources/db-4.4.20/build_unix# cd $LFS/sources/coreutils-5.96
通常 uname 程序总是有点毛病的,比如 -punknown 的结果。下面的补丁对 Intel 平台的机器能修正这个问题:
root:/sources/coreutils-5.96# patch -Np1 -i ../coreutils-5.96-uname-1.patch
patching file src/uname.c
root:/sources/coreutils-5.96#
阻止 Coreutils 安装后面将由别的包安装的程序:
root:/sources/coreutils-5.96# patch -Np1 -i ../coreutils-5.96-suppress_uptime_kill_su-1.patch
patching file AUTHORS
patching file Makefile.in
patching file README
patching file configure
Hunk #1 succeeded at 48977 (offset -1441 lines).
patching file man/Makefile.in
Hunk #2 succeeded at 301 (offset -2 lines).
Hunk #4 succeeded at 605 (offset -2 lines).
Hunk #6 succeeded at 651 (offset -2 lines).
patching file src/Makefile.in
Hunk #7 succeeded at 830 (offset -2 lines).
Hunk #9 succeeded at 1212 (offset -2 lines).
Hunk #11 succeeded at 1360 (offset -2 lines).
root:/sources/coreutils-5.96#
POSIX 要求 Coreutils 的程序即使在多字节环境下也能够识别出字符的边界。下面的这个patch能够解决这个问题以及其他的一些国际化相关的问题:
root:/sources/coreutils-5.96# patch -Np1 -i ../coreutils-5.96-i18n-1.patch
patching file lib/linebuffer.h
patching file src/cut.c
patching file src/pr.c
patching file src/uniq.c
patching file src/expand.c
patching file src/fold.c
patching file src/join.c
patching file src/unexpand.c
patching file src/sort.c
patching file tests/sort/sort-mb-tests
patching file tests/sort/mb1.I
patching file tests/sort/mb2.I
patching file tests/sort/mb1.X
patching file tests/sort/mb2.X
patching file tests/sort/Makefile.am
patching file tests/sort/Makefile.in
Hunk #1 succeeded at 336 (offset -2 lines).
root:/sources/coreutils-5.96#
为了测试应用的patch能够运行,修改文件的权限:
root:/sources/coreutils-5.96# chmod +x tests/sort/sort-mb-tests
注意
过去,在这个patch里面发现了很多bug。当你向 Coreutils 的维护者发送错误报告的时候,首先确认不应用这个patch错误会不会出现。
现在已经发现在使用who -Hu时,转换的信息有时会导致缓冲区溢出。增大缓冲区大小:
root:/sources/coreutils-5.96# sed -i 's/_LEN 6/_LEN 20/' src/who.c
为编译 Coreutils 做准备:
root:/sources/coreutils-5.96# ./configure –prefix=/usr
编译软件包:
root:/sources/coreutils-5.96# make && date +%c (开始于2006-11-14 12:58:38)
……
……
……
make[3]: Leaving directory `/sources/coreutils-5.96/tests/uniq'
Making all in wc
make[3]: Entering directory `/sources/coreutils-5.96/tests/wc'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/sources/coreutils-5.96/tests/wc'
make[3]: Entering directory `/sources/coreutils-5.96/tests'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/sources/coreutils-5.96/tests'
make[2]: Leaving directory `/sources/coreutils-5.96/tests'
make[2]: Entering directory `/sources/coreutils-5.96'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/sources/coreutils-5.96'
make[1]: Leaving directory `/sources/coreutils-5.96'
Tue Nov 14 05:00:47 2006 (结束于2006-11-14 13:00:47)
root:/sources/coreutils-5.96#
Coreutils 软件包的测试套件对系统进行了某些假设,比如要求有非 root 用户和组,但是我们目前的系统中尚不存在。如果你不想运行测试套件,就直接跳过下面将要进行的测试,直接从"安装软件包"那里继续。
下面的命令为我们做测试前的准备,创建两个 dummy(伪) 组和一个 dummy(伪) 用户:
root:/sources/coreutils-5.96# echo "dummy1:x:1000:" >> /etc/group
root:/sources/coreutils-5.96# echo "dummy2:x:1001:dummy" >> /etc/group
root:/sources/coreutils-5.96# echo "dummy:x:1000:1000::/root:/bin/bash" >> /etc/passwd
现在已经准备好可以运行测试套件了,首先运行那些需要以 root 运行的测试:
root:/sources/coreutils-5.96# make NON_ROOT_USERNAME=dummy check-root
cd tests && make check-root
make[1]: Entering directory `/sources/coreutils-5.96/tests'
cd chown && make check TESTS=basic
make[2]: Entering directory `/sources/coreutils-5.96/tests/chown'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests/chown'
PASS: basic
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests/chown'
make[2]: Leaving directory `/sources/coreutils-5.96/tests/chown'
cd cp && make check TESTS=special-bits
make[2]: Entering directory `/sources/coreutils-5.96/tests/cp'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests/cp'
PASS: special-bits
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests/cp'
make[2]: Leaving directory `/sources/coreutils-5.96/tests/cp'
cd rm && make check TESTS=no-give-up
make[2]: Entering directory `/sources/coreutils-5.96/tests/rm'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests/rm'
PASS: no-give-up
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests/rm'
make[2]: Leaving directory `/sources/coreutils-5.96/tests/rm'
cd rm && make check TESTS=fail-2eperm
make[2]: Entering directory `/sources/coreutils-5.96/tests/rm'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests/rm'
PASS: fail-2eperm
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests/rm'
make[2]: Leaving directory `/sources/coreutils-5.96/tests/rm'
make[1]: Leaving directory `/sources/coreutils-5.96/tests'
root:/sources/coreutils-5.96#
然后以 dummy 用户运行剩余的测试:
root:/sources/coreutils-5.96# src/su dummy -c "make RUN_EXPENSIVE_TESTS=yes check"
……
……
……
make[2]: Entering directory `/sources/coreutils-5.96/tests/wc'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests/wc'
PASS: wc-tests
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests/wc'
make[2]: Leaving directory `/sources/coreutils-5.96/tests/wc'
make[2]: Entering directory `/sources/coreutils-5.96/tests'
make check-TESTS
make[3]: Entering directory `/sources/coreutils-5.96/tests'
0+1 records in
0+1 records out
1 byte (1 B) copied, 0.000156 seconds, 6.4 kB/s
../../src/df: Warning: cannot read table of mounted file systems
PASS: help-version
==================
All 1 tests passed
==================
make[3]: Leaving directory `/sources/coreutils-5.96/tests'
make[2]: Leaving directory `/sources/coreutils-5.96/tests'
make[1]: Leaving directory `/sources/coreutils-5.96/tests'
make[1]: Entering directory `/sources/coreutils-5.96'
make[1]: Nothing to be done for `check-am'.
make[1]: Leaving directory `/sources/coreutils-5.96'
root:/sources/coreutils-5.96#
测试结束后,删除 dummy 组和用户:
root:/sources/coreutils-5.96# sed -i '/dummy/d' /etc/passwd /etc/group
安装软件包:
root:/sources/coreutils-5.96# make install
把一些程序移动到合适的位置以符合 FHS 标准:
root:/sources/coreutils-5.96# mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
`/usr/bin/cat' -> `/bin/cat'
`/usr/bin/chgrp' -> `/bin/chgrp'
`/usr/bin/chmod' -> `/bin/chmod'
`/usr/bin/chown' -> `/bin/chown'
`/usr/bin/cp' -> `/bin/cp'
`/usr/bin/date' -> `/bin/date'
`/usr/bin/dd' -> `/bin/dd'
`/usr/bin/df' -> `/bin/df'
`/usr/bin/echo' -> `/bin/echo'
root:/sources/coreutils-5.96# mv -v /usr/bin/{false,hostname,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
`/usr/bin/false' -> `/bin/false'
`/usr/bin/hostname' -> `/bin/hostname'
`/usr/bin/ln' -> `/bin/ln'
`/usr/bin/ls' -> `/bin/ls'
`/usr/bin/mkdir' -> `/bin/mkdir'
`/usr/bin/mknod' -> `/bin/mknod'
`/usr/bin/mv' -> `/bin/mv'
`/usr/bin/pwd' -> `/bin/pwd'
`/usr/bin/rm' -> `/bin/rm'
root:/sources/coreutils-5.96# mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin
`/usr/bin/rmdir' -> `/bin/rmdir'
`/usr/bin/stty' -> `/bin/stty'
`/usr/bin/sync' -> `/bin/sync'
`/usr/bin/true' -> `/bin/true'
`/usr/bin/uname' -> `/bin/uname'
root:/sources/coreutils-5.96# mv -v /usr/bin/chroot /usr/sbin
`/usr/bin/chroot' -> `/usr/sbin/chroot'
root:/sources/coreutils-5.96#
一些 LFS-Bootscripts 包中的脚本依赖于 head, sleep,和 nice 。由于 /usr 目录有可能在系统启动过程的早期不可用(比如尚未挂载),所以这些二进制程序需要放置在根分区上:
root:/sources/coreutils-5.96# mv -v /usr/bin/{head,sleep,nice} /bin
`/usr/bin/head' -> `/bin/head'
`/usr/bin/sleep' -> `/bin/sleep'
`/usr/bin/nice' -> `/bin/nice'
root:/sources/coreutils-5.96#
Coreutils 的内容
安装的程序: basename, cat, chgrp, chmod, chown, chroot, cksum, comm, cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo, env, expand, expr, factor, false, fmt, fold, groups, head, hostid, hostname, id, install, join, 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, sum, sync, tac, tail, tee, test, touch, tr, true, tsort, tty, uname, unexpand, uniq, unlink, users, vdir, wc, who, whoami, yes
简要描述
basename |
去掉文件名中的目录和后缀 |
cat |
把文本文件的内容发送到标准输出 |
chgrp |
改变文件和目录属组,属组可以使用组名或者组识别号表示 |
chmod |
改变文件和目录的权限,权限可以使用符号或者八进制两种表达方式 |
chown |
改变文件和目录的所有权(包括用户和/或组) |
chroot |
使用特定的目录作为执行某个命令或者交互 shell 的根目录(/)。在多数系统中,只有 root 用户能运行这个命令 |
cksum |
输出指定的每个文件的CRC(循环冗余校验)校验和与字节数 |
comm |
一行一行对两个已经排序的文件进行比较,在第三列中显示同一行是否相同 |
cp |
复制文件 |
csplit |
把一个文件按照给定的模式或者行号分成几块 |
cut |
从指定的文件中提取特定的列送到标准输出 |
date |
以特定的格式显示当前时间,或者设置系统日期 |
dd |
以可选块长度复制文件,默认情况下从标准输入设备输出到标准输出设备。复制过程中,还可以对文件进行一些转换 |
df |
显示参数中的文件所在分区磁盘空间的使用情况,如果没有给出文件参数就显示所有已经安装的文件系统的可用空间数量。 |
dir |
列出给定目录的内容 (同 ls 命令) |
dircolors |
设置 LS_COLOR 环境变量(用来改变 ls 及相关工具默认颜色组合) |
dirname |
显示从文件名去掉非目录后缀之后的内容 |
du |
显示参数使用的磁盘空间的数量,对于参数为目录还会列出每个子目录磁盘空间占用情况。 |
echo |
显示给定字符串或变量值 |
env |
在一个被修改的环境中运行一个程序 |
expand |
把 tab 转换为空格符 |
expr |
执行表达式计算 |
factor |
输出所有指定整数的质因数 |
false |
返回一个不成功或者逻辑假的结果 |
fmt |
重新格式化指定文件的段落 |
fold |
断开指定文件(默认是标准输入)较长的行,在屏幕上显示 |
groups |
显示一个用户所在的组 |
head |
显示每个指定文件的前几行(默认是10) |
hostid |
以16进制方式,显示当前主机的数字标志符 |
hostname |
显示或设置主机名 |
id |
显示某个用户或者当前用户的真实和有效的 UID、GID 。 |
install |
复制文件,设置它们的权限,如果可能还设置拥有它们的用户和组 |
join |
合并两个文件的行 |
link |
创建从指定文件到指定名称的硬链接 |
ln |
创建文件之间的硬/软(符号)连接 |
logname |
显示当前用户的登录名 |
ls |
列出指定目录的所有内容。缺省是将文件和子目录按字母顺序排列。 |
md5sum |
显示或者校验 MD5 校验码。 |
mkdir |
建立目录,使用给定的参数作为目录名。 |
mkfifo |
以给定的参数作为名字建立FIFO(又叫"命名管道")文件。 |
mknod |
使用给出的文件名,建立一个设备节点,也就是:FIFO、字符特殊文件(special file)或者块特殊文件(special file)。 |
mv |
根据所给参数的不同,把文件或者目录移动到另外的目录或者将其改名 |
nice |
修改某个进程的调度优先级 |
nl |
把每个指定文件的内容写到标准输出,在每行加上行号 |
nohup |
使某个命令不被挂起,并将输出重定向到一个日志文件。 |
od |
以数字方式显示指定文件的内容,默认为八进制。 |
paste |
将字段连接在一起,在字段之间自动插入分割符,默认的分割符是 Tab 。 |
pathchk |
检查文件名是否是有效的或者是可移植的 |
pinky |
一个轻量级的 finger 客户端,用来得到某个用户的信息。 |
pr |
将文件分成适当大小的页送到打印机 |
printenv |
显示环境变量 |
printf |
根据给定的参数格式化输出数据,与 C 语言中的该函数相似。 |
ptx |
为指定的文件提供一个排序索引 |
pwd |
显示当前工作目录 |
readlink |
显示指定符号链接的值 |
rm |
删除文件或者目录 |
rmdir |
删除目录(目录必需为空) |
seq |
以指定的步长输出一个数列 |
sha1sum |
显示或校验 160 位的 SHA1 校验码 |
shred |
安全删除一个文件,重写其占用的磁盘空间,使其无法恢复。 |
sleep |
延迟一段时间 |
sort |
对文件进行排序 |
split |
把文件分成固定大小(字节或行数)的片断 |
stat |
显示文件或者文件系统的状态 |
stty |
改变和显示终端行的设置 |
sum |
显示指定文件的校验和及块数 |
sync |
刷新文件系统缓冲区,使磁盘和内存的数据同步。 |
tac |
逆向显示指定的文件,最后一行在最前。 |
tail |
显示每个指定文件的最后几行(默认是10)。 |
tee |
从标准输入读取数据,输出到标准输出和指定的文件。 |
test |
检查文件类型,以及进行变量的比较。 |
touch |
把参数指定的文件的访问和修改时间改为当前的时间。如果文件不存在,它就建立一个空文件。 |
tr |
从标准输入读入正文,对字符进行转换、压缩或者删除,然后写到标准输出 |
true |
返回一个成功或者逻辑真的结果 |
tsort |
对给定的文件进行拓扑排序 |
tty |
显示标准输出设备连接终端的文件名 |
uname |
打印系统信息 |
unexpand |
把空格符转换成 tab |
uniq |
抛弃指定文件或者标准输入中内容重复的行 |
unlink |
删除指定文件 |
users |
显示在当前主机登录的用户名 |
vdir |
同 ls -l |
wc |
统计文件中包含的字节数、单词数、行数 |
who |
显示有哪些用户登录 |
whoami |
打印当前用户的有效用户标志符 |
yes |
重复输出"y"字符,直到被杀死。 |
15.Iana-Etc-2.10
Iana-Etc 软件包提供了网络服务和协议的数据。
预计编译时间: 少于 0.1 SBU
所需磁盘空间: 2.1 MB
安装Iana-Etc
root:/sources/coreutils-5.96# tar -jxvf $LFS/sources/iana-etc-2.10.tar.bz2 -C $LFS/sources
root:/sources/coreutils-5.96# cd $LFS/sources/iana-etc-2.10
下面的命令将 IANA 的原始数据转换为 /etc/protocols 和 /etc/services 数据文件能够识别的格式:
root:/sources/iana-etc-2.10# make
ln -f -s protocol-numbers.dist protocol-numbers
gawk --re-interval -f protocols.gawk protocol-numbers > protocols
ln -f -s port-numbers.dist port-numbers
gawk -f services.gawk port-numbers > services
root:/sources/iana-etc-2.10#
这个软件包没有附带测试程序。
安装软件包:
root:/sources/iana-etc-2.10# make install
install -d /etc
install -m 644 protocols /etc
install -m 644 services /etc
root:/sources/iana-etc-2.10#
Iana-Etc 的内容
安装的文件: /etc/protocols, /etc/services
简要描述
/etc/protocols |
描述 TCP/IP 子系统可用的各种 Internet 协议。 |
/etc/services |
将 internet 服务映射到一个包含端口号和所使用协议的文本名称。 |
16.M4-1.4.4
M4 软件包包含一个宏处理器。
预计编译时间: 少于 0.1 SBU
所需磁盘空间: 3 MB
安装M4
root:/sources/iana-etc-2.10# mv $LFS/sources/m4-1.4.4 $LFS/sources/old2
root:/sources/iana-etc-2.10# tar -zxvf $LFS/sources/m4-1.4.4.tar.gz -C $LFS/sources
root:/sources/iana-etc-2.10# cd $LFS/sources/m4-1.4.4
为编译M4做准备:
root:/sources/m4-1.4.4# ./configure –prefix=/usr
编译软件包:
root:/sources/m4-1.4.4# make
要测试结果,请运行:make check 。
安装软件包:
root:/sources/m4-1.4.4# make install
M4 的内容
安装的程序: m4
简要描述
m4 |
M4 能够将宏展开并将输入拷贝到输出。宏可以是内嵌的也可以是用户定义的,并且可以接受很多参数。除了展开宏,m4 还有其它内置的功能,比如包含引用文件、运行 Unix 命令、进行整数运算、文本操作、循环等等。m4 可以被用作一个编译器的前端或作为自身的一个宏处理程序。 |
17.Bison-2.2
Bison 软件包包括一个语法分析程序生成器。
预计编译时间: 0.6 SBU
所需磁盘空间: 11.9 MB
安装 Bison
root:/sources/m4-1.4.4# tar -jxvf $LFS/sources/bison-2.2.tar.bz2 -C $LFS/sources
root:/sources/m4-1.4.4# cd $LFS/sources/bison-2.2
为编译 Bison 做准备:
root:/sources/bison-2.2# ./configure --prefix=/usr
如果 bison 程序不在 $PATH 中的话,编译时将会出现缺乏国际化支持的错误信息。下面处理可以解决这个问题:
root:/sources/bison-2.2# echo '#define YYENABLE_NLS 1' >> config.h
编译软件包:
root:/sources/bison-2.2# make
要测试结果,请运行:make check 。
安装软件包:
root:/sources/bison-2.2# make install
Bison 的内容
安装的程序: bison, yacc
安装的库: liby.a
简要描述
bison |
根据一系列规则来生成一个可以分析文本文件的结构的程序的程序,Bison 是一个替代 Yacc (Yet Another Compiler Compiler) 的语法分析程序生成器。 |
yacc |
一个 bison 的包装,意思是程序仍然调用 yacc 而不是 bison ,它用 -y 选项调用 bison 。 |
liby.a |
acc 库包含与 Yacc 兼容的 yyerror 和 main 函数,这个库通常不是很有用,但是 POSIX 需要它。 |
18. Ncurses-5.5
Ncurses 程序包提供字符终端处理库,包括面板和菜单。
预计编译时间: 0.7 SBU
所需磁盘空间: 31 MB
安装 Ncurses
root:/sources/bison-2.2# mv $LFS/sources/ncurses-5.5 $LFS/sources/old2
root:/sources/bison-2.2# tar -zxvf $LFS/sources/ncurses-5.5.tar.gz -C $LFS/sources
root:/sources/bison-2.2# cd $LFS/sources/ncurses-5.5
Ncurses-5.5 有一个内存泄漏和一些显示的bug被发现,并修正了。应用这些修正:
root:/sources/ncurses-5.5# patch -Np1 -i ../ncurses-5.5-fixes-1.patch
为编译 Ncurses 做准备:
root:/sources/ncurses-5.5# ./configure --prefix=/usr --with-shared --without-debug --enable-widec
配置选项的含义:
--enable-widec 这个选项导致宽字符库(例如,libncursesw.so.5.5)将会替换正常的(例如,libncurses.so.5.5)。这些宽字符库可以在 多字节和传统的8位 locale 下使用,然而正常的库一般只能在 8位 的locale环境下工作。宽字符和正常的库是源码兼容的,但不是二进制兼容的。编译软件包:
root:/sources/ncurses-5.5# make
这个软件包没有附带测试程序。
安装软件包:
root:/sources/ncurses-5.5# make install
赋予 ncurses 库文件可执行权限:
root:/sources/ncurses-5.5# chmod -v 755 /usr/lib/*.5.5
mode of `/usr/lib/libformw.so.5.5' changed to 0755 (rwxr-xr-x)
mode of `/usr/lib/libmenuw.so.5.5' changed to 0755 (rwxr-xr-x)
mode of `/usr/lib/libncursesw.so.5.5' changed to 0755 (rwxr-xr-x)
mode of `/usr/lib/libpanelw.so.5.5' changed to 0755 (rwxr-xr-x)
root:/sources/ncurses-5.5#
修正一个不应该有可执行权限的库文件:
root:/sources/ncurses-5.5# chmod -v 644 /usr/lib/libncurses++w.a
mode of `/usr/lib/libncurses++w.a' changed to 0644 (rw-r--r--)
root:/sources/ncurses-5.5#
把库文件移到更合理的 /lib 目录里:
root:/sources/ncurses-5.5# mv -v /usr/lib/libncursesw.so.5* /lib
`/usr/lib/libncursesw.so.5' -> `/lib/libncursesw.so.5'
`/usr/lib/libncursesw.so.5.5' -> `/lib/libncursesw.so.5.5'
root:/sources/ncurses-5.5#
由于库文件移动了,所以有的符号链接就指向了不存在的文件。需要重新创建这些符号链接:
root:/sources/ncurses-5.5# ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so
create symbolic link `/usr/lib/libncursesw.so' to `../../lib/libncursesw.so.5'
root:/sources/ncurses-5.5#
许多的程序依然希望链接器能够发现非宽字符的 Ncurses 库。通过符号链接和链接器脚本来欺骗它使其链接宽字符的库:
root:/sources/ncurses-5.5# 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
create symbolic link `/usr/lib/libcurses.a' to `libcursesw.a'
create symbolic link `/usr/lib/libncurses.a' to `libncursesw.a'
create symbolic link `/usr/lib/libform.a' to `libformw.a'
create symbolic link `/usr/lib/libpanel.a' to `libpanelw.a'
create symbolic link `/usr/lib/libmenu.a' to `libmenuw.a'
create symbolic link `/usr/lib/libncurses++.a' to `libncurses++w.a'
root:/sources/ncurses-5.5#
最后,确保一些在编译的时候寻找 -lcurses 的老程序仍然可以编译:
root:/sources/ncurses-5.5# 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
create symbolic link `/usr/lib/libcurses.so' to `libncurses.so'
create symbolic link `/usr/lib/libcursesw.a' to `libncursesw.a'
create symbolic link `/usr/lib/libcurses.a' to `libncurses.a'
root:/sources/ncurses-5.5#
注意
上面的说明并没有创建非宽字符的 Ncurses 库,因为没有软件包编译后在运行时需要链接到它们的。如果你因为一些只有二进制文件的程序,必须安装这样的库的话,按照下面的命令进行编译:
make distclean &&
./configure --prefix=/usr --with-shared --without-normal \
--without-debug --without-cxx-binding &&
make sources libs &&
cp -av lib/lib*.so.5* /usr/lib
Ncurses 的内容
安装的程序: captoinfo(→tic), clear, infocmp, infotocap(→tic), reset(→tset), tack, tic, toe, tput, tset
安装的库: libcursesw.{a,so} (symlink and linker script to libncursesw.{a,so}), libformw.{a,so}, libmenuw.{a,so}, libncurses++w.a, libncursesw.{a,so}, libpanelw.{a,so} and their non-wide-character counterparts without "w" in the library names.
简要描述
captoinfo |
将 termcap 描述转化成 terminfo 描述 |
clear |
如果可能,就进行清屏操作 |
infocmp |
比较或显示 terminfo 描述 |
infotocap |
将 terminfo 描述转化成 termcat 描述 |
reset |
重新初始化终端到默认值 |
tack |
terminfo 动作检测器。主要用来测试 terminfo 数据库中某一条目的正确性。 |
tic |
Tic 是 terminfo 项说明的编译器。这个程序通过 ncurses 库将源代码格式的 terminfo 文件转换成编译后格式(二进制)的文件。 Terminfo 文件包含终端能力的信息。 |
toe |
列出所有可用的终端类型,分别列出名称和描述。 |
tput |
利用 terminfo 数据库使与终端相关的能力和信息值对 shell 可用,初始化和重新设置终端,或返回所要求终端为类型的长名。 |
tset |
可以用来初始化终端 |
libcurses |
链接到 libncurses |
libncurses |
用来在显示器上显示文本的库。一个例子就是在内核的 make menuconfig 进程中。 |
libform |
在 ncurses 中使用表格 |
libmenu |
在 ncurses 中使用菜单 |
libpanel |
在 ncurses 中使用面板 |
19.Procps-3.2.6
Procps 包含有用于监视系统进程的程序。
预计编译时间: 0.1 SBU
所需磁盘空间: 2.3 MB
安装Procps
root:/sources/ncurses-5.5# tar -zxvf $LFS/sources/procps-3.2.6.tar.gz -C $LFS/sources
root:/sources/ncurses-5.5# cd $LFS/sources/procps-3.2.6
编译软件包:
root:/sources/procps-3.2.6# make
这个软件包没有附带测试程序。
安装软件包:
root:/sources/procps-3.2.6# make install
install -D --owner 0 --group 0 --mode a=rx uptime /usr/bin/uptime
install -D --owner 0 --group 0 --mode a=rx tload /usr/bin/tload
install -D --owner 0 --group 0 --mode a=rx free /usr/bin/free
install -D --owner 0 --group 0 --mode a=rx w /usr/bin/w
install -D --owner 0 --group 0 --mode a=rx top /usr/bin/top
install -D --owner 0 --group 0 --mode a=rx vmstat /usr/bin/vmstat
install -D --owner 0 --group 0 --mode a=rx watch /usr/bin/watch
install -D --owner 0 --group 0 --mode a=rx skill /usr/bin/skill
install -D --owner 0 --group 0 --mode a=rx snice /usr/bin/snice
install -D --owner 0 --group 0 --mode a=rx kill /bin/kill
install -D --owner 0 --group 0 --mode a=rx sysctl /sbin/sysctl
install -D --owner 0 --group 0 --mode a=rx pmap /usr/bin/pmap
install -D --owner 0 --group 0 --mode a=rx pgrep /usr/bin/pgrep
install -D --owner 0 --group 0 --mode a=rx pkill /usr/bin/pkill
install -D --owner 0 --group 0 --mode a=rx slabtop /usr/bin/slabtop
install -D --owner 0 --group 0 --mode a=rx pwdx /usr/bin/pwdx
install -D --owner 0 --group 0 --mode a=r uptime.1 /usr/share/man/man1/uptime.1
install -D --owner 0 --group 0 --mode a=r tload.1 /usr/share/man/man1/tload.1
install -D --owner 0 --group 0 --mode a=r free.1 /usr/share/man/man1/free.1
install -D --owner 0 --group 0 --mode a=r w.1 /usr/share/man/man1/w.1
install -D --owner 0 --group 0 --mode a=r top.1 /usr/share/man/man1/top.1
install -D --owner 0 --group 0 --mode a=r watch.1 /usr/share/man/man1/watch.1
install -D --owner 0 --group 0 --mode a=r skill.1 /usr/share/man/man1/skill.1
install -D --owner 0 --group 0 --mode a=r kill.1 /usr/share/man/man1/kill.1
install -D --owner 0 --group 0 --mode a=r snice.1 /usr/share/man/man1/snice.1
install -D --owner 0 --group 0 --mode a=r pgrep.1 /usr/share/man/man1/pgrep.1
install -D --owner 0 --group 0 --mode a=r pkill.1 /usr/share/man/man1/pkill.1
install -D --owner 0 --group 0 --mode a=r pmap.1 /usr/share/man/man1/pmap.1
install -D --owner 0 --group 0 --mode a=r sysctl.conf.5 /usr/share/man/man5/sysctl.conf.5
install -D --owner 0 --group 0 --mode a=r vmstat.8 /usr/share/man/man8/vmstat.8
install -D --owner 0 --group 0 --mode a=r sysctl.8 /usr/share/man/man8/sysctl.8
install -D --owner 0 --group 0 --mode a=r slabtop.1 /usr/share/man/man1/slabtop.1
install -D --owner 0 --group 0 --mode a=r pwdx.1 /usr/share/man/man1/pwdx.1
install -D --owner 0 --group 0 --mode a=rx proc/libproc-3.2.6.so /lib/libproc-3.2.6.so
ldconfig
install -D --owner 0 --group 0 --mode a=rx ps/ps /bin/ps
install -D --owner 0 --group 0 --mode a=r ps/ps.1 /usr/share/man/man1/ps.1
rm -f /var/catman/cat1/ps.1.gz /var/man/cat1/ps.1.gz
cd /usr/bin/ && ln -f skill snice
cd /usr/bin/ && ln -f pgrep pkill
root:/sources/procps-3.2.6#
Procps 的内容
安装的程序: free, kill, pgrep, pkill, pmap, ps, skill, slabtop, snice, sysctl, tload, top, uptime, vmstat, w, watch
安装的库: libproc.so
简要描述
free |
报告系统中的空闲和已用内存数量(同时包括物理内存和交换内存) |
kill |
向进程发送消息 |
pgrep |
基于进程名及其属性来查找进程 |
pkill |
依据进程名及其属性向进程发送消息 |
pmap |
报告所告所给定进程的内存映射 |
ps |
显示当前正运行的进程列表 |
skill |
向符合所给标准的进程发送消息 |
slabtop |
实时显示内核 slap 缓冲的详细信息 |
snice |
改变符合所给标准的进程的调度优先权 |
sysctl |
在运行期间修改内核参数 |
tload |
打印当前系统平均负荷曲线图 |
top |
显示使用 CPU 最密集的进程列表,它提供了对实时的处理器行为的实时察看。 |
uptime |
报告系统运行了多久,有多少用户登录,以及系统平均负荷。 |
vmstat |
报告虚拟内存统计,并给出有关处进程、内存、块输入/输出(IO)、陷阱、CPU使用率。 |
w |
显示哪个用户登录,在哪里以及何时登录的。 |
watch |
重复运行所给的命令,以显示输出的第一次满屏,这将允许用户察看随时间变化的输出。 |
libproc |
含有该软件包中大多数程序所需使用的函数 |