From 6094daeb7aa83eefa865872182eed1adfa410c73 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 3 Aug 2021 23:58:46 +0800 Subject: [PATCH 1/7] strip: restore versions in online_usrlib and save_usrlib Without them, for example: cp /usr/lib/libbfd.so /tmp/libbfd.so # now /tmp/libbfd.so is a hardcopy of /usr/lib/libbfd-2.37.so strip --strip-unneeded /tmp/libbfd.so install -vm755 /tmp/libbfd.so /usr/lib/libbfd.so # now /usr/lib/libbfd.so is *not* a symlink, but a real file We don't want this to happen. libdl and libpthread removed: they are now dummy libs and is not used by anything built in LFS/BLFS. --- chapter08/strippingagain.xml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/chapter08/strippingagain.xml b/chapter08/strippingagain.xml index 825cd20e2..7692f6ce9 100644 --- a/chapter08/strippingagain.xml +++ b/chapter08/strippingagain.xml @@ -43,12 +43,11 @@ - save_usrlib="ld-linux-x86-64.so.2 +save_usrlib="ld-linux-x86-64.so.2 libc.so.6 - libpthread.so.6 - libthread_db.so + libthread_db.so.1 libquadmath.so.&libquadmath-version; - libstdc++.so.6 + libstdc++.so.&libstdcpp-version; libitm.so.&libitm-version; libatomic.so.&libatomic-version;" @@ -64,13 +63,12 @@ for LIB in $save_usrlib; do done online_usrbin="bash find strip" -online_usrlib="libbfd.so - libdl.so.2 - libhistory.so - libncursesw.so - libm.so.6 - libreadline.so - libz.so +online_usrlib="libbfd-&binutils-version;.so + libhistory.so.&readline-version; + libncursesw.so.&ncurses-version; + libm.so.6 + libreadline.so.&readline-version; + libz.so.&zlib-version; $(cd /usr/lib; find libnss*.so* -type f)" for BIN in $online_usrbin; do From 2a2225677242e22274c5446fc60bf2e4d2724cc8 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Wed, 4 Aug 2021 00:09:52 +0800 Subject: [PATCH 2/7] bash: minor command style fix --- chapter08/bash.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter08/bash.xml b/chapter08/bash.xml index e2d32bba4..699a24e43 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -42,9 +42,9 @@ Prepare Bash for compilation: -./configure --prefix=/usr \ +./configure --prefix=/usr \ --docdir=/usr/share/doc/bash-&bash-version; \ - --without-bash-malloc \ + --without-bash-malloc \ --with-installed-readline From 887b02bd8c9140431b76c4bf8712e1d2d9c827c8 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Wed, 4 Aug 2021 00:12:51 +0800 Subject: [PATCH 3/7] fix temp hosts file I think it may be related to Python 3 tests hang (?) --- chapter07/createfiles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter07/createfiles.xml b/chapter07/createfiles.xml index c55d40836..79fdaaf97 100644 --- a/chapter07/createfiles.xml +++ b/chapter07/createfiles.xml @@ -48,7 +48,7 @@ as well: cat > /etc/hosts << EOF -"127.0.0.1 localhost $(hostname)" +127.0.0.1 localhost $(hostname) ::1 localhost EOF From 99b29384ca1889da5776b261009940c239ae2958 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Wed, 4 Aug 2021 00:26:51 +0800 Subject: [PATCH 4/7] minor typo --- chapter08/glibc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter08/glibc.xml b/chapter08/glibc.xml index 2935c84af..675adf633 100644 --- a/chapter08/glibc.xml +++ b/chapter08/glibc.xml @@ -939,7 +939,7 @@ mkdir -pv /etc/ld.so.conf.d libutil - >Dummy library containing no functions. Previously contained + Dummy library containing no functions. Previously contained code for standard functions used in many different Unix utilities. These functions are now in libc From c649743dd612621a69872e95e38d5d575ce13d7e Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 3 Aug 2021 21:35:39 -0500 Subject: [PATCH 5/7] Clarify chapter 7 stripping and backup In chapter 7 we do not need to unmount file systems to strip binaries. Move unmounting to the backup/restore sections. Also make sure the stripping commands are valid. --- chapter07/stripping.xml | 54 ++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/chapter07/stripping.xml b/chapter07/stripping.xml index 1d81fff6f..65edf3a89 100644 --- a/chapter07/stripping.xml +++ b/chapter07/stripping.xml @@ -55,28 +55,27 @@ - Leave the chroot environment and unmount the kernel virtual file - systems: + Now, if you are stripping installed files or making a backup, + leave the chroot environment: - +exit + + All of the following instructions are executed by root. Take extra care about the commands you're going to run as mistakes here can modify your host system. Be aware that the - environment variable LFS is set for user - lfs by default - but it might not be set for + environment variables LFS and LFS_TGT + are set for user lfs by default + but may not be set for root. Whenever commands are to be executed by root, - make sure you have set LFS accordingly. + make sure you have set LFS and LFS_TGT accordingly. This has been discussed in . - + -exit -umount $LFS/dev{/pts,} -umount $LFS/{sys,proc,run} Stripping @@ -87,15 +86,15 @@ umount $LFS/{sys,proc,run} symbols. Strip off debugging symbols from binaries: -$LFS_TGT-strip --strip-unneeded $LFS/usr/lib/* -$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/* -$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/* + + cd $LFS/tools/$LFS_TGT +bin/strip --strip-unneeded $LFS/usr/lib/* +bin/strip --strip-unneeded $LFS/usr/{,s}bin/* +bin/strip --strip-unneeded $LFS/tools/bin/* These commands will skip a number of files reporting that it does not recognize their file format. Most of these are scripts instead of binaries. - + At this point, you should have at least 5 GB of free space on the chroot partition that can be used to build and install Glibc and GCC in @@ -125,14 +124,19 @@ $LFS_TGT-strip --strip-unneeded $LFS/tools/bin/* root. + Before we make a backup, unmount the virtual file systems: + +umount $LFS/dev{/pts,} +umount $LFS/{sys,proc,run} + Create the backup archive by running the following command: -cd $LFS && +cd $LFS tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz . -cd $LFS && +cd $LFS tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz . @@ -158,12 +162,12 @@ tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz . -cd $LFS && -rm -rf ./* && +cd $LFS +rm -rf ./* tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz -cd $LFS && -rm -rf ./* && +cd $LFS +rm -rf ./* tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz @@ -173,8 +177,8 @@ tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz - If you left the chroot environment either to strip off debug - symbols, create a backup, or restart building using a restore, + If you left the chroot environment + to create a backup or restart building using a restore, remember to check that the virtual filesystems are still mounted (findmnt | grep $LFS). If they are not mounted, remount them now as From d04ce158fe2f20829b45961f5217ced1a67e6923 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 3 Aug 2021 21:45:54 -0500 Subject: [PATCH 6/7] Wording --- chapter07/stripping.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chapter07/stripping.xml b/chapter07/stripping.xml index 65edf3a89..6572b042e 100644 --- a/chapter07/stripping.xml +++ b/chapter07/stripping.xml @@ -162,6 +162,12 @@ tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz . + The following commands are extremly dangerous. If + you run rm -rf ./* as the root user and you + do not change to the $LFS directory or the LFS + environment variable is not set for the root user, it will destroy + your entire host system. YOU ARE WARNED. + cd $LFS rm -rf ./* tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz From 4350669654193cfd741a9ff9def436efb9b13bef Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 3 Aug 2021 21:58:23 -0500 Subject: [PATCH 7/7] Make stripping work fo rboth x86 and x86_64 --- chapter08/strippingagain.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chapter08/strippingagain.xml b/chapter08/strippingagain.xml index 7692f6ce9..bf2493b02 100644 --- a/chapter08/strippingagain.xml +++ b/chapter08/strippingagain.xml @@ -40,10 +40,15 @@ Read the related entry in for the rationale to use the install command here. + The linux loader's name is ld-linux-x86-64.so.2 on 64-bit systems + and ld-linux.so.2 on 32-bit systems. The contruct below selects the + correct name for the current architecture. + + -save_usrlib="ld-linux-x86-64.so.2 + save_usrlib="$(cd /usr/lib; ls ld_linux*) libc.so.6 libthread_db.so.1 libquadmath.so.&libquadmath-version;