lfs(systemd版本)学习笔记-第3页

时间:2022-06-21 16:55:54

lfs(systemd)学习笔记-第2页 的地址:https://www.cnblogs.com/renren-study-notes/p/10385583.html

七.开始构建lfs

第六章节中构建的所有包必须进行测试。

终端的环境应该是:

1.设置变量

2.挂载你为lfs创建的所有分区
3.逐步完成6.2.2与6.2.3章节内容后

4.chroot进入lfs分区继续操作。

第6.7章节

编译安装Linux API Headers包

根据上一章节的构建要求,首先进入到$LFS/sources目录

cd /sources

因为Linux API Headers在linux包中,所以解压并进入linux包

tar -xvf linux-4.20.12.tar.xz
cd  linux-4.20.12

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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf linux-4.20.12

第6.8章节

编译安装man-pages包

1.解压并进入man-pages包目录

tar -xvf man-pages-4.16.tar.xz

cd man-pages-4.16

2.参照书中说明编译安装

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf man-pages-4.16

第6.9章节

编译安装glibc包

1.解压并进入glibc包目录

tar -xvf glibc-2.29.tar.xz

cd glibc-2.29

2.参照书中说明编译安装

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 make -j8 make -j8 check touch /etc/ld.so.conf sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile make install 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.service
 

3.配置glibc包

按照书籍安装步骤到(可以使用localedef程序安装单个语言环境)步骤

我们需要安装英文语言环境和中文语言环境

1.创建语言环境安装目录

mkdir -pv /usr/lib/locale

2.安装语言环境

localedef -i en_US -f UTF-8 en_US.UTF-8
localedef -i zh_CN -f UTF-8 zh_CN.UTF-8

3.创建/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

4.安装和设置时区数据

tar -xf ../../tzdata2018e.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

5.确定时区

tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa
2) Americas
3) Antarctica
4) Asia
5) Atlantic Ocean
6) Australia
7) Europe
8) Indian Ocean
9) Pacific Ocean
10) coord - I want to use geographical coordinates.
11) TZ - I want to specify the time zone using the Posix TZ format.

6.这里我们选择4亚洲

Please select a country whose clocks agree with yours.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) *
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) * 30) * 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan

7.这里我们选择9中国

Please select one of the following time zone regions.
1) Beijing Time
2) * Time

8.这里我们选择1北京时间

The following information has been given:

    China
Beijing Time Therefore TZ='Asia/Shanghai' will be used.
Selected time is now: Sun Dec 30 18:00:59 CST 2018.
Universal Time is now: Sun Dec 30 10:00:59 UTC 2018.
Is the above information OK?
1) Yes
2) No
#? yes
Please enter a number in range.

9.是否选择以上信息?这里选择1

You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

这句的意思是你可以将该配置文件添加到/usr/bin/tzselect使其生效(这个命令是创建一个时区环境变量,重启后会失效)

10.运行以下命令创建时区文件/etc/localtime

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

11.配置动态加载文件

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

12.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf glibc-2.29

第6.10章节

调整工具链

1.输入书中命令核对输出即可

mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /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' grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log grep -B1 '^ /usr/include' dummy.log grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' grep "/lib.*/libc.so.6 " dummy.log grep found dummy.log rm -v dummy.c a.out dummy.log

第6.11章节

编译安装zlib包

1.解压并进入zlib包目录

tar -xvf zlib-1.2.11.tar.xz

cd zlib-1.2.11

2.参照书中内容编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf zlib-1.2.11

第6.12章节

构建安装file包

1.解压并进入file包目录

tar -xvf file-5.36.tar.gz

cd file-5.36

2.参照书中内容编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf file-5.36

第6.13章节

编译安装readline包

1.解压并进入readline包目录

tar -xvf readline-8.0.tar.gz

cd readline-8.0

2.参照书中说明编译安装

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 make SHLIB_LIBS="-L/tools/lib -lncursesw" make SHLIB_LIBS="-L/tools/lib -lncurses" install 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 install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-8.0

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf readline-8.0

