Index: HLFS/hlfs.xsl
===================================================================
--- HLFS/hlfs.xsl	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ HLFS/hlfs.xsl	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -27,5 +27,5 @@
        1 = only chapter06 Glibc, GCC and Binutils testsuites
        2 = all chapter06 testsuites
-       3 = all chapter05 and chapter06 testsuites-->
+       3 = alias to 2 -->
   <xsl:param name="testsuite" select="1"/>
 
@@ -95,29 +95,27 @@
         </xsl:choose>
         <xsl:if test="(sect2[@role='installation'] and
-                     not(@id='bootable-kernel')) or
-                     @id='ch-tools-adjusting' or
-                     @id='ch-system-readjusting'">
+                           not(@id='bootable-kernel'))">
           <xsl:text>cd $PKGDIR&#xA;</xsl:text>
           <xsl:if test="@id='ch-tools-uclibc' or @id='ch-system-uclibc'">
              <xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
           </xsl:if>
-          <xsl:if test="@id='ch-tools-glibc' or @id='ch-system-glibc'">
-             <xsl:text>tar -xvf ../glibc-libidn-&glibc-version;.*&#xA;</xsl:text>
-          </xsl:if>
-          <xsl:if test="@id='ch-tools-gcc' or @id='ch-system-gcc'">
-             <xsl:text>pushd ../; tar -xvf gcc-g++-&gcc-version;.*; popd; &#xA;</xsl:text>
-          </xsl:if>
-          <xsl:if test="@id='ch-tools-gcc' and $testsuite = '3'">
-            <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
-          </xsl:if>
-          <xsl:if test="@id='ch-system-gcc' and $testsuite != '0'">
-            <xsl:text>pushd ../; tar -xvf gcc-testsuite-&gcc-version;.*; popd; &#xA;</xsl:text>
-          </xsl:if>
+
+          <!-- NEW toolchain format, from inside ./sources dir unpack binutils and gcc -->
+	  <xsl:if test="@id='ch-tools-embryo-toolchain' or
+                        @id='ch-tools-cocoon-toolchain' or
+                        @id='ch-system-butterfly-toolchain'">
+             <xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
+             <xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
+             <xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
+          </xsl:if>
+          <!-- ONLY butterfly has a testsuite -->
+          <xsl:if test="@id='ch-tools-butterfly-toolchain' and $testsuite != '0'">
+            <xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
+          </xsl:if>
+          <!-- END new toolchain format -->
+
           <xsl:if test="@id='bootable-bootscripts'">
              <xsl:text>pushd ../; tar -xvf blfs-bootscripts-&blfs-bootscripts-version;.* ; popd; &#xA;</xsl:text>
           </xsl:if>
-        </xsl:if>
-        <xsl:if test="@id='ch-system-kernfs'">
-          <xsl:text>export HLFS=$LFS&#xA;</xsl:text>
         </xsl:if>
         <xsl:apply-templates select=".//para/userinput | .//screen"/>
@@ -136,22 +134,10 @@
   <xsl:template match="para/userinput">
     <xsl:if test="(contains(string(),'test') or
-            contains(string(),'check')) and
-            (($testsuite = '1' and
-            (ancestor::sect1[@id='ch-system-gcc'] or
-            ancestor::sect1[@id='ch-system-glibc'])) or
-            ($testsuite = '2' and
-            ancestor::chapter[@id='chapter-building-system']) or
-            $testsuite = '3')">
-      <xsl:choose>
-        <xsl:when test="ancestor::sect1[@id='ch-system-gcc']">
-          <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="substring-before(string(),'make')"/>
-          <xsl:text>make -k</xsl:text>
-          <xsl:value-of select="substring-after(string(),'make')"/>
-          <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
-        </xsl:otherwise>
-      </xsl:choose>
+                  contains(string(),'check')) and
+                  ($testsuite = '2' or $testsuite = '3')">
+      <xsl:value-of select="substring-before(string(),'make')"/>
+      <xsl:text>make -k</xsl:text>
+      <xsl:value-of select="substring-after(string(),'make')"/>
+      <xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
     </xsl:if>
   </xsl:template>
@@ -228,27 +214,21 @@
         </xsl:choose>
       </xsl:when>
-      <!-- Fixing toolchain test suites run -->
-      <xsl:when test="string() = 'make check' or
-                string() = 'make -k check'">
-        <xsl:choose>
-          <xsl:when test="(($testsuite = '1' or $testsuite = '2') and
-                    ancestor::chapter[@id='chapter-building-system']) or
-                    $testsuite = '3'">
+      <!-- Fixing butterfly toolchain test suites run -->
+      <xsl:when test="string() = 'make -k check'">
+        <xsl:choose>
+          <xsl:when test="$testsuite != '0'">
             <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
           </xsl:when>
         </xsl:choose>
       </xsl:when>
