[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() {
|
---|
[d95b8f2] | 17 | echo -e "\n\t${BOLD}Goodbye and thank you for choosing ${L_arrow}JHALFS-X${R_arrow}\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 |
|
---|
[12a5707] | 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 | MODULE_CONFIG=$PACKAGE_DIR/config
|
---|
| 47 |
|
---|
| 48 | echo -n "Loading common-functions module..."
|
---|
| 49 | source $COMMON_DIR/common-functions
|
---|
| 50 | [[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
|
---|
| 51 | echo "OK"
|
---|
| 52 | #
|
---|
| 53 |
|
---|
| 54 | echo -n "Loading masterscript conf..."
|
---|
| 55 | source $COMMON_DIR/config
|
---|
[13e816f] | 56 | [[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
|
---|
[0170229] | 57 | echo "OK"
|
---|
| 58 | #
|
---|
| 59 | echo -n "Loading config module <$MODULE_CONFIG>..."
|
---|
| 60 | source $MODULE_CONFIG
|
---|
| 61 | [[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
|
---|
| 62 | echo "OK"
|
---|
| 63 | #
|
---|
| 64 | echo -n "Loading code module <$MODULE>..."
|
---|
| 65 | source $MODULE
|
---|
[12a5707] | 66 | [[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
|
---|
[0170229] | 67 | echo "OK"
|
---|
| 68 | #
|
---|
| 69 | echo "---------------${nl_}"
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | #===========================================================
|
---|
| 73 | # If the var BOOK contains something then, maybe, it points
|
---|
| 74 | # to a working doc.. set WC=1, else 'null'
|
---|
| 75 | #===========================================================
|
---|
| 76 | WC=${BOOK:+1}
|
---|
| 77 | #===========================================================
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | #*******************************************************************#
|
---|
[12a5707] | 81 | echo -n "Loading function <func_check_version.sh>..."
|
---|
| 82 | source $COMMON_DIR/func_check_version.sh
|
---|
| 83 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
| 84 | echo "OK"
|
---|
[0170229] | 85 |
|
---|
[12a5707] | 86 | echo -n "Loading function <func_validate_configs.sh>..."
|
---|
| 87 | source $COMMON_DIR/func_validate_configs.sh
|
---|
| 88 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
| 89 | echo "OK"
|
---|
| 90 | echo "---------------${nl_}"
|
---|
[0170229] | 91 |
|
---|
| 92 |
|
---|
| 93 | ###################################
|
---|
| 94 | ### MAIN ###
|
---|
| 95 | ###################################
|
---|
| 96 |
|
---|
| 97 | # Evaluate any command line switches
|
---|
| 98 |
|
---|
| 99 | while test $# -gt 0 ; do
|
---|
| 100 | case $1 in
|
---|
| 101 | --version | -V )
|
---|
| 102 | clear
|
---|
| 103 | echo "$version"
|
---|
| 104 | exit 0
|
---|
| 105 | ;;
|
---|
| 106 |
|
---|
| 107 | --help | -h )
|
---|
| 108 | if [[ "$PROGNAME" = "blfs" ]]; then
|
---|
| 109 | blfs_usage
|
---|
| 110 | else
|
---|
| 111 | usage
|
---|
| 112 | fi
|
---|
| 113 | ;;
|
---|
| 114 |
|
---|
| 115 | --LFS-version | -L )
|
---|
| 116 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 117 | shift
|
---|
| 118 | case $1 in
|
---|
| 119 | dev* | SVN | trunk )
|
---|
| 120 | LFSVRS=development
|
---|
| 121 | ;;
|
---|
[d95b8f2] | 122 | *) if [[ "$PROGNAME" = "lfs" ]]; then
|
---|
| 123 | case $1 in
|
---|
| 124 | 6.1.1 )
|
---|
| 125 | echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
---|
| 126 | exit 0
|
---|
| 127 | ;;
|
---|
| 128 | alpha*) LFSVRS=alphabetical ;;
|
---|
| 129 | udev*) LFSVRS=udev_update ;;
|
---|
| 130 | * ) echo "$1 is an unsupported version at this time." ;;
|
---|
| 131 | esac
|
---|
| 132 | else
|
---|
[6c7fe49] | 133 | 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."
|
---|
[d95b8f2] | 134 | exit 0
|
---|
| 135 | fi
|
---|
[0170229] | 136 | ;;
|
---|
| 137 | esac
|
---|
| 138 | ;;
|
---|
| 139 |
|
---|
| 140 | --directory | -d )
|
---|
| 141 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 142 | shift
|
---|
| 143 | BUILDDIR=$1
|
---|
| 144 | JHALFSDIR=$BUILDDIR/jhalfs
|
---|
| 145 | LOGDIR=$JHALFSDIR/logs
|
---|
| 146 | MKFILE=$JHALFSDIR/${PROGNAME}-Makefile
|
---|
| 147 | ;;
|
---|
| 148 |
|
---|
[d95b8f2] | 149 |
|
---|
[0170229] | 150 | --download-client | -D )
|
---|
| 151 | echo "The download feature is temporarily disable.."
|
---|
| 152 | exit
|
---|
| 153 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 154 | shift
|
---|
| 155 | DL=$1
|
---|
| 156 | ;;
|
---|
| 157 |
|
---|
| 158 | --working-copy | -W )
|
---|
| 159 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 160 | shift
|
---|
| 161 | if [ -f $1/patches.ent ] ; then
|
---|
[d95b8f2] | 162 | WC=1
|
---|
| 163 | BOOK=$1
|
---|
[0170229] | 164 | else
|
---|
| 165 | echo -e "\nLook like $1 isn't a supported working copy."
|
---|
| 166 | echo -e "Verify your selection and the command line.\n"
|
---|
| 167 | exit 1
|
---|
| 168 | fi
|
---|
| 169 | ;;
|
---|
| 170 |
|
---|
[8ab950f] | 171 | --testsuites | -T )
|
---|
| 172 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 173 | shift
|
---|
| 174 | case $1 in
|
---|
| 175 | 0 | 1 | 2 | 3 )
|
---|
| 176 | TEST=$1
|
---|
| 177 | ;;
|
---|
| 178 | * )
|
---|
| 179 | echo -e "\n$1 isn't a valid testsuites level value."
|
---|
| 180 | echo -e "You must to use 0, 1, 2, or 3.\n"
|
---|
| 181 | exit 1
|
---|
| 182 | ;;
|
---|
| 183 | esac
|
---|
| 184 | ;;
|
---|
| 185 |
|
---|
[d95b8f2] | 186 | --get-packages | -P ) HPKG=1 ;;
|
---|
| 187 | --run-make | -M ) RUNMAKE=1 ;;
|
---|
| 188 | --no-strip ) STRIP=0 ;;
|
---|
| 189 | --no-vim-lang ) VIMLANG=0 ;;
|
---|
| 190 | --rebuild ) CLEAN=1 ;;
|
---|
[0170229] | 191 |
|
---|
| 192 | --page_size )
|
---|
| 193 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 194 | shift
|
---|
| 195 | case $1 in
|
---|
| 196 | letter | A4 )
|
---|
| 197 | PAGE=$1
|
---|
| 198 | ;;
|
---|
| 199 | * )
|
---|
| 200 | echo "$1 isn't a supported page size."
|
---|
| 201 | exit 1
|
---|
| 202 | ;;
|
---|
| 203 | esac
|
---|
| 204 | ;;
|
---|
| 205 |
|
---|
| 206 | --timezone )
|
---|
| 207 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 208 | shift
|
---|
| 209 | if [ -f /usr/share/zoneinfo/$1 ] ; then
|
---|
| 210 | TIMEZONE=$1
|
---|
| 211 | else
|
---|
| 212 | echo -e "\nLooks like $1 isn't a valid timezone description."
|
---|
| 213 | echo -e "Verify your selection and the command line.\n"
|
---|
| 214 | exit 1
|
---|
| 215 | fi
|
---|
| 216 | ;;
|
---|
| 217 |
|
---|
| 218 | --fstab )
|
---|
| 219 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 220 | shift
|
---|
| 221 | if [ -f $1 ] ; then
|
---|
| 222 | FSTAB=$1
|
---|
| 223 | else
|
---|
| 224 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
| 225 | exit 1
|
---|
| 226 | fi
|
---|
| 227 | ;;
|
---|
| 228 |
|
---|
| 229 | --kernel-config | -C )
|
---|
| 230 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 231 | shift
|
---|
| 232 | if [ -f $1 ] ; then
|
---|
| 233 | CONFIG=$1
|
---|
| 234 | else
|
---|
| 235 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
| 236 | exit 1
|
---|
| 237 | fi
|
---|
| 238 | ;;
|
---|
| 239 |
|
---|
| 240 | * )
|
---|
| 241 | if [[ "$PROGNAME" = "blfs" ]]; then
|
---|
| 242 | blfs_usage
|
---|
| 243 | else
|
---|
| 244 | usage
|
---|
| 245 | fi
|
---|
| 246 | ;;
|
---|
| 247 | esac
|
---|
| 248 | shift
|
---|
| 249 | done
|
---|
| 250 |
|
---|
| 251 | # Find the download client to use, if not already specified.
|
---|
| 252 |
|
---|
| 253 | if [ -z $DL ] ; then
|
---|
| 254 | if [ `type -p wget` ] ; then
|
---|
| 255 | DL=wget
|
---|
| 256 | elif [ `type -p curl` ] ; then
|
---|
| 257 | DL=curl
|
---|
| 258 | else
|
---|
| 259 | eval "$no_dl_client"
|
---|
| 260 | fi
|
---|
| 261 | fi
|
---|
| 262 |
|
---|
| 263 | #===================================================
|
---|
| 264 | # Set the document location...
|
---|
[13e816f] | 265 | # BOOK is either defined in
|
---|
[0170229] | 266 | # xxx.config
|
---|
| 267 | # comand line
|
---|
[13e816f] | 268 | # default
|
---|
[d95b8f2] | 269 | # If set by conf file or cmd line leave it
|
---|
[0170229] | 270 | # alone otherwise load the default version
|
---|
| 271 | #===================================================
|
---|
| 272 | BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
---|
| 273 | #===================================================
|
---|
| 274 |
|
---|
[13e816f] | 275 |
|
---|
| 276 | # Check for minumum gcc and kernel versions
|
---|
| 277 | #check_requirements 1 # 0/1 0-do not display values.
|
---|
| 278 | check_version "2.6.2" "`uname -r`" "KERNEL"
|
---|
| 279 | check_version "3.0" "$BASH_VERSION" "BASH"
|
---|
| 280 | check_version "3.0" "`gcc -dumpversion`" "GCC"
|
---|
[e1edff3] | 281 | tarVer=`tar --version`
|
---|
| 282 | check_version "1.15.0" "${tarVer##* }" "TAR"
|
---|
[13e816f] | 283 | echo "---------------${nl_}"
|
---|
| 284 |
|
---|
| 285 | validate_config 1 # 0/1 0-do not display values
|
---|
| 286 | echo "---------------${nl_}"
|
---|
| 287 |
|
---|
[164afa2] | 288 | echo -n "Are you happy with that settings? yes/no (no): "
|
---|
[13e816f] | 289 | read ANSWER
|
---|
| 290 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 291 | echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
---|
| 292 | exit 1
|
---|
| 293 | fi
|
---|
| 294 |
|
---|
| 295 | # Prevents setting "-d /" by mistake.
|
---|
| 296 |
|
---|
| 297 | if [ $BUILDDIR = / ] ; then
|
---|
| 298 | echo -ne "\nThe root directory can't be used to build LFS.\n\n"
|
---|
| 299 | exit 1
|
---|
| 300 | fi
|
---|
| 301 |
|
---|
| 302 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
| 303 | # and notify the user about that.
|
---|
| 304 |
|
---|
| 305 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
| 306 | eval "$no_empty_builddir"
|
---|
| 307 | fi
|
---|
| 308 |
|
---|
| 309 | # If requested, clean the build directory
|
---|
| 310 | clean_builddir
|
---|
| 311 |
|
---|
[0170229] | 312 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
| 313 | mkdir -pv $JHALFSDIR
|
---|
| 314 | fi
|
---|
| 315 |
|
---|
[13e816f] | 316 | if [[ "$PWD" != "$JHALFSDIR" ]]; then
|
---|
[12a5707] | 317 | cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
|
---|
[0170229] | 318 | if [[ -n "$FILES" ]]; then
|
---|
[9c90294] | 319 | # pushd/popd necessary to deal with mulitiple files
|
---|
| 320 | pushd $PACKAGE_DIR
|
---|
| 321 | cp -v $FILES $JHALFSDIR/
|
---|
| 322 | popd
|
---|
[0170229] | 323 | fi
|
---|
[12a5707] | 324 | sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
|
---|
[0170229] | 325 | export XSL=$JHALFSDIR/${XSL}
|
---|
| 326 | fi
|
---|
| 327 |
|
---|
| 328 | if [[ ! -d $LOGDIR ]]; then
|
---|
| 329 | mkdir -v $LOGDIR
|
---|
| 330 | fi
|
---|
| 331 | >$LOGDIR/$LOG
|
---|
| 332 | echo "---------------${nl_}"
|
---|
| 333 |
|
---|
| 334 | get_book
|
---|
| 335 | echo "---------------${nl_}"
|
---|
[12a5707] | 336 |
|
---|
[0170229] | 337 | build_Makefile
|
---|
| 338 | echo "---------------${nl_}"
|
---|
[12a5707] | 339 |
|
---|
[386bc75] | 340 | run_make
|
---|
[0170229] | 341 |
|
---|