source: master.sh@ 3c96826

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

Moved internal envars to Config.in

  • Property mode set to 100755
File size: 7.3 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${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\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 COMMON_DIR="common"
44PACKAGE_DIR=$(echo $PROGNAME | tr [a-z] [A-Z])
45 MODULE=$PACKAGE_DIR/master.sh
46 VERBOSITY=1
47
48
49[[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
50source configuration
51[[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
52[[ $VERBOSITY > 0 ]] && echo "OK"
53
54 #--- Envars not sourced from configuration (yet)
55declare -r SVN="svn://svn.linuxfromscratch.org"
56declare -r LOG=000-masterscript.log
57
58case $PROGNAME in
59 clfs2) LFSVRS=development; TREE=branches/clfs-2.0/BOOK ;;
60 *) LFSVRS=development; TREE=trunk/BOOK ;;
61esac
62
63if [[ ! -z ${BRANCH_ID} ]]; then
64 case $BRANCH_ID in
65 dev* | SVN | trunk )
66 case $PROGNAME in
67 clfs2 ) TREE=branches/clfs-2.0/BOOK ;;
68 *) TREE=trunk/BOOK ;;
69 esac
70 LFSVRS=development
71 ;;
72 branch-* )
73 LFSVRS=${BRANCH_ID}
74 TREE=branches/${BRANCH_ID#branch-}/BOOK
75 ;;
76 * )
77 case $PROGNAME in
78 lfs | hlfs )
79 LFSVRS=${BRANCH_ID}
80 TREE=tags/${BRANCH_ID}/BOOK
81 ;;
82 clfs | clfs2 )
83 LFSVRS=${BRANCH_ID}
84 TREE=tags/${BRANCH_ID}
85 ;;
86 esac
87 ;;
88 esac
89fi
90# These are boolean vars generated from Config.in.
91# ISSUE: If a boolean parameter is not set <true> that
92# variable is not defined by the menu app. This can
93# cause a headache if you are not careful.
94# The following parameters MUST be created and have a
95# default value.
96RUNMAKE=${RUNMAKE:-n}
97GETPKG=${GETPKG:-n}
98GETKERNEL=${GETKERNEL:-n}
99COMPARE=${COMPARE:-n}
100RUN_FARCE=${RUN_FARCE:-n}
101RUN_ICA=${RUN_ICA:-n}
102BOMB_TEST=${BOMB_TEST:-n}
103STRIP=${STRIP:=n}
104REPORT=${REPORT:=n}
105VIMLANG=${VIMLANG:-n}
106KEYMAP=${KEYMAP:=none}
107GRSECURITY_HOST=${GRSECURITY_HOST:-n}
108
109
110[[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
111source $COMMON_DIR/common-functions
112[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
113[[ $VERBOSITY > 0 ]] && echo "OK"
114[[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
115source $MODULE
116[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
117[[ $VERBOSITY > 0 ]] && echo "OK"
118#
119[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
120
121
122#===========================================================
123# If the var BOOK contains something then, maybe, it points
124# to a working doc.. set WC=1, else 'null'
125#===========================================================
126WC=${BOOK:+y}
127#===========================================================
128
129#===================================================
130# Set the document location...
131#===================================================
132BOOK=${BOOK:=$PROGNAME-$LFSVRS}
133#===================================================
134
135
136#*******************************************************************#
137[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
138source $COMMON_DIR/func_check_version.sh
139[[ $? > 0 ]] && echo " function module did not load.." && exit 2
140[[ $VERBOSITY > 0 ]] && echo "OK"
141
142[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
143source $COMMON_DIR/func_validate_configs.sh
144[[ $? > 0 ]] && echo " function module did not load.." && exit 2
145[[ $VERBOSITY > 0 ]] && echo "OK"
146[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
147
148
149###################################
150### MAIN ###
151###################################
152
153# Check for minimum bash,tar,gcc and kernel versions
154echo
155check_version "2.6.2" "`uname -r`" "KERNEL"
156check_version "3.0" "$BASH_VERSION" "BASH"
157check_version "3.0" "`gcc -dumpversion`" "GCC"
158tarVer=`tar --version | head -n1 | cut -d " " -f4`
159check_version "1.15.0" "${tarVer}" "TAR"
160echo "${SD_BORDER}${nl_}"
161
162validate_config
163echo "${SD_BORDER}${nl_}"
164echo -n "Are you happy with these settings? yes/no (no): "
165read ANSWER
166if [ x$ANSWER != "xyes" ] ; then
167 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
168 exit 1
169fi
170echo "${nl_}${SD_BORDER}${nl_}"
171
172# Load additional modules or configuration files based on global settings
173# compare module
174if [[ "$COMPARE" = "y" ]]; then
175 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
176 source $COMMON_DIR/func_compare.sh
177 [[ $? > 0 ]] && echo "$COMMON_DIR/func_compare.sh did not load.." && exit
178 [[ $VERBOSITY > 0 ]] && echo "OK"
179fi
180#
181# optimize module
182if [[ "$OPTIMIZE" != "0" ]]; then
183 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
184 source optimize/optimize_functions
185 [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
186 [[ $VERBOSITY > 0 ]] && echo "OK"
187 #
188 # optimize configurations
189 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
190 source optimize/opt_config
191 [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
192 [[ $VERBOSITY > 0 ]] && echo "OK"
193 # Validate optimize settings, if required
194 validate_opt_settings
195fi
196#
197
198# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
199# and notify the user about that.
200if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
201 eval "$no_empty_builddir"
202fi
203
204# If requested, clean the build directory
205clean_builddir
206
207if [[ ! -d $JHALFSDIR ]]; then
208 mkdir -p $JHALFSDIR
209fi
210#
211# Create $BUILDDIR/sources even though it could be created by get_sources()
212if [[ ! -d $BUILDDIR/sources ]]; then
213 mkdir -p $BUILDDIR/sources
214fi
215#
216# Create the log directory
217if [[ ! -d $LOGDIR ]]; then
218 mkdir $LOGDIR
219fi
220>$LOGDIR/$LOG
221#
222[[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
223#
224cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
225#
226[[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
227#
228if [[ "$COMPARE" = "y" ]]; then
229 mkdir -p $JHALFSDIR/extras
230 cp extras/* $JHALFSDIR/extras
231fi
232#
233if [[ -n "$FILES" ]]; then
234 # pushd/popd necessary to deal with multiple files
235 pushd $PACKAGE_DIR 1> /dev/null
236 cp $FILES $JHALFSDIR/
237 popd 1> /dev/null
238fi
239#
240if [[ "$REPORT" = "y" ]]; then
241 cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
242 # After being sure that all looks sane, dump the settings to a file
243 # This file will be used to create the REPORT header
244 validate_config > $JHALFSDIR/jhalfs.config
245fi
246#
247[[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
248#
249cp $COMMON_DIR/packages.xsl $JHALFSDIR/
250#
251sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
252export XSL=$JHALFSDIR/${XSL}
253
254get_book
255echo "${SD_BORDER}${nl_}"
256
257build_Makefile
258echo "${SD_BORDER}${nl_}"
259
260run_make
Note: See TracBrowser for help on using the repository browser.