source: master.sh@ 4612459

experimental
Last change on this file since 4612459 was 4612459, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Adding farce to config options.

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