精华内容
下载资源
问答
  • LFS7.10——构建LFS系统

    2018-12-18 22:17:00
    本文正式开始构建LFS系统,后面所有命令的执行都是在root用户下完成的。 这时开始构建LFS前准备工作 更改$LFS/tools属主 chown -R root:root $LFS/tools 准备Virtual Kernel File Systems mkdir -pv $LFS/{dev,...

    参考:LFS7.10——准备Host系统

    LFS7.10——构造临时Linux系统

    本文正式开始构建LFS系统,后面所有命令的执行都是在root用户下完成的。

    这时开始构建LFS前准备工作

    更改$LFS/tools属主

    chown -R root:root $LFS/tools

    准备Virtual Kernel File Systems

    mkdir -pv $LFS/{dev,proc,sys,run}

    创建初始设备节点

    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3

    挂载和激活 /dev

    mount -v --bind /dev $LFS/dev

    挂载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

    进入 Chroot 环境

    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
    View Code

    准备LFS文件系统里面二点目录结构

    mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,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}
    View Code

    创建必需的文件和符号链接

    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
    View Code

    ln -sv /proc/self/mounts /etc/mtab

    创建/etc/passwd 文件

    cat > /etc/passwd << "EOF"
    root:x:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/dev/null:/bin/false
    daemon:x:6:6:Daemon User:/dev/null:/bin/false
    messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
    nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    EOF
    View Code

    创建/etc/group 文件

    cat > /etc/group << "EOF"
    root:x:0:
    bin:x:1:daemon
    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:
    adm:x:16:
    messagebus:x:18:
    systemd-journal:x:23:
    input:x:24:
    mail:x:34:
    nogroup:x:99:
    users:x:999:
    EOF
    View Code

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

    初始化一下日志文件并加上合适的权限

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

    安装Linux-4.7.2 API Headers

    tar -xvf linux-4.7.2.tar.xz
    cd linux-4.7.2
    make mrproper
    make INSTALL_HDR_PATH=dest headers_install
    find dest/include \( -name .install -o -name ..install.cmd \) -delete
    cp -rv dest/include/* /usr/include
    cd ..
    rm -rf linux-4.7.2

    安装Man-pages

    tar -xvf man-pages-4.07.tar.xz
    cd man-pages-4.07
    make install
    cd ..
    rm -rf man-pages-4.07

    Glibc

    安装

    tar -xvf glibc-2.24.tar.xz
    cd glibc-2.24
    patch -Np1 -i ../glibc-2.24-fhs-1.patch
    mkdir -v build
    cd build

    ../configure --prefix=/usr \
    --enable-kernel=2.6.32 \
    --enable-obsolete-rpc
    View Code

    make -j8

    make check

    touch /etc/ld.so.conf
    make install

    cp -v ../nscd/nscd.conf /etc/nscd.conf
    mkdir -pv /var/cache/nscd
    View Code
    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
    View Code

    make localedata/install-locales

    配置Glibc

    创建一个新文件/etc/nsswitch.conf

    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
    View Code

    安装时区数据:

    tar -xf ../../tzdata2016f.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 zone1970.tab iso3166.tab $ZONEINFO
    zic -d $ZONEINFO -p America/New_York
    unset ZONEINFO
    View Code

    tzselect

    cp -v /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

    配置Dynamic Loader

    创建/etc/ld.so.conf

    cat > /etc/ld.so.conf << "EOF"
    # Begin /etc/ld.so.conf
    /usr/local/lib
    /opt/lib
    EOF
    View Code
    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
    View Code

    调整工具链

    与LFS7.10 Adjusting the Toolchain 预期结果不符,还在排查问题,未完待续。。。

     

    转载于:https://www.cnblogs.com/kelamoyujuzhen/p/10140532.html

    展开全文
  • 文章目录准备虚拟内核文件系统进入Chroot环境创建目录与一些必要的文件和符号连接安装必要的软件包(前边临时系统构建正确的话,一般在编译期间不会出现错误)编译内核让LFS系统可引导LFS系统的完成与启动结语 ...


    上文说到:构建 LFS 的临时系统已经完成。本篇将进行正式 LFS 系统的构建工作。

    准备虚拟内核文件系统

    基本步骤

    • 创建将用来挂载文件系统的目录
    • 创建初始设备节点
    • 挂载和激活 /dev
    • 挂载虚拟文件系统

    完成上述步骤的脚本文件内容为:

    #!/bin/bash
    LFS=/home/lfs/LFS_FS
    chown -R root:root $LFS/tools
    mkdir -pv $LFS/{dev,proc,sys,run}
    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3
    mount -v --bind /dev $LFS/dev
    
    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
    

    进入Chroot环境

    现在可以切换到 chroot 环境开始构建和安装最终的 LFS 系统了。以 root 用户运行下面的命令进入此环境:

    chroot "$LFS" /tools/bin/env -i \
     HOME=/root \
     TERM="$TERM" \
     PS1='(lfs tools bash!) \u:\w\$ ' \
     PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
     /tools/bin/bash --login +h
    

    创建目录与一些必要的文件和符号连接

    首先需要创建一些必要的目录,有些程序里会使用写死的路径调用其它暂时还未安装的程序。为了满足这种类型程序的需要,需要创建一些符号链接。这些步骤的执行脚本为:

    if [ -f /etc/passwd ]; then
     echo "system ok "
     exit 0
    fi
    
    
    echo "create dir"
    mkdir -p /{bin,boot,root,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
    mkdir -p /{media/{floppy,cdrom},sbin,srv,var}
    install -d -m 0750 /root
    install -d -m 1777 /tmp /var/tmp
    mkdir -p /usr/{,local/}{bin,include,lib,sbin,src}
    mkdir -p /usr/{,local/}share/{color,dict,doc,info,locale,man}
    mkdir  /usr/{,local/}share/{misc,terminfo,zoneinfo}
    mkdir  /usr/libexec
    mkdir -p /usr/{,local/}share/man/man{1..8}
    case $(uname -m) in
     x86_64) mkdir -v /lib64 ;;
    esac
    mkdir /var/{log,mail,spool}
    ln -s /run /var/run
    ln -s /run/lock /var/lock
    mkdir -p /var/{opt,cache,lib/{color,misc,locate},local}
    
    ln -s /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin
    ln -s /tools/bin/{env,install,perl,printf} /usr/bin
    ln -s /tools/lib/libgcc_s.so{,.1} /usr/lib
    ln -s /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
    install -dm755 /usr/lib/pkgconfig
    ln -s bash /bin/sh
    
    ln -s /proc/self/mounts /etc/mtab
    
    
    cat > /root/.bashrc << "EOF"
    set +h 
    umask 022
    MAKEFLAGS='-j 6'
    export MAKEFLAGS
    alias ls="ls --color"
    EOF
    
    echo "create /etc/passwd"
    cat > /etc/passwd << "EOF"
    root:x:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/dev/null:/bin/false
    daemon:x:6:6:Daemon User:/dev/null:/bin/false
    messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
    systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
    systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
    systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
    systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
    systemd-network:x:76:76:systemd Network Management:/:/bin/false
    systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
    systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
    systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
    nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
    EOF
    
    echo "create /etc/group"
    cat > /etc/group << "EOF"
    root:x:0:
    bin:x:1:daemon
    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:
    adm:x:16:
    messagebus:x:18:
    systemd-journal:x:23:
    input:x:24:
    mail:x:34:
    kvm:x:61:
    systemd-bus-proxy:x:72:
    systemd-journal-gateway:x:73:
    systemd-journal-remote:x:74:
    systemd-journal-upload:x:75:
    systemd-network:x:76:
    systemd-resolve:x:77:
    systemd-timesync:x:78:
    systemd-coredump:x:79:
    wheel:x:97:
    nogroup:x:99:
    users:x:999:
    EOF
    
    echo "create log file"
    touch /var/log/{btmp,lastlog,faillog,wtmp}
    chgrp -v utmp /var/log/lastlog
    chmod -v 664 /var/log/lastlog
    chmod -v 600 /var/log/btmp
    
    #exec /tools/bin/bash --login +h
    

    安装必要的软件包(前边临时系统构建正确的话,一般在编译期间不会出现错误)

    • Linux-5.1.6 API 头文件
      Linux API 头文件会将内核 API 导出给 Glibc 使用.
    cd /build/linux-5.1.6
    make mrproper
    make INSTALL_HDR_PATH=dest headers_install 
    if [ $? != 0 ] ;then
    echo "make kernel-headers error!"
    exit 1;
    else
    find dest/include \( -name .install -o -name ..install.cmd \) -delete
    cp -rv dest/include/* /usr/include 
    fi
    
    • Man-pages ,Man-pages 软件包里包含了超过 2,200 份 man 手册页面。
      执行脚本:
    cd /build/8.4/
    tar -xf man-pages-4.16.tar.xz 
    cd man-pages-4.16
    make install   || exit 1
    
    • Glibc,Glibc 软件包包含了主要的 C 函数库。这个库提供了分配内存、搜索目录、打开关闭文件、读写文件、操作字符串、模式匹配、基础算法等基本程序。
      执行脚本:
    cd /build/8.4/
    tar -xf glibc-2.29.tar.xz
    cd glibc-2.29
    patch -Np1 -i ../glibc-2.29-fhs-1.patch
    ln -sfv /tools/lib/gcc /usr/lib
    case $(uname -m) in
     i?86) GCC_INCDIR=/usr/lib/gcc/$(uname -m)-pc-linux-gnu/8.2.0/include
     ln -sfv ld-linux.so.2 /lib/ld-lsb.so.3
     ;;
     x86_64) GCC_INCDIR=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include
     ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64
     ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
     ;;
    esac
    
    rm -f /usr/include/limits.h
    
    mkdir -v build
    cd build
    
    CC="gcc -isystem $GCC_INCDIR -isystem /usr/include" \
    ../configure --prefix=/usr \
     --disable-werror \
     --enable-kernel=3.2 \
     --enable-stack-protector=strong \
     libc_cv_slibdir=/lib 
    unset GCC_INCDIR
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    touch /etc/ld.so.conf
    sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    touch /etc/ld.so.conf
    
    cp -v ../nscd/nscd.conf /etc/nscd.conf
    mkdir -pv /var/cache/nscd
    
    install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
    install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.servic
    
    
    
    
    mkdir -pv /usr/lib/locale
    localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
    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 el_GR -f ISO-8859-7 el_GR
    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 ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true
    localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
    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
    localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS
    
    
    make check   || echo "check error"
    
    
    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 ../../tzdata2018i.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 ${tz}
     zic -L /dev/null -d $ZONEINFO/posix ${tz}
     zic -L leapseconds -d $ZONEINFO/right ${tz}
    done
    cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
    zic -d $ZONEINFO -p America/New_York
    unset ZONEINFO
    
    cat > /etc/ld.so.conf << "EOF"
    # Begin /etc/ld.so.conf
    /usr/local/lib
    /opt/lib
    
    # Add an include directory
    include /etc/ld.so.conf.d/*.conf
    
    EOF
    mkdir -pv /etc/ld.so.conf.d
    
    ln -sfv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
    • 调整工具链
      现在最后的 C 语言库已经装好了,是时候调整工具链,让新编译的程序链接到这些新的库上。
      执行脚本:
    
    mv  /tools/bin/{ld,ld-old}
    mv  /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old}
    mv  /tools/bin/{ld-new,ld}
    ln -s /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/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 'int main(){}' > dummy.c
    cc dummy.c -v -Wl,--verbose &> dummy.log
    readelf -l a.out | grep ': /lib'
    
    if [ $? != 0 ] ;then
    echo "ld-linux error!"
    exit 1;
    fi
    
    echo ==========================1
    grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
    echo ==========================2
    grep -B1 '^ /usr/include' dummy.log
    echo ==========================
    grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
    echo ==========================3
    grep "/lib.*/libc.so.6 " dummy.log
    echo =========================4
    grep found dummy.log
    if [ $? != 0 ] ;then
    echo "ld-linux error!"
    exit 1;
    fi
    echo =========================5
    rm -v dummy.c a.out dummy.log
    
    • Zlib,Zlib 软件包包括一些程序所使用的压缩和解压缩例程。
      执行脚本:
    cd /build/8.4
    tar -xf zlib-1.2.11.tar.xz
    cd zlib-1.2.11
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/lib/libz.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so
    
    • File,File 软件包包括一个判断给定的某个或某些文件文件类型的工具。
      执行脚本:
    cd /build/8.4
    tar -xf file-5.36.tar.gz
    cd file-5.36
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    • Readline,Readline 软件包是提供命令行编辑和历史功能的库的集合。
      执行脚本:
    cd /build/8.4
    tar -xf readline-8.0.tar.gz
    cd readline-8.0
    sed -i '/MV.*old/d' Makefile.in
    sed -i '/{OLDSUFF}/c:' support/shlib-install
    ./configure --prefix=/usr \
     --disable-static \
     --docdir=/usr/share/doc/readline-8.0  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make SHLIB_LIBS="-L/tools/lib -lncursesw" 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make SHLIB_LIBS="-L/tools/lib -lncursesw" install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/lib/lib{readline,history}.so.* /lib
    chmod -v u+w /lib/lib{readline,history}.so.*
    ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so
    ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so
    
    • M4
    cd /build/8.4
    tar -xf m4-1.4.18.tar.xz
    cd m4-1.4.18
    sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
    echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Bc,Bc 软件包包括一个任意精度数值处理的语言。
      执行脚本:
    cd /build/8.4
    tar -xf bc-1.07.1.tar.gz
    cd bc-1.07.1
    
    cat > bc/fix-libmath_h << "EOF"
    #! /bin/bash
    sed -e '1 s/^/{"/' \
     -e 's/$/",/' \
     -e '2,$ s/^/"/' \
     -e '$ d' \
     -i libmath.h
    sed -e '$ s/$/0}/' \
     -i libmath.h
    EOF
    
    ln -sv /tools/lib/libncursesw.so.6 /usr/lib/libncursesw.so.6
    ln -sfv libncursesw.so.6 /usr/lib/libncurses.so
    sed -i -e '/flex/s/as_fn_error/: ;; # &/' configure
    
    ./configure --prefix=/usr \
     --with-readline \
     --mandir=/usr/share/man \
     --infodir=/usr/share/info  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    echo "quit" | ./bc/bc -l Test/checklib.b 
    
    • Binutils,Binutils 软件包包含一个链接器、一个汇编器、以及其它处理目标文件的工具。
      脚本:
    cd /build/8.4
    tar -xf binutils-2.32.tar.xz
    cd binutils-2.32
    
    expect -c "spawn ls" | grep spawn 
    if [ $? != 0 ] ;then
    echo "expect test error!"
    exit 1;
    fi
    
    mkdir build
    cd build
    
    ../configure --prefix=/usr \
     --enable-gold \
     --enable-ld=default \
     --enable-plugins \
     --enable-shared \
     --disable-werror \
     --enable-64-bit-bfd \
     --with-system-zlib  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make  tooldir=/usr 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make  tooldir=/usr install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make  -k check   || echo "check error"
    
    • GMP,GMP 软件包包含一些数学库。这里有对任意精度数值计算很有用的函数。
      执行脚本:
    cd /build/8.4
    tar -xf gmp-6.1.2.tar.xz
    cd gmp-6.1.2
    
    ./configure --prefix=/usr \
     --enable-cxx \
     --disable-static \
     --docdir=/usr/share/doc/gmp-6.1.2  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error"
    exit 1;
    else
    make html 
    fi
    
    if [ $? != 0 ] ;then
    echo "make html error"
    exit 1;
    else
    make check 2>&1 | tee gmp-check-log  
    fi
    
    awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log | grep 190
    
    
    
    
    if [ $? != 0 ] ;then
    echo "check  error! not 190"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make install-html ||echo "make install-html failed"
    
    • MPFR,MPFR 软件包包含多精度数学函数。
      执行脚本:
    cd /build/8.4
    tar -xf mpfr-4.0.2.tar.xz 
    cd mpfr-4.0.2
    
    ./configure --prefix=/usr \
     --disable-static \
     --enable-thread-safe \
     --docdir=/usr/share/doc/mpfr-4.0.2   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error"
    exit 1;
    else
    make html  
    fi
    
    
    if [ $? != 0 ] ;then
    echo "make html error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    else 
    make install-html 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install-html error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • MPC,MPC 软件包包含一个能以任意高精度进行复数数值计算和对结果进行正确四舍五入的库。
      执行脚本:
    cd /build/8.4
    tar -xf mpc-1.1.0.tar.gz
    cd mpc-1.1.0
    
    ./configure --prefix=/usr \
     --disable-static \
     --docdir=/usr/share/doc/mpc-1.1.0   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error"
    exit 1;
    else
    make html  
    fi
    
    
    if [ $? != 0 ] ;then
    echo "make html error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    else 
    make install-html 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install-html error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Shadow,Shadow 软件包包含以安全方式处理密码的程序。
      执行脚本:
    cd /build/8.4
    tar -xf shadow-4.6.tar.xz
    cd shadow-4.6
    
    sed -i 's/groups$(EXEEXT) //' src/Makefile.in
    find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;
    find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
    find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \;
    
    sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
     -e 's@/var/spool/mail@/var/mail@' etc/login.defs
    
    
    ./configure --sysconfdir=/etc --with-group-name-max-length=32   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/bin/passwd /bin
    pwconv
    grpconv
    sed -i 's/yes/no/' /etc/default/useradd
    echo root:root | chpasswd
    
    • GCC,GCC 软件包包括 GNU 编译器集,其中有 C 和 C++ 的编译器。
      执行脚本:
    cd /build/8.4
    tar -xf gcc-8.2.0.tar.xz
    cd gcc-8.2.0
    
    case $(uname -m) in
     x86_64)
     sed -e '/m64=/s/lib64/lib/' \
     -i.orig gcc/config/i386/t-linux64
     ;;
    esac
    
    rm -f /usr/lib/gcc
    mkdir -v build
    cd build
    
    SED=sed \
    ../configure --prefix=/usr \
     --enable-languages=c,c++ \
     --disable-multilib \
     --disable-bootstrap \
     --disable-libmpx \
     --with-system-zlib   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    ln -sv ../usr/bin/cpp /lib
    ln -sv gcc /usr/bin/cc
    
    install -v -dm755 /usr/lib/bfd-plugins
    ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/8.2.0/liblto_plugin.so  /usr/lib/bfd-plugins/
    
    
    ulimit -s 32768
    rm ../gcc/testsuite/g++.dg/pr83239.C
    chown -Rv nobody .
    su nobody -s /bin/bash -c "PATH=$PATH make -k check"  || echo "gcc check error!"
    ../contrib/test_summary > /gcc_test
    
    
    echo 'int main(){}' > dummy.c
    cc dummy.c -v -Wl,--verbose &> dummy.log
    
    echo ======================ld-linux=================================
    readelf -l a.out | grep ': /lib'
    echo ======================crt1.o crti.o crtn.o==============================
    grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
    echo =====================include===================
    grep -B4 '^ /usr/include' dummy.log
    echo =====================SEARCH_DIR ===============================
    grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
    echo =====================libc.so.6 ===============================
    grep "/lib.*/libc.so.6 " dummy.log
    echo ======================= at /lib/ld-linux-x86-64.so.2  ====================
    grep found dummy.log
    echo ======================================================================
    echo "check result and check gcc_test whit http://www.linuxfromscratch.org/lfs/build-logs/8.4 (anykey to pass):"
    #read 
    
    rm -v dummy.c a.out dummy.log
    
    mkdir -pv /usr/share/gdb/auto-load/usr/lib
    mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
    
    • Bzip2
      执行脚本:
    cd /build/8.4
    tar -xf 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
    
    if [ $? != 0 ] ;then
    echo "Makefile-libbz2_so error!"
    exit 1;
    else
    make clean 
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make PREFIX=/usr install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    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
    
    • Pkg-config,pkg-config 软件包包含一个在配置和 make 文件运行时把 include 路径和库路径传递给编译工具的工具。
      执行脚本:
    cd /build/8.4
    tar -xf pkg-config-0.29.2.tar.gz
    cd pkg-config-0.29.2
    
    ./configure --prefix=/usr \
     --with-internal-glib \
     --disable-host-tool \
     --docdir=/usr/share/doc/pkg-config-0.29.2   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    • Ncurses,Ncurses 软件包包含用于不依赖于特定终端的字符屏幕处理的库。
      执行脚本:
    cd /build/8.4
    tar -xf ncurses-6.1.tar.gz
    cd ncurses-6.1
    
    sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in
    
    ./configure --prefix=/usr \
     --mandir=/usr/share/man \
     --with-shared \
     --without-debug \
     --without-normal \
     --enable-pc-files \
     --enable-widec   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/lib/libncursesw.so.6* /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}w.pc /usr/lib/pkgconfig/${lib}.pc
    done
    
    rm -vf /usr/lib/libcursesw.so
    echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
    ln -sfv libncurses.so /usr/lib/libcurses.so
    mkdir -v /usr/share/doc/ncurses-6.1
    cp -v -R doc/* /usr/share/doc/ncurses-6.1
    
    
    make distclean
    ./configure --prefix=/usr \
     --with-shared \
     --without-normal \
     --without-debug \
     --without-cxx-binding \
     --with-abi-version=5  
    make sources libs  
    cp -av lib/lib*.so.5* /usr/lib
    
    • Attr,attr 软件包包含管理文件系统对象的扩展属性的工具。
      执行脚本:
    cd /build/8.4
    tar -xf attr-2.4.48.tar.gz
    cd attr-2.4.48
    
    ./configure --prefix=/usr \
     --disable-static \
     --sysconfdir=/etc \
     --docdir=/usr/share/doc/attr-2.4.48   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    mv -v /usr/lib/libattr.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so
    
    • Acl,Acl 软件包包含管理访问控制列表的工具,访问控制列表用于定义文件和目录更细粒度的自定义访问权限。
      脚本:
    cd /build/8.4
    tar -xf acl-2.2.53.tar.gz
    cd acl-2.2.53
    
    ./configure --prefix=/usr \
     --disable-static \
     --libexecdir=/usr/lib \
     --docdir=/usr/share/doc/acl-2.2.53   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    mv -v /usr/lib/libacl.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libacl.so) /usr/lib/libacl.so
    
    • Libcap,Libcap 软件包实现了可用在 Linux 内核上的对 POSIX 1003.1e 功能的用户空间接口。这些功能将所有强大root 权限划分为不同的权限组合。
      脚本:
    cd /build/8.4
    tar -xf libcap-2.26.tar.xz
    
    
    cd libcap-2.26
    
    make 
    
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make RAISE_SETFCAP=no lib=lib prefix=/usr install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    chmod -v 755 /usr/lib/libcap.so.2.26
    mv -v /usr/lib/libcap.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libcap.so) /usr/lib/libcap.so
    
    • Sed,Sed 软件包包含一个流编辑器。
      执行脚本:
    cd /build/8.4
    tar -xf sed-4.7.tar.xz
    cd sed-4.7
    
    sed -i 's/usr/tools/' build-aux/help2man
    sed -i 's/testsuite.panic-tests.sh//' Makefile.in
    
    
    ./configure --prefix=/usr  --bindir=/bin   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make html 
    fi
    
    if [ $? != 0 ] ;then
    echo "make html error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    install -d -m755 /usr/share/doc/sed-4.7
    install -m644 doc/sed.html /usr/share/doc/sed-4.7
    
    • Psmisc,Psmisc 软件包包含用于显示运行中进程信息的程序。
      执行脚本:
    cd /build/8.4
    tar -xf psmisc-23.2.tar.xz
    cd psmisc-23.2
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/bin/fuser /bin
    mv -v /usr/bin/killall /bin
    
    • Iana-Etc,Iana-Etc 软件包为网络服务和协议提供数据。
      执行脚本:
    cd /build/8.4
    tar -xf iana-etc-2.30.tar.bz2
    cd iana-etc-2.30
    
    make 
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    • Bison,Bison 软件包包含一个语法生成器。
      执行脚本:
    cd /build/8.4
    tar -xf bison-3.3.2.tar.xz
    cd bison-3.3.2
    
    ./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.3.2   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    • Flex,Flex 软件包包括一个用于生成识别文本模式的程序的工具。
      执行脚本:
    cd /build/8.4
    tar -xf flex-2.6.4.tar.gz
    cd flex-2.6.4
    sed -i "/math.h/a #include <malloc.h>" src/flexdef.h
    HELP2MAN=/tools/bin/true \
    ./configure --prefix=/usr \
                --docdir=/usr/share/doc/flex-2.6.4   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    ln -sv flex /usr/bin/lex
    
    • Grep,Grep 软件包包含用于在文件中搜索的程序。
      执行脚本:
    cd /build/8.4
    tar -xf grep-3.3.tar.xz
    cd grep-3.3
    
    ./configure --prefix=/usr --bindir=/bin   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make -k check   || echo "check error"
    
    • Bash,Bash 软件包包含 Bourne-Again Shell。
      执行脚本:
    cd /build/8.4
    tar -xf bash-5.0.tar.gz
    cd bash-5.0
    
    ./configure --prefix=/usr \
     --docdir=/usr/share/doc/bash-5.0 \
     --without-bash-malloc \
     --with-installed-readline \
      
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    chown -Rv nobody .
    
    
    su nobody -s /bin/bash -c "PATH=$PATH HOME=/home make tests" \
       || echo "check error"
       
    mv -vf /usr/bin/bash /bin
    #exec /bin/bash --login +h
    
    #PS1='(chroot) \u:\w >'
    
    • Libtool-2.4.6
      Libtool 软件包包含 GNU 通用库支持脚本。它用一致的、可移植的接口封装复杂的共享库。执行脚本:
    cd /build/8.4
    tar -xf libtool-2.4.6.tar.xz
    cd libtool-2.4.6
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • GDBM
      GDBM 软件包包含 GNU 数据库管理器。是使用扩展散列,工作方法和标准 UNIX dbm 类似的数据库函数库。该库提供存储键/数据对、通过键搜索和检索数据、以及删除键和数据的原语。执行脚本:
    cd /build/8.4
    tar -xf gdbm-1.18.1.tar.gz
    cd gdbm-1.18.1
    
    ./configure --prefix=/usr \
      --disable-static \
      --enable-libgdbm-compat  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Gperf,Gperf 为键集合生成完美的哈希函数。
      执行脚本:
    cd /build/8.4
    tar -xf gperf-3.1.tar.gz
    cd gperf-3.1
    
    ./configure --prefix=/usr  --docdir=/usr/share/doc/gperf-3.1   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make  -j1 check   || echo "check error"
    
    • Expat
      Expat 软件包包含一个用于解析 XML 的面向流的 C 库。执行脚本:
    cd /build/8.4
    tar -xf expat-2.2.6.tar.bz2
    cd expat-2.2.6
    
    sed -i 's|usr/bin/env |bin/|' run.sh.in
    
    ./configure --prefix=/usr --disable-static \
     --docdir=/usr/share/doc/expat-2.2.6   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.2.6
    
    • Inetutils
      Inetutils 软件包包含基本的网络程序。
      执行脚本:
    cd /build/8.4
    tar -xf inetutils-1.9.4.tar.xz
    cd inetutils-1.9.4
    
    ./configure --prefix=/usr \
     --localstatedir=/var \
     --disable-logger \
     --disable-whois \
     --disable-rcp \
     --disable-rexec \
     --disable-rlogin \
     --disable-rsh \
     --disable-servers  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
    mv -v /usr/bin/ifconfig /sbin
    
    • Perl
      Perl 软件包包含实用信息抽取与报告语言。
      执行脚本:
    cd /build/8.4
    tar -xf perl-5.28.1.tar.xz
    
    cd perl-5.28.1
    echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
    export BUILD_ZLIB=False
    export BUILD_BZIP2=0
    
    sh Configure -des -Dprefix=/usr \
     -Dvendorprefix=/usr \
     -Dman1dir=/usr/share/man/man1 \
     -Dman3dir=/usr/share/man/man3 \
     -Dpager="/usr/bin/less -isR" \
     -Duseshrplib \
     -Dusethreads   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make -k check   || echo "check error"
    unset BUILD_ZLIB BUILD_BZIP2
    
    • XML::Parser
      XML::Parser 模块是到 James Clark 的 XML 解析器的 Perl Expat 接口。
      执行脚本:
    cd /build/8.4
    tar -xf XML-Parser-2.44.tar.gz
    cd XML-Parser-2.44
    
    perl Makefile.PL   
    
    if [ $? != 0 ] ;then
    echo "create makefile error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make test   || echo "check error"
    
    • Intltool
      Intltool 是一个用于从源文件中抽取可翻译字符串的国际化工具。
      执行脚本:
    cd /build/8.4
    tar -xf intltool-0.51.0.tar.gz
    cd intltool-0.51.0
    
    sed -i 's:\\\${:\\\$\\{:' intltool-update.in
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO
    
    • Autoconf
      Autoconf 软件包包含用于生成自动配置源代码的 shell 脚本的程序。
      执行脚本:
    cd /build/8.4
    tar -xf autoconf-2.69.tar.xz
    cd autoconf-2.69
    sed '361 s/{/\\{/' -i bin/autoscan.in
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Automake
      软件包包含了生成可与 Autoconf 一同使用的 Makefile 的程序。
      执行脚本:
    cd /build/8.4
    tar -xf automake-1.16.1.tar.xz
    cd automake-1.16.1
    
    ./configure --prefix=/usr  --docdir=/usr/share/doc/automake-1.16.1  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make -j4 check   || echo "check error"
    
    • Xz
      Xz 软件包包含用于压缩和解压文件的程序。它提供 lzma 和更新的 xz 压缩格式功能。和传统的 gzip 或 bzip2命令相比,用 xz 压缩文本文件能获得更好的压缩率。
      执行脚本:
    cd /build/8.4
    tar -xf xz-5.2.4.tar.xz
    cd xz-5.2.4
    
    ./configure --prefix=/usr --disable-static \
     --docdir=/usr/share/doc/xz-5.2.4   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    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
    
    • Kmod
      Kmod 软件包包含用于加载内核模块的库和工具。
      执行脚本:
    cd /build/8.4
    tar -xf kmod-26.tar.xz
    cd kmod-26
    
    ./configure --prefix=/usr \
    --bindir=/bin \
     --sysconfdir=/etc \
     --with-rootlibdir=/lib \
     --with-xz \
     --with-zlib  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    for target in depmod insmod lsmod modinfo modprobe rmmod; do
     ln -sfv ../bin/kmod /sbin/$target
    done
    ln -sfv kmod /bin/lsmod
    
    • Gettext
      执行脚本:
    cd /build/8.4
    tar -xf gettext-0.19.8.1.tar.xz
    cd gettext-0.19.8.1
    sed -i '/^TESTS =/d' gettext-runtime/tests/Makefile.in &&
    sed -i 's/test-lock..EXEEXT.//' gettext-tools/gnulib-tests/Makefile.in
    sed -e '/AppData/{N;N;p;s/\.appdata\./.metainfo./}' \
     -i gettext-tools/its/appdata.loc
    
    
    
    ./configure --prefix=/usr \
     --disable-static \
     --docdir=/usr/share/doc/gettext-0.19.8.1   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    chmod -v 0755 /usr/lib/preloadable_libintl.so
    
    • Elfutils
      Libelf 是处理 ELF(可执行与可链接格式)文件的库。
      执行脚本:
    cd /build/8.4
    tar -xf elfutils-0.176.tar.bz2
    cd elfutils-0.176
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make -C  libelf install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    install -vm644 config/libelf.pc /usr/lib/pkgconfig
    
    • Libffi
      Libffi 库为各种调用规范提供了一个可移植的,高级编程接口。允许程序员在运行时,通过调用接口描述调用任意指定函数。
      执行脚本:
    cd /build/8.4
    tar -xf libffi-3.2.1.tar.gz
    cd libffi-3.2.1
    
    sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \
     -i include/Makefile.in
    sed -e '/^includedir/ s/=.*$/=@includedir@/' \
     -e 's/^Cflags: -I${includedir}/Cflags:/' \
     -i libffi.pc.in
    
    
    ./configure --prefix=/usr --disable-static --with-gcc-arch=native   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    • OpenSSL
      OpenSSL 软件包包含管理工具和加密相关的库。其中提供的这些加密功能对于其他软件包,比方说OpenSSH,email 应用和网页浏览器(访问 HTTPS 站点)来说,十分有用。
      执行脚本:
    cd /build/8.4
    tar -xf openssl-1.1.1a.tar.gz
    cd openssl-1.1.1a
    
    ./Configure --prefix=/usr --openssldir=/etc/ssl \
     --libdir=lib \
     shared \
     zlib-dynamic linux-$(uname -m)  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
    make  MANSUFFIX=ssl install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make test   || echo "check error"
    mv -v /usr/share/doc/openssl /usr/share/doc/openssl-1.1.1a
    cp -vfr doc/* /usr/share/doc/openssl-1.1.1a
    
    • Python
      执行脚本:
    cd /build/8.4
    tar -xf Python-3.7.2.tar.xz
    cd Python-3.7.2
    
    ./configure --prefix=/usr --enable-shared \
     --with-system-expat \
     --with-system-ffi \
     --with-ensurepip=yes   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    chmod -v 755 /usr/lib/libpython3.7m.so
    chmod -v 755 /usr/lib/libpython3.so
    install -v -dm755 /usr/share/doc/python-3.7.2/html
    tar --strip-components=1 \
     --no-same-owner \
     --no-same-permissions \
     -C /usr/share/doc/python-3.7.2/html \
     -xvf ../python-3.7.2-docs-html.tar.bz2
    
    • Ninja
      执行脚本:
    cd /build/8.4
    tar -xf ninja-1.9.0.tar.gz
    cd ninja-1.9.0
    export NINJAJOBS=6
    sed -i '/int Guess/a \
     int j = 0;\
     char* jobs = getenv( "NINJAJOBS" );\
     if ( jobs != NULL ) j = atoi( jobs );\
     if ( j > 0 ) return j;\
    ' src/ninja.cc
    
    python3 configure.py --bootstrap
    
    if [ $? != 0 ] ;then
    echo "configure.py error!"
    exit 1;
    else
    install -vm755 ninja /usr/bin/
    install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
    install -vDm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja
    fi
    
    python3 configure.py
    ./ninja ninja_test
    ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
    
    • Meson
      Meson 是一个开源代码构建系统,不仅速度非常快,而且更重要的是对用户极其友好。
      执行脚本:
    cd /build/8.4
    tar -xf meson-0.49.2.tar.gz
    cd meson-0.49.2
    python3 setup.py build 
    
    if [ $? != 0 ] ;then
    echo "setup.py error!"
    exit 1;
    else
    python3 setup.py install --root=dest 
    cp -r dest/* /
    fi
    
    • Coreutils
      Coreutils 软件包包含用于显示和设置基本系统特性的工具。
      执行脚本:
    cd /build/8.4
    tar -xf coreutils-8.30.tar.xz
    cd coreutils-8.30
    patch -Np1 -i ../coreutils-8.30-i18n-1.patch 
    
    sed -i '/test.lock/s/^/#/' gnulib-tests/gnulib.mk
    
    autoreconf -fiv
    FORCE_UNSAFE_CONFIGURE=1 ./configure \
     --prefix=/usr \
     --enable-no-install-program=kill,uptime  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    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"  ||ehco "test error!"
    sed -i '/dummy/d' /etc/group
    
    mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
    mv -v /usr/bin/{rmdir,stty,sync,true,uname} /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,nice,sleep,touch} /bin
    mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
    
    • Check
      Check 是 C 语言的单元测试框架。
      执行脚本:
    cd /build/8.4
    tar -xf check-0.12.0.tar.gz
    cd check-0.12.0
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    sed -i '1 s/tools/usr/' /usr/bin/checkmk
    
    • Diffutils
      Diffutils 软件包包含显示文件和目录差异的程序。
      执行脚本:
    cd /build/8.4
    tar -xf diffutils-3.7.tar.xz
    cd diffutils-3.7
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Gawk
      执行脚本:
    cd /build/8.4
    tar -xf gawk-4.2.1.tar.xz
    cd gawk-4.2.1
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    mkdir  /usr/share/doc/gawk-4.2.1
    cp  doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.2.1
    
    • Findutils
      执行脚本:
    cd /build/8.4
    tar -xf findutils-4.6.0.tar.gz
    cd findutils-4.6.0
    sed -i 's/test-lock..EXEEXT.//' tests/Makefile.in
    sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' gl/lib/*.c
    sed -i '/unistd/a #include <sys/sysmacros.h>' gl/lib/mountlist.c
    echo "#define _IO_IN_BACKUP 0x100" >> gl/lib/stdio-impl.h
    
    
    
    ./configure --prefix=/usr  --localstatedir=/var/lib/locate   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    mv  /usr/bin/find /bin
    sed -i 's|find:=${BINDIR}|find:=/bin|' /usr/bin/updatedb
    
    • Groff
      Groff 软件包包含用于处理和格式化文本的程序。
      执行脚本:
    cd /build/8.4
    tar -xf groff-1.22.4.tar.gz
    cd groff-1.22.4
    
    PAGE=A4 ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make -j1 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • GRUB
      GRUB 软件包包含多重启动管理器。
      执行脚本:
    cd /build/8.4
    tar -xf grub-2.02.tar.xz
    cd grub-2.02
    
    ./configure --prefix=/usr --sbindir=/sbin \
     --sysconfdir=/etc \
     --disable-efiemu \
     --disable-werror   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions
    
    • Less
      Less 软件包包含一个文本文件查看器。
      执行脚本:
    cd /build/8.4
    tar -xf less-530.tar.gz
    cd less-530
    
    ./configure --prefix=/usr  --sysconfdir=/etc   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    • Gzip
      执行脚本:
    cd /build/8.4
    tar -xf gzip-1.10.tar.xz
    cd gzip-1.10
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    mv -v /usr/bin/gzip /bin
    
    • IPRoute2
      IPRoute2 软件包包含基于 IPV4 网络的基本和高级程序。
      执行脚本:
    cd /build/8.4
    tar -xf iproute2-4.20.0.tar.xz
    cd iproute2-4.20.0
    sed -i /ARPD/d Makefile
    rm -fv man/man8/arpd.8
    sed -i 's/.m_ipt.o//' tc/Makefile
    
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make  DOCDIR=/usr/share/doc/iproute2-4.20.0 install error!"
    exit 1;
    fi
    
    • Kbd
      Kbd 软件包包含键表文件、控制台字体和键盘工具。
      执行脚本:
    cd /build/8.4
    tar -xf kbd-2.0.4.tar.xz
    cd kbd-2.0.4
    
    patch -Np1 -i ../kbd-2.0.4-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  
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    mkdir  /usr/share/doc/kbd-2.0.4
    cp -R  docs/doc/* /usr/share/doc/kbd-2.0.4
    
    • Libpipeline
      Libpipeline 软件包包含以灵活方便方式管理管道和子进程的库。
      执行脚本:
    cd /build/8.4
    tar -xf libpipeline-1.5.1.tar.gz
    cd libpipeline-1.5.1
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Make
      执行脚本:
    cd /build/8.4
    tar -xf make-4.2.1.tar.bz2
    cd make-4.2.1
    sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make  PERL5LIB=$PWD/tests/ check   || echo "check error"
    
    • Patch
      执行脚本:
    cd /build/8.4
    tar -xf patch-2.7.6.tar.xz
    cd patch-2.7.6
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Man-DB
      Man-DB 软件包包含用于查找和查看 man 页面的程序。
      执行脚本:
    cd /build/8.4
    tar -xf man-db-2.8.5.tar.xz
    cd man-db-2.8.5
    
    ./configure --prefix=/usr --docdir=/usr/share/doc/man-db-2.8.5 \
     --sysconfdir=/etc \
     --disable-setuid \
     --enable-cache-owner=bin \
     --with-browser=/usr/bin/lynx \
     --with-vgrind=/usr/bin/vgrind \
     --with-grap=/usr/bin/grap   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    • Tar
      执行脚本:
    cd /build/8.4
    tar -xf tar-1.31.tar.xz
    cd tar-1.31
    sed -i 's/abort.*/FALLTHROUGH;/' src/extract.c
    
    FORCE_UNSAFE_CONFIGURE=1 \
    ./configure --prefix=/usr \
     --bindir=/bin   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    make check   || echo "check error"
    
    make -C doc install-html docdir=/usr/share/doc/tar-1.31
    
    • Texinfo
      执行脚本:
    cd /build/8.4
    tar -xf texinfo-6.5.tar.xz
    cd texinfo-6.5
    sed -i '5481,5485 s/({/(\\{/' tp/Texinfo/Parser.pm
    ./configure --prefix=/usr  --disable-static   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make  TEXMF=/usr/share/texmf install-tex 
    fi
    
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    make check   || echo "check error"
    
    pushd /usr/share/info
    rm -v dir
    for f in *
     do install-info $f dir 2>/dev/null
    done
    popd
    
    • Vim
      Vim 软件包包含了一个强大的文本编辑器。
      执行脚本:
    cd /build/8.4
    tar -xf vim-8.1.tar.bz2
    cd vim81
    
    echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
    
    ./configure --prefix=/usr   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    
    LANG=en_US.UTF-8 make -j1 test    || echo "check error"
    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/vim81/doc /usr/share/doc/vim-8.1
    
    cat > /etc/vimrc << "EOF"
    " Begin /etc/vimrc
    " Ensure defaults are set before customizing settings, not after
    source $VIMRUNTIME/defaults.vim
    let skip_defaults_vim=1
    set nocompatible
    set backspace=2
    set mouse=
    syntax on
    if (&term == "xterm") || (&term == "putty")
     set background=dark
    endif
    " End /etc/vimrc
    EOF
    
    • systemd
      systemd 软件包包含用于控制启动、运行和关闭系统的程序。
      执行脚本:
    cd /build/8.4
    tar -xf systemd-240.tar.gz
    cd systemd-240
    patch -Np1 -i ../systemd-240-security_fixes-2.patch
    ln -sf /tools/bin/true /usr/bin/xsltproc
    for file in /tools/lib/lib{blkid,mount,uuid}*; do
     ln -sf $file /usr/lib/
    done
    
    tar -xf ../systemd-man-pages-240.tar.xz
    
    sed '177,$ d' -i src/resolve/meson.build
    sed -i 's/GROUP="render", //' rules/50-udev-default.rules.in
    
    mkdir -p build
    cd build
    
    
    PKG_CONFIG_PATH="/usr/lib/pkgconfig:/tools/lib/pkgconfig" \
    LANG=en_US.UTF-8 \
    meson --prefix=/usr \
     --sysconfdir=/etc \
     --localstatedir=/var \
     -Dblkid=true \
     -Dbuildtype=release \
     -Ddefault-dnssec=no \
     -Dfirstboot=false \
     -Dinstall-tests=false \
     -Dkill-path=/bin/kill \
     -Dkmod-path=/bin/kmod \
     -Dldconfig=false \
     -Dmount-path=/bin/mount \
     -Drootprefix= \
     -Drootlibdir=/lib \
     -Dsplit-usr=true \
     -Dsulogin-path=/sbin/sulogin \
     -Dsysusers=false \
     -Dumount-path=/bin/umount \
     -Db_lto=false \
     ..   
    
    
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    LANG=en_US.UTF-8 ninja 
    fi
    
    if [ $? != 0 ] ;then
    echo "ninja error!"
    exit 1;
    else
    LANG=en_US.UTF-8 ninja install 
    fi
    if [ $? != 0 ] ;then
    echo "ninja install error"
    exit 1;
    else
    rm -rf /usr/lib/rpm
    rm -f /usr/bin/xsltproc 
    systemd-machine-id-setup 
    fi
    
    if [ $? != 0 ] ;then
    echo "systemd-machine-id-setup error!"
    exit 1;
    fi
    
    cat > /lib/systemd/systemd-user-sessions << "EOF"
    #!/bin/bash
    rm -f /run/nologin
    EOF
    chmod 755 /lib/systemd/systemd-user-sessions
    
    • D-Bus
      D-Bus 是一个消息总线系统,应用之间相互通信的简单方式。D-Bus 支持系统守护进程(例如添加新硬件设备或打印队列更改事件)和每个用户的登录会话守护进程 (例如用户应用程序之间的一般进程间通信)。另外,消息总线在通用一对一消息传递框架之上构建,该框架使得任意两个应用可以直接通信(而不需要通过消息总线守护进程)。
      执行脚本:
    cd /build/8.4
    tar -xf dbus-1.12.12.tar.gz
    cd dbus-1.12.12
    
    ./configure --prefix=/usr \
     --sysconfdir=/etc \
     --localstatedir=/var \
     --disable-static \
     --disable-doxygen-docs \
     --disable-xml-docs \
     --docdir=/usr/share/doc/dbus-1.12.12 \
     --with-console-auth-dir=/run/console   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    mv -v /usr/lib/libdbus-1.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libdbus-1.so) /usr/lib/libdbus-1.so
    
    ln -sfv /etc/machine-id /var/lib/dbus
    
    • Procps-ng
      Procps-ng 软件包包含监视进程的程序。
      执行脚本:
    cd /build/8.4
    tar -xf procps-ng-3.3.15.tar.xz
    cd procps-ng-3.3.15
    
    ./configure --prefix=/usr \
     --exec-prefix= \
     --libdir=/usr/lib \
     --docdir=/usr/share/doc/procps-ng-3.3.15 \
     --disable-static \
     --disable-kill \
     --with-systemd   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    sed -i -r 's|(pmap_initname)\\\$|\1|' testsuite/pmap.test/pmap.exp
    sed -i '/set tty/d' testsuite/pkill.test/pkill.exp
    rm testsuite/pgrep.test/pgrep.exp
    
    make check   || echo "check error"
    
    mv -v /usr/lib/libprocps.so.* /lib
    ln -sfv ../../lib/$(readlink /usr/lib/libprocps.so) /usr/lib/libprocps.so
    
    • Util-linux
      执行脚本:
    cd /build/8.4
    tar -xf util-linux-2.33.1.tar.xz
    cd util-linux-2.33.1
    
    mkdir -pv /var/lib/hwclock
    rm -vf /usr/include/{blkid,libmount,uuid}
    
    
    ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
     --docdir=/usr/share/doc/util-linux-2.33.1 \
     --disable-chfn-chsh \
     --disable-login \
     --disable-nologin \
     --disable-su \
     --disable-setpriv \
     --disable-runuser \
     --disable-pylibmount \
     --disable-static \
     --without-python   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    
    if [ $? != 0 ] ;then
    echo "make install error!"
    exit 1;
    fi
    
    chown -Rv nobody .
    su nobody -s /bin/bash -c "PATH=$PATH make -k check"   || echo "check error"
    
    • E2fsprogs
      E2fsprogs 软件包包含用于处理 ext2 文件系统的工具。它也支持 ext3 和 ext4 日志文件系统。
      执行脚本:
    cd /build/8.4
    tar -xf e2fsprogs-1.44.5.tar.gz
    cd e2fsprogs-1.44.5
    
    mkdir -v build
    cd build
    
    ../configure --prefix=/usr \
     --bindir=/bin \
     --with-root-prefix="" \
     --enable-elf-shlibs \
     --disable-libblkid \
     --disable-libuuid \
     --disable-uuidd \
     --disable-fsck   
    
    if [ $? != 0 ] ;then
    echo "configure error"
    exit 1;
    else
    make 
    fi
    
    if [ $? != 0 ] ;then
    echo "make error!"
    exit 1;
    else
    make install 
    fi
    if [ $? != 0 ] ;then
    echo "make  install error!"
    exit 1;
    else
    make install-libs 
    fi
    
    
    if [ $? != 0 ] ;then
    echo "make install-libs error!"
    exit 1;
    fi
    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
    
    make check   || echo "check error"
    

    到此,软件包的安装就算结束了。

    编译内核

    编译 Linux-5.1.6 内核源码,并拷贝内核镜像 bzImage 和 System.map 到 /boot/ 下
    执行脚本:

    #!/bin/sh
    
    cd /build/linux-5.1.6
    make mrproper
    cp /script/.config ./
    
    
    make 
    
    if [ $? != 0 ] ;then
    echo "kernel make error"
    exit 1;
    else
    make modules_install
    fi
    
    cp -iv arch/x86/boot/bzImage /boot/vmlinuz-5.1.6-systemd
    cp -iv System.map /boot/System.map-5.1.6
    install -d /usr/share/doc/linux-5.1.6 
    cp -r Documentation/* /usr/share/doc/linux-5.1.6
    

    让LFS系统可引导

    • 创建 fstab 文件
    • 为新的 LFS 系统编译内核
    • 安装 GRUB 引导器
      以上步骤的可由以下脚本文件执行:
    #!/bin/sh
    
    grub-install /dev/sdb
    
    cat > /boot/grub/grub.cfg << "EOF"
    # Begin /boot/grub/grub.cfg 
    set default=0 set timeout=5
    insmod ext2 set root=(hd0,1)
    menuentry "GNU/Linux, Linux 5.1.6-systemd" {
    
            linux   /boot/vmlinuz-5.1.6-systemd root=/dev/sda1 ro 
    		} 
    		
    EOF
    
    cat > /etc/fstab << "EOF" 
    # Begin /etc/fstab
    # file system  mount-point  type     options             dump  fsck order
    /dev/sda1     /             ext4    defaults            1     1
    
    # End /etc/fstab
    EOF
    

    LFS系统的完成与启动

    VMware 虚拟机将添加的LFS系统硬盘分成了7个子盘,如图:
    在这里插入图片描述
    其中LFS-1构建的LFS系统盘,可以通过VMware虚拟机新建虚拟机并将硬盘选择为自己构建的LFS系统盘,即可进行LFS系统的引导启动流程。
    如图:
    在这里插入图片描述
    在这里插入图片描述

    结语

    做事需要细心和耐心,更要有接受错误的勇气与改正问题的决心。
    很喜欢陈奕迅的《无条件》唱到的:

    " 来让我定然都发现
    我有很多未达完美事情
    我只懂得 再努力每天"

    在这里插入图片描述

    展开全文
  • LFS-Linux From Scratch学习笔记——构建LFS系统。

    前言

    LFS-Linux From Scratch学习笔记——LFS系统编译文。

    这里开始真正的系统创建。

    开始之前要重新chroot,具体的命令下:

    mount -v --bind /dev $LFS/dev
    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
    chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login

    注意跟之前chroot不同的是/usr/bin/env而不再是/tools/bin/env了。

    当然除了chroot,mount硬盘之类的操作也还需要。

     

    安装启动脚本

    将lfs-bootscripts-20150222.tar.bz2解压到/etc目录下并进入解压后的目录。

    运行如下的命令:

    make install

    结果如下:

    root:/etc/lfs-bootscripts-20150222# make install
    install -d -m 755  /etc/rc.d/rc0.d
    install -d -m 755  /etc/rc.d/rc1.d
    install -d -m 755  /etc/rc.d/rc2.d
    install -d -m 755  /etc/rc.d/rc3.d
    install -d -m 755  /etc/rc.d/rc4.d
    install -d -m 755  /etc/rc.d/rc5.d
    install -d -m 755  /etc/rc.d/rc6.d
    install -d -m 755  /etc/rc.d/rcS.d
    install -d -m 755  /etc/rc.d/init.d
    install -d -m 755  /etc/sysconfig
    install -d -m 755  /lib
    install -d -m 755  /lib/services
    install -d -m 755  /usr/share/man/man8
    install -d -m 755  /sbin
    ln -sfn       services    /lib/lsb
    ln -sfn       rc.d/init.d /etc/init.d
    install -m 754 lfs/init.d/checkfs       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/cleanfs       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/halt          /etc/rc.d/init.d/
    install -m 754 lfs/init.d/console       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/localnet      /etc/rc.d/init.d/
    install -m 754 lfs/init.d/modules       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/mountfs       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/mountvirtfs   /etc/rc.d/init.d/
    install -m 754 lfs/init.d/network       /etc/rc.d/init.d/
    install -m 754 lfs/init.d/rc            /etc/rc.d/init.d/
    install -m 754 lfs/init.d/reboot        /etc/rc.d/init.d/
    install -m 754 lfs/init.d/sendsignals   /etc/rc.d/init.d/
    install -m 754 lfs/init.d/setclock      /etc/rc.d/init.d/
    install -m 754 lfs/init.d/swap          /etc/rc.d/init.d/
    install -m 754 lfs/init.d/sysctl        /etc/rc.d/init.d/
    install -m 754 lfs/init.d/sysklogd      /etc/rc.d/init.d/
    install -m 754 lfs/init.d/template      /etc/rc.d/init.d/
    install -m 754 lfs/init.d/udev          /etc/rc.d/init.d/
    install -m 754 lfs/init.d/udev_retry    /etc/rc.d/init.d/
    install -m 754 lfs/sbin/ifup            /sbin
    install -m 754 lfs/sbin/ifdown          /sbin
    install -m 644 lfs/sbin/ifup.8      /usr/share/man/man8
    ln -sf  ifup.8                              /usr/share/man/man8/ifdown.8
    install -m 754     lfs/lib/services/ipv4-static-route  /lib/services
    install -m 754     lfs/lib/services/ipv4-static        /lib/services
    install -m 644 lfs/lib/services/init-functions     /lib/services
    if [ ! -f /etc/sysconfig/createfiles ]; then \
              install -m 644 lfs/sysconfig/createfiles /etc/sysconfig/ ;\
            fi
    if [ ! -f /etc/sysconfig/modules     ]; then \
              install -m 644 lfs/sysconfig/modules     /etc/sysconfig/ ;\
            fi
    if [ ! -f /etc/sysconfig/udev_retry  ]; then \
              install -m 644 lfs/sysconfig/udev_retry  /etc/sysconfig/ ;\
            fi
    if [ ! -f /etc/sysconfig/rc.site     ]; then \
              install -m 644 lfs/sysconfig/rc.site     /etc/sysconfig/ ;\
            fi
    ln -sf ../init.d/mountvirtfs /etc/rc.d/rcS.d/S00mountvirtfs
    ln -sf ../init.d/modules     /etc/rc.d/rcS.d/S05modules
    ln -sf ../init.d/localnet    /etc/rc.d/rcS.d/S08localnet
    ln -sf ../init.d/udev        /etc/rc.d/rcS.d/S10udev
    ln -sf ../init.d/swap        /etc/rc.d/rcS.d/S20swap
    ln -sf ../init.d/checkfs     /etc/rc.d/rcS.d/S30checkfs
    ln -sf ../init.d/mountfs     /etc/rc.d/rcS.d/S40mountfs
    ln -sf ../init.d/cleanfs     /etc/rc.d/rcS.d/S45cleanfs
    ln -sf ../init.d/udev_retry  /etc/rc.d/rcS.d/S50udev_retry
    ln -sf ../init.d/console     /etc/rc.d/rcS.d/S70console
    ln -sf ../init.d/sysctl      /etc/rc.d/rcS.d/S90sysctl
    ln -sf ../init.d/network     /etc/rc.d/rc0.d/K80network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc0.d/K90sysklogd
    ln -sf ../init.d/sendsignals /etc/rc.d/rc0.d/S60sendsignals
    ln -sf ../init.d/swap        /etc/rc.d/rc0.d/S65swap
    ln -sf ../init.d/mountfs     /etc/rc.d/rc0.d/S70mountfs
    ln -sf ../init.d/localnet    /etc/rc.d/rc0.d/S90localnet
    ln -sf ../init.d/halt        /etc/rc.d/rc0.d/S99halt
    ln -sf ../init.d/network     /etc/rc.d/rc1.d/K80network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc1.d/K90sysklogd
    ln -sf ../init.d/network     /etc/rc.d/rc2.d/K80network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc2.d/K90sysklogd
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc3.d/S10sysklogd
    ln -sf ../init.d/network     /etc/rc.d/rc3.d/S20network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc4.d/S10sysklogd
    ln -sf ../init.d/network     /etc/rc.d/rc4.d/S20network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc5.d/S10sysklogd
    ln -sf ../init.d/network     /etc/rc.d/rc5.d/S20network
    ln -sf ../init.d/network     /etc/rc.d/rc6.d/K80network
    ln -sf ../init.d/sysklogd    /etc/rc.d/rc6.d/K90sysklogd
    ln -sf ../init.d/sendsignals /etc/rc.d/rc6.d/S60sendsignals
    ln -sf ../init.d/swap        /etc/rc.d/rc6.d/S65swap
    ln -sf ../init.d/mountfs     /etc/rc.d/rc6.d/S70mountfs
    ln -sf ../init.d/localnet    /etc/rc.d/rc6.d/S90localnet
    ln -sf ../init.d/reboot      /etc/rc.d/rc6.d/S99reboot

    可以看到主要是安装了rc.d和sysconfig。
     

    设备相关的操作

    下面介绍设备相关的操作。

     

    创建默认的udev规则

     

    网络配置

    cd /etc/sysconfig/
    cat > ifconfig.eth0 << "EOF"
    ONBOOT=yes
    IFACE=eth0
    SERVICE=ipv4-static
    IP=192.168.1.2
    GATEWAY=192.168.1.1
    PREFIX=24
    BROADCAST=192.168.1.255
    EOF
    
    cat > /etc/resolv.conf << "EOF"
    # Begin /etc/resolv.conf
    domain <Your Domain Name>
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    # End /etc/resolv.conf
    EOF
    
    echo "lfs" > /etc/hostname
    
    cat > /etc/hosts << "EOF"
    # Begin /etc/hosts (no network card version)
    127.0.0.1	localhost
    127.0.1.1	lfs
    # End /etc/hosts (no network card version)
    EOF

    这里的有些配置是参考手册的,有些是参考原本机器上的,现在还不确定是否有问题。

     

    System V启动脚本配置

    创建/etc/inittab文件:

    cat > /etc/inittab << "EOF"
    # Begin /etc/inittab
    
    id:3:initdefault:
    
    si::sysinit:/etc/rc.d/init.d/rc S
    
    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:S016:once:/sbin/sulogin
    
    1:2345:respawn:/sbin/agetty --noclear 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

    创建/etc/sysconfig/clock文件:

    cat > /etc/sysconfig/clock << "EOF"
    # Begin /etc/sysconfig/clock
    
    UTC=1
    
    # Set this to any options you might need to give to hwclock,
    # such as machine hardware clock type for Alphas.
    CLOCKPARAMS=
    
    # End /etc/sysconfig/clock
    EOF

    创建/etc/sysconfig/console文件:

    cat > /etc/sysconfig/console << "EOF"
    # Begin /etc/sysconfig/console
    
    KEYMAP="pl2"
    FONT="lat2a-16 -m 8859-2"
    
    # End /etc/sysconfig/console
    EOF

    通过/etc/sysconfig/rc.site可以修改启动的配置。

    创建/etc/profile文件:

    cat > /etc/profile << "EOF"
    # Begin /etc/profile
    
    export LANG=zh_CN.UTF-8
    
    # End /etc/profile
    EOF

    这里的LANG是在编译服务器上通过echo $LANG获取到的。

    创建/etc/inputrc文件:

    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

    创建/etc/shalls文件:

    cat > /etc/shells << "EOF"
    # Begin /etc/shells
    
    /bin/sh
    /bin/bash
    
    # End /etc/shells
    EOF

     

    让LFS系统可启动

    创建/etc/fstab文件:

    cat > /etc/fstab << "EOF"
    # Begin /etc/fstab
    
    # file system mount-point type options dump fsck
    #
    /dev/sda2  /         ext4      defaults             1  1
    /dev/sda1  swap      swap      pri=1                0  0
    proc       /proc     proc      nosuid,noexec,nodev  0  0
    sysfs      /sys      sysfs     nosuid,noexec,nodev  0  0
    devpts     /dev/pts  devpts    gid=5,mode=620       0  0
    tmpfs      /run      tmpfs     defaults             0  0
    devtmpfs   /dev      devtmpfs  mode=0755,nosuid     0  0
    
    
    # End /etc/fstab
    EOF

    这里的/dev/sdcx和ext4是根据实际情况确定的。

     

    内核编译

    1. 首先解压linux-4.9.9.tar.xz,并进入该目录;

    2. 运行make mrproper;

    3. 创建默认的config文件:make defconfig;

    4. 执行make menuconfig进行一些配置;

    5. make编译;

    6. make modules_install;

    7. 文件拷贝:

    cp -v arch/x86/boot/bzImage /boot/vmlinuz-4.9.9-lfs-8.0
    cp -v System.map /boot/System.map-4.9.9
    cp -v .config /boot/config-4.9.9
    install -d /usr/share/doc/linux-4.9.9
    cp -r Documentation/* /usr/share/doc/linux-4.9.9

    其他的一些配置:

    install -v -m755 -d /etc/modprobe.d
    
    cat > /etc/modprobe.d/usb.conf << "EOF"
    # Begin /etc/modprobe.d/usb.conf
    
    install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
    install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
    
    # End /etc/modprobe.d/usb.conf
    EOF

    grub安装和配置:

    grub-install /dev/sdc -d /usr/lib/grub/i386-pc/
    
    cat > /boot/grub/grub.cfg << "EOF"
    # Begin /boot/grub/grub.cfg
    set default=0
    set timeout=5
    
    insmod ext4
    set root=(hd0,2)
    menuentry "GNU/Linux, Linux 4.9.9-lfs-8.0" {
      linux /boot/vmlinuz-4.9.9-lfs-8.0 root=/dev/sda2 ro
    }
    EOF

    这里root= insmod之后的值可能需要根据实际情况更改的。

     

    尾声

    以上是LFS系统构建的所有内容。

    之后是一些收尾的操作:

    1. 设定版本:

    echo 8.0 > /etc/lfs-release
    
    cat > /etc/lsb-release << "EOF"
    DISTRIB_ID="Linux From Scratch"
    DISTRIB_RELEASE="8.0"
    DISTRIB_CODENAME="<your name here>"
    DISTRIB_DESCRIPTION="Linux From Scratch"
    EOF

    2. 退出系统:

    logout
    umount -v $LFS/dev/pts
    umount -v $LFS/dev
    umount -v $LFS/run
    umount -v $LFS/proc
    umount -v $LFS/sys
    umount -v $LFS
    shutdown -r now

     

    展开全文
  • 尽可能简单地构建LFS(Linux From Scratch)10.0版的说明和脚本(我知道,不是那么简单,但是无论如何)。 lfs-scripts:penguin:尽可能简单地构建LFS(Linux From Scratch)10.0版的说明和脚本(我知道,不是那么...
  • 本章我们会进入构建环境中,正式的构建lfs系统。 创建构建环境 1. 准备虚拟内核文件系统 1.1 创建即将用来挂载文件系统的目录: mkdir -pv $LFS/{dev,proc,sys,run} 1.2 创建初始设备节点:   LFS文档的解释:内核...

      前一篇中,我们在tools中安装了临时构建工具。本章我们会进入构建环境中,正式的构建lfs系统。

    创建构建环境

    1. 准备虚拟内核文件系统

    1.1 创建即将用来挂载文件系统的目录:

    mkdir -pv $LFS/{dev,proc,sys,run}

    1.2 创建初始设备节点:

      LFS文档的解释:内核引导系统的时候,依赖于几个设备节点,特别是console和null两个设备。这些设备需要创建在硬盘上,这样在udevd启动之前他们也仍然有效的,特别在linux使用init=/bin/bash参数启动的时候。

    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3

    1.3 挂载和激活/dev

      将宿主系统中的/dev挂载到$LFS下的dev下:

    mount -v --bind /dev $LFS/dev

    1.4 挂载虚拟文件系统

    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

      创建shm目录:

    if [ -h $LFS/dev/shm ]; then
    mkdir -pv $LFS/$(readlink $LFS/dev/shm)
    fi

    1.5 进入chroot环境

      现在可以切换到chroot环境下正式构建lfs系统了,关于chroot可以阅读如下的文件进行了解:
      https://www.ibm.com/developerworks/cn/linux/l-cn-chroot/
      以root用户运行如下的命令即可:

    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

    注意事项:
    在这之后的处理中,都是在chroot下进行的,如果出现机器重启的情况,需要重新“挂载和激活/dev” 和“挂载虚拟文件系统”以及“创建shm目录”

    2. 开始构建

    2.1 创建lfs文件系统目录:

    mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,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}

      使用ls查看一下,会发现和宿主系统的根目录下的结构类似。

    2.2 创建lfs文件系统目录:

      有些程序会使用写死的路径调用还未安装的程序,为了满足这种程序的需要,我们需要创建一些符号链接,在安装好这写程序后,会替代这些符号链接。

    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

      创建密码(/etc/passwd)和用户组(/etc/group)配置文件
      执行如下创建/etc/passwd:

    cat > /etc/passwd << “EOF”
    root: x:0:0:root:/root:/bin/bash
    bin: x:1:1:bin:/dev/null:/bin/false
    daemon: x:6:6:Daemon User:/dev/null:/bin/false
    messagebus: x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
    systemd-bus-proxy: x:72:72:systemd Bus Proxy:/:/bin/false
    systemd-journal-gateway: x:73:73:systemd Journal Gateway:/:/bin/false
    systemd-journal-remote: x:74:74:systemd Journal Remote:/:/bin/false
    systemd-journal-upload: x:75:75:systemd Journal Upload:/:/bin/false
    systemd-network: x:76:76:systemd Network Management:/:/bin/false
    systemd-resolve: x:77:77:systemd Resolver:/:/bin/false
    systemd-timesync: x:78:78:systemd Time Synchronization:/:/bin/false
    systemd-coredump: x:79:79:systemd Core Dumper:/:/bin/false
    nobody: x:99:99:Unprivileged User:/dev/null:/bin/false
    EOF

      执行如下创建/etc/group:

    cat > /etc/group << “EOF”
    root: x:0:
    bin: x:1:daemon
    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:
    adm: x:16:
    messagebus: x:18:
    systemd-journal: x:23:
    input: x:24:
    mail: x:34:
    systemd-bus-proxy: x:72:
    systemd-journal-gateway: x:73:
    systemd-journal-remote: x:74:
    systemd-journal-upload: x:75:
    systemd-network: x:76:
    systemd-resolve: x:77:
    systemd-timesync: x:78:
    systemd-coredump: x:79:
    nogroup: x:99:
    users: x:999:
    EOF

       如上x之前没有空格,具体命令可以复制lfs文档中对应章节的命令。

       移除“I have no name!”的提示符:

    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

    /var/log/wtmp会记录登入登出的动作,/var/log/lastlog会记录最后一次登陆的信息,/var/log/btmp记录的是失败的登陆尝试。

      至此创建构建环境的准备工作完成,下一步就是编译和安装程序,这个与上一篇的操作类似,为了防止出错,后续一篇还是会加上这一步的内容。

    展开全文
  • 一名linux爱好者,记录构建Linux From Scratch的过程 经博客园-骏马金龙前辈介绍,开始接触学习lfs,用博客...要实际构建lfs请结合lfs官方的书籍操作 一.lfs系列概述 1.lfs:Linux From Scratch(LFS)是一个项目...
  • 文章目录LFS介绍准备工作构建临时系统清理无用内容改变属主 LFS介绍 LFS—Linux from Scratch,是一种从网上直接下载源码,从头编译LINUX的安装方式。 本篇内容宿主机环境选择为Centos 7,LFS系统选择的 Linux 内核...
  • 构建LFS系统不是一个简单的任务。为了解决问题和正确执行命令列表,需要掌握一定的Unix系统管理知识。少部分时候,你应该可以使用命令行拷贝、移动文件和目录,列出文件或目录的内容,修改当前目录。也需要具备正确...
  • OpenEuler上构建LFS8.4

    2021-03-23 18:00:49
    export LFS=/mnt/lfs mkdir -pv $LFS mount -v -t ext4 /dev/sdb1 $LFS 有警告,暂时不管; 如果设置了swap分区: /sbin/swapon -v /dev/sda3 验证了swap分区可用。 准备软件包 软件包从某位B站大佬处获得:视频...
  • MPC configure 检查配置的时候报错: 根据提示知道是:MPFR 没有安装。 应该是MPFR安装的时候出了问题。回溯到MPFR的安装目录,make check ,没有问题 ...(这里重复执行MPFR的配置安装好几遍,仍旧在MP

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 465
精华内容 186
关键字:

构建lfs