Index: CLFS2/master.sh
===================================================================
--- CLFS2/master.sh	(revision f4caf9cd7f297ad0938f0bdd92728a22e1bba4ad)
+++ CLFS2/master.sh	(revision 045b2dc1ce0a04e1270d82e02c34be3b28844a60)
@@ -12,5 +12,5 @@
   local   CLFS_HOST
 
-  echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
+  echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
 
   # defined here, only for ease of reading
@@ -36,5 +36,5 @@
 		touch luser-exist; \\
 	fi;
-	@chown \$(LUSER) \$(MOUNT_PT) && \\
+	@chown -R \$(LUSER) \$(MOUNT_PT) && \\
 	chown \$(LUSER) \$(MOUNT_PT)/sources
 	@touch \$@ && \\
@@ -65,5 +65,7 @@
 	echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
 	@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
-	touch envars
+	touch envars && \\
+	chown \$(LUSER):\$(LGROUP) envars && \\
+	chmod -R a+wt \$(MOUNT_PT)
 	@touch \$@ && \\
 	echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
@@ -123,4 +125,6 @@
 EOF
 ) >> $MKFILE.tmp
+
+  host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
 }
 
@@ -129,5 +133,5 @@
 cross_tools_Makefiles() {     #
 #-----------------------------#
-  echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
+  echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools     ( LUSER ) ${R_arrow}"
 
   for file in cross-tools/* ; do
@@ -176,16 +180,16 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    LUSER_wrt_target "${this_script}" "$PREV"
     #
     # If $pkg_tarball isn't empty, we've got a package...
     if [ "$pkg_tarball" != "" ] ; then
-       wrt_unpack "$pkg_tarball"
+       LUSER_wrt_unpack "$pkg_tarball"
        # If using optimizations, write the instructions
        [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     fi
     #
-    wrt_RunAsUser "${this_script}" "${file}"
-    #
-    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
+    LUSER_wrt_RunAsUser "${file}"
+    #
+    [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
     #
     # Include a touch of the target name so make can check if it's already been made.
@@ -207,5 +211,5 @@
 final_system_Makefiles() {    #
 #-----------------------------#
-  echo "${tab_}${GREEN}Processing... ${L_arrow}final system${R_arrow}"
+  echo "${tab_}${GREEN}Processing... ${L_arrow}final system    ( LUSER ) ${R_arrow}"
 
   for file in final-system/* ; do
@@ -241,16 +245,16 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    LUSER_wrt_target "${this_script}" "$PREV"
     #
     # If $pkg_tarball isn't empty, we've got a package...
     if [ "$pkg_tarball" != "" ] ; then
-      wrt_unpack "$pkg_tarball"
+      LUSER_wrt_unpack "$pkg_tarball"
       # If using optimizations, write the instructions
       [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
     fi
     #
-    wrt_RunAsUser "${this_script}" "${file}"
-    #
-    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
+    LUSER_wrt_RunAsUser "${file}"
+    #
+    [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
     #
     # Include a touch of the target name so make can check if it's already been made.
@@ -271,5 +275,5 @@
 bootscripts_Makefiles() {     #
 #-----------------------------#
-    echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}"
+  echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts     ( LUSER ) ${R_arrow}"
 
   for file in bootscripts/* ; do
@@ -307,12 +311,12 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    LUSER_wrt_target "${this_script}" "$PREV"
     #
     # If $pkg_tarball isn't empty, we've got a package...
-    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
-    #
-    wrt_RunAsUser "${this_script}" "${file}"
-    #
-    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
+    [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
+    #
+    LUSER_wrt_RunAsUser "${file}"
+    #
+    [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
     #
     # Include a touch of the target name so make can check if it's already been made.
@@ -334,5 +338,5 @@
 bootable_Makefiles() {        #
 #-----------------------------#
-  echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}"
+  echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable   ( LUSER ) ${R_arrow}"
 
   for file in bootable/* ; do
@@ -343,4 +347,5 @@
     case $this_script in
       *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* )  continue ;;
+      *fstab)  [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
       *kernel) # if there is no kernel config file do not build the kernel
                [[ -z $CONFIG ]] && continue
@@ -352,5 +357,10 @@
     # First append each name of the script files to a list (this will become
     # the names of the targets in the Makefile
-    bootable="$bootable $this_script"
+    # NOTE: new makfile format forces the last script, *chowning, into a separate
+    #  phase.
+    case ${this_script} in
+      *chowning) chowning=${this_script}   ;;
+              *) bootable="$bootable $this_script"  ;;
+    esac
     #
     # Grab the name of the target, strip id number and misc words.
@@ -369,25 +379,25 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    LUSER_wrt_target "${this_script}" "$PREV"
     #
     # If $pkg_tarball isn't empty, we've got a package...
-    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
+    [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
     #
     # Select a script execution method
     case $this_script in
       *fstab*)  if [[ -n "$FSTAB" ]]; then
-                  wrt_copy_fstab "${this_script}"
+                  LUSER_wrt_CopyFstab
                 else
-                  wrt_RunAsUser "${this_script}" "${file}"
+                  LUSER_wrt_RunAsUser "${file}"
                 fi
           ;;
       *chowning)  wrt_RunAsRoot "${this_script}" "${file}"
           ;;
-              *)  wrt_RunAsUser "${this_script}" "${file}"
+              *)  LUSER_wrt_RunAsUser "${file}"
           ;;
     esac
     #
     # Housekeeping...remove any build directory(ies) except if the package build fails.
-    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
+    [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
     #
     # Include a touch of the target name so make can check if it's already been made.
@@ -402,7 +412,4 @@
 
   done
-
-  # Add SBU-disk_usage report target if required
-  if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
 
 }
@@ -447,4 +454,6 @@
 LUSER_HOME = /home/\$(LUSER)
 
+export PATH := \${PATH}:/usr/sbin
+
 include makefile-functions
 
@@ -455,25 +464,42 @@
   # as a dependency.
 (
-	cat << EOF
-all:  chapter2 chapter3 chapter4 chapter5 chapter6 restore-luser-env do-housekeeping
+cat << EOF
+
+all:	ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report
+	@sudo make do-housekeeping
 	@\$(call echo_finished,$VERSION)
 
-chapter2:  023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile
-
-chapter3:  chapter2 $cross_tools
-
-chapter4:  chapter3 $basicsystem
-
-chapter5:  chapter4 $bootscripttools
-
-chapter6:  chapter5 $bootable
-
-clean-all:  clean
-	rm -rf ./{clfs2-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
-
-clean:
+ck_UID:
+	@if [ \`id -u\` = "0" ]; then \\
+	  echo "--------------------------------------------------"; \\
+	  echo "You cannot run this makefile from the root account"; \\
+	  echo "--------------------------------------------------"; \\
+	  exit 1; \\
+	fi
+
+mk_SETUP:
+	@\$(call echo_SU_request)
+	@sudo make SETUP
+	@touch \$@
+
+mk_LUSER: mk_SETUP
+	@\$(call echo_SULUSER_request)
+	@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
+	@sudo make restore-luser-env
+	@touch \$@
+
+mk_ROOT:
+	@sudo make ROOT
+	@touch \$@
+
+SETUP:  $host_prep
+
+LUSER:	$cross_tools $basicsystem $bootscripttools $bootable
+
+ROOT:	$chowning
+
 
 restart:
-	@echo "This feature does not exist for the CLFS makefile. (yet)"
+	@echo "This feature does not exist for the CLFS-2 makefile. (yet)"
 
 restore-luser-env:
@@ -499,4 +525,19 @@
 ) >> $MKFILE
 
+  # Add SBU-disk_usage report target
+  echo "create-sbu_du-report:" >> $MKFILE
+  if [[ "$REPORT" = "y" ]] ; then
+(
+    cat << EOF
+	@\$(call echo_message, Building)
+	@./create-sbu_du-report.sh logs $VERSION
+	@\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
+	@touch  \$@
+
+
+EOF
+) >> $MKFILE
+  else echo -e "\t@true\n\n" >> $MKFILE; fi
+
   # Bring over the items from the Makefile.tmp
   cat $MKFILE.tmp >> $MKFILE