第6.14章节

编译安装m4包

1.解压并进入m4包目录

tar -xvf m4-1.4.18.tar.xz

cd m4-1.4.18

2.参照书中说明编译安装

sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h ./configure --prefix=/usr make -j8 make -j8 check make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf m4-1.4.18

第6.15章节

编译安装bc包

1.解压并进入bc包目录

tar -xvf bc-1.07.1.tar.gz

cd bc-1.07.1

2.参照书中内容编译安装

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 libncurses.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 make -j8 echo "quit" | ./bc/bc -l Test/checklib.b make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf bc-1.07.1

第6.16章节

编译安装binutils包

1.解压并进入binutils包目录

tar -xvf binutils-2.32.tar.xz

cd binutils-2.32

2.参照书中说明编译安装

expect -c "spawn ls"

mkdir -v build
cd build ../configure --prefix=/usr \
--enable-gold \
--enable-ld=default \
--enable-plugins \
--enable-shared \
--disable-werror \
--enable-64-bit-bfd \
--with-system-zlib make tooldir=/usr make -k check make tooldir=/usr install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf binutils-2.32

第6.17章节

编译安装gmp包

1.解压并进入gmp包目录

tar -xvf gmp-6.1.2.tar.xz

cd gmp-6.1.2

2.参照书中说明编译安装

./configure --prefix=/usr    \
--enable-cxx \
--disable-static \
--docdir=/usr/share/doc/gmp-6.1.2 make -j8
make html make check 2>&1 | tee gmp-check-log awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log make install
make install-html

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gmp-6.1.2

第6.18章节

编译安装mpfr包

1.解压并进入mpfr包目录

tar -xvf mpfr-4.0.2.tar.xz

cd mpfr-4.0.2

2.参照书中说明编译安装

./configure --prefix=/usr        \
--disable-static \
--enable-thread-safe \
--docdir=/usr/share/doc/mpfr-4.0.2 make -j8
make -j8 html make -j8 check make install
make install-html

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf mpfr-4.0.2

第6.19章节

安装编译mpc包

1.解压并进入mpc包目录

tar -xvf mpc-1.1.0.tar.gz

cd mpc-1.1.0 

2.参照书中内容编译安装

./configure --prefix=/usr    \
--disable-static \
--docdir=/usr/share/doc/mpc-1.1.0 make -j8
make -j8 html make -j8 check make install
make install-html

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf mpc-1.1.0

第6.20章节

编译安装shadow包

1.解压并进入shadow包目录

tar -xvf shadow-4.6.tar.xz

cd shadow-4.6

2.参照书中说明编译安装

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 sed -i 's/1000/999/' etc/useradd ./configure --sysconfdir=/etc --with-group-name-max-length=32 make -j8 make install mv -v /usr/bin/passwd /bin

3.配置shadow包

pwconv

grpconv

sed -i 's/yes/no/' /etc/default/useradd

4.为root用户设置密码

passwd root

5.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf shadow-4.6

第6.21章节

编译安装gcc包

1.解压并进入gcc包目录

tar -xvf gcc-8.2.0.tar.xz

cd gcc-8.2.0

2.参照书中的说明进行编译安装

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 make -j8 ulimit -s 32768 rm ../gcc/testsuite/g++.dg/pr83239.C chown -Rv nobody .
su nobody -s /bin/bash -c "PATH=$PATH make -k check" ../contrib/test_summary make install 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/

3.检查工具链并核对输出结果

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib' grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log grep -B4 '^ /usr/include' dummy.log grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g' grep "/lib.*/libc.so.6 " dummy.log grep found dummy.log 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

5.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gcc-8.2.0

第6.22章节

编译安装 bzip2包

1.解压并进入bzip2包目录

tar -xvf bzip2-1.0.6.tar.gz

cd bzip2-1.0.6

2.参照书中说明编译安装

