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