source: jhalfs@ 14a3e90

ablfs
Last change on this file since 14a3e90 was 1825286, checked in by Pierre Labastie <pierre@…>, 12 years ago

Merge trunk r3694

  • Property mode set to 100755
File size: 11.8 KB
Line 
1#!/bin/bash
2# $Id$
3set -e
4
5# VT100 colors
6declare -r BLACK=$'\e[1;30m'
7declare -r DK_GRAY=$'\e[0;30m'
8
9declare -r RED=$'\e[31m'
10declare -r GREEN=$'\e[32m'
11declare -r YELLOW=$'\e[33m'
12declare -r BLUE=$'\e[34m'
13declare -r MAGENTA=$'\e[35m'
14declare -r CYAN=$'\e[36m'
15declare -r WHITE=$'\e[37m'
16
17declare -r OFF=$'\e[0m'
18declare -r BOLD=$'\e[1m'
19declare -r REVERSE=$'\e[7m'
20declare -r HIDDEN=$'\e[8m'
21
22declare -r tab_=$'\t'
23declare -r nl_=$'\n'
24
25declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
26declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
27declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
28
29# bold yellow > < pair
30declare -r R_arrow=$'\e[1;33m>\e[0m'
31declare -r L_arrow=$'\e[1;33m<\e[0m'
32
33
34#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
35#-----------------------#
36simple_error() { # Basic error trap.... JUST DIE
37#-----------------------#
38 # If +e then disable text output
39 if [[ "$-" =~ e ]]; then
40 echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
41 fi
42}
43
44see_ya() {
45 echo -e "\n${L_arrow}${BOLD}jhalfs-trunk${R_arrow} exit${OFF}\n"
46}
47##### Simple error TRAPS
48# ctrl-c SIGINT
49# ctrl-y
50# ctrl-z SIGTSTP
51# SIGHUP 1 HANGUP
52# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
53# SIGQUIT 3
54# SIGKILL 9 KILL
55# SIGTERM 15 TERMINATION
56# SIGSTOP 17,18,23 STOP THE PROCESS
57#####
58set -e
59trap see_ya 0
60trap simple_error ERR
61trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
62#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
63
64version="
65${BOLD} \"jhalfs-trunk\"${OFF} builder tool (development) \$Rev$
66 \$Date$
67
68 Written by George Boudreau and Manuel Canales Esparcia,
69 plus several contributions.
70
71 Based on an idea from Jeremy Huntwork
72
73 This set of files are published under the
74 ${BOLD}Gnu General Public License, Version 2.${OFF}
75"
76
77case $1 in
78 -v ) echo "$version" && exit 1 ;;
79 run ) : ;;
80 * )
81 echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
82 exit 1
83 ;;
84esac
85
86# If the user has not saved his configuration file, let's ask
87# if he or she really wants to run this stuff
88if [ $(ls -l --time-style='+%Y%m%d%H%M%S' configuration.old | cut -d' ' -f 6) \
89 -ge $(ls -l --time-style='+%Y%m%d%H%M%S' configuration | cut -d' ' -f 6) ]
90 then echo -n "Do you want to run jhalfs? yes/no (yes): "
91 read ANSWER
92 if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
93 echo "${nl_}Exiting gracefully.${nl_}"
94 exit
95 fi
96fi
97
98# Change this to 0 to suppress almost all messages
99VERBOSITY=1
100
101[[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
102source configuration
103[[ $? > 0 ]] && echo "file: configuration did not load.." && exit 1
104[[ $VERBOSITY > 0 ]] && echo "OK"
105
106# These are boolean vars generated from Config.in.
107# ISSUE: If a boolean parameter is not set to y(es) there
108# is no variable defined by the menu app. This can
109# cause a headache if you are not aware.
110# The following variables MUST exist. If they don't, the
111# default value is n(o).
112RUNMAKE=${RUNMAKE:-n}
113GETPKG=${GETPKG:-n}
114COMPARE=${COMPARE:-n}
115RUN_FARCE=${RUN_FARCE:-n}
116RUN_ICA=${RUN_ICA:-n}
117PKGMNGT=${PKGMNGT:-n}
118BOMB_TEST=${BOMB_TEST:-n}
119STRIP=${STRIP:=n}
120REPORT=${REPORT:=n}
121VIMLANG=${VIMLANG:-n}
122FULL_LOCALE=${FULL_LOCALE:-n}
123GRSECURITY_HOST=${GRSECURITY_HOST:-n}
124CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
125REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
126INSTALL_LOG=${INSTALL_LOG:-n}
127CLEAN=${CLEAN:=n}
128SET_SSP=${SET_SSP:=n}
129SET_ASLR=${SET_ASLR:=n}
130SET_PAX=${SET_PAX:=n}
131SET_HARDENED_TMP=${SET_HARDENED_TMP:=n}
132SET_WARNINGS=${SET_WARNINGS:=n}
133SET_MISC=${SET_MISC:=n}
134SET_BLOWFISH=${SET_BLOWFISH:=n}
135
136if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
137 NO_PROGRESS="#"
138fi
139
140
141# Sanity check on the location of $BUILDDIR / $JHALFSDIR
142CWD=$(cd `dirname $0` && pwd)
143if [[ $JHALFSDIR == $CWD ]]; then
144 echo " The jhalfs source directory conflicts with the jhalfs build directory."
145 echo " Please move the source directory or change the build directory."
146 exit 2
147fi
148
149# Book sources envars
150BRANCH_ID=${BRANCH_ID:=development}
151
152case $BRANCH_ID in
153 development )
154 case $PROGNAME in
155 clfs2 ) TREE=branches/clfs-sysroot/BOOK ;;
156 clfs3 ) TREE=branches/clfs-embedded/BOOK ;;
157 *) TREE=trunk/BOOK ;;
158 esac
159 LFSVRS=development
160 ;;
161 *EDIT* ) echo " You forgot to set the branch or stable book version."
162 echo " Please rerun make and fix the configuration."
163 exit 2 ;;
164 branch-* )
165 LFSVRS=${BRANCH_ID}
166 TREE=branches/${BRANCH_ID#branch-}/BOOK
167 ;;
168 * )
169 case $PROGNAME in
170 lfs )
171 LFSVRS=${BRANCH_ID}
172 TREE=tags/${BRANCH_ID}
173 if (( ${BRANCH_ID:0:1} < 7 )) ; then
174 TREE=${TREE}/BOOK
175 fi
176 ;;
177 hlfs )
178 LFSVRS=${BRANCH_ID}
179 TREE=tags/${BRANCH_ID}/BOOK
180 ;;
181 clfs | clfs2 | clfs3)
182 LFSVRS=${BRANCH_ID}
183 TREE=tags/${BRANCH_ID}
184 ;;
185 esac
186 ;;
187esac
188
189# Set the document location...
190BOOK=${BOOK:=$JHALFSDIR/$PROGNAME-$LFSVRS}
191
192
193#--- Envars not sourced from configuration
194case $PROGNAME in
195# TODO: clfs is now on git
196# clfs* ) declare -r SVN="http://svn.cross-lfs.org/svn/repos" ;;
197 * ) declare -r SVN="svn://svn.linuxfromscratch.org" ;;
198esac
199declare -r LOG=000-masterscript.log
200 # Needed for fetching BLFS book sources when building CLFS
201declare -r SVN_2="svn://svn.linuxfromscratch.org"
202
203# Set true internal variables
204COMMON_DIR="common"
205PACKAGE_DIR=$(echo $PROGNAME | tr '[a-z]' '[A-Z]')
206MODULE=$PACKAGE_DIR/master.sh
207PKGMNGTDIR="pkgmngt"
208# The name packageManager.xml is hardcoded in *.xsl, so no variable.
209
210[[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
211source $COMMON_DIR/common-functions
212[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
213[[ $VERBOSITY > 0 ]] && echo "OK"
214[[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
215source $MODULE
216[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
217[[ $VERBOSITY > 0 ]] && echo "OK"
218#
219[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
220
221
222#*******************************************************************#
223[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
224source $COMMON_DIR/libs/func_check_version.sh
225[[ $? > 0 ]] && echo " function module did not load.." && exit 2
226[[ $VERBOSITY > 0 ]] && echo "OK"
227
228[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
229source $COMMON_DIR/libs/func_validate_configs.sh
230[[ $? > 0 ]] && echo " function module did not load.." && exit 2
231[[ $VERBOSITY > 0 ]] && echo "OK"
232
233[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_custom_pkgs>..."
234source $COMMON_DIR/libs/func_custom_pkgs
235[[ $? > 0 ]] && echo " function module did not load.." && exit 2
236[[ $VERBOSITY > 0 ]] && echo "OK"
237
238
239[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
240
241# blfs-tool envars
242BLFS_TOOL=${BLFS_TOOL:-n}
243if [[ "${BLFS_TOOL}" = "y" ]] ; then
244 BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
245 case $BLFS_BRANCH_ID in
246 development ) BLFS_TREE=trunk/BOOK ;;
247 *EDIT* ) echo " You forgot to set the BLFS branch or stable book version."
248 echo " Please rerun make and fix the configuration."
249 exit 2 ;;
250 branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
251 * ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
252 esac
253 [[ $VERBOSITY > 0 ]] && echo -n "Loading blfs tools installation function..."
254 source $COMMON_DIR/libs/func_install_blfs
255 [[ $? > 0 ]] && echo "function module did not load.." && exit 1
256 [[ $VERBOSITY > 0 ]] && echo "OK"
257fi
258
259###################################
260### MAIN ###
261###################################
262
263
264validate_config
265echo "${SD_BORDER}${nl_}"
266echo -n "Are you happy with these settings? yes/no (no): "
267read ANSWER
268if [ x$ANSWER != "xyes" ] ; then
269 echo "${nl_}Rerun make to fix the configuration options.${nl_}"
270 exit 1
271fi
272echo "${nl_}${SD_BORDER}${nl_}"
273
274# Load additional modules or configuration files based on global settings
275# compare module
276if [[ "$COMPARE" = "y" ]]; then
277 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
278 source $COMMON_DIR/libs/func_compare.sh
279 [[ $? > 0 ]] && echo "$COMMON_DIR/libs/func_compare.sh did not load.." && exit
280 [[ $VERBOSITY > 0 ]] && echo "OK"
281fi
282#
283# optimize module
284if [[ "$OPTIMIZE" != "0" ]]; then
285 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
286 source optimize/optimize_functions
287 [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
288 [[ $VERBOSITY > 0 ]] && echo "OK"
289 #
290 # optimize configurations
291 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
292 source optimize/opt_config
293 [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
294 [[ $VERBOSITY > 0 ]] && echo "OK"
295 # Validate optimize settings, if required
296 validate_opt_settings
297fi
298#
299
300if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
301
302 # If requested, clean the build directory
303 clean_builddir
304
305 if [[ ! -d $JHALFSDIR ]]; then
306 mkdir -p $JHALFSDIR
307 fi
308
309 # Create $BUILDDIR/sources even though it could be created by get_sources()
310 if [[ ! -d $BUILDDIR/sources ]]; then
311 mkdir -p $BUILDDIR/sources
312 fi
313 #
314 # Create the log directory
315 if [[ ! -d $LOGDIR ]]; then
316 mkdir $LOGDIR
317 fi
318 >$LOGDIR/$LOG
319 #
320 # Copy common helper files
321 cp $COMMON_DIR/{makefile-functions,progress_bar.sh,packages.xsl} $JHALFSDIR/
322 #
323 # Fix the XSL book parser
324 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
325 export XSL=$JHALFSDIR/${XSL}
326 #
327
328 # Copy packageManager.xml, if needed
329 [[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] &&
330 cp $PKGMNGTDIR/packageManager.xml $JHALFSDIR/ &&
331 cp $PKGMNGTDIR/packInstall.sh $JHALFSDIR/
332 #
333 # Copy urls.xsl, if needed
334 [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
335 #
336 # Create the test-log directory, if needed
337 [[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
338 #
339 # Create the installed-files directory, if needed
340 [[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 $FILELOGDIR
341 #
342 # Prepare report creation, if needed
343 if [[ "$REPORT" = "y" ]]; then
344 cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
345 # After making sure that all looks sane, dump the settings to a file
346 # This file will be used to create the REPORT header
347 validate_config > $JHALFSDIR/jhalfs.config
348 fi
349 #
350 # Copy optimize files, if needed
351 [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
352 #
353 # Copy compare files, if needed
354 if [[ "$COMPARE" = "y" ]]; then
355 mkdir -p $JHALFSDIR/extras
356 cp extras/* $JHALFSDIR/extras
357 fi
358 #
359 # Copy custom tools config files, if requested
360 if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
361 echo "Copying custom tool scripts to $JHALFSDIR"
362 mkdir -p $JHALFSDIR/custom-commands
363 cp -f custom/config/* $JHALFSDIR/custom-commands
364 fi
365 #
366 # Install blfs-tool, if requested.
367 if [[ "${BLFS_TOOL}" = "y" ]] ; then
368 echo Downloading and validating the BLFS book
369 echo '(may take some time...)'
370 install_blfs_tools 2>&1 | tee -a $LOGDIR/$LOG
371 fi
372 #
373
374# Download or updates the book source
375 get_book
376 extract_commands
377 echo "${SD_BORDER}${nl_}"
378
379fi
380
381# When regenerating the Makefile, we need to know also the
382# canonical book version
383if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
384 case $PROGNAME in
385 clfs | clfs2 | clfs3 )
386 VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
387 *)
388 VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
389 esac
390fi
391
392build_Makefile
393
394echo "${SD_BORDER}${nl_}"
395
396# Check for build prerequisites.
397 echo
398 cd $CWD
399 check_prerequisites
400 echo "${SD_BORDER}${nl_}"
401# All is well, run the build (if requested)
402run_make
Note: See TracBrowser for help on using the repository browser.