patch -Np1 -i ../bzip2-1.0.6-install_docs-1.patch

sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile

sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile

make -f Makefile-libbz2_so
make clean make -j8 make PREFIX=/usr install cp -v bzip2-shared /bin/bzip2
cp -av libbz2.so* /lib
ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm -v /usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 /bin/bunzip2
ln -sv bzip2 /bin/bzcat

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf bzip2-1.0.6

第6.23章节

编译安装pkg-config包

1.解压并进入pkg-config包

tar -xvf pkg-config-0.29.2.tar.gz

cd pkg-config-0.29.2

2.参照书中说明编译安装

./configure --prefix=/usr              \
--with-internal-glib \
--disable-host-tool \
--docdir=/usr/share/doc/pkg-config-0.29.2 make -j8 make check make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf pkg-config-0.29.2

第6.24章节

编译安装ncurses包

1.解压并进入ncurses包目录

tar -xvf ncurses-6.1.tar.gz

cd ncurses-6.1

2.参照书中说明编译安装

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 make -j8 make install 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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf ncurses-6.1

第6.25章节

编译安装attr包

1.解压并进入attr包目录

tar -xvf attr-2.4.48.tar.gz

cd attr-2.4.48

2.参照书中说明进行编译安装

./configure --prefix=/usr     \
--bindir=/bin \
--disable-static \
--sysconfdir=/etc \
--docdir=/usr/share/doc/attr-2.4.48 make -j8 make -j8 check make install mv -v /usr/lib/libattr.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf attr-2.4.48

第6.26章节

编译安装acl包

1.解压并进入acl包目录

tar -xvf acl-2.2.53.tar.gz

cd acl-2.2.53

2.参照书中说明编译安装

./configure --prefix=/usr         \
--bindir=/bin \
--disable-static \
--libexecdir=/usr/lib \
--docdir=/usr/share/doc/acl-2.2.53 make -j8 make install mv -v /usr/lib/libacl.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libacl.so) /usr/lib/libacl.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf acl-2.2.53

第6.27章节

编译安装libcap包

1.解压并进入libcap包目录

tar -xvf libcap-2.26.tar.xz

cd libcap-2.26

2.参照书中说明编译安装

sed -i '/install.*STALIBNAME/d' libcap/Makefile

make -j8

make RAISE_SETFCAP=no lib=lib prefix=/usr install
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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf libcap-2.26

第6.28章节

编译安装sed包

1.解压并进入sed包

tar -xvf sed-4.7.tar.xz

cd sed-4.7

2.参照书中内容编译安装

sed -i 's/usr/tools/'                 build-aux/help2man
sed -i 's/testsuite.panic-tests.sh//' Makefile.in ./configure --prefix=/usr --bindir=/bin make -j8
make -j8 html make check make install
install -d -m755 /usr/share/doc/sed-4.7
install -m644 doc/sed.html /usr/share/doc/sed-4.7

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf sed-4.7

第6.29章节

编译安装psmisc包

1.解压并进入psmisc包目录

tar -xvf psmisc-23.2.tar.xz

cd psmisc-23.2

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make install 

mv -v /usr/bin/fuser   /bin
mv -v /usr/bin/killall /bin

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf psmisc-23.2

第6.30章节

编译安装iana-etc包

1.解压并进入iana-etc包

tar -xvf iana-etc-2.30.tar.bz2

cd iana-etc-2.30

2.参照书中说明编译安装

make -j8

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf iana-etc-2.30

第6.31章节

编译安装bison包

1.解压并进入bison包目录

tar -xvf bison-3.3.2.tar.xz

cd bison-3.3.2

2.参照书中说明编译安装

./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.3.2

make -j8

make install

如果需要测试,在下一节中安装flex后,可以重建bison,并且可以通过make check来运行bison检查。(不推荐重建)

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf bison-3.3.2

第6.32章节

编译安装flex包

1.解压并进入flex包目录

