source: master.sh@ 1ad9211

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

Removed cmdline support and config files.
Several envar settings could be moved from master.sh to Config.in to keep it centralized.

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