mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-07-09 13:59:51 +01:00
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.
This commit is contained in:
parent
69c4524b6d
commit
490dc15317
@ -42,6 +42,11 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>2022-02-04</para>
|
<para>2022-02-04</para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>[xry111] - Rename <command>bash</command>
|
||||||
|
<literal>+h</literal> directives in chroot. Fixes
|
||||||
|
<ulink url="&lfs-ticket-root;4998">#4998</ulink>.</para>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>[xry111] - Update to man-db-2.10.0. Fixes
|
<para>[xry111] - Update to man-db-2.10.0. Fixes
|
||||||
<ulink url="&lfs-ticket-root;5002">#5002</ulink>.</para>
|
<ulink url="&lfs-ticket-root;5002">#5002</ulink>.</para>
|
||||||
|
@ -64,9 +64,11 @@ EOF</userinput></screen>
|
|||||||
be used as soon as they are installed. By switching off the hash function,
|
be used as soon as they are installed. By switching off the hash function,
|
||||||
the shell will always search the <envar>PATH</envar> when a program is to
|
the shell will always search the <envar>PATH</envar> when a program is to
|
||||||
be run. As such, the shell will find the newly compiled tools in
|
be run. As such, the shell will find the newly compiled tools in
|
||||||
<filename class="directory">$LFS/tools</filename> as soon as they are
|
<filename class="directory">$LFS/tools/bin</filename> as soon as they are
|
||||||
available without remembering a previous version of the same program in a
|
available without remembering a previous version of the same program
|
||||||
different location.</para>
|
provided by the host distro, in
|
||||||
|
<filename class='directory'>/usr/bin</filename> or
|
||||||
|
<filename class='directory'>/bin</filename>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
TERM="$TERM" \
|
TERM="$TERM" \
|
||||||
PS1='(lfs chroot) \u:\w\$ ' \
|
PS1='(lfs chroot) \u:\w\$ ' \
|
||||||
PATH=/usr/bin:/usr/sbin \
|
PATH=/usr/bin:/usr/sbin \
|
||||||
/bin/bash --login +h</userinput></screen>
|
/bin/bash --login</userinput></screen>
|
||||||
|
|
||||||
<para>The <parameter>-i</parameter> option given to the <command>env</command>
|
<para>The <parameter>-i</parameter> option given to the <command>env</command>
|
||||||
command will clear all variables of the chroot environment. After that, only
|
command will clear all variables of the chroot environment. After that, only
|
||||||
@ -44,10 +44,7 @@
|
|||||||
|
|
||||||
<para>Notice that <filename class="directory">/tools/bin</filename> is not
|
<para>Notice that <filename class="directory">/tools/bin</filename> is not
|
||||||
in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
|
in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
|
||||||
used in the chroot environment. This occurs when the shell does not
|
used in the chroot environment.</para>
|
||||||
<quote>remember</quote> the locations of executed binaries—for this
|
|
||||||
reason, hashing is switched off by passing the <parameter>+h</parameter> option
|
|
||||||
to <command>bash</command>.</para>
|
|
||||||
|
|
||||||
<para>Note that the <command>bash</command> prompt will say
|
<para>Note that the <command>bash</command> prompt will say
|
||||||
<computeroutput>I have no name!</computeroutput> This is normal because the
|
<computeroutput>I have no name!</computeroutput> This is normal because the
|
||||||
|
@ -184,14 +184,7 @@ install -o tester -d /home/tester</userinput></screen>
|
|||||||
files have been created, user name and group name resolution will now
|
files have been created, user name and group name resolution will now
|
||||||
work:</para>
|
work:</para>
|
||||||
|
|
||||||
<screen role="nodump"><userinput>exec /usr/bin/bash --login +h</userinput></screen>
|
<screen role="nodump"><userinput>exec /usr/bin/bash --login</userinput></screen>
|
||||||
|
|
||||||
<para>Note the use of the <parameter>+h</parameter> directive. This tells
|
|
||||||
<command>bash</command> not to use its internal path hashing. Without this
|
|
||||||
directive, <command>bash</command> 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 <parameter>+h</parameter> directive will be used for the duration
|
|
||||||
of this and the next chapter.</para>
|
|
||||||
|
|
||||||
<para>The <command>login</command>, <command>agetty</command>, and
|
<para>The <command>login</command>, <command>agetty</command>, and
|
||||||
<command>init</command> programs (and others) use a number of log
|
<command>init</command> programs (and others) use a number of log
|
||||||
|
@ -94,13 +94,7 @@ EOF</userinput></screen>
|
|||||||
<para>Run the newly compiled <command>bash</command> program (replacing the one that is
|
<para>Run the newly compiled <command>bash</command> program (replacing the one that is
|
||||||
currently being executed):</para>
|
currently being executed):</para>
|
||||||
|
|
||||||
<screen role="nodump"><userinput>exec /usr/bin/bash --login +h</userinput></screen>
|
<screen role="nodump"><userinput>exec /usr/bin/bash --login</userinput></screen>
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>The parameters used make the <command>bash</command>
|
|
||||||
process an interactive login shell and continues to disable hashing so
|
|
||||||
that new programs are found as they become available.</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
@ -14,28 +14,6 @@
|
|||||||
|
|
||||||
<screen><userinput>rm -rf /tmp/*</userinput></screen>
|
<screen><userinput>rm -rf /tmp/*</userinput></screen>
|
||||||
|
|
||||||
<para>Now log out and reenter the chroot environment with an updated
|
|
||||||
chroot command. From now on, use this updated chroot command any time
|
|
||||||
you need to reenter the chroot environment after exiting:</para>
|
|
||||||
|
|
||||||
<screen role="nodump"><userinput>logout
|
|
||||||
|
|
||||||
chroot "$LFS" /usr/bin/env -i \
|
|
||||||
HOME=/root TERM="$TERM" \
|
|
||||||
PS1='(lfs chroot) \u:\w\$ ' \
|
|
||||||
PATH=/usr/bin:/usr/sbin \
|
|
||||||
/usr/bin/bash --login</userinput></screen>
|
|
||||||
|
|
||||||
<para>Here the <parameter>+h</parameter> option is not used anymore, since
|
|
||||||
all the previous programs have been replaced: hashing is therefore
|
|
||||||
possible.</para>
|
|
||||||
|
|
||||||
<para>If the virtual kernel file systems have been unmounted, either manually
|
|
||||||
or through a reboot, ensure that the virtual kernel file systems are mounted
|
|
||||||
when reentering the chroot. This process was explained in <xref
|
|
||||||
linkend="ch-tools-bindmount"/> and <xref
|
|
||||||
linkend="ch-tools-kernfsmount"/>.</para>
|
|
||||||
|
|
||||||
<para>There are also several files installed in the /usr/lib and /usr/libexec
|
<para>There are also several files installed in the /usr/lib and /usr/libexec
|
||||||
directories with a file name extension of .la. These are "libtool archive"
|
directories with a file name extension of .la. These are "libtool archive"
|
||||||
files. As already said, they are only useful when linking with static
|
files. As already said, they are only useful when linking with static
|
||||||
|
Loading…
Reference in New Issue
Block a user