source: master.sh@ 4bf0fc3

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

Typo

  • Property mode set to 100755
File size: 7.4 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() {
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
[12a5707]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
[13e816f]57[[ $? > 0 ]] && echo "$COMMON_DIR/conf did not load.." && exit
[0170229]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
[12a5707]67[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
[0170229]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#*******************************************************************#
[12a5707]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"
[0170229]86
[12a5707]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_}"
[0170229]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 * )
131 echo "$1 is an unsupported version at this time."
132 exit 1
133 ;;
134 esac
135 ;;
136
137 --directory | -d )
138 test $# = 1 && eval "$exit_missing_arg"
139 shift
140 BUILDDIR=$1
141 JHALFSDIR=$BUILDDIR/jhalfs
142 LOGDIR=$JHALFSDIR/logs
143 MKFILE=$JHALFSDIR/${PROGNAME}-Makefile
144 ;;
145
146 --rebuild ) CLEAN=1 ;;
147
148 --download-client | -D )
149 echo "The download feature is temporarily disable.."
150 exit
151 test $# = 1 && eval "$exit_missing_arg"
152 shift
153 DL=$1
154 ;;
155
156 --working-copy | -W )
157 test $# = 1 && eval "$exit_missing_arg"
158 shift
159 if [ -f $1/patches.ent ] ; then
160 WC=1
161 BOOK=$1
162 else
163 echo -e "\nLook like $1 isn't a supported working copy."
164 echo -e "Verify your selection and the command line.\n"
165 exit 1
166 fi
167 ;;
168
169 --testsuites | -T ) TEST=1 ;;
170 --get-packages | -P ) HPKG=1 ;;
171 --run-make | -M ) RUNMAKE=1 ;;
172 --no-toolchain-test ) TOOLCHAINTEST=0 ;;
173 --no-strip ) STRIP=0 ;;
174 --no-vim-lang ) VIMLANG=0 ;;
175
176 --page_size )
177 test $# = 1 && eval "$exit_missing_arg"
178 shift
179 case $1 in
180 letter | A4 )
181 PAGE=$1
182 ;;
183 * )
184 echo "$1 isn't a supported page size."
185 exit 1
186 ;;
187 esac
188 ;;
189
190 --timezone )
191 test $# = 1 && eval "$exit_missing_arg"
192 shift
193 if [ -f /usr/share/zoneinfo/$1 ] ; then
194 TIMEZONE=$1
195 else
196 echo -e "\nLooks like $1 isn't a valid timezone description."
197 echo -e "Verify your selection and the command line.\n"
198 exit 1
199 fi
200 ;;
201
202 --fstab )
203 test $# = 1 && eval "$exit_missing_arg"
204 shift
205 if [ -f $1 ] ; then
206 FSTAB=$1
207 else
208 echo -e "\nFile $1 not found. Verify your command line.\n"
209 exit 1
210 fi
211 ;;
212
213 --kernel-config | -C )
214 test $# = 1 && eval "$exit_missing_arg"
215 shift
216 if [ -f $1 ] ; then
217 CONFIG=$1
218 else
219 echo -e "\nFile $1 not found. Verify your command line.\n"
220 exit 1
221 fi
222 ;;
223
224 * )
225 if [[ "$PROGNAME" = "blfs" ]]; then
226 blfs_usage
227 else
228 usage
229 fi
230 ;;
231 esac
232 shift
233done
234
235# Find the download client to use, if not already specified.
236
237if [ -z $DL ] ; then
238 if [ `type -p wget` ] ; then
239 DL=wget
240 elif [ `type -p curl` ] ; then
241 DL=curl
242 else
243 eval "$no_dl_client"
244 fi
245fi
246
247#===================================================
248# Set the document location...
[13e816f]249# BOOK is either defined in
[0170229]250# xxx.config
251# comand line
[13e816f]252# default
[0170229]253# If set by conf file leave or cmd line leave it
254# alone otherwise load the default version
255#===================================================
256BOOK=${BOOK:=$PROGNAME-$LFSVRS}
257#===================================================
258
[13e816f]259
260# Check for minumum gcc and kernel versions
261#check_requirements 1 # 0/1 0-do not display values.
262check_version "2.6.2" "`uname -r`" "KERNEL"
263check_version "3.0" "$BASH_VERSION" "BASH"
264check_version "3.0" "`gcc -dumpversion`" "GCC"
265echo "---------------${nl_}"
266
267validate_config 1 # 0/1 0-do not display values
268echo "---------------${nl_}"
269
[164afa2]270echo -n "Are you happy with that settings? yes/no (no): "
[13e816f]271read ANSWER
272if [ x$ANSWER != "xyes" ] ; then
273 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
274 exit 1
275fi
276
277# Prevents setting "-d /" by mistake.
278
279if [ $BUILDDIR = / ] ; then
280 echo -ne "\nThe root directory can't be used to build LFS.\n\n"
281 exit 1
282fi
283
284# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
285# and notify the user about that.
286
287if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
288 eval "$no_empty_builddir"
289fi
290
291# If requested, clean the build directory
292clean_builddir
293
[0170229]294if [[ ! -d $JHALFSDIR ]]; then
295 mkdir -pv $JHALFSDIR
296fi
297
[13e816f]298if [[ "$PWD" != "$JHALFSDIR" ]]; then
[12a5707]299 cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
[0170229]300 if [[ -n "$FILES" ]]; then
[13e816f]301 cp -v $PACKAGE_DIR/$FILES $JHALFSDIR/
[0170229]302 fi
[12a5707]303 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
[0170229]304 export XSL=$JHALFSDIR/${XSL}
305fi
306
307if [[ ! -d $LOGDIR ]]; then
308 mkdir -v $LOGDIR
309fi
310>$LOGDIR/$LOG
311echo "---------------${nl_}"
312
313get_book
314echo "---------------${nl_}"
[12a5707]315
[0170229]316build_Makefile
317echo "---------------${nl_}"
[12a5707]318
[0170229]319#run_make
320
Note: See TracBrowser for help on using the repository browser.