-      <xsl:when test="contains(string(),'make check') and
-                ancestor::sect1[@id='ch-system-binutils']">
+      <!-- Fixing Glbc test suite  -->
+      <xsl:when test="contains(string(),'glibc-check-log')">
         <xsl:choose>
           <xsl:when test="$testsuite != '0'">
-            <xsl:value-of select="substring-before(string(),'make check')"/>
-            <xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
-          </xsl:when>
-        </xsl:choose>
-      </xsl:when>
-      <xsl:when test="contains(string(),'hardened-specs') and
-                ancestor::sect1[@id='ch-system-binutils']
-                and $testsuite = '0'"/>
+            <xsl:value-of select="substring-before(string(),'&gt; glibc-')"/>
+            <xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:when>
       <!-- Don't stop on strip run and chapter05 GCC installation test-->
       <xsl:when test="contains(string(),'strip ') or
@@ -266,4 +246,10 @@
   </xsl:template>
 
+  <xsl:template match="literal">
+    <xsl:if test="@condition=$model or not(@condition)">
+      <xsl:apply-templates/>
+    </xsl:if>
+  </xsl:template>
+
   <xsl:template match="replaceable">
     <xsl:choose>
Index: HLFS/master.sh
===================================================================
--- HLFS/master.sh	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ HLFS/master.sh	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -8,9 +8,107 @@
 ###################################
 