tar -xvf flex-2.6.4.tar.gz

cd flex-2.6.4

2.参照书中说明编译安装

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 make -j8 make -j8 check make install ln -sv flex /usr/bin/lex

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf flex-2.6.4

第6.33章节

编译安装grep包

1.解压并进入grep包目录

tar -xvf grep-3.3.tar.xz

cd grep-3.3

2.参照书中说明编译安装

./configure --prefix=/usr --bindir=/bin

make -j8

make -kj8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf grep-3.3

第6.34章节

编译安装bash包

1.解压并进入bash包目录

tar -xvf bash-5.0.tar.gz

cd bash-5.0

2.参照书中说明编译安装

./configure --prefix=/usr                       \
--docdir=/usr/share/doc/bash-5.0 \
--without-bash-malloc \
--with-installed-readline make -j8 chown -Rv nobody . su nobody -s /bin/bash -c "PATH=$PATH make tests" make install
mv -vf /usr/bin/bash /bin exec /bin/bash --login +h

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf bash-5.0

第6.35章节

编译安装libtool

1.解压并进入libtool包目录

tar -xvf libtool-2.4.6.tar.xz

cd libtool-2.4.6

2.参照书中内容编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf libtool-2.4.6

第6.36章节

编译安装gdbm包

1.解压并进入gdbm包目录

tar -xvf gdbm-1.18.1.tar.gz

cd gdbm-1.18.1

2.参照书中说明编译安装

./configure --prefix=/usr \
--disable-static \
--enable-libgdbm-compat make -j8 make -j8 check make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gdbm-1.18.1

第6.37章节

编译安装gperf包

1.解压并进入gperf包目录

tar -xvf gperf-3.1.tar.gz

cd gperf-3.1

2.参照书中说明编译安装

./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.1

make -j8

make -j1 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gperf-3.1

第6.38章节

编译安装expat包

1.解压并进入expat包目录

tar -xvf expat-2.2.6.tar.bz2

cd expat-2.2.6

2.参照书中说明编译安装

sed -i 's|usr/bin/env |bin/|' run.sh.in

./configure --prefix=/usr    \
--disable-static \
--docdir=/usr/share/doc/expat-2.2.6 make -j8 make -j8 check make install install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.2.6

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf expat-2.2.6

第6.39章节

编译安装inetutils包

1.解压并进入inetutils包目录

tar -xvf inetutils-1.9.4.tar.xz

cd inetutils-1.9.4

2.参照书中说明编译安装

./configure --prefix=/usr        \
--localstatedir=/var \
--disable-logger \
--disable-whois \
--disable-rcp \
--disable-rexec \
--disable-rlogin \
--disable-rsh \
--disable-servers make -j8 make -j8 check make install mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
mv -v /usr/bin/ifconfig /sbin

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf inetutils-1.9.4

第6.40章节

编译安装perl包

1.解压并进入perl包目录

tar -xvf perl-5.28.1.tar.xz

cd perl-5.28.1

2.参照书中说明编译安装

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 make -j8 make -kj8 test make install unset BUILD_ZLIB BUILD_BZIP2

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf perl-5.28.1

第6.41章节

编译安装XML-Parser包

1.解压并进入XML-Parser包目录

tar -xvf XML-Parser-2.44.tar.gz

cd XML-Parser-2.44

2.参照书中说明编译安装

perl Makefile.PL

make -j8

make -j8 test

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf XML-Parser-2.44

第6.42章节

编译安装intltool包

1.解压并进入intltool包目录

tar -xvf intltool-0.51.0.tar.gz

cd intltool-0.51.0

2.参照书中的说明编译安装

sed -i 's:\\\${:\\\$\\{:' intltool-update.in

./configure --prefix=/usr

make -j8

make -j8 check

make install
install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf intltool-0.51.0

第6.43章节

编译安装autoconf包

1.解压并进入autoconf包目录

tar -xvf autoconf-2.69.tar.xz

cd autoconf-2.69

