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
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() {
[9e627f6]17 echo -e "\n${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\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
[1ad9211]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
[12a5707]47
[0170229]48
[1ad9211]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"
[9e627f6]53
[1ad9211]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 )
[398a037]81 case $PROGNAME in
82 clfs2 ) TREE=branches/clfs-2.0/BOOK ;;
83 *) TREE=trunk/BOOK ;;
84 esac
85 LFSVRS=development
86 ;;
87 branch-* )
[1ad9211]88 LFSVRS=${BRANCH_ID}
89 TREE=branches/${BRANCH_ID#branch-}/BOOK
[398a037]90 ;;
91 * )
92 case $PROGNAME in
93 lfs | hlfs )
[1ad9211]94 LFSVRS=${BRANCH_ID}
[398a037]95 TREE=tags/${BRANCH_ID}/BOOK
[1ad9211]96 ;;
[398a037]97 clfs | clfs2 )
[1ad9211]98 LFSVRS=${BRANCH_ID}
99 TREE=tags/${BRANCH_ID}
100 ;;
[398a037]101 esac
102 ;;
[1ad9211]103 esac
[613d46b]104fi
[1ad9211]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}
[0170229]123
[47fddc8]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
[0170229]137#===========================================================
138# If the var BOOK contains something then, maybe, it points
139# to a working doc.. set WC=1, else 'null'
140#===========================================================
[1ad9211]141WC=${BOOK:+y}
[0170229]142#===========================================================
143
[1ad9211]144#===================================================
145# Set the document location...
146#===================================================
147BOOK=${BOOK:=$PROGNAME-$LFSVRS}
148#===================================================
149
[0170229]150
151#*******************************************************************#
[26a8fdf]152[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
[12a5707]153source $COMMON_DIR/func_check_version.sh
154[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[26a8fdf]155[[ $VERBOSITY > 0 ]] && echo "OK"
[0170229]156
[26a8fdf]157[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
[12a5707]158source $COMMON_DIR/func_validate_configs.sh
159[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[26a8fdf]160[[ $VERBOSITY > 0 ]] && echo "OK"
[65d83a6]161[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
[0170229]162
163
164###################################
[4612459]165### MAIN ###
[0170229]166###################################
167
[47fddc8]168# Check for minimum bash,tar,gcc and kernel versions
[f15fe85]169echo
[13e816f]170check_version "2.6.2" "`uname -r`" "KERNEL"
171check_version "3.0" "$BASH_VERSION" "BASH"
172check_version "3.0" "`gcc -dumpversion`" "GCC"
[e35e794]173tarVer=`tar --version | head -n1 | cut -d " " -f4`
174check_version "1.15.0" "${tarVer}" "TAR"
[65d83a6]175echo "${SD_BORDER}${nl_}"
[13e816f]176
[3051f95]177validate_config
[65d83a6]178echo "${SD_BORDER}${nl_}"
[7e6ddf0]179echo -n "Are you happy with these settings? yes/no (no): "
[13e816f]180read ANSWER
181if [ x$ANSWER != "xyes" ] ; then
182 echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
183 exit 1
184fi
[65d83a6]185echo "${nl_}${SD_BORDER}${nl_}"
[13e816f]186
[3a27393]187# Load additional modules or configuration files based on global settings
[bb8e6bc]188# compare module
[47fddc8]189if [[ "$COMPARE" = "y" ]]; then
[bb8e6bc]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#
[2c2471d]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"
[3a27393]202 #
203 # optimize configurations
[bb8e6bc]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"
[3a27393]208 # Validate optimize settings, if required
209 validate_opt_settings
[bb8e6bc]210fi
211#
212
[13e816f]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
[0170229]222if [[ ! -d $JHALFSDIR ]]; then
[a110145]223 mkdir -p $JHALFSDIR
[0170229]224fi
[3a27393]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#
[e35e794]237[[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
[3a27393]238#
[1ad9211]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
[0170229]246fi
[1ad9211]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}
[0170229]268
269get_book
[65d83a6]270echo "${SD_BORDER}${nl_}"
[12a5707]271
[0170229]272build_Makefile
[65d83a6]273echo "${SD_BORDER}${nl_}"
[12a5707]274
[386bc75]275run_make
Note: See TracBrowser for help on using the repository browser.