文章目录
上文说到:构建 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系统的引导启动流程。
如图:
结语
做事需要细心和耐心,更要有接受错误的勇气与改正问题的决心。
很喜欢陈奕迅的《无条件》唱到的:
" 来让我定然都发现
我有很多未达完美事情
我只懂得 再努力每天"