星期五, 十一月 24, 2006

为 cable modem 接入配置 LFS network dhcp client

...未完...

LFS 可用的 dhcp client 有两个:dhcp 和 dhcpcd,前者包括一个服务器,因为没有必要安装服务,所以我选择后者:
# cat usr/src/dhcpcd/.config
pkgname = "dhcpcd";
version = "1.3.22";
group = "dhcpcd";
user = "dhcpcd";
archive = "dhcpcd-1.3.22-pl4.tar.gz";
patch = "dhcpcd-1.3.22-pl4-fhs-1.patch";
command = "tar xfz dhcpcd-1.3.22-pl4.tar.gz";
command = "cd dhcpcd-1.3.22-pl4";
command = "patch -Np1 -i ../dhcpcd-1.3.22-pl4-fhs-1.patch";
command = "./configure --prefix="" --sysconfdir=/var/lib";
command = "make";
command = "make install";
command = "cd ..";
command = "rm -rf dhcpcd-1.3.22-p14";
time = "20061125 19:34:15 Sat";

然后安装 blfs-bootscripts-6.1 的 dhcpcd script:
# tar xfj blfs-bootscripts-6.1.tar.bz2
# cd blfs-bootscripts-6.1
# make install-service-dhcpcd
这会在 /etc/sysconfig/network-devices/services 下安装一个 dhcpcd 脚本。

然后移除 /etc/sysconfig/network-devices/ifconfig.eth0/ipv4,编写:
cat > /etc/sysconfig/network-devices/ifconfig.eth0/dhcpcd << "EOF"
ONBOOT="yes"
SERVICE="dhcpcd"
# DHCP_START="[insert appropriate start options here]"
# DHCP_STOP="-k [insert additional stop options here]"
DHCP_STOP="-k"

# Set PRINTIP="yes" to have the script print
# the DHCP assigned IP address
PRINTIP="yes"

# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
PRINTALL="no"
EOF

然后运行 /etc/rc.d/init.d/network restart。

