LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 5353|回复: 43

[原创]Linux系统源代码搭建手册之sysroot LFS(试验版本)

[复制链接]
发表于 2007-8-1 21:22:18 | 显示全部楼层 |阅读模式
前言
  本文并非正式版本,目前该方法我已经成功的建立了标准的LFS系统,但还需要一些排错和修正的过程,发布本试验版本是希望对此有兴趣的朋友能够一起完善一下,也可以查找一些问题,能起到抛砖引玉的作用就最好啦!:)


  由于是试验版本还未对文章的原理及相关命令进行讲解,这部分将在正式版本中增加上。有兴趣的朋友可以自己看一下,基本上本文算是CLFS-sysroot和LFS的综合版本。

版权:
  本文命令内容绝大部分来自www.linuxfromscratch.org的LFS手册中,部分为修改过的命令。
  如须转载请注明本文作者为孙海勇,并提供转载出处。
更新,由于篇幅比较长所以难免出现一些错误或者笔误,也有可能加入新内容,因此难免会进行修正或增删一些内容,如果本文被转载可以在www.linuxsir.cn 的LFS版中或者在本人的Blog中查看最新版本。
  linuxsir:http://www.linuxsir.cn/bbs/showthread.php?t=309688
  我的Blog:http://youbest.cublog.cn


说明:
  由于本文并非手把手类文章,因此并非按照文中命令就可以完成,对于软件包的解压缩及在包安装完成后删除原代码目录的命令并没有在每个包的命令中给出,需要读者自己进行这方面的命令,参照本文建立系统建议需要有一些LFS实际使用经验。

  目前依赖于三个测试包的一些软件包测试还有一些问题,正在想办法解决。

准备工作

建立用户
groupadd slfs
useradd –s /bin/bash –g slfs –m –k /dev/null slfs
passwd slfs

设置分区
  简单起见我们假设系统被安装在/dev/sda2中
加载分区
mount /dev/sda2 /mnt

