source: master.sh@ d43a271

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

CLFS/master.sh, boot method now has its own makefile-. text changes to makefile-functions.

  • Property mode set to 100755
File size: 8.1 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
101 --version | -V )
102 clear
103 echo "$version"
104 exit 0
105 ;;
106
107 --help | -h )
108 if [[ "$PROGNAME" = "blfs" ]]; then
109 blfs_usage
110 else
111 usage
112 fi
113 ;;
114
115 --LFS-version | -L )
116 test $# = 1 && eval "$exit_missing_arg"
117 shift
118 case $1 in
119 dev* | SVN | trunk )
120 LFSVRS=development
121 ;;
[d95b8f2]122 *) if [[ "$PROGNAME" = "lfs" ]]; then
123 case $1 in
124 6.1.1 )
125 echo "For stable 6.1.1 book, please use jhalfs-0.2."
126 exit 0
127 ;;
128 alpha*) LFSVRS=alphabetical ;;
129 udev*) LFSVRS=udev_update ;;
130 * ) echo "$1 is an unsupported version at this time." ;;
131 esac
132 else
[6c7fe49]133 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]134 exit 0
135 fi
[0170229]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
[d95b8f2]149
[0170229]150 --download-client | -D )
151 echo "The download feature is temporarily disable.."
152 exit
153 test $# = 1 && eval "$exit_missing_arg"
154 shift
155 DL=$1
156 ;;
157
158 --working-copy | -W )
159 test $# = 1 && eval "$exit_missing_arg"
160 shift
161 if [ -f $1/patches.ent ] ; then
[d95b8f2]162 WC=1
163 BOOK=$1
[0170229]164 else
165 echo -e "\nLook like $1 isn't a supported working copy."
166 echo -e "Verify your selection and the command line.\n"
167 exit 1
168 fi
169 ;;
170
[8ab950f]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
[d95b8f2]186 --get-packages | -P ) HPKG=1 ;;
187 --run-make | -M ) RUNMAKE=1 ;;
188 --no-strip ) STRIP=0 ;;
189 --no-vim-lang ) VIMLANG=0 ;;
190 --rebuild ) CLEAN=1 ;;
[0170229]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...
[13e816f]265# BOOK is either defined in
[0170229]266# xxx.config
267# comand line
[13e816f]268# default
[d95b8f2]269# If set by conf file or cmd line leave it
[0170229]270# alone otherwise load the default version
271#===================================================
272BOOK=${BOOK:=$PROGNAME-$LFSVRS}
273#===================================================
274
[13e816f]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"
[e1edff3]281tarVer=`tar --version`
282check_version "1.15.0" "${tarVer##* }" "TAR"
[13e816f]283echo "---------------${nl_}"
284
285validate_config 1 # 0/1 0-do not display values
286echo "---------------${nl_}"
287
[164afa2]288echo -n "Are you happy with that settings? yes/no (no): "
[13e816f]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
[0170229]312if [[ ! -d $JHALFSDIR ]]; then
313 mkdir -pv $JHALFSDIR
314fi
315
[13e816f]316if [[ "$PWD" != "$JHALFSDIR" ]]; then
[12a5707]317 cp -v $COMMON_DIR/makefile-functions $JHALFSDIR/
[0170229]318 if [[ -n "$FILES" ]]; then
[9c90294]319 # pushd/popd necessary to deal with mulitiple files
320 pushd $PACKAGE_DIR
321 cp -v $FILES $JHALFSDIR/
322 popd
[0170229]323 fi
[12a5707]324 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
[0170229]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_}"
[12a5707]336
[0170229]337build_Makefile
338echo "---------------${nl_}"
[12a5707]339
[386bc75]340run_make
[0170229]341
Note: See TracBrowser for help on using the repository browser.