LFS 学习日记(修复原 LFS BOOK 中没有把 SBU 值和需要的磁盘空间解释清楚的问题 )

2010年07月01日 星期四
完善发现的LFS BOOK 开发版中措辞方面的问题。
svn co svn://svn.linuxfromscratch.org/LFS/trunk/BOOK/
取得开发版的xml源码,进入源码的顶级目录BOOK。

删除旧的源码,恢复源码备份,重新编译成HTML文档的命令:
cd ~/LFSBOOK-DEV; rm BOOK -fr; cp BOOK.bak* BOOK -a; \
~/fixa.sh ~/LFSBOOK-DEV/BOOK; cd ~/LFSBOOK-DEV/BOOK; \
rm ../HTML -fr; mkdir ../HTML; make BASEDIR=../HTML

1、 If SBU measure include test time?
http://linuxfromscratch.org/pipermail/lfs-support/2010-June/039092.html

因为电子邮件往往会限制每行的长度,所以长的字符串必须折断,但是直接在 sed 中折断又会引起替换的文字格式不对,于是,下面就把字符串分成小段赋在变量里,再在 sed 中引用对象进行操作。而且,sed 中如果使用单引号则变量或表达式都会变成纯粹的字符串。所以在下面的第二、三个 sed 语句中使用双引号(在LFS BOOK源码的BOOK目录下还有不用引号的例子 aux-file-data.sh ,但具体的用法有待学习。)。
<code>
#!/bin/bash
# usage: fixa.sh source_top_directory_full_path
# e.g., ./fixa.sh ~/LFS-DEV/BOOK
# For fixing a trivial wording issue about
# clarifying the approximate build SBU number
# and required disk space of the package.

if [ $# -lt 1 ] ; then
  echo "This script needs the location of the source top directory."
  exit 1
fi

cd $1

# Delete " testsuite included" from ./packages.ent
cp  -u packages.ent{,.orig}
sed 's/ testsuite included//g' \
packages.ent.orig > packages.ent
touch packages.ent.orig

# Add note into ./chapter05/binutils-pass1.xml
cp -u chapter05/binutils-pass1.xml{,.orig}
a="<para>Now prepare Binutils for compilation:</para>"
b="<note><para>The approximate build SBU\ "\
"number and required disk space\n\ \ \ \ "\
"of every package in Chapter 5 does\ "\
"not include testsuite.</para></note>\n\n\ \ \ \ &"
sed "s@$a@$b@" \
chapter05/binutils-pass1.xml.orig \
> chapter05/binutils-pass1.xml
touch chapter05/binutils-pass1.xml.orig

# Add note into ./chapter06/linux-headers.xml
cp -u chapter06/linux-headers.xml{,.orig}
a="<title>Installation of Linux API Headers</title>"
b="&\n\n\ \ \ \ <note><para>The approximate build\ "\
"SBU number and required disk space\n\ \ \ \ "\
"of every package which has testsuite in\ "\
"Chapter 6 includes testsuite.</para></note>"
sed "s@$a@$b@" \
chapter06/linux-headers.xml.orig \
> chapter06/linux-headers.xml
touch chapter06/linux-headers.xml.orig

exit 0
</code>

2010年07月02日 星期五
LFS 维护人员不接收上面这种脚本式的补丁,故在 LFS 专门的问题跟踪系统提交了一个Bug,并附上了用 diff 命令制作的补丁文件。并随即被维护人员作了一些修改后采用。

Ticket #2702 (new enhancement) clarifying the approximate build SBU
number and required disk space of the package
http://wiki.linuxfromscratch.org/lfs/ticket/2702

patch file:  
http://wiki.linuxfromscratch.org/lfs/attachment/ticket/2702/clarify-sbu-disk_space.patch

制作补丁:
cp BOOK BOOK.20100702 -a #把用 svn co svn://svn.linuxfromscratch.org/LFS/trunk/BOOK/ 命令下载的源码文件夹复制一份
cd BOOK.20100702 #进入复制的目录编辑源码并保存
cd .. #回到 BOOK 和 BOOK.20100702 所在的共同上级目录
diff -Nur BOOK BOOK.20100702 > clarify-sbu-disk_space.patch #用 diff 命令生成补丁,旧版本在前,新版本在后

在旧版本里应用补丁升级到新版本:
cd BOOK
patch -p1 < ../clarify-sbu-disk_space.patch #去掉 patch 文件里路径中的第一个 / 及之前的部分,即在 BOOK 目录中去掉路径中的 BOOK/,对之后路径中的文件应用补丁。如果是在 BOOK 的上层目录,则用 -p0 ,但是要保证是 patch 文件中的旧版本目录名,即是 BOOK。

diff 和 patch 命令维护源码的简易教程资料:
用Diff和Patch工具维护源码: http://www.ibm.com/developerworks/cn/linux/l-diffp/index.html

另外,今天向 LFS bug 跟踪系统提了一个 Bug 跟踪网站的可用性增强的 ticket  :
suggest make "New Ticket" link text alway
displaying on the top of LFS wiki website http://wiki.linuxfromscratch.org/lfs/ticket/2703

我觉得交流和热心对开源社区很重要,尽管有些看似不值一提的小问题,但是只要有益,就可以提出,“勿以善小而不为”嘛,甚至是错的也没关系,也是对自己的提高等。