Added --rebuild switch.

This commit is contained in:
Manuel Canales Esparcia 2005-11-23 21:55:01 +00:00
parent 5adc3fdb2e
commit da5860a6c8

49
jhalfs
View file

@ -27,6 +27,11 @@ Options:
jhalfs produces will be in the directory jhalfs produces will be in the directory
DIR/jhalfs. Default is \"/mnt/lfs\". 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 -P, --get-packages download the packages and patches. This
assumes that the server declared in the assumes that the server declared in the
jhalfs.conf file has the proper packages jhalfs.conf file has the proper packages
@ -113,6 +118,31 @@ HEADER="# This file is automatically generated by jhalfs
################################### ###################################
#----------------------------#
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() { get_book() {
#----------------------------# #----------------------------#
@ -962,6 +992,8 @@ while test $# -gt 0 ; do
MKFILE=$JHALFSDIR/Makefile MKFILE=$JHALFSDIR/Makefile
;; ;;
--rebuild ) CLEAN=1 ;;
--download-client | -D ) --download-client | -D )
test $# = 1 && eval "$exit_missing_arg" test $# = 1 && eval "$exit_missing_arg"
shift shift
@ -1050,14 +1082,23 @@ while test $# -gt 0 ; do
shift shift
done done
# If $BUILDDIR have subdirectories like tools/ or bin/, stop the run # Prevents setting "-d /" by mistake.
# and notify the user about that. This also prevents setting "-d /"
# by mistake.
if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] ; then 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.
if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
eval "$no_empty_builddir" eval "$no_empty_builddir"
fi fi
# If requested, clean the build directory
clean_builddir
# Find the download client to use, if not already specified. # Find the download client to use, if not already specified.
if [ -z $DL ] ; then if [ -z $DL ] ; then