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