设为首页收藏本站

LinuxTone | 运维专家网论坛 - 最棒的Linux运维与开源架构技术交流社区!

 找回密码
 注册

QQ登录

只需一步,快速开始

#公告#抱歉,网站将关闭,不再开放。由于PC时代已远逝 。在这个后移动互联网时代,我们继续携手前行,保持对技术的热情。共同构建linuxtone知识星球欢迎加入,一起讨论技术、招聘人才、分享资源。请新老linuxtone人 扫码移步到 知识星球:linuxtone

学习是一种信仰!分享是一种快乐!能力= 心态 * 沟通 * 知识 (你的每一天需要正能量!)

 网站的发展需要你贡献一份力量!希望你能每天坚持看贴1小时,并回答网友的问题!祝你在浏览论坛的过程中取得进步!谢谢!linuxtone加油!大家加油! 友情提示: 你今天学习了吗?你今天进步了吗?少一点抱怨!多一点进步!Life is short ! Why not linuxtone ?  

网站的发展、感谢每位坛友的努力!

查看: 4841|回复: 1

从源代码建立Linux系统系列之(Sysroot LFS 1.1) [复制链接]

Rank: 6Rank: 6

签到
44
注册时间
2009-1-21
最后登录
2014-4-22
在线时间
95 小时
阅读权限
70
积分
2690
帖子
127
主题
14
精华
0
UID
1131
发表于 2009-3-20 10:24:34 |显示全部楼层
源文地址:http://zdbr.net.cn/download/Sysroot-LFS-1.1.htm  作者:孙海勇

附:前言

 对于大多数制作过LFS的朋友,对于LFS通过 工具链->临时系统->基本系统 的模式应该已经比较熟悉了,不知道你是否想过在不影响制作结果的情况下能否将制作过程进行简化?我一直希望能尽可能的简化制作过程。
  在经历过CLFS-Sysroot的制作后,我对于Sysroot的制作方式颇为着迷,因此萌生了将Sysroot和LFS结合起来的想法,因此便有了本文,我将其命名为“Sysroot LFS”,同时我在制作过程中采用了gnu的hashstyle,在提高系统的性能上有一定的程度的提高。

更新日志(具体更新内容见文末):  2008年7月6日:1.1发布(可支持UTF-8编码的中文及其它文字在终端上直接显示)
  2008年6月8日(端午节):1.0 正式版发布
  2007年8月1日:试验版本发布

目录

  • 前言
  • 更新说明
  • 思想概要
  • 准备工作
    * 软件包及补丁下载
    * 创建用户
    * 加载分区
    * 创建制作基地
    * 设置用户环境
    * 创建目标系统目录结构
    * 创建必要文件
  • 工具链
    * linux-header-2.6.25.4
    * binutils-2.18 toolchain
    * glibc-header-2.7
    * gcc-4.2.4(static)
  • 目标系统C库
    * glibc-2.7
  • 最基本的目标系统
    * 设置编译参数
    * binutils-2.18
    * gcc-4.2.4
    * sed-4.1.5
    * bash-3.2(tools)
    * grep-2.5.3
    * coreutils-6.12
    * make-3.81
    * diffutils-2.8.7
    * gawk-3.1.6
    * gzip-1.3.12
    * tar-1.20
  • 目标系统
    * 设置目标系统环境
    * 进入目标系统
    * patch-2.5.9
    * bzip2-1.0.5
    * findutils-4.4.0
    * gcc-4.2.4 bootstrap
    * ncurses-5.6
    * gettext-0.17
    * texinfo-4.12
    * Berkeley db-4.7.25
    * iana-etc-2.30
    * e2fsprogs-1.40.10
    * m4-1.4.11
    * bison-2.3
    * procps-3.2.7
    * libtool-2.2.4
    * zlib-1.2.3
    * utils-linux-ng-2.13.1.1
    * perl-5.8.8
    * readline-5.2
    * autoconf-2.62
    * automake-1.10.1
    * bash-3.2
    * file-4.24
    * flex-2.5.35
    * groff-1.19.2
    * inetutils-1.5
    * iproute2-2.6.25
    * kbd-1.14.1
    * less-418
    * man-db-2.5.2
    * mktemp-1.5(取消)
    * module-init-tools-3.4
    * psmisc-22.6
    * shadow-4.0.18.1
    * sysklogd-1.5
    * sysvinit-2.86
    * udev-122
    * vim-7.1
    * grub-0.97
    * lfs-bootscripts-20080522
    * linux-2.6.25.4
  • 设置置系统
    * 配置文件
    * 设置grub
  • 附加应用
    * bc-1.06
    * openssl-0.9.8h
    * wget-1.11.3
     
前言
  对于大多数制作过LFS的朋友,对于LFS通过 工具链->临时系统->基本系统 的模式应该已经比较熟悉了,不知道你是否想过在不影响制作结果的情况下能否将制作过程进行简化?我一直希望能尽可能的简化制作过程。
  在经历过CLFS-Sysroot的制作后,我对于Sysroot的制作方式颇为着迷,因此萌生了将Sysroot和LFS结合起来的想法,因此便有了本文,我将其命名为“Sysroot LFS”,同时我在制作过程中采用了gnu的hashstyle,在提高系统的性能上有一定的程度的提高。
  本文力争完成一个完整的制作命令,可以根据本文提供的命令顺序输入就可以完成系统的制作了,通常命令表示为
命令更新说明:  由于篇幅比较长所以难免出现一些错误或者笔误,也有可能加入新内容,因此难免会进行修正或增删一些内容,如果本文被转载可以在本人的Blog中查看最新版本。
  我的Blog:http://youbest.cublog.cn
  如须转载请注明作者为孙海勇,并提供转载出处。

思想概要:
  本文所使用的方法是:
    工具链->最小可扩展系统->基本系统
  
这里和LFS不同的是:LFS用工具链制作了“临时系统”,而Sysroot LFS则用工具链制作了一个最小的可扩展的系统,LFS的“临时系统”将不会出现在最终的基本系统中,而Sysroot LFS的“最小可扩展系统”是作为最终的基本系统中的一部分。
  “工具链->最小可扩展系统”这部分工作的原理完全等同于CLFS-Sysroot中的方式,而制作“基本系统”的方法却采用了LFS的chroot的模式。
  Sysroot LFS的方式还可以用于制作从32到64位系统的制作,当然前提是CPU和主系统的内核是支持64位的。
  基本过程:
                1、先利用主系统完成一个使用了sysroot方式编译的工具链(包括gcc和binutils、目标系统的内核和基本C库的头文件)
                2、利用工具链完成一个最小系统,这个最小系统需要满足能够自我进行扩展的能力,也就是可以在这个小系统上进行编译。
                3、利用这个最小的可扩展系统编译生成最终的基本系统。
  本文还采用了目前比较新的gnu的Hash-Style,这对于在程序执行过程中定位库中的函数有比较明显的优势,因此也能导致整个系统的性能有所提高。

准备工作
 

* 软件包及补丁下载
  软件包下载:
    可参考LFS手册中的下载页面中的指引。
  补丁下载:
    http://www.zdbr.net.cn/download/sysroot-lfs-patch-1.0.tar.bz2
  UTF-8字符显示补丁下载:
    此补丁可以用来在终端下的framebuffer环境下显示UTF-8编码的中文及其它文字。
    http://www.zdbr.net.cn/download/ ... 25-core-1.patch.bz2

    http://www.zdbr.net.cn/download/ ... 5-fonts-1.patch.bz2


* 创建用户
groupadd slfsuseradd -s /bin/bash -g slfs -m -k /dev/null slfspasswd slfs
* 加载分区
mkdir /slfs
mount /dev/hda2 /slfs
* 创建制作基地

export TARGET_DIR="/slfs"
mkdir ?pv ${TARGET_DIR}/{build,download}
chown ?Rv slfs ${TARGET_DIR}
* 设置用户环境

su ? slfs
cat > ~/.bash_profile << "EOF"
exec env ?i HOME=${HOME} TERM="${TERM}" PS1='\u:\w\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
export TARGET_DIR="/slfs"
export LC_ALL=POSIX
export BUILD_DIR="${TARGET_DIR}/build"
export DOWNLOAD_DIR="${TARGET_DIR}/download"
export BUILD_TARGET=${MACHTYPE}
export BUILD_HOST=${BUILD_TARGET}.old
export PATH=${TARGET_DIR}/systools/bin:/bin:/usr/bin
unset CFLAGS
unset CXXFLAGS
EOF
source ~/.bash_profile

* 创建目标系统目录结构

pushd ${TARGET_DIR}
mkdir -pv {bin,boot,dev,{etc/,}opt,home,lib,mnt}
mkdir -pv {proc,media/{floppy,cdrom},sbin,srv,sys}
mkdir -pv var/{lock,log,mail,run,spool}
mkdir -pv var/{opt,cache,lib/{misc,locate},local}
install -dv -m 0750 root
install -dv -m 1777 {var/,}tmp
mkdir -pv usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv usr/{,local/}share/{doc,info,locale,man}
mkdir -pv usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv usr/{,local/}share/man/man{1..8}
for dir in usr{,/local}; do
  ln -sv share/{man,doc,info} $dir
done
cd boot
ln -svf . boot
popd
* 创建必要文件

cat > ${TARGET_DIR}/etc/passwd << "EOF"
root::0:0:root:/root:/bin/bash
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
EOF

cat > ${TARGET_DIR}/etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
uucp:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
mail:x:34:
nogroup:x:99:
EOF

touch ${TARGET_DIR}/var/run/utmp ${TARGET_DIR}/var/log/{btmp,lastlog,wtmp}
chmod -v 664 ${TARGET_DIR}/var/run/utmp ${TARGET_DIR}/var/log/lastlog

工具链

* linux-header-2.6.25.4

tar xvf ${DOWNLOAD_DIR}/linux-2.6.25.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/linux-2.6.25.4
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp ?rv dest/include/* ${TARGET_DIR}/usr/include
popd
rm -r ${BUILD_DIR}/linux-2.6.25.4

* binutils-2.18 toolchain

tar xvf ${DOWNLOAD_DIR}/binutils-2.18.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/binutils-2.18
mkdir ?v ../binutils-build
cd ../binutils-build
CC="gcc" AR="ar" ../binutils-2.18/configure --prefix=${TARGET_DIR}/systools \        --build=${BUILD_HOST} --target=${BUILD_TARGET} \
        --with-sysroot=${TARGET_DIR} --disable-nls --enable-shared --disable-multilib
make configure-host
make
make install
cp ?v ../binutils-2.18/include/libiberty.h ${TARGET_DIR}/usr/include
popd
rm -r ${BUILD_DIR}/binutils-2.18
rm -r ${BUILD_DIR}/binutils-build
* glibc-header-2.7

tar xvf ${DOWNLOAD_DIR}/glibc-2.7.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/glibc-2.7
cp configure{,.orig}
sed -e 's/3.4/3.[0-9]/g' configure.orig > configure
mkdir -v ../glibc-build
cd ../glibc-build
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_386_tls=yes" >> config.cache
echo "install_root=${TARGET_DIR}" > configparms
CC=gcc ../glibc-2.7/configure --prefix=/usr --host=${BUILD_TARGET} --build=${BUILD_HOST} \
         --with-headers=${TARGET_DIR}/usr/include --cache-file=config.cache
make install-headers
cp -v bits/stdio_lim.h ${TARGET_DIR}/usr/include/bits
touch ${TARGET_DIR}/usr/include/gnu/stubs.h
cp -v ../glibc-2.7/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h ${TARGET_DIR}/usr/include/bits
popd
rm -rf ${BUILD_DIR}/glibc-2.7
rm -rf ${BUILD_DIR}/glibc-build
* gcc-4.2.4(static)

tar xvf ${DOWNLOAD_DIR}/gcc-4.2.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gcc-4.2.4
patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.2.4-cross_search_paths-1.patch
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.2.4/configure --prefix=${TARGET_DIR}/systools --host=${BUILD_HOST} \
       --target=${BUILD_TARGET} --with-sysroot=${TARGET_DIR} --disable-nls \
       --disable-shared --disable-threads --disable-multilib --enable-languages=c
make all-gcc
make install-gcc
popd
rm -rf ${BUILD_DIR}/gcc-4.2.4
rm -rf ${BUILD_DIR}/gcc-build

目标系统C库

* glibc-2.7

tar xvf ${DOWNLOAD_DIR}/glibc-2.7.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/glibc-2.7
patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.7-libgcc_eh-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.7-localedef_segfault-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.7-cross_hacks.patch
mkdir -v ../glibc-build
cd ../glibc-build
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "install_root=${TARGET_DIR}" > configparms
BUILD_CC="gcc" CC="${BUILD_TARGET}-gcc -Wl,--hash-style=gnu" AR="${BUILD_TARGET}-ar" \          RANLIB="${BUILD_TARGET}-ranlib" \          CFLAGS="-march=$(cut -d- -f1 <<< ${BUILD_TARGET}) -mtune=generic -g -O2" ../glibc-2.7/configure \
          --prefix=/usr --libexecdir=/usr/lib/glibc --host=${BUILD_TARGET} --build=${BUILD_HOST} \
                    --disable-profile --enable-add-ons --with-tls --enable-kernel=2.6.18 --with-__thread \
          --with-binutils=${TARGET_DIR}/systools/bin --with-headers=${TARGET_DIR}/usr/include \          --cache-file=config.cache
       修改glibc-2.7/Makeconfig中-Wl,--hash-style=both去掉
sed -i 's@,--hash-style=both@@g' ../glibc-2.7/Makeconfig
 
    
make
make install
make localedata/install-locales
cat > ${TARGET_DIR}/etc/nsswitch.conf << “EOF”
passwd: files
group: files
shadow: files
hosts: files dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
EOF

cp -v --remove-destination ${TARGET_DIR}/usr/share/zoneinfo/Asia/Shanghai \
      ${TARGET_DIR}/etc/localtime
cat > ${TARGET_DIR}/etc/ld.so.conf << "EOF"
/usr/local/lib
/opt/lib
EOF
popd
rm -rf ${BUILD_DIR}/glibc-2.7
rm -rf ${BUILD_DIR}/glibc-build


最基本的目标系统

* 设置编译参数

export LDFLAGS="-Wl,--hash-style=gnu"
echo "export LDFLAGS=\"-Wl,--hash-style=gnu\"" >> ~/.bashrc
* binutils-2.18

tar xvf ${DOWNLOAD_DIR}/binutils-2.18.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/binutils-2.18
mkdir -pv ../binutils-build
cd ../binutils-build
../binutils-2.18/configure \
        --prefix=/usr --build=${BUILD_HOST} --host=${BUILD_TARGET} \
        --enable-shared --disable-multilib
make configure-host
make tooldir=/usr
make DESTDIR=${TARGET_DIR} tooldir=/usr install
cp -v ../binutils-2.18/include/libiberty.h ${TARGET_DIR}/usr/include
popd
rm -rf ${BUILD_DIR}/binutils-2.18
rm -rf ${BUILD_DIR}/binutils-build
* gcc-4.2.4

tar xvf ${DOWNLOAD_DIR}/gcc-4.2.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gcc-4.2.4

cp libiberty/Makefile.in{,.orig} &&
sed 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in.orig \
    > libiberty/Makefile.in
cp gcc/gccbug.in{,.orig} &&
sed 's/@have_mktemp_command@/yes/' gcc/gccbug.in.orig > gcc/gccbug.in
cp gcc/Makefile.in{,.orig} &&
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in

mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.2.1/configure --prefix=/usr \
        --libexecdir=/usr/lib --build=${BUILD_HOST} --host=${BUILD_TARGET} \
        --target=${BUILD_TARGET} --enable-shared --enable-threads=posix \
        --enable-__cxa_atexit --enable-c99 --enable-long-long \
        --enable-clocale=gnu --enable-languages=c --disable-multilib
make
make DESTDIR=${TARGET_DIR} install
ln -sv ../usr/bin/cpp ${TARGET_DIR}/lib
ln -sv gcc ${TARGET_DIR}/usr/bin/cc

popd
rm -rf ${BUILD_DIR}/gcc-4.2.4
rm -rf ${BUILD_DIR}/gcc-build

* sed-4.1.5

tar xvf ${DOWNLOAD_DIR}/sed-4.1.5.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/sed-4.1.5

./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} \
        --prefix=/usr --bindir=/bin --enable-html
make
make DESTDIR=${TARGET_DIR} install
popd
rm -rf ${BUILD_DIR}/sed-4.1.5

* bash-3.2(tools)

tar xvf ${DOWNLOAD_DIR}/bash-3.2.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/bash-3.2
patch -Np1 -i ${DOWNLOAD_DIR}/bash-3.2-fixes-7.patch
./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} \
      --prefix=${TARGET_DIR}/systools --without-bash-malloc
sed -i 's@$(LDFLAGS)@-L./lib/termcap $(LOCAL_LDFLAGS) $(CFLAGS)@g' builtins/Makefile
make
make install
popd
rm -rf ${BUILD_DIR}/bash-3.2

* grep-2.5.3

tar xvf ${DOWNLOAD_DIR}/grep-2.5.3.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/grep-2.5.3

./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} \
        --prefix=/usr --bindir=/bin --disable-perl-regexp
make
make DESTDIR=${TARGET_DIR} install

popd
rm -rf ${BUILD_DIR}/grep-2.5.3

* coreutils-6.12

tar xvf ${DOWNLOAD_DIR}/coreutils-6.12.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/coreutils-6.12
patch -Np1 -i ${DOWNLOAD_DIR}/coreutils-6.12-uname-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/coreutils-6.12-cross_compiler-1.patch
sed -i "s/futimens/gl_&/" $(grep -lr futimens *)
touch man/uname.1 man/touch.1 man/hostname.1
echo "fu_cv_sys_stat_statfs2_bsize=yes" > config.cache
./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr \
        --enable-install-program=hostname --enable-no-install-program=kill,uptime \
        --cache-file=config.cache
make
make DESTDIR=${TARGET_DIR} install

mv -v ${TARGET_DIR}/usr/bin/{cat,chgrp,chmod,chown,cp,date} ${TARGET_DIR}/bin
mv -v ${TARGET_DIR}/usr/bin/{dd,df,echo,false,hostname,ln,ls,mkdir,mknod} ${TARGET_DIR}/bin
mv -v ${TARGET_DIR}/usr/bin/{mv,pwd,rm,rmdir,stty,true,uname} ${TARGET_DIR}/bin
mv -v ${TARGET_DIR}/usr/bin/chroot ${TARGET_DIR}/usr/sbin
mv -v ${TARGET_DIR}/usr/bin/{[,basename,head,nice} ${TARGET_DIR}/bin
mv -v ${TARGET_DIR}/usr/bin/{readlink,sleep,sync,test,touch} ${TARGET_DIR}/bin
popd
rm -rf {BUILD_DIR}/coreutils-6.12

* make-3.81

tar xvf ${DOWNLOAD_DIR}/make-3.81.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/make-3.81

./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr
make
make DESTDIR=${TARGET_DIR} install
popd
rm -rf ${BUILD_DIR}/make-3.81

* diffutils-2.8.7

tar xvf ${DOWNLOAD_DIR}/diffutils-2.8.7.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/diffuils-2.8.7
touch man/diff.1
./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr
make
make DESTDIR=${TARGET_DIR} install
popd
rm -rf ${BUILD_DIR}/diffutils-2.8.7

* gawk-3.1.6

tar xvf ${DOWNLOAD_DIR}/gawk-3.1.6.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gawk-3.1.6

./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr --libexecdir=/usr/lib
make
make DESTDIR=${TARGET_DIR} install
popd
rm -rf ${BUILD_DIR}/gawk-3.1.6

* gzip-1.3.12

tar xvf ${DOWNLOAD_DIR}/gzip-1.3.12.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gzip-1.3.12

sed -i "s/futimens/gl_&/" $(grep -lr futimens *)
./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr --bindir=/bin
make
make DESTDIR=${TARGET_DIR} install
mv -v ${TARGET_DIR}/bin/{gzexe,uncompress,zcmp,zdiff,zegrep} ${TARGET_DIR}/usr/bin
mv -v ${TARGET_DIR}/bin/{zfgrep,zforce,zgrep,zless,zmore,znew} ${TARGET_DIR}/usr/bin
popd
rm -rf ${BUILD_DIR}/gzip-1.3.12

* tar-1.20

tar xvf ${DOWNLOAD_DIR}/tar-1.20.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/tar-1.20
./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr
make
make DESTDIR=${TARGET_DIR} install
popd
rm -rf ${BUILD_DIR}/tar-1.20

目标系统
以root用户身份执行下面的命令
 
* 设置目标系统环境

export TARGET_DIR="/slfs"
mknod -m 600 ${TARGET_DIR}/dev/console c 5 1
mknod -m 666 ${TARGET_DIR}/dev/null c 1 3
mount -v --bind /dev ${TARGET_DIR}/dev
mount -vt devpts devpts ${TARGET_DIR}/dev/pts
mount -vt tmpfs shm ${TARGET_DIR}/dev/shm
mount -vt proc proc ${TARGET_DIR}/proc
mount -vt sysfs sysfs ${TARGET_DIR}/sys
* 进入目标系统

ln -sv /systools/bin/bash ${TARGET_DIR}/bin/bash
ln -sv bash ${TARGET_DIR}/bin/sh
chroot ${TARGET_DIR} /usr/bin/env -i HOME=/root TERM="${TERM}" LDFLAGS="-Wl,--hash-style=gnu" PS1='\u:\w\$ ' \
       PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login +h
export DOWNLOAD_DIR=/download
export BUILD_DIR=/build

* patch-2.5.9

tar xvf ${DOWNLOAD_DIR}/patch-2.5.9.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/patch-2.5.9
./configure --prefix=/usr
make
make install

popd
rm -rf ${BUILD_DIR}/patch-2.5.9

* bzip2-1.0.5

tar xvf ${DOWNLOAD_DIR}/bzip2-1.0.5.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/bzip2-1.0.5

patch -Np1 -i ${DOWNLOAD_DIR}/bzip2-1.0.5-install_docs-1.patch
make -f Makefile-libbz2_so
make clean
make
make PREFIX=/usr install
cp -v bzip2-shared /bin/bzip2
cp -av libbz2.so* /lib
ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm -v /usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 /bin/bunzip2
ln -sv bzip2 /bin/bzcat
popd
rm -rf ${BUILD_DIR}/bzip2-1.0.5

* findutils-4.4.0

tar xvf ${DOWNLOAD_DIR}/findutils-4.4.0 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/findutils-4.4.0

./configure --prefix=/usr --libexecdir=/usr/lib/findutils --localstatedir=/var/lib/locate
make
make install
mv -v /usr/bin/find /bin
sed -i -e 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb
popd
rm -rf ${BUILD_DIR}/findutils-4.4.0

* gcc-4.2.4 bootstrap

tar xvf ${DOWNLOAD_DIR}/gcc-4.2.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gcc-4.2.4

sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
sed -i 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in
sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.2.4/configure --host=$(gcc -dumpmachine) --prefix=/usr \
          --libexecdir=/usr/lib --enable-shared \
          --enable-threads=posix --enable-__cxa_atexit \
          --enable-clocale=gnu --enable-languages=c,c++
make BOOT_LDFLAGS="-Wl,--hash-style=gnu" bootstrap
make install
popd
rm -rf ${BUILD_DIR}/gcc-4.2.4
rm -rf ${BUILD_DIR}/gcc-build

* ncurses-5.6

tar xvf ${DOWNLOAD_DIR}/ncurses-5.6.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/ncurses-5.6

patch -Np1 -i ${DOWNLOAD_DIR}/ncurses-5.6-coverity_fixes-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/ncurses-5.6-bash_fix-1.patch
./configure --prefix=/usr --with-shared --without-debug --enable-widec --build=$(gcc -dumpmachine)
make
make install
chmod -v 644 /usr/lib/libncurses++w.a
mv -v /usr/lib/libncursesw.so.5* /lib
ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so
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
rm -vf /usr/lib/libcursesw.so
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

popd
rm -rf ${BUILD_DIR}/ncurses-5.6

* gettext-0.17

tar xvf ${DOWNLOAD_DIR}/gettext-0.17.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gettext-0.17

./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/gettext-0.17

* texinfo-4.12

tar xvf ${DOWNLOAD_DIR}/texinfo-4.12.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/texinfo-4.12

./configure --prefix=/usr
make
make install
make TEXMF=/usr/share/texmf install-tex
cd /usr/share/info
rm dir
for f in *
  do install-info $f dir 2>/dev/null
done
popd
rm -rf ${BUILD_DIR}/texinfo-4.12

* Berkeley db-4.7.25

tar xvf ${DOWNLOAD_DIR}/db-4.7.25.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}
cd build_unix
../dist/configure --prefix=/usr --enable-compat185 --enable-cxx
make
make docdir=/usr/share/doc/db-4.7.25 install
chown -Rv root:root /usr/share/doc/db-4.7.25
popd
rm -rf ${BUILD_DIR}/db-4.7.25

* iana-etc-2.30

tar xvf ${DOWNLOAD_DIR}/iana-etc-2.30.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/iana-etc-2.30

make
make install
popd
rm -rf ${BUILD_DIR}/iana-etc-2.30

* e2fsprogs-1.40.10

tar xvf ${DOWNLOAD_DIR}/e2fsprogs-1.40.10.tar.gz ${BUILD_DIR}
pushd ${BUILD_DIR}/e2fsprogs-1.40.10

mkdir -v build
cd build
../configure --prefix=/usr --with-root-prefix="" \
         --enable-elf-shlibs
make LDFLAGS="${LDFLAGS}"
make install
make install-libs
popd
rm -rf ${BUILD_DIR}/e2fsprogs-1.40.10

* m4-1.4.11

tar xvf ${DOWNLOAD_DIR}/m4-1.4.11.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/m4-1.4.11
./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/m4-1.4.11

* bison-2.3

tar xvf ${DOWNLOAD_DIR}/bison-2.3.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/bison-2.3
./configure --prefix=/usr
echo '#define YYENABLE_NLS 1' >> config.h
make
make install
popd
rm -rf ${BUILD_DIR}/bison-2.3

* procps-3.2.7

tar xvf ${DOWNLOAD_DIR}/procps-3.2.7.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/procps-3.2.7

make LDFLAGS="-Wl,--hash-style=gnu"
make install
popd
rm -rf ${BUILD_DIR}/procps-3.2.7

* libtool-2.2.4

tar xvf ${DOWNLOAD_DIR}/libtool-2.2.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/libtool-2.2.4

./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/libtool-2.2.4

* zlib-1.2.3

tar xvf ${DOWNLOAD_DIR}/zlib-1.2.3.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/zlib-1.2.3

./configure --prefix=/usr --shared --libdir=/lib
make
make install
rm -v /lib/libz.so
ln -sfv ../../lib/libz.so.1.2.3 /usr/lib/libz.so
make clean
./configure --prefix=/usr
make
make install
chmod -v 644 /usr/lib/libz.a

popd
rm -rf ${BUILD_DIR}/zlib-1.2.3

* utils-linux-ng-2.13.1.1

tar xvf ${DOWNLOAD_DIR}/util-linux-ng-2.13.1.1.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/util-linux-ng-2.13.1.1

sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' -i $(grep -rl '/etc/adjtime' .)
mkdir -pv /var/lib/hwclock
./configure
make
make install

popd
rm -rf ${BUILD_DIR}/util-linux-ng-2.13.1.1

* perl-5.8.8

tar xvf ${DOWNLOAD_DIR}/perl-5.8.8.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/perl-5.8.8
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
cp makedepend.SH{,.orig}
sed 's/<command line>/<command-line>/g' makedepend.SH.orig > makedepend.SH
patch -Np1 -i ${DOWNLOAD_DIR}/perl-5.8.8-page_h-1.patch
./configure.gnu --prefix=/usr \
        -Dman1dir=/usr/share/man/man1 \
        -Dman3dir=/usr/share/man/man3 \
        -Dpager="/usr/bin/less -isR"
make
make install

popd
rm -rf ${BUILD_DIR}/perl-5.8.8

* readline-5.2

tar xvf ${DOWNLOAD_DIR}/readline-5.2.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/readline-5.2

sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install
patch -Np1 -i ${DOWNLOAD_DIR}/readline-5.2-fixes-5.patch
./configure --prefix=/usr --libdir=/lib
make SHLIB_LIBS=-lncurses
make install
mv -v /lib/lib{readline,history}.a /usr/lib
rm -v /lib/lib{readline,history}.so
ln -sfv ../../lib/libreadline.so.5 /usr/lib/libreadline.so
ln -sfv ../../lib/libhistory.so.5 /usr/lib/libhistory.so
popd
rm -rf ${BUILD_DIR}/readline-5.2

* autoconf-2.62

tar xvf ${DOWNLOAD_DIR}/autoconf-2.62.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/autoconf-2.62
./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/autoconf-2.62

* automake-1.10.1

tar xvf ${DOWNLOAD_DIR}/automake-1.10.1.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/automake-1.10.1

./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/automake-1.10.1

* bash-3.2

tar xvf ${DOWNLOAD_DIR}/bash-3.2.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/bash-3.2
tar -xvf ${DOWNLOAD_DIR}/bash-doc-3.2.tar.gz
sed -i "s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.2|" \
Makefile.in
patch -Np1 -i ${DOWNLOAD_DIR}/bash-3.2-fixes-7.patch
./configure --prefix=/usr --bindir=/bin \
        --without-bash-malloc --with-installed-readline
make
make install
exec /bin/bash --login +h

popd
rm -rf ${BUILD_DIR}/bash-3.2

* file-4.24

tar xvf ${DOWNLOAD_DIR}/file-4.24.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/file-4.24

./configure --prefix=/usr
make
make install
popd
rm -rf ${BUILD_DIR}/file-4.24

* flex-2.5.35

tar xvf ${DOWNLOAD_DIR}/flex-2.5.35.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/flex-2.5.35

./configure --prefix=/usr
make
make install
ln -sv libfl.a /usr/lib/libl.a
cat > /usr/bin/lex << “EOF”
#!/bin/sh
exec /usr/bin/flex -l “$@”
EOF
chmod -v 755 /usr/bin/lex
popd
rm -rf ${BUILD_DIR}/flex-2.5.35

* groff-1.19.2

tar xvf ${DOWNLOAD_DIR}/groff-1.19.2.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/groff-1.19.2

sed -i -e 's/2010/002D/' -e 's/2212/002D/' \
       -e 's/2018/0060/' -e 's/2019/0027/' font/devutf8/R.proto
PAGE=A4 ./configure --prefix=/usr --enable-multibyte
make
make install
ln -sv eqn /usr/bin/geqn
ln -sv tbl /usr/bin/gtbl

popd
rm -rf ${BUILD_DIR}/groff-1.19.2

* inetutils-1.5

tar xvf ${DOWNLOAD_DIR}/inetutils-1.5.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/inetutils-1.5

patch -Np1 -i ${DOWNLOAD_DIR}/inetutils-1.5-no_server_man_pages-2.patch
./configure --prefix=/usr --libexecdir=/usr/sbin \
        --sysconfdir=/etc --localstatedir=/var \
        --disable-ifconfig --disable-logger --disable-syslogd \
        --disable-whois --disable-servers
make
make install
mv -v /usr/bin/ping /bin
popd
rm -rf ${BUILD_DIR}/inetutils-1.5

* iproute2-2.6.25

tar xvf ${DOWNLOAD_DIR}/iproute2-2.6.25 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/iproute2-2.6.25

sed -i -e '/tc-bfifo.8/d' -e '/tc-pfifo.8/s/pbfifo/bfifo/' Makefile
make SBINDIR=/sbin
make SBINDIR=/sbin install
mv -v /sbin/arpd /usr/sbin

popd
rm -rf ${BUILD_DIR}/iproute2-2.6.25

* kbd-1.14.1

tar xvf ${DOWNLOAD_DIR}/kbd-1.14.1.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/kbd-1.14.1

patch -Np1 -i ${DOWNLOAD_DIR}/kbd-1.14.1-backspace-1.patch

sed -i -e '1i KEYCODES_PROGS = @KEYCODES_PROGS@' \
       -e '1i RESIZECONS_PROGS = @RESIZECONS_PROGS@' src/Makefile.in
var=OPTIONAL_PROGS
sed -i "s/ifdef $var/ifeq (\$($var),yes)/" man/Makefile.in
unset var

./configure --prefix=/usr --datadir=/lib/kbd
make LDFLAGS="${LDFLAGS}"
make install
mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin
popd
rm -rf ${BUILD_DIR}/kbd-1.14.1

* less-418

tar xvf ${DOWNLOAD_DIR}/less-418.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/less-418

./configure --prefix=/usr --sysconfdir=/etc
make
make install

popd
rm -rf ${BUILD_DIR}/less-418

* man-db-2.5.2

tar xvf ${DOWNLOAD_DIR}/man-db-2.5.2.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/man-db-2.5.2

sed -i -e '\%\t/usr/man%d' -e '\%\t/usr/local/man%d' src/man_db.conf.in

cat >> include/manconfig.h.in << "EOF"
#define WEB_BROWSER "exec /usr/bin/lynx"
#define COL "/usr/bin/col"
#define VGRIND "/usr/bin/vgrind"
#define GRAP "/usr/bin/grap"
EOF

./configure --prefix=/usr --libexecdir=/usr/lib --sysconfdir=/etc \
        --disable-setuid
make
make install

cat >> convert-mans << "EOF"
#!/bin/sh -e
FROM="$1"
TO="$2"
shift ; shift
while [ $# -gt 0 ]
do
FILE="$1"
shift
iconv -f "$FROM" -t "$TO" "$FILE" >.tmp.iconv
mv .tmp.iconv "$FILE"
done
EOF
install -m755 convert-mans /usr/bin
popd
rm -rf ${BUILD_DIR}/man-db-2.5.2

* module-init-tools-3.4

tar xvf ${DOWNLOAD_DIR}/module-init-tools-3.4.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/module-init-tools-3.4
patch -Np1 -i ${DOWNLOAD_DIR}/module-init-tools-3.4-manpages-1.patch
make distclean
./configure --prefix=/ --enable-zlib
make
make INSTALL=install install

popd
rm -rf ${BUILD_DIR}/module-init-tools-3.4

* psmisc-22.6

tar xvf ${DOWNLOAD_DIR}/psmisc-22.6.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/psmisc-22.6

./configure --prefix=/usr --exec-prefix=""
make
make install
mv -v /bin/pstree* /usr/bin
ln -sv killall /bin/pidof
popd
rm -rf ${BUILD_DIR}/psmisc-22.6

* shadow-4.0.18.1

tar xvf ${DOWNLOAD_DIR}/shadow-4.0.18.1.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/shadow-4.0.18.1
patch -Np1 -i ${DOWNLOAD_DIR}/shadow-4.0.18.1-useradd_fix-2.patch
./configure --libdir=/lib --sysconfdir=/etc --enable-shared \
        --without-selinux
sed -i 's/groups$(EXEEXT) //' src/Makefile
find man -name Makefile -exec sed -i 's/groups\.1 / /' {} \;
sed -i -e 's/ ko//' -e 's/ zh_CN zh_TW//' man/Makefile
sed -i -e 's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' \
-e 's@/var/spool/mail@/var/mail@' etc/login.defs
make
make install
mv -v /usr/bin/passwd /bin
mv -v /lib/libshadow.*a /usr/lib
rm -v /lib/libshadow.so
ln -sfv ../../lib/libshadow.so.0 /usr/lib/libshadow.so

pwconv
grpconv

useradd -D -b /home
sed -i 's/yes/no/' /etc/default/useradd

passwd root

popd
rm -rf ${BUILD_DIR}/shadow-4.0.18.1

* sysklogd-1.5

tar xvf ${DOWNLOAD_DIR}/sysklogd-1.5.tar.gz ${BUILD_DIR}
pushd ${BUILD_DIR}/sysklogd-1.5

make LDFLAGS="${LDFLAGS}"
make install
cat > /etc/syslog.conf << "EOF"
# Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.emerg *
# End /etc/syslog.conf
EOF
popd
rm -rf ${BUILD_DIR}/sysklogd-1.5

* sysvinit-2.86

tar xvf ${DOWNLOAD_DIR}/sysvinit-2.86.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/sysvinit-2.86
sed -i 's@Sending processes@& configured via /etc/inittab@g' src/init.c
make LDFLAGS="${LDFLAGS}" -C src
make -C src install
cat > /etc/inittab << "EOF"
# Begin /etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/init.d/rc sysinit
l0:0:wait:/etc/rc.d/init.d/rc 0
l1:S1:wait:/etc/rc.d/init.d/rc 1
l2:2:wait:/etc/rc.d/init.d/rc 2
l3:3:wait:/etc/rc.d/init.d/rc 3
l4:4:wait:/etc/rc.d/init.d/rc 4
l5:5:wait:/etc/rc.d/init.d/rc 5
l6:6:wait:/etc/rc.d/init.d/rc 6

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
su:S016nce:/sbin/sulogin
1:2345:respawn:/sbin/agetty tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/agetty tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600
# End /etc/inittab
EOF

popd
rm -rf ${BUILD_DIR}/sysvinit-2.86

* udev-122

tar xvf ${DOWNLOAD_DIR}/udev-122.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/udev-122

tar -xvf ${DOWNLOAD_DIR}/udev-config-20080522.tar.bz2
install -dv /lib/{firmware,udev/devices/{pts,shm}}
mknod -m0666 /lib/udev/devices/null c 1 3
ln -sv /proc/self/fd /lib/udev/devices/fd
ln -sv /proc/self/fd/0 /lib/udev/devices/stdin
ln -sv /proc/self/fd/1 /lib/udev/devices/stdout
ln -sv /proc/self/fd/2 /lib/udev/devices/stderr
ln -sv /proc/kcore /lib/udev/devices/core
make EXTRAS="`echo extras/*/`"
make DESTDIR=/ EXTRAS="`echo extras/*/`" install
cp -v etc/udev/rules.d/[0-9]* /etc/udev/rules.d/
cd udev-config-20070731
make install
make install-doc
make install-extra-doc
cd ..
install -dv /usr/share/doc/udev-122
install -m644 -v docs/writing_udev_rules/index.html /usr/share/doc/udev-122/index.html
popd
rm -rf ${BUILD_DIR}/udev-122

* vim-7.1

tar xvf ${DOWNLOAD_DIR}/vim-7.1.tar.bz2 -C ${BUILD_DIR}
tar xvf ${DOWNLOAD_DIR}/vim-7.1-extra.tar.gz -C ${BUILD_DIR}
tar xvf ${DOWNLOAD_DIR}/vim-7.1-lang.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/vim71

patch -Np1 -i ${DOWNLOAD_DIR}/vim-7.6-fixes-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/vim-7.1-mandir-1.patch
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
./configure --prefix=/usr --enable-multibyte
make
make install
ln -sv vim /usr/bin/vi
for L in "" fr it pl ru; do
  ln -sv vim.1 /usr/share/man/$L/man1/vi.1
done
ln -sv ../vim/vim71/doc /usr/share/doc/vim-7.1

cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
set nocompatible
set backspace=2
syntax on
if (&term == "iterm") || (&term == "putty")
  set background=dark
endif
" End /etc/vimrc
EOF

popd
rm -rf ${BUILD_DIR}/vim71

* grub-0.97

tar xvf ${DOWNLOAD_DIR}/grub-0.97.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/grub-0.97
patch -Np1 -i ${DOWNLOAD_DIR}/grub-0.97-disk_geometry-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/grub-0.97-256byte_inode-1.patch
./configure --prefix=/usr
make
make install
mkdir -v /boot/grub
cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub
popd
rm -rf ${BUILD_DIR}/grub-0.97

* lfs-bootscripts-20080522

tar xvf ${DOWNLOAD_DIR}/lfs-bootscripts-20080522.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/lfs-bootscripts-20080522

make install

popd
rm -rf ${BUILD_DIR}/lfs-bootscripts-20080522

* linux-2.6.25.4

tar xvf ${DOWNLOAD_DIR}/linux-2.6.25.4.tar.bz2 -C /usr/src
pushd /usr/src/linux-2.6.25.4


patch -Np1 -i ${DOWNLOAD_DIR}/utf8-kernel-2.6.25-core-1.patch
patch -Np1 -i ${DOWNLOAD_DIR}/utf8-kernel-2.6.25-fonts-1.patch


make mrproper
make menuconfig
make
make modules_install
cp -v arch/i386/boot/bzImage /boot/linux-2.6.25.4
cp -v System.map /boot/System.map-2.6.25.4
install -d /usr/share/doc/linux-2.6.25.4
cp -r Documentation/* /usr/share/doc/linux-2.6.25.4

popd
 


设置系统

* 配置文件
  (以下取自LFS手册中,为了输入方便做了简化,同时改进了部分内容)

cat > /etc/sysconfig/clock << "EOF"
UTC=1
EOF
cat > /etc/inputrc << "EOF"
set horizontal-scroll-mode Off
set meta-flag On
set input-meta On
set convert-meta Off

set output-meta On
set bell-style none
"\eOd": backward-word
"\eOc": forward-word

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

"\eOH": beginning-of-line
"\eOF": end-of-line
"\e[H": beginning-of-line
"\e[F": end-of-line
EOF
cat > /etc/profile << "EOF"
export LANG=zh_CN.UTF-8export PS1='\u:\w\$ '
EOF
echo "HOSTNAME=slfs" > /etc/sysconfig/network
cat > /etc/hosts << "EOF"
127.0.0.1 localhost
EOF
cd /etc/sysconfig/network-devices
mkdir -v ifconfig.eth0
cat > ifconfig.eth0/ipv4 << "EOF"
ONBOOT=yes
SERVICE=ipv4-static
IP=192.168.1.1
GATEWAY=192.168.1.2
PREFIX=24
BROADCAST=192.168.1.255
EOF
cat > /etc/resolv.conf << "EOF"
nameserver <域名服务器地址1>
nameserver <域名服务器地址2>
EOF
  注意:/etc/fstab中的内容请根据实际情况进行填写(这里以本文开头所使用的hda2为例)

cat > /etc/fstab << "EOF"
# file system mount-point type options dump fsck order
/dev/hda2 / xfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
shm /dev/shm tmpfs defaults 0 0
EOF

* 设置grub

grub       注意:grub的设置请根据实际情况进行(这里以本文开头所使用的hda2为例)
   root (hd0,1)
   setup (hd0)
   quit


cat > /boot/grub/menu.lst << "EOF"
default 0
timeout 30
color green/black light-green/black
title LFS
root (hd0,1)
kernel /boot/linux-2.6.25.4 root=/dev/hda2 vga=788
EOF

mkdir -v /etc/grub
ln -sv /boot/grub/menu.lst /etc/grub

附加应用
  这里增加几个软件包的安装过程是为了方便制作出来的基本系统可以方便的从网络上下载源代码包。

* bc-1.06

tar xvf ${DOWNLOAD_DIR}/bc-1.06.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/bc-1.06

sed -i '/PROTO.*readline/d' bc/scan.l &&
sed -i '/flex -I8/s/8//' configure &&
sed -i '/stdlib/a #include <string.h>' lib/number.c &&
sed -i 's/program.*save/static &/' bc/load.c &&
./configure --prefix=/usr --with-readline &&
make
echo "quit" | ./bc/bc -l Test/checklib.b
make install
popd
rm -rf ${BUILD_DIR}/bc-1.06

* openssl-0.9.8h

tar xvf ${DOWNLOAD_DIR}/openssl-0.9.8h.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/openssl-0.9.8h

patch -Np1 -i ../openssl-0.9.8h-fix_manpages-1.patch &&
./config --openssldir=/etc/ssl --prefix=/usr shared &&
make MANDIR=/usr/share/man
make MANDIR=/usr/share/man install &&
cp -v -r certs /etc/ssl &&
install -v -d -m755 /usr/share/doc/openssl-0.9.8h &&
cp -v -r doc/{HOWTO,README,*.{txt,html,gif}} /usr/share/doc/openssl-0.9.8h
popd
rm -rf ${BUILD_DIR}/openssl-0.9.8h

* wget-1.11.3

tar xvf ${DOWNLOAD_DIR}/wget-1.11.3.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/wget-1.11.3

./configure --prefix=/usr --sysconfdir=/etc
make
make install

popd
rm -rf ${BUILD_DIR}/wget-1.11.3
 
结束  如果你坚持做完那么现在应该是一个可以正常启动的Linux系统了,同时也具备了自我完善的功能,你可以根据你的实际需求不断的增加你需要的软件来完善它。
  当然,本文还有许多不完善的地方,如果你发现了什么问题欢迎及时指出来,同时希望你能提供宝贵的意见,我在这里先谢谢您的支持。
(转载请保持文章的完整性,请注明作者和出处)
                               作者:孙海勇
                               Email:youbest@sina.com
                               2008年6月8日



更新记录
  1.1:
     1、增加内核的对UTF-8文字显示支持。
您需要登录后才可以回帖 登录 | 注册

IT运维专家网感谢您的支持

合作联系: QQ:67888954/MSN:cnseek@msn.com/mail:netseek@linuxtone.org

Archiver|手机版|感谢所有关心和支持过LinuxTone的朋友们 转载本站内容请注明原作者名及出处 ( 京ICP备08103151 )   |

GMT+8, 2019-11-12 19:26 , Processed in 0.033148 second(s), 14 queries , Apc On.

Powered by Discuz! X2 Licensed

© 2001-2011 Comsenz Inc.

回顶部