#!/bin/bash # $Id$ set -e # From common/common-functions # VT100 colors declare -r BLACK=$'\e[1;30m' declare -r DK_GRAY=$'\e[0;30m' declare -r RED=$'\e[31m' declare -r GREEN=$'\e[32m' declare -r YELLOW=$'\e[33m' declare -r BLUE=$'\e[34m' declare -r MAGENTA=$'\e[35m' declare -r CYAN=$'\e[36m' declare -r WHITE=$'\e[37m' declare -r OFF=$'\e[0m' declare -r BOLD=$'\e[1m' declare -r REVERSE=$'\e[7m' declare -r HIDDEN=$'\e[8m' declare -r tab_=$'\t' declare -r nl_=$'\n' declare -r DD_BORDER="${BOLD}==============================================================================${OFF}" declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}" declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}" # bold yellow > < pair declare -r R_arrow=$'\e[1;33m>\e[0m' declare -r L_arrow=$'\e[1;33m<\e[0m' #>>>>>>>>>>>>>>>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() { echo -e "\n${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\n" } ##### 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 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # envars not sourced from configuration file PROGNAME=$(basename $0) COMMON_DIR="common" VERBOSITY=1 [[ $VERBOSITY > 0 ]] && echo -n "Loading config params from ..." source configuration [[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1 [[ $VERBOSITY > 0 ]] && echo "OK" [[ $VERBOSITY > 0 ]] && echo -n "Loading function ..." source $COMMON_DIR/func_validate_configs.sh [[ $? > 0 ]] && echo " function module did not load.." && exit 2 [[ $VERBOSITY > 0 ]] && echo "OK" [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}" # Be sure that we have a configuration file [[ -z $BOOK_BLFS ]] && echo -e "\nNo BLFS configuration found. Please configure it." && exit 1 # Set default book version BRANCH_ID=${BRANCH_ID:=development} # Set the SVN tree case $BRANCH_ID in dev* | SVN | trunk ) TREE=trunk/BOOK ;; *EDIT* ) echo " You forgot to set the branch or stable book version." echo " Please rerun make and fix the configuration." exit 2 ;; branch-* ) TREE=branches/${BRANCH_ID#branch-}/BOOK ;; * ) TREE=tags/${BRANCH_ID}/BOOK ;; esac # For consistency with other books validate_config echo "${SD_BORDER}${nl_}" echo -n "Are you happy with these settings? yes/no (no): " read ANSWER if [ x$ANSWER != "xyes" ] ; then echo "${nl_}Fix the configuration options and rerun the script.${nl_}" exit 1 fi echo "${nl_}${SD_BORDER}${nl_}" # Install the files [[ ! -d $BLFS_ROOT ]] && mkdir -p $BLFS_ROOT cp -r BLFS/* $BLFS_ROOT cp -r menu $BLFS_ROOT cp $COMMON_DIR/progress_bar.sh $BLFS_ROOT cp README.BLFS $BLFS_ROOT # Start the work cd $BLFS_ROOT # Clean-up rm -rf libs/.svn rm -rf menu/.svn rm -rf menu/lxdialog/.svn # Set some harcoded values to the proper values sed -i 's,blfs-xml,'$BLFS_XML',' update_book.sh libs/book.xsl #sed -i 's,blfs-xml,'$BLFS_XML',' libs/book.xsl sed -i 's,tracking-dir,'$TRACKING_DIR',' gen_config.sh # Fetch book sources and create packages and GNOME/KDE dependencies files if [[ -d $BLFS_XML ]] ; then ./update_book.sh else ./update_book.sh $BLFS_XML get $TREE fi # Generate Config.in and run the menuconfig interface ./gen_config.sh # make