[4da2512] | 1 | #!/bin/bash
|
---|
| 2 | set -e
|
---|
[bbcdeab] | 3 | # Pass trap handlers to functions
|
---|
| 4 | set -E
|
---|
[4da2512] | 5 |
|
---|
| 6 | # VT100 colors
|
---|
| 7 | declare -r RED=$'\e[31m'
|
---|
| 8 | declare -r GREEN=$'\e[32m'
|
---|
| 9 | declare -r YELLOW=$'\e[33m'
|
---|
| 10 |
|
---|
[0e4ddfa] | 11 | # shellcheck disable=SC2034
|
---|
| 12 | declare -r BLUE=$'\e[34m'
|
---|
[4da2512] | 13 | declare -r OFF=$'\e[0m'
|
---|
| 14 | declare -r BOLD=$'\e[1m'
|
---|
| 15 | declare -r tab_=$'\t'
|
---|
| 16 | declare -r nl_=$'\n'
|
---|
| 17 |
|
---|
[0e4ddfa] | 18 | # shellcheck disable=SC2034
|
---|
[4da2512] | 19 | declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
---|
[0e4ddfa] | 20 | # shellcheck disable=SC2034
|
---|
[4da2512] | 21 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
[0e4ddfa] | 22 | # shellcheck disable=SC2034
|
---|
[4da2512] | 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 | #-----------------------#
|
---|
[0e4ddfa] | 34 | LASTLINE="$1"
|
---|
| 35 | LASTERR="$2"
|
---|
| 36 | LASTSOURCE="$4"
|
---|
| 37 | error_message "${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!"
|
---|
[4da2512] | 38 | }
|
---|
| 39 |
|
---|
| 40 | see_ya() {
|
---|
[0e4ddfa] | 41 | printf '\n%b%bjhalfs%b exit%b\n' "$L_arrow" "$BOLD" "$R_arrow" "$OFF"
|
---|
[4da2512] | 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
|
---|
[bbcdeab] | 56 | trap 'simple_error "${LINENO}" "$?" "${FUNCNAME}" "${BASH_SOURCE}"' ERR
|
---|
[d505128] | 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
|
---|
[4da2512] | 60 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
| 61 |
|
---|
[0e4ddfa] | 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 |
|
---|
[e5518fd] | 101 | git_commit=$(git log -1 --format=format:"%h %ad")
|
---|
[4da2512] | 102 | version="
|
---|
[e5518fd] | 103 | ${BOLD} \"jhalfs\"${OFF} builder tool (development) $git_commit
|
---|
[4da2512] | 104 |
|
---|
[e5518fd] | 105 | Copyright (C) 2005-2021, the jhalfs team:
|
---|
[f596dde] | 106 | Jeremy Huntwork
|
---|
| 107 | George Boudreau
|
---|
| 108 | Manuel Canales Esparcia
|
---|
| 109 | Thomas Pegg
|
---|
| 110 | Matthew Burgess
|
---|
| 111 | Pierre Labastie
|
---|
[4da2512] | 112 |
|
---|
[f596dde] | 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.
|
---|
[4da2512] | 115 |
|
---|
[f596dde] | 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.
|
---|
[4da2512] | 118 | "
|
---|
| 119 |
|
---|
[f596dde] | 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 |
|
---|
[4da2512] | 124 | case $1 in
|
---|
[909ee37] | 125 | -v ) echo "$version" && exit ;;
|
---|
[4da2512] | 126 | run ) : ;;
|
---|
[f596dde] | 127 | * ) echo "$usage" && exit 1 ;;
|
---|
[4da2512] | 128 | esac
|
---|
| 129 |
|
---|
[65c998b] | 130 | # If the user has not saved his configuration file, let's ask
|
---|
| 131 | # if he or she really wants to run this stuff
|
---|
[a22bfe1] | 132 | time_current=$(stat -c '%Y' configuration 2>/dev/null || date +%s)
|
---|
[cf2f109] | 133 | time_old=$(stat -c '%Y' configuration.old 2>/dev/null || printf '%s' "$time_current")
|
---|
[a22bfe1] | 134 | if [ "$(printf '%d' "$time_old")" -ge "$(printf '%d' "$time_current")" ] ; then
|
---|
| 135 | printf 'Do you want to run jhalfs? yes/no (yes): '
|
---|
[0e4ddfa] | 136 | read -r ANSWER
|
---|
[a22bfe1] | 137 | case ${ANSWER:0:1} in
|
---|
| 138 | n|N) printf "\nExiting gracefully.\n"; exit ;;
|
---|
| 139 | esac
|
---|
[65c998b] | 140 | fi
|
---|
| 141 |
|
---|
| 142 | # Change this to 0 to suppress almost all messages
|
---|
[4da2512] | 143 | VERBOSITY=1
|
---|
| 144 |
|
---|
[0e4ddfa] | 145 | load_file configuration "Loading config params from <configuration>"
|
---|
[4da2512] | 146 |
|
---|
| 147 | # These are boolean vars generated from Config.in.
|
---|
[7072e1f] | 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).
|
---|
[4da2512] | 153 | RUNMAKE=${RUNMAKE:-n}
|
---|
| 154 | GETPKG=${GETPKG:-n}
|
---|
| 155 | COMPARE=${COMPARE:-n}
|
---|
| 156 | RUN_ICA=${RUN_ICA:-n}
|
---|
[7072e1f] | 157 | PKGMNGT=${PKGMNGT:-n}
|
---|
[945ccaa] | 158 | WRAP_INSTALL=${WRAP_INSTALL:-n}
|
---|
[4da2512] | 159 | STRIP=${STRIP:=n}
|
---|
| 160 | REPORT=${REPORT:=n}
|
---|
[085435e] | 161 | NCURSES5=${NCURSES5:-n}
|
---|
[dc7fd7b] | 162 | DEL_LA_FILES=${DEL_LA_FILES:-n}
|
---|
[b339c94] | 163 | FULL_LOCALE=${FULL_LOCALE:-n}
|
---|
[4da2512] | 164 | GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
---|
[9a536f7] | 165 | CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
|
---|
[a16f769] | 166 | REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
|
---|
[93346ee] | 167 | INSTALL_LOG=${INSTALL_LOG:-n}
|
---|
[486e9a7] | 168 | CLEAN=${CLEAN:=n}
|
---|
[d035526] | 169 | SET_SSP=${SET_SSP:=n}
|
---|
| 170 | SET_ASLR=${SET_ASLR:=n}
|
---|
| 171 | SET_PAX=${SET_PAX:=n}
|
---|
| 172 | SET_HARDENED_TMP=${SET_HARDENED_TMP:=n}
|
---|
| 173 | SET_WARNINGS=${SET_WARNINGS:=n}
|
---|
| 174 | SET_MISC=${SET_MISC:=n}
|
---|
| 175 | SET_BLOWFISH=${SET_BLOWFISH:=n}
|
---|
[945ccaa] | 176 | UNICODE=${UNICODE:=n}
|
---|
[3b43e17b] | 177 | LOCAL=${LOCAL:=n}
|
---|
[84a3fda] | 178 | REALSBU=${REALSBU:=n}
|
---|
[f5ecc28] | 179 | SAVE_CH5=${SAVE_CH5:=n}
|
---|
[4da2512] | 180 |
|
---|
[75d6d1c] | 181 | if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
|
---|
[0e4ddfa] | 182 | # shellcheck disable=SC2034
|
---|
| 183 | NO_PROGRESS="#"
|
---|
[75d6d1c] | 184 | fi
|
---|
| 185 |
|
---|
[38ae01f] | 186 | # Sanity check on the location of $BUILDDIR / $JHALFSDIR
|
---|
[0e4ddfa] | 187 | CWD="$(cd "$(dirname "$0")" && pwd)"
|
---|
| 188 | if [[ $JHALFSDIR == "$CWD" ]]; then
|
---|
| 189 | echo " The jhalfs source directory conflicts with the jhalfs build directory."
|
---|
| 190 | echo " Please move the source directory or change the build directory."
|
---|
| 191 | exit 2
|
---|
[38ae01f] | 192 | fi
|
---|
| 193 |
|
---|
[4da2512] | 194 | # Set the document location...
|
---|
[2fd624d] | 195 | BOOK=${BOOK:=$JHALFSDIR/book-source}
|
---|
[4da2512] | 196 |
|
---|
[4965fa8] | 197 |
|
---|
[728955b] | 198 | #--- Envars not sourced from configuration
|
---|
[0e4ddfa] | 199 | # shellcheck disable=SC2034
|
---|
[875366f] | 200 | declare -r REPO=https://git.linuxfromscratch.org/lfs.git
|
---|
[728955b] | 201 | declare -r LOG=000-masterscript.log
|
---|
[2bd2fb8] | 202 | declare -r COMMANDS=lfs-commands
|
---|
[728955b] | 203 |
|
---|
[4da2512] | 204 | # Set true internal variables
|
---|
| 205 | COMMON_DIR="common"
|
---|
[8825e69] | 206 | PACKAGE_DIR=LFS
|
---|
[4da2512] | 207 | MODULE=$PACKAGE_DIR/master.sh
|
---|
[7072e1f] | 208 | PKGMNGTDIR="pkgmngt"
|
---|
| 209 | # The name packageManager.xml is hardcoded in *.xsl, so no variable.
|
---|
[4da2512] | 210 |
|
---|
[0e4ddfa] | 211 | for file in \
|
---|
| 212 | "$COMMON_DIR/common-functions" \
|
---|
| 213 | "$COMMON_DIR/libs/func_book_parser" \
|
---|
| 214 | "$COMMON_DIR/libs/func_download_pkgs" \
|
---|
| 215 | "$COMMON_DIR/libs/func_wrt_Makefile" \
|
---|
| 216 | "$MODULE" ; do
|
---|
| 217 | load_file "$file"
|
---|
| 218 | done
|
---|
[9a536f7] | 219 |
|
---|
[0e4ddfa] | 220 | simple_message "${SD_BORDER}${nl_}"
|
---|
[9a536f7] | 221 |
|
---|
| 222 |
|
---|
[0e4ddfa] | 223 | #*******************************************************************#
|
---|
| 224 | LASTERR=2
|
---|
| 225 | for file in \
|
---|
| 226 | "$COMMON_DIR/libs/func_check_version.sh" \
|
---|
| 227 | "$COMMON_DIR/libs/func_validate_configs.sh" \
|
---|
| 228 | "$COMMON_DIR/libs/func_custom_pkgs" ; do
|
---|
| 229 | load_file "$file"
|
---|
| 230 | done
|
---|
| 231 | unset LASTERR
|
---|
| 232 |
|
---|
| 233 | simple_message "${SD_BORDER}${nl_}"
|
---|
[183cc33] | 234 | simple_message "Checking tools required for jhalfs${nl_}"
|
---|
[6ed3dd7] | 235 | check_alfs_tools
|
---|
[0e4ddfa] | 236 | simple_message "${SD_BORDER}${nl_}"
|
---|
[4da2512] | 237 |
|
---|
[e576789] | 238 | # blfs-tool envars
|
---|
| 239 | BLFS_TOOL=${BLFS_TOOL:-n}
|
---|
| 240 | if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
---|
[0870a7c] | 241 | #not needed now that the check is in alfs_tools
|
---|
| 242 | # simple_message 'Checking supplementary tools for installing BLFS'
|
---|
| 243 | # check_blfs_tools
|
---|
[0e4ddfa] | 244 | simple_message "${SD_BORDER}${nl_}"
|
---|
[854854e] | 245 | BLFS_BRANCH=${BLFS_BRANCH:-n}
|
---|
[9b99ada] | 246 | BLFS_WORKING_COPY=${BLFS_WORKING_COPY:-n}
|
---|
| 247 | if [[ "${BLFS_WORKING_COPY}" = "y" ]] &&
|
---|
| 248 | [[ ! -d "$BLFS_WC_LOCATION/postlfs" ]] ; then
|
---|
[854854e] | 249 | echo " BLFS tools: This is not a working copy: $BLFS_WC_LOCATION."
|
---|
| 250 | echo " Please rerun make and fix the configuration."
|
---|
| 251 | exit 2
|
---|
| 252 | fi
|
---|
[0e4ddfa] | 253 | load_file "${COMMON_DIR}/libs/func_install_blfs"
|
---|
[e576789] | 254 | fi
|
---|
[4da2512] | 255 |
|
---|
| 256 | ###################################
|
---|
| 257 | ### MAIN ###
|
---|
| 258 | ###################################
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 | validate_config
|
---|
| 262 | echo "${SD_BORDER}${nl_}"
|
---|
| 263 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
[0e4ddfa] | 264 | read -r ANSWER
|
---|
| 265 | if [ "x$ANSWER" != "xyes" ] ; then
|
---|
[881c96f] | 266 | echo "${nl_}Rerun make to fix the configuration options.${nl_}"
|
---|
[d023a35] | 267 | exit
|
---|
[4da2512] | 268 | fi
|
---|
| 269 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
| 270 |
|
---|
| 271 | # Load additional modules or configuration files based on global settings
|
---|
| 272 | # compare module
|
---|
| 273 | if [[ "$COMPARE" = "y" ]]; then
|
---|
[0e4ddfa] | 274 | load_file "${COMMON_DIR}/libs/func_compare.sh" 'Loading compare module'
|
---|
[4da2512] | 275 | fi
|
---|
| 276 | #
|
---|
[f5ecc28] | 277 | # save module
|
---|
| 278 | if [[ "$SAVE_CH5" = "y" ]]; then
|
---|
| 279 | load_file "${COMMON_DIR}/libs/func_save.sh" 'Loading save module'
|
---|
| 280 | fi
|
---|
| 281 | #
|
---|
[4da2512] | 282 | # optimize module
|
---|
[f32cd50] | 283 | # the optimize_functions file is needed for wrt_makeflags even
|
---|
| 284 | # if optimize=0, because we need to pass NINJAJOBS=1
|
---|
| 285 | load_file optimize/optimize_functions 'Loading optimization module'
|
---|
[4da2512] | 286 | if [[ "$OPTIMIZE" != "0" ]]; then
|
---|
| 287 | #
|
---|
| 288 | # optimize configurations
|
---|
[0e4ddfa] | 289 | load_file optimize/opt_config 'Loading optimization config'
|
---|
[854854e] | 290 | # The number of parallel jobs is taken from configuration now
|
---|
[0e4ddfa] | 291 | # shellcheck disable=SC2034
|
---|
[9ef12f7] | 292 | JH_MAKEFLAGS="-j${N_PARALLEL}"
|
---|
[4da2512] | 293 | # Validate optimize settings, if required
|
---|
| 294 | validate_opt_settings
|
---|
| 295 | fi
|
---|
| 296 | #
|
---|
| 297 |
|
---|
[a16f769] | 298 | if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
|
---|
[4da2512] | 299 |
|
---|
[200fbde] | 300 | # If requested, clean the build directory
|
---|
[7b6ecc5] | 301 | clean_builddir
|
---|
[4da2512] | 302 |
|
---|
[7b6ecc5] | 303 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
[0e4ddfa] | 304 | sudo mkdir -p "$JHALFSDIR"
|
---|
[106157fd] | 305 | # Do not assume there is a group named as $USER, do not use
|
---|
| 306 | # $USER:$USER...
|
---|
| 307 | sudo chown "$USER" "$JHALFSDIR"
|
---|
[7b6ecc5] | 308 | fi
|
---|
[3e7ceed] | 309 |
|
---|
[200fbde] | 310 | # Create $BUILDDIR/sources even though it could be created by get_sources()
|
---|
[7b6ecc5] | 311 | if [[ ! -d $BUILDDIR/sources ]]; then
|
---|
[0e4ddfa] | 312 | sudo mkdir -p "$BUILDDIR/sources"
|
---|
| 313 | sudo chmod a+wt "$BUILDDIR/sources"
|
---|
[7b6ecc5] | 314 | fi
|
---|
[200fbde] | 315 |
|
---|
| 316 | # Create the log directory
|
---|
[7b6ecc5] | 317 | if [[ ! -d $LOGDIR ]]; then
|
---|
[0e4ddfa] | 318 | mkdir "$LOGDIR"
|
---|
[7b6ecc5] | 319 | fi
|
---|
[0e4ddfa] | 320 | true >"$LOGDIR/$LOG"
|
---|
[200fbde] | 321 |
|
---|
| 322 | # Copy common helper files
|
---|
[0e4ddfa] | 323 | cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh} "$JHALFSDIR/"
|
---|
[200fbde] | 324 |
|
---|
| 325 | # Copy needed stylesheets
|
---|
[0e4ddfa] | 326 | cp "$COMMON_DIR"/{packages.xsl,chroot.xsl,kernfs.xsl} "$JHALFSDIR/"
|
---|
[c412a07] | 327 | cp "$PACKAGE_DIR/$XSL" "$JHALFSDIR/"
|
---|
[200fbde] | 328 |
|
---|
[3e7ceed] | 329 | export XSL=$JHALFSDIR/${XSL}
|
---|
[7b6ecc5] | 330 |
|
---|
[200fbde] | 331 | # Copy packageManager.xml, if needed
|
---|
[8825e69] | 332 | [[ "$PKGMNGT" = "y" ]] && {
|
---|
[5a965ad] | 333 | sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \
|
---|
| 334 | "$JHALFSDIR/"packageManager.xml
|
---|
[0e4ddfa] | 335 | cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"
|
---|
[3aa1acd] | 336 | }
|
---|
[200fbde] | 337 |
|
---|
| 338 | # Copy urls.xsl, if needed
|
---|
[0e4ddfa] | 339 | [[ "$GETPKG" = "y" ]] && cp "$COMMON_DIR/urls.xsl" "$JHALFSDIR/"
|
---|
[200fbde] | 340 |
|
---|
[c672fa8] | 341 | # Always create the test-log directory to allow user to "uncomment" test
|
---|
| 342 | # instructions
|
---|
[0e4ddfa] | 343 | install -d -m 1777 "$TESTLOGDIR"
|
---|
[200fbde] | 344 |
|
---|
| 345 | # Create the installed-files directory, if needed
|
---|
[0e4ddfa] | 346 | [[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 "$FILELOGDIR"
|
---|
[200fbde] | 347 |
|
---|
| 348 | # Prepare report creation, if needed
|
---|
[7b6ecc5] | 349 | if [[ "$REPORT" = "y" ]]; then
|
---|
[0e4ddfa] | 350 | cp $COMMON_DIR/create-sbu_du-report.sh "$JHALFSDIR/"
|
---|
[7072e1f] | 351 | # After making sure that all looks sane, dump the settings to a file
|
---|
[7b6ecc5] | 352 | # This file will be used to create the REPORT header
|
---|
[0e4ddfa] | 353 | validate_config >"$JHALFSDIR/jhalfs.config"
|
---|
[7b6ecc5] | 354 | fi
|
---|
[200fbde] | 355 |
|
---|
| 356 | # Copy optimize files, if needed
|
---|
[0e4ddfa] | 357 | [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override "$JHALFSDIR/"
|
---|
[200fbde] | 358 |
|
---|
| 359 | # Copy compare files, if needed
|
---|
[3e7ceed] | 360 | if [[ "$COMPARE" = "y" ]]; then
|
---|
[0e4ddfa] | 361 | mkdir -p "$JHALFSDIR/extras"
|
---|
| 362 | cp extras/* "$JHALFSDIR/extras"
|
---|
[3e7ceed] | 363 | fi
|
---|
[200fbde] | 364 |
|
---|
| 365 | # Copy custom tools config files, if requested
|
---|
[3e7ceed] | 366 | if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
|
---|
| 367 | echo "Copying custom tool scripts to $JHALFSDIR"
|
---|
[0e4ddfa] | 368 | mkdir -p "$JHALFSDIR/custom-commands"
|
---|
| 369 | cp -f custom/config/* "$JHALFSDIR/custom-commands"
|
---|
[3e7ceed] | 370 | fi
|
---|
[200fbde] | 371 |
|
---|
[f733772] | 372 | # Download or updates the book source
|
---|
| 373 | # Note that all customization to $JHALFSDIR have to be done before this.
|
---|
| 374 | # But the LFS book is needed for BLFS tools.
|
---|
| 375 | get_book
|
---|
| 376 | extract_commands
|
---|
| 377 | echo "${SD_BORDER}${nl_}"
|
---|
[0e4ddfa] | 378 | cd "$CWD" # the functions above change directory
|
---|
[f733772] | 379 |
|
---|
[200fbde] | 380 | # Install blfs-tool, if requested.
|
---|
[7b6ecc5] | 381 | if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
---|
[6ed3dd7] | 382 | echo Installing BLFS book and tools
|
---|
[0e4ddfa] | 383 | install_blfs_tools 2>&1 | tee -a "$LOGDIR/$LOG"
|
---|
[bbcdeab] | 384 | [[ ${PIPESTATUS[0]} != 0 ]] && exit 1
|
---|
[7b6ecc5] | 385 | fi
|
---|
| 386 |
|
---|
[4965fa8] | 387 | fi
|
---|
| 388 |
|
---|
[0e4ddfa] | 389 | # shellcheck disable=SC2034
|
---|
[a16f769] | 390 | if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
|
---|
[8b85dae] | 391 | # Sanity check: users tend to tick "rebuild Makefile"
|
---|
| 392 | # without generating one first. Check we have one:
|
---|
| 393 | if [ ! -f $MKFILE ]; then
|
---|
| 394 | set -e
|
---|
| 395 | error_message "You cannot \"rebuild Makefile\" without first building one"
|
---|
| 396 | fi
|
---|
| 397 | # When regenerating the Makefile, we need to know also the
|
---|
| 398 | # canonical book version
|
---|
[0fa52f2] | 399 | VERSION=$(grep 'echo.*lfs-release' "$JHALFSDIR/prbook.xml" | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
---|
[a16f769] | 400 | fi
|
---|
| 401 |
|
---|
[4da2512] | 402 | build_Makefile
|
---|
[3e7ceed] | 403 |
|
---|
[4da2512] | 404 | echo "${SD_BORDER}${nl_}"
|
---|
| 405 |
|
---|
[1cf621b] | 406 | # Check for build prerequisites.
|
---|
| 407 | echo
|
---|
[0e4ddfa] | 408 | cd "$CWD"
|
---|
[1cf621b] | 409 | check_prerequisites
|
---|
| 410 | echo "${SD_BORDER}${nl_}"
|
---|
| 411 | # All is well, run the build (if requested)
|
---|
[4da2512] | 412 | run_make
|
---|