[8419a04] | 1 | #!/bin/bash
|
---|
[d3ce173] | 2 | # $Id$
|
---|
| 3 |
|
---|
[8419a04] | 4 | set -e
|
---|
| 5 |
|
---|
[c59f9a0] | 6 | # From common/common-functions
|
---|
| 7 | # VT100 colors
|
---|
| 8 | declare -r BLACK=$'\e[1;30m'
|
---|
| 9 | declare -r DK_GRAY=$'\e[0;30m'
|
---|
| 10 |
|
---|
| 11 | declare -r RED=$'\e[31m'
|
---|
| 12 | declare -r GREEN=$'\e[32m'
|
---|
| 13 | declare -r YELLOW=$'\e[33m'
|
---|
| 14 | declare -r BLUE=$'\e[34m'
|
---|
| 15 | declare -r MAGENTA=$'\e[35m'
|
---|
| 16 | declare -r CYAN=$'\e[36m'
|
---|
| 17 | declare -r WHITE=$'\e[37m'
|
---|
| 18 |
|
---|
| 19 | declare -r OFF=$'\e[0m'
|
---|
| 20 | declare -r BOLD=$'\e[1m'
|
---|
| 21 | declare -r REVERSE=$'\e[7m'
|
---|
| 22 | declare -r HIDDEN=$'\e[8m'
|
---|
| 23 |
|
---|
| 24 | declare -r tab_=$'\t'
|
---|
| 25 | declare -r nl_=$'\n'
|
---|
| 26 |
|
---|
| 27 | declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
---|
| 28 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
| 29 | declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
|
---|
| 30 |
|
---|
| 31 | # bold yellow > < pair
|
---|
| 32 | declare -r R_arrow=$'\e[1;33m>\e[0m'
|
---|
| 33 | declare -r L_arrow=$'\e[1;33m<\e[0m'
|
---|
| 34 |
|
---|
[8419a04] | 35 |
|
---|
[d3ce173] | 36 | #>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
---|
| 37 | #-----------------------#
|
---|
| 38 | simple_error() { # Basic error trap.... JUST DIE
|
---|
| 39 | #-----------------------#
|
---|
| 40 | # If +e then disable text output
|
---|
| 41 | if [[ "$-" =~ "e" ]]; then
|
---|
| 42 | echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
|
---|
| 43 | fi
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | see_ya() {
|
---|
[fff1061] | 47 | echo -e "\n${L_arrow}${BOLD}jhalfs-trunk${R_arrow} exit${OFF}\n"
|
---|
[d3ce173] | 48 | }
|
---|
| 49 | ##### Simple error TRAPS
|
---|
| 50 | # ctrl-c SIGINT
|
---|
| 51 | # ctrl-y
|
---|
| 52 | # ctrl-z SIGTSTP
|
---|
| 53 | # SIGHUP 1 HANGUP
|
---|
| 54 | # SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
---|
| 55 | # SIGQUIT 3
|
---|
| 56 | # SIGKILL 9 KILL
|
---|
| 57 | # SIGTERM 15 TERMINATION
|
---|
| 58 | # SIGSTOP 17,18,23 STOP THE PROCESS
|
---|
| 59 | #####
|
---|
| 60 | set -e
|
---|
| 61 | trap see_ya 0
|
---|
| 62 | trap simple_error ERR
|
---|
| 63 | trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
---|
| 64 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
| 65 |
|
---|
[c59f9a0] | 66 | # envars not sourced from configuration file
|
---|
| 67 | COMMON_DIR="common"
|
---|
[4da2512] | 68 | VERBOSITY=1
|
---|
[d3ce173] | 69 |
|
---|
| 70 | [[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
|
---|
| 71 | source configuration
|
---|
| 72 | [[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
|
---|
| 73 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 74 |
|
---|
[c59f9a0] | 75 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
|
---|
| 76 | source $COMMON_DIR/func_validate_configs.sh
|
---|
| 77 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
| 78 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 79 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
| 80 |
|
---|
| 81 | # Be sure that we have a configuration file
|
---|
[d3ce173] | 82 | [[ -z $BOOK_BLFS ]] && echo -e "\nNo BLFS configuration found. Please configure it." && exit 1
|
---|
| 83 |
|
---|
[c59f9a0] | 84 | # Set default book version
|
---|
| 85 | BRANCH_ID=${BRANCH_ID:=development}
|
---|
| 86 |
|
---|
| 87 | # Set the SVN tree
|
---|
| 88 | case $BRANCH_ID in
|
---|
[4965fa8] | 89 | development ) TREE=trunk/BOOK ;;
|
---|
| 90 | *EDIT* ) echo " You forgot to set the branch or stable book version."
|
---|
| 91 | echo " Please rerun make and fix the configuration."
|
---|
| 92 | exit 2 ;;
|
---|
| 93 | branch-* ) TREE=branches/${BRANCH_ID#branch-}/BOOK ;;
|
---|
| 94 | * ) TREE=tags/${BRANCH_ID}/BOOK ;;
|
---|
[c59f9a0] | 95 | esac
|
---|
[d3ce173] | 96 |
|
---|
[c59f9a0] | 97 | # For consistency with other books
|
---|
| 98 | validate_config
|
---|
| 99 | echo "${SD_BORDER}${nl_}"
|
---|
| 100 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
| 101 | read ANSWER
|
---|
| 102 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 103 | echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
---|
| 104 | exit 1
|
---|
[d3ce173] | 105 | fi
|
---|
[c59f9a0] | 106 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
[d3ce173] | 107 |
|
---|
[c59f9a0] | 108 | # Install the files
|
---|
[d3ce173] | 109 | [[ ! -d $BLFS_ROOT ]] && mkdir -p $BLFS_ROOT
|
---|
| 110 |
|
---|
| 111 | cp -r BLFS/* $BLFS_ROOT
|
---|
[f4ed135] | 112 | cp -r menu $BLFS_ROOT
|
---|
[c59f9a0] | 113 | cp $COMMON_DIR/progress_bar.sh $BLFS_ROOT
|
---|
[f4ed135] | 114 | cp README.BLFS $BLFS_ROOT
|
---|
[d3ce173] | 115 |
|
---|
[c59f9a0] | 116 | # Start the work
|
---|
[d3ce173] | 117 | cd $BLFS_ROOT
|
---|
| 118 |
|
---|
[c59f9a0] | 119 | # Clean-up
|
---|
| 120 | rm -rf libs/.svn
|
---|
[f4ed135] | 121 | rm -rf menu/.svn
|
---|
| 122 | rm -rf menu/lxdialog/.svn
|
---|
[c59f9a0] | 123 |
|
---|
[d3ce173] | 124 |
|
---|
[f4ed135] | 125 | # Set some harcoded envars to their proper values
|
---|
| 126 | sed -i 's,blfs-xml,'$BLFS_XML',' update_book.sh libs/book.xsl
|
---|
| 127 | sed -i 's,tracking-dir,'$TRACKING_DIR',' update_book.sh gen-makefile.sh
|
---|
| 128 |
|
---|
| 129 | # Fetch book sources and create packages and meta-packages dependencies files
|
---|
[c59f9a0] | 130 | if [[ -d $BLFS_XML ]] ; then
|
---|
| 131 | ./update_book.sh
|
---|
| 132 | else
|
---|
[f4ed135] | 133 | ./update_book.sh get $BLFS_XML $TREE
|
---|
[c59f9a0] | 134 | fi
|
---|
| 135 |
|
---|
[f4ed135] | 136 | # Run the menuconfig interface
|
---|
| 137 | make
|
---|
[d3ce173] | 138 |
|
---|