source: master.sh@ 1ee8ad5

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

Load additional modules or configuration files only is requested.

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