2.参照书中的说明编译安装

sed '361 s/{/\\{/' -i bin/autoscan.in

./configure --prefix=/usr

make -j8

mkae -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf autoconf-2.69

第6.44章节

编译安装automake包

1.解压并进入automake包目录

tar -xvf automake-1.16.1.tar.xz

cd automake-1.16.1

2.参照书中的说明进行编译安装

./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.16.1

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf automake-1.16.1

第6.45章节

编译安装xz包

1.解压并进入xz包目录

tar -xvf xz-5.2.4.tar.xz

cd xz-5.2.4

2.参照书中说明编译安装

./configure --prefix=/usr    \
--disable-static \
--docdir=/usr/share/doc/xz-5.2.4 make -j8 make -j8 check make install
mv -v /usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} /bin
mv -v /usr/lib/liblzma.so.* /lib
ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf xz-5.2.4

第6.46章节

编译安装kmod包

1.解压并进入kmod包目录

tar -xvf kmod-26.tar.xz

cd kmod-26

2.参照书中说明编译安装

./configure --prefix=/usr          \
--bindir=/bin \
--sysconfdir=/etc \
--with-rootlibdir=/lib \
--with-xz \
--with-zlib make -j8 make install for target in depmod insmod lsmod modinfo modprobe rmmod; do
ln -sfv ../bin/kmod /sbin/$target
done ln -sfv kmod /bin/lsmod

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf kmod-26

第6.47章节

编译安装gettext包

1.解压并进入gettext包目录

tar -xvf gettext-0.19.8.1.tar.xz

cd gettext-0.19.8.1

2.参照书中说明编译安装

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 make -j8 make -j8 check make install
chmod -v 0755 /usr/lib/preloadable_libintl.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gettext-0.19.8.1

第6.48章节

编译安装libelf包

1.Libelf是elfutils-0.173包的一部分,所以需要解压并进入elfutils-0.173包目录

tar -xvf elfutils-0.176.tar.bz2

cd elfutils-0.176

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make -C libelf install
install -vm644 config/libelf.pc /usr/lib/pkgconfig

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf elfutils-0.176

第6.49章节

编译安装libffi包

1.解压并进入libffi包目录

tar -xvf libffi-3.2.1.tar.gz

cd libffi-3.2.1

2.参照书中说明编译安装

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 make -j8 make -j8 check make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf libffi-3.2.1

第6.50章节

编译安装openssl包

1.解压并进入openssl包目录

tar -xvf openssl-1.1.1a.tar.gz

cd openssl-1.1.1a

2.参照书中内容编译安装

