1 | #!/bin/bash
|
---|
2 | # $Id$
|
---|
3 | set -e
|
---|
4 |
|
---|
5 |
|
---|
6 | #>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
---|
7 | #-----------------------#
|
---|
8 | simple_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 |
|
---|
16 | see_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 | #####
|
---|
30 | set -e
|
---|
31 | trap see_ya 0
|
---|
32 | trap simple_error ERR
|
---|
33 | trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
|
---|
34 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
35 |
|
---|
36 |
|
---|
37 | if [ ! -L $0 ] ; then
|
---|
38 | echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
|
---|
39 | exit 1
|
---|
40 | fi
|
---|
41 |
|
---|
42 | PROGNAME=$(basename $0)
|
---|
43 | COMMON_DIR="common"
|
---|
44 | PACKAGE_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>..."
|
---|
50 | source configuration
|
---|
51 | [[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
|
---|
52 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
53 |
|
---|
54 | #--- Envars not sourced from configuration (yet)
|
---|
55 | declare -r SVN="svn://svn.linuxfromscratch.org"
|
---|
56 | declare -r LOG=000-masterscript.log
|
---|
57 |
|
---|
58 | case $PROGNAME in
|
---|
59 | clfs2) LFSVRS=development; TREE=branches/clfs-2.0/BOOK ;;
|
---|
60 | *) LFSVRS=development; TREE=trunk/BOOK ;;
|
---|
61 | esac
|
---|
62 |
|
---|
63 | if [[ ! -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
|
---|
89 | fi
|
---|
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.
|
---|
96 | RUNMAKE=${RUNMAKE:-n}
|
---|
97 | GETPKG=${GETPKG:-n}
|
---|
98 | GETKERNEL=${GETKERNEL:-n}
|
---|
99 | COMPARE=${COMPARE:-n}
|
---|
100 | RUN_FARCE=${RUN_FARCE:-n}
|
---|
101 | RUN_ICA=${RUN_ICA:-n}
|
---|
102 | BOMB_TEST=${BOMB_TEST:-n}
|
---|
103 | STRIP=${STRIP:=n}
|
---|
104 | REPORT=${REPORT:=n}
|
---|
105 | VIMLANG=${VIMLANG:-n}
|
---|
106 | KEYMAP=${KEYMAP:=none}
|
---|
107 | GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
---|
108 |
|
---|
109 |
|
---|
110 | [[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
|
---|
111 | source $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>..."
|
---|
115 | source $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 | #===========================================================
|
---|
126 | WC=${BOOK:+y}
|
---|
127 | #===========================================================
|
---|
128 |
|
---|
129 | #===================================================
|
---|
130 | # Set the document location...
|
---|
131 | #===================================================
|
---|
132 | BOOK=${BOOK:=$PROGNAME-$LFSVRS}
|
---|
133 | #===================================================
|
---|
134 |
|
---|
135 |
|
---|
136 | #*******************************************************************#
|
---|
137 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
|
---|
138 | source $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>..."
|
---|
143 | source $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
|
---|
154 | echo
|
---|
155 | check_version "2.6.2" "`uname -r`" "KERNEL"
|
---|
156 | check_version "3.0" "$BASH_VERSION" "BASH"
|
---|
157 | check_version "3.0" "`gcc -dumpversion`" "GCC"
|
---|
158 | tarVer=`tar --version | head -n1 | cut -d " " -f4`
|
---|
159 | check_version "1.15.0" "${tarVer}" "TAR"
|
---|
160 | echo "${SD_BORDER}${nl_}"
|
---|
161 |
|
---|
162 | validate_config
|
---|
163 | echo "${SD_BORDER}${nl_}"
|
---|
164 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
165 | read ANSWER
|
---|
166 | if [ x$ANSWER != "xyes" ] ; then
|
---|
167 | echo "${nl_}Fix the configuration options and rerun the script.${nl_}"
|
---|
168 | exit 1
|
---|
169 | fi
|
---|
170 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
171 |
|
---|
172 | # Load additional modules or configuration files based on global settings
|
---|
173 | # compare module
|
---|
174 | if [[ "$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"
|
---|
179 | fi
|
---|
180 | #
|
---|
181 | # optimize module
|
---|
182 | if [[ "$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
|
---|
195 | fi
|
---|
196 | #
|
---|
197 |
|
---|
198 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
199 | # and notify the user about that.
|
---|
200 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
201 | eval "$no_empty_builddir"
|
---|
202 | fi
|
---|
203 |
|
---|
204 | # If requested, clean the build directory
|
---|
205 | clean_builddir
|
---|
206 |
|
---|
207 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
208 | mkdir -p $JHALFSDIR
|
---|
209 | fi
|
---|
210 | #
|
---|
211 | # Create $BUILDDIR/sources even though it could be created by get_sources()
|
---|
212 | if [[ ! -d $BUILDDIR/sources ]]; then
|
---|
213 | mkdir -p $BUILDDIR/sources
|
---|
214 | fi
|
---|
215 | #
|
---|
216 | # Create the log directory
|
---|
217 | if [[ ! -d $LOGDIR ]]; then
|
---|
218 | mkdir $LOGDIR
|
---|
219 | fi
|
---|
220 | >$LOGDIR/$LOG
|
---|
221 | #
|
---|
222 | [[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
|
---|
223 | #
|
---|
224 | cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
|
---|
225 | #
|
---|
226 | [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
|
---|
227 | #
|
---|
228 | if [[ "$COMPARE" = "y" ]]; then
|
---|
229 | mkdir -p $JHALFSDIR/extras
|
---|
230 | cp extras/* $JHALFSDIR/extras
|
---|
231 | fi
|
---|
232 | #
|
---|
233 | if [[ -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
|
---|
238 | fi
|
---|
239 | #
|
---|
240 | if [[ "$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
|
---|
245 | fi
|
---|
246 | #
|
---|
247 | [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
|
---|
248 | #
|
---|
249 | cp $COMMON_DIR/packages.xsl $JHALFSDIR/
|
---|
250 | #
|
---|
251 | sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
|
---|
252 | export XSL=$JHALFSDIR/${XSL}
|
---|
253 |
|
---|
254 | get_book
|
---|
255 | echo "${SD_BORDER}${nl_}"
|
---|
256 |
|
---|
257 | build_Makefile
|
---|
258 | echo "${SD_BORDER}${nl_}"
|
---|
259 |
|
---|
260 | run_make
|
---|