Index: common/common-functions
===================================================================
--- common/common-functions	(revision 05ccaa98626df60d7d7ac0b979ddee1fe688d352)
+++ common/common-functions	(revision 9357c13af58c9f3d1d00b77bdbaae7fa3d3919ab)
@@ -242,6 +242,7 @@
    #
    case $script_name in
-     tcl)   echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
-     *)     echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
+     tcl)           echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
+     linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
+     *)             echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
    esac
 
@@ -298,25 +299,5 @@
 	@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
 	echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
-	chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
-EOF
-) >> $MKFILE.tmp
-}
-
-
-#----------------------------------#
-wrt_unpack_clfs() {                # Unpack and set 'ROOT' var
-#----------------------------------#
-  local FILE=$1
-  local optSAVE_PREVIOUS=$2
-
-  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 clfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
+	chown -R \$(LUSER) \$(MOUNT_PT)\$(SRC)/\$\$ROOT
 EOF
 ) >> $MKFILE.tmp
@@ -368,5 +349,5 @@
 cat  << EOF
 	@echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
-	su - lfs -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
+	su - \$(LUSER) -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
 EOF
 ) >> $MKFILE.tmp
@@ -399,5 +380,5 @@
 
 #----------------------------------#
-wrt_run_as_su() {                  # Execute script inside time { }, footer to log file
+wrt_RunAsUser() {                  # Execute script inside time { }, footer to log file
 #----------------------------------#
   local this_script=$1
@@ -405,5 +386,5 @@
 (
 cat << EOF
-	@( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
+	@( time { su - \$(LUSER) -c "source /home/\$(LUSER)/.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
@@ -413,11 +394,22 @@
 
 #----------------------------------#
-wrt_run_as_root() {                # Some scripts must be run as root..
-#----------------------------------#
+wrt_RunAsRoot() {                  # Some scripts must be run as root..
+#----------------------------------#
+  local ENV_MOUNT
   local this_script=$1
   local file=$2
-(
-cat << EOF
-	@( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
+
+  case ${PROGNAME} in
+    lfs   ) MOUNT_ENV="LFS" ;;
+    blfs  ) MOUNT_ENV="BLFS" ;;
+    clfs  ) MOUNT_ENV="CLFS" ;;
+    clfs2 ) MOUNT_ENV="CLFS" ;;
+    hlfs  ) MOUNT_ENV="HLFS" ;;
+    *) echo "undefined progname $PROGNAME"; exit 1
+  esac
+
+(
+cat << EOF
+	@( time { export ${MOUNT_ENV}=\$(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
@@ -427,5 +419,5 @@
 
 #----------------------------------#
-wrt_run_as_clfs_su() {             # Execute script inside time { }, footer to log file
+wrt_run_as_root2() {               #
 #----------------------------------#
   local this_script=$1
@@ -433,32 +425,4 @@
 (
 cat << EOF
-	@( time { su - clfs -c "source /home/clfs/.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_run_as_clfs_root() {           # Some scripts must be run as root..
-#----------------------------------#
-  local this_script=$1
-  local file=$2
-(
-cat << EOF
-	@( time { export CLFS=\$(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
-}
-
-
-#----------------------------------#
-wrt_run_as_root2() {               #
-#----------------------------------#
-  local this_script=$1
-  local file=$2
-(
-cat << EOF
 	@( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
 	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
@@ -466,5 +430,4 @@
 ) >> $MKFILE.tmp
 }
-
 
 
@@ -527,7 +490,7 @@
 cat << EOF
 	@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
-	rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
+	rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
 	if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
-		rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
+		rm -rf \$(MOUNT_PT)\$(SRC)/$name-build; \\
 	fi;
 EOF
@@ -543,7 +506,7 @@
 cat << EOF
 	@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
-	rm -r \$(SRC)/\$\$ROOT && \\
+	rm -rf \$(SRC)/\$\$ROOT && \\
 	if [ -e \$(SRC)/$name-build ]; then \\
-		rm -r \$(SRC)/$name-build; \\
+		rm -rf \$(SRC)/$name-build; \\
 	fi;
 EOF
