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