其基本机制是,/etc/rc.d/init.d/network 脚本会首先查找 /etc/sysconfig/network-devices/ifconfig.*,针对每个接口运行 /etc/sysconfig/network-devices/ifup,而这个脚本又会查找所有的配置文件逐一启用,例如 ifconfig.eth0,则会查看 ifconfig.eth0/*,所以如果有 ipv4 和 dhcpcd 则都会运行,所以前面移除 ipv4。对 dhcpcd,则会检查 ONBOOT 和 SERVICE 等参数,对 SERVICE="dhcpcd",则会寻找 /etc/sysconfig/network-devices/services/dhcpcd 以运行之。

gpm protocol

...未完...

# ls /dev/mouse -l
/dev/mouse -> input/mice
# gpm -m /dev/mouse -t help
查看所有的 protocol。

在主系统中查看 protocol:
# ps aux | grep gpm | cut -b 66-
gpm -m /dev/input/mice -t exps2

text web browser: w3m

text web browsers 有 lynx, links, elinks 和 w3m 等,但 lynx 比较晦涩,links 和 elinks 对中文的支持都不太好,所以使用 w3m。
首先要安装 gc(A garbage collector for C and C++)。以下是 userpack 的安装配置文件(profile):
# cat /usr/src/gc/.config
pkgname = "gc";
version = "6.8";
group = "gc";
user = "gc";
archive = "gc6.8.tar.gz";
command = "tar xfz gc6.8.tar.gz";
command = "cd gc6.8";
command = "./configure --prefix=/usr";
command = "make";
command = "make install";
command = "cd ..";
command = "rm -rf gc6.8";
time = "20061124 19:54:26 Fri";
这里使用 --prefix=/usr 可以避免装入 /usr/local/lib,否则下面安装 w3m 时,configure 会有问题。

然后安装 w3m。相关 profile 如下:
# cat /usr/src/w3m/.config
pkgname = "w3m";
version = "0.5.1";
group = "w3m";
user = "w3m";
archive = "w3m-0.5.1.tar.gz";
command = "tar xfz w3m-0.5.1.tar.gz";
command = "cd w3m-0.5.1";
command = "./configure --prefix=/usr --libexecdir=/usr/lib --sysconfdir=/etc";
command = "sed -i '/MAN1_JA/d' Makefile";
command = "make";
command = "make install";
command = "install -v -D -m 644 doc/keymap.default /etc/w3m/keymap";
command = "install -v -D -m 644 doc/menu.default /etc/w3m/menu";
command = "install -v -d -m 755 /usr/share/doc/w3m-0.5.1/html";
command = "install -v -m 644 doc/{HISTORY,README*,keymap.*,menu.*} /usr/share/doc/w3m-0.5.1";
command = "install -v -m 644 doc/*.html /usr/share/doc/w3m-0.5.1/html";
command = "cd ..";
command = "rm -rf w3m-0.5.1";
time = "20061125 06:15:34 Sat";
如果 gc 没有安装到 /usr,则 make 可以使用参数 LDFLAGS=/usr/local/lib。

sed -i '/MAN1_JA/d' Makefile
当使用 userpack 进行安装时,用上面这个命令阻止 w3m 安装日文的 man 手册,因为我没有将 /usr/man/$locale 加入到 /etc/userpack.dirs。如果要加入,应该使用这个命令:
# find /usr/man -type d -maxdepth 2 >>/etc/userpack.dirs

星期四, 十一月 23, 2006

sourceForge file release system

sourceforge file release system

在最下面选择"Add Release"来上传新的版本的文件。在编辑 Note 和 ChangeLog 之后(可直接上传文本),需要先通过 ftp 将上传的包及其相关文件上传到:
ftp://upload.sourceforge.net/incoming
中,然后在页面上 refresh 就可以看到需要的文件,选中后点击"upload"即可。

LFS kernel compling

之前构建 LFS 时直接使用了老系统的内核,将 vmlinuz 和 initrd.img 直接拷贝过去再编辑 grub.conf 的,系统可以启动。

但现在编译 Xorg-6.9.0 却有问题,在日志中有如下信息:
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
[drm] failed to load kernel module "i915"
(II) I810(0): [drm] drmOpen failed
(EE) I810(0): [dri] DRIScreenInit failed. Disabling DRI.

推测可能和内核有关,于是重新编译内核。将原理系统的 .config 文件拷贝过来。但 LFS 本身是没有 initrd 的,所以有几个模块必须编译到内核中才能保证系统可以启动。解档 initrd(initrd.img解档)后可以查看 lib 下的几个模块,这几个模块需要注意:
ahci.ko
ata_piix.ko
ext3.ko
jbd.ko
libata.ko
scsi_mod.ko
sd_mod.ko

在 make menuconfig 时将 SCSI disk support 和 ext3 file system 编译到内核中,但是 ahci.ko, ata_piix.ko 和 libata 不知道是哪个子选项,于是直接编辑 .config 文件:
# sed -i 's/CONFIG_SCSI_ATA_PIIX=m/CONFIG_SCSI_ATA_PIIX=y/' .config
# sed -i 's/CONFIG_SCSI_SATA=m/CONFIG_SCSI_SATA=y/' .config
# sed -i 's/CONFIG_SCSI_SATA_AHCI=m/CONFIG_SCSI_SATA_AHCI=y/' .config

星期三, 十一月 22, 2006

google homepage 添加待办事项来进行时间管理

可以进入"添加内容",搜索待办事项,或者直接加入如下 url:
http://www.google.com/ig/modules/todo.xml

我加了两个"todo list",一个"重要紧急"和一个"重要但不紧急",这样比较有计划。

initrd.img 解档

# cp /boot/initrd-$version.img /tmp
# cd /tmp
# cat initrd-$version.img | gunzip >initrdfs
# mkdir initrd
# cd initrd
# cpio -idv <../initrdfs

星期一, 十一月 20, 2006

svn simple tagging

$ svn copy file:///file/project/data/ea/crablfs/trunk file:///file/project/data/ea/crablfs/tags/v0.1.1alpha -m "tagging v0.1.1alpha"
Committed revision 59.
$ svn update

其中 $repos=/file/project/data/

星期日, 十一月 19, 2006

FC6 误删 /usr/lib/python2.4 之 rpm 恢复

Fedora Core 6 下调试 BLFS 时误删了 /usr/lib/python2.4,很多程序都不能跑了,可以如下方式恢复:

# cd
# mkdir pkg && cd pkg
# for pkg in `rpm -qa`; do echo $pkg; rpm -V $pkg >$pkg; done
// 校验所有的包
# for pkg in `du * | grep -v '^0' | awk '{print $2}'`; do echo "$pkg"; rpm -ivh /mnt/iso/Fedora/RPMS/$pkg.i386.rpm --force; done
// 如果记录非空,说明该包有问题,则重新安装之
// 有少数包是 noarch,手工安装一下即可

星期四, 十一月 16, 2006

jhalfs-1.0 LFS trouble shooting

参照:
http://chowroc.blogspot.com/2006/10/jhalfs-clfs.html
进行配置,注意这里是 LFS 而不是 CLFS。所以运行:
# ./lfs -B 6.2 -D /mnt/lfs -K ~lfs/skeleton/linux-kernel-config -F ~lfs/skeleton/etc/fstab -G -T 0 -M

但是编译 028-binutils-pass1 时出错,gcc 报告 /tools/bin/ld 的 --hash-style=gnu 无效:
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -o ld-new ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_i386.o ei386linux.o ../bfd/.libs/libbfd.a ../libiberty/libiberty.a
/tools/bin/ld: unrecognized option '--hash-style=gnu'
/tools/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make[2]: *** [ld-new] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make: *** [all-recursive-am] Error 2
make: Leaving directory `/mnt/lfs/sources/binutils-build/ld'

再次编译,configure 报告 compiler 不能 work,"can't create executables":
checking for gcc... gcc
checking whether the C compiler (gcc ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.

于是排错,发现 $LFS/jhalfs/lfs-commands/chapter04/022-addinguser 有 useradd 和 groupadd 命令,但之前已经创建了用户,所以肯定会出错,那么后面的:
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
两个命令就无法运行,权限检查的结果也是如此,$LFS/sources的属主没有被更改。

进一步,发现 $LFS/jhalfs/lfs-commands/chapter04/023-settingenvironment 没有产生实际的效果,在 ~lfs 下没有相应的 .bashrc 和 .bash_profile。显然,set +h 没有运行,所以这可能是导致报告 ld --hash-style=gnu 无法识别的原因吗?

于是手工添加了 ~lfs/.bashrc 和 ~/.bash_profile,再在 $LFS/jhalfs 下运行 make,但结果好像是整个进程挂起了,编译 binutils 一小时都没有结果,而手工编译却只要几分钟就结束了。查看进程树得到如下显示:
mlterm
\_ bash
\_ su -
\_ -bash
\_ make
\_ /bin/sh -c ( time { su - lfs -c "source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1" >>logs/028-binutils-pass1 2>&1 ; } ) 2>>logs/028-binutils-pass1 && \?echo -e "\nKB: `du -skx --exclude=jhalfs /mnt/lfs`\n" >>logs/028-binutils-pass1
\_ /bin/sh -c ( time { su - lfs -c "source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1" >>logs/028-binutils-pass1 2>&1 ; } ) 2>>logs/028-binutils-pass1 && \?echo -e "\nKB: `du -skx --exclude=jhalfs /mnt/lfs`\n" >>logs/028-binutils-pass1
\_ su - lfs -c source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1
\_ /bin/bash
/bin/bash ./progress_bar.sh 028-binutils-pass1
\_ sleep .12
好像是启动了一个 /bin/bash 但没有调用任何命令。

目录树是用如下方法得到的:
$ echo "roc 15754 0.0 0.5 10588 1344 ? S 16:16 0:01" | wc
1 10 65
$ ps auxf | cut -b 65-
(当然也可以用 pstree)

这是在 Fedora Core 6 环境下构建的,之后尝试 jhalfs-1.0 CLFS i386 却可以通过 binutils-pass1 这一段;并且最后通过使用 lfs-livecd 完成了安装!

所以只能推测是版本或平台的问题,可能是 FC6 太新,gcc-4.1.1 于 binutils-2.16.1 不能正确匹配(livecd 是 gcc-4.0.3)的原因。

星期三, 十一月 15, 2006

tor google/blogspot 语言问题

当使用 tor 访问 google 及其 blogspot 时,由于是通过代理访问,locale 的设置会受到影响,结果显示出来的可能是各种语言,根本看不懂,有两种方法解决。

其一是在 url 之后加 ?hl=en(没有其他参数时)或 &hl=en(前面已经有其他参数),例如:
http://beta.blogger.com/home?hl=en
http://beta.blogger.com/posts.g?blogID=6363462607047579738&hl=en

其二是对 blogspot,可以现直接进入:
http://beta.blogger.com/language.g
选择英文,则以后的会话都会以英文显示。

参考:
http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#GoogleLanguage