source: jhalfs@ d2a7ec8

ablfs-more legacy trunk
Last change on this file since d2a7ec8 was dc7fd7b, checked in by Pierre Labastie <pierre@…>, 7 years ago

Add .la file removal to LFS and BLFS scripts

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