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