Index: common/common-functions
===================================================================
--- common/common-functions	(revision 34933b4610217e872389c718de167bfcbccd9faa)
+++ common/common-functions	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
@@ -58,5 +58,5 @@
 ${BOLD}  -D  --directory DIR${OFF}
         use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs-X produces
-        will be in the directory DIR/jhalfs.
+        will be in the directory DIR/${SCRIPT_ROOT}.
         The current setting for BUILDDIR is "$BUILDDIR"
 
@@ -202,8 +202,45 @@
 $i:  $PREV
 	@\$(call echo_message, Building)
-	@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$LOGFILE
-EOF
-) >> $MKFILE.tmp
-}
+	@./progress_bar.sh \$@ &
+	@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE
+EOF
+) >> $MKFILE.tmp
+}
+
+
+#----------------------------------#
+wrt_remove_existing_dirs() {       #
+#----------------------------------#
+  local PKG_NAME=$1
+(
+cat << EOF
+	@PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\
+	ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
+	[[ -n \$\$ROOT ]] && \\
+	rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
+	if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build ]; then \\
+		rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build; \\
+	fi;
+EOF
+) >> $MKFILE.tmp
+}
+
+#----------------------------------#
+wrt_remove_existing_dirs2() {      #
+#----------------------------------#
+  local PKG_NAME=$1
+(
+cat << EOF
+	@PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\
+	ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
+	[[ -n \$\$ROOT ]] && \\
+	rm -rf \$(SRC)/\$\$ROOT && \\
+	if [ -e \$(SRC)/${PKG_NAME%%-*}-build ]; then \\
+		rm -rf \$(SRC)/${PKG_NAME%%-*}-build; \\
+	fi;
+EOF
+) >> $MKFILE.tmp
+}
+
 
 
@@ -212,8 +249,13 @@
 #----------------------------------#
   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 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
+	@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
@@ -227,8 +269,13 @@
 #----------------------------------#
   local FILE=$1
+  local optSAVE_PREVIOUS=$2
+
+  if [ "${optSAVE_PREVIOUS}" != "1" ]; then
+    wrt_remove_existing_dirs "$FILE"
+  fi
 (
 cat  << EOF
 	@\$(call unpack2,$FILE)
-	@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
+	@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
 	echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
 EOF
@@ -241,13 +288,17 @@
 #----------------------------------#
   local FILE=$1
+  local optSAVE_PREVIOUS=$2
+
+  if [ "${optSAVE_PREVIOUS}" != "1" ]; then
+    wrt_remove_existing_dirs2 "$FILE"
+  fi
 (
 cat  << EOF
 	@\$(call unpack3,$FILE)
-	@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
+	@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
 	echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
 EOF
 ) >> $MKFILE.tmp
 }
-
 
 #----------------------------------#
@@ -272,5 +323,5 @@
 cat << EOF
 	@( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
-	echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
+	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
 EOF
 ) >> $MKFILE.tmp
@@ -286,5 +337,5 @@
 cat << EOF
 	@( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
-	echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
+	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
 EOF
 ) >> $MKFILE.tmp
@@ -300,5 +351,5 @@
 cat << EOF
 	@( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
-	echo -e "\nKB: \`du -skx --exclude=jhalfs \`\n" >>logs/$this_script
+	echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
 EOF
 ) >> $MKFILE.tmp
@@ -314,6 +365,6 @@
 (
     cat << EOF
-	@( time { \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
-	echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
+	@( time { \$(CHROOT1) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/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
@@ -328,6 +379,6 @@
 (
 cat << EOF
-	@( time { \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
-	echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
+	@( time { \$(CHROOT2) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/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
@@ -364,5 +415,5 @@
 (
 cat << EOF
-	@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
+	@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
 	rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
 	if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
@@ -380,5 +431,5 @@
 (
 cat << EOF
-	@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
+	@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
 	rm -r \$(SRC)/\$\$ROOT && \\
 	if [ -e \$(SRC)/$name-build ]; then \\
Index: common/config
===================================================================
--- common/config	(revision 34933b4610217e872389c718de167bfcbccd9faa)
+++ common/config	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
@@ -89,6 +89,10 @@
 
 #--- Working directories
-JHALFSDIR=$BUILDDIR/jhalfs
+SCRIPT_ROOT=jhalfs
+JHALFSDIR=$BUILDDIR/$SCRIPT_ROOT
    LOGDIR=$JHALFSDIR/logs
+
+#--- File listing package contents (from where package sources dir is extracted)
+PKG_LST=unpacked
 
 #--- ICA report log directory
Index: common/func_compare.sh
===================================================================
--- common/func_compare.sh	(revision 34933b4610217e872389c718de167bfcbccd9faa)
+++ common/func_compare.sh	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
@@ -44,15 +44,15 @@
   local ITERATION=$1
   local   PREV_IT=$2
-  local PRUNEPATH="/dev /home /jhalfs /lost+found /media /mnt /opt /proc \
+  local PRUNEPATH="/dev /home /${SCRIPT_ROOT} /lost+found /media /mnt /opt /proc \
 /sources /root /srv /sys /tmp /tools /usr/local /usr/src /var/log/paco"
 
   if [[ "$PROGNAME" = "clfs" ]] && [[ "$METHOD" = "boot" ]] ; then
     local    ROOT_DIR=/
-    local DEST_TOPDIR=/jhalfs
-    local   ICALOGDIR=/jhalfs/logs/ICA
-    local FARCELOGDIR=/jhalfs/logs/farce
+    local DEST_TOPDIR=/${SCRIPT_ROOT}
+    local   ICALOGDIR=/${SCRIPT_ROOT}/logs/ICA
+    local FARCELOGDIR=/${SCRIPT_ROOT}/logs/farce
   else
     local    ROOT_DIR=$BUILDDIR
-    local DEST_TOPDIR=$BUILDDIR/jhalfs
+    local DEST_TOPDIR=$BUILDDIR/${SCRIPT_ROOT}
   fi
 
Index: common/makefile-functions
===================================================================
--- common/makefile-functions	(revision 34933b4610217e872389c718de167bfcbccd9faa)
+++ common/makefile-functions	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
@@ -18,15 +18,15 @@
 define unpack
   @cd $(MOUNT_PT)$(SRC) && \
-  tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked
+  tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST)
 endef
 
 define unpack2
   @cd $(MOUNT_PT)$(SRC) && \
-  /tools/bin/tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked
+  /tools/bin/tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST)
 endef
 
 define unpack3
   @cd $(SRC) && \
-  tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked
+  tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST)
 endef
 
Index: common/progress_bar.sh
===================================================================
--- common/progress_bar.sh	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
+++ common/progress_bar.sh	(revision 460ea6306b0a8ace7ef8d19264c4cb7385c383ff)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# $Id$
+
+set -e
+
+[[ -z $1 ]] && exit
+
+if [ ! -f $1 ] ; then
+  while fuser -v . 2>&1 | grep make >/dev/null ; do
+    echo -n "."
+    sleep 1
+    [[ -f $1 ]] && exit
+  done
+fi
