source: master.sh@ ccc7c2b

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since ccc7c2b was d385453, checked in by George Boudreau <georgeb@…>, 18 years ago

numerous grammar/spelling corrections provided by Chris Staub

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