[4da2512] | 1 | #!/bin/bash
|
---|
| 2 | # $Id$
|
---|
| 3 | set -e
|
---|
[bbcdeab] | 4 | # Pass trap handlers to functions
|
---|
| 5 | set -E
|
---|
[4da2512] | 6 |
|
---|
| 7 | # VT100 colors
|
---|
| 8 | declare -r RED=$'\e[31m'
|
---|
| 9 | declare -r GREEN=$'\e[32m'
|
---|
| 10 | declare -r YELLOW=$'\e[33m'
|
---|
| 11 |
|
---|
[0e4ddfa] | 12 | # shellcheck disable=SC2034
|
---|
| 13 | declare -r BLUE=$'\e[34m'
|
---|
[4da2512] | 14 | declare -r OFF=$'\e[0m'
|
---|
| 15 | declare -r BOLD=$'\e[1m'
|
---|
| 16 | declare -r tab_=$'\t'
|
---|
| 17 | declare -r nl_=$'\n'
|
---|
| 18 |
|
---|
[0e4ddfa] | 19 | # shellcheck disable=SC2034
|
---|
[4da2512] | 20 | declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
---|
[0e4ddfa] | 21 | # shellcheck disable=SC2034
|
---|
[4da2512] | 22 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
[0e4ddfa] | 23 | # shellcheck disable=SC2034
|
---|
[4da2512] | 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 | #-----------------------#
|
---|
[0e4ddfa] | 35 | LASTLINE="$1"
|
---|
| 36 | LASTERR="$2"
|
---|
| 37 | LASTSOURCE="$4"
|
---|
| 38 | error_message "${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!"
|
---|
[4da2512] | 39 | }
|
---|
| 40 |
|
---|
| 41 | see_ya() {
|
---|
[0e4ddfa] | 42 | printf '\n%b%bjhalfs%b exit%b\n' "$L_arrow" "$BOLD" "$R_arrow" "$OFF"
|
---|
[4da2512] | 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
|
---|
[bbcdeab] | 57 | trap 'simple_error "${LINENO}" "$?" "${FUNCNAME}" "${BASH_SOURCE}"' ERR
|
---|
[d505128] | 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
|
---|
[4da2512] | 61 | #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
---|
| 62 |
|
---|
[0e4ddfa] | 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 |
|
---|
[4da2512] | 102 | version="
|
---|
[8d56c87] | 103 | ${BOLD} \"jhalfs\"${OFF} builder tool (development) \$Rev$
|
---|
[4da2512] | 104 | \$Date$
|
---|
| 105 |
|
---|
[8d56c87] | 106 | Written by George Boudreau, Manuel Canales Esparcia, Pierre Labastie,
|
---|
[4da2512] | 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}
|
---|
[8d56c87] | 113 | See the ${BOLD}LICENCE${OFF} file in this directory.
|
---|
[4da2512] | 114 | "
|
---|
| 115 |
|
---|
| 116 | case $1 in
|
---|
[909ee37] | 117 | -v ) echo "$version" && exit ;;
|
---|
[4da2512] | 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 |
|
---|
[65c998b] | 125 | # If the user has not saved his configuration file, let's ask
|
---|
| 126 | # if he or she really wants to run this stuff
|
---|
[a22bfe1] | 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): '
|
---|
[0e4ddfa] | 131 | read -r ANSWER
|
---|
[a22bfe1] | 132 | case ${ANSWER:0:1} in
|
---|
| 133 | n|N) printf "\nExiting gracefully.\n"; exit ;;
|
---|
| 134 | esac
|
---|
[65c998b] | 135 | fi
|
---|
| 136 |
|
---|
| 137 | # Change this to 0 to suppress almost all messages
|
---|
[4da2512] | 138 | VERBOSITY=1
|
---|
| 139 |
|
---|
[0e4ddfa] | 140 | load_file configuration "Loading config params from <configuration>"
|
---|
[4da2512] | 141 |
|
---|
| 142 | # These are boolean vars generated from Config.in.
|
---|
[7072e1f] | 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).
|
---|
[4da2512] | 148 | RUNMAKE=${RUNMAKE:-n}
|
---|
| 149 | GETPKG=${GETPKG:-n}
|
---|
| 150 | COMPARE=${COMPARE:-n}
|
---|
| 151 | RUN_FARCE=${RUN_FARCE:-n}
|
---|
| 152 | RUN_ICA=${RUN_ICA:-n}
|
---|
[7072e1f] | 153 | PKGMNGT=${PKGMNGT:-n}
|
---|
[945ccaa] | 154 | WRAP_INSTALL=${WRAP_INSTALL:-n}
|
---|
[4da2512] | 155 | BOMB_TEST=${BOMB_TEST:-n}
|
---|
| 156 | STRIP=${STRIP:=n}
|
---|
| 157 | REPORT=${REPORT:=n}
|
---|
| 158 | VIMLANG=${VIMLANG:-n}
|
---|
[dc7fd7b] | 159 | DEL_LA_FILES=${DEL_LA_FILES:-n}
|
---|
[b339c94] | 160 | FULL_LOCALE=${FULL_LOCALE:-n}
|
---|
[4da2512] | 161 | GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
---|
[9a536f7] | 162 | CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
|
---|
[a16f769] | 163 | REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
|
---|
[93346ee] | 164 | INSTALL_LOG=${INSTALL_LOG:-n}
|
---|
[486e9a7] | 165 | CLEAN=${CLEAN:=n}
|
---|
[d035526] | 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}
|
---|
[945ccaa] | 173 | UNICODE=${UNICODE:=n}
|
---|
[3b43e17b] | 174 | LOCAL=${LOCAL:=n}
|
---|
[84a3fda] | 175 | REALSBU=${REALSBU:=n}
|
---|
[4da2512] | 176 |
|
---|
[75d6d1c] | 177 | if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
|
---|
[0e4ddfa] | 178 | # shellcheck disable=SC2034
|
---|
| 179 | NO_PROGRESS="#"
|
---|
[75d6d1c] | 180 | fi
|
---|
| 181 |
|
---|
| 182 |
|
---|
[38ae01f] | 183 | # Sanity check on the location of $BUILDDIR / $JHALFSDIR
|
---|
[0e4ddfa] | 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
|
---|
[38ae01f] | 189 | fi
|
---|
| 190 |
|
---|
[0873ccc] | 191 | # Book sources envars
|
---|
[4965fa8] | 192 | BRANCH_ID=${BRANCH_ID:=development}
|
---|
| 193 |
|
---|
| 194 | case $BRANCH_ID in
|
---|
| 195 | development )
|
---|
| 196 | case $PROGNAME in
|
---|
[92b7cb8] | 197 | clfs* ) TREE="" ;;
|
---|
[c4ad7bf] | 198 | * ) TREE=trunk/BOOK ;;
|
---|
[4965fa8] | 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-* )
|
---|
[c4ad7bf] | 206 | case $PROGNAME in
|
---|
| 207 | lfs )
|
---|
| 208 | LFSVRS=${BRANCH_ID}
|
---|
[bb2862d] | 209 | TREE=branches/${BRANCH_ID#branch-}
|
---|
[dd08e14] | 210 | if [ ${BRANCH_ID:7:1} = 6 ]; then
|
---|
[bb2862d] | 211 | TREE=${TREE}/BOOK
|
---|
| 212 | fi
|
---|
[c4ad7bf] | 213 | ;;
|
---|
| 214 | clfs* )
|
---|
| 215 | LFSVRS=${BRANCH_ID}
|
---|
| 216 | TREE=${BRANCH_ID#branch-}
|
---|
| 217 | ;;
|
---|
| 218 | esac
|
---|
[4965fa8] | 219 | ;;
|
---|
| 220 | * )
|
---|
| 221 | case $PROGNAME in
|
---|
[e650dc7] | 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 )
|
---|
[4965fa8] | 230 | LFSVRS=${BRANCH_ID}
|
---|
| 231 | TREE=tags/${BRANCH_ID}/BOOK
|
---|
| 232 | ;;
|
---|
[92b7cb8] | 233 | clfs* )
|
---|
[4965fa8] | 234 | LFSVRS=${BRANCH_ID}
|
---|
[34d1b6a] | 235 | TREE=clfs-${BRANCH_ID}
|
---|
[4965fa8] | 236 | ;;
|
---|
[92b7cb8] | 237 | * )
|
---|
[4965fa8] | 238 | esac
|
---|
| 239 | ;;
|
---|
| 240 | esac
|
---|
| 241 |
|
---|
[4da2512] | 242 | # Set the document location...
|
---|
[1cf621b] | 243 | BOOK=${BOOK:=$JHALFSDIR/$PROGNAME-$LFSVRS}
|
---|
[4da2512] | 244 |
|
---|
[4965fa8] | 245 |
|
---|
[728955b] | 246 | #--- Envars not sourced from configuration
|
---|
[0e4ddfa] | 247 | # shellcheck disable=SC2034
|
---|
[728955b] | 248 | case $PROGNAME in
|
---|
[0e4ddfa] | 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" ;;
|
---|
[728955b] | 253 | esac
|
---|
[0e4ddfa] | 254 |
|
---|
[728955b] | 255 | declare -r LOG=000-masterscript.log
|
---|
[0e4ddfa] | 256 | # Needed for fetching BLFS book sources when building CLFS
|
---|
| 257 | # shellcheck disable=SC2034
|
---|
[728955b] | 258 | declare -r SVN_2="svn://svn.linuxfromscratch.org"
|
---|
| 259 |
|
---|
[4da2512] | 260 | # Set true internal variables
|
---|
| 261 | COMMON_DIR="common"
|
---|
[0e4ddfa] | 262 | PACKAGE_DIR=$(echo "$PROGNAME" | tr '[:lower:]' '[:upper:]')
|
---|
[4da2512] | 263 | MODULE=$PACKAGE_DIR/master.sh
|
---|
[7072e1f] | 264 | PKGMNGTDIR="pkgmngt"
|
---|
| 265 | # The name packageManager.xml is hardcoded in *.xsl, so no variable.
|
---|
[4da2512] | 266 |
|
---|
[0e4ddfa] | 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
|
---|
[9a536f7] | 275 |
|
---|
[0e4ddfa] | 276 | simple_message "${SD_BORDER}${nl_}"
|
---|
[9a536f7] | 277 |
|
---|
| 278 |
|
---|
[0e4ddfa] | 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'
|
---|
[6ed3dd7] | 291 | check_alfs_tools
|
---|
[0e4ddfa] | 292 | simple_message "${SD_BORDER}${nl_}"
|
---|
[4da2512] | 293 |
|
---|
[e576789] | 294 | # blfs-tool envars
|
---|
| 295 | BLFS_TOOL=${BLFS_TOOL:-n}
|
---|
| 296 | if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
---|
[0e4ddfa] | 297 | simple_message 'Checking supplementary tools for installing BLFS'
|
---|
[6ed3dd7] | 298 | check_blfs_tools
|
---|
[0e4ddfa] | 299 | simple_message "${SD_BORDER}${nl_}"
|
---|
[854854e] | 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
|
---|
[0e4ddfa] | 307 | if [[ ! -d "$BLFS_WC_LOCATION/postlfs" ]] ; then
|
---|
[854854e] | 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
|
---|
[0e4ddfa] | 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@@')
|
---|
[0ba80be] | 317 | elif [[ "${BLFS_BRANCH}" = "y" ]] ; then
|
---|
[854854e] | 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 ;;
|
---|
[dd08e14] | 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} ;;
|
---|
[854854e] | 325 | * ) BLFS_TREE=tags/${BLFS_BRANCH_ID}/BOOK ;;
|
---|
| 326 | esac
|
---|
| 327 | fi
|
---|
[0e4ddfa] | 328 | load_file "${COMMON_DIR}/libs/func_install_blfs"
|
---|
[e576789] | 329 | fi
|
---|
[4da2512] | 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): "
|
---|
[0e4ddfa] | 339 | read -r ANSWER
|
---|
| 340 | if [ "x$ANSWER" != "xyes" ] ; then
|
---|
[881c96f] | 341 | echo "${nl_}Rerun make to fix the configuration options.${nl_}"
|
---|
[d023a35] | 342 | exit
|
---|
[4da2512] | 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
|
---|
[0e4ddfa] | 349 | load_file "${COMMON_DIR}/libs/func_compare.sh" 'Loading compare module'
|
---|
[4da2512] | 350 | fi
|
---|
| 351 | #
|
---|
| 352 | # optimize module
|
---|
| 353 | if [[ "$OPTIMIZE" != "0" ]]; then
|
---|
[0e4ddfa] | 354 | load_file optimize/optimize_functions 'Loading optimization module'
|
---|
[4da2512] | 355 | #
|
---|
| 356 | # optimize configurations
|
---|
[0e4ddfa] | 357 | load_file optimize/opt_config 'Loading optimization config'
|
---|
[854854e] | 358 | # The number of parallel jobs is taken from configuration now
|
---|
[0e4ddfa] | 359 | # shellcheck disable=SC2034
|
---|
[854854e] | 360 | MAKEFLAGS="-j${N_PARALLEL}"
|
---|
[4da2512] | 361 | # Validate optimize settings, if required
|
---|
| 362 | validate_opt_settings
|
---|
| 363 | fi
|
---|
| 364 | #
|
---|
| 365 |
|
---|
[a16f769] | 366 | if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
|
---|
[4da2512] | 367 |
|
---|
[200fbde] | 368 | # If requested, clean the build directory
|
---|
[7b6ecc5] | 369 | clean_builddir
|
---|
[4da2512] | 370 |
|
---|
[7b6ecc5] | 371 | if [[ ! -d $JHALFSDIR ]]; then
|
---|
[0e4ddfa] | 372 | sudo mkdir -p "$JHALFSDIR"
|
---|
| 373 | sudo chown "$USER":"$USER" "$JHALFSDIR"
|
---|
[7b6ecc5] | 374 | fi
|
---|
[3e7ceed] | 375 |
|
---|
[200fbde] | 376 | # Create $BUILDDIR/sources even though it could be created by get_sources()
|
---|
[7b6ecc5] | 377 | if [[ ! -d $BUILDDIR/sources ]]; then
|
---|
[0e4ddfa] | 378 | sudo mkdir -p "$BUILDDIR/sources"
|
---|
| 379 | sudo chmod a+wt "$BUILDDIR/sources"
|
---|
[7b6ecc5] | 380 | fi
|
---|
[200fbde] | 381 |
|
---|
| 382 | # Create the log directory
|
---|
[7b6ecc5] | 383 | if [[ ! -d $LOGDIR ]]; then
|
---|
[0e4ddfa] | 384 | mkdir "$LOGDIR"
|
---|
[7b6ecc5] | 385 | fi
|
---|
[0e4ddfa] | 386 | true >"$LOGDIR/$LOG"
|
---|
[200fbde] | 387 |
|
---|
| 388 | # Copy common helper files
|
---|
[0e4ddfa] | 389 | cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh} "$JHALFSDIR/"
|
---|
[200fbde] | 390 |
|
---|
| 391 | # Copy needed stylesheets
|
---|
[0e4ddfa] | 392 | cp "$COMMON_DIR"/{packages.xsl,chroot.xsl,kernfs.xsl} "$JHALFSDIR/"
|
---|
[200fbde] | 393 |
|
---|
| 394 | # Fix the XSL book parser
|
---|
[92b7cb8] | 395 | case $PROGNAME in
|
---|
[0e4ddfa] | 396 | clfs* ) sed 's,FAKEDIR,'"${BOOK}/BOOK"',' "${PACKAGE_DIR}/${XSL}" > "${JHALFSDIR}/${XSL}" ;;
|
---|
| 397 | lfs | hlfs ) sed 's,FAKEDIR,'"$BOOK"',' "${PACKAGE_DIR}/${XSL}" > "${JHALFSDIR}/${XSL}" ;;
|
---|
[92b7cb8] | 398 | * ) ;;
|
---|
| 399 | esac
|
---|
[3e7ceed] | 400 | export XSL=$JHALFSDIR/${XSL}
|
---|
[7b6ecc5] | 401 |
|
---|
[200fbde] | 402 | # Copy packageManager.xml, if needed
|
---|
[3aa1acd] | 403 | [[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] && {
|
---|
[0e4ddfa] | 404 | cp "$PKGMNGTDIR/packageManager.xml" "$JHALFSDIR/"
|
---|
| 405 | cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"
|
---|
[3aa1acd] | 406 | }
|
---|
[200fbde] | 407 |
|
---|
| 408 | # Copy urls.xsl, if needed
|
---|
[0e4ddfa] | 409 | [[ "$GETPKG" = "y" ]] && cp "$COMMON_DIR/urls.xsl" "$JHALFSDIR/"
|
---|
[200fbde] | 410 |
|
---|
[c672fa8] | 411 | # Always create the test-log directory to allow user to "uncomment" test
|
---|
| 412 | # instructions
|
---|
[0e4ddfa] | 413 | install -d -m 1777 "$TESTLOGDIR"
|
---|
[200fbde] | 414 |
|
---|
| 415 | # Create the installed-files directory, if needed
|
---|
[0e4ddfa] | 416 | [[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 "$FILELOGDIR"
|
---|
[200fbde] | 417 |
|
---|
| 418 | # Prepare report creation, if needed
|
---|
[7b6ecc5] | 419 | if [[ "$REPORT" = "y" ]]; then
|
---|
[0e4ddfa] | 420 | cp $COMMON_DIR/create-sbu_du-report.sh "$JHALFSDIR/"
|
---|
[7072e1f] | 421 | # After making sure that all looks sane, dump the settings to a file
|
---|
[7b6ecc5] | 422 | # This file will be used to create the REPORT header
|
---|
[0e4ddfa] | 423 | validate_config >"$JHALFSDIR/jhalfs.config"
|
---|
[7b6ecc5] | 424 | fi
|
---|
[200fbde] | 425 |
|
---|
| 426 | # Copy optimize files, if needed
|
---|
[0e4ddfa] | 427 | [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override "$JHALFSDIR/"
|
---|
[200fbde] | 428 |
|
---|
| 429 | # Copy compare files, if needed
|
---|
[3e7ceed] | 430 | if [[ "$COMPARE" = "y" ]]; then
|
---|
[0e4ddfa] | 431 | mkdir -p "$JHALFSDIR/extras"
|
---|
| 432 | cp extras/* "$JHALFSDIR/extras"
|
---|
[3e7ceed] | 433 | fi
|
---|
[200fbde] | 434 |
|
---|
| 435 | # Copy custom tools config files, if requested
|
---|
[3e7ceed] | 436 | if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
|
---|
| 437 | echo "Copying custom tool scripts to $JHALFSDIR"
|
---|
[0e4ddfa] | 438 | mkdir -p "$JHALFSDIR/custom-commands"
|
---|
| 439 | cp -f custom/config/* "$JHALFSDIR/custom-commands"
|
---|
[3e7ceed] | 440 | fi
|
---|
[200fbde] | 441 |
|
---|
[f733772] | 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_}"
|
---|
[0e4ddfa] | 448 | cd "$CWD" # the functions above change directory
|
---|
[f733772] | 449 |
|
---|
[200fbde] | 450 | # Install blfs-tool, if requested.
|
---|
[7b6ecc5] | 451 | if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
---|
[6ed3dd7] | 452 | echo Installing BLFS book and tools
|
---|
[0e4ddfa] | 453 | install_blfs_tools 2>&1 | tee -a "$LOGDIR/$LOG"
|
---|
[bbcdeab] | 454 | [[ ${PIPESTATUS[0]} != 0 ]] && exit 1
|
---|
[7b6ecc5] | 455 | fi
|
---|
| 456 |
|
---|
[4965fa8] | 457 | fi
|
---|
| 458 |
|
---|
[e576789] | 459 | # When regenerating the Makefile, we need to know also the
|
---|
| 460 | # canonical book version
|
---|
[0e4ddfa] | 461 | # shellcheck disable=SC2034
|
---|
[a16f769] | 462 | if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
|
---|
| 463 | case $PROGNAME in
|
---|
[92b7cb8] | 464 | clfs* )
|
---|
[0e4ddfa] | 465 | VERSION=$(xmllint --noent "$BOOK/prologue/$ARCH/bookinfo.xml" 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
[c9598f2] | 466 | lfs)
|
---|
| 467 | if [[ "$INITSYS" = "sysv" ]] ; then
|
---|
[0e4ddfa] | 468 | VERSION=$(grep 'ENTITY version ' "$BOOK/general.ent" | cut -d\" -f2)
|
---|
[c9598f2] | 469 | else
|
---|
[0e4ddfa] | 470 | VERSION=$(grep 'ENTITY versiond' "$BOOK/general.ent" | cut -d\" -f2)
|
---|
[c9598f2] | 471 | fi
|
---|
| 472 | ;;
|
---|
[a16f769] | 473 | *)
|
---|
[0e4ddfa] | 474 | VERSION=$(xmllint --noent "$BOOK/prologue/bookinfo.xml" 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
[a16f769] | 475 | esac
|
---|
| 476 | fi
|
---|
| 477 |
|
---|
[4da2512] | 478 | build_Makefile
|
---|
[3e7ceed] | 479 |
|
---|
[4da2512] | 480 | echo "${SD_BORDER}${nl_}"
|
---|
| 481 |
|
---|
[1cf621b] | 482 | # Check for build prerequisites.
|
---|
| 483 | echo
|
---|
[0e4ddfa] | 484 | cd "$CWD"
|
---|
[1cf621b] | 485 | check_prerequisites
|
---|
| 486 | echo "${SD_BORDER}${nl_}"
|
---|
| 487 | # All is well, run the build (if requested)
|
---|
[4da2512] | 488 | run_make
|
---|