LFS 学习日记(第六章安装基本系统软件之创建目录至 Glibc 安装 )

2010年07月09日 星期五
http://www.linuxfromscratch.org/lfs/view/6.6/chapter06/creatingdirs.html
6.5. Creating Directories

for dir in /usr /usr/local; do
  ln -sv share/{man,doc,info} $dir
done

ln -s share/man share/doc share/info /usr #在/usr下建立 man 的软链接,链接到同目录下的 share/man  create links to each TARGET in DIRECTORY.

ln -s man /usr/share/man-link #在/usr/share 建立到 /usr/share/man 的软链接 /usr/share/man-link * If two file names are given, `ln' creates a link to the first file from the second.

translation: The first mode change ensures that not just anybody can enter the /root directory—the same as a normal user would do with his or her home directory.

http://www.linuxfromscratch.org/lfs/view/6.6/chapter06/createfiles.html
6.6. Creating Essential Files and Symlinks

tranlation: Since we will not be mounting any file systems inside our chroot environment
语法: will not be doing sth.

todo: /etc/passwd 和 /etc/group 中用户和组的设立原因
todo: agetty 的使用 (getty  opens  a  tty  port,  prompts  for  a login name and invokes the /bin/login command. It is normally invoked by init(8).)

root:/sources/linux-2.6.32.15# time { make mrproper && make headers_check &&  make INSTALL_HDR_PATH=dest headers_install &&  find dest/include \( -name .install -o -name ..install.cmd \) -delete &&  cp -rv dest/include/* /usr/include; }

real    0m11.586s
user    0m2.188s
sys    0m12.537s

question:
find dest/include \( -name .install -o -name ..install.cmd \) -delete # man find:
( expr )
              Force precedence.  Since parentheses are special to  the  shell,
              you  will  normally need to quote them.  Many of the examples in
              this manual page use backslashes  for  this  purpose:  `\(...\)'
              instead of `(...)'.
find 里面的括号的意思是否像四则运算一样,加了括号就先计算? (1+2)*3=9 1+2*3=7 那么在这个 find 语句里面不加括号会有什么后果? 后果是不加括号就不会删除找到的文件,但是是为什么呢?

http://www.linuxfromscratch.org/lfs/view/6.6/chapter06/man-pages.html
6.8. Man-pages-3.23

这个man page 主要是内核相关的,一般的具体命令是具体命令的man page,这里有个man intro 关于各种常用命令的简介。

root:/sources/man-pages-3.23# time { make install; }
real    0m0.817s
user    0m0.028s
sys    0m0.800s

为了避免混淆,特地把netbook 上 PS1 改为: export PS1='(\#@\t)\u:\w\$'

http://www.linuxfromscratch.org/lfs/view/6.6/chapter06/glibc.html
6.9. Glibc-2.11.1

question: The Glibc build system is self-contained and will install perfectly, even though the compiler specs file and linker are still pointing at /tools. The specs and linker cannot be adjusted before the Glibc install because the Glibc autoconf tests would give false results and defeat the goal of achieving a clean build.
用在5.10. GCC-4.4.3 - Pass 2 中的方法测试的动态装载器仍是: /tools/lib/ld-linux.so.2 ,gcc -dumpspecs 里面的动态装载器仍是 /tools/lib/ld-linux.so.2 。但是为什么现在调整了specs 和 linker 就会导致autoconf 测试失败并导致不能完成一次干净的编译?

DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p') #

-n, --quiet, --silent   suppress automatic printing of pattern space

`.'     Matches any character, including newline.

`*'     Matches a sequence of zero or more instances of matches for the preceding regular expression,

`$'     It is the same as `^', but refers to end of pattern space.

\1      The replacement may contain the special character & to refer to that portion of the pattern space  which  matched,  and  the  special escapes  \1  through  \9  to refer to the corresponding matching sub-expressions in the regexp.

