source: master.sh@ a7db907

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

Extensive code changes. A different method for finding the tarball name.

  • Property mode set to 100755
File size: 13.3 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[[ $VERBOSITY > 0 ]] && echo -n "Loading masterscript conf..."
55source $COMMON_DIR/config
56[[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
57[[ $VERBOSITY > 0 ]] && echo "OK"
58#
59[[ $VERBOSITY > 0 ]] && echo -n "Loading config module <$MODULE_CONFIG>..."
60source $MODULE_CONFIG
61[[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
62[[ $VERBOSITY > 0 ]] && echo "OK"
63#
64[[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
65source $MODULE
66[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
67[[ $VERBOSITY > 0 ]] && echo "OK"
68#
[21f0a91]69[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
[877cc6a]70
71
72#===========================================================
73# If the var BOOK contains something then, maybe, it points
74# to a working doc.. set WC=1, else 'null'
75#===========================================================
76WC=${BOOK:+1}
77#===========================================================
78
79
80#*******************************************************************#
81[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
82source $COMMON_DIR/func_check_version.sh
83[[ $? > 0 ]] && echo " function module did not load.." && exit 2
84[[ $VERBOSITY > 0 ]] && echo "OK"
85
86[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
87source $COMMON_DIR/func_validate_configs.sh
88[[ $? > 0 ]] && echo " function module did not load.." && exit 2
89[[ $VERBOSITY > 0 ]] && echo "OK"
[21f0a91]90[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
[877cc6a]91
92
93###################################
[45f82718]94### MAIN ###
[877cc6a]95###################################
96
97# Evaluate any command line switches
98
99while test $# -gt 0 ; do
100 case $1 in
[1ec8fce]101 # Common options for {C,H}LFS books
[877cc6a]102 --book | -B )
103 test $# = 1 && eval "$exit_missing_arg"
104 shift
105 case $1 in
106 dev* | SVN | trunk )
107 LFSVRS=development
108 ;;
109 *) if [[ "$PROGNAME" = "lfs" ]]; then
110 case $1 in
111 6.1.1 )
112 echo "For stable 6.1.1 book, please use jhalfs-0.2."
113 exit 0
114 ;;
[3570c1c]115 * )
116 echo "$1 is an unsupported version at this time."
117 exit 0
118 ;;
[877cc6a]119 esac
120 else
121 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."
122 exit 0
123 fi
124 ;;
125 esac
126 ;;
127
128 --directory | -D )
129 test $# = 1 && eval "$exit_missing_arg"
130 shift
131 case $1 in
132 -* )
133 echo -e "\n$1 isn't a valid build directory."
134 echo -e "Directory names can't start with - .\n"
135 exit 1
136 ;;
137 * )
138 BUILDDIR=$1
[1a1f099]139 JHALFSDIR=$BUILDDIR/${SCRIPT_ROOT}
[877cc6a]140 LOGDIR=$JHALFSDIR/logs
[a229600]141 TESTLOGDIR=$JHALFSDIR/test-logs
[877cc6a]142 MKFILE=$JHALFSDIR/Makefile
143 ;;
144 esac
145 ;;
146
[15cad16]147 --get-packages | -G ) GETPKG=1 ;;
[877cc6a]148
149 --help | -h ) usage | more && exit ;;
150
[1b65a84]151 --optimize | -O )
152 test $# = 1 && eval "$exit_missing_arg"
153 shift
154 case $1 in
155 0 | 1 | 2 )
156 OPTIMIZE=$1
157 ;;
158 * )
159 echo -e "\n$1 isn't a valid optimize level value."
160 echo -e "You must use 0, 1, or 2.\n"
161 exit 1
162 ;;
163 esac
164 ;;
165
[877cc6a]166 --testsuites | -T )
167 test $# = 1 && eval "$exit_missing_arg"
168 shift
169 case $1 in
170 0 | 1 | 2 | 3 )
171 TEST=$1
172 ;;
173 * )
174 echo -e "\n$1 isn't a valid testsuites level value."
175 echo -e "You must to use 0, 1, 2, or 3.\n"
176 exit 1
177 ;;
178 esac
179 ;;
180
181 --version | -V )
182 echo "$version"
183 exit 0
184 ;;
185
186 --working-copy | -W )
187 test $# = 1 && eval "$exit_missing_arg"
188 shift
189 case $PROGNAME in # Poor checks. We should find better ones.
190 lfs)
[4bc3c2b]191 if [ -d $1/chapter09 ] ; then
[877cc6a]192 WC=1
193 BOOK=$1
194 else
195 echo -e "\nLooks like $1 isn't a LFS working copy."
196 exit 1
197 fi
198 ;;
199 clfs)
[4bc3c2b]200 if [ -d $1/cross-tools ] ; then
[877cc6a]201 WC=1
202 BOOK=$1
203 else
204 echo -e "\nLooks like $1 isn't a CLFS working copy."
205 exit 1
206 fi
207 ;;
208 hlfs)
209 if [ -f $1/template.xml ] ; then
210 WC=1
211 BOOK=$1
212 else
213 echo -e "\nLooks like $1 isn't a HLFS working copy."
214 exit 1
215 fi
216 ;;
217 esac
218 ;;
219
[45f82718]220 --comparasion | -C )
221 test $# = 1 && eval "$exit_missing_arg"
222 shift
223 case $1 in
224 ICA) RUN_ICA=1
225 RUN_FARCE=0
226 COMPARE=1
227 ;;
228 farce) RUN_ICA=0
229 RUN_FARCE=1
230 COMPARE=1
231 ;;
232 both) RUN_ICA=1
233 RUN_FARCE=1
234 COMPARE=1
235 ;;
236 *)
[0ad851d]237 echo -e "\n$1 is an unknown analysis method."
[45f82718]238 exit 1
239 ;;
240 esac
241 ;;
242
[877cc6a]243 --fstab | -F )
244 test $# = 1 && eval "$exit_missing_arg"
245 shift
246 if [ -f $1 ] ; then
247 FSTAB=$1
248 else
249 echo -e "\nFile $1 not found. Verify your command line.\n"
250 exit 1
251 fi
252 ;;
253
254 --kernel-config | -K )
255 test $# = 1 && eval "$exit_missing_arg"
256 shift
257 if [ -f $1 ] ; then
258 CONFIG=$1
259 else
260 echo -e "\nFile $1 not found. Verify your command line.\n"
261 exit 1
262 fi
263 ;;
264
265 --make | -M ) RUNMAKE=1 ;;
266
267 --rebuild | -R ) CLEAN=1 ;;
268
269 # CLFS options
270 --arch | -A )
271 test $# = 1 && eval "$exit_missing_arg"
272 shift
273 case $1 in
274 x86 )
275 ARCH=x86
276 TARGET="i686-pc-linux-gnu"
277 ;;
278 i486 )
279 ARCH=x86
280 TARGET="i486-pc-linux-gnu"
281 ;;
282 i586 )
283 ARCH=x86
284 TARGET="i586-pc-linux-gnu"
285 ;;
286 ppc )
287 ARCH=ppc
288 TARGET="powerpc-unknown-linux-gnu"
289 ;;
290 mips )
291 ARCH=mips
292 TARGET="mips-unknown-linux-gnu"
293 ;;
294 mipsel )
295 ARCH=mips
296 TARGET="mipsel-unknown-linux-gnu"
297 ;;
298 sparc )
299 ARCH=sparc
300 TARGET="sparcv9-unknown-linux-gnu"
301 ;;
302 x86_64-64 )
303 ARCH=x86_64-64
304 TARGET="x86_64-unknown-linux-gnu"
305 ;;
306 mips64-64 )
307 ARCH=mips64-64
308 TARGET="mips-unknown-linux-gnu"
309 ;;
310 mipsel64-64 )
311 ARCH=mips64-64
312 TARGET="mipsel-unknown-linux-gnu"
313 ;;
314 sparc64-64 )
315 ARCH=sparc64-64
316 TARGET="sparc64-unknown-linux-gnu"
317 ;;
318 alpha )
319 ARCH=alpha
320 TARGET="alpha-unknown-linux-gnu"
321 ;;
322 x86_64 )
323 ARCH=x86_64
324 TARGET="x86_64-unknown-linux-gnu"
325 TARGET32="i686-pc-linux-gnu"
326 ;;
327 mips64 )
328 ARCH=mips64
329 TARGET="mips-unknown-linux-gnu"
330 TARGET32="mips-unknown-linux-gnu"
331 ;;
332 mipsel64 )
333 ARCH=mips64
334 TARGET="mipsel-unknown-linux-gnu"
335 TARGET32="mipsel-unknown-linux-gnu"
336 ;;
337 sparc64 )
338 ARCH=sparc64
339 TARGET="sparc64-unknown-linux-gnu"
340 TARGET32="sparcv9-unknown-linux-gnu"
341 ;;
342 ppc64 )
343 ARCH=ppc64
344 TARGET="powerpc64-unknown-linux-gnu"
345 TARGET32="powerpc-unknown-linux-gnu"
346 ;;
347 * )
348 echo -e "\n$1 is an unknown or unsopported arch."
349 exit 1
350 ;;
351 esac
352 ;;
353
354 --boot-config )
355 test $# = 1 && eval "$exit_missing_arg"
356 shift
357 if [ -f $1 ] ; then
358 BOOT_CONFIG=$1
359 else
360 echo -e "\nFile $1 not found. Verify your command line.\n"
361 exit 1
362 fi
363 ;;
364
365 --method )
366 test $# = 1 && eval "$exit_missing_arg"
367 shift
368 case $1 in
369 chroot | boot )
370 METHOD=$1
371 ;;
372 * )
373 echo -e "\n$1 isn't a valid build method."
374 exit 1
375 ;;
376 esac
377 ;;
378
379 # HLFS options
380 --model )
381 test $# = 1 && eval "$exit_missing_arg"
382 shift
383 case $1 in
384 glibc | uclibc )
385 MODEL=$1
386 ;;
387 * )
388 echo -e "\n$1 isn't a valid libc model."
389 exit 1
390 ;;
391 esac
392 ;;
393
394 # Unknown options
395 * ) usage ;;
396 esac
397 shift
398done
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"
[27f165a]419tarVer=`tar --version | head -n1 | cut -d " " -f4`
420check_version "1.15.0" "${tarVer}" "TAR"
[21f0a91]421echo "${SD_BORDER}${nl_}"
[877cc6a]422
423validate_config
[21f0a91]424echo "${SD_BORDER}${nl_}"
[877cc6a]425echo -n "Are you happy with these settings? yes/no (no): "
426read ANSWER
427if [ x$ANSWER != "xyes" ] ; then
428 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
429 exit 1
430fi
[21f0a91]431echo "${nl_}${SD_BORDER}${nl_}"
[877cc6a]432
[a0f0bee]433# Load additional modules or configuration files based on global settings
[1ee8ad5]434# compare module
435if [[ "$COMPARE" = "1" ]]; then
436 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
437 source $COMMON_DIR/func_compare.sh
438 [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
439 [[ $VERBOSITY > 0 ]] && echo "OK"
440fi
[1b65a84]441#
442# optimize module
443if [[ "$OPTIMIZE" != "0" ]]; then
444 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
445 source optimize/optimize_functions
446 [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
447 [[ $VERBOSITY > 0 ]] && echo "OK"
[a0f0bee]448 #
449 # optimize configurations
[1b65a84]450 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
451 source optimize/opt_config
452 [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
453 [[ $VERBOSITY > 0 ]] && echo "OK"
[a0f0bee]454 # Validate optimize settings, if required
455 validate_opt_settings
[1b65a84]456fi
457#
458
[877cc6a]459# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
460# and notify the user about that.
461if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
462 eval "$no_empty_builddir"
463fi
464
465# If requested, clean the build directory
466clean_builddir
467
468if [[ ! -d $JHALFSDIR ]]; then
469 mkdir -p $JHALFSDIR
470fi
[a0f0bee]471#
472# Create $BUILDDIR/sources even though it could be created by get_sources()
473if [[ ! -d $BUILDDIR/sources ]]; then
474 mkdir -p $BUILDDIR/sources
475fi
476#
477# Create the log directory
478if [[ ! -d $LOGDIR ]]; then
479 mkdir $LOGDIR
480fi
481>$LOGDIR/$LOG
482#
[a229600]483[[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
[a0f0bee]484#
[877cc6a]485if [[ "$PWD" != "$JHALFSDIR" ]]; then
[a858a78]486 cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
[a229600]487 #
[1b65a84]488 [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
[a229600]489 #
[45f82718]490 if [[ "$COMPARE" != "0" ]] ; then
491 mkdir -p $JHALFSDIR/extras
492 cp extras/* $JHALFSDIR/extras
493 fi
[a0f0bee]494 #
[877cc6a]495 if [[ -n "$FILES" ]]; then
496 # pushd/popd necessary to deal with mulitiple files
497 pushd $PACKAGE_DIR 1> /dev/null
498 cp $FILES $JHALFSDIR/
499 popd 1> /dev/null
500 fi
[a0f0bee]501 #
[1ec8fce]502 if [[ "$REPORT" = "1" ]]; then
503 cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
504 # After be sure that all look sane, dump the settings to a file
505 # This file will be used to create the REPORT header
506 validate_config > $JHALFSDIR/jhalfs.config
[8d0fa35]507 fi
[a0f0bee]508 #
[1ec8fce]509 [[ "$GETPKG" = "1" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
[a160d86]510 cp $COMMON_DIR/packages.xsl $JHALFSDIR/
[1ec8fce]511 #
[877cc6a]512 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
513 export XSL=$JHALFSDIR/${XSL}
514fi
515
516get_book
[21f0a91]517echo "${SD_BORDER}${nl_}"
[877cc6a]518
519build_Makefile
[21f0a91]520echo "${SD_BORDER}${nl_}"
[877cc6a]521
522run_make
Note: See TracBrowser for help on using the repository browser.