+#----------------------------------#
+wrt_ExecuteAsUser() {              # Execute the file ($3) under the users account ($1), log in $2
+#----------------------------------#
+  local this_user=$1
+  local this_script=$2
+  local file=$3
+
+(
+cat << EOF
+	@( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
+	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
+EOF
+) >> $MKFILE.tmp
+}
+
+
+#----------------------------------#
+wrt_Unpack_SetOwner() {            # Unpack and set owner. Assign 'ROOT' var
+#----------------------------------#
+  local USER_ACCT=$1
+  local FILE=$2
+  local optSAVE_PREVIOUS=$3
+
+  if [ "${optSAVE_PREVIOUS}" != "1" ]; then
+    wrt_remove_existing_dirs "$FILE"
+  fi
+(
+cat << EOF
+	@\$(call unpack,$FILE)
+	@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
+	echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
+	chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
+EOF
+) >> $MKFILE.tmp
+}
+
+#----------------------------------#
+wrt_RunAsRoot() {                  # Some scripts must be run as root..
+#----------------------------------#
+  local user_ACCT=$(echo $1 | tr [a-z] [A-Z])
+  local this_script=$2
+  local file=$3
+
+(
+cat << EOF
+	@( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
+	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
+EOF
+) >> $MKFILE.tmp
+}
+
+
+#----------------------------#
+process_toolchain() {        # embryo,cocoon and butterfly need special handling
+#----------------------------#
+  local toolchain=$1
+  local this_script=$2
+  local  tc_phase
+
+  echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}"
+
+  case ${toolchain} in
+    *butterfly*)
+      [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
+(
+cat << EOF
+	@echo "export PKGDIR=\$(SRC)" > envars
+EOF
+) >> $MKFILE.tmp
+      wrt_run_as_chroot1 "$toolchain" "$this_script"
+      ;;
+
+    *)
+(
+cat << EOF
+	@echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
+EOF
+) >> $MKFILE.tmp
+      wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
+      ;;
+  esac
+  #
+  # Safe method to remove packages unpacked outside the toolchain
+  pkg_tarball=$(get_package_tarball_name "binutils")
+  wrt_remove_existing_dirs  "$pkg_tarball"
+  pkg_tarball=$(get_package_tarball_name "gcc-core")
+  wrt_remove_existing_dirs  "$pkg_tarball"
+  #
+  # Manually remove the toolchain directories..
+  tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
+(
+cat << EOF
+	@rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
+	rm  -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
+EOF
+) >> $MKFILE.tmp
+
+}
+
 
 #----------------------------#
 chapter3_Makefiles() {       # Initialization of the system
 #----------------------------#
-  local TARGET LOADER
 
   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
@@ -18,12 +116,11 @@
   # Define a few model dependant variables
   if [[ ${MODEL} = "uclibc" ]]; then
-    TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
+    TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
   else
-    TARGET="tools-linux-gnu";    LOADER="ld-linux.so.2"
+    TARGET="pc-linux-gnu";    LOADER="ld-linux.so.2"
   fi
 
-  # NOTE: We use the lfs username and groupname also in HLFS
-  # If /home/lfs is already present in the host, we asume that the
-  # lfs user and group are also presents in the host, and a backup
+  # If /home/hlfs is already present in the host, we asume that the
+  # hlfs user and group are also presents in the host, and a backup
   # of their bash init files is made.
 (
@@ -44,12 +141,12 @@
 021-addinguser:  020-creatingtoolsdir
 	@\$(call echo_message, Building)
-	@if [ ! -d /home/lfs ]; then \\
-		groupadd lfs; \\
-		useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
+	@if [ ! -d /home/hlfs ]; then \\
+		groupadd hlfs; \\
+		useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
 	else \\
-		touch user-lfs-exist; \\
-	fi;
-	@chown lfs \$(MOUNT_PT)/tools && \\
-	chown lfs \$(MOUNT_PT)/sources && \\
+		touch user-hlfs-exist; \\
+	fi;
+	@chown hlfs \$(MOUNT_PT)/tools && \\
+	chown hlfs \$(MOUNT_PT)/sources && \\
 	touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -58,22 +155,22 @@
 022-settingenvironment:  021-addinguser
 	@\$(call echo_message, Building)
-	@if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
-		mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
-	fi;
-	@if [ -f /home/lfs/.bash_profile  -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
-		mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
-	fi;
-	@echo "set +h" > /home/lfs/.bashrc && \\
-	echo "umask 022" >> /home/lfs/.bashrc && \\
-	echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
-	echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
-	echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
-	echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
-	echo "" >> /home/lfs/.bashrc && \\
+	@if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
+		mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
+	fi;
+	@if [ -f /home/hlfs/.bash_profile  -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
+		mv /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
+	fi;
+	@echo "set +h" > /home/hlfs/.bashrc && \\
+	echo "umask 022" >> /home/hlfs/.bashrc && \\
+	echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\
+	echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
+	echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
+	echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
+	echo "" >> /home/hlfs/.bashrc && \\
 	echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
 	echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
 	echo "export target ldso" >> /home/lfs/.bashrc && \\
-	echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
-	chown lfs:lfs /home/lfs/.bashrc && \\
+	echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
+	chown hlfs:hlfs /home/hlfs/.bashrc && \\
 	touch envars && \\
 	touch \$@ && \\
@@ -114,12 +211,9 @@
     chapter5="$chapter5 $this_script"
 
-    # Grab the name of the target (minus the -headers or -cross in the case of gcc
-    # and binutils in chapter 5)
-    name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
+    # Grab the name of the target
+    name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
 
     # Adjust 'name'
     case $name in
-      linux-libc) name="linux-libc-headers" ;;
-      gcc)        name="gcc-core"  ;;
       uclibc)     name="uClibc"  ;;
     esac
@@ -134,6 +228,17 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
+
+    # This is a very special script and requires manual processing
+    # NO Optimization allowed
+    if [[ ${name} = "embryo-toolchain" ]] || \
+       [[ ${name} = "cocoon-toolchain" ]]; then
+       wrt_target "$this_script" "$PREV"
+         process_toolchain "${this_script}" "${file}"
+       wrt_touch
+       PREV=$this_script
+       continue
+    fi
+    #
     wrt_target "$this_script" "$PREV"
-
     # Find the version of the command files, if it corresponds with the building of
     # a specific package
@@ -142,8 +247,5 @@
     if [ "$pkg_tarball" != "" ] ; then
       # Insert instructions for unpacking the package and to set the PKGDIR variable.
-      case $this_script in
-        *binutils* )  wrt_unpack "$pkg_tarball" 1 ;; # Do not delete an existing package directories
-        *)            wrt_unpack "$pkg_tarball" ;;
-      esac
+      wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
       # If the testsuites must be run, initialize the log file
       [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
@@ -151,46 +253,13 @@
       [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     fi
-
-    case $this_script in
-      *binutils* )  # Dump the path to sources directory for later removal
-(
-cat << EOF
-	@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
-	echo "\$(MOUNT_PT)\$(SRC)/\$\$ROOT" >> sources-dir
-EOF
-) >> $MKFILE.tmp
-        ;;
-      *adjusting* )  # For the Adjusting phase we must to cd to the binutils-build directory.
-        echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
-        ;;
-    esac
-
     # Insert date and disk usage at the top of the log file, the script run
     # and date and disk usage again at the bottom of the log file.