./config --prefix=/usr         \
--openssldir=/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic make -j8 make -j8 test sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
make MANSUFFIX=ssl install mv -v /usr/share/doc/openssl /usr/share/doc/openssl-1.1.1a
cp -vfr doc/* /usr/share/doc/openssl-1.1.1a

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf openssl-1.1.1a

第6.51章节

编译安装python包

1.解压并进入python包目录

tar -xvf Python-3.7.2.tar.xz

cd Python-3.7.2

2.参照书中说明编译安装

./configure --prefix=/usr       \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-ensurepip=yes make -j8 make install
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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf Python-3.7.2

第6.52章节

编译安装ninja包

1.解压并进入ninja包目录

tar -xvf ninja-1.9.0.tar.gz

cd ninja-1.9.0

2.参照书中说明编译安装

python3 configure.py --bootstrap

python3 configure.py
./ninja ninja_test
./ninja_test --gtest_filter=-SubprocessTest.SetWithLots 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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf ninja-1.9.0

第6.53章节

编译安装meson包

1.解压并进入meson包目录

tar -xvf meson-0.49.2.tar.gz

cd meson-0.49.2

2.参照书中说明编译安装

python3 setup.py build

python3 setup.py install --root=dest
cp -rv dest/* /

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf meson-0.49.3

第6.54章节

编译安装coreutils包

1.解压并进入coreutils包目录

tar -xvf coreutils-8.30.tar.xz

cd coreutils-8.30

2.参照书中说明编译安装

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 FORCE_UNSAFE_CONFIGURE=1 make make NON_ROOT_USERNAME=nobody check-root echo "dummy:x:1000:nobody" >> /etc/group chown -Rv nobody . su nobody -s /bin/bash \
-c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check" sed -i '/dummy/d' /etc/group make install mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin
mv -v /usr/bin/chroot /usr/sbin
mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8 mv -v /usr/bin/{head,sleep,nice} /bin

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf coreutils-8.30

第6.55章节

编译安装check包

1.解压并进入check包目录

tar -xvf check-0.12.0.tar.gz

cd  check-0.12.0

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install
sed -i '1 s/tools/usr/' /usr/bin/checkmk

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf check-0.12.0

第6.56章节

编译安装diffutils包

1.解压并进入diffutils包目录

tar -xvf diffutils-3.7.tar.xz

cd diffutils-3.7

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf diffutils-3.7

第6.57章节

编译安装gawk包

1.解压并进入gawk包目录

tar -xvf gawk-4.2.1.tar.xz

cd gawk-4.2.1

2.参照书中说明编译安装

sed -i 's/extras//' Makefile.in

./configure --prefix=/usr

make -j8

make -j8 check

make install

mkdir -v /usr/share/doc/gawk-4.2.1
cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.2.1

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gawk-4.2.1

第6.58章节

编译安装findutils包

1.解压并进入findutils包目录

tar -xvf findutils-4.6.0.tar.gz

cd findutils-4.6.0

2.参照书中说明编译安装

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 make -j8 make -j8 check make install mv -v /usr/bin/find /bin
sed -i 's|find:=${BINDIR}|find:=/bin|' /usr/bin/updatedb

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf findutils-4.6.0

第6.59章节

编译安装groff包

1.解压并进入groff包目录

tar -xvf groff-1.22.4.tar.gz

cd groff-1.22.4

2.参照书中说明编译安装

PAGE=A4 ./configure --prefix=/usr

make -j1

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf groff-1.22.4

第6.60章节

编译安装grub包

1.解压并进入grub包目录

tar -xvf grub-2.02.tar.xz

cd grub-2.02

2.参照书中说明编译安装

./configure --prefix=/usr          \
--sbindir=/sbin \
--sysconfdir=/etc \
--disable-efiemu \
--disable-werror make -j8 make install
mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf grub-2.02

第6.61章节

编译安装less包

1.解压并进入less包目录

tar -xvf less-530.tar.gz

cd less-530

2.参照书中说明编译安装

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

make -j8

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf less-530

第6.62章节

编译安装gzip包

1.解压并进入bzip包目录

tar -xvf gzip-1.10.tar.xz

cd gzip-1.10

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

mv -v /usr/bin/gzip /bin

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf gzip-1.10

第6.63章节

编译安装iproute包

1.解压并进入iproute包目录

tar -xvf iproute2-4.20.0.tar.xz

cd iproute2-4.20.0

2.参照书中说明编译安装

sed -i /ARPD/d Makefile
rm -fv man/man8/arpd.8 sed -i 's/.m_ipt.o//' tc/Makefile make -j8 make DOCDIR=/usr/share/doc/iproute2-4.20.0 install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf iproute2-4.20.0

第6.64章节

编译安装kbd包

1.解压并进入kbd包目录

tar -xvf kbd-2.0.4.tar.xz

cd kbd-2.0.4

2.参照书中说明编译安装

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 make -j8 make -j8 check make install mkdir -v /usr/share/doc/kbd-2.0.4
cp -R -v docs/doc/* /usr/share/doc/kbd-2.0.4

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf kbd-2.0.4

第6.65章节

编译安装libpipeline包

1.解压并进入libpipeline包目录

tar -xvf libpipeline-1.5.1.tar.gz 

cd libpipeline-1.5.1

2.参照书中说明编译安装

./configure --prefix=/usr

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf libpipeline-1.5.1

第6.66章节

编译安装make包

1.解压并进入make包目录

tar -xvf make-4.2.1.tar.bz2

cd make-4.2.1

2.参照书中说明编译安装

sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c

./configure --prefix=/usr

make -j8

make PERL5LIB=$PWD/tests/ check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf make-4.2.1

第6.67章节

编译安装patch包

1.解压并进入patch包目录

tar -xvf patch-2.7.6.tar.xz

cd patch-2.7.6 

2.参照书中说明编译安装patch包

./configure --prefix=/usr

make -j8

make -j8 check

make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf patch-2.7.6

第6.68章节

编译安装man-db包

1.解压并进入man-db包目录

tar -xvf man-db-2.8.5.tar.xz

cd man-db-2.8.5

2.参照书中说明编译安装

./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 \
--with-systemdtmpfilesdir= make -j8 make -j8 check make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf man-db-2.8.5

第6.69章节

编译安装tar包

1.解压并进入tar包

tar -xvf tar-1.31.tar.xz

cd tar-1.31

2.参照书中说明编译安装

sed -i 's/abort.*/FALLTHROUGH;/' src/extract.c

