source: master.sh@ 1ec8fce

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

Removed BLFS code from master.sh and common/*.

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