2006-03-07 21:02:53 +01:00
|
|
|
#!/bin/bash
|
2006-03-10 02:44:55 +01:00
|
|
|
# $Id$
|
2006-03-07 21:02:53 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
|
|
|
#-----------------------#
|
|
|
|
simple_error() { # Basic error trap.... JUST DIE
|
|
|
|
#-----------------------#
|
|
|
|
# If +e then disable text output
|
|
|
|
if [[ "$-" =~ "e" ]]; then
|
|
|
|
echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
see_ya() {
|
2006-03-26 16:12:55 +02:00
|
|
|
echo -e "\n\t${BOLD}Goodbye and thank you for choosing ${L_arrow}JHALFS-X${R_arrow}\n"
|
2006-03-07 21:02:53 +01:00
|
|
|
}
|
|
|
|
##### Simple error TRAPS
|
|
|
|
# ctrl-c SIGINT
|
|
|
|
# ctrl-y
|
|
|
|
# ctrl-z SIGTSTP
|
|
|
|
# SIGHUP 1 HANGUP
|
|
|
|
# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
|
|
|
# SIGQUIT 3
|
|
|
|
# SIGKILL 9 KILL
|
|
|
|
# SIGTERM 15 TERMINATION
|
|
|
|
# SIGSTOP 17,18,23 STOP THE PROCESS
|
|
|
|
#####
|
|
|
|
set -e
|
|
|
|
trap see_ya 0
|
|
|
|
trap simple_error ERR
|
|
|
|
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
|
|
|
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -L $0 ] ; then
|
|
|
|
echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-03-10 02:44:55 +01:00
|
|
|
PROGNAME=$(basename $0)
|
|
|
|
COMMON_DIR="common"
|
|
|
|
PACKAGE_DIR=$(echo $PROGNAME | tr [a-z] [A-Z])
|
|
|
|
MODULE=$PACKAGE_DIR/master.sh
|
|
|
|
MODULE_CONFIG=$PACKAGE_DIR/config
|
|
|
|
|
|
|
|
echo -n "Loading common-functions module..."
|
|
|
|
source $COMMON_DIR/common-functions
|
|
|
|
[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
|
|
|
|
echo "OK"
|
|
|
|
#
|
|
|
|
|
|
|
|
echo -n "Loading masterscript conf..."
|
|
|
|
source $COMMON_DIR/config
|
2006-03-12 12:28:15 +01:00
|
|
|
[[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
|
2006-03-07 21:02:53 +01:00
|
|
|
echo "OK"
|
|
|
|
#
|
|
|
|
echo -n "Loading config module <$MODULE_CONFIG>..."
|
|
|
|
source $MODULE_CONFIG
|
|
|
|
[[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
|
|
|
|
echo "OK"
|
|
|
|
#
|
|
|
|
echo -n "Loading code module <$MODULE>..."
|
|
|
|
source $MODULE
|
2006-03-10 02:44:55 +01:00
|
|
|
[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
|
2006-03-07 21:02:53 +01:00
|
|
|
echo "OK"
|
|
|
|
#
|
|
|
|
echo "---------------${nl_}"
|
|
|
|
|
|
|
|
|
|
|
|
#===========================================================
|
|
|
|
# If the var BOOK contains something then, maybe, it points
|
|
|
|
# to a working doc.. set WC=1, else 'null'
|
|
|
|
#===========================================================
|
|
|
|
WC=${BOOK:+1}
|
|
|
|
#===========================================================
|
|
|
|
|
|
|
|
|
|
|
|
#*******************************************************************#
|
2006-03-10 02:44:55 +01:00
|
|
|
echo -n "Loading function <func_check_version.sh>..."
|
|
|
|
source $COMMON_DIR/func_check_version.sh
|
|
|
|
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
|
|
|
echo "OK"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
2006-03-10 02:44:55 +01:00
|
|
|
echo -n "Loading function <func_validate_configs.sh>..."
|
|
|
|
source $COMMON_DIR/func_validate_configs.sh
|
|
|
|
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
|
|
|
echo "OK"
|
|
|
|
echo "---------------${nl_}"
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
###################################
|
|
|
|
### MAIN ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
# Evaluate any command line switches
|
|
|
|
|
|
|
|
while test $# -gt 0 ; do
|
|
|
|
case $1 in
|
|
|
|
--version | -V )
|
|
|
|
clear
|
|
|
|
echo "$version"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--help | -h )
|
|
|
|
if [[ "$PROGNAME" = "blfs" ]]; then
|
|
|
|
blfs_usage
|
|
|
|
else
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--LFS-version | -L )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
case $1 in
|
|
|
|
dev* | SVN | trunk )
|
|
|
|
LFSVRS=development
|
|
|
|
;;
|
2006-03-26 16:12:55 +02:00
|
|
|
*) if [[ "$PROGNAME" = "lfs" ]]; then
|
|
|
|
case $1 in
|
|
|
|
6.1.1 )
|
|
|
|
echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
alpha*) LFSVRS=alphabetical ;;
|
|
|
|
udev*) LFSVRS=udev_update ;;
|
|
|
|
* ) echo "$1 is an unsupported version at this time." ;;
|
|
|
|
esac
|
|
|
|
else
|
2006-03-26 16:28:00 +02:00
|
|
|
echo "The requested version, ${L_arrow} ${BOLD}$1${OFF} ${R_arrow}, is undefined in the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} series."
|
2006-03-26 16:12:55 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
2006-03-07 21:02:53 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
--directory | -d )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
BUILDDIR=$1
|
|
|
|
JHALFSDIR=$BUILDDIR/jhalfs
|
|
|
|
LOGDIR=$JHALFSDIR/logs
|
2006-03-27 19:35:46 +02:00
|
|
|
MKFILE=$JHALFSDIR/Makefile
|
2006-03-07 21:02:53 +01:00
|
|
|
;;
|
|
|
|
|
2006-03-26 16:12:55 +02:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
--download-client | -D )
|
|
|
|
echo "The download feature is temporarily disable.."
|
|
|
|
exit
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
DL=$1
|
|
|
|
;;
|
|
|
|
|
|
|
|
--working-copy | -W )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1/patches.ent ] ; then
|
2006-03-26 16:12:55 +02:00
|
|
|
WC=1
|
|
|
|
BOOK=$1
|
2006-03-07 21:02:53 +01:00
|
|
|
else
|
|
|
|
echo -e "\nLook like $1 isn't a supported working copy."
|
|
|
|
echo -e "Verify your selection and the command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2006-03-16 19:50:00 +01:00
|
|
|
--testsuites | -T )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
case $1 in
|
|
|
|
0 | 1 | 2 | 3 )
|
|
|
|
TEST=$1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo -e "\n$1 isn't a valid testsuites level value."
|
|
|
|
echo -e "You must to use 0, 1, 2, or 3.\n"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
2006-03-26 16:12:55 +02:00
|
|
|
--get-packages | -P ) HPKG=1 ;;
|
|
|
|
--run-make | -M ) RUNMAKE=1 ;;
|
|
|
|
--no-strip ) STRIP=0 ;;
|
|
|
|
--no-vim-lang ) VIMLANG=0 ;;
|
2006-03-27 19:35:46 +02:00
|
|
|
--rebuild ) CLEAN=1 ;;
|
2006-03-07 21:02:53 +01:00
|
|
|
|
|
|
|
--page_size )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
case $1 in
|
|
|
|
letter | A4 )
|
|
|
|
PAGE=$1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "$1 isn't a supported page size."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
--timezone )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f /usr/share/zoneinfo/$1 ] ; then
|
|
|
|
TIMEZONE=$1
|
|
|
|
else
|
|
|
|
echo -e "\nLooks like $1 isn't a valid timezone description."
|
|
|
|
echo -e "Verify your selection and the command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--fstab )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
FSTAB=$1
|
|
|
|
else
|
|
|
|
echo -e "\nFile $1 not found. Verify your command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--kernel-config | -C )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
CONFIG=$1
|
|
|
|
else
|
|
|
|
echo -e "\nFile $1 not found. Verify your command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
if [[ "$PROGNAME" = "blfs" ]]; then
|
|
|
|
blfs_usage
|
|
|
|
else
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Find the download client to use, if not already specified.
|
|
|
|
|
|
|
|
if [ -z $DL ] ; then
|
|
|
|
if [ `type -p wget` ] ; then
|
|
|
|
DL=wget
|
|
|
|
elif [ `type -p curl` ] ; then
|
|
|
|
DL=curl
|
|
|
|
else
|
|
|
|
eval "$no_dl_client"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#===================================================
|
|
|
|
# Set the document location...
|
2006-03-12 12:28:15 +01:00
|
|
|
# BOOK is either defined in
|
2006-03-07 21:02:53 +01:00
|
|
|
# xxx.config
|
|
|
|
# comand line
|
2006-03-12 12:28:15 +01:00
|
|
|
# default
|
2006-03-26 16:12:55 +02:00
|
|
|
# If set by conf file or cmd line leave it
|
2006-03-07 21:02:53 +01:00
|
|
|
# alone otherwise load the default version
|
|
|
|
#===================================================
|
|
|
|
BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
|
|
|
#===================================================
|
|
|
|
|
2006-03-12 12:28:15 +01:00
|
|
|
|
|
|
|
# Check for minumum gcc and kernel versions
|
|
|
|
#check_requirements 1 # 0/1 0-do not display values.
|
|
|
|
check_version "2.6.2" "`uname -r`" "KERNEL"
|
|
|
|
check_version "3.0" "$BASH_VERSION" "BASH"
|
|
|
|
check_version "3.0" "`gcc -dumpversion`" "GCC"
|
2006-03-15 22:50:40 +01:00
|
|
|
tarVer=`tar --version`
|
|
|
|
check_version "1.15.0" "${tarVer##* }" "TAR"
|
2006-03-12 12:28:15 +01:00
|
|
|
echo "---------------${nl_}"
|
|
|
|
|
|
|
|
validate_config 1 # 0/1 0-do not display values
|
|
|
|
echo "---------------${nl_}"
|
|
|
|
|
2006-03-14 22:09:06 +01:00
|
|
|
echo -n "Are you happy with that settings? yes/no (no): "
|
2006-03-12 12:28:15 +01:00
|
|
|
read ANSWER
|
|
|
|
if [ x$ANSWER != "xyes" ] ; then
|
|
|
|
echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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 has 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"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If requested, clean the build directory
|
|
|
|
clean_builddir
|
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
if [[ ! -d $JHALFSDIR ]]; then
|
|
|
|
mkdir -pv $JHALFSDIR
|
|
|
|
fi
|
|
|
|
|
2006-03-12 12:28:15 +01:00
|
|
|
if [[ "$PWD" != "$JHALFSDIR" ]]; then
|
2006-03-10 02:44:55 +01:00
|
|
|
cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
|
2006-03-07 21:02:53 +01:00
|
|
|
if [[ -n "$FILES" ]]; then
|
2006-03-21 00:07:53 +01:00
|
|
|
# pushd/popd necessary to deal with mulitiple files
|
|
|
|
pushd $PACKAGE_DIR
|
|
|
|
cp -v $FILES $JHALFSDIR/
|
|
|
|
popd
|
2006-03-07 21:02:53 +01:00
|
|
|
fi
|
2006-03-10 02:44:55 +01:00
|
|
|
sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
|
2006-03-07 21:02:53 +01:00
|
|
|
export XSL=$JHALFSDIR/${XSL}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d $LOGDIR ]]; then
|
|
|
|
mkdir -v $LOGDIR
|
|
|
|
fi
|
|
|
|
>$LOGDIR/$LOG
|
|
|
|
echo "---------------${nl_}"
|
|
|
|
|
|
|
|
get_book
|
|
|
|
echo "---------------${nl_}"
|
2006-03-10 02:44:55 +01:00
|
|
|
|
2006-03-07 21:02:53 +01:00
|
|
|
build_Makefile
|
|
|
|
echo "---------------${nl_}"
|
2006-03-10 02:44:55 +01:00
|
|
|
|
2006-03-21 02:03:35 +01:00
|
|
|
run_make
|
2006-03-07 21:02:53 +01:00
|
|
|
|