Index: CLFS/master.sh
===================================================================
--- CLFS/master.sh	(revision 33c7b13f0deaced8b4bc83c77a5cebff5c351801)
+++ CLFS/master.sh	(revision 6ad5a2fbb71942d230be4bf47110dd71c89b0d55)
@@ -42,14 +42,14 @@
 025-addinguser:  024-creatingcrossdir
 	@\$(call echo_message, Building)
-	@if [ ! -d /home/clfs ]; then \\
-		groupadd clfs; \\
-		useradd -s /bin/bash -g clfs -m -k /dev/null clfs; \\
+	@if [ ! -d /home/\$(LUSER) ]; then \\
+		groupadd \$(LGROUP); \\
+		useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
 	else \\
-		touch user-clfs-exist; \\
+		touch luser-exist; \\
 	fi;
-	@chown clfs \$(MOUNT_PT) && \\
-	chown clfs \$(MOUNT_PT)/tools && \\
-	chown clfs \$(MOUNT_PT)/cross-tools && \\
-	chown clfs \$(MOUNT_PT)/sources && \\
+	@chown \$(LUSER) \$(MOUNT_PT) && \\
+	chown \$(LUSER) \$(MOUNT_PT)/tools && \\
+	chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
+	chown \$(LUSER) \$(MOUNT_PT)/sources && \\
 	touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -58,25 +58,25 @@
 026-settingenvironment:  025-addinguser
 	@\$(call echo_message, Building)
-	@if [ -f /home/clfs/.bashrc -a ! -f /home/clfs/.bashrc.XXX ]; then \\
-		mv /home/clfs/.bashrc /home/clfs/.bashrc.XXX; \\
+	@if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
+		mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
 	fi;