FORCE_UNSAFE_CONFIGURE=  \
./configure --prefix=/usr \
--bindir=/bin make -j8 make -j8 check make install
make -C doc install-html docdir=/usr/share/doc/tar-1.31

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf tar-1.31

第6.70章节

编译安装texinfo包

1.解压并进入texinfo包目录

tar -xvf texinfo-6.5.tar.xz

cd texinfo-6.5

2.参照书中说明编译安装

sed -i '5481,5485 s/({/(\\{/' tp/Texinfo/Parser.pm

./configure --prefix=/usr --disable-static

make -j8

make -j8 check

make install

make TEXMF=/usr/share/texmf install-tex

pushd /usr/share/info
rm -v dir
for f in *
do install-info $f dir 2>/dev/null
done
popd

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf texinfo-6.5

第6.71章节

编译安装vim包

1.解压并进入vim包目录

tar -xvf vim-8.1.tar.bz2

cd vim81/

2.参照书中说明编译安装

echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h

./configure --prefix=/usr

make -j8

LANG=en_US.UTF-8 make -j1 test &> vim-test.log

make install

ln -sv vim /usr/bin/vi
for L in /usr/share/man/{,*/}man1/vim.1; do
ln -sv vim.1 $(dirname $L)/vi.1
done ln -sv ../vim/vim81/doc /usr/share/doc/vim-8.1

3.创建vim配置文件

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

4.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf vim81/

第6.72章节

编译安装systemd包

1.解压并进入systemd包

tar -xvf systemd-240.tar.gz

cd systemd-240

2.参照书中说明编译安装

patch -Np1 -i ../systemd--security_fixes-.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-.tar.xz sed '177,$ d' -i src/resolve/meson.build sed -i 's/GROUP="render", //' rules/-udev-default.rules.in mkdir -p build
cd build PKG_CONFIG_PATH="/usr/lib/pkgconfig:/tools/lib/pkgconfig" \
LANG=en_US.UTF- \
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 \
.. LANG=en_US.UTF- ninja
LANG=en_US.UTF- ninja install rm -rfv /usr/lib/rpm
rm -f /usr/bin/xsltproc systemd-machine-id-setup cat > /lib/systemd/systemd-user-sessions << "EOF"
#!/bin/bash
rm -f /run/nologin
EOF
chmod /lib/systemd/systemd-user-sessions

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf systemd-240

第6.73章节

编译安装dbus包

1.解压并进入dbus包目录

tar -xvf dbus-1.12.12.tar.gz

cd dbus-1.12.12

2.参照书中内容编译安装

  ./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 make -j8 make install 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

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf dbus-1.12.12

第6.74章节

编译安装procps包

1.解压并进入procps包目录