`p'     If the substitution was made, then print the new pattern space.

sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \ #

-Ldir           Add directory dir to the list of directories to be searched for -l.

 -llibrary
 -l library           Search the library named library when linking.

scripts/test-installation.pl
unset DL

2010年07月10日 星期六

case `uname -m` in
  i?86) echo "CFLAGS += -march=i486 -mtune=native -O3 -pipe" > configparms ;;
esac

-O3     Optimize yet more.  -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload and -ftree-vectorize options.

-pipe           Use pipes rather than temporary files for communication between the various stages of compilation.

question: 为什么第五章编译 glibc 不用上述的优化参数而这章用了?

todo: 在需要时详细学习 gcc 编译(优化)参数

glibc 配置选项:
 --enable-add-ons    This tells Glibc to use the NPTL add-on as its threading library.

Native POSIX Thread Library (NPTL): http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library

添加了几个locale:
localedef -i zh_CN -f UTF-8 zh_CN.UTF-8
localedef -i zh_TW -f BIG5 zh_TW.BIG5
localedef -i zh_TW -f UTF-8 zh_TW.UTF-8

todo: locale 相关的技术理解,如什么是 charset-independent locale definition 和 charmap definition 等

Individual locales can be installed using the localedef  program. E.g., the first localedef  command below combines the /usr/share/i18n/locales/cs_CZ  charset-independent locale definition with the /usr/share/i18n/charmaps/UTF-8.gz  charmap definition and appends the result to the /usr/lib/locale/locale-archive file.

question: /etc/nsswitch.conf 的作用和内容的意义
已学习了一下 man msswitch.conf, 作用主要是供 glibc 相关的函数读取配置信息,但是数据库名称后面跟的 files 是什么意思不明白。(这里的 man page 是属于Man-pages-3.23包的内容: Linux Programmer's Manual NSSWITCH.CONF(5))

question:
cp -f 选项:        -f, --force
              if an existing destination file cannot be opened, remove it  and
              try again (redundant if the -n option is used)
在什么情况下使用 -f 选项,如果存在可以打开的目的文件又怎么样?就不移除它保持不变吗?

make -k check 2>&1 | tee glibc-check-log # 2<&1 把错误信息也输出到标准输出设备(这里是终端),然后通过管道命令把标准输出作为标准输入传给 tee,由 tee 输出到文件 glibc-check-log 并同时输出到标准输出设备(这里是终端)。实际的效果就相当于同时在终端和文件中输出。原始的make -k check 2>&1 的输出信息并没有直接到标准输出设备和文件,而是通过管道传给了 tee 命令。

question:
书中说把timezone 的信息从比如 /usr/share/zoneinfo/Asia/Chongqing 复制到而不是软链接到 /etc/localtime 的原因是:有可能 /usr 在单独的分区上,如果启动进入单用户模式,就会出问题。 可是进入单用户模式会出现什么问题呢?难道软链接会被破坏?或者是单独的 /usr 分区不会挂载,在 Ubuntu 10.04 下测试,单用户single 模式仍然会挂载所有在 /etc/fstab 中确定的挂载项目。那书中说的是什么意思呢?

2010年07月12日 星期一
root:/sources/glibc-build# time { ../glibc-2.11.1/configure --prefix=/usr     --disable-profile --enable-add-ons     --enable-kernel=2.6.18 --libexecdir=/usr/lib/glibc && make; } 2>&1 | tee $LFS/backup/installlogs/6glibc.make.log
real    6m43.582s
user    6m17.000s
sys    5m52.990s

root:/sources/glibc-build# time { cp -v ../glibc-2.11.1/iconvdata/gconv-modules iconvdata && make -k check 2>&1 | tee glibc-check-log && grep Error glibc-check-log; }
real    10m17.327s
user    5m47.338s
sys    5m34.357s
测试只发现书中所说的预料之中可以忽略的错误,没有出现书中所说的多少依赖于宿主系统的错误。
mdx@u1004b2-desktop:/mnt/lfs/sources/glibc-build$ grep Error glibc-check-log
make[2]: [/sources/glibc-build/posix/annexc.out] Error 1 (ignored)

root:/sources/glibc-build# time { touch /etc/ld.so.conf && make install; } 2>&1 | tee $LFS/backup/installlogs/6glibc.install.log
real    1m35.289s
user    0m58.720s
sys    0m48.003s

总共的 SBU 值为: 18m36.198s (上面3个 real 值相加)。