-	@if [ -f /home/clfs/.bash_profile  -a ! -f /home/clfs/.bash_profile.XXX ]; then \\
-		mv /home/clfs/.bash_profile /home/clfs/.bash_profile.XXX; \\
+	@if [ -f /home/\$(LUSER)/.bash_profile  -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
+		mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
 	fi;
-	@echo "set +h" > /home/clfs/.bashrc && \\
-	echo "umask 022" >> /home/clfs/.bashrc && \\
-	echo "CLFS=\$(MOUNT_PT)" >> /home/clfs/.bashrc && \\
-	echo "LC_ALL=POSIX" >> /home/clfs/.bashrc && \\
-	echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/clfs/.bashrc && \\
-	echo "export CLFS LC_ALL PATH" >> /home/clfs/.bashrc && \\
-	echo "" >> /home/clfs/.bashrc && \\
-	echo "unset CFLAGS" >> /home/clfs/.bashrc && \\
-	echo "unset CXXFLAGS" >> /home/clfs/.bashrc && \\
-	echo "" >> /home/clfs/.bashrc && \\
-	echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/clfs/.bashrc && \\
-	echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/clfs/.bashrc && \\
-	echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/clfs/.bashrc && \\
-	echo "source $JHALFSDIR/envars" >> /home/clfs/.bashrc
-	@chown clfs:clfs /home/clfs/.bashrc && \\
+	@echo "set +h" > /home/\$(LUSER)/.bashrc && \\
+	echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
+	echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
+	echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
+	echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
+	echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
+	echo "" >> /home/\$(LUSER)/.bashrc && \\
+	echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
+	echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
+	echo "" >> /home/\$(LUSER)/.bashrc && \\
+	echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
+	echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
+	echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
+	echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
+	@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
 	touch envars && \\
 	touch \$@ && \\
@@ -132,7 +132,7 @@
     # If $pkg_tarball isn't empty, we've got a package...
     #
-    [[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
-    #
-    wrt_run_as_clfs_su "${this_script}" "${file}"
+    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
+    #
+    wrt_RunAsUser "${this_script}" "${file}"
     #
     [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
@@ -191,8 +191,8 @@
     # Insert instructions for unpacking the package and to set the PKGDIR variable.
     #
-    [[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
+    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
     [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     #
-    wrt_run_as_clfs_su "${this_script}" "${file}"
+    wrt_RunAsUser "${this_script}" "${file}"
     #
     [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
@@ -263,18 +263,18 @@
     # Insert instructions for unpacking the package and changing directories
     #
-    [[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
+    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
     [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     #
     # Select a script execution method
     case $this_script in
-      *changingowner*)  wrt_run_as_clfs_root "${this_script}" "${file}"    ;;
-      *devices*)        wrt_run_as_clfs_root "${this_script}" "${file}"    ;;
+      *changingowner*)  wrt_RunAsRoot "${this_script}" "${file}"    ;;
+      *devices*)        wrt_RunAsRoot "${this_script}" "${file}"    ;;
       *fstab*)   if [[ -n "$FSTAB" ]]; then
                    wrt_copy_fstab "${this_script}"
                  else
-                   wrt_run_as_clfs_su  "${this_script}" "${file}"
+                   wrt_RunAsUser  "${this_script}" "${file}"
                  fi
          ;;
-      *)         wrt_run_as_clfs_su  "${this_script}" "${file}"       ;;
+      *)         wrt_RunAsUser  "${this_script}" "${file}"       ;;
     esac
     #
@@ -333,5 +333,5 @@
     if [ "$pkg_tarball" != "" ] ; then
       case $this_script in
-        *util-linux)    wrt_unpack_clfs  "$pkg_tarball"  ;;
+        *util-linux)    wrt_unpack  "$pkg_tarball"  ;;
         *)              wrt_unpack2 "$pkg_tarball"  ;;
       esac
@@ -341,7 +341,7 @@
     # Select a script execution method
     case $this_script in
-      *kernfs)        wrt_run_as_clfs_root "${this_script}" "${file}"  ;;
-      *util-linux)    wrt_run_as_clfs_su   "${this_script}" "${file}"  ;;
-      *)              wrt_run_as_chroot1   "${this_script}" "${file}"  ;;
+      *kernfs)      wrt_RunAsRoot "${this_script}" "${file}"  ;;
+      *util-linux)  wrt_RunAsUser "${this_script}" "${file}"  ;;
+      *)            wrt_run_as_chroot1  "${this_script}" "${file}"  ;;
     esac
     #
@@ -1013,4 +1013,6 @@
 MOUNT_PT= $BUILDDIR
 PKG_LST= $PKG_LST
+LUSER= $LUSER
+LGROUP= $LGROUP
 
 include makefile-functions
@@ -1021,13 +1023,18 @@
   # Add chroot commands
   if [ "$METHOD" = "chroot" ] ; then
-    chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
-                            -e '/^export/d' \
-                            -e '/^logout/d' \
-                            -e 's@ \\\@ @g' | tr -d '\n' |  sed -e 's/  */ /g' \
-                                                                -e 's|\\$|&&|g' \
-                                                                -e 's|exit||g' \
-                                                                -e 's|$| -c|' \
-                                                                -e 's|"$$CLFS"|$(MOUNT_PT)|'\
-                                                                -e 's|set -e||'`
+    CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
+    chroot=`cat chroot/*chroot* | \
+            sed  -e "s@chroot@$CHROOT_LOC@" \
+                 -e '/#!\/tools\/bin\/bash/d' \
+                 -e '/^export/d' \
+                 -e '/^logout/d' \
+                 -e 's@ \\\@ @g' | \
+            tr -d '\n' |  \
+            sed -e 's/  */ /g' \
+                -e 's|\\$|&&|g' \
+                -e 's|exit||g' \
+                -e 's|$| -c|' \
+                -e 's|"$$CLFS"|$(MOUNT_PT)|'\
+                -e 's|set -e||'`
     echo -e "CHROOT1= $chroot\n" >> $MKFILE
   fi
