source: master.sh@ c16cedc

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

Placing current switches in alphabetical order.

  • Property mode set to 100755
File size: 8.0 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() {
[d95b8f2]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"
44 PACKAGE_DIR=$(echo $PROGNAME | tr [a-z] [A-Z])
45 MODULE=$PACKAGE_DIR/master.sh
46MODULE_CONFIG=$PACKAGE_DIR/config
47
48echo -n "Loading common-functions module..."
49source $COMMON_DIR/common-functions
50[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
51echo "OK"
52#
53
54echo -n "Loading masterscript conf..."
55source $COMMON_DIR/config
[13e816f]56[[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
[0170229]57echo "OK"
58#
59echo -n "Loading config module <$MODULE_CONFIG>..."
60source $MODULE_CONFIG
61[[ $? > 0 ]] && echo "$MODULE_CONFIG did not load.." && exit 1
62echo "OK"
63#
64echo -n "Loading code module <$MODULE>..."
65source $MODULE
[12a5707]66[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
[0170229]67echo "OK"
68#
69echo "---------------${nl_}"
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#*******************************************************************#
[12a5707]81echo -n "Loading function <func_check_version.sh>..."
82source $COMMON_DIR/func_check_version.sh
83[[ $? > 0 ]] && echo " function module did not load.." && exit 2
84echo "OK"
[0170229]85
[12a5707]86echo -n "Loading function <func_validate_configs.sh>..."
87source $COMMON_DIR/func_validate_configs.sh
88[[ $? > 0 ]] && echo " function module did not load.." && exit 2
89echo "OK"
90echo "---------------${nl_}"
[0170229]91
92
93###################################
94### MAIN ###
95###################################
96
97# Evaluate any command line switches
98
99while test $# -gt 0 ; do
100 case $1 in
[5627958]101 --book | -B )
[0170229]102 test $# = 1 && eval "$exit_missing_arg"
103 shift
104 case $1 in
105 dev* | SVN | trunk )
106 LFSVRS=development
107 ;;
[5627958]108 *) if [[ "$PROGNAME" = "lfs" ]]; then
109 case $1 in
[d95b8f2]110 6.1.1 )
111 echo "For stable 6.1.1 book, please use jhalfs-0.2."
112 exit 0
113 ;;
114 alpha*) LFSVRS=alphabetical ;;
115 udev*) LFSVRS=udev_update ;;
116 * ) echo "$1 is an unsupported version at this time." ;;
[5627958]117 esac
118 else
119 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]120 exit 0
121 fi
[0170229]122 ;;
123 esac
124 ;;
125
[c16cedc]126 --directory | -D )
[0170229]127 test $# = 1 && eval "$exit_missing_arg"
128 shift
129 BUILDDIR=$1
130 JHALFSDIR=$BUILDDIR/jhalfs
131 LOGDIR=$JHALFSDIR/logs
[a6b81cd]132 MKFILE=$JHALFSDIR/Makefile
[0170229]133 ;;
134
[c16cedc]135 --fstab | -F )
136 test $# = 1 && eval "$exit_missing_arg"
137 shift
138 if [ -f $1 ] ; then
139 FSTAB=$1
140 else
141 echo -e "\nFile $1 not found. Verify your command line.\n"
142 exit 1
143 fi
144 ;;
145
146 --get-packages | -G ) HPKG=1 ;;
147
148 --help | -h )
149 if [[ "$PROGNAME" = "blfs" ]]; then
150 blfs_usage
151 else
152 usage
153 fi
154 ;;
155
156 --kernel-config | -K )
157 test $# = 1 && eval "$exit_missing_arg"
158 shift
159 if [ -f $1 ] ; then
160 CONFIG=$1
161 else
162 echo -e "\nFile $1 not found. Verify your command line.\n"
163 exit 1
164 fi
165 ;;
166
167 --make | -M ) RUNMAKE=1 ;;
168
169 --rebuild | -R ) CLEAN=1 ;;
170
171 --testsuites | -T )
172 test $# = 1 && eval "$exit_missing_arg"
173 shift
174 case $1 in
175 0 | 1 | 2 | 3 )
176 TEST=$1
177 ;;
178 * )
179 echo -e "\n$1 isn't a valid testsuites level value."
180 echo -e "You must to use 0, 1, 2, or 3.\n"
181 exit 1
182 ;;
183 esac
184 ;;
185
186 --version | -V )
187 clear
188 echo "$version"
189 exit 0
190 ;;
191
[0170229]192 --working-copy | -W )
193 test $# = 1 && eval "$exit_missing_arg"
194 shift
[5627958]195 case $PROGNAME in # Poor checks. We should find better ones.
196 lfs)
197 if [ -f $1/patches.ent ] ; then
198 WC=1
199 BOOK=$1
200 else
201 echo -e "\nLook like $1 isn't a LFS working copy."
202 exit 1
203 fi
204 ;;
205 clfs)
206 if [ -f $1/patches.ent ] && [ -f $1/packages.ent ]; then
207 WC=1
208 BOOK=$1
209 else
210 echo -e "\nLook like $1 isn't a CLFS working copy."
211 exit 1
212 fi
213 ;;
214 hlfs)
215 if [ -f $1/template.xml ] ; then
216 WC=1
217 BOOK=$1
218 else
219 echo -e "\nLook like $1 isn't a HLFS working copy."
220 exit 1
221 fi
222 ;;
223 blfs)
224 if [ -f $1/use-unzip.xml ] ; then
225 WC=1
226 BOOK=$1
227 else
228 echo -e "\nLook like $1 isn't a BLFS working copy."
229 exit 1
230 fi
231 ;;
[0170229]232
233 * )
234 if [[ "$PROGNAME" = "blfs" ]]; then
235 blfs_usage
236 else
237 usage
238 fi
239 ;;
240 esac
241 shift
242done
243
244# Find the download client to use, if not already specified.
245
246if [ -z $DL ] ; then
247 if [ `type -p wget` ] ; then
248 DL=wget
249 elif [ `type -p curl` ] ; then
250 DL=curl
251 else
252 eval "$no_dl_client"
253 fi
254fi
255
256#===================================================
257# Set the document location...
[13e816f]258# BOOK is either defined in
[0170229]259# xxx.config
260# comand line
[13e816f]261# default
[d95b8f2]262# If set by conf file or cmd line leave it
[0170229]263# alone otherwise load the default version
264#===================================================
265BOOK=${BOOK:=$PROGNAME-$LFSVRS}
266#===================================================
267
[13e816f]268
269# Check for minumum gcc and kernel versions
270#check_requirements 1 # 0/1 0-do not display values.
271check_version "2.6.2" "`uname -r`" "KERNEL"
272check_version "3.0" "$BASH_VERSION" "BASH"
273check_version "3.0" "`gcc -dumpversion`" "GCC"
[e1edff3]274tarVer=`tar --version`
275check_version "1.15.0" "${tarVer##* }" "TAR"
[13e816f]276echo "---------------${nl_}"
277
278validate_config 1 # 0/1 0-do not display values
279echo "---------------${nl_}"
280
[164afa2]281echo -n "Are you happy with that settings? yes/no (no): "
[13e816f]282read ANSWER
283if [ x$ANSWER != "xyes" ] ; then
284 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
285 exit 1
286fi
287
288# Prevents setting "-d /" by mistake.
289
290if [ $BUILDDIR = / ] ; then
291 echo -ne "\nThe root directory can't be used to build LFS.\n\n"
292 exit 1
293fi
294
295# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
296# and notify the user about that.
297
298if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
299 eval "$no_empty_builddir"
300fi
301
302# If requested, clean the build directory
303clean_builddir
304
[0170229]305if [[ ! -d $JHALFSDIR ]]; then
306 mkdir -pv $JHALFSDIR
307fi
308
[13e816f]309if [[ "$PWD" != "$JHALFSDIR" ]]; then
[12a5707]310 cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
[0170229]311 if [[ -n "$FILES" ]]; then
[9c90294]312 # pushd/popd necessary to deal with mulitiple files
313 pushd $PACKAGE_DIR
314 cp -v $FILES $JHALFSDIR/
315 popd
[0170229]316 fi
[12a5707]317 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
[0170229]318 export XSL=$JHALFSDIR/${XSL}
319fi
320
321if [[ ! -d $LOGDIR ]]; then
322 mkdir -v $LOGDIR
323fi
324>$LOGDIR/$LOG
325echo "---------------${nl_}"
326
327get_book
328echo "---------------${nl_}"
[12a5707]329
[0170229]330build_Makefile
331echo "---------------${nl_}"
[12a5707]332
[386bc75]333run_make
[0170229]334
Note: See TracBrowser for help on using the repository browser.