From a5e3400f3a2a4c3a0e441ddfddaab532e1f2b90a Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Sun, 18 Feb 2007 12:37:10 +0000 Subject: [PATCH] Fixed clean_buildir function to handle properly dev, proc, and sys directories. --- common/common-functions | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/common/common-functions b/common/common-functions index c97eff3..9e08f1c 100644 --- a/common/common-functions +++ b/common/common-functions @@ -12,7 +12,7 @@ ${DD_BORDER} ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF} Looks like the \$BUILDDIR directory contains subdirectories - from a previous HLFS build. + from a previous build. Please format the partition mounted on \$BUILDDIR or set a different build directory before running jhalfs. @@ -52,10 +52,22 @@ clean_builddir() { # if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then echo "Looks like $BUILDDIR was not populated by a previous jhalfs run." exit 1 + # Test that dev filesystems are not mounted in $BUILDDIR + elif mount | grep $BUILDDIR/dev > /dev/null ; then + echo "Looks like kernel fylesystems are yet mounted on $BUILDDIR." + exit 1 else # Clean the build directory echo -n "Cleaning $BUILDDIR ..." - sudo rm -rf $BUILDDIR/{bin,boot,etc,home,lib,media,mnt,opt,root,sbin,srv,tmp,tools,cross-tools,usr,var} + # First delete proc and sys directories, if exit. + # Both should be empty, if not be sure to exit. + if [ -d $BUILDDIR/proc ] ; then + sudo rmdir $BUILDDIR/proc || exit 1 + fi + if [ -d $BUILDDIR/sys ] ; then + sudo rmdir $BUILDDIR/sys || exit 1 + fi + sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,root,sbin,srv,tmp,tools,cross-tools,usr,var} echo "done" echo -n "Cleaning $JHALFSDIR ..." sudo rm -rf $JHALFSDIR