• 从头开始构建LINUX [LFS 脚本]


    脚本共享在这 http://pan.baidu.com/s/1nt6yiH7

    version-check.sh : 这个是检查HOST机器的软件依赖情况

    host-dep.sh:针对ubuntu10_64的缺少的包的安装【开发环境已安装】

    comp.sh:LFS7.5的图书大量的编译代码的整理脚本 ,可参数运行,如 ./comp.sh -s=5.1表示对应章节的执行步骤

    如下是comp.sh的内容

    #!/bin/bash

    :<<EOF
    安装依赖的包在这些独立的文件中,不用独立下载
    ftp://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.5.tar
    http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.5.tar
    EOF

    export LFS=/mnt/lfs
    #虚机上make并发存在死机的情况,不用
    #export MAKEFLAGS="-j 2"

    STEP=1
    for i in "$@"
    do
    case $i in
    -s=*|--step=*)
    STEP="${i#*=}"
    shift
    ;;
    esac
    done;

    #chap2
    if [[ $STEP = "2" ]]; then
    mkdir -pv $LFS
    mount -v -t ext4 /dev/sdb1 $LFS

    /sbin/swapon -v /dev/sdb2
    #Add to /etc/fstab
    #/dev/sdb1 /mnt/lfs ext4 defaults 0 0
    fi

    #chap3
    if [[ $STEP = "3" ]]; then
    mkdir -v $LFS/sources
    chmod -v a+wt $LFS/sources

    pushd $LFS/sources
    #wget -i wget-list -P $LFS/sources
    popd
    fi

    #chap4
    if [[ $STEP = "4" ]]; then
    mkdir -v $LFS/tools
    ln -sv $LFS/tools /

    groupadd lfs
    useradd -s /bin/bash -g lfs -m -k /dev/null lfs
    passwd lfs

    su - lfs
    fi

    if [[ $STEP = "4.1" ]]; then
    chown -v lfs $LFS/tools
    chown -v lfs $LFS/sources
    cat > ~/.bash_profile << "EOF"
    exec env -i HOME=$HOME TERM=$TERM PS1='u:w$ ' /bin/bash
    EOF
    cat > ~/.bashrc << "EOF"
    set +h
    umask 022
    LFS=/mnt/lfs
    LC_ALL=POSIX
    LFS_TGT=$(uname -m)-lfs-linux-gnu
    PATH=/tools/bin:/bin:/usr/bin
    export LFS LC_ALL LFS_TGT PATH
    EOF

    #source ~/.bash_profile
    fi

    <<EOF
    !USE lfs user
    a. Using the tar program, extract the package to be built. In Chapter 5, ensure you are the lfs user
    when extracting the package.
    b. Change to the directory created when the package was extracted.
    c. Follow the book's instructions for building the package.
    d. Change back to the sources directory.
    e. Delete the extracted source directory and any <package>-build directories that were created
    in the build process unless instructed otherwise.
    EOF
    #chap5
    if [[ $STEP = "5" ]]; then
    case $(uname -m) in
    x86_64)
    mkdir -v /tools/lib && ln -sv lib /tools/lib64
    ;;
    esac
    fi


    #Binutils
    #-----------------
    pushd $LFS/sources
    if [[ $STEP = "5.1" ]]; then
    tar xjf binutils-2.24.tar.bz2
    mkdir -v binutils-build
    pushd binutils-build
    ../binutils-2.24/configure
    --prefix=/tools
    --with-sysroot=$LFS
    --with-lib-path=/tools/lib
    --target=$LFS_TGT
    --disable-nls
    --disable-werror
    make
    make install
    popd
    fi
    #GCC
    if [[ $STEP = "5.2" ]]; then
    tar xjf gcc-4.8.2.tar.bz2
    #configure
    cd gcc-4.8.2
    tar -Jxf ../mpfr-3.1.2.tar.xz
    mv -v mpfr-3.1.2 mpfr
    tar -Jxf ../gmp-5.1.3.tar.xz
    mv -v gmp-5.1.3 gmp
    tar -zxf ../mpc-1.0.2.tar.gz
    mv -v mpc-1.0.2 mpc
    for file in
    $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
    do
    cp -uv $file{,.orig}
    sed -e 's@/lib(64)?(32)?/ld@/tools&@g'
    -e 's@/usr@/tools@g' $file.orig > $file
    echo '
    #undef STANDARD_STARTFILE_PREFIX_1
    #undef STANDARD_STARTFILE_PREFIX_2
    #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
    touch $file.orig
    done

    sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
    cd ..
    #build
    mkdir -v gcc-build
    cd gcc-build

    ../gcc-4.8.2/configure
    --target=$LFS_TGT
    --prefix=/tools
    --with-sysroot=$LFS
    --with-newlib
    --without-headers
    --with-local-prefix=/tools
    --with-native-system-header-dir=/tools/include
    --disable-nls
    --disable-shared
    --disable-multilib
    --disable-decimal-float
    --disable-threads
    --disable-libatomic
    --disable-libgomp
    --disable-libitm
    --disable-libmudflap
    --disable-libquadmath
    --disable-libsanitizer
    --disable-libssp
    --disable-libstdc++-v3
    --enable-languages=c,c++
    --with-mpfr-include=$(pwd)../gcc-4.8.2/mpfr/src
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs
    make #-j
    make install
    ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
    cd ..

    fi
    #LINUX HEADER
    if [[ $STEP = "5.3" ]]; then
    tar xf linux-3.13.3.tar.xz
    cd linux-3.13.3
    make mrproper
    make headers_check
    make INSTALL_HDR_PATH=dest headers_install
    cp -rv dest/include/* /tools/include
    cd ..
    fi
    #GLIBC
    if [[ $STEP = "5.4" ]]; then
    tar xf glibc-2.19.tar.xz
    cd glibc-2.19
    if [ ! -r /usr/include/rpc/types.h ]; then
    su -c 'mkdir -pv /usr/include/rpc'
    su -c 'cp -v sunrpc/rpc/*.h /usr/include/rpc'
    fi
    cd ..

    mkdir -v glibc-build
    cd glibc-build
    ../glibc-2.19/configure
    --prefix=/tools
    --host=$LFS_TGT
    --build=$(../glibc-2.19/scripts/config.guess)
    --disable-profile
    --enable-kernel=2.6.32
    --with-headers=/tools/include
    libc_cv_forced_unwind=yes
    libc_cv_ctors_header=yes
    libc_cv_c_cleanup=yes
    make
    make install
    cd ..

    fi
    #libstdc++ [of gcc]
    if [[ $STEP = "5.5" ]]; then
    cd gcc-build
    ../gcc-4.8.2/libstdc++-v3/configure
    --host=$LFS_TGT
    --prefix=/tools
    --disable-multilib
    --disable-shared
    --disable-nls
    --disable-libstdcxx-threads
    --disable-libstdcxx-pch
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/4.8.2
    make
    make install
    cd ..
    fi
    #Binutils-2.24 - Pass 2
    if [[ $STEP = "5.9" ]]; then
    rm -rf binutils-build
    rm -rf binutils-2.24
    tar xjf binutils-2.24.tar.bz2
    mkdir -v binutils-build
    cd binutils-build
    CC=$LFS_TGT-gcc
    AR=$LFS_TGT-ar
    RANLIB=$LFS_TGT-ranlib
    ../binutils-2.24/configure
    --prefix=/tools
    --disable-nls
    --with-lib-path=/tools/lib
    --with-sysroot

    make
    make install
    # prepare the linker for the “Re-adjusting” phase in
    make -C ld clean
    make -C ld LIB_PATH=/usr/lib:/lib
    cp -v ld/ld-new /tools/bin
    cd ..
    fi
    #GCC-4.8.2 - Pass 2
    if [[ $STEP = "5.10" ]]; then
    rm -rf gcc-4.8.2
    tar xjf gcc-4.8.2.tar.bz2
    cd gcc-4.8.2
    tar -Jxf ../mpfr-3.1.2.tar.xz
    mv -v mpfr-3.1.2 mpfr
    tar -Jxf ../gmp-5.1.3.tar.xz
    mv -v gmp-5.1.3 gmp
    tar -zxf ../mpc-1.0.2.tar.gz
    mv -v mpc-1.0.2 mpc

    cat gcc/limitx.h gcc/glimits.h gcc/limity.h >
    `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h
    case `uname -m` in
    i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;;
    esac
    for file in
    $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
    do
    cp -uv $file{,.orig}
    sed -e 's@/lib(64)?(32)?/ld@/tools&@g'
    -e 's@/usr@/tools@g' $file.orig > $file
    echo '
    #undef STANDARD_STARTFILE_PREFIX_1
    #undef STANDARD_STARTFILE_PREFIX_2
    #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
    #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
    touch $file.orig
    done
    cd ..
    #build
    rm -rf gcc-build
    mkdir -v gcc-build
    cd gcc-build
    CC=$LFS_TGT-gcc
    CXX=$LFS_TGT-g++
    AR=$LFS_TGT-ar
    RANLIB=$LFS_TGT-ranlib
    ../gcc-4.8.2/configure
    --prefix=/tools
    --with-local-prefix=/tools
    --with-native-system-header-dir=/tools/include
    --enable-clocale=gnu
    --enable-shared
    --enable-threads=posix
    --enable-__cxa_atexit
    --enable-languages=c,c++
    --disable-libstdcxx-pch
    --disable-multilib
    --disable-bootstrap
    --disable-libgomp
    --with-mpfr-include=$(pwd)/../gcc-4.8.2/mpfr/src
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs
    make
    make install
    ln -sv gcc /tools/bin/cc
    echo 'main(){}' > dummy.c
    cc dummy.c
    readelf -l a.out | grep ': /tools'
    #rm -v dummy.c a.out
    cd ..
    fi
    #5.11. Tcl-8.6.1
    if [[ $STEP = "5.11" ]]; then
    tar xzf tcl8.6.1-src.tar.gz
    cd tcl8.6.1
    cd unix
    ./configure --prefix=/tools
    make
    TZ=UTC make test
    make install
    chmod -v u+w /tools/lib/libtcl8.6.so
    make install-private-headers
    ln -sv tclsh8.6 /tools/bin/tclsh
    cd ..
    cd ..
    fi
    #5.12. Expect-5.45
    if [[ $STEP = "5.12" ]]; then
    tar xzf expect5.45.tar.gz
    cd expect5.45
    cp -v configure{,.orig}
    sed 's:/usr/local/bin:/bin:' configure.orig > configure
    ./configure --prefix=/tools
    --with-tcl=/tools/lib
    --with-tclinclude=/tools/include
    make
    make test
    make SCRIPTS="" install
    cd ..
    fi
    #5.13. DejaGNU-1.5.1
    if [[ $STEP = "5.13" ]]; then
    tar xzf dejagnu-1.5.1.tar.gz
    cd dejagnu-1.5.1
    ./configure --prefix=/tools
    make install
    make check
    cd ..
    fi
    #5.14. Check-0.9.12
    if [[ $STEP = "5.14" ]]; then
    tar xzf check-0.9.12.tar.gz
    cd check-0.9.12
    PKG_CONFIG= ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.15. Ncurses-5.9
    if [[ $STEP = "5.15" ]]; then
    tar xzf ncurses-5.9.tar.gz
    cd ncurses-5.9
    ./configure --prefix=/tools
    --with-shared
    --without-debug
    --without-ada
    --enable-widec
    --enable-overwrite
    make
    make install
    cd ..
    fi
    #5.16. Bash-4.2
    if [[ $STEP = "5.16" ]]; then
    tar xzf bash-4.2.tar.gz
    cd bash-4.2
    patch -Np1 -i ../bash-4.2-fixes-12.patch
    ./configure --prefix=/tools --without-bash-malloc
    make
    make tests
    make install
    ln -sv bash /tools/bin/sh
    cd ..
    fi
    #5.17. Bzip2-1.0.6
    if [[ $STEP = "5.17" ]]; then
    tar bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
    make
    make PREFIX=/tools install
    cd ..
    fi
    #5.18. Coreutils-8.22
    if [[ $STEP = "5.18" ]]; then
    tar -Jxf coreutils-8.22.tar.xz
    cd coreutils-8.22
    ./configure --prefix=/tools --enable-install-program=hostname
    make
    make RUN_EXPENSIVE_TESTS=yes check
    make install
    cd ..
    fi
    #5.19. Diffutils-3.3
    if [[ $STEP = "5.19" ]]; then
    tar -Jxf diffutils-3.3.tar.xz
    cd diffutils-3.3
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.20. File-5.17
    if [[ $STEP = "5.20" ]]; then
    tar xzf file-5.17.tar.gz
    cd file-5.17
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.21. Findutils-4.4.2
    if [[ $STEP = "5.21" ]]; then
    tar xzf findutils-4.4.2.tar.gz
    cd findutils-4.4.2
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.22. Gawk-4.1.0
    if [[ $STEP = "5.22" ]]; then
    tar -Jxf gawk-4.1.0.tar.xz
    cd gawk-4.1.0
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.23. Gettext-0.18.3.2
    if [[ $STEP = "5.23" ]]; then
    tar xzf gettext-0.18.3.2.tar.gz
    cd gettext-0.18.3.2
    cd gettext-tools
    EMACS="no" ./configure --prefix=/tools --disable-shared
    make -C gnulib-lib
    make -C src msgfmt
    make -C src msgmerge
    make -C src xgettext
    cp -v src/{msgfmt,msgmerge,xgettext} /tools/bin
    cd ..
    fi
    #5.24. Grep-2.16
    if [[ $STEP = "5.24" ]]; then
    tar -Jxf grep-2.16.tar.xz
    cd grep-2.16
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.25. Gzip-1.6
    if [[ $STEP = "5.25" ]]; then
    tar -Jxf gzip-1.6.tar.xz
    cd gzip-1.6
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.26. M4-1.4.17
    if [[ $STEP = "5.26" ]]; then
    tar -Jxf m4-1.4.17.tar.xz
    cd m4-1.4.17
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.27. Make-4.0
    if [[ $STEP = "5.27" ]]; then
    tar xjf make-4.0.tar.bz2
    cd make-4.0
    ./configure --prefix=/tools --without-guile
    make
    make check
    make install
    cd ..
    fi
    #5.28. Patch-2.7.1
    if [[ $STEP = "5.28" ]]; then
    tar -Jxf patch-2.7.1.tar.xz
    cd patch-2.7.1
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.29. Perl-5.18.2
    if [[ $STEP = "5.29" ]]; then
    tar xjf perl-5.18.2.tar.bz2
    cd perl-5.18.2
    patch -Np1 -i ../perl-5.18.2-libc-1.patch
    sh Configure -des -Dprefix=/tools
    make

    cp -v perl cpan/podlators/pod2man /tools/bin
    mkdir -pv /tools/lib/perl5/5.18.2
    cp -Rv lib/* /tools/lib/perl5/5.18.2
    cd ..
    fi
    #5.30. Sed-4.2.2
    if [[ $STEP = "5.30" ]]; then
    tar xjf sed-4.2.2.tar.bz2
    cd sed-4.2.2
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.31. Tar-1.27.1
    if [[ $STEP = "5.31" ]]; then
    tar -Jxf tar-1.27.1.tar.xz
    cd tar-1.27.1
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.32. Texinfo-5.2
    if [[ $STEP = "5.32" ]]; then
    tar -Jxf texinfo-5.2.tar.xz
    cd texinfo-5.2
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.33. Util-linux-2.24.1
    if [[ $STEP = "5.33" ]]; then
    tar -Jxf util-linux-2.24.1.tar.xz
    cd util-linux-2.24.1
    ./configure --prefix=/tools
    --disable-makeinstall-chown
    --without-systemdsystemunitdir
    PKG_CONFIG=""
    make
    make install
    cd ..
    fi
    #5.34. Xz-5.0.5
    if [[ $STEP = "5.34" ]]; then
    tar -Jxf xz-5.0.5.tar.xz
    cd xz-5.0.5
    ./configure --prefix=/tools
    make
    make check
    make install
    cd ..
    fi
    #5.35. Stripping
    if [[ $STEP = "5.35" ]]; then
    strip --strip-debug /tools/lib/*
    /usr/bin/strip --strip-unneeded /tools/{,s}bin/*
    rm -rf /tools/{,share}/{info,man,doc}
    fi
    #5.36. Changing Ownership
    if [[ $STEP = "5.36" ]]; then
    chown -R root:root $LFS/tools
    fi
    #-----------------
    popd

    #chap6
    if [[ $STEP = "6" ]]; then
    #Preparing Virtual Kernel File Systems
    mkdir -pv $LFS/{dev,proc,sys,run}
    #6.2.1. Creating Initial Device Nodes
    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3
    #6.2.2. Mounting and Populating /dev
    mount -v --bind /dev $LFS/dev
    #6.2.3. Mounting Virtual Kernel File Systems
    mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
    mount -vt proc proc $LFS/proc
    mount -vt sysfs sysfs $LFS/sys
    mount -vt tmpfs tmpfs $LFS/run
    if [ -h $LFS/dev/shm ]; then
    mkdir -pv $LFS/$(readlink $LFS/dev/shm)
    fi
    fi
    #As user root, run the following command to enter the realm that is
    if [[ $STEP = "6.1" ]]; then
    chroot "$LFS" /tools/bin/env -i
    HOME=/root
    TERM="$TERM"
    PS1='u:w$ '
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
    /tools/bin/bash --login +h
    fi

    if [[ $STEP = "6.2" ]]; then
    #6.5. Creating Directories
    mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt}
    mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
    install -dv -m 0750 /root
    install -dv -m 1777 /tmp /var/tmp
    mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
    mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
    mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
    mkdir -v /usr/libexec
    mkdir -pv /usr/{,local/}share/man/man{1..8}
    case $(uname -m) in
    x86_64) ln -sv lib /lib64 &&
    ln -sv lib /usr/lib64 &&
    ln -sv lib /usr/local/lib64 ;;
    esac
    mkdir -v /var/{log,mail,spool}
    ln -sv /run /var/run
    ln -sv /run/lock /var/lock
    mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}
    #6.6. Creating Essential Files and Symlinks
    ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
    ln -sv /tools/bin/perl /usr/bin
    ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
    ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
    sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
    ln -sv bash /bin/sh

    ln -sv /proc/self/mounts /etc/mtab
    cat > /etc/passwd << "EOF"
    root:x:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/dev/null:/bin/false
    nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    EOF
    cat > /etc/group << "EOF"
    root:x:0:
    bin:x:1:
    sys:x:2:
    kmem:x:3:
    tape:x:4:
    tty: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

    exec /tools/bin/bash --login +h

    touch /var/log/{btmp,lastlog,wtmp}
    chgrp -v utmp /var/log/lastlog
    chmod -v 664 /var/log/lastlog
    chmod -v 600 /var/log/btmp
    fi

    pushd $LFS/sources
    #6.7. Linux-3.13.3 API Headers
    if [[ $STEP = "6.7" ]]; then
    tar xf linux-3.13.3.tar.xz
    cd linux-3.13.3
    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
    cd ..
    fi
    #6.8. Man-pages-3.59
    if [[ $STEP = "6.8" ]]; then
    tar -Jxf man-pages-3.59.tar.xz
    cd man-pages-3.59
    make install
    cd ..
    fi
    #6.9. Glibc-2.19
    if [[ $STEP = "6.9" ]]; then
    tar xf glibc-2.19.tar.xz
    cd glibc-2.19
    sed -i 's/\$$(pwd)/`pwd`/' timezone/Makefile
    patch -Np1 -i ../glibc-2.19-fhs-1.patch
    cd ..
    mkdir -v glibc-build
    cd glibc-build
    ../glibc-2.19/configure
    --prefix=/usr
    --disable-profile
    --enable-kernel=2.6.32
    --enable-obsolete-rpc
    make -k check 2>&1 | tee glibc-check-log
    grep Error glibc-check-log
    touch /etc/ld.so.conf
    make install
    cp -v ../glibc-2.19/nscd/nscd.conf /etc/nscd.conf
    mkdir -pv /var/cache/nscd

    mkdir -pv /usr/lib/locale
    localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
    localedef -i de_DE -f ISO-8859-1 de_DE
    localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
    localedef -i de_DE -f UTF-8 de_DE.UTF-8
    localedef -i en_GB -f UTF-8 en_GB.UTF-8
    localedef -i en_HK -f ISO-8859-1 en_HK
    localedef -i en_PH -f ISO-8859-1 en_PH
    localedef -i en_US -f ISO-8859-1 en_US
    localedef -i en_US -f UTF-8 en_US.UTF-8
    localedef -i es_MX -f ISO-8859-1 es_MX
    localedef -i fa_IR -f UTF-8 fa_IR
    localedef -i fr_FR -f ISO-8859-1 fr_FR
    localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
    localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
    localedef -i it_IT -f ISO-8859-1 it_IT
    localedef -i it_IT -f UTF-8 it_IT.UTF-8
    localedef -i ja_JP -f EUC-JP ja_JP
    localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
    localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
    localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
    localedef -i zh_CN -f GB18030 zh_CN.GB18030

    make localedata/install-locales
    cat > /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

    tar -xf ../tzdata2013i.tar.gz
    ZONEINFO=/usr/share/zoneinfo
    mkdir -pv $ZONEINFO/{posix,right}
    for tz in etcetera southamerica northamerica europe africa antarctica
    asia australasia backward pacificnew systemv; do
    zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
    zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
    zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
    done
    cp -v zone.tab iso3166.tab $ZONEINFO
    zic -d $ZONEINFO -p America/New_York
    unset ZONEINFO

    tzselect

    cp -v /usr/share/zoneinfo/<xxx> /etc/localtime

    cat > /etc/ld.so.conf << "EOF"
    # Begin /etc/ld.so.conf
    /usr/local/lib
    /opt/lib
    EOF
    cat >> /etc/ld.so.conf << "EOF"
    # Add an include directory
    include /etc/ld.so.conf.d/*.conf
    EOF
    mkdir -pv /etc/ld.so.conf.d

    cd ..
    fi

    #6.10. Adjusting the Toolchain
    if [[ $STEP = "6.10" ]]; then
    mv -v /tools/bin/{ld,ld-old}
    mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
    mv -v /tools/bin/{ld-new,ld}
    ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

    gcc -dumpspecs | sed -e 's@/tools@@g'
    -e '/*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}'
    -e '/*cpp:/{n;s@$@ -isystem /usr/include@}' >
    `dirname $(gcc --print-libgcc-file-name)`/specs

    echo 'main(){}' > dummy.c
    cc dummy.c -v -Wl,--verbose &> dummy.log
    readelf -l a.out | grep ': /lib'

    grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
    grep -B1 '^ /usr/include' dummy.log
    grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; | |g'
    grep "/lib.*/libc.so.6 " dummy.log
    grep found dummy.logs
    rm -v dummy.c a.out dummy.log

    fi
    #6.11. Zlib-1.2.8
    if [[ $STEP = "6.11" ]]; then
    tar -Jxf zlib-1.2.8.tar.xz
    cd zlib-1.2.8
    ./configure --prefix=/usr
    make
    make check
    make install
    mv -v /usr/lib/libz.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so
    cd ..
    fi
    #6.12. File-5.17
    if [[ $STEP = "6.12" ]]; then
    tar xzf file-5.17.tar.gz
    cd file-5.17
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.13. Binutils-2.24
    if [[ $STEP = "6.13" ]]; then
    tar xjf binutils-2.24.tar.bz2
    cd binutils-2.24
    expect -c "spawn ls"
    rm -fv etc/standards.info
    sed -i.bak '/^INFO/s/standards.info //' etc/Makefile.in
    cd ..

    mkdir -v binutils-build
    ../binutils-2.24/configure --prefix=/usr --enable-shared
    make tooldir=/usr
    make check
    make tooldir=/usr install
    cd binutils-build
    cd ..
    fi
    #6.14. GMP-5.1.3
    if [[ $STEP = "6.14" ]]; then
    tar -Jxf gmp-5.1.3.tar.xz
    cd gmp-5.1.3
    ./configure --prefix=/usr --enable-cxx
    make
    make check 2>&1 | tee gmp-check-log
    awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log
    make install
    mkdir -v /usr/share/doc/gmp-5.1.3
    cp -v doc/{isa_abi_headache,configuration} doc/*.html
    /usr/share/doc/gmp-5.1.3
    cd ..
    fi
    #6.15. MPFR-3.1.2
    if [[ $STEP = "6.15" ]]; then
    tar -Jxf mpfr-3.1.2.tar.xz
    cd mpfr-3.1.2
    ./configure --prefix=/usr
    --enable-thread-safe
    --docdir=/usr/share/doc/mpfr-3.1.2
    make
    make check
    make install
    make html
    make install-html
    cd ..
    fi
    #6.16. MPC-1.0.2
    if [[ $STEP = "6.16" ]]; then
    tar xzf mpc-1.0.2.tar.gz
    cd mpc-1.0.2
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.17. GCC-4.8.2
    if [[ $STEP = "6.17" ]]; then
    tar xjf gcc-4.8.2.tar.bz2
    #configure
    cd gcc-4.8.2
    case `uname -m` in
    i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;;
    esac
    sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in
    mv -v libmudflap/testsuite/libmudflap.c++/pass41-frag.cxx{,.disable}
    cd ..
    mkdir -v gcc-build
    cd gcc-build
    SED=sed
    ../gcc-4.8.2/configure
    --prefix=/usr
    --enable-shared
    --enable-threads=posix
    --enable-__cxa_atexit
    --enable-clocale=gnu
    --enable-languages=c,c++
    --disable-multilib
    --disable-bootstrap
    --with-system-zlib
    make
    ulimit -s 32768
    make -k check
    ../gcc-4.8.2/contrib/test_summary
    make install
    ln -sv ../usr/bin/cpp /lib
    ln -sv gcc /usr/bin/cc
    echo 'main(){}' > dummy.c
    cc dummy.c -v -Wl,--verbose &> dummy.log
    readelf -l a.out | grep ': /lib'
    grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

    mkdir -pv /usr/share/gdb/auto-load/usr/lib
    mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
    cd ..
    fi
    #6.18. Sed-4.2.2
    if [[ $STEP = "6.18" ]]; then
    tar xjf sed-4.2.2.tar.bz2
    cd sed-4.2.2
    ./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.2
    make
    make html
    make check
    make install
    make -C doc install-html
    cd ..
    fi
    #6.19. Bzip2-1.0.6
    if [[ $STEP = "6.19" ]]; then
    tar bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
    patch -Np1 -i ../bzip2-1.0.6-install_docs-1.patch
    sed -i 's@(ln -s -f )$(PREFIX)/bin/@1@' Makefile
    sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
    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
    cd ..
    fi
    #6.20. Pkg-config-0.28
    if [[ $STEP = "6.20" ]]; then
    tar xzf pkg-config-0.28.tar.gz
    cd pkg-config-0.28
    ./configure --prefix=/usr
    --with-internal-glib
    --disable-host-tool
    --docdir=/usr/share/doc/pkg-config-0.28
    make
    make check
    make install
    cd ..
    fi
    #6.21. Ncurses-5.9
    if [[ $STEP = "6.21" ]]; then
    tar xzf ncurses-5.9.tar.gz
    cd ncurses-5.9
    ./configure --prefix=/usr
    --mandir=/usr/share/man
    --with-shared
    --without-debug
    --enable-pc-files
    --enable-widec
    make
    make install
    mv -v /usr/lib/libncursesw.so.5* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so
    for lib in 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
    ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
    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

    mkdir -v /usr/share/doc/ncurses-5.9
    cp -v -R doc/* /usr/share/doc/ncurses-5.9
    cd ..
    fi
    #6.22. Shadow-4.1.5.1
    if [[ $STEP = "6.22" ]]; then
    tar xzf shadow_4.1.5.1.orig.tar.gz
    cd shadow_4.1.5.1

    sed -i 's/groups$(EXEEXT) //' src/Makefile.in
    find man -name Makefile.in -exec sed -i 's/groups.1 / /' {} ;

    sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@'
    -e 's@/var/spool/mail@/var/mail@' etc/login.defs

    ./configure --sysconfdir=/etc
    make
    make install
    mv -v /usr/bin/passwd /bin
    cd ..
    #pwconv grpconv
    fi
    #6.23. Psmisc-22.20
    if [[ $STEP = "6.23" ]]; then
    tar xzf psmisc-22.20.tar.gz
    cd psmisc-22.20
    ./configure --prefix=/usr
    make
    make install
    mv -v /usr/bin/fuser /bin
    mv -v /usr/bin/killall /bin
    cd ..
    fi
    #6.24. Procps-ng-3.3.9
    if [[ $STEP = "6.24" ]]; then
    tar -Jxf procps-ng-3.3.9.tar.xz
    cd procps-ng-3.3.9
    ./configure --prefix=/usr
    --exec-prefix=
    --libdir=/usr/lib
    --docdir=/usr/share/doc/procps-ng-3.3.9
    --disable-static
    --disable-kill
    make
    sed -i -r 's|(pmap_initname)\$|1|' testsuite/pmap.test/pmap.exp
    make check
    make install

    mv -v /usr/bin/pidof /bin
    mv -v /usr/lib/libprocps.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libprocps.so) /usr/lib/libprocps.so
    cd ..
    fi
    #6.25. E2fsprogs-1.42.9
    if [[ $STEP = "6.25" ]]; then
    tar xzf e2fsprogs-1.42.9.tar.gz
    cd e2fsprogs-1.42.9
    sed -i -e 's|^LD_LIBRARY_PATH.*|&:/tools/lib|' tests/test_config
    mkdir -v build
    cd build
    LIBS=-L/tools/lib
    CFLAGS=-I/tools/include
    PKG_CONFIG_PATH=/tools/lib/pkgconfig
    ../configure --prefix=/usr
    --with-root-prefix=""
    --enable-elf-shlibs
    --disable-libblkid
    --disable-libuuid
    --disable-uuidd
    --disable-fsck
    make
    make check
    make install
    make install-libs
    chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

    gunzip -v /usr/share/info/libext2fs.info.gz
    install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info

    makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo
    install -v -m644 doc/com_err.info /usr/share/info
    install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info

    cd ..
    cd ..
    fi
    #6.26. Coreutils-8.22
    if [[ $STEP = "6.26" ]]; then
    tar -Jxf coreutils-8.22.tar.xz
    cd coreutils-8.22
    patch -Np1 -i ../coreutils-8.22-i18n-4.patch
    FORCE_UNSAFE_CONFIGURE=1 ./configure
    --prefix=/usr
    --enable-no-install-program=kill,uptime
    make
    make NON_ROOT_USERNAME=nobody check-root
    echo "dummy:x:1000:nobody" >> /etc/group
    chown -Rv nobody .
    su nobody -s /bin/bash
    -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check"
    sed -i '/dummy/d' /etc/group
    make install

    mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
    mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
    mv -v /usr/bin/{rmdir,stty,sync,true,uname,test,[} /bin
    mv -v /usr/bin/chroot /usr/sbin
    mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
    sed -i s/"1"/"8"/1 /usr/share/man/man8/chroot.8

    mv -v /usr/bin/{head,sleep,nice} /bin

    cd ..
    fi
    #6.27. Iana-Etc-2.30
    if [[ $STEP = "6.27" ]]; then
    tar xjf iana-etc-2.30.tar.bz2
    cd iana-etc-2.30
    make
    make install
    cd ..
    fi
    #6.28. M4-1.4.17
    if [[ $STEP = "6.28" ]]; then
    tar -Jxf m4-1.4.17.tar.xz
    cd m4-1.4.17
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.29. Flex-2.5.38
    if [[ $STEP = "6.29" ]]; then
    tar xjf flex-2.5.38.tar.bz2
    cd flex-2.5.38
    sed -i -e '/test-bison/d' tests/Makefile.in
    ./configure --prefix=/usr --docdir=/usr/share/doc/flex-2.5.38
    make
    make check
    make install
    cd ..
    cat > /usr/bin/lex << "EOF"
    #!/bin/sh
    # Begin /usr/bin/lex
    exec /usr/bin/flex -l "$@"
    # End /usr/bin/lex
    EOF
    chmod -v 755 /usr/bin/lex
    fi
    #6.30. Bison-3.0.2
    if [[ $STEP = "6.30" ]]; then
    tar -Jxf bison-3.0.2.tar.xz
    cd bison-3.0.2
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.31. Grep-2.16
    if [[ $STEP = "6.31" ]]; then
    tar -Jxf grep-2.16.tar.xz
    cd grep-2.16
    ./configure --prefix=/usr --bindir=/bin
    make
    make check
    make install
    cd ..
    fi
    #6.32. Readline-6.2
    if [[ $STEP = "6.32" ]]; then
    tar xzf readline-6.2.tar.gz
    cd readline-6.2
    sed -i '/MV.*old/d' Makefile.in
    sed -i '/{OLDSUFF}/c:' support/shlib-install
    patch -Np1 -i ../readline-6.2-fixes-2.patch
    ./configure --prefix=/usr
    make SHLIB_LIBS=-lncurses
    make install

    mv -v /usr/lib/lib{readline,history}.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so
    ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so

    mkdir -v /usr/share/doc/readline-6.2
    install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-6.2
    cd ..
    fi
    #6.33. Bash-4.2
    if [[ $STEP = "6.33" ]]; then
    tar xzf bash-4.2.tar.gz
    cd bash-4.2
    patch -Np1 -i ../bash-4.2-fixes-12.patch
    ./configure --prefix=/usr
    --bindir=/bin
    --htmldir=/usr/share/doc/bash-4.2
    --without-bash-malloc
    --with-installed-readline
    make
    chown -Rv nobody .
    su nobody -s /bin/bash -c "PATH=$PATH make tests"
    make install
    exec /bin/bash --login +h
    cd ..
    fi
    #6.34. Bc-1.06.95
    if [[ $STEP = "6.34" ]]; then
    tar xjf bc-1.06.95.tar.bz2
    cd bc-1.06.95
    ./configure --prefix=/usr
    --with-readline
    --mandir=/usr/share/man
    --infodir=/usr/share/info
    make
    echo "quit" | ./bc/bc -l Test/checklib.b
    make install
    cd ..
    fi
    #6.35. Libtool-2.4.2
    if [[ $STEP = "6.35" ]]; then
    tar xzf libtool-2.4.2.tar.gz
    cd libtool-2.4.2
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.36. GDBM-1.11
    if [[ $STEP = "6.36" ]]; then
    tar xzf gdbm-1.11.tar.gz
    cd gdbm-1.11
    ./configure --prefix=/usr --enable-libgdbm-compat
    make
    make check
    make install
    cd ..
    fi
    #6.37. Inetutils-1.9.2
    if [[ $STEP = "6.37" ]]; then
    tar zxf inetutils-1.9.2.tar.gz
    cd inetutils-1.9.2
    echo '#define PATH_PROCNET_DEV "/proc/net/dev"' >> ifconfig/system/linux.h
    ./configure --prefix=/usr
    --localstatedir=/var
    --disable-logger
    --disable-syslogd
    --disable-whois
    --disable-servers
    make
    make check
    make install

    mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
    mv -v /usr/bin/ifconfig /sbin
    cd ..
    fi
    #6.38. Perl-5.18.2
    if [[ $STEP = "6.38" ]]; then
    tar xjf perl-5.18.2.tar.bz2
    cd perl-5.18.2
    echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
    sed -i -e "s|BUILD_ZLIBs*= True|BUILD_ZLIB = False|"
    -e "s|INCLUDEs*= ./zlib-src|INCLUDE = /usr/include|"
    -e "s|LIBs*= ./zlib-src|LIB = /usr/lib|"
    cpan/Compress-Raw-Zlib/config.in
    sh Configure -des -Dprefix=/usr
    -Dvendorprefix=/usr
    -Dman1dir=/usr/share/man/man1
    -Dman3dir=/usr/share/man/man3
    -Dpager="/usr/bin/less -isR"
    -Duseshrplib
    make
    make -k test
    make install
    cd ..
    fi
    #6.39. Autoconf-2.69
    if [[ $STEP = "6.39" ]]; then
    tar -Jxf autoconf-2.69.tar.xz
    cd autoconf-2.69
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.40. Automake-1.14.1
    if [[ $STEP = "6.40" ]]; then
    tar -Jxf automake-1.14.1.tar.xz
    cd automake-1.14.1
    ./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.14.1
    make

    sed -i "s:./configure:LEXLIB=/usr/lib/libfl.a &:" t/lex-{clean,depend}-cxx.sh
    make -j4 check
    make install

    cd ..
    fi
    #6.41. Diffutils-3.3
    if [[ $STEP = "6.41" ]]; then
    tar -Jxf diffutils-3.3.tar.xz
    cd diffutils-3.3
    sed -i 's:= @mkdir_p@:= /bin/mkdir -p:' po/Makefile.in.in
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.42. Gawk-4.1.0
    if [[ $STEP = "6.42" ]]; then
    tar -Jxf gawk-4.1.0.tar.xz
    cd gawk-4.1.0
    ./configure --prefix=/usr
    make
    make check
    make install

    mkdir -v /usr/share/doc/gawk-4.1.0
    cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.1.0
    cd ..
    fi
    #6.43. Findutils-4.4.2
    if [[ $STEP = "6.43" ]]; then
    tar xzf findutils-4.4.2.tar.gz
    cd findutils-4.4.2
    ./configure --prefix=/usr --localstatedir=/var/lib/locate
    make
    make check
    make install

    mv -v /usr/bin/find /bin
    sed -i 's/find:=${BINDIR}/find:=/bin/' /usr/bin/updatedb
    cd ..
    fi
    #6.44. Gettext-0.18.3.2
    if [[ $STEP = "6.44" ]]; then
    tar xzf gettext-0.18.3.2.tar.gz
    cd gettext-0.18.3.2
    ./configure --prefix=/usr --docdir=/usr/share/doc/gettext-0.18.3.2
    make
    make check
    make install
    cd ..
    fi
    #6.45. Groff-1.22.2
    if [[ $STEP = "6.45" ]]; then
    tar xzf groff-1.22.2.tar.gz
    cd groff-1.22.2
    PAGE=<paper_size> ./configure --prefix=/usr
    make
    make install

    ln -sv eqn /usr/bin/geqn
    ln -sv tbl /usr/bin/gtbl
    cd ..
    fi
    #6.46. Xz-5.0.5
    if [[ $STEP = "6.46" ]]; then
    tar -Jxf xz-5.0.5.tar.xz
    cd xz-5.0.5
    ./configure --prefix=/usr --docdir=/usr/share/doc/xz-5.0.5
    make
    make check
    make install

    mv -v /usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} /bin
    mv -v /usr/lib/liblzma.so.* /lib
    ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so
    cd ..
    fi
    #6.47. GRUB-2.00
    if [[ $STEP = "6.47" ]]; then
    tar -Jxf grub-2.00.tar.xz
    cd grub-2.00
    sed -i -e '/gets is a/d' grub-core/gnulib/stdio.in.h
    ./configure --prefix=/usr
    --sbindir=/sbin
    --sysconfdir=/etc
    --disable-grub-emu-usb
    --disable-efiemu
    --disable-werror
    make
    make install
    cd ..
    fi
    #6.48. Less-458
    if [[ $STEP = "6.48" ]]; then
    tar xzf less-458.tar.gz
    cd less-458
    ./configure --prefix=/usr --sysconfdir=/etc
    make
    make install
    cd ..
    fi
    #6.49. Gzip-1.6
    if [[ $STEP = "6.49" ]]; then
    tar -Jxf gzip-1.6.tar.xz
    cd gzip-1.6
    ./configure --prefix=/usr --bindir=/bin
    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
    cd ..
    fi
    #6.50. IPRoute2-3.12.0
    if [[ $STEP = "6.50" ]]; then
    tar -Jxf iproute2-3.12.0.tar.xz
    cd iproute2-3.12.0
    sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
    sed -i /ARPD/d Makefile
    sed -i 's/arpd.8//' man/man8/Makefile
    make DESTDIR=
    make DESTDIR=
    MANDIR=/usr/share/man
    DOCDIR=/usr/share/doc/iproute2-3.12.0 install
    cd ..
    fi
    #6.51. Kbd-2.0.1
    if [[ $STEP = "6.51" ]]; then
    tar xzf kbd-2.0.1.tar.gz
    cd kbd-2.0.1
    patch -Np1 -i ../kbd-2.0.1-backspace-1.patch
    sed -i 's/(RESIZECONS_PROGS=)yes/1no/g' configure
    sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in

    PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr --disable-vlock
    make
    make check
    make install

    mkdir -v /usr/share/doc/kbd-2.0.1
    cp -R -v docs/doc/* /usr/share/doc/kbd-2.0.1
    cd ..
    fi
    #6.52. Kmod-16
    if [[ $STEP = "6.52" ]]; then
    tar -Jxf kmod-16.tar.xz
    cd kmod-16
    ./configure --prefix=/usr
    --bindir=/bin
    --sysconfdir=/etc
    --with-rootlibdir=/lib
    --disable-manpages
    --with-xz
    --with-zlib
    make
    make check
    make install
    make -C man install
    for target in depmod insmod modinfo modprobe rmmod; do
    ln -sv ../bin/kmod /sbin/$target
    done
    ln -sv kmod /bin/lsmod
    cd ..
    fi
    #6.53. Libpipeline-1.2.6
    if [[ $STEP = "6.53" ]]; then
    tar xzf libpipeline-1.2.6.tar.gz
    cd libpipeline-1.2.6
    PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.54. Make-4.0
    if [[ $STEP = "6.54" ]]; then
    tar xjf make-4.0.tar.bz2
    cd make-4.0
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.55. Patch-2.7.1
    if [[ $STEP = "6.55" ]]; then
    tar -Jxf patch-2.7.1.tar.xz
    cd patch-2.7.1
    ./configure --prefix=/usr
    make
    make check
    make install
    cd ..
    fi
    #6.56. Sysklogd-1.5
    if [[ $STEP = "6.56" ]]; then
    tar xzf sysklogd-1.5.tar.gz
    cd sysklogd-1.5
    make
    make BINDIR=/sbin 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
    cd ..
    fi
    #6.57. Sysvinit-2.88dsf
    if [[ $STEP = "6.57" ]]; then
    tar xjf sysvinit-2.88dsf.tar.bz2
    cd sysvinit-2.88dsf
    patch -Np1 -i ../sysvinit-2.88dsf-consolidated-1.patch
    make -C src
    make -C src install
    cd ..
    fi
    #6.58. Tar-1.27.1
    if [[ $STEP = "6.58" ]]; then
    tar -Jxf tar-1.27.1.tar.xz
    cd tar-1.27.1
    patch -Np1 -i ../tar-1.27.1-manpage-1.patch
    FORCE_UNSAFE_CONFIGURE=1
    ./configure --prefix=/usr
    --bindir=/bin
    make
    make check
    make install
    make -C doc install-html docdir=/usr/share/doc/tar-1.27.1

    perl tarman > /usr/share/man/man1/tar.1
    cd ..
    fi
    #6.59. Texinfo-5.2
    if [[ $STEP = "6.59" ]]; then
    tar -Jxf texinfo-5.2.tar.xz
    cd texinfo-5.2
    ./configure --prefix=/usr
    make
    make check
    make install
    make TEXMF=/usr/share/texmf install-tex
    cd /usr/share/info
    rm -v dir
    for f in *
    do install-info $f dir 2>/dev/null
    done
    cd ..
    fi
    #6.60. Udev-208
    if [[ $STEP = "6.60" ]]; then
    cd systemd-208
    tar jxf ../udev-lfs-208-3.tar.bz2
    ln -svf /tools/include/blkid /usr/include
    ln -svf /tools/include/uuid /usr/include
    export LD_LIBRARY_PATH=/tools/lib
    make -f udev-lfs-208-3/Makefile.lfs

    make -f udev-lfs-208-3/Makefile.lfs install
    build/udevadm hwdb --update
    bash udev-lfs-208-3/init-net-rules.sh
    rm -fv /usr/include/{uuid,blkid}
    unset LD_LIBRARY_PATH
    cd ..
    fi
    #6.61. Util-linux-2.24.1
    if [[ $STEP = "6.61" ]]; then
    tar -Jxf util-linux-2.24.1.tar.xz
    cd util-linux-2.24.1
    sed -i -e 's@etc/adjtime@var/lib/hwclock/adjtime@g'
    $(grep -rl '/etc/adjtime' .)
    mkdir -pv /var/lib/hwclock
    ./configure
    make

    chown -Rv nobody .
    su nobody -s /bin/bash -c "PATH=$PATH make -k check"

    make install
    cd ..
    fi
    #6.62. Man-DB-2.6.6
    if [[ $STEP = "6.62" ]]; then
    tar -Jxf man-db-2.6.6.tar.xz
    cd man-db-2.6.6
    ./configure --prefix=/usr
    --docdir=/usr/share/doc/man-db-2.6.6
    --sysconfdir=/etc
    --disable-setuid
    --with-browser=/usr/bin/lynx
    --with-vgrind=/usr/bin/vgrind
    --with-grap=/usr/bin/grap
    make
    make check
    make install
    cd ..
    fi
    #6.63. Vim-7.4
    if [[ $STEP = "6.63" ]]; then
    tar xjf vim-7.4.tar.bz2
    cd vim-7.4
    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 /usr/share/man/{,*/}man1/vim.1; do
    ln -sv vim.1 $(dirname $L)/vi.1
    done
    ln -sv ../vim/vim74/doc /usr/share/doc/vim-7.4

    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
    cd ..
    fi
    #6.65. Stripping Again
    if [[ $STEP = "6.65" ]]; then
    #lfs logout
    logout
    chroot $LFS /tools/bin/env -i
    HOME=/root TERM=$TERM PS1='u:w$ '
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    /tools/bin/bash --login

    /tools/bin/find /{,usr/}{bin,lib,sbin} -type f
    -exec /tools/bin/strip --strip-debug '{}' ';'

    rm -rf /tmp/*

    chroot "$LFS" /usr/bin/env -i
    HOME=/root TERM="$TERM" PS1='u:w$ '
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    /bin/bash --login

    #rm -rf /tools
    fi

    #chap 7
    #
    #LFS-Bootscripts-20130821 lfs-bootscripts-20130821.tar.bz2
    #$LFS/sources
    popd

  • 相关阅读:
    extern “C”的作用详解
    const和typedef的常见用法详解
    虚函数、纯虚函数、虚函数与析构函数
    C++中四种类型转换方式
    面经中高频知识点归纳(一)
    leetcode Database4
    32位机和64位机下面各类型sizeof的大小
    Spring框架针对dao层的jdbcTemplate操作crud之query查询数据操作
    字符串变量的定义与引用
    使用字符数组及相关函数,求3个国家名中字母顺序排在最前面的国家。
  • 原文地址:https://www.cnblogs.com/2018/p/3981399.html
Copyright © 2020-2023  润新知