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