[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 |
|
---|
[1ad9211] | 54 | #--- CONSTANTS
|
---|
| 55 | declare -r SVN="svn://svn.linuxfromscratch.org"
|
---|
| 56 | declare -r LOG=000-masterscript.log
|
---|
| 57 | # --- Server used if the file isn't found in SRC_ARCHIVE.
|
---|
| 58 | # As a last resort, the file will dowloaded from upstream, if possible.
|
---|
| 59 | SERVER=ftp://ftp.lfs-matrix.net
|
---|
| 60 | #--- Working directories
|
---|
| 61 | SCRIPT_ROOT=jhalfs
|
---|
| 62 | JHALFSDIR=$BUILDDIR/$SCRIPT_ROOT
|
---|
| 63 | LOGDIR=$JHALFSDIR/logs
|
---|
| 64 | TESTLOGDIR=$JHALFSDIR/test-logs
|
---|
| 65 | MKFILE=$JHALFSDIR/Makefile
|
---|
| 66 | #--- ICA report log directory
|
---|
| 67 | ICALOGDIR=$LOGDIR/ICA
|
---|
| 68 | #--- farce report log directory
|
---|
| 69 | FARCELOGDIR=$LOGDIR/farce
|
---|
| 70 | XSL=$PROGNAME.xsl
|
---|
| 71 | PKG_LST=unpacked
|
---|
| 72 |
|
---|
| 73 | case $PROGNAME in
|
---|
| 74 | clfs2) LFSVRS=development; TREE=branches/clfs-2.0/BOOK ;;
|
---|
| 75 | *) LFSVRS=development; TREE=trunk/BOOK ;;
|
---|
| 76 | esac
|
---|
| 77 |
|
---|
| 78 | if [[ ! -z ${BRANCH_ID} ]]; then
|
---|
| 79 | case $BRANCH_ID in
|
---|
| 80 | dev* | SVN | trunk )
|
---|
[398a037] | 81 | case $PROGNAME in
|
---|
| 82 | clfs2 ) TREE=branches/clfs-2.0/BOOK ;;
|
---|
| 83 | *) TREE=trunk/BOOK ;;
|
---|
| 84 | esac
|
---|
| 85 | LFSVRS=development
|
---|
| 86 | ;;
|
---|
| 87 | branch-* )
|
---|
[1ad9211] | 88 | LFSVRS=${BRANCH_ID}
|
---|
| 89 | TREE=branches/${BRANCH_ID#branch-}/BOOK
|
---|
[398a037] | 90 | ;;
|
---|
| 91 | * )
|
---|
| 92 | case $PROGNAME in
|
---|
| 93 | lfs | hlfs )
|
---|
[1ad9211] | 94 | LFSVRS=${BRANCH_ID}
|
---|
[398a037] | 95 | TREE=tags/${BRANCH_ID}/BOOK
|
---|
[1ad9211] | 96 | ;;
|
---|
[398a037] | 97 | clfs | clfs2 )
|
---|
[1ad9211] | 98 | LFSVRS=${BRANCH_ID}
|
---|
| 99 | TREE=tags/${BRANCH_ID}
|
---|
| 100 | ;;
|
---|
[398a037] | 101 | esac
|
---|
| 102 | ;;
|
---|
[1ad9211] | 103 | esac
|
---|
[613d46b] | 104 | fi
|
---|
[1ad9211] | 105 | # These are boolean vars generated from Config.in.
|
---|
| 106 | # ISSUE: If a boolean parameter is not set <true> that
|
---|
| 107 | # variable is not defined by the menu app. This can
|
---|
| 108 | # cause a headache if you are not careful.
|
---|
| 109 | # The following parameters MUST be created and have a
|
---|
| 110 | # default value.
|
---|
| 111 | RUNMAKE=${RUNMAKE:-n}
|
---|
| 112 | GETPKG=${GETPKG:-n}
|
---|
| 113 | GETKERNEL=${GETKERNEL:-n}
|
---|
| 114 | COMPARE=${COMPARE:-n}
|
---|
| 115 | RUN_FARCE=${RUN_FARCE:-n}
|
---|
| 116 | RUN_ICA=${RUN_ICA:-n}
|
---|
| 117 | BOMB_TEST=${BOMB_TEST:-n}
|
---|
| 118 | STRIP=${STRIP:=n}
|
---|
| 119 | REPORT=${REPORT:=n}
|
---|
| 120 | VIMLANG=${VIMLANG:-n}
|
---|
| 121 | KEYMAP=${KEYMAP:=none}
|
---|
| 122 | GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
---|
[0170229] | 123 |
|
---|
[47fddc8] | 124 |
|
---|
| 125 | [[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
|
---|
| 126 | source $COMMON_DIR/common-functions
|
---|
| 127 | [[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
|
---|
| 128 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 129 | [[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
|
---|
| 130 | source $MODULE
|
---|
| 131 | [[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
|
---|
| 132 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 133 | #
|
---|
| 134 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
| 135 |
|
---|
| 136 |
|
---|
[0170229] | 137 | #===========================================================
|
---|
| 138 | # If the var BOOK contains something then, maybe, it points
|
---|
| 139 | # to a working doc.. set WC=1, else 'null'
|
---|
| 140 | #===========================================================
|
---|
[1ad9211] | 141 | WC=${BOOK:+y}
|
---|
[0170229] | 142 | #===========================================================
|
---|
| 143 |
|
---|
[1ad9211] | 144 | #===================================================
|
---|
| 145 | # Set the document location...
|
---|
| 146 | #===================================================
|
---|
| 147 | BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
---|
| 148 | #===================================================
|
---|
| 149 |
|
---|
[0170229] | 150 |
|
---|
| 151 | #*******************************************************************#
|
---|
[26a8fdf] | 152 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
|
---|
[12a5707] | 153 | source $COMMON_DIR/func_check_version.sh
|
---|
| 154 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
[26a8fdf] | 155 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[0170229] | 156 |
|
---|
[26a8fdf] | 157 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
|
---|
[12a5707] | 158 | source $COMMON_DIR/func_validate_configs.sh
|
---|
| 159 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
[26a8fdf] | 160 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[65d83a6] | 161 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
[0170229] | 162 |
|
---|
| 163 |
|
---|
| 164 | ###################################
|
---|
[4612459] | 165 | ### MAIN ###
|
---|
[0170229] | 166 | ###################################
|
---|
| 167 |
|
---|
[47fddc8] | 168 | # Check for minimum bash,tar,gcc and kernel versions
|
---|
[f15fe85] | 169 | echo
|
---|
[13e816f] | 170 | check_version "2.6.2" "`uname -r`" "KERNEL"
|
---|
| 171 | check_version "3.0" "$BASH_VERSION" "BASH"
|
---|
| 172 | check_version "3.0" "`gcc -dumpversion`" "GCC"
|
---|
[e35e794] | 173 | tarVer=`tar --version | head -n1 | cut -d " " -f4`
|
---|
| 174 | check_version "1.15.0" "${tarVer}" "TAR"
|
---|
[65d83a6] | 175 | echo "${SD_BORDER}${nl_}"
|
---|
[13e816f] | 176 |
|
---|
[3051f95] | 177 | validate_config
|
---|
[65d83a6] | 178 | echo "${SD_BORDER}${nl_}"
|
---|
[7e6ddf0] | 179 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
[13e816f] | 180 | read ANSWER
|
---|
| 181 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 182 | echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
---|
| 183 | exit 1
|
---|
| 184 | fi
|
---|
[65d83a6] | 185 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
[13e816f] | 186 |
|
---|
[3a27393] | 187 | # Load additional modules or configuration files based on global settings
|
---|
[bb8e6bc] | 188 | # compare module
|
---|
[47fddc8] | 189 | if [[ "$COMPARE" = "y" ]]; then
|
---|
[bb8e6bc] | 190 | [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
|
---|
| 191 | source $COMMON_DIR/func_compare.sh
|
---|
| 192 | [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
|
---|
| 193 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 194 | fi
|
---|
| 195 | #
|
---|
[2c2471d] | 196 | # optimize module
|
---|
| 197 | if [[ "$OPTIMIZE" != "0" ]]; then
|
---|
| 198 | [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
|
---|
| 199 | source optimize/optimize_functions
|
---|
| 200 | [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
|
---|
| 201 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[3a27393] | 202 | #
|
---|
| 203 | # optimize configurations
|
---|
[bb8e6bc] | 204 | [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
|
---|
| 205 | source optimize/opt_config
|
---|
| 206 | [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
|
---|
| 207 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
[3a27393] | 208 | # Validate optimize settings, if required
|
---|
| 209 | validate_opt_settings
|
---|
[bb8e6bc] | 210 | fi
|
---|
| 211 | #
|
---|
| 212 |
|
---|
[13e816f] | 213 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
| 214 | # and notify the user about that.
|
---|
| 215 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
| 216 | eval "$no_empty_builddir"
|
---|
| 217 | fi
|
---|
| 218 |
|
---|
| 219 | # If requested, clean the build directory
|
---|
| 220 | clean_builddir
|
---|
| 221 |
|
---|
[0170229] | 222 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
[a110145] | 223 | mkdir -p $JHALFSDIR
|
---|
[0170229] | 224 | fi
|
---|
[3a27393] | 225 | #
|
---|
| 226 | # Create $BUILDDIR/sources even though it could be created by get_sources()
|
---|
| 227 | if [[ ! -d $BUILDDIR/sources ]]; then
|
---|
| 228 | mkdir -p $BUILDDIR/sources
|
---|
| 229 | fi
|
---|
| 230 | #
|
---|
| 231 | # Create the log directory
|
---|
| 232 | if [[ ! -d $LOGDIR ]]; then
|
---|
| 233 | mkdir $LOGDIR
|
---|
| 234 | fi
|
---|
| 235 | >$LOGDIR/$LOG
|
---|
| 236 | #
|
---|
[e35e794] | 237 | [[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
|
---|
[3a27393] | 238 | #
|
---|
[1ad9211] | 239 | cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
|
---|
| 240 | #
|
---|
| 241 | [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
|
---|
| 242 | #
|
---|
| 243 | if [[ "$COMPARE" = "y" ]]; then
|
---|
| 244 | mkdir -p $JHALFSDIR/extras
|
---|
| 245 | cp extras/* $JHALFSDIR/extras
|
---|
[0170229] | 246 | fi
|
---|
[1ad9211] | 247 | #
|
---|
| 248 | if [[ -n "$FILES" ]]; then
|
---|
| 249 | # pushd/popd necessary to deal with multiple files
|
---|
| 250 | pushd $PACKAGE_DIR 1> /dev/null
|
---|
| 251 | cp $FILES $JHALFSDIR/
|
---|
| 252 | popd 1> /dev/null
|
---|
| 253 | fi
|
---|
| 254 | #
|
---|
| 255 | if [[ "$REPORT" = "y" ]]; then
|
---|
| 256 | cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
|
---|
| 257 | # After being sure that all looks sane, dump the settings to a file
|
---|
| 258 | # This file will be used to create the REPORT header
|
---|
| 259 | validate_config > $JHALFSDIR/jhalfs.config
|
---|
| 260 | fi
|
---|
| 261 | #
|
---|
| 262 | [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
|
---|
| 263 | #
|
---|
| 264 | cp $COMMON_DIR/packages.xsl $JHALFSDIR/
|
---|
| 265 | #
|
---|
| 266 | sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
|
---|
| 267 | export XSL=$JHALFSDIR/${XSL}
|
---|
[0170229] | 268 |
|
---|
| 269 | get_book
|
---|
[65d83a6] | 270 | echo "${SD_BORDER}${nl_}"
|
---|
[12a5707] | 271 |
|
---|
[0170229] | 272 | build_Makefile
|
---|
[65d83a6] | 273 | echo "${SD_BORDER}${nl_}"
|
---|
[12a5707] | 274 |
|
---|
[386bc75] | 275 | run_make
|
---|