source: master.sh@ 158b30f

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

Started ICA support.

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