source: master.sh@ d2a9d60

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

Fixed udev_update branch support.

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