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