From 490dc15317e18e4f87d2a2555adc6ce2c2a774ba Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sat, 5 Feb 2022 11:36:39 +0800 Subject: remove "+h" in bash commands in chroot (#4998) In the new cross-compilation approach, the $PATH in chroot does not contain '/tools/bin'. So "+h" is useless in chroot as the newly installed tools always replace the temporary counterpart at the same location. "+h" in chapter4/settingenviron.xml is kept deliberately. Currently $LFS/tools/bin only contains programs prefixed with "x86_64-lfs-linux-gnu-", and it's highly unlikely that any distro will ever ship a program named with such prefix. So it may seems that we can remove this "+h" as well. However, the situation may change in future and we can take this oppertunity to teach the advantage and disvantage of bash hash feature. --- chapter07/chroot.xml | 7 ++----- chapter07/createfiles.xml | 9 +-------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'chapter07') diff --git a/chapter07/chroot.xml b/chapter07/chroot.xml index d018cb218..6404c0625 100644 --- a/chapter07/chroot.xml +++ b/chapter07/chroot.xml @@ -23,7 +23,7 @@ TERM="$TERM" \ PS1='(lfs chroot) \u:\w\$ ' \ PATH=/usr/bin:/usr/sbin \ - /bin/bash --login +h + /bin/bash --login The -i option given to the env command will clear all variables of the chroot environment. After that, only @@ -44,10 +44,7 @@ Notice that /tools/bin is not in the PATH. This means that the cross toolchain will no longer be - used in the chroot environment. This occurs when the shell does not - remember the locations of executed binaries—for this - reason, hashing is switched off by passing the +h option - to bash. + used in the chroot environment. Note that the bash prompt will say I have no name! This is normal because the diff --git a/chapter07/createfiles.xml b/chapter07/createfiles.xml index 9c4f6ac54..009806b3f 100644 --- a/chapter07/createfiles.xml +++ b/chapter07/createfiles.xml @@ -184,14 +184,7 @@ install -o tester -d /home/tester files have been created, user name and group name resolution will now work: -exec /usr/bin/bash --login +h - - Note the use of the +h directive. This tells - bash not to use its internal path hashing. Without this - directive, bash would remember the paths to binaries it has - executed. To ensure the use of the newly compiled binaries as soon as they are - installed, the +h directive will be used for the duration - of this and the next chapter. +exec /usr/bin/bash --login The login, agetty, and init programs (and others) use a number of log -- cgit v1.2.3-54-g00ecf