source: master.sh@ 0044289

experimental
Last change on this file since 0044289 was 0044289, checked in by George Boudreau <georgeb@…>, 18 years ago

another missing menu variable

  • Property mode set to 100755
File size: 15.0 KB
RevLine 
[0170229]1#!/bin/bash
[12a5707]2# $Id$
[0170229]3set -e
4
5
6#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
7#-----------------------#
8simple_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
16see_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#####
30set -e
31trap see_ya 0
32trap simple_error ERR
33trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
34#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
35
36
37if [ ! -L $0 ] ; then
38 echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
39 exit 1
40fi
41
[12a5707]42 PROGNAME=$(basename $0)
43 COMMON_DIR="common"
[26a8fdf]44 PACKAGE_DIR=$(echo $PROGNAME | tr [a-z] [A-Z])
[12a5707]45 MODULE=$PACKAGE_DIR/master.sh
46MODULE_CONFIG=$PACKAGE_DIR/config
[26a8fdf]47 VERBOSITY=0
[12a5707]48
[0170229]49
[613d46b]50if [[ -e using_menuconfig ]]; then
[398a037]51 [[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
[613d46b]52 source configuration
[398a037]53 [[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
54 [[ $VERBOSITY > 0 ]] && echo "OK"
[9485eba]55
[480390a]56 #--- CONSTANTS
57 declare -r SVN="svn://svn.linuxfromscratch.org"
58 declare -r LOG=000-masterscript.log
[0044289]59 # --- Server used if the file isn't found in SRC_ARCHIVE.
60 # As a last resort, the file will dowloaded from upstream, if possible.
61 SERVER=ftp://ftp.lfs-matrix.net
[613d46b]62 #--- Working directories
63 SCRIPT_ROOT=jhalfs
64 JHALFSDIR=$BUILDDIR/$SCRIPT_ROOT
65 LOGDIR=$JHALFSDIR/logs
66 TESTLOGDIR=$JHALFSDIR/test-logs
67 MKFILE=$JHALFSDIR/Makefile
68 #--- ICA report log directory
69 ICALOGDIR=$LOGDIR/ICA
70 #--- farce report log directory
71 FARCELOGDIR=$LOGDIR/farce
[47fddc8]72 XSL=$PROGNAME.xsl
[613d46b]73
[47fddc8]74 case $PROGNAME in
[9e627f6]75 clfs2) LFSVRS=development; TREE=branches/clfs-2.0/BOOK ;;
[47fddc8]76 *) LFSVRS=development; TREE=trunk/BOOK ;;
77 esac
[9e627f6]78
[398a037]79 if [[ ! -z ${BRANCH_ID} ]]; then
80 case $BRANCH_ID in
81 dev* | SVN | trunk )
82 case $PROGNAME in
83 clfs2 ) TREE=branches/clfs-2.0/BOOK ;;
84 *) TREE=trunk/BOOK ;;
85 esac
86 LFSVRS=development
87 ;;
88 branch-* )
89 LFSVRS=${BRANCH_ID}
90 TREE=branches/${BRANCH_ID#branch-}/BOOK
91 ;;
92 * )
93 case $PROGNAME in
94 lfs | hlfs )
95 LFSVRS=${BRANCH_ID}
96 TREE=tags/${BRANCH_ID}/BOOK
97 ;;
98 clfs | clfs2 )
99 LFSVRS=${BRANCH_ID}
100 TREE=tags/${BRANCH_ID}
101 ;;
102 esac
103 ;;
[613d46b]104 esac
[398a037]105 fi
[47fddc8]106 # These are boolean vars generated from Config.in.
[9e627f6]107 # ISSUE: If a boolean parameter is not set <true> that
108 # variable is not defined by the menu app. This can
[47fddc8]109 # cause a headache if you are not careful.
[9e627f6]110 # The following parameters MUST be created and have a
[47fddc8]111 # default value.
112 RUNMAKE=${RUNMAKE:-n}
113 GETPKG=${GETPKG:-n}
114 GETKERNEL=${GETKERNEL:-n}
115 COMPARE=${COMPARE:-n}
116 RUN_FARCE=${RUN_FARCE:-n}
117 RUN_ICA=${RUN_ICA:-n}
118 BOMB_TEST=${BOMB_TEST:-n}
119 STRIP=${STRIP:=n}
120 REPORT=${REPORT:=n}
121 VIMLANG=${VIMLANG:-n}
122 KEYMAP=${KEYMAP:=none}
123 GRSECURITY_HOST=${GRSECURITY_HOST:-n}
[9e627f6]124
[47fddc8]125else
126 #
127 [[ $VERBOSITY > 0 ]] && echo -n "Loading masterscript conf..."
128 source $COMMON_DIR/config
129 [[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
130 [[ $VERBOSITY > 0 ]] && echo "OK"
131 #
132 [[ $VERBOSITY > 0 ]] && echo -n "Loading config module <$MODULE_CONFIG>..."
133 source $MODULE_CONFIG
134 [[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
135 [[ $VERBOSITY > 0 ]] && echo "OK"
136 #
[613d46b]137fi
[0170229]138
[47fddc8]139
140[[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
141source $COMMON_DIR/common-functions
142[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
143[[ $VERBOSITY > 0 ]] && echo "OK"
144[[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
145source $MODULE
146[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
147[[ $VERBOSITY > 0 ]] && echo "OK"
148#
149[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
150
151
[0170229]152#===========================================================
153# If the var BOOK contains something then, maybe, it points
154# to a working doc.. set WC=1, else 'null'
155#===========================================================
156WC=${BOOK:+1}
157#===========================================================
158
159
160#*******************************************************************#
[26a8fdf]161[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
[12a5707]162source $COMMON_DIR/func_check_version.sh
163[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[26a8fdf]164[[ $VERBOSITY > 0 ]] && echo "OK"
[0170229]165
[26a8fdf]166[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
[12a5707]167source $COMMON_DIR/func_validate_configs.sh
168[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[26a8fdf]169[[ $VERBOSITY > 0 ]] && echo "OK"
[65d83a6]170[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
[0170229]171
172
173###################################
[4612459]174### MAIN ###
[0170229]175###################################
176
177# Evaluate any command line switches
178
179while test $# -gt 0 ; do
180 case $1 in
[25b52e2]181 # Common options for {C,H}LFS books
[5627958]182 --book | -B )
[0170229]183 test $# = 1 && eval "$exit_missing_arg"
184 shift
185 case $1 in
186 dev* | SVN | trunk )
187 LFSVRS=development
[3b63c8c]188 TREE=trunk/BOOK
[0170229]189 ;;
[3b63c8c]190 branch-* )
191 LFSVRS=$1
192 TREE=branches/${1#branch-}/BOOK
193 ;;
194 * )
195 case $PROGNAME in
196 lfs | hlfs )
197 LFSVRS=$1
198 TREE=tags/$1/BOOK
199 ;;
200 clfs )
201 LFSVRS=$1
202 TREE=tags/$1
203 ;;
204 esac
[0170229]205 ;;
206 esac
207 ;;
208
[c16cedc]209 --directory | -D )
[0170229]210 test $# = 1 && eval "$exit_missing_arg"
211 shift
[e95c26c]212 case $1 in
213 -* )
[ea29b1f]214 echo -e "\n$1 isn't a valid build directory."
[e95c26c]215 echo -e "Directory names can't start with - .\n"
216 exit 1
217 ;;
218 * )
219 BUILDDIR=$1
[460ea63]220 JHALFSDIR=$BUILDDIR/${SCRIPT_ROOT}
[e95c26c]221 LOGDIR=$JHALFSDIR/logs
[e35e794]222 TESTLOGDIR=$JHALFSDIR/test-logs
[e95c26c]223 MKFILE=$JHALFSDIR/Makefile
224 ;;
225 esac
[0170229]226 ;;
227
[47fddc8]228 --get-packages | -G ) GETPKG=y ;;
[c16cedc]229
[e2b5b99]230 --help | -h ) usage | more && exit ;;
[c16cedc]231
[53588e2]232 --optimize | -O )
233 test $# = 1 && eval "$exit_missing_arg"
234 shift
235 case $1 in
236 0 | 1 | 2 )
237 OPTIMIZE=$1
238 ;;
239 * )
240 echo -e "\n$1 isn't a valid optimize level value."
241 echo -e "You must use 0, 1, or 2.\n"
242 exit 1
243 ;;
244 esac
245 ;;
246
[c16cedc]247 --testsuites | -T )
248 test $# = 1 && eval "$exit_missing_arg"
249 shift
250 case $1 in
251 0 | 1 | 2 | 3 )
252 TEST=$1
253 ;;
254 * )
255 echo -e "\n$1 isn't a valid testsuites level value."
256 echo -e "You must to use 0, 1, 2, or 3.\n"
257 exit 1
258 ;;
259 esac
260 ;;
261
262 --version | -V )
263 echo "$version"
264 exit 0
265 ;;
266
[0170229]267 --working-copy | -W )
268 test $# = 1 && eval "$exit_missing_arg"
269 shift
[5627958]270 case $PROGNAME in # Poor checks. We should find better ones.
271 lfs)
[f8615e5]272 if [ -d $1/chapter09 ] ; then
[5627958]273 WC=1
274 BOOK=$1
275 else
[3b63c8c]276 echo -e "\nLooks like $1 isn't an LFS working copy."
[5627958]277 exit 1
278 fi
279 ;;
280 clfs)
[f8615e5]281 if [ -d $1/cross-tools ] ; then
[5627958]282 WC=1
283 BOOK=$1
284 else
[da626a9]285 echo -e "\nLooks like $1 isn't a CLFS working copy."
[5627958]286 exit 1
287 fi
288 ;;
289 hlfs)
290 if [ -f $1/template.xml ] ; then
291 WC=1
292 BOOK=$1
293 else
[3b63c8c]294 echo -e "\nLooks like $1 isn't an HLFS working copy."
[5627958]295 exit 1
296 fi
297 ;;
[4532c37]298 esac
299 ;;
[0170229]300
[3b63c8c]301 --comparison | -C )
[4612459]302 test $# = 1 && eval "$exit_missing_arg"
303 shift
[02d1ae7]304 case $1 in
[47fddc8]305 ICA) RUN_ICA=y; RUN_FARCE=n; COMPARE=y ;;
306 farce) RUN_ICA=n; RUN_FARCE=y; COMPARE=y ;;
307 both) RUN_ICA=y; RUN_FARCE=y; COMPARE=y ;;
[4612459]308 *)
[c58f330]309 echo -e "\n$1 is an unknown analysis method."
[4612459]310 exit 1
311 ;;
312 esac
313 ;;
[42346b2]314
[40ccddf]315 --fstab | -F )
316 test $# = 1 && eval "$exit_missing_arg"
317 shift
318 if [ -f $1 ] ; then
319 FSTAB=$1
320 else
321 echo -e "\nFile $1 not found. Verify your command line.\n"
322 exit 1
323 fi
324 ;;
325
326 --kernel-config | -K )
327 test $# = 1 && eval "$exit_missing_arg"
328 shift
329 if [ -f $1 ] ; then
330 CONFIG=$1
331 else
332 echo -e "\nFile $1 not found. Verify your command line.\n"
333 exit 1
334 fi
335 ;;
336
[3fa20d4]337 --run-make | -M ) RUNMAKE=y ;;
[40ccddf]338
[3fa20d4]339 --rebuild | -R ) CLEAN=y ;;
[40ccddf]340
[bd99331]341 # CLFS options
342 --arch | -A )
343 test $# = 1 && eval "$exit_missing_arg"
344 shift
[47fddc8]345 case $PROGNAME in
346 CLFS2)
347 case $1 in
348 arm) ARCH=arm; TARGET="arm-unknown-linux-gnu" ;;
349 x86) ARCH=x86; TARGET="i686-pc-linux-gnu" ;;
350 *) echo -e "\n$1 is an unknown or unsupported arch."; exit 1
351 esac
352 ;;
353 CLFS)
354 case $1 in
355 arm ) ARCH=arm; TARGET="arm-unknown-linux-gnu" ;;
356 x86 ) ARCH=x86; TARGET="i686-pc-linux-gnu" ;;
357 i486 ) ARCH=x86; TARGET="i486-pc-linux-gnu" ;;
358 i586 ) ARCH=x86; TARGET="i586-pc-linux-gnu" ;;
359 ppc ) ARCH=ppc; TARGET="powerpc-unknown-linux-gnu" ;;
360 mips ) ARCH=mips; TARGET="mips-unknown-linux-gnu" ;;
361 mipsel ) ARCH=mips; TARGET="mipsel-unknown-linux-gnu" ;;
362 sparc ) ARCH=sparc; TARGET="sparcv9-unknown-linux-gnu" ;;
[9e627f6]363
[47fddc8]364 x86_64-64 ) ARCH=x86_64-64; TARGET="x86_64-unknown-linux-gnu" ;;
365 mips64-64 ) ARCH=mips64-64; TARGET="mips-unknown-linux-gnu" ;;
366 mipsel64-64 ) ARCH=mips64-64; TARGET="mipsel-unknown-linux-gnu" ;;
367 sparc64-64 ) ARCH=sparc64-64; TARGET="sparc64-unknown-linux-gnu" ;;
368 alpha ) ARCH=alpha; TARGET="alpha-unknown-linux-gnu" ;;
[9e627f6]369
[47fddc8]370 x86_64 ) ARCH=x86_64; TARGET="x86_64-unknown-linux-gnu"; TARGET32="i686-pc-linux-gnu" ;;
371 mips64 ) ARCH=mips64; TARGET="mips-unknown-linux-gnu"; TARGET32="mips-unknown-linux-gnu" ;;
372 mipsel64 ) ARCH=mips64; TARGET="mipsel-unknown-linux-gnu"; TARGET32="mipsel-unknown-linux-gnu" ;;
373 sparc64 ) ARCH=sparc64; TARGET="sparc64-unknown-linux-gnu"; TARGET32="sparcv9-unknown-linux-gnu" ;;
374 ppc64 ) ARCH=ppc64; TARGET="powerpc64-unknown-linux-gnu"; TARGET32="powerpc-unknown-linux-gnu" ;;
[9e627f6]375
[47fddc8]376 * ) echo -e "\n$1 is an unknown or unsupported arch."; exit 1 ;;
377 esac
378 ;;
[bd99331]379 esac
380 ;;
381
[5ff30ff]382 --boot-config )
383 test $# = 1 && eval "$exit_missing_arg"
384 shift
385 if [ -f $1 ] ; then
386 BOOT_CONFIG=$1
387 else
388 echo -e "\nFile $1 not found. Verify your command line.\n"
389 exit 1
390 fi
391 ;;
392
[bd99331]393 --method )
394 test $# = 1 && eval "$exit_missing_arg"
395 shift
396 case $1 in
397 chroot | boot )
398 METHOD=$1
399 ;;
400 * )
401 echo -e "\n$1 isn't a valid build method."
402 exit 1
403 ;;
404 esac
405 ;;
406
[890acc6]407 # HLFS options
408 --model )
409 test $# = 1 && eval "$exit_missing_arg"
410 shift
411 case $1 in
412 glibc | uclibc )
413 MODEL=$1
414 ;;
415 * )
416 echo -e "\n$1 isn't a valid libc model."
417 exit 1
418 ;;
419 esac
420 ;;
421
[bd99331]422 # Unknown options
[e794f06]423 * ) usage ;;
[0170229]424 esac
425 shift
426done
427
[47fddc8]428
[0170229]429#===================================================
430# Set the document location...
[13e816f]431# BOOK is either defined in
[0170229]432# xxx.config
433# comand line
[13e816f]434# default
[d95b8f2]435# If set by conf file or cmd line leave it
[0170229]436# alone otherwise load the default version
437#===================================================
438BOOK=${BOOK:=$PROGNAME-$LFSVRS}
439#===================================================
440
[13e816f]441
[47fddc8]442# Check for minimum bash,tar,gcc and kernel versions
[f15fe85]443echo
[13e816f]444check_version "2.6.2" "`uname -r`" "KERNEL"
445check_version "3.0" "$BASH_VERSION" "BASH"
446check_version "3.0" "`gcc -dumpversion`" "GCC"
[e35e794]447tarVer=`tar --version | head -n1 | cut -d " " -f4`
448check_version "1.15.0" "${tarVer}" "TAR"
[65d83a6]449echo "${SD_BORDER}${nl_}"
[13e816f]450
[3051f95]451validate_config
[65d83a6]452echo "${SD_BORDER}${nl_}"
[7e6ddf0]453echo -n "Are you happy with these settings? yes/no (no): "
[13e816f]454read ANSWER
455if [ x$ANSWER != "xyes" ] ; then
456 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
457 exit 1
458fi
[65d83a6]459echo "${nl_}${SD_BORDER}${nl_}"
[13e816f]460
[3a27393]461# Load additional modules or configuration files based on global settings
[bb8e6bc]462# compare module
[47fddc8]463if [[ "$COMPARE" = "y" ]]; then
[bb8e6bc]464 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
465 source $COMMON_DIR/func_compare.sh
466 [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
467 [[ $VERBOSITY > 0 ]] && echo "OK"
468fi
469#
[2c2471d]470# optimize module
471if [[ "$OPTIMIZE" != "0" ]]; then
472 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
473 source optimize/optimize_functions
474 [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
475 [[ $VERBOSITY > 0 ]] && echo "OK"
[3a27393]476 #
477 # optimize configurations
[bb8e6bc]478 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
479 source optimize/opt_config
480 [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
481 [[ $VERBOSITY > 0 ]] && echo "OK"
[3a27393]482 # Validate optimize settings, if required
483 validate_opt_settings
[bb8e6bc]484fi
485#
486
[13e816f]487# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
488# and notify the user about that.
489if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
490 eval "$no_empty_builddir"
491fi
492
493# If requested, clean the build directory
494clean_builddir
495
[0170229]496if [[ ! -d $JHALFSDIR ]]; then
[a110145]497 mkdir -p $JHALFSDIR
[0170229]498fi
[3a27393]499#
500# Create $BUILDDIR/sources even though it could be created by get_sources()
501if [[ ! -d $BUILDDIR/sources ]]; then
502 mkdir -p $BUILDDIR/sources
503fi
504#
505# Create the log directory
506if [[ ! -d $LOGDIR ]]; then
507 mkdir $LOGDIR
508fi
509>$LOGDIR/$LOG
510#
[e35e794]511[[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
[3a27393]512#
[13e816f]513if [[ "$PWD" != "$JHALFSDIR" ]]; then
[460ea63]514 cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
[e35e794]515 #
[d0e48ec]516 [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
[e35e794]517 #
[47fddc8]518 if [[ "$COMPARE" = "y" ]]; then
[cc020f4]519 mkdir -p $JHALFSDIR/extras
[4612459]520 cp extras/* $JHALFSDIR/extras
[ed0a142]521 fi
[3a27393]522 #
[0170229]523 if [[ -n "$FILES" ]]; then
[3b63c8c]524 # pushd/popd necessary to deal with multiple files
[a110145]525 pushd $PACKAGE_DIR 1> /dev/null
526 cp $FILES $JHALFSDIR/
527 popd 1> /dev/null
[0170229]528 fi
[3a27393]529 #
[47fddc8]530 if [[ "$REPORT" = "y" ]]; then
[25b52e2]531 cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
[3b63c8c]532 # After being sure that all looks sane, dump the settings to a file
[25b52e2]533 # This file will be used to create the REPORT header
534 validate_config > $JHALFSDIR/jhalfs.config
[708a612]535 fi
[3a27393]536 #
[47fddc8]537 [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
[25b52e2]538 #
[3b63c8c]539 cp $COMMON_DIR/packages.xsl $JHALFSDIR/
540 #
[12a5707]541 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
[0170229]542 export XSL=$JHALFSDIR/${XSL}
543fi
544
545get_book
[65d83a6]546echo "${SD_BORDER}${nl_}"
[12a5707]547
[0170229]548build_Makefile
[65d83a6]549echo "${SD_BORDER}${nl_}"
[12a5707]550
[386bc75]551run_make
Note: See TracBrowser for help on using the repository browser.