source: master.sh@ a167246

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since a167246 was b0dd4bd, checked in by George Boudreau <georgeb@…>, 19 years ago

Adjusted files to reflect the removal of sparcv8 identifier from the CLFS book

  • Property mode set to 100755
File size: 11.6 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 x86_64-64 )
276 ARCH=x86_64-64
277 TARGET="x86_64-unknown-linux-gnu"
278 ;;
279 mips64-64 )
280 ARCH=mips64-64
281 TARGET="mips-unknown-linux-gnu"
282 ;;
283 mipsel64-64 )
284 ARCH=mips64-64
285 TARGET="mipsel-unknown-linux-gnu"
286 ;;
287 sparc64-64 )
288 ARCH=sparc64-64
289 TARGET="sparc64-unknown-linux-gnu"
290 ;;
291 alpha )
292 ARCH=alpha
293 TARGET="alpha-unknown-linux-gnu"
294 ;;
295 x86_64 )
296 ARCH=x86_64
297 TARGET="x86_64-unknown-linux-gnu"
298 TARGET32="i686-pc-linux-gnu"
299 ;;
300 mips64 )
301 ARCH=mips64
302 TARGET="mips-unknown-linux-gnu"
303 TARGET32="mips-unknown-linux-gnu"
304 ;;
305 mipsel64 )
306 ARCH=mips64
307 TARGET="mipsel-unknown-linux-gnu"
308 TARGET32="mipsel-unknown-linux-gnu"
309 ;;
310 sparc64 )
311 ARCH=sparc64
312 TARGET="sparc64-unknown-linux-gnu"
313 TARGET32="sparcv9-unknown-linux-gnu"
314 ;;
315 ppc64 )
316 ARCH=ppc64
317 TARGET="powerpc64-unknown-linux-gnu"
318 TARGET32="powerpc-unknown-linux-gnu"
319 ;;
320 * )
321 echo -e "\n$1 is an unknown or unsopported arch."
322 exit 1
323 ;;
324 esac
325 ;;
326
327 --boot-config )
328 test $# = 1 && eval "$exit_missing_arg"
329 shift
330 if [ -f $1 ] ; then
331 BOOT_CONFIG=$1
332 else
333 echo -e "\nFile $1 not found. Verify your command line.\n"
334 exit 1
335 fi
336 ;;
337
338 --method )
339 test $# = 1 && eval "$exit_missing_arg"
340 shift
341 case $1 in
342 chroot | boot )
343 METHOD=$1
344 ;;
345 * )
346 echo -e "\n$1 isn't a valid build method."
347 exit 1
348 ;;
349 esac
350 ;;
351
352 # HLFS options
353 --model )
354 test $# = 1 && eval "$exit_missing_arg"
355 shift
356 case $1 in
357 glibc | uclibc )
358 MODEL=$1
359 ;;
360 * )
361 echo -e "\n$1 isn't a valid libc model."
362 exit 1
363 ;;
364 esac
365 ;;
366
367 # BLFS options
368 --dependencies )
369 test $# = 1 && eval "$exit_missing_arg"
370 shift
371 case $1 in
372 0 | 1 | 2 )
373 DEPEND=$1
374 ;;
375 * )
376 echo -e "\n$1 isn't a valid dependencies level."
377 exit 1
378 ;;
379 esac
380 ;;
381
382 # Unknown options
383 * ) usage ;;
384 esac
385 shift
386done
387
388# Find the download client to use, if not already specified.
389
390if [ -z $DL ] ; then
391 if [ `type -p wget` ] ; then
392 DL=wget
393 elif [ `type -p curl` ] ; then
394 DL=curl
395 else
396 eval "$no_dl_client"
397 fi
398fi
399
400#===================================================
401# Set the document location...
402# BOOK is either defined in
403# xxx.config
404# comand line
405# default
406# If set by conf file or cmd line leave it
407# alone otherwise load the default version
408#===================================================
409BOOK=${BOOK:=$PROGNAME-$LFSVRS}
410#===================================================
411
412
413# Check for minumum gcc and kernel versions
414#check_requirements 1 # 0/1 0-do not display values.
415echo
416check_version "2.6.2" "`uname -r`" "KERNEL"
417check_version "3.0" "$BASH_VERSION" "BASH"
418check_version "3.0" "`gcc -dumpversion`" "GCC"
419tarVer=`tar --version`
420check_version "1.15.0" "${tarVer##* }" "TAR"
421echo "---------------${nl_}"
422
423validate_config
424echo "---------------${nl_}"
425
426echo -n "Are you happy with these settings? yes/no (no): "
427read ANSWER
428if [ x$ANSWER != "xyes" ] ; then
429 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
430 exit 1
431fi
432echo "${nl_}---------------${nl_}"
433
434# Prevents setting "-d /" by mistake.
435
436if [ $BUILDDIR = / ] ; then
437 echo -ne "\nThe root directory can't be used to build LFS.\n\n"
438 exit 1
439fi
440
441# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
442# and notify the user about that.
443
444if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
445 eval "$no_empty_builddir"
446fi
447
448# If requested, clean the build directory
449clean_builddir
450
451if [[ ! -d $JHALFSDIR ]]; then
452 mkdir -p $JHALFSDIR
453fi
454
455if [[ "$PWD" != "$JHALFSDIR" ]]; then
456 cp $COMMON_DIR/makefile-functions $JHALFSDIR/
457 if [[ -n "$FILES" ]]; then
458 # pushd/popd necessary to deal with mulitiple files
459 pushd $PACKAGE_DIR 1> /dev/null
460 cp $FILES $JHALFSDIR/
461 popd 1> /dev/null
462 fi
463 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
464 export XSL=$JHALFSDIR/${XSL}
465fi
466
467if [[ ! -d $LOGDIR ]]; then
468 mkdir $LOGDIR
469fi
470>$LOGDIR/$LOG
471
472get_book
473echo "---------------${nl_}"
474
475build_Makefile
476echo "---------------${nl_}"
477
478run_make
479
Note: See TracBrowser for help on using the repository browser.