-    wrt_run_as_su "${this_script}" "${file}"
+    wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
 
     # Remove the build directory(ies) except if the package build fails
     # (so we can review config.cache, config.log, etc.)
-    # For Binutils the sources must be retained for some time.
     if [ "$pkg_tarball" != "" ] ; then
-      case "${this_script}" in
-        *binutils*) : ;;   # do NOTHING
-	*gcc*) wrt_remove_build_dirs "gcc"    ;;
-        *)     wrt_remove_build_dirs "$name"    ;;
-      esac
+       wrt_remove_build_dirs "$name"
     fi
-
-    # Remove the Binutils pass 1 sources after a successful Adjusting phase.
-    case "${this_script}" in
-     *adjusting*)
-(
-cat << EOF
-	@rm -r \`cat sources-dir\` && \\
-	rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
-	rm sources-dir
-EOF
-) >> $MKFILE.tmp
-      ;;
-    esac
 
     # Include a touch of the target name so make can check if it's already been made.
@@ -210,5 +279,4 @@
 chapter6_Makefiles() {       # sysroot or chroot build phase
 #----------------------------#
-  local TARGET LOADER
   local file
   local this_script
@@ -238,12 +306,4 @@
 
   echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
-  #
-  # Set these definitions early and only once
-  #
-  if [[ ${MODEL} = "uclibc" ]]; then
-    TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
-  else
-    TARGET="pc-linux-gnu";    LOADER="ld-linux.so.2"
-  fi
 
   for file in chapter06$N/* ; do
@@ -263,15 +323,5 @@
     name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
 
-    #
-    # Sed replacement to fix some rm command that could fail.
-    # That should be fixed in the book sources.
-    #
     case $name in
-      glibc)  sed 's/rm /rm -f /' -i chapter06$N/$this_script        ;;
-      gcc)    sed 's/rm /rm -f /' -i chapter06$N/$this_script        ;;
-    esac
-
-    case $name in
-      gcc)     name="gcc-core" ;;
       uclibc)  name="uClibc"   ;;
     esac
@@ -302,5 +352,13 @@
     #
     # Drop in the name of the target on a new line, and the previous target
-    # as a dependency. Also call the echo_message function.		
+    # as a dependency. Also call the echo_message function.
+    if [[ ${name} = "butterfly-toolchain" ]]; then
+       wrt_target "$this_script" "$PREV"
+         process_toolchain "${this_script}" "${file}"
+       wrt_touch
+       PREV=$this_script
+       continue
+    fi
+
     wrt_target "${this_script}${N}" "$PREV"
 
@@ -309,8 +367,7 @@
     if [ "$pkg_tarball" != "" ] ; then
       wrt_unpack2 "$pkg_tarball"
-      wrt_target_vars
       # If the testsuites must be run, initialize the log file
       case $name in
-        binutils | gcc-core | glibc )
+        glibc )
           [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
           ;;
@@ -323,14 +380,8 @@
     fi
 
-    case $this_script in
-      *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
-        echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
-        ;;
-    esac
-
-    # In the mount of kernel filesystems we need to set LFS and not to use chroot.
+    # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
     case "${this_script}" in
       *kernfs*)
-        wrt_run_as_root "${this_script}" "${file}"
+        wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
         ;;
       *)   # The rest of Chapter06
@@ -344,17 +395,4 @@
     fi
     #
-    # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
-    case "${this_script}" in
-      *readjusting*)
-(
-cat << EOF
-	@rm -r \`cat sources-dir\` && \\
-	rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
-	rm sources-dir
-EOF
-) >> $MKFILE.tmp
-      ;;
-    esac
-
     # Include a touch of the target name so make can check if it's already been made.
     wrt_touch
@@ -390,5 +428,4 @@
       *usage)   continue  ;; # Contains example commands
       *grub)    continue  ;;
-      *reboot)  continue  ;;
       *console) continue  ;; # Use the file generated by lfs-bootscripts
 
@@ -520,5 +557,5 @@
 chapter3:  020-creatingtoolsdir 021-addinguser 022-settingenvironment
 
-chapter5:  chapter3 $chapter5 restore-lfs-env
+chapter5:  chapter3 $chapter5 restore-hlfs-env
 
 chapter6:  chapter5 $chapter6
@@ -534,16 +571,16 @@
 
 clean-chapter3:
-	-if [ ! -f user-lfs-exist ]; then \\
-		userdel lfs; \\
-		rm -rf /home/lfs; \\
+	-if [ ! -f user-hlfs-exist ]; then \\
+		userdel hlfs; \\
+		rm -rf /home/hlfs; \\
 	fi;
 	rm -rf \$(MOUNT_PT)/tools
 	rm -f /tools
-	rm -f envars user-lfs-exist
+	rm -f envars user-hlfs-exist
 	rm -f 02* logs/02*.log
 
 clean-chapter5:
 	rm -rf \$(MOUNT_PT)/tools/*
-	rm -f $chapter5 restore-lfs-env sources-dir
+	rm -f $chapter5 restore-hlfs-env sources-dir
 	cd logs && rm -f $chapter5 && cd ..
 
@@ -562,13 +599,13 @@
 	cd logs && rm -f $chapter7 && cd ..
 
-restore-lfs-env:
+restore-hlfs-env:
 	@\$(call echo_message, Building)
-	@if [ -f /home/lfs/.bashrc.XXX ]; then \\
-		mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
-	fi;
-	@if [ -f /home/lfs/.bash_profile.XXX ]; then \\
-		mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
-	fi;
-	@chown lfs:lfs /home/lfs/.bash* && \\
+	@if [ -f /home/hlfs/.bashrc.XXX ]; then \\
+		mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
+	fi;
+	@if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
+		mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
+	fi;
+	@chown hlfs:hlfs /home/hlfs/.bash* && \\
 	touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -581,23 +618,23 @@
 	@-umount \$(MOUNT_PT)/sys
 	@-umount \$(MOUNT_PT)/proc
-	@-if [ ! -f user-lfs-exist ]; then \\
-		userdel lfs; \\
-		rm -rf /home/lfs; \\
+	@-if [ ! -f user-hlfs-exist ]; then \\
+		userdel hlfs; \\
+		rm -rf /home/hlfs; \\
 	fi;
 
 restart_code:
-	@echo ">>> This feature is experimental, BUGS may exist"	
-	
+	@echo ">>> This feature is experimental, BUGS may exist"
+
 	@if [ ! -L /tools ]; then \\
 	  echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
 	fi;
-	
+
 	@if [ ! -e /tools ]; then \\
 	  echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
 	fi;
-	
+
 	@if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
 	  echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
-	fi;	
+	fi;
 
 	@if [ -f ???-kernfs ]; then \\
Index: LFS/lfs.xsl
===================================================================
--- LFS/lfs.xsl	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ LFS/lfs.xsl	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -133,4 +133,10 @@
         <xsl:text>&#xA;</xsl:text>
       </xsl:when>
+      <!-- Fix Udev reinstallation after a build failure -->
+      <xsl:when test="contains(string(),'firmware,udev')">
+        <xsl:text>if [[ ! -d /lib/udev/devices ]] ; then&#xA;</xsl:text>
+        <xsl:apply-templates/>
+        <xsl:text>&#xA;fi&#xA;</xsl:text>
+      </xsl:when>
       <!-- Setting $LANG for /etc/profile -->
       <xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
Index: LFS/master.sh
===================================================================
--- LFS/master.sh	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ LFS/master.sh	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -166,7 +166,4 @@
     # Remove Bzip2 binaries before make install
     sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
-    # Let some Udev pre-installation commands to fail
-    sed -e 's@/lib/udev/devices/fd@& || true@' \
-        -e 's/mknod -m.*/& || true/' -i chapter06$N/*-udev
   fi
 
Index: common/common-functions
===================================================================
--- common/common-functions	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ common/common-functions	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -83,5 +83,5 @@
           2 = all final system testsuites
           3 = all temporary tools and final system testsuites
-        In CLFS, 3 is an alias to 2
+        In CLFS and HLFS, 3 is an alias to 2
 
 ${BOLD}  -W, --working-copy DIR${OFF}
Index: common/config
===================================================================
--- common/config	(revision 95a954c0870c5b0ce645c02b93234097b84c6b1b)
+++ common/config	(revision 83d73fb98517f7bbc7190e06b80721fd2623bd96)
@@ -17,5 +17,5 @@
 
 #=== Getting packages ===
-#    Files will be retrieved from the local archive SRC_ARCHIVE 
+#    Files will be retrieved from the local archive SRC_ARCHIVE
 #    (if defined) or the 'net and will be stored in $BUILDDIR/sources
 #--- Download the source packages 0(no)/1(yes)
@@ -49,5 +49,5 @@
 #  2 = all chapter06 testsuites
 #  3 = all chapter05 and chapter06 testsuites
-#      (in CLFS, alias to 2)
+#      (in CLFS and HLFS, alias to 2)
 TEST=1
 
