source: master.sh@ 308e05c

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 308e05c was 0ad851d, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Mixed fix.

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