source: master.sh@ 6c7fe49

experimental
Last change on this file since 6c7fe49 was 6c7fe49, checked in by George Boudreau <georgeb@…>, 19 years ago

master.sh, corrected my terrible grammar, wil add a spel and grama cheker to mi editer reel soon

  • Property mode set to 100755
File size: 8.1 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-X${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 *) if [[ "$PROGNAME" = "lfs" ]]; then
124 case $1 in
125 6.1.1 )
126 echo "For stable 6.1.1 book, please use jhalfs-0.2."
127 exit 0
128 ;;
129 alpha*) LFSVRS=alphabetical ;;
130 udev*) LFSVRS=udev_update ;;
131 * ) echo "$1 is an unsupported version at this time." ;;
132 esac
133 else
134 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."
135 exit 0
136 fi
137 ;;
138 esac
139 ;;
140
141 --directory | -d )
142 test $# = 1 && eval "$exit_missing_arg"
143 shift
144 BUILDDIR=$1
145 JHALFSDIR=$BUILDDIR/jhalfs
146 LOGDIR=$JHALFSDIR/logs
147 MKFILE=$JHALFSDIR/${PROGNAME}-Makefile
148 ;;
149
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 --rebuild ) CLEAN=1 ;;
192
193 --page_size )
194 test $# = 1 && eval "$exit_missing_arg"
195 shift
196 case $1 in
197 letter | A4 )
198 PAGE=$1
199 ;;
200 * )
201 echo "$1 isn't a supported page size."
202 exit 1
203 ;;
204 esac
205 ;;
206
207 --timezone )
208 test $# = 1 && eval "$exit_missing_arg"
209 shift
210 if [ -f /usr/share/zoneinfo/$1 ] ; then
211 TIMEZONE=$1
212 else
213 echo -e "\nLooks like $1 isn't a valid timezone description."
214 echo -e "Verify your selection and the command line.\n"
215 exit 1
216 fi
217 ;;
218
219 --fstab )
220 test $# = 1 && eval "$exit_missing_arg"
221 shift
222 if [ -f $1 ] ; then
223 FSTAB=$1
224 else
225 echo -e "\nFile $1 not found. Verify your command line.\n"
226 exit 1
227 fi
228 ;;
229
230 --kernel-config | -C )
231 test $# = 1 && eval "$exit_missing_arg"
232 shift
233 if [ -f $1 ] ; then
234 CONFIG=$1
235 else
236 echo -e "\nFile $1 not found. Verify your command line.\n"
237 exit 1
238 fi
239 ;;
240
241 * )
242 if [[ "$PROGNAME" = "blfs" ]]; then
243 blfs_usage
244 else
245 usage
246 fi
247 ;;
248 esac
249 shift
250done
251
252# Find the download client to use, if not already specified.
253
254if [ -z $DL ] ; then
255 if [ `type -p wget` ] ; then
256 DL=wget
257 elif [ `type -p curl` ] ; then
258 DL=curl
259 else
260 eval "$no_dl_client"
261 fi
262fi
263
264#===================================================
265# Set the document location...
266# BOOK is either defined in
267# xxx.config
268# comand line
269# default
270# If set by conf file or cmd line leave it
271# alone otherwise load the default version
272#===================================================
273BOOK=${BOOK:=$PROGNAME-$LFSVRS}
274#===================================================
275
276
277# Check for minumum gcc and kernel versions
278#check_requirements 1 # 0/1 0-do not display values.
279check_version "2.6.2" "`uname -r`" "KERNEL"
280check_version "3.0" "$BASH_VERSION" "BASH"
281check_version "3.0" "`gcc -dumpversion`" "GCC"
282tarVer=`tar --version`
283check_version "1.15.0" "${tarVer##* }" "TAR"
284echo "---------------${nl_}"
285
286validate_config 1 # 0/1 0-do not display values
287echo "---------------${nl_}"
288
289echo -n "Are you happy with that settings? yes/no (no): "
290read ANSWER
291if [ x$ANSWER != "xyes" ] ; then
292 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
293 exit 1
294fi
295
296# Prevents setting "-d /" by mistake.
297
298if [ $BUILDDIR = / ] ; then
299 echo -ne "\nThe root directory can't be used to build LFS.\n\n"
300 exit 1
301fi
302
303# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
304# and notify the user about that.
305
306if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
307 eval "$no_empty_builddir"
308fi
309
310# If requested, clean the build directory
311clean_builddir
312
313if [[ ! -d $JHALFSDIR ]]; then
314 mkdir -pv $JHALFSDIR
315fi
316
317if [[ "$PWD" != "$JHALFSDIR" ]]; then
318 cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
319 if [[ -n "$FILES" ]]; then
320 # pushd/popd necessary to deal with mulitiple files
321 pushd $PACKAGE_DIR
322 cp -v $FILES $JHALFSDIR/
323 popd
324 fi
325 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
326 export XSL=$JHALFSDIR/${XSL}
327fi
328
329if [[ ! -d $LOGDIR ]]; then
330 mkdir -v $LOGDIR
331fi
332>$LOGDIR/$LOG
333echo "---------------${nl_}"
334
335get_book
336echo "---------------${nl_}"
337
338build_Makefile
339echo "---------------${nl_}"
340
341run_make
342
Note: See TracBrowser for help on using the repository browser.