source: jhalfs@ 0727893

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

Merge trunk r3692

  • Property mode set to 100755
File size: 11.7 KB
RevLine 
[4da2512]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
[a96109a]39 if [[ "$-" =~ e ]]; then
[4da2512]40 echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
41 fi
42}
43
44see_ya() {
[401aac8]45 echo -e "\n${L_arrow}${BOLD}jhalfs-trunk${R_arrow} exit${OFF}\n"
[4da2512]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="
[401aac8]65${BOLD} \"jhalfs-trunk\"${OFF} builder tool (development) \$Rev$
[4da2512]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
[0727893]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
[4da2512]99VERBOSITY=1
100
101[[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
102source configuration
[7072e1f]103[[ $? > 0 ]] && echo "file: configuration did not load.." && exit 1
[4da2512]104[[ $VERBOSITY > 0 ]] && echo "OK"
105
106# These are boolean vars generated from Config.in.
[7072e1f]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).
[4da2512]112RUNMAKE=${RUNMAKE:-n}
113GETPKG=${GETPKG:-n}
114COMPARE=${COMPARE:-n}
115RUN_FARCE=${RUN_FARCE:-n}
116RUN_ICA=${RUN_ICA:-n}
[7072e1f]117PKGMNGT=${PKGMNGT:-n}
[4da2512]118BOMB_TEST=${BOMB_TEST:-n}
119STRIP=${STRIP:=n}
120REPORT=${REPORT:=n}
121VIMLANG=${VIMLANG:-n}
[b339c94]122FULL_LOCALE=${FULL_LOCALE:-n}
[4da2512]123GRSECURITY_HOST=${GRSECURITY_HOST:-n}
[9a536f7]124CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
[a16f769]125REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
[93346ee]126INSTALL_LOG=${INSTALL_LOG:-n}
[486e9a7]127CLEAN=${CLEAN:=n}
[d035526]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}
[4da2512]135
[75d6d1c]136if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
137 NO_PROGRESS="#"
138fi
139
140
[38ae01f]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
[0873ccc]149# Book sources envars
[4965fa8]150BRANCH_ID=${BRANCH_ID:=development}
151
152case $BRANCH_ID in
153 development )
154 case $PROGNAME in
[abf2c47]155 clfs2 ) TREE=branches/clfs-sysroot/BOOK ;;
156 clfs3 ) TREE=branches/clfs-embedded/BOOK ;;
[4965fa8]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
[e650dc7]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 )
[4965fa8]178 LFSVRS=${BRANCH_ID}
179 TREE=tags/${BRANCH_ID}/BOOK
180 ;;
[2639f65]181 clfs | clfs2 | clfs3)
[4965fa8]182 LFSVRS=${BRANCH_ID}
183 TREE=tags/${BRANCH_ID}
184 ;;
185 esac
186 ;;
187esac
188
[4da2512]189# Set the document location...
190BOOK=${BOOK:=$PROGNAME-$LFSVRS}
191
[4965fa8]192
[728955b]193#--- Envars not sourced from configuration
194case $PROGNAME in
[7072e1f]195# TODO: clfs is now on git
196# clfs* ) declare -r SVN="http://svn.cross-lfs.org/svn/repos" ;;
[728955b]197 * ) declare -r SVN="svn://svn.linuxfromscratch.org" ;;
198esac
199declare -r LOG=000-masterscript.log
[7072e1f]200 # Needed for fetching BLFS book sources when building CLFS
[728955b]201declare -r SVN_2="svn://svn.linuxfromscratch.org"
202
[4da2512]203# Set true internal variables
204COMMON_DIR="common"
[52b0d10]205PACKAGE_DIR=$(echo $PROGNAME | tr '[a-z]' '[A-Z]')
[4da2512]206MODULE=$PACKAGE_DIR/master.sh
[7072e1f]207PKGMNGTDIR="pkgmngt"
208# The name packageManager.xml is hardcoded in *.xsl, so no variable.
[4da2512]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>..."
[d517356]224source $COMMON_DIR/libs/func_check_version.sh
[4da2512]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>..."
[d517356]229source $COMMON_DIR/libs/func_validate_configs.sh
[4da2512]230[[ $? > 0 ]] && echo " function module did not load.." && exit 2
231[[ $VERBOSITY > 0 ]] && echo "OK"
[9a536f7]232
[fe30c61]233[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_custom_pkgs>..."
234source $COMMON_DIR/libs/func_custom_pkgs
[9a536f7]235[[ $? > 0 ]] && echo " function module did not load.." && exit 2
236[[ $VERBOSITY > 0 ]] && echo "OK"
237
238
[4da2512]239[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
240
[2507cf7]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
[4da2512]258
259###################################
260### MAIN ###
261###################################
262
[0873ccc]263# Check for build prerequisites.
[4da2512]264echo
[045b2dc]265 check_prerequisites
[4da2512]266echo "${SD_BORDER}${nl_}"
267
268validate_config
269echo "${SD_BORDER}${nl_}"
270echo -n "Are you happy with these settings? yes/no (no): "
271read ANSWER
272if [ x$ANSWER != "xyes" ] ; then
[881c96f]273 echo "${nl_}Rerun make to fix the configuration options.${nl_}"
[4da2512]274 exit 1
275fi
276echo "${nl_}${SD_BORDER}${nl_}"
277
278# Load additional modules or configuration files based on global settings
279# compare module
280if [[ "$COMPARE" = "y" ]]; then
281 [[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
[d517356]282 source $COMMON_DIR/libs/func_compare.sh
283 [[ $? > 0 ]] && echo "$COMMON_DIR/libs/func_compare.sh did not load.." && exit
[4da2512]284 [[ $VERBOSITY > 0 ]] && echo "OK"
285fi
286#
287# optimize module
288if [[ "$OPTIMIZE" != "0" ]]; then
289 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
290 source optimize/optimize_functions
291 [[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
292 [[ $VERBOSITY > 0 ]] && echo "OK"
293 #
294 # optimize configurations
295 [[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
296 source optimize/opt_config
297 [[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
298 [[ $VERBOSITY > 0 ]] && echo "OK"
299 # Validate optimize settings, if required
300 validate_opt_settings
301fi
302#
303
[a16f769]304if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
[4da2512]305
[7b6ecc5]306 # If requested, clean the build directory
307 clean_builddir
[4da2512]308
[7b6ecc5]309 if [[ ! -d $JHALFSDIR ]]; then
310 mkdir -p $JHALFSDIR
311 fi
[3e7ceed]312
[7b6ecc5]313 # Create $BUILDDIR/sources even though it could be created by get_sources()
314 if [[ ! -d $BUILDDIR/sources ]]; then
315 mkdir -p $BUILDDIR/sources
316 fi
317 #
318 # Create the log directory
319 if [[ ! -d $LOGDIR ]]; then
320 mkdir $LOGDIR
321 fi
322 >$LOGDIR/$LOG
323 #
[3e7ceed]324 # Copy common helper files
325 cp $COMMON_DIR/{makefile-functions,progress_bar.sh,packages.xsl} $JHALFSDIR/
[7b6ecc5]326 #
[3e7ceed]327 # Fix the XSL book parser
328 sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL}
329 export XSL=$JHALFSDIR/${XSL}
[7b6ecc5]330 #
331
[7072e1f]332 # Copy packageManager.xml, if needed
333 [[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] &&
334 cp $PKGMNGTDIR/packageManager.xml $JHALFSDIR/ &&
335 cp $PKGMNGTDIR/packInstall.sh $JHALFSDIR/
336 #
[3e7ceed]337 # Copy urls.xsl, if needed
338 [[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
[7b6ecc5]339 #
[3e7ceed]340 # Create the test-log directory, if needed
341 [[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
342 #
[93346ee]343 # Create the installed-files directory, if needed
344 [[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 $FILELOGDIR
345 #
[3e7ceed]346 # Prepare report creation, if needed
[7b6ecc5]347 if [[ "$REPORT" = "y" ]]; then
348 cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
[7072e1f]349 # After making sure that all looks sane, dump the settings to a file
[7b6ecc5]350 # This file will be used to create the REPORT header
351 validate_config > $JHALFSDIR/jhalfs.config
352 fi
353 #
[3e7ceed]354 # Copy optimize files, if needed
355 [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
[7b6ecc5]356 #
[3e7ceed]357 # Copy compare files, if needed
358 if [[ "$COMPARE" = "y" ]]; then
359 mkdir -p $JHALFSDIR/extras
360 cp extras/* $JHALFSDIR/extras
361 fi
[7b6ecc5]362 #
[3e7ceed]363 # Copy custom tools config files, if requested
364 if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
365 echo "Copying custom tool scripts to $JHALFSDIR"
366 mkdir -p $JHALFSDIR/custom-commands
367 cp -f custom/config/* $JHALFSDIR/custom-commands
368 fi
369 #
[7b6ecc5]370 # Install blfs-tool, if requested.
371 if [[ "${BLFS_TOOL}" = "y" ]] ; then
[2507cf7]372 echo Downloading and validating the BLFS book
373 echo '(may take some time...)'
374 install_blfs_tools 2>&1 | tee -a $LOGDIR/$LOG
[7b6ecc5]375 fi
[3e7ceed]376 #
[7b6ecc5]377
378 get_book
[4965fa8]379 echo "${SD_BORDER}${nl_}"
[7b6ecc5]380
[4965fa8]381fi
382
[63e068c]383# When regenerating the Makefile, we need to know also the
384# canonical book version
[a16f769]385if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
386 case $PROGNAME in
[2639f65]387 clfs | clfs2 | clfs3 )
[a16f769]388 VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
389 *)
390 VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
391 esac
392fi
393
[4da2512]394build_Makefile
[3e7ceed]395
[4da2512]396echo "${SD_BORDER}${nl_}"
397
398run_make
Note: See TracBrowser for help on using the repository browser.