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