From 7b54528e96a6d715f55222fb071d0dcb0021258d Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Fri, 2 Feb 2024 10:10:53 -0600 Subject: [PATCH 1/8] Fix currency for xz --- lfs-latest-git.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lfs-latest-git.php b/lfs-latest-git.php index 162d8d6c8..c2414789a 100644 --- a/lfs-latest-git.php +++ b/lfs-latest-git.php @@ -152,6 +152,7 @@ if ( $package == "tcl" ) $dirpath = "https://www.tcl.tk/software/tcltk/do if ( $package == "util-linux" ) $dirpath = max_parent( $dirpath, "v." ); if ( $package == "vim" ) $dirpath = "https://github.com/vim/vim/tags"; if ( $package == "wheel" ) $dirpath = "https://pypi.org/project/wheel/#files"; +if ( $package == "xz" ) $dirpath = github("tukaani-project/xz"); if ( $package == "zlib" ) $dirpath = "https://www.zlib.net"; if ( $package == "zstd" ) $dirpath = github("facebook/zstd"); From 677f795cf85f1ecb40dfedf1624817d3288ea1ca Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sat, 3 Feb 2024 18:55:26 +0800 Subject: [PATCH 2/8] glibc: When update, also regenerate the locales A Glibc update may contain locale updates, so keep /usr/lib/locale/locale-archive synced. Other distros are also doing this when Glibc is updated with the package manager. --- chapter08/glibc.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chapter08/glibc.xml b/chapter08/glibc.xml index e09fe4900..64ed3b630 100644 --- a/chapter08/glibc.xml +++ b/chapter08/glibc.xml @@ -309,10 +309,11 @@ install -vm755 dest/usr/lib/*.so.* /usr/lib - Then continue to run the make install command - and the sed command against - /usr/bin/ldd. Once they are finished, reboot - the system immediately. + Then continue to run the make install command, + the sed command against + /usr/bin/ldd, and the commands to install + the locales. Once they are finished, reboot the system + immediately. From 8cf42d4c72d9e0b773c32849af2fb237b557029e Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sun, 4 Feb 2024 03:40:36 +0800 Subject: [PATCH 3/8] Fix and unify the commands creating the link target of /dev/shm $(realpath /dev/shm) will return the absolute path of the target of /dev/shm, thus the command will work for both absolute symlink and relative symlink. --- chapter07/kernfs.xml | 5 +++-- chapter11/afterlfs.xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml index 00a971b59..ecdff0dd2 100644 --- a/chapter07/kernfs.xml +++ b/chapter07/kernfs.xml @@ -97,7 +97,8 @@ mount -vt tmpfs tmpfs $LFS/run --> In some host systems, /dev/shm is a - symbolic link to /run/shm. + symbolic link to a directory, typically + /run/shm. The /run tmpfs was mounted above so in this case only a directory needs to be created. @@ -107,7 +108,7 @@ mount -vt tmpfs tmpfs $LFS/run we must explicitly mount a tmpfs: if [ -h $LFS/dev/shm ]; then - (cd $LFS/dev; mkdir $(readlink shm)) + mkdir -pv $LFS$(realpath /dev/shm) else mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm fi diff --git a/chapter11/afterlfs.xml b/chapter11/afterlfs.xml index ff8bae006..5c2693ade 100644 --- a/chapter11/afterlfs.xml +++ b/chapter11/afterlfs.xml @@ -130,7 +130,7 @@ mounttype proc proc proc mounttype sys sysfs sysfs mounttype run tmpfs run if [ -h $LFS/dev/shm ]; then - mkdir -pv $LFS/$(readlink $LFS/dev/shm) + mkdir -pv $LFS$(realpath /dev/shm) else mounttype dev/shm tmpfs tmpfs -o nosuid,nodev fi From 7436c28ae4acc14d3646131bb59cc3574e42936e Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sun, 4 Feb 2024 22:56:04 +0800 Subject: [PATCH 4/8] If we need to create the link target of /dev/shm, make its mode 1777 To match the behavior of a tmpfs mount. Otherwise non-root user (for e.g. the tester user) will get errors using Glibc shm functions. --- chapter07/kernfs.xml | 4 ++-- chapter11/afterlfs.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml index ecdff0dd2..31244e8c0 100644 --- a/chapter07/kernfs.xml +++ b/chapter07/kernfs.xml @@ -100,7 +100,7 @@ mount -vt tmpfs tmpfs $LFS/run symbolic link to a directory, typically /run/shm. The /run tmpfs was mounted above so in this case only a - directory needs to be created. + directory needs to be created with a correct mode. In other host systems /dev/shm is a mount point for a tmpfs. In that case the mount of /dev above will only create @@ -108,7 +108,7 @@ mount -vt tmpfs tmpfs $LFS/run we must explicitly mount a tmpfs: if [ -h $LFS/dev/shm ]; then - mkdir -pv $LFS$(realpath /dev/shm) + install -v -d -m 1777 $LFS$(realpath /dev/shm) else mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm fi diff --git a/chapter11/afterlfs.xml b/chapter11/afterlfs.xml index 5c2693ade..633a782df 100644 --- a/chapter11/afterlfs.xml +++ b/chapter11/afterlfs.xml @@ -130,7 +130,7 @@ mounttype proc proc proc mounttype sys sysfs sysfs mounttype run tmpfs run if [ -h $LFS/dev/shm ]; then - mkdir -pv $LFS$(realpath /dev/shm) + install -v -d -m 1777 $LFS$(realpath /dev/shm) else mounttype dev/shm tmpfs tmpfs -o nosuid,nodev fi From 1541b7c29f10b6cfaf954dbb67345206e4f78e93 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Sun, 4 Feb 2024 12:13:17 -0600 Subject: [PATCH 5/8] Minor wording update --- chapter07/kernfs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml index 31244e8c0..575044106 100644 --- a/chapter07/kernfs.xml +++ b/chapter07/kernfs.xml @@ -100,7 +100,7 @@ mount -vt tmpfs tmpfs $LFS/run symbolic link to a directory, typically /run/shm. The /run tmpfs was mounted above so in this case only a - directory needs to be created with a correct mode. + directory needs to be created with the correct permissions. In other host systems /dev/shm is a mount point for a tmpfs. In that case the mount of /dev above will only create From ce11e97f013485bdedd834b960c88a1452701648 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 6 Feb 2024 00:15:33 +0800 Subject: [PATCH 6/8] kernfs: Use a separate devpts filesystem for chroot environment IIRC we switched from separate devpts to bind mount, and matched the UID of tester with the host UID owning the TTY, to satisify the Bash test suite. But now we are always using UID 101 for tester and expect to spawn a PTY for Bash test suite (so when building LFS in a TTY owned by the root user of the host tester won't be UID 0). Thus we can switch back to a separate devpts mount which is cleaner and safer. And we are already using a separate devpts mount in Chapter 11. --- chapter07/kernfs.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml index 575044106..067a614f4 100644 --- a/chapter07/kernfs.xml +++ b/chapter07/kernfs.xml @@ -63,11 +63,14 @@ Now mount the remaining virtual kernel file systems: -mount -v --bind /dev/pts $LFS/dev/pts + + +mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys mount -vt tmpfs tmpfs $LFS/run - + In some host systems, /dev/shm is a symbolic link to a directory, typically /run/shm. From 1fde756b121ffcba522f252475418714240358c7 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 6 Feb 2024 01:00:53 +0800 Subject: [PATCH 7/8] expect: Add (back) a simple test for PTY We used to run "expect -c 'spawn ls'" for this in Binutils, but then we thought expect test suite was enough as such a simple PTY test. However expect test can fail due to some different reason, so add back a simple test using Python pty module before building expect. Now we no longer need to consider expect test critical (IIRC there was a report saying one expect test failed for unknown reason but all other things OK). --- chapter08/expect.xml | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/chapter08/expect.xml b/chapter08/expect.xml index 810bc55a2..5c21e390f 100644 --- a/chapter08/expect.xml +++ b/chapter08/expect.xml @@ -48,6 +48,25 @@ Installation of Expect + Expect needs PTYs to work. Verify that the PTYs are working + properly inside the chroot environment by performing a simple + test: + +python3 -c 'from pty import spawn; spawn(["echo", "ok"])' + + This command should output ok. + If, instead, the output includes OSError: out of pty + devices, then the environment is not set up for proper + PTY operation. You need to exit from the chroot environment, read + again, and ensure the + devpts file system (and + other virtual kernel file systems) mounted correctly. Then reenter + the chroot environment following . + This issue needs to be resolved before continuing, or the test suites + requring Expect (for example the test suites of Bash, Binutils, GCC, + GDBM, and of course Expect itself) will fail catastrophically, and other + subtle breakages may also happen. + Prepare Expect for compilation: ./configure --prefix=/usr \ @@ -82,27 +101,10 @@ make - - The test suite for Expect is considered critical. - Do not skip it under any circumstances. - - To test the results, issue: make test - If any test fails with the message - The system has no more ptys. Ask your system - administrator to create more, it indicates - you've not mounted the - devpts file system - correctly. You need to exit from the chroot environment, read - again, and ensure the - devpts file system (and - other virtual kernel file systems) mounted correctly. Then reenter - the chroot environment following . - This issue needs to be resolved before continuing. - Install the package: make install From 4816dc69f596e962ecb050fdfea3704e65514a47 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Tue, 6 Feb 2024 03:44:38 +0800 Subject: [PATCH 8/8] bash: Really pass through the return code We want expect to return the return code of "make test" (stored in $value), but $value is expanded too early to nothing by Bash. Quote EOF so Bash won't expand $xxx. --- chapter08/bash.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter08/bash.xml b/chapter08/bash.xml index 4b5b47e62..1490e7791 100644 --- a/chapter08/bash.xml +++ b/chapter08/bash.xml @@ -83,7 +83,7 @@ Expect and run the tests as the tester user: -su -s /usr/bin/expect tester << EOF +su -s /usr/bin/expect tester << "EOF" set timeout -1 spawn make tests expect eof