tar -xvf procps-ng-3.3.15.tar.xz

cd procps-ng-3.3.15

2.参照书中说明编译安装

./configure --prefix=/usr                            \
--exec-prefix= \
--libdir=/usr/lib \
--docdir=/usr/share/doc/procps-ng-3.3.15 \
--disable-static \
--disable-kill \
--with-systemd make -j8 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 make install mv -v /usr/lib/libprocps.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libprocps.so) /usr/lib/libprocps.so

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf procps-ng-3.3.15

第6.75章节

编译安装util-linux包

1.解压并进入util-linux包目录

tar -xvf util-linux-2.33.1.tar.xz

cd util-linux-2.33.1

2.参照书中说明编译安装

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 \
--without-systemd \
--without-systemdsystemunitdir make -j8 chown -Rv nobody .
su nobody -s /bin/bash -c "PATH=$PATH make -k check" make install

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf util-linux-2.33.1 

第6.76章节

编译安装e2fsprogs包

1.解压并进入e2fsprogs包目录

tar -xvf e2fsprogs-1.44.5.tar.gz

cd e2fsprogs-1.44.5

2.参照书中说明编译安装

mkdir -v build
cd build ../configure --prefix=/usr \
--bindir=/bin \
--with-root-prefix="" \
--enable-elf-shlibs \
--disable-libblkid \
--disable-libuuid \
--disable-uuidd \
--disable-fsck make -j8 ln -sfv /tools/lib/lib{blk,uu}id.so.1 lib
make LD_LIBRARY_PATH=/tools/lib check make install make install-libs chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a gunzip -v /usr/share/info/libext2fs.info.gz
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo
install -v -m644 doc/com_err.info /usr/share/info
install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info

3.返回sources目录并删除包目录

cd /mnt/lfs/sources
rm -rf e2fsprogs-1.44.5

第6.78章节

从二进制文件和库中删除调试符号 按照书籍中的命令操作即可(可选)建议执行此项操作

save_lib="ld-2.28.so libc-2.28.so libpthread-2.28.so libthread_db-1.0.so"

cd /lib

for LIB in $save_lib; do
objcopy --only-keep-debug $LIB $LIB.dbg
strip --strip-unneeded $LIB
objcopy --add-gnu-debuglink=$LIB.dbg $LIB
done save_usrlib="libquadmath.so.0.0.0 libstdc++.so.6.0.25
libitm.so.1.0.0 libatomic.so.1.2.0" cd /usr/lib for LIB in $save_usrlib; do
objcopy --only-keep-debug $LIB $LIB.dbg
strip --strip-unneeded $LIB
objcopy --add-gnu-debuglink=$LIB.dbg $LIB
done unset LIB save_lib save_usrlib exec /tools/bin/bash /tools/bin/find /usr/lib -type f -name \*.a \
-exec /tools/bin/strip --strip-debug {} ';' /tools/bin/find /lib /usr/lib -type f \( -name \*.so* -a ! -name \*dbg \) \
-exec /tools/bin/strip --strip-unneeded {} ';' /tools/bin/find /{bin,sbin} /usr/{bin,sbin,libexec} -type f \
-exec /tools/bin/strip --strip-all {} ';'

第6.79章节

1.清理运行测试剩下的一些额外文件

rm -rf /tmp/*

2.退出

exit

3.chroot进入lfs系统目录

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

4.删除tools目录

rm -rf tools/

5.删除无用的库

rm -f /usr/lib/lib{bfd,opcodes}.a
rm -f /usr/lib/libbz2.a
rm -f /usr/lib/lib{com_err,e2p,ext2fs,ss}.a
rm -f /usr/lib/libltdl.a
rm -f /usr/lib/libfl.a
rm -f /usr/lib/libz.a find /usr/lib /usr/libexec -name \*.la -delete

lfs(systemv版本)学习笔记第4页:https://www.cnblogs.com/renren-study-notes/p/10387326.html