source: master.sh@ 3570c1c

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

Bug fix.

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