[0170229] | 1 | #!/bin/bash
|
---|
[12a5707] | 2 | # $Id$
|
---|
[0170229] | 3 | set -e
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | #>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
---|
| 7 | #-----------------------#
|
---|
| 8 | simple_error() { # Basic error trap.... JUST DIE
|
---|
| 9 | #-----------------------#
|
---|
| 10 | # If +e then disable text output
|
---|
| 11 | if [[ "$-" =~ "e" ]]; then
|
---|
| 12 | echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
|
---|
| 13 | fi
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | see_ya() {
|
---|
[9e627f6] | 17 | echo -e "\n${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\n"
|
---|
[0170229] | 18 | }
|
---|
| 19 | ##### Simple error TRAPS
|
---|
| 20 | # ctrl-c SIGINT
|
---|
| 21 | # ctrl-y
|
---|
| 22 | # ctrl-z SIGTSTP
|
---|
| 23 | # SIGHUP 1 HANGUP
|
---|
| 24 | # SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
---|
| 25 | # SIGQUIT 3
|
---|
| 26 | # SIGKILL 9 KILL
|
---|
| 27 | # SIGTERM 15 TERMINATION
|
---|
| 28 | # SIGSTOP 17,18,23 STOP THE PROCESS
|
---|
| 29 | #####
|
---|
| 30 | set -e
|
---|
| 31 | trap see_ya 0
|
---|
| 32 | trap simple_error ERR
|
---|
| 33 | trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
---|
| 34 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | if [ ! -L $0 ] ; then
|
---|
| 38 | echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
|
---|
| 39 | exit 1
|
---|
| 40 | fi
|
---|
| 41 |
|
---|
[1ad9211] | 42 | PROGNAME=$(basename $0)
|
---|
| 43 | COMMON_DIR="common"
|
---|
| 44 | PACKAGE_DIR=$(echo $PROGNAME | tr [a-z] [A-Z])
|
---|
| 45 | MODULE=$PACKAGE_DIR/master.sh
|
---|
| 46 | VERBOSITY=1
|
---|
[12a5707] | 47 |
|
---|
[0170229] | 48 |
|
---|
[1ad9211] | 49 | [[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
|
---|
| 50 | source configuration
|
---|
| 51 | [[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
|
---|
| 52 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[9e627f6] | 53 |
|
---|
[3c96826] | 54 | #--- Envars not sourced from configuration (yet)
|
---|
[1ad9211] | 55 | declare -r SVN="svn://svn.linuxfromscratch.org"
|
---|
| 56 | declare -r LOG=000-masterscript.log
|
---|
| 57 |
|
---|
| 58 | case $PROGNAME in
|
---|
| 59 | clfs2) LFSVRS=development; TREE=branches/clfs-2.0/BOOK ;;
|
---|
| 60 | *) LFSVRS=development; TREE=trunk/BOOK ;;
|
---|
| 61 | esac
|
---|
| 62 |
|
---|
| 63 | if [[ ! -z ${BRANCH_ID} ]]; then
|
---|
| 64 | case $BRANCH_ID in
|
---|
| 65 | dev* | SVN | trunk )
|
---|
[398a037] | 66 | case $PROGNAME in
|
---|
| 67 | clfs2 ) TREE=branches/clfs-2.0/BOOK ;;
|
---|
| 68 | *) TREE=trunk/BOOK ;;
|
---|
| 69 | esac
|
---|
| 70 | LFSVRS=development
|
---|
| 71 | ;;
|
---|
| 72 | branch-* )
|
---|
[1ad9211] | 73 | LFSVRS=${BRANCH_ID}
|
---|
| 74 | TREE=branches/${BRANCH_ID#branch-}/BOOK
|
---|
[398a037] | 75 | ;;
|
---|
| 76 | * )
|
---|
| 77 | case $PROGNAME in
|
---|
| 78 | lfs | hlfs )
|
---|
[1ad9211] | 79 | LFSVRS=${BRANCH_ID}
|
---|
[398a037] | 80 | TREE=tags/${BRANCH_ID}/BOOK
|
---|
[1ad9211] | 81 | ;;
|
---|
[398a037] | 82 | clfs | clfs2 )
|
---|
[1ad9211] | 83 | LFSVRS=${BRANCH_ID}
|
---|
| 84 | TREE=tags/${BRANCH_ID}
|
---|
| 85 | ;;
|
---|
[398a037] | 86 | esac
|
---|
| 87 | ;;
|
---|
[1ad9211] | 88 | esac
|
---|
[613d46b] | 89 | fi
|
---|
[1ad9211] | 90 | # These are boolean vars generated from Config.in.
|
---|
| 91 | # ISSUE: If a boolean parameter is not set <true> that
|
---|
| 92 | # variable is not defined by the menu app. This can
|
---|
| 93 | # cause a headache if you are not careful.
|
---|
| 94 | # The following parameters MUST be created and have a
|
---|
| 95 | # default value.
|
---|
| 96 | RUNMAKE=${RUNMAKE:-n}
|
---|
| 97 | GETPKG=${GETPKG:-n}
|
---|
| 98 | GETKERNEL=${GETKERNEL:-n}
|
---|
| 99 | COMPARE=${COMPARE:-n}
|
---|
| 100 | RUN_FARCE=${RUN_FARCE:-n}
|
---|
| 101 | RUN_ICA=${RUN_ICA:-n}
|
---|
| 102 | BOMB_TEST=${BOMB_TEST:-n}
|
---|
| 103 | STRIP=${STRIP:=n}
|
---|
| 104 | REPORT=${REPORT:=n}
|
---|
| 105 | VIMLANG=${VIMLANG:-n}
|
---|
| 106 | KEYMAP=${KEYMAP:=none}
|
---|
| 107 | GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
---|
[0170229] | 108 |
|
---|
[47fddc8] | 109 |
|
---|
| 110 | [[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
|
---|
| 111 | source $COMMON_DIR/common-functions
|
---|
| 112 | [[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
|
---|
| 113 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 114 | [[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
|
---|
| 115 | source $MODULE
|
---|
| 116 | [[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
|
---|
| 117 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 118 | #
|
---|
| 119 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
| 120 |
|
---|
| 121 |
|
---|
[0170229] | 122 | #===========================================================
|
---|
| 123 | # If the var BOOK contains something then, maybe, it points
|
---|
| 124 | # to a working doc.. set WC=1, else 'null'
|
---|
| 125 | #===========================================================
|
---|
[1ad9211] | 126 | WC=${BOOK:+y}
|
---|
[0170229] | 127 | #===========================================================
|
---|
| 128 |
|
---|
[1ad9211] | 129 | #===================================================
|
---|
| 130 | # Set the document location...
|
---|
| 131 | #===================================================
|
---|
| 132 | BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
---|
| 133 | #===================================================
|
---|
| 134 |
|
---|
[0170229] | 135 |
|
---|
| 136 | #*******************************************************************#
|
---|
[26a8fdf] | 137 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
|
---|
[12a5707] | 138 | source $COMMON_DIR/func_check_version.sh
|
---|
| 139 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
[26a8fdf] | 140 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[0170229] | 141 |
|
---|
[26a8fdf] | 142 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
|
---|
[12a5707] | 143 | source $COMMON_DIR/func_validate_configs.sh
|
---|
| 144 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
[26a8fdf] | 145 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[65d83a6] | 146 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
[0170229] | 147 |
|
---|
| 148 |
|
---|
| 149 | ###################################
|
---|
[4612459] | 150 | ### MAIN ###
|
---|
[0170229] | 151 | ###################################
|
---|
| 152 |
|
---|
[47fddc8] | 153 | # Check for minimum bash,tar,gcc and kernel versions
|
---|
[f15fe85] | 154 | echo
|
---|
[13e816f] | 155 | check_version "2.6.2" "`uname -r`" "KERNEL"
|
---|
| 156 | check_version "3.0" "$BASH_VERSION" "BASH"
|
---|
| 157 | check_version "3.0" "`gcc -dumpversion`" "GCC"
|
---|
[e35e794] | 158 | tarVer=`tar --version | head -n1 | cut -d " " -f4`
|
---|
| 159 | check_version "1.15.0" "${tarVer}" "TAR"
|
---|
[65d83a6] | 160 | echo "${SD_BORDER}${nl_}"
|
---|
[13e816f] | 161 |
|
---|
[3051f95] | 162 | validate_config
|
---|
[65d83a6] | 163 | echo "${SD_BORDER}${nl_}"
|
---|
[7e6ddf0] | 164 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
[13e816f] | 165 | read ANSWER
|
---|
| 166 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 167 | echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
---|
| 168 | exit 1
|
---|
| 169 | fi
|
---|
[65d83a6] | 170 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
[13e816f] | 171 |
|
---|
[3a27393] | 172 | # Load additional modules or configuration files based on global settings
|
---|
[bb8e6bc] | 173 | # compare module
|
---|
[47fddc8] | 174 | if [[ "$COMPARE" = "y" ]]; then
|
---|
[bb8e6bc] | 175 | [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
|
---|
| 176 | source $COMMON_DIR/func_compare.sh
|
---|
| 177 | [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
|
---|
| 178 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 179 | fi
|
---|
| 180 | #
|
---|
[2c2471d] | 181 | # optimize module
|
---|
| 182 | if [[ "$OPTIMIZE" != "0" ]]; then
|
---|
| 183 | [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
|
---|
| 184 | source optimize/optimize_functions
|
---|
| 185 | [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
|
---|
| 186 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[3a27393] | 187 | #
|
---|
| 188 | # optimize configurations
|
---|
[bb8e6bc] | 189 | [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
|
---|
| 190 | source optimize/opt_config
|
---|
| 191 | [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
|
---|
| 192 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[3a27393] | 193 | # Validate optimize settings, if required
|
---|
| 194 | validate_opt_settings
|
---|
[bb8e6bc] | 195 | fi
|
---|
| 196 | #
|
---|
| 197 |
|
---|
[13e816f] | 198 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
| 199 | # and notify the user about that.
|
---|
| 200 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
| 201 | eval "$no_empty_builddir"
|
---|
| 202 | fi
|
---|
| 203 |
|
---|
| 204 | # If requested, clean the build directory
|
---|
| 205 | clean_builddir
|
---|
| 206 |
|
---|
[0170229] | 207 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
[a110145] | 208 | mkdir -p $JHALFSDIR
|
---|
[0170229] | 209 | fi
|
---|
[3a27393] | 210 | #
|
---|
| 211 | # Create $BUILDDIR/sources even though it could be created by get_sources()
|
---|
| 212 | if [[ ! -d $BUILDDIR/sources ]]; then
|
---|
| 213 | mkdir -p $BUILDDIR/sources
|
---|
| 214 | fi
|
---|
| 215 | #
|
---|
| 216 | # Create the log directory
|
---|
| 217 | if [[ ! -d $LOGDIR ]]; then
|
---|
| 218 | mkdir $LOGDIR
|
---|
| 219 | fi
|
---|
| 220 | >$LOGDIR/$LOG
|
---|
| 221 | #
|
---|
[e35e794] | 222 | [[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
|
---|
[3a27393] | 223 | #
|
---|
[1ad9211] | 224 | cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
|
---|
| 225 | #
|
---|
| 226 | [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
|
---|
| 227 | #
|
---|
| 228 | if [[ "$COMPARE" = "y" ]]; then
|
---|
| 229 | mkdir -p $JHALFSDIR/extras
|
---|
| 230 | cp extras/* $JHALFSDIR/extras
|
---|
[0170229] | 231 | fi
|
---|
[1ad9211] | 232 | #
|
---|
| 233 | if [[ -n "$FILES" ]]; then
|
---|
| 234 | # pushd/popd necessary to deal with multiple files
|
---|
| 235 | pushd $PACKAGE_DIR 1> /dev/null
|
---|
| 236 | cp $FILES $JHALFSDIR/
|
---|
| 237 | popd 1> /dev/null
|
---|
| 238 | fi
|
---|
| 239 | #
|
---|
| 240 | if [[ "$REPORT" = "y" ]]; then
|
---|
| 241 | cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
|
---|
| 242 | # After being sure that all looks sane, dump the settings to a file
|
---|
| 243 | # This file will be used to create the REPORT header
|
---|
| 244 | validate_config > $JHALFSDIR/jhalfs.config
|
---|
| 245 | fi
|
---|
| 246 | #
|
---|
| 247 | [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
|
---|
| 248 | #
|
---|
| 249 | cp $COMMON_DIR/packages.xsl $JHALFSDIR/
|
---|
| 250 | #
|
---|
| 251 | sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
|
---|
| 252 | export XSL=$JHALFSDIR/${XSL}
|
---|
[0170229] | 253 |
|
---|
| 254 | get_book
|
---|
[65d83a6] | 255 | echo "${SD_BORDER}${nl_}"
|
---|
[12a5707] | 256 |
|
---|
[0170229] | 257 | build_Makefile
|
---|
[65d83a6] | 258 | echo "${SD_BORDER}${nl_}"
|
---|
[12a5707] | 259 |
|
---|
[386bc75] | 260 | run_make
|
---|