@@ -1047,5 +1054,5 @@
 chapter4:  chapter3 $temptools
 
-chapter5:  chapter4 $chroottools $testsuitetools
+chapter5:  chapter4 $chroottools restore-luser-env $testsuitetools
 
 chapter6:  chapter5 $basicsystem
@@ -1064,7 +1071,7 @@
 
 clean-chapter2:
-	-if [ ! -f user-clfs-exist ]; then \\
-		userdel clfs; \\
-		rm -rf /home/clfs; \\
+	-if [ ! -f luser-exist ]; then \\
+		userdel \$(LUSER); \\
+		rm -rf /home/\$(LUSER); \\
 	fi;
 	rm -rf \$(MOUNT_PT)/tools
@@ -1072,10 +1079,10 @@
 	rm -rf \$(MOUNT_PT)/cross-tools
 	rm -f /cross-tools
-	rm -f envars user-clfs-exist
+	rm -f envars luser-exist
 	rm -f 02* logs/02*.log
 
 clean-chapter3:
 	rm -rf \$(MOUNT_PT)/tools/*
-	rm -f $cross_tools restore-clfs-env sources-dir
+	rm -f $cross_tools sources-dir
 	cd logs && rm -f $cross_tools && cd ..
 
@@ -1091,13 +1098,13 @@
 
 
-restore-clfs-env:
+restore-luser-env:
 	@\$(call echo_message, Building)
-	@if [ -f /home/clfs/.bashrc.XXX ]; then \\
-		mv -f /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
+	@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
+		mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
 	fi;
-	@if [ -f /home/clfs/.bash_profile.XXX ]; then \\
-		mv /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
+	@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
+		mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
 	fi;
-	@chown clfs:clfs /home/clfs/.bash* && \\
+	@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
 	touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -1110,7 +1117,7 @@
 	@-umount \$(MOUNT_PT)/sys
 	@-umount \$(MOUNT_PT)/proc
-	@-if [ ! -f user-clfs-exist ]; then \\
-		userdel clfs; \\
-		rm -rf /home/clfs; \\
+	@-if [ ! -f luser-exist ]; then \\
+		userdel \$(LUSER); \\
+		rm -rf /home/\$(LUSER); \\
 	fi;
 
@@ -1130,5 +1137,5 @@
 	$temptools \
 	$chroottools \
-	$boottools
+	$boottools restore-luser-env
 	@\$(call echo_boot_finished,$VERSION)
 
@@ -1146,7 +1153,7 @@
 
 clean-jhalfs:
-	-if [ ! -f user-clfs-exist ]; then \\
-		userdel clfs; \\
-		rm -rf /home/clfs; \\
+	-if [ ! -f luser-exist ]; then \\
+		userdel \$(LUSER); \\
+		rm -rf /home/\$(LUSER); \\
 	fi;
 	rm -rf \$(MOUNT_PT)/tools
@@ -1154,5 +1161,5 @@
 	rm -rf \$(MOUNT_PT)/cross-tools
 	rm -f /cross-tools
-	rm -f envars user-clfs-exist
+	rm -f envars luser-exist
 	rm -f 02* logs/02*.log
 
@@ -1160,5 +1167,5 @@
 	rm -rf /tools/*
 	rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
-	rm -f restore-clfs-env sources-dir
+	rm -f restore-luser-env sources-dir
 	cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
 
@@ -1176,13 +1183,13 @@
 
 
-restore-clfs-env:
+restore-luser-env:
 	@\$(call echo_message, Building)
-	@if [ -f /home/clfs/.bashrc.XXX ]; then \\
-		mv -fv /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
+	@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
+		mv -fv /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
 	fi;
-	@if [ -f /home/clfs/.bash_profile.XXX ]; then \\
-		mv -v /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
+	@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
+		mv -v /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
 	fi;
-	@chown clfs:clfs /home/clfs/.bash* && \\
+	@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
 	touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
