r2204 - jhalfs/trunk

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Wed Nov 23 13:55:01 PST 2005


Author: manuel
Date: 2005-11-23 14:55:01 -0700 (Wed, 23 Nov 2005)
New Revision: 2204

Modified:
   jhalfs/trunk/jhalfs
Log:
Added --rebuild switch.

Modified: jhalfs/trunk/jhalfs
===================================================================
--- jhalfs/trunk/jhalfs	2005-11-23 20:26:36 UTC (rev 2203)
+++ jhalfs/trunk/jhalfs	2005-11-23 21:55:01 UTC (rev 2204)
@@ -27,6 +27,11 @@
                                 jhalfs produces will be in the directory
                                 DIR/jhalfs. Default is \"/mnt/lfs\".
 
+  --rebuild                     clean the build directory before to perfom
+                                any other task. The directory is cleaned
+                                only if it was populated by a previous
+                                jhalfs run.
+
   -P, --get-packages            download the packages and patches. This
                                 assumes that the server declared in the 
                                 jhalfs.conf file has the proper packages
@@ -114,6 +119,31 @@
 
 
 #----------------------------#
+clean_builddir() {
+#----------------------------#
+  # Test if the clean must be done.
+  if [ "$CLEAN" = "1" ] ; then
+    # Test to make sure we're running the clean as root
+    if [ "$UID" != "0" ] ; then
+      echo "You must be logged in as root to clean the build directory."
+      exit 1
+    fi
+    # Test to make sure that the build directory was populated by jhalfs
+    if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
+      echo "Look like $BUILDDIR was not populated by a previous jhalfs run."
+      exit 1
+    else
+      # Clean the build directory
+      echo -ne "Cleaning $BUILDDIR...\n"
+      rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
+      echo -ne "Cleaning $JHALFSDIR...\n"
+      rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
+      echo -ne "done\n"
+    fi
+  fi
+}
+
+#----------------------------#
 get_book() {
 #----------------------------#
   # Check for Subversion instead of just letting the script hit 'svn' and fail.
@@ -962,6 +992,8 @@
       MKFILE=$JHALFSDIR/Makefile
       ;;
 
+    --rebuild )	  CLEAN=1 ;;
+
     --download-client | -D )
       test $# = 1 && eval "$exit_missing_arg"
       shift
@@ -1050,14 +1082,23 @@
   shift
 done
 
+# Prevents setting "-d /" by mistake. 
+
+if [ $BUILDDIR = / ] ; then
+  echo -ne "\nThe root directory can't be used to build LFS.\n\n"
+  exit 1
+fi
+
 # If $BUILDDIR have subdirectories like tools/ or bin/, stop the run
-# and notify the user about that. This also prevents setting "-d /"
-# by mistake.
+# and notify the user about that. 
 
-if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] ; then
+if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
   eval "$no_empty_builddir"
 fi
 
+# If requested, clean the build directory
+clean_builddir
+
 # Find the download client to use, if not already specified.
 
 if [ -z $DL ] ; then




More information about the alfs-log mailing list