[877cc6a] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # $Id$
|
---|
| 4 |
|
---|
| 5 | set +e
|
---|
| 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 |
|
---|
[47e524f] | 27 | declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
---|
| 28 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
| 29 | declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
|
---|
[877cc6a] | 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 | usage() {
|
---|
| 37 | cat <<- -EOF-
|
---|
| 38 | ${DD_BORDER}
|
---|
| 39 | ${BOLD}
|
---|
| 40 | Usage: $0 ${BOLD}[OPTION]
|
---|
| 41 |
|
---|
[efc0d1e] | 42 | ${RED}IMPORTANT:${OFF} Only supported command line switches are listed here.
|
---|
[4dd25a1] | 43 | For more fine-grained setups you must edit the relevant
|
---|
[efc0d1e] | 44 | configuration files placed under ${BOLD}common/${OFF} and ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])/${OFF}
|
---|
| 45 |
|
---|
[877cc6a] | 46 | Options:
|
---|
| 47 | ${BOLD} -h, --help${OFF}
|
---|
| 48 | print this help, then exit
|
---|
| 49 |
|
---|
| 50 | ${BOLD} -V, --version${OFF}
|
---|
| 51 | print version information, then exit
|
---|
| 52 |
|
---|
| 53 | ${BOLD} -B, --book VER${OFF}
|
---|
[e2fa2bd] | 54 | use VER version of the book as the system to build.
|
---|
[a6655ff] | 55 | Supported VER values are:
|
---|
| 56 | dev*, trunk, SVN = aliases for the Development version of {C,H}LFS
|
---|
| 57 | branch-NAME = a branch of name NAME
|
---|
| 58 | VERSION = the version of a stable released book
|
---|
[95a954c] | 59 | To know what branches and stable books work with this version of jhalfs
|
---|
[a6655ff] | 60 | please see http://wiki.linuxfromscratch.org/alfs/wiki/SupportedBooks
|
---|
[877cc6a] | 61 |
|
---|
| 62 | ${BOLD} -D --directory DIR${OFF}
|
---|
[73e5448] | 63 | use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs produces
|
---|
[1a1f099] | 64 | will be in the directory DIR/${SCRIPT_ROOT}.
|
---|
[511923a] | 65 | The current setting for BUILDDIR is "$BUILDDIR"
|
---|
[877cc6a] | 66 |
|
---|
| 67 | ${BOLD} -G, --get-packages${OFF}
|
---|
| 68 | download the packages and patches. This assumes that the server declared
|
---|
| 69 | in the configuration file has the proper packages and patches for the
|
---|
| 70 | book version being processed.
|
---|
| 71 |
|
---|
[1b65a84] | 72 | ${BOLD} -O, --optimize${OFF}
|
---|
| 73 | Optimize [0-2]
|
---|
| 74 | 0 = no optimization
|
---|
[1ec8fce] | 75 | 1 = optimize final system only
|
---|
| 76 | 2 = optimize both temporary tools and final system
|
---|
[1b65a84] | 77 | Edit common/opt_config{,.d/*} and common/opt_override as desired.
|
---|
| 78 |
|
---|
[877cc6a] | 79 | ${BOLD} -T, --testsuites N ${OFF}
|
---|
| 80 | Run test suites [0-3]
|
---|
| 81 | 0 = none
|
---|
[0755d1a] | 82 | 1 = only final system Glibc, GCC and Binutils testsuites
|
---|
| 83 | 2 = all final system testsuites
|
---|
[b240ee6] | 84 | 3 = all temporary tools and final system testsuites
|
---|
[83d73fb] | 85 | In CLFS and HLFS, 3 is an alias to 2
|
---|
[877cc6a] | 86 |
|
---|
| 87 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
| 88 | use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
|
---|
| 89 |
|
---|
[95a954c] | 90 | ${BOLD} -C, --comparison TYPE${OFF}
|
---|
[e2fa2bd] | 91 | do iterative comparison analysis. This extends the total build time
|
---|
| 92 | considerably because the entire final system will rebuild itself
|
---|
| 93 | the number of times specified by ITERATIONS in common/config.
|
---|
[6dcfd53] | 94 | Types allowed are:
|
---|
[e2fa2bd] | 95 | ICA = do ICA as designed by Greg Schafer
|
---|
[0ad851d] | 96 | farce = do the farce analysis designed by Ken Moffat
|
---|
[95a954c] | 97 | both = perform both ICA and farce analysis
|
---|
[45f82718] | 98 |
|
---|
[877cc6a] | 99 | ${BOLD} -F, --fstab FILE${OFF}
|
---|
| 100 | use FILE as the /etc/fstab file for the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} system. If not specified,
|
---|
| 101 | a default /etc/fstab file with dummy values is created.
|
---|
| 102 |
|
---|
| 103 | ${BOLD} -K, --kernel-config FILE${OFF}
|
---|
| 104 | use the kernel configuration file specified in FILE to build the kernel.
|
---|
| 105 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
| 106 |
|
---|
| 107 | ${BOLD} -M, --run-make${OFF}
|
---|
| 108 | run make on the generated Makefile
|
---|
| 109 |
|
---|
| 110 | ${BOLD} -R --rebuild${OFF}
|
---|
[95a954c] | 111 | clean the build directory before performing any other task. The directory
|
---|
[73e5448] | 112 | is cleaned only if it was populated by a previous jhalfs run.
|
---|
[877cc6a] | 113 | -EOF-
|
---|
| 114 |
|
---|
| 115 | [[ ${PROGNAME} = "clfs" ]] &&
|
---|
| 116 | cat <<- -EOF-
|
---|
| 117 |
|
---|
| 118 | ${BOLD} -A, --arch ARCH ${OFF}
|
---|
| 119 | Select the TARGET architecture, valid selections are:
|
---|
| 120 | 32bit builds
|
---|
[b0dd4bd] | 121 | x86, i486, i586, ppc, mips, mipsel, sparc
|
---|
[877cc6a] | 122 | 64bit builds
|
---|
| 123 | x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
|
---|
| 124 | 64bit multi-lib
|
---|
| 125 | x86_64, mips64, mipsel64, sparc64, ppc64
|
---|
| 126 |
|
---|
[c7c5a53] | 127 | ${BOLD} --boot-config FILE ${OFF}
|
---|
[877cc6a] | 128 | The configuration file for the bootstrap kernel if method=boot
|
---|
| 129 |
|
---|
| 130 | ${BOLD} --method BUILDMETHOD ${OFF}
|
---|
| 131 | Select the build method, chroot or boot
|
---|
| 132 | -EOF-
|
---|
| 133 |
|
---|
| 134 | [[ ${PROGNAME} = "hlfs" ]] &&
|
---|
| 135 | cat <<- -EOF-
|
---|
| 136 |
|
---|
| 137 | ${BOLD} --model STYLE ${OFF}
|
---|
| 138 | Select the library model for the HLFS system
|
---|
| 139 | Valid choices are: glibc or uclibc
|
---|
| 140 | -EOF-
|
---|
| 141 |
|
---|
| 142 | cat <<- -EOF-
|
---|
| 143 | ${DD_BORDER}
|
---|
| 144 | -EOF-
|
---|
| 145 | exit
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | version="
|
---|
[bae64d8] | 149 | ${BOLD} \"jhalfs\"${OFF} builder tool (branch 1.0.x) \$Rev$
|
---|
[877cc6a] | 150 | \$Date$
|
---|
| 151 |
|
---|
| 152 | ${BOLD} \"${PROGNAME}\"${OFF} script module
|
---|
| 153 |
|
---|
| 154 | Written by George Boudreau,
|
---|
| 155 | Manuel Canales Esparcia,
|
---|
| 156 | Jeremy Huntwork
|
---|
| 157 |
|
---|
| 158 | This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
|
---|
| 159 | "
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 | no_empty_builddir() {
|
---|
| 163 | 'clear'
|
---|
| 164 | cat <<- -EOF-
|
---|
| 165 | ${DD_BORDER}
|
---|
| 166 |
|
---|
| 167 | ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
---|
| 168 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
| 169 | from a previous HLFS build.
|
---|
| 170 |
|
---|
| 171 | Please format the partition mounted on \$BUILDDIR or set
|
---|
[73e5448] | 172 | a different build directory before running jhalfs.
|
---|
[877cc6a] | 173 | ${OFF}
|
---|
| 174 | ${DD_BORDER}
|
---|
| 175 | -EOF-
|
---|
| 176 | exit
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 |
|
---|
| 180 | help="${nl_}Try '$0 --help' for more information."
|
---|
| 181 |
|
---|
| 182 | exit_missing_arg="\
|
---|
| 183 | echo \"Option '\$1' requires an argument\" >&2
|
---|
| 184 | echo \"\$help\" >&2
|
---|
| 185 | exit 1"
|
---|
| 186 |
|
---|
[73e5448] | 187 | HEADER="# This file is automatically generated by jhalfs
|
---|
[877cc6a] | 188 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 189 | #
|
---|
| 190 | # Generated on `date \"+%F %X %Z\"`"
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 |
|
---|
| 194 | #----------------------------------#
|
---|
[3a321ea] | 195 | wrt_target() { # Create target and initialize log file
|
---|
[877cc6a] | 196 | #----------------------------------#
|
---|
| 197 | local i=$1
|
---|
| 198 | local PREV=$2
|
---|
[4edf3b7] | 199 | case $i in
|
---|
| 200 | iteration* ) local LOGFILE=$this_script.log ;;
|
---|
| 201 | * ) local LOGFILE=$this_script ;;
|
---|
| 202 | esac
|
---|
[877cc6a] | 203 | (
|
---|
| 204 | cat << EOF
|
---|
| 205 |
|
---|
| 206 | $i: $PREV
|
---|
| 207 | @\$(call echo_message, Building)
|
---|
[46758a2] | 208 | @./progress_bar.sh \$@ &
|
---|
[1a1f099] | 209 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE
|
---|
[877cc6a] | 210 | EOF
|
---|
| 211 | ) >> $MKFILE.tmp
|
---|
| 212 | }
|
---|
| 213 |
|
---|
[7eb9402] | 214 |
|
---|
| 215 | #----------------------------------#
|
---|
| 216 | wrt_target_boot() { # Create target and initialize log file
|
---|
| 217 | #----------------------------------#
|
---|
| 218 | local i=$1
|
---|
| 219 | local PREV=$2
|
---|
| 220 | case $i in
|
---|
| 221 | iteration* ) local LOGFILE=$this_script.log ;;
|
---|
| 222 | * ) local LOGFILE=$this_script ;;
|
---|
| 223 | esac
|
---|
| 224 | (
|
---|
| 225 | cat << EOF
|
---|
| 226 |
|
---|
| 227 | $i: $PREV
|
---|
| 228 | @\$(call echo_message, Building)
|
---|
| 229 | @./progress_bar.sh \$@ &
|
---|
| 230 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT}\`\n" >logs/$LOGFILE
|
---|
| 231 | EOF
|
---|
| 232 | ) >> $MKFILE.tmp
|
---|
| 233 | }
|
---|
| 234 |
|
---|
[dd29d02] | 235 | #----------------------------#
|
---|
| 236 | get_package_tarball_name() { #
|
---|
| 237 | #----------------------------#
|
---|
| 238 | local script_name=$1
|
---|
| 239 |
|
---|
| 240 | # The use of 'head' is necessary to limit the return value to the FIRST match..
|
---|
| 241 | # hopefully this will not cause problems.
|
---|
| 242 | #
|
---|
| 243 | case $script_name in
|
---|
[9357c13] | 244 | tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
| 245 | linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
| 246 | *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
[dd29d02] | 247 | esac
|
---|
| 248 |
|
---|
| 249 | }
|
---|
[877cc6a] | 250 |
|
---|
[5842156] | 251 | #----------------------------------#
|
---|
| 252 | wrt_remove_existing_dirs() { #
|
---|
| 253 | #----------------------------------#
|
---|
| 254 | local PKG_NAME=$1
|
---|
| 255 | (
|
---|
| 256 | cat << EOF
|
---|
[3b3251a] | 257 | @PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 258 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 259 | [[ -n \$\$ROOT ]] && \\
|
---|
| 260 | rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 261 | if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 262 | rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 263 | fi;
|
---|
| 264 | EOF
|
---|
| 265 | ) >> $MKFILE.tmp
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | #----------------------------------#
|
---|
| 269 | wrt_remove_existing_dirs2() { #
|
---|
| 270 | #----------------------------------#
|
---|
| 271 | local PKG_NAME=$1
|
---|
| 272 | (
|
---|
| 273 | cat << EOF
|
---|
[3b3251a] | 274 | @PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 275 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 276 | [[ -n \$\$ROOT ]] && \\
|
---|
| 277 | rm -rf \$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 278 | if [ -e \$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 279 | rm -rf \$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 280 | fi;
|
---|
| 281 | EOF
|
---|
| 282 | ) >> $MKFILE.tmp
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 |
|
---|
| 286 |
|
---|
[877cc6a] | 287 | #----------------------------------#
|
---|
| 288 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 289 | #----------------------------------#
|
---|
| 290 | local FILE=$1
|
---|
[5842156] | 291 | local optSAVE_PREVIOUS=$2
|
---|
[82eb8c1] | 292 |
|
---|
[5842156] | 293 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 294 | wrt_remove_existing_dirs "$FILE"
|
---|
| 295 | fi
|
---|
[877cc6a] | 296 | (
|
---|
| 297 | cat << EOF
|
---|
| 298 | @\$(call unpack,$FILE)
|
---|
[82eb8c1] | 299 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 300 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
[9357c13] | 301 | chown -R \$(LUSER) \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
[e5f5970] | 302 | EOF
|
---|
| 303 | ) >> $MKFILE.tmp
|
---|
| 304 | }
|
---|
| 305 |
|
---|
| 306 |
|
---|
[877cc6a] | 307 | #----------------------------------#
|
---|
| 308 | wrt_unpack2() { #
|
---|
| 309 | #----------------------------------#
|
---|
| 310 | local FILE=$1
|
---|
[5842156] | 311 | local optSAVE_PREVIOUS=$2
|
---|
| 312 |
|
---|
| 313 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 314 | wrt_remove_existing_dirs "$FILE"
|
---|
| 315 | fi
|
---|
[877cc6a] | 316 | (
|
---|
| 317 | cat << EOF
|
---|
| 318 | @\$(call unpack2,$FILE)
|
---|
[a229600] | 319 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 320 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 321 | EOF
|
---|
| 322 | ) >> $MKFILE.tmp
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 |
|
---|
[261eea6] | 326 | #----------------------------------#
|
---|
| 327 | wrt_unpack3() { #
|
---|
| 328 | #----------------------------------#
|
---|
[877cc6a] | 329 | local FILE=$1
|
---|
[5842156] | 330 | local optSAVE_PREVIOUS=$2
|
---|
| 331 |
|
---|
| 332 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 333 | wrt_remove_existing_dirs2 "$FILE"
|
---|
| 334 | fi
|
---|
[877cc6a] | 335 | (
|
---|
| 336 | cat << EOF
|
---|
| 337 | @\$(call unpack3,$FILE)
|
---|
[82eb8c1] | 338 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 339 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 340 | EOF
|
---|
| 341 | ) >> $MKFILE.tmp
|
---|
| 342 | }
|
---|
| 343 |
|
---|
[a229600] | 344 | #----------------------------------#
|
---|
| 345 | wrt_test_log() { # Initialize testsuite log file
|
---|
| 346 | #----------------------------------#
|
---|
| 347 | local TESTLOGFILE=$1
|
---|
| 348 | (
|
---|
| 349 | cat << EOF
|
---|
| 350 | @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
|
---|
[9357c13] | 351 | su - \$(LUSER) -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
|
---|
[a229600] | 352 | EOF
|
---|
| 353 | ) >> $MKFILE.tmp
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | #----------------------------------#
|
---|
| 357 | wrt_test_log2() { #
|
---|
| 358 | #----------------------------------#
|
---|
| 359 | local TESTLOGFILE=$1
|
---|
| 360 | (
|
---|
| 361 | cat << EOF
|
---|
| 362 | @echo "export TEST_LOG=/$SCRIPT_ROOT/test-logs/$TESTLOGFILE" >> envars && \\
|
---|
| 363 | echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
|
---|
| 364 | EOF
|
---|
| 365 | ) >> $MKFILE.tmp
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[877cc6a] | 368 | #----------------------------------#
|
---|
| 369 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
| 370 | #----------------------------------#
|
---|
| 371 | (
|
---|
| 372 | cat << EOF
|
---|
| 373 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
| 374 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
| 375 | EOF
|
---|
| 376 | ) >> $MKFILE.tmp
|
---|
| 377 |
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | #----------------------------------#
|
---|
[9357c13] | 382 | wrt_RunAsUser() { # Execute script inside time { }, footer to log file
|
---|
[877cc6a] | 383 | #----------------------------------#
|
---|
| 384 | local this_script=$1
|
---|
| 385 | local file=$2
|
---|
| 386 | (
|
---|
| 387 | cat << EOF
|
---|
[9357c13] | 388 | @( time { su - \$(LUSER) -c "source /home/\$(LUSER)/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 389 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
[877cc6a] | 390 | EOF
|
---|
| 391 | ) >> $MKFILE.tmp
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 |
|
---|
[e5f5970] | 395 | #----------------------------------#
|
---|
[9357c13] | 396 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
[e5f5970] | 397 | #----------------------------------#
|
---|
[9357c13] | 398 | local ENV_MOUNT
|
---|
[e5f5970] | 399 | local this_script=$1
|
---|
| 400 | local file=$2
|
---|
| 401 |
|
---|
[9357c13] | 402 | case ${PROGNAME} in
|
---|
| 403 | lfs ) MOUNT_ENV="LFS" ;;
|
---|
| 404 | blfs ) MOUNT_ENV="BLFS" ;;
|
---|
| 405 | clfs ) MOUNT_ENV="CLFS" ;;
|
---|
| 406 | clfs2 ) MOUNT_ENV="CLFS" ;;
|
---|
| 407 | hlfs ) MOUNT_ENV="HLFS" ;;
|
---|
| 408 | *) echo "undefined progname $PROGNAME"; exit 1
|
---|
| 409 | esac
|
---|
[e5f5970] | 410 |
|
---|
[ac1d897] | 411 | (
|
---|
| 412 | cat << EOF
|
---|
[9357c13] | 413 | @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[ac1d897] | 414 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 415 | EOF
|
---|
| 416 | ) >> $MKFILE.tmp
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 |
|
---|
[261eea6] | 420 | #----------------------------------#
|
---|
| 421 | wrt_run_as_root2() { #
|
---|
| 422 | #----------------------------------#
|
---|
[877cc6a] | 423 | local this_script=$1
|
---|
| 424 | local file=$2
|
---|
| 425 | (
|
---|
| 426 | cat << EOF
|
---|
[3a321ea] | 427 | @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 428 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
|
---|
[877cc6a] | 429 | EOF
|
---|
| 430 | ) >> $MKFILE.tmp
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 | #----------------------------------#
|
---|
| 435 | wrt_run_as_chroot1() { #
|
---|
| 436 | #----------------------------------#
|
---|
| 437 | local this_script=$1
|
---|
| 438 | local file=$2
|
---|
| 439 | (
|
---|
| 440 | cat << EOF
|
---|
[1a1f099] | 441 | @( time { \$(CHROOT1) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
| 442 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
[877cc6a] | 443 | EOF
|
---|
| 444 | ) >> $MKFILE.tmp
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 |
|
---|
| 448 | #----------------------------------#
|
---|
| 449 | wrt_run_as_chroot2() { #
|
---|
| 450 | #----------------------------------#
|
---|
| 451 | local this_script=$1
|
---|
| 452 | local file=$2
|
---|
| 453 | (
|
---|
| 454 | cat << EOF
|
---|
[1a1f099] | 455 | @( time { \$(CHROOT2) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
| 456 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
[877cc6a] | 457 | EOF
|
---|
| 458 | ) >> $MKFILE.tmp
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 |
|
---|
| 462 | #----------------------------------#
|
---|
| 463 | wrt_copy_fstab() { #
|
---|
| 464 | #----------------------------------#
|
---|
| 465 | local i=$1
|
---|
| 466 | (
|
---|
| 467 | cat << EOF
|
---|
[3a321ea] | 468 | @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 469 | EOF
|
---|
| 470 | ) >> $MKFILE.tmp
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 | #----------------------------------#
|
---|
[3a321ea] | 474 | wrt_copy_fstab2() { #
|
---|
[877cc6a] | 475 | #----------------------------------#
|
---|
| 476 | local i=$1
|
---|
| 477 | (
|
---|
| 478 | cat << EOF
|
---|
[3a321ea] | 479 | @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 480 | EOF
|
---|
| 481 | ) >> $MKFILE.tmp
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 |
|
---|
| 485 | #----------------------------------#
|
---|
[0bdf6ed] | 486 | wrt_remove_build_dirs() { #
|
---|
[877cc6a] | 487 | #----------------------------------#
|
---|
[0bdf6ed] | 488 | local name=$1
|
---|
[877cc6a] | 489 | (
|
---|
[0bdf6ed] | 490 | cat << EOF
|
---|
[82eb8c1] | 491 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[9357c13] | 492 | rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
[b7faa5a] | 493 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
[9357c13] | 494 | rm -rf \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
[0bdf6ed] | 495 | fi;
|
---|
| 496 | EOF
|
---|
| 497 | ) >> $MKFILE.tmp
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 |
|
---|
| 501 | #----------------------------------#
|
---|
| 502 | wrt_remove_build_dirs2() { #
|
---|
| 503 | #----------------------------------#
|
---|
| 504 | local name=$1
|
---|
| 505 | (
|
---|
| 506 | cat << EOF
|
---|
[82eb8c1] | 507 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[9357c13] | 508 | rm -rf \$(SRC)/\$\$ROOT && \\
|
---|
[b7faa5a] | 509 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
[9357c13] | 510 | rm -rf \$(SRC)/$name-build; \\
|
---|
[0bdf6ed] | 511 | fi;
|
---|
[877cc6a] | 512 | EOF
|
---|
| 513 | ) >> $MKFILE.tmp
|
---|
| 514 | }
|
---|
| 515 |
|
---|
| 516 |
|
---|
[e2ef100] | 517 | #----------------------------------#
|
---|
| 518 | wrt_touch() { #
|
---|
| 519 | #----------------------------------#
|
---|
| 520 | (
|
---|
| 521 | cat << EOF
|
---|
| 522 | @touch \$@ && \\
|
---|
| 523 | sleep .25 && \\
|
---|
[4a444f1] | 524 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 525 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[e2ef100] | 526 | EOF
|
---|
| 527 | ) >> $MKFILE.tmp
|
---|
| 528 | }
|
---|
| 529 |
|
---|
| 530 |
|
---|
[453bef0] | 531 | #----------------------------------#
|
---|
[261eea6] | 532 | wrt_report() { #
|
---|
[453bef0] | 533 | #----------------------------------#
|
---|
| 534 | (
|
---|
| 535 | cat << EOF
|
---|
| 536 |
|
---|
| 537 | create-sbu_du-report: $PREV
|
---|
| 538 | @\$(call echo_message, Building)
|
---|
[a9429d5] | 539 | @./create-sbu_du-report.sh logs $VERSION
|
---|
[453bef0] | 540 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
| 541 | @touch \$@
|
---|
| 542 | EOF
|
---|
| 543 | ) >> $MKFILE.tmp
|
---|
| 544 |
|
---|
| 545 | chapter789="$chapter789 create-sbu_du-report"
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 |
|
---|
[877cc6a] | 549 | #----------------------------#
|
---|
[261eea6] | 550 | run_make() { #
|
---|
[877cc6a] | 551 | #----------------------------#
|
---|
| 552 | # Test if make must be run.
|
---|
| 553 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
| 554 | # Test to make sure we're running the build as root
|
---|
| 555 | if [ "$UID" != "0" ] ; then
|
---|
| 556 | echo "You must be logged in as root to successfully build the system."
|
---|
| 557 | exit 1
|
---|
| 558 | fi
|
---|
| 559 | # Build the system
|
---|
| 560 | if [ -e $MKFILE ] ; then
|
---|
| 561 | echo -ne "Building the system...\n"
|
---|
[a167246] | 562 | cd $JHALFSDIR && make
|
---|
[877cc6a] | 563 | echo -ne "done\n"
|
---|
| 564 | fi
|
---|
| 565 | fi
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 |
|
---|
| 569 | #----------------------------#
|
---|
[261eea6] | 570 | clean_builddir() { #
|
---|
[877cc6a] | 571 | #----------------------------#
|
---|
| 572 | # Test if the clean must be done.
|
---|
| 573 | if [ "$CLEAN" = "1" ] ; then
|
---|
| 574 | # Test to make sure we're running the clean as root
|
---|
| 575 | if [ "$UID" != "0" ] ; then
|
---|
| 576 | echo "You must be logged in as root to clean the build directory."
|
---|
| 577 | exit 1
|
---|
| 578 | fi
|
---|
| 579 | # Test to make sure that the build directory was populated by jhalfs
|
---|
| 580 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
[73e5448] | 581 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
[877cc6a] | 582 | exit 1
|
---|
| 583 | else
|
---|
| 584 | # Clean the build directory
|
---|
| 585 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
| 586 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
|
---|
| 587 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
[dd29d02] | 588 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
|
---|
[877cc6a] | 589 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
| 590 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
| 591 | echo -ne "done\n"
|
---|
| 592 | fi
|
---|
| 593 | fi
|
---|
| 594 | }
|
---|
| 595 |
|
---|
| 596 | #----------------------------#
|
---|
[261eea6] | 597 | get_book() { #
|
---|
[877cc6a] | 598 | #----------------------------#
|
---|
| 599 | cd $JHALFSDIR
|
---|
| 600 |
|
---|
| 601 | if [ -z $WC ] ; then
|
---|
| 602 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
| 603 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
| 604 | exit 1"
|
---|
| 605 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
| 606 |
|
---|
| 607 | case $PROGNAME in
|
---|
| 608 | lfs) svn_root="LFS" ;;
|
---|
| 609 | hlfs) svn_root="HLFS" ;;
|
---|
| 610 | clfs) svn_root="cross-lfs" ;;
|
---|
| 611 | *) echo "BOOK not defined in function <get_book>"
|
---|
| 612 | exit 1 ;;
|
---|
| 613 | esac
|
---|
| 614 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
| 615 | # repo. If we've already extracted the commands, move on to getting the
|
---|
| 616 | # sources.
|
---|
| 617 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
| 618 | cd ${PROGNAME}-$LFSVRS
|
---|
[1ff6768] | 619 | if LC_ALL=C svn up | grep -q At && \
|
---|
| 620 | test -d $JHALFSDIR/${PROGNAME}-commands && \
|
---|
| 621 | test -f $JHALFSDIR/pkg_tarball_list ; then
|
---|
[877cc6a] | 622 | # Set the canonical book version
|
---|
[a6655ff] | 623 | echo -ne "done\n"
|
---|
[877cc6a] | 624 | cd $JHALFSDIR
|
---|
[1ff6768] | 625 | case $PROGNAME in
|
---|
| 626 | clfs)
|
---|
| 627 | VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 628 | *)
|
---|
| 629 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 630 | esac
|
---|
[877cc6a] | 631 | get_sources
|
---|
| 632 | else
|
---|
| 633 | echo -ne "done\n"
|
---|
| 634 | extract_commands
|
---|
| 635 | fi
|
---|
| 636 | else
|
---|
[a6655ff] | 637 | svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
[877cc6a] | 638 | echo -ne "done\n"
|
---|
| 639 | extract_commands
|
---|
| 640 | fi
|
---|
[1ff6768] | 641 |
|
---|
[877cc6a] | 642 | else
|
---|
| 643 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
| 644 | extract_commands
|
---|
| 645 | fi
|
---|
[a6655ff] | 646 | echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
|
---|
[877cc6a] | 647 | }
|
---|
| 648 |
|
---|
| 649 | #----------------------------#
|
---|
| 650 | extract_commands() { #
|
---|
| 651 | #----------------------------#
|
---|
| 652 |
|
---|
| 653 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
| 654 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
| 655 | exit 1"
|
---|
| 656 |
|
---|
| 657 | cd $JHALFSDIR
|
---|
[1ff6768] | 658 | case $PROGNAME in
|
---|
[a6655ff] | 659 | clfs)
|
---|
[1ff6768] | 660 | VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 661 | *)
|
---|
| 662 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 663 | esac
|
---|
[877cc6a] | 664 |
|
---|
| 665 | # Start clean
|
---|
[bfc07d6] | 666 | if [ -d ${PROGNAME}-commands ]; then
|
---|
| 667 | rm -rf ${PROGNAME}-commands
|
---|
| 668 | mkdir -v ${PROGNAME}-commands
|
---|
[877cc6a] | 669 | fi
|
---|
| 670 | echo -n "Extracting commands for"
|
---|
| 671 |
|
---|
| 672 | # Dump the commands in shell script form from the HLFS book.
|
---|
| 673 | case ${PROGNAME} in
|
---|
| 674 | clfs)
|
---|
| 675 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 676 | xsltproc --nonet \
|
---|
| 677 | --xinclude \
|
---|
| 678 | --stringparam method $METHOD \
|
---|
| 679 | --stringparam testsuite $TEST \
|
---|
[05ccaa9] | 680 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 681 | --stringparam vim-lang $VIMLANG \
|
---|
| 682 | --stringparam timezone $TIMEZONE \
|
---|
| 683 | --stringparam page $PAGE \
|
---|
| 684 | --stringparam lang $LANG \
|
---|
| 685 | --stringparam keymap $KEYMAP \
|
---|
| 686 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 687 | ;;
|
---|
| 688 | hlfs)
|
---|
| 689 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
| 690 | xsltproc --nonet \
|
---|
| 691 | --xinclude \
|
---|
| 692 | --stringparam model $MODEL \
|
---|
| 693 | --stringparam testsuite $TEST \
|
---|
[05ccaa9] | 694 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 695 | --stringparam timezone $TIMEZONE \
|
---|
| 696 | --stringparam page $PAGE \
|
---|
| 697 | --stringparam lang $LANG \
|
---|
| 698 | --stringparam lc_all $LC_ALL \
|
---|
| 699 | --stringparam keymap $KEYMAP \
|
---|
| 700 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
| 701 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 702 | ;;
|
---|
| 703 | lfs)
|
---|
| 704 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
| 705 | xsltproc --nonet \
|
---|
| 706 | --xinclude \
|
---|
| 707 | --stringparam testsuite $TEST \
|
---|
[05ccaa9] | 708 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 709 | --stringparam vim-lang $VIMLANG \
|
---|
| 710 | --stringparam timezone $TIMEZONE \
|
---|
| 711 | --stringparam page $PAGE \
|
---|
| 712 | --stringparam lang $LANG \
|
---|
| 713 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 714 | ;;
|
---|
[15cad16] | 715 | *) exit 1 ;;
|
---|
[877cc6a] | 716 | esac
|
---|
| 717 |
|
---|
| 718 | echo " ...OK"
|
---|
| 719 |
|
---|
| 720 | # Make the scripts executable.
|
---|
| 721 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
| 722 |
|
---|
[15cad16] | 723 | # Create the packages file. We need it for proper Makefile creation
|
---|
[dd29d02] | 724 | create_package_list
|
---|
[877cc6a] | 725 |
|
---|
| 726 | # Done. Moving on...
|
---|
| 727 | get_sources
|
---|
| 728 | }
|
---|
| 729 |
|
---|
[dd29d02] | 730 | #----------------------------#
|
---|
| 731 | create_package_list() { #
|
---|
| 732 | #----------------------------#
|
---|
| 733 |
|
---|
| 734 | # Create the packages file. We need it for proper Makefile creation
|
---|
| 735 | rm -f pkg_tarball_list
|
---|
| 736 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
|
---|
| 737 | case ${PROGNAME} in
|
---|
| 738 | clfs)
|
---|
| 739 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 740 | $BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 741 | ;;
|
---|
| 742 | hlfs)
|
---|
| 743 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 744 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 745 | ;;
|
---|
| 746 | lfs)
|
---|
| 747 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 748 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 749 | ;;
|
---|
| 750 | esac
|
---|
| 751 | echo " ...OK"
|
---|
| 752 |
|
---|
| 753 | }
|
---|
| 754 |
|
---|
| 755 |
|
---|
[877cc6a] | 756 | #----------------------------#
|
---|
[15cad16] | 757 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
[93135fd] | 758 | #----------------------------#
|
---|
| 759 | local saveIFS=$IFS
|
---|
[26053c4] | 760 | local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
|
---|
[93135fd] | 761 |
|
---|
| 762 | # Test if the packages must be downloaded
|
---|
| 763 | [ ! "$GETPKG" = "1" ] && return
|
---|
| 764 |
|
---|
| 765 | gs_wrt_message(){
|
---|
| 766 | echo "${RED}$1${OFF}"
|
---|
[c7dbe78] | 767 | echo "$1" >> MISSING_FILES.DMP
|
---|
| 768 | }
|
---|
[93135fd] | 769 | # Housekeeping
|
---|
| 770 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
| 771 | cd $BUILDDIR/sources
|
---|
| 772 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
| 773 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
| 774 | [[ -f urls.lst ]] && rm urls.lst
|
---|
| 775 |
|
---|
| 776 | # Generate URLs file
|
---|
| 777 | create_urls
|
---|
| 778 |
|
---|
| 779 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 780 | for line in `cat urls.lst`; do
|
---|
| 781 | IFS=$saveIFS # Restore the system defaults
|
---|
| 782 |
|
---|
| 783 | # Skip some packages if they aren't needed
|
---|
| 784 | case $line in
|
---|
| 785 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
| 786 | [[ "$TEST" = "0" ]] && continue
|
---|
| 787 | ;;
|
---|
| 788 | */vim-*-lang* )
|
---|
| 789 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
| 790 | ;;
|
---|
[0c3f2f9] | 791 | *linux/linux-* )
|
---|
[294c937] | 792 | [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
|
---|
| 793 | [[ "$GETKERNEL" = "0" ]] && continue
|
---|
[0c3f2f9] | 794 | ;;
|
---|
[93135fd] | 795 | esac
|
---|
| 796 |
|
---|
| 797 | # Locations
|
---|
[296ae69] | 798 | URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
---|
| 799 | URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
---|
[26053c4] | 800 | FILE=`basename $URL1` # File name
|
---|
| 801 | BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
---|
| 802 |
|
---|
[8a43b5b] | 803 | # Validation pair
|
---|
| 804 | MD5="$BOOKMD5 $FILE"
|
---|
| 805 | HAVEMD5=1
|
---|
[93135fd] | 806 |
|
---|
| 807 | set -e
|
---|
[c7dbe78] | 808 | # If the file exists in the archive copy it to the
|
---|
[93135fd] | 809 | # $BUILDDIR/sources dir. MD5SUM will be validated later.
|
---|
| 810 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 811 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 812 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
| 813 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
| 814 | echo "$FILE: -- copied from $SRC_ARCHIVE"
|
---|
| 815 | fromARCHIVE=1
|
---|
| 816 | else
|
---|
| 817 | echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
|
---|
| 818 | fromARCHIVE=0
|
---|
[8a43b5b] | 819 | # If the file does not exist yet in /sources download a fresh one
|
---|
[93135fd] | 820 | if [ ! -f $FILE ] ; then
|
---|
| 821 | if ! wget $URL1 && ! wget $URL2 ; then
|
---|
[c7dbe78] | 822 | gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
---|
| 823 | continue
|
---|
[93135fd] | 824 | fi
|
---|
| 825 | fi
|
---|
| 826 | fi
|
---|
| 827 |
|
---|
[8a43b5b] | 828 | # IF the md5sum does not match the existing files
|
---|
| 829 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
| 830 | [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
---|
| 831 | [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
---|
| 832 | # Remove the old file and download a new one
|
---|
| 833 | rm -fv $FILE
|
---|
| 834 | # Force storage in SRC_ARCHIVE
|
---|
| 835 | fromARCHIVE=0;
|
---|
| 836 | # Try to retrieve again the file. Servers in reverse order.
|
---|
| 837 | if ! wget $URL2 && ! wget $URL1 ; then
|
---|
| 838 | gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
---|
| 839 | continue
|
---|
[93135fd] | 840 | fi
|
---|
| 841 | fi
|
---|
| 842 |
|
---|
| 843 | # Validate the MD5SUM one last time
|
---|
[8a43b5b] | 844 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
[93135fd] | 845 | gs_wrt_message "$FILE does not match MD5SUMS value"
|
---|
[0910f55] | 846 | # Force generation of MD5SUM
|
---|
| 847 | HAVEMD5=0
|
---|
[93135fd] | 848 | fi
|
---|
| 849 |
|
---|
| 850 | # Generate a fresh MD5SUM for this file
|
---|
| 851 | if [[ "$HAVEMD5" = "0" ]] ; then
|
---|
| 852 | echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
---|
[8a43b5b] | 853 | echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
---|
[93135fd] | 854 | fi
|
---|
| 855 |
|
---|
| 856 | # Good or bad we write the original md5sum to a file
|
---|
[8a43b5b] | 857 | echo "$MD5" >> MD5SUMS
|
---|
[93135fd] | 858 |
|
---|
| 859 | # Copy the freshly downloaded file
|
---|
| 860 | # to the source archive.
|
---|
| 861 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 862 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 863 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
| 864 | [ "$fromARCHIVE" = "0" ] ; then
|
---|
| 865 | echo "Storing file:<$FILE> in the package archive"
|
---|
| 866 | cp -f $FILE ${SRC_ARCHIVE}
|
---|
| 867 | fi
|
---|
| 868 |
|
---|
| 869 | done
|
---|
| 870 |
|
---|
| 871 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
[95a954c] | 872 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have bad MD5SUMS.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
|
---|
| 873 | # Do not allow the automatic execution of the Makefile.
|
---|
[261eea6] | 874 | echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
|
---|
[93135fd] | 875 | RUNMAKE=0
|
---|
| 876 | fi
|
---|
| 877 | }
|
---|
| 878 |
|
---|
[877cc6a] | 879 | #----------------------------#
|
---|
[15cad16] | 880 | create_urls() { #
|
---|
[877cc6a] | 881 | #----------------------------#
|
---|
[15cad16] | 882 | cd $JHALFSDIR
|
---|
[877cc6a] | 883 |
|
---|
[15cad16] | 884 | case ${PROGNAME} in
|
---|
| 885 | clfs)
|
---|
| 886 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
| 887 | xsltproc --nonet --xinclude \
|
---|
| 888 | --stringparam server $SERVER \
|
---|
| 889 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 890 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 891 | echo " ...OK"
|
---|
| 892 | ;;
|
---|
| 893 | hlfs)
|
---|
| 894 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
| 895 | xsltproc --nonet --xinclude \
|
---|
| 896 | --stringparam server $SERVER \
|
---|
| 897 | --stringparam model $MODEL \
|
---|
| 898 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 899 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 900 | echo " ...OK"
|
---|
| 901 | ;;
|
---|
| 902 | lfs)
|
---|
| 903 | echo -n "Creating LFS specific URLs file"
|
---|
| 904 | xsltproc --nonet --xinclude \
|
---|
| 905 | --stringparam server $SERVER \
|
---|
| 906 | -o ../sources/urls.lst urls.xsl \
|
---|
| 907 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 908 | echo " ...OK"
|
---|
| 909 | ;;
|
---|
| 910 | esac
|
---|
[877cc6a] | 911 |
|
---|
[15cad16] | 912 | cd $BUILDDIR/sources
|
---|
[877cc6a] | 913 | }
|
---|