source: master.sh@ 28ff443

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 28ff443 was a705708, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Merged menuconfig code from experimental.
Added clfs2 symlink (required by menuconfig)

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