设置环境变量及制造基地
export TARGET_DIR=”/mnt”
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=”/mnt”
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}/tools/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:
dialout: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.21.2(目标系统使用)
        tar xvf ${DOWNLOAD_DIR}/linux-2.6.21.2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/linux-2.6.21.2
        make mrproper
        make headers_check
        make INSTALL_HDR_PATH=dest headers_install
        cp –rv dest/include/* ${TARGET_DIR}/usr/include
        popd

binutils-2.17(临时工具链)
        tar xvf ${DOWNLOAD_DIR}/binutils-2.17.tar.bz2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/binutils-2.17
        mkdir –v ../binutils-build
        cd ../binutils-build
        ../binutils-2.17/configure --prefix=${TARGET_DIR}/tools --host=${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.17/include/libiberty.h ${TARGET_DIR}/usr/include
        cd ..
        rm -rf binutils-build
        rm -rf binutils-2.17
        popd

glibc-header-2.5(目标系统(临时))
        tar xvf ${DOWNLOAD_DIR}/glibc-2.5.tar.bz2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/glibc-2.5
        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.5/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.5/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h ${TARGET_DIR}/usr/include/bits
        cd ..
        rm -rf glibc-build
        rm -rf glibc-2.5
        popd

gcc-4.2.1(static) (临时工具链)
        tar xvf ${DOWNLOAD_DIR}/gcc-4.2.1.tar.bz2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/gcc-4.2.1
        patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.2.1-posix-1.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.2.1-cross_search_paths-1.patch
        mkdir -v ../gcc-build
        cd ../gcc-build
        ../gcc-4.2.1/configure --prefix=${TARGET_DIR}/tools --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
        cd ..
        rm -rf gcc-build
        rm -rf gcc-4.2.1
        popd

glibc-2.5(目标系统)
        tar xvf ${DOWNLOAD_DIR}/glibc-2.5.tar.bz2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/glibc-2.5
        patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.5-libgcc_eh-2.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.5-localedef_segfault-1.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/glibc-2.5-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” AR=”${BUILD_TARGET}-ar” RANLIB=”${BUILD_TARGET}-ranlib” ../glibc-2.5/configure --prefix=/usr --libexecdir=/usr/lib/glibc --host=${BUILD_TARGET} --build=${BUILD_HOST} --disable-profile --enable-add-ons --with-tls --enable-kernel=2.6.16 --with-__thread --with-binutils=${TARGET_DIR}/tools/bin --with-headers=${TARGET_DIR}/usr/include --cache-file=config.cache
        make
        make install
        make localedata/install-locales
        cd ..
        rm -rf glibc-build
        rm -rf glibc-2.5
        popd

cat > ${TARGET_DIR}/etc/nsswitch.conf << “EOF”
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

hosts: files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF


cp -v --remove-destination ${TARGET_DIR}/usr/share/zoneinfo/Asia/Shanghai \         ${TARGET_DIR}/etc/localtime


cat > ${TARGET_DIR}/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/usr/local/lib
/opt/lib

# End /etc/ld.so.conf
EOF

binutls-2.17(目标系统)
tar xvf ${DOWNLOAD_DIR}/binutils-2.17.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/binutils-2.17
#        patch -Np1 -i ${DOWNLOAD_DIR}/binutils-2.17-posix-1.patch
        mkdir -pv ../binutils-build
        cd ../binutils-build
        ../binutils-2.17/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.17/include/libiberty.h ${TARGET_DIR}/usr/include
        cd ..
        rm -r binutils-build
        rm -r binutils-2.17
popd

gcc-4.2.1(目标系统)
tar xvf ${DOWNLOAD_DIR}/gcc-4.1.2.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/gcc-4.1.2
#        patch -Np1 -i ${DOWNLOAD_DIR}/gcc-4.1.2-posix-1.patch
        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,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
        cd ..
        rm -r gcc-build
        rm -r gcc-4.2.1
popd

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
        cd ..
        rm -r sed-4.1.5
popd

bash-3.2(临时工具链)
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-4.patch
        echo "bash_cv_sys_named_pipes=yes" > config.cache
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=${TARGET_DIR}/tools --without-bash-malloc
        make
        make install
        cd ..
        rm -r bash-3.2
popd

grep-2.5.1a(目标系统)
tar xvf ${DOWNLOAD_DIR}/grep-2.5.1a.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/grep-2.5.1a
        patch -Np1 -i ${DOWNLOAD_DIR}/grep-2.5.1a-redhat_fixes-2.patch
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr --bindir=/bin --disable-perl-regexp
        make
        make DESTDIR=${TARGET_DIR} install
        cd ..
        rm -r grep-2.5.1a
popd


coreutils-6.9(目标系统)
tar xvf ${DOWNLOAD_DIR}/coreutils-6.9.tar.bz2 -C ${BUILD_DIR}
pushd ${BUILD_DIR}/coreutils-6.9
        patch -Np1 -i ${DOWNLOAD_DIR}/coreutils-6.9-suppress_uptime_kill_su-1.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/coreutils-6.9-uname-1.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/coreutils-6.9-i18n-1.patch
        touch man/uname.1
        echo "fu_cv_sys_stat_statfs2_bsize=yes" > config.cache
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr --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
        cd ..
        rm -r coreutils-6.9
popd

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
        cd ..
        rm -r make-3.81
popd

tcl-8.4.15(工具链)
tar xvf ${DOWNLOAD_DIR}/tcl-8.4.15-src.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/tcl8.4.15
        cd unix
  ./configure --prefix=${TARGET_DIR}/tools
  make
  make install
  make install-private-headers
  ln -sv tclsh8.4 ${TARGET_DIR}/tools/bin/tclsh
        cd ../..
        rm -r tcl8.4.15
popd

expect-5.43.0(工具链)
tar xvf ${DOWNLOAD_DIR}/expect-5.43.0.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/expect-5.43
        patch -Np1 -i ../expect-5.43.0-spawn-1.patch
        cp configure{,.bak}
  sed 's:/usr/local/bin:/bin:' configure.bak > configure
  ./configure --prefix=${TARGET_DIR}/tools --with-tcl=${TARGET_DIR}/tools/lib \
    --with-tclinclude=${TARGET_DIR}/tools/include --with-x=no
  make
  make SCRIPTS=”” install
        cd ..
        rm -r expect-5.43
popd

dejagnu-1.4.4(工具链)
tar xvf ${DOWNLOAD_DIR}/dejagnu-1.4.4.tar.gz -C ${BUILD_DIR}
pushd ${BUILD_DIR}/dejagnu-1.4.4
        ./configure --prefix=${TARGET_DIR}/tools
        make install
        cd ..
        rm -r dejagnu-1.4.4
popd

diffutils-2.8.7(目标系统)
        tar xvf ${DOWNLOAD_DIR}/diffutils-2.8.7.tar.bz2 -C ${BUILD_DIR}
        pushd ${BUILD_DIR}/diffutils-2.8.7
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr
        make
        make DESTDIR=${TARGET_DIR} install
        cd ..
        rm -r diffutils-2.8.7
popd

gawk-3.1.5(目标系统)
        patch -Np1 -i ../gawk-3.1.5-segfault_fix-1.patch
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=/usr --libexecdir=/usr/lib
        cat >> config.h << "EOF"
  #define HAVE_LANGINFO_CODESET 1
  #define HAVE_LC_MESSAGES 1
  EOF
  make
#  make check
  make DESTDIR=${TARGET_DIR} install

tar-1.1.8(工具链)
        ./configure --build=${BUILD_HOST} --host=${BUILD_TARGET} --prefix=${TARGET_DIR}/tools
        make
        make install


解开一些软件包,以便在chroot后因为暂时tar无法解压缩包时需要编译的软件包
tar xvf ${DWONLOAD_DIR}/patch-2.5.4 -C ${BUILD_DIR}
tar xvf ${DOWNLOAD_DIR}/ncurses-5.6.tar.gz -C ${BUILD_DIR}
tar xvf ${DOWNLOAD_DIR}/gzip-1.3.12.tar.gz -C ${BUILD_DIR}
退出slfs用户,使用root用户


开始制作目标系统
export TARGET_DIR=”/mnt”
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 /tools/bin/bash ${TARGET_DIR}/bin/bash
ln -sv bash ${TARGET_DIR}/bin/sh

chroot ${TARGET_DIR} /usr/bin/env -i HOME=/root TERM=”${TERM}” 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.4
        ./configure --prefix=/usr
        make
        make install

ncurses-5.6
        patch -Np1 -i ${DOWNLOAD_DIR}/ncurses-5.6-coverity_fixes-1.patch
        ./configure --prefix=/usr --with-shared --without-debug --enable-widec
        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


gzip-1.3.12
        ./configure --prefix=/usr --bindir=/bin
        make
        make install
        make clean
        make
        make check(通过)
        make install
        mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin
        mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin

bzip2-1.0.4
        patch -Np1 -i ${DOWNLOAD_DIR}/bzip2-1.0.4-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

findutils-4.2.31
        ./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

tar-1.1.8
        ./configure --prefix=/usr --bindir=/bin --libexecdir=/usr/sbin
        make
        make check(通过)
        make install

gettext-0.16.1
        ./configure --prefix=/usr
        make
        make check(通过,有个别未运行的测试)
        make install

texinfo-4.9
        patch -Np1 -i ${DOWNLOAD_DIR}/texinfo-4.9-multibyte-1.patch
        patch -Np1 -i ${DOWNLOAD_DIR}/texinfo-4.9-tempfile_fix-1.patch
        ./configure --prefix=/usr
        make
        make check (通过)
        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

Berkeley db-4.5.20
        patch -Np1 -i ${DOWNLOAD_DIR}/db-4.5.20-fixes-1.patch
  cd build_unix
  ../dist/configure --prefix=/usr --enable-compat185 --enable-cxx
  make
  make docdir=/usr/share/doc/db-4.5.20 install
  chown -Rv root:root /usr/share/doc/db-4.5.20

iana-etc-2.20
  make
  make install

e2fsprogs-1.40.2
        mkdir -v build
  cd build
  ../configure --prefix=/usr --with-root-prefix="" \
      --enable-elf-shlibs
  make
  make check(有错误)
  make install
  make install-libs

m4-1.4.10
        ./configure --prefix=/usr
        make
        make check(通过)
        make install

bison-2.3
        ./configure --prefix=/usr
        echo ‘#define YYENABLE_NLS 1’ >> config.h
        make
        make check(通过)
        make install

procps-3.2.7
        make
        make install

libtool-1.5.24
        ./configure --prefix=/usr
        make
        make check(通过)
        make install

zlib-1.2.3
        ./configure --prefix=/usr --shared --libdir=/lib
        make
        make check(通过)
        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 check(通过)
        make install
        chmod -v 644 /usr/lib/libz.a

utils-linux-2.12r
        sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
    -i $(grep -rl '/etc/adjtime' .)
  mkdir -pv /var/lib/hwclock
  patch -Np1 -i ../util-linux-2.12r-cramfs-1.patch
  patch -Np1 -i ../util-linux-2.12r-lseek-1.patch
  ./configure
  make HAVE_KILL=yes HAVE_SLN=yes
  make HAVE_KILL=yes HAVE_SLN=yes install

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
        ./configure.gnu --prefix=/usr \
            -Dman1dir=/usr/share/man/man1 \
            -Dman3dir=/usr/share/man/man3 \
            -Dpager="/usr/bin/less -isR"
        make
        make test(个别测试未通过)
        make install

readline-5.2
        sed -i '/MV.*old/d' Makefile.in
  sed -i '/{OLDSUFF}/c:' support/shlib-install
  patch -Np1 -i ../readline-5.2-fixes-3.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

autoconf-2.61
        ./configure --prefix=/usr
        make
        make check(通过,有个别跳过)
        make install

automake-1.10
        ./configure --prefix=/usr
        make
        make check(基本都通过,大概有3个测试错误)
        make install

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-5.patch
  ./configure --prefix=/usr --bindir=/bin \
      --without-bash-malloc --with-installed-readline
  make
  make install
  exec /bin/bash --login +h

file-4.21
        ./configure --prefix=/usr
        make
        make install

flex-2.5.33
        ./configure --prefix=/usr
        make
        make check(通过)
        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

groff-1.18.1.4
        patch -Np1 -i ../groff-1.18.1.4-debian_fixes-1.patch
        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

inetutils-1.5
        patch -Np1 -i ../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

iproute2-2.6.20-070313
        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

kbd-1.12
  patch -Np1 -i ../kbd-1.12-backspace-1.patch
  patch -Np1 -i ../kbd-1.12-gcc4_fixes-1.patch
  ./configure --datadir=/lib/kbd
  make
  make install
  mv -v /usr/bin/{kbd_mode,openvt,setfont} /bin

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

man-db-2.4.4
        sed -i 's,\*_\*,??,' man/Makefile.in
        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 --enable-mb-groff --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

mktemp-1.5
        patch -Np1 -i ${DOWNLOAD_DIR}/mktemp-1.5-add_tempfile-3.patch
        ./configure --prefix=/usr --with-libc
        make
        make install
        make install-tempfile

module-init-tools-3.2.2
        patch -Np1 -i ${DOWNLOAD_DIR}/module-init-tools-3.2.2-modprobe-1.patch
        ./configure
        make check
        make distclean
        ./configure --prefix=/ --enable-zlib
        make
        make INSTALL=install install

psmisc-22.5
        ./configure --prefix=/usr --exec-prefix=""
        make
        make install
        mv -v /bin/pstree* /usr/bin
        ln -sv killall /bin/pidof

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

sysklogd-1.4.1
        patch -Np1 -i ../sysklogd-1.4.1-fixes-2.patch
        patch -Np1 -i ../sysklogd-1.4.1-8bit-1.patch
        make
        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

sysvinit-2.86
        sed -i 's@Sending processes@& configured via /etc/inittab@g' \
  src/init.c
  make -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

udev-113
        tar -xvf ${DOWNLOAD_DIR}/udev-config-20070304.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 test(通过,有3个错误)
  make DESTDIR=/ EXTRAS="`echo extras/*/`" install
  cp -v etc/udev/rules.d/[0-9]* /etc/udev/rules.d/
  cd udev-config-20070304
  make install
  make install-doc
  make install-extra-doc
  cd ..
  install -m644 -v docs/writing_udev_rules/index.html \
      /usr/share/doc/udev-113/index.html

vim-7.1
  patch -Np1 -i ${DOWNLOAD_DIR}/vim-7.1-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 test(有失败内容)
  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

grub-0.97
  patch -Np1 -i ${DOWNLOAD_DIR}/grub-0.97-disk_geometry-1.patch
  ./configure --prefix=/usr
  make
  make check(通过)
  make install
  mkdir -v /boot/grub
  cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub

lfs-bootscripts-20070420
        make install

cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock

UTC=1

# End /etc/sysconfig/clock
EOF

cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>

# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word



# for linux console
"\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

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

# End /etc/inputrc
EOF

cat > /etc/profile << "EOF"
# Begin /etc/profile

export LANG=zh_CN.UTF-8

# End /etc/profile
EOF

echo "HOSTNAME=slfs" > /etc/sysconfig/network

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)

127.0.0.1 localhost

# End /etc/hosts (network card version)
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"
# Begin /etc/resolv.conf

nameserver <域名服务器地址>
nameserver <域名服务器地址>

# End /etc/resolv.conf
EOF

cat > /etc/fstab << "EOF"
# Begin /etc/fstab

# file system  mount-point  type   options         dump  fsck
#                                                        order

/dev/<xxx>     /            <fff>  defaults        1     1
/dev/<yyy>     swap         swap   pri=1           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
# End /etc/fstab
EOF

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

grub
        root (hd0,1)
        setup (hd0)
        quit

cat > /boot/grub/menu.lst << "EOF"
# Begin /boot/grub/menu.lst

# By default boot the first menu entry.
default 0

# Allow 30 seconds before booting the default.
timeout 30

# Use prettier colors.
color green/black light-green/black

# The first entry is for LFS.
title LFS SVN-20070724
root (hd0,1)
kernel /boot/lfskernel-2.6.22.1 root=/dev/sda2
EOF

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

                                              作者:孙海勇
                                          Email:youbest@sina.com
                                          2007年8月1日

今天是“八一”建军节,发本文算是庆祝一下!
 楼主| 发表于 2007-8-1 21:25:51 | 显示全部楼层
排版乱了点~
回复 支持 反对

使用道具 举报

发表于 2007-8-1 21:40:26 | 显示全部楼层
豹兄又有大作了,必看之。。。
回复 支持 反对

使用道具 举报

发表于 2007-8-1 21:44:38 | 显示全部楼层
完蛋了,这个周末又要荒废在LFS上了
支持YouBest!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-1 21:50:41 | 显示全部楼层
没有什么太多的新东西,结合了一下CLFS-sysroot和LFS,使LFS的制作过程简化了一下。

这个方法我这还有一些变种,不过它们相互之间没有什么特别优于其它的,我挑选了一个方法发出来的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-1 21:55:17 | 显示全部楼层
最近空闲的时间不太多,所以很多东西想到了但没有时间去完成。
回复 支持 反对

使用道具 举报

发表于 2007-8-1 23:15:54 | 显示全部楼层
好文章!
有研究下。
回复 支持 反对

使用道具 举报

发表于 2007-8-2 08:48:02 | 显示全部楼层
楼主,这些命令,完全可以放一个脚本里面,一次,或者两次之内执行吗
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-2 09:02:05 | 显示全部楼层
可以是可以,不过你需要加入软件包的解压、进入目录、删除等等一些操作

本文目前不是手把手类型文章,省略了一些常规命令。主要目的是探讨不同于LFS的制作方法
回复 支持 反对

使用道具 举报

发表于 2007-8-2 12:41:45 | 显示全部楼层
有个“表情符”请更正一下:)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表