source: master.sh@ 65d83a6

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

Synchrnized experimental branch with trunk.

  • Property mode set to 100755
File size: 12.5 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#
[d6614ab]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
[a5fa1a9]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#
[65d83a6]74[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${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"
[65d83a6]95[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${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 ;;
[18911500]120 * )
121 echo "$1 is an unsupported version at this time."
122 exit 0
123 ;;
[5627958]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."
[d95b8f2]127 exit 0
128 fi
[0170229]129 ;;
130 esac
131 ;;
132
[c16cedc]133 --directory | -D )
[0170229]134 test $# = 1 && eval "$exit_missing_arg"
135 shift
[e95c26c]136 case $1 in
137 -* )
[ea29b1f]138 echo -e "\n$1 isn't a valid build directory."
[e95c26c]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
[0170229]149 ;;
150
[3e7af38]151 --get-packages | -G ) GETPKG=1 ;;
[c16cedc]152
[e2b5b99]153 --help | -h ) usage | more && exit ;;
[c16cedc]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
[0170229]175 --working-copy | -W )
176 test $# = 1 && eval "$exit_missing_arg"
177 shift
[5627958]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
[da626a9]184 echo -e "\nLooks like $1 isn't a LFS working copy."
[5627958]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
[da626a9]193 echo -e "\nLooks like $1 isn't a CLFS working copy."
[5627958]194 exit 1
195 fi
196 ;;
197 hlfs)
198 if [ -f $1/template.xml ] ; then
199 WC=1
200 BOOK=$1
201 else
[da626a9]202 echo -e "\nLooks like $1 isn't a HLFS working copy."
[5627958]203 exit 1
204 fi
205 ;;
206 blfs)
207 if [ -f $1/use-unzip.xml ] ; then
208 WC=1
209 BOOK=$1
210 else
[da626a9]211 echo -e "\nLooks like $1 isn't a BLFS working copy."
[5627958]212 exit 1
213 fi
214 ;;
[4532c37]215 esac
216 ;;
[0170229]217
[40ccddf]218 # Common options for LFS, CLFS and HLFS
[4612459]219 --comparasion | -C )
220 test $# = 1 && eval "$exit_missing_arg"
221 shift
[02d1ae7]222 case $1 in
[4612459]223 ICA) RUN_ICA=1
224 RUN_FARCE=0
[fb68d23]225 COMPARE=1
[4612459]226 ;;
227 farce) RUN_ICA=0
228 RUN_FARCE=1
[fb68d23]229 COMPARE=1
[4612459]230 ;;
231 both) RUN_ICA=1
232 RUN_FARCE=1
[fb68d23]233 COMPARE=1
[97520c9]234 ;;
[4612459]235 *)
[c58f330]236 echo -e "\n$1 is an unknown analysis method."
[4612459]237 exit 1
238 ;;
239 esac
240 ;;
[42346b2]241
[40ccddf]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
[bd99331]264 --make | -M ) RUNMAKE=1 ;;
[40ccddf]265
266 --rebuild | -R ) CLEAN=1 ;;
267
[bd99331]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
[5ff30ff]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
[bd99331]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
[890acc6]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
[bd99331]408 # Unknown options
[e794f06]409 * ) usage ;;
[0170229]410 esac
411 shift
412done
413
414#===================================================
415# Set the document location...
[13e816f]416# BOOK is either defined in
[0170229]417# xxx.config
418# comand line
[13e816f]419# default
[d95b8f2]420# If set by conf file or cmd line leave it
[0170229]421# alone otherwise load the default version
422#===================================================
423BOOK=${BOOK:=$PROGNAME-$LFSVRS}
424#===================================================
425
[13e816f]426
427# Check for minumum gcc and kernel versions
428#check_requirements 1 # 0/1 0-do not display values.
[f15fe85]429echo
[13e816f]430check_version "2.6.2" "`uname -r`" "KERNEL"
431check_version "3.0" "$BASH_VERSION" "BASH"
432check_version "3.0" "`gcc -dumpversion`" "GCC"
[e1edff3]433tarVer=`tar --version`
434check_version "1.15.0" "${tarVer##* }" "TAR"
[65d83a6]435echo "${SD_BORDER}${nl_}"
[13e816f]436
[3051f95]437validate_config
[65d83a6]438echo "${SD_BORDER}${nl_}"
[13e816f]439
[7e6ddf0]440echo -n "Are you happy with these settings? yes/no (no): "
[13e816f]441read ANSWER
442if [ x$ANSWER != "xyes" ] ; then
443 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
444 exit 1
445fi
[65d83a6]446echo "${nl_}${SD_BORDER}${nl_}"
[13e816f]447
448# Prevents setting "-d /" by mistake.
449
450if [ $BUILDDIR = / ] ; then
451 echo -ne "\nThe root directory can't be used to build LFS.\n\n"
452 exit 1
453fi
454
455# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
456# and notify the user about that.
457
458if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
459 eval "$no_empty_builddir"
460fi
461
462# If requested, clean the build directory
463clean_builddir
464
[0170229]465if [[ ! -d $JHALFSDIR ]]; then
[a110145]466 mkdir -p $JHALFSDIR
[0170229]467fi
468
[13e816f]469if [[ "$PWD" != "$JHALFSDIR" ]]; then
[a110145]470 cp $COMMON_DIR/makefile-functions $JHALFSDIR/
[fb68d23]471 if [[ "$COMPARE" != "0" ]] ; then
[cc020f4]472 mkdir -p $JHALFSDIR/extras
[4612459]473 cp extras/* $JHALFSDIR/extras
[ed0a142]474 fi
[0170229]475 if [[ -n "$FILES" ]]; then
[9c90294]476 # pushd/popd necessary to deal with mulitiple files
[a110145]477 pushd $PACKAGE_DIR 1> /dev/null
478 cp $FILES $JHALFSDIR/
479 popd 1> /dev/null
[0170229]480 fi
[9e4b9a1]481 [[ "$REPORT" = "1" ]] && cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
[3e7af38]482 [[ "$GETPKG" = "1" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
[12a5707]483 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
[0170229]484 export XSL=$JHALFSDIR/${XSL}
485fi
486
487if [[ ! -d $LOGDIR ]]; then
[a110145]488 mkdir $LOGDIR
[0170229]489fi
[3cc7540]490
491# After be sure that all look sane and if REPORT=1, dump the settings to a file
492# This file will be used to create the REPORT header
493[[ "$REPORT" = "1" ]] && validate_config > $JHALFSDIR/jhalfs.config
494
[0170229]495>$LOGDIR/$LOG
496
497get_book
[65d83a6]498echo "${SD_BORDER}${nl_}"
[12a5707]499
[0170229]500build_Makefile
[65d83a6]501echo "${SD_BORDER}${nl_}"
[12a5707]502
[386bc75]503run_make
[0170229]504
Note: See TracBrowser for help on using the repository browser.