We have "exec /bin/bash" in Bash instruction, so it's no matter
about the chroot command used.  We can explicitly check which shell
is currently used.

And, use a simple "exec /tools/bin/bash" instead of reentering
the chroot.
-- 
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University
From d528a1e7bbff3163027a92e1cdf6b2e31838f3e4 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <[email protected]>
Date: Fri, 27 Apr 2018 20:07:55 +0800
Subject: [PATCH] Revise command to use temporary shell in "Stripping Again"

We have "exec /bin/bash" in Bash instruction, so it's no matter
about the chroot command used.  We can explicitly check which shell
we are using.

And, use a simple "exec /tools/bin/bash" instead of reentering
the chroot.
---
 chapter06/strippingagain.xml | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/chapter06/strippingagain.xml b/chapter06/strippingagain.xml
index db4a605b..df4edf49 100644
--- a/chapter06/strippingagain.xml
+++ b/chapter06/strippingagain.xml
@@ -58,20 +58,13 @@ done
 unset LIB save_lib save_usrlib</userinput></screen>
 
   <para>Before performing the stripping, take special care to ensure that
-  none of the binaries that are about to be stripped are running. If
-  unsure whether the user entered chroot with the command given in
-  <xref linkend="ch-system-chroot" role=","/> first exit from
-  chroot:</para>
+  none of the binaries that are about to be stripped are running. If the
+  current shell is in /bin, we must replace it with the temporary shell
+  in /tools/bin:</para>
 
-<screen role="nodump"><userinput>logout</userinput></screen>
-
-  <para>Then reenter it with:</para>
-
-<screen role="nodump"><userinput>chroot $LFS /tools/bin/env -i          \
-    HOME=/root TERM=$TERM              \
-    PS1='(lfs chroot) \u:\w\$ '        \
-    PATH=/bin:/usr/bin:/sbin:/usr/sbin \
-    /tools/bin/bash --login</userinput></screen>
+<screen role="nodump"><userinput>case $(readlink /proc/$$/exe) in /bin/*)
+    exec /tools/bin/bash --login
+esac</userinput></screen>
 
   <para>Now the binaries and libraries can be safely stripped:</para>
 
-- 
2.16.2

-- 
http://lists.linuxfromscratch.org/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to