[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
|
---|
[d385453] | 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
|
---|
[d81c640] | 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 |
|
---|
[d385453] | 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
|
---|
[d385453] | 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}
|
---|
[d385453] | 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 |
|
---|
[7432834] | 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 |
|
---|
[877cc6a] | 146 | [[ ${PROGNAME} = "hlfs" ]] &&
|
---|
| 147 | cat <<- -EOF-
|
---|
| 148 |
|
---|
| 149 | ${BOLD} --model STYLE ${OFF}
|
---|
| 150 | Select the library model for the HLFS system
|
---|
| 151 | Valid choices are: glibc or uclibc
|
---|
| 152 | -EOF-
|
---|
| 153 |
|
---|
| 154 | cat <<- -EOF-
|
---|
| 155 | ${DD_BORDER}
|
---|
| 156 | -EOF-
|
---|
| 157 | exit
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | version="
|
---|
[73e5448] | 161 | ${BOLD} \"jhalfs\"${OFF} builder tool (development) \$Rev$
|
---|
[877cc6a] | 162 | \$Date$
|
---|
| 163 |
|
---|
| 164 | ${BOLD} \"${PROGNAME}\"${OFF} script module
|
---|
| 165 |
|
---|
| 166 | Written by George Boudreau,
|
---|
| 167 | Manuel Canales Esparcia,
|
---|
| 168 | Jeremy Huntwork
|
---|
| 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
|
---|
[73e5448] | 184 | a different build directory before running jhalfs.
|
---|
[877cc6a] | 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 |
|
---|
[73e5448] | 199 | HEADER="# This file is automatically generated by jhalfs
|
---|
[877cc6a] | 200 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
| 201 | #
|
---|
| 202 | # Generated on `date \"+%F %X %Z\"`"
|
---|
| 203 |
|
---|
| 204 |
|
---|
| 205 |
|
---|
| 206 | #----------------------------------#
|
---|
[3a321ea] | 207 | wrt_target() { # Create target and initialize log file
|
---|
[877cc6a] | 208 | #----------------------------------#
|
---|
| 209 | local i=$1
|
---|
| 210 | local PREV=$2
|
---|
[4edf3b7] | 211 | case $i in
|
---|
| 212 | iteration* ) local LOGFILE=$this_script.log ;;
|
---|
| 213 | * ) local LOGFILE=$this_script ;;
|
---|
| 214 | esac
|
---|
[877cc6a] | 215 | (
|
---|
| 216 | cat << EOF
|
---|
| 217 |
|
---|
| 218 | $i: $PREV
|
---|
| 219 | @\$(call echo_message, Building)
|
---|
[46758a2] | 220 | @./progress_bar.sh \$@ &
|
---|
[1a1f099] | 221 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE
|
---|
[877cc6a] | 222 | EOF
|
---|
| 223 | ) >> $MKFILE.tmp
|
---|
| 224 | }
|
---|
| 225 |
|
---|
[7eb9402] | 226 |
|
---|
| 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 |
|
---|
[dd29d02] | 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
|
---|
[6ad5a2f] | 256 | tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
[983db9f] | 257 | linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
[6ad5a2f] | 258 | *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
[dd29d02] | 259 | esac
|
---|
| 260 |
|
---|
| 261 | }
|
---|
[877cc6a] | 262 |
|
---|
[5842156] | 263 | #----------------------------------#
|
---|
| 264 | wrt_remove_existing_dirs() { #
|
---|
| 265 | #----------------------------------#
|
---|
| 266 | local PKG_NAME=$1
|
---|
| 267 | (
|
---|
| 268 | cat << EOF
|
---|
[3b3251a] | 269 | @PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 270 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 271 | [[ -n \$\$ROOT ]] && \\
|
---|
| 272 | rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 273 | if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 274 | rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 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
|
---|
[3b3251a] | 286 | @PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 287 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 288 | [[ -n \$\$ROOT ]] && \\
|
---|
| 289 | rm -rf \$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 290 | if [ -e \$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 291 | rm -rf \$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 292 | fi;
|
---|
| 293 | EOF
|
---|
| 294 | ) >> $MKFILE.tmp
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 |
|
---|
| 298 |
|
---|
[877cc6a] | 299 | #----------------------------------#
|
---|
| 300 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 301 | #----------------------------------#
|
---|
| 302 | local FILE=$1
|
---|
[5842156] | 303 | local optSAVE_PREVIOUS=$2
|
---|
[82eb8c1] | 304 |
|
---|
[5842156] | 305 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 306 | wrt_remove_existing_dirs "$FILE"
|
---|
| 307 | fi
|
---|
[877cc6a] | 308 | (
|
---|
| 309 | cat << EOF
|
---|
| 310 | @\$(call unpack,$FILE)
|
---|
[82eb8c1] | 311 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 312 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
[6ad5a2f] | 313 | chown -R \$(LUSER) \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
[e5f5970] | 314 | EOF
|
---|
| 315 | ) >> $MKFILE.tmp
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 |
|
---|
[877cc6a] | 319 | #----------------------------------#
|
---|
| 320 | wrt_unpack2() { #
|
---|
| 321 | #----------------------------------#
|
---|
| 322 | local FILE=$1
|
---|
[5842156] | 323 | local optSAVE_PREVIOUS=$2
|
---|
| 324 |
|
---|
| 325 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 326 | wrt_remove_existing_dirs "$FILE"
|
---|
| 327 | fi
|
---|
[877cc6a] | 328 | (
|
---|
| 329 | cat << EOF
|
---|
| 330 | @\$(call unpack2,$FILE)
|
---|
[a229600] | 331 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 332 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 333 | EOF
|
---|
| 334 | ) >> $MKFILE.tmp
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 |
|
---|
[261eea6] | 338 | #----------------------------------#
|
---|
| 339 | wrt_unpack3() { #
|
---|
| 340 | #----------------------------------#
|
---|
[877cc6a] | 341 | local FILE=$1
|
---|
[5842156] | 342 | local optSAVE_PREVIOUS=$2
|
---|
| 343 |
|
---|
| 344 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 345 | wrt_remove_existing_dirs2 "$FILE"
|
---|
| 346 | fi
|
---|
[877cc6a] | 347 | (
|
---|
| 348 | cat << EOF
|
---|
| 349 | @\$(call unpack3,$FILE)
|
---|
[82eb8c1] | 350 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 351 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 352 | EOF
|
---|
| 353 | ) >> $MKFILE.tmp
|
---|
| 354 | }
|
---|
| 355 |
|
---|
[a229600] | 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 && \\
|
---|
[6ad5a2f] | 363 | su - \$(LUSER) -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
|
---|
[a229600] | 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 |
|
---|
[877cc6a] | 380 | #----------------------------------#
|
---|
| 381 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
| 382 | #----------------------------------#
|
---|
| 383 | (
|
---|
| 384 | cat << EOF
|
---|
| 385 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
| 386 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
| 387 | EOF
|
---|
| 388 | ) >> $MKFILE.tmp
|
---|
| 389 |
|
---|
| 390 | }
|
---|
| 391 |
|
---|
| 392 |
|
---|
| 393 | #----------------------------------#
|
---|
[6ad5a2f] | 394 | wrt_RunAsUser() { # Execute script inside time { }, footer to log file
|
---|
[877cc6a] | 395 | #----------------------------------#
|
---|
| 396 | local this_script=$1
|
---|
| 397 | local file=$2
|
---|
| 398 | (
|
---|
| 399 | cat << EOF
|
---|
[6ad5a2f] | 400 | @( time { su - \$(LUSER) -c "source /home/\$(LUSER)/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 401 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
[877cc6a] | 402 | EOF
|
---|
| 403 | ) >> $MKFILE.tmp
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 |
|
---|
[e5f5970] | 407 | #----------------------------------#
|
---|
[6ad5a2f] | 408 | wrt_RunAsRoot() { # Some scripts must be run as root..
|
---|
[e5f5970] | 409 | #----------------------------------#
|
---|
[6ad5a2f] | 410 | local ENV_MOUNT
|
---|
[e5f5970] | 411 | local this_script=$1
|
---|
| 412 | local file=$2
|
---|
| 413 |
|
---|
[6ad5a2f] | 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
|
---|
[e5f5970] | 422 |
|
---|
[ac1d897] | 423 | (
|
---|
| 424 | cat << EOF
|
---|
[6ad5a2f] | 425 | @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[ac1d897] | 426 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 427 | EOF
|
---|
| 428 | ) >> $MKFILE.tmp
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 |
|
---|
[261eea6] | 432 | #----------------------------------#
|
---|
| 433 | wrt_run_as_root2() { #
|
---|
| 434 | #----------------------------------#
|
---|
[877cc6a] | 435 | local this_script=$1
|
---|
| 436 | local file=$2
|
---|
| 437 | (
|
---|
| 438 | cat << EOF
|
---|
[3a321ea] | 439 | @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 440 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
|
---|
[877cc6a] | 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
|
---|
[1a1f099] | 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}
|
---|
[877cc6a] | 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
|
---|
[1a1f099] | 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}
|
---|
[877cc6a] | 469 | EOF
|
---|
| 470 | ) >> $MKFILE.tmp
|
---|
| 471 | }
|
---|
| 472 |
|
---|
| 473 |
|
---|
| 474 | #----------------------------------#
|
---|
| 475 | wrt_copy_fstab() { #
|
---|
| 476 | #----------------------------------#
|
---|
| 477 | local i=$1
|
---|
| 478 | (
|
---|
| 479 | cat << EOF
|
---|
[3a321ea] | 480 | @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 481 | EOF
|
---|
| 482 | ) >> $MKFILE.tmp
|
---|
| 483 | }
|
---|
| 484 |
|
---|
| 485 | #----------------------------------#
|
---|
[3a321ea] | 486 | wrt_copy_fstab2() { #
|
---|
[877cc6a] | 487 | #----------------------------------#
|
---|
| 488 | local i=$1
|
---|
| 489 | (
|
---|
| 490 | cat << EOF
|
---|
[3a321ea] | 491 | @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 492 | EOF
|
---|
| 493 | ) >> $MKFILE.tmp
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 |
|
---|
| 497 | #----------------------------------#
|
---|
[0bdf6ed] | 498 | wrt_remove_build_dirs() { #
|
---|
[877cc6a] | 499 | #----------------------------------#
|
---|
[0bdf6ed] | 500 | local name=$1
|
---|
[877cc6a] | 501 | (
|
---|
[0bdf6ed] | 502 | cat << EOF
|
---|
[82eb8c1] | 503 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[6ad5a2f] | 504 | rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
[b7faa5a] | 505 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
[6ad5a2f] | 506 | rm -rf \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
[0bdf6ed] | 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
|
---|
[82eb8c1] | 519 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[6ad5a2f] | 520 | rm -rf \$(SRC)/\$\$ROOT && \\
|
---|
[b7faa5a] | 521 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
[6ad5a2f] | 522 | rm -rf \$(SRC)/$name-build; \\
|
---|
[0bdf6ed] | 523 | fi;
|
---|
[877cc6a] | 524 | EOF
|
---|
| 525 | ) >> $MKFILE.tmp
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 |
|
---|
[e2ef100] | 529 | #----------------------------------#
|
---|
| 530 | wrt_touch() { #
|
---|
| 531 | #----------------------------------#
|
---|
| 532 | (
|
---|
| 533 | cat << EOF
|
---|
| 534 | @touch \$@ && \\
|
---|
| 535 | sleep .25 && \\
|
---|
[4a444f1] | 536 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 537 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[e2ef100] | 538 | EOF
|
---|
| 539 | ) >> $MKFILE.tmp
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 |
|
---|
[453bef0] | 543 | #----------------------------------#
|
---|
[261eea6] | 544 | wrt_report() { #
|
---|
[453bef0] | 545 | #----------------------------------#
|
---|
| 546 | (
|
---|
| 547 | cat << EOF
|
---|
| 548 |
|
---|
| 549 | create-sbu_du-report: $PREV
|
---|
| 550 | @\$(call echo_message, Building)
|
---|
[a9429d5] | 551 | @./create-sbu_du-report.sh logs $VERSION
|
---|
[453bef0] | 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 |
|
---|
[877cc6a] | 561 | #----------------------------#
|
---|
[261eea6] | 562 | run_make() { #
|
---|
[877cc6a] | 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
|
---|
| 568 | echo "You must be logged in as root to successfully build the system."
|
---|
| 569 | exit 1
|
---|
| 570 | fi
|
---|
| 571 | # Build the system
|
---|
| 572 | if [ -e $MKFILE ] ; then
|
---|
| 573 | echo -ne "Building the system...\n"
|
---|
[a167246] | 574 | cd $JHALFSDIR && make
|
---|
[877cc6a] | 575 | echo -ne "done\n"
|
---|
| 576 | fi
|
---|
| 577 | fi
|
---|
| 578 | }
|
---|
| 579 |
|
---|
| 580 |
|
---|
| 581 | #----------------------------#
|
---|
[261eea6] | 582 | clean_builddir() { #
|
---|
[877cc6a] | 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
|
---|
[73e5448] | 593 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
[877cc6a] | 594 | exit 1
|
---|
| 595 | else
|
---|
| 596 | # Clean the build directory
|
---|
| 597 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
| 598 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
|
---|
| 599 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
[dd29d02] | 600 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
|
---|
[877cc6a] | 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 | #----------------------------#
|
---|
[261eea6] | 609 | get_book() { #
|
---|
[877cc6a] | 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" ;;
|
---|
[7432834] | 623 | clfs2) svn_root="cross-lfs" ;;
|
---|
[877cc6a] | 624 | *) echo "BOOK not defined in function <get_book>"
|
---|
| 625 | exit 1 ;;
|
---|
| 626 | esac
|
---|
| 627 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
| 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
|
---|
[1ff6768] | 632 | if LC_ALL=C svn up | grep -q At && \
|
---|
| 633 | test -d $JHALFSDIR/${PROGNAME}-commands && \
|
---|
| 634 | test -f $JHALFSDIR/pkg_tarball_list ; then
|
---|
[877cc6a] | 635 | # Set the canonical book version
|
---|
[a6655ff] | 636 | echo -ne "done\n"
|
---|
[877cc6a] | 637 | cd $JHALFSDIR
|
---|
[1ff6768] | 638 | case $PROGNAME in
|
---|
[7432834] | 639 | clfs | clfs2)
|
---|
[1ff6768] | 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
|
---|
[877cc6a] | 644 | get_sources
|
---|
| 645 | else
|
---|
| 646 | echo -ne "done\n"
|
---|
| 647 | extract_commands
|
---|
| 648 | fi
|
---|
| 649 | else
|
---|
[cb39f79] | 650 | svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
[877cc6a] | 651 | echo -ne "done\n"
|
---|
| 652 | extract_commands
|
---|
| 653 | fi
|
---|
[1ff6768] | 654 |
|
---|
[877cc6a] | 655 | else
|
---|
| 656 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
| 657 | extract_commands
|
---|
| 658 | fi
|
---|
[a6655ff] | 659 | echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
|
---|
[877cc6a] | 660 | }
|
---|
| 661 |
|
---|
| 662 | #----------------------------#
|
---|
| 663 | extract_commands() { #
|
---|
| 664 | #----------------------------#
|
---|
| 665 |
|
---|
| 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
|
---|
[1ff6768] | 671 | case $PROGNAME in
|
---|
[7432834] | 672 | clfs | clfs2 )
|
---|
[1ff6768] | 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
|
---|
[877cc6a] | 677 |
|
---|
| 678 | # Start clean
|
---|
[bfc07d6] | 679 | if [ -d ${PROGNAME}-commands ]; then
|
---|
| 680 | rm -rf ${PROGNAME}-commands
|
---|
| 681 | mkdir -v ${PROGNAME}-commands
|
---|
[877cc6a] | 682 | fi
|
---|
| 683 | echo -n "Extracting commands for"
|
---|
| 684 |
|
---|
| 685 | # Dump the commands in shell script form from the HLFS book.
|
---|
| 686 | case ${PROGNAME} in
|
---|
| 687 | clfs)
|
---|
| 688 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 689 | xsltproc --nonet \
|
---|
| 690 | --xinclude \
|
---|
| 691 | --stringparam method $METHOD \
|
---|
| 692 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 693 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 694 | --stringparam vim-lang $VIMLANG \
|
---|
| 695 | --stringparam timezone $TIMEZONE \
|
---|
| 696 | --stringparam page $PAGE \
|
---|
| 697 | --stringparam lang $LANG \
|
---|
| 698 | --stringparam keymap $KEYMAP \
|
---|
| 699 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 700 | ;;
|
---|
[7432834] | 701 |
|
---|
| 702 | clfs2)
|
---|
| 703 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 704 | xsltproc --nonet \
|
---|
| 705 | --xinclude \
|
---|
| 706 | --stringparam vim-lang $VIMLANG \
|
---|
| 707 | --stringparam timezone $TIMEZONE \
|
---|
| 708 | --stringparam page $PAGE \
|
---|
| 709 | --stringparam lang $LANG \
|
---|
| 710 | --stringparam keymap $KEYMAP \
|
---|
| 711 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 712 | ;;
|
---|
[877cc6a] | 713 | hlfs)
|
---|
| 714 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
| 715 | xsltproc --nonet \
|
---|
| 716 | --xinclude \
|
---|
| 717 | --stringparam model $MODEL \
|
---|
| 718 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 719 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 720 | --stringparam timezone $TIMEZONE \
|
---|
| 721 | --stringparam page $PAGE \
|
---|
| 722 | --stringparam lang $LANG \
|
---|
| 723 | --stringparam lc_all $LC_ALL \
|
---|
| 724 | --stringparam keymap $KEYMAP \
|
---|
| 725 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
| 726 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 727 | ;;
|
---|
| 728 | lfs)
|
---|
| 729 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
| 730 | xsltproc --nonet \
|
---|
| 731 | --xinclude \
|
---|
| 732 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 733 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 734 | --stringparam vim-lang $VIMLANG \
|
---|
| 735 | --stringparam timezone $TIMEZONE \
|
---|
| 736 | --stringparam page $PAGE \
|
---|
| 737 | --stringparam lang $LANG \
|
---|
| 738 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 739 | ;;
|
---|
[15cad16] | 740 | *) exit 1 ;;
|
---|
[877cc6a] | 741 | esac
|
---|
| 742 |
|
---|
| 743 | echo " ...OK"
|
---|
| 744 |
|
---|
| 745 | # Make the scripts executable.
|
---|
| 746 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
| 747 |
|
---|
[15cad16] | 748 | # Create the packages file. We need it for proper Makefile creation
|
---|
[dd29d02] | 749 | create_package_list
|
---|
[877cc6a] | 750 |
|
---|
| 751 | # Done. Moving on...
|
---|
| 752 | get_sources
|
---|
| 753 | }
|
---|
| 754 |
|
---|
[dd29d02] | 755 | #----------------------------#
|
---|
| 756 | create_package_list() { #
|
---|
| 757 | #----------------------------#
|
---|
| 758 |
|
---|
| 759 | # Create the packages file. We need it for proper Makefile creation
|
---|
| 760 | rm -f pkg_tarball_list
|
---|
| 761 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
|
---|
| 762 | case ${PROGNAME} in
|
---|
[7432834] | 763 | clfs | clfs2)
|
---|
[dd29d02] | 764 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 765 | $BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 766 | ;;
|
---|
| 767 | hlfs)
|
---|
| 768 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 769 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 770 | ;;
|
---|
| 771 | lfs)
|
---|
| 772 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 773 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 774 | ;;
|
---|
| 775 | esac
|
---|
| 776 | echo " ...OK"
|
---|
| 777 |
|
---|
| 778 | }
|
---|
| 779 |
|
---|
| 780 |
|
---|
[877cc6a] | 781 | #----------------------------#
|
---|
[15cad16] | 782 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
[93135fd] | 783 | #----------------------------#
|
---|
| 784 | local saveIFS=$IFS
|
---|
[26053c4] | 785 | local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
|
---|
[93135fd] | 786 |
|
---|
| 787 | # Test if the packages must be downloaded
|
---|
| 788 | [ ! "$GETPKG" = "1" ] && return
|
---|
| 789 |
|
---|
| 790 | gs_wrt_message(){
|
---|
| 791 | echo "${RED}$1${OFF}"
|
---|
[c7dbe78] | 792 | echo "$1" >> MISSING_FILES.DMP
|
---|
| 793 | }
|
---|
[93135fd] | 794 | # Housekeeping
|
---|
| 795 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
| 796 | cd $BUILDDIR/sources
|
---|
| 797 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
| 798 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
| 799 | [[ -f urls.lst ]] && rm urls.lst
|
---|
| 800 |
|
---|
| 801 | # Generate URLs file
|
---|
| 802 | create_urls
|
---|
| 803 |
|
---|
| 804 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 805 | for line in `cat urls.lst`; do
|
---|
| 806 | IFS=$saveIFS # Restore the system defaults
|
---|
| 807 |
|
---|
| 808 | # Skip some packages if they aren't needed
|
---|
| 809 | case $line in
|
---|
| 810 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
| 811 | [[ "$TEST" = "0" ]] && continue
|
---|
| 812 | ;;
|
---|
| 813 | */vim-*-lang* )
|
---|
| 814 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
| 815 | ;;
|
---|
[0c3f2f9] | 816 | *linux/linux-* )
|
---|
[294c937] | 817 | [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
|
---|
| 818 | [[ "$GETKERNEL" = "0" ]] && continue
|
---|
[0c3f2f9] | 819 | ;;
|
---|
[93135fd] | 820 | esac
|
---|
| 821 |
|
---|
| 822 | # Locations
|
---|
[296ae69] | 823 | URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
---|
| 824 | URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
---|
[26053c4] | 825 | FILE=`basename $URL1` # File name
|
---|
| 826 | BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
---|
| 827 |
|
---|
[8a43b5b] | 828 | # Validation pair
|
---|
| 829 | MD5="$BOOKMD5 $FILE"
|
---|
| 830 | HAVEMD5=1
|
---|
[93135fd] | 831 |
|
---|
| 832 | set -e
|
---|
[c7dbe78] | 833 | # If the file exists in the archive copy it to the
|
---|
[93135fd] | 834 | # $BUILDDIR/sources dir. MD5SUM will be validated later.
|
---|
| 835 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 836 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 837 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
| 838 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
| 839 | echo "$FILE: -- copied from $SRC_ARCHIVE"
|
---|
| 840 | fromARCHIVE=1
|
---|
| 841 | else
|
---|
| 842 | echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
|
---|
| 843 | fromARCHIVE=0
|
---|
[8a43b5b] | 844 | # If the file does not exist yet in /sources download a fresh one
|
---|
[93135fd] | 845 | if [ ! -f $FILE ] ; then
|
---|
| 846 | if ! wget $URL1 && ! wget $URL2 ; then
|
---|
[c7dbe78] | 847 | gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
---|
| 848 | continue
|
---|
[93135fd] | 849 | fi
|
---|
| 850 | fi
|
---|
| 851 | fi
|
---|
| 852 |
|
---|
[8a43b5b] | 853 | # IF the md5sum does not match the existing files
|
---|
| 854 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
| 855 | [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
---|
| 856 | [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
---|
| 857 | # Remove the old file and download a new one
|
---|
| 858 | rm -fv $FILE
|
---|
| 859 | # Force storage in SRC_ARCHIVE
|
---|
| 860 | fromARCHIVE=0;
|
---|
| 861 | # Try to retrieve again the file. Servers in reverse order.
|
---|
| 862 | if ! wget $URL2 && ! wget $URL1 ; then
|
---|
| 863 | gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
---|
| 864 | continue
|
---|
[93135fd] | 865 | fi
|
---|
| 866 | fi
|
---|
| 867 |
|
---|
| 868 | # Validate the MD5SUM one last time
|
---|
[8a43b5b] | 869 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
[93135fd] | 870 | gs_wrt_message "$FILE does not match MD5SUMS value"
|
---|
[0910f55] | 871 | # Force generation of MD5SUM
|
---|
| 872 | HAVEMD5=0
|
---|
[93135fd] | 873 | fi
|
---|
| 874 |
|
---|
| 875 | # Generate a fresh MD5SUM for this file
|
---|
| 876 | if [[ "$HAVEMD5" = "0" ]] ; then
|
---|
| 877 | echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
---|
[8a43b5b] | 878 | echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
---|
[93135fd] | 879 | fi
|
---|
| 880 |
|
---|
| 881 | # Good or bad we write the original md5sum to a file
|
---|
[8a43b5b] | 882 | echo "$MD5" >> MD5SUMS
|
---|
[93135fd] | 883 |
|
---|
| 884 | # Copy the freshly downloaded file
|
---|
| 885 | # to the source archive.
|
---|
| 886 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 887 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 888 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
| 889 | [ "$fromARCHIVE" = "0" ] ; then
|
---|
| 890 | echo "Storing file:<$FILE> in the package archive"
|
---|
| 891 | cp -f $FILE ${SRC_ARCHIVE}
|
---|
| 892 | fi
|
---|
| 893 |
|
---|
| 894 | done
|
---|
| 895 |
|
---|
| 896 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
[d385453] | 897 | 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"
|
---|
| 898 | # Do not allow the automatic execution of the Makefile.
|
---|
[261eea6] | 899 | echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
|
---|
[93135fd] | 900 | RUNMAKE=0
|
---|
| 901 | fi
|
---|
| 902 | }
|
---|
| 903 |
|
---|
[877cc6a] | 904 | #----------------------------#
|
---|
[15cad16] | 905 | create_urls() { #
|
---|
[877cc6a] | 906 | #----------------------------#
|
---|
[15cad16] | 907 | cd $JHALFSDIR
|
---|
[877cc6a] | 908 |
|
---|
[15cad16] | 909 | case ${PROGNAME} in
|
---|
| 910 | clfs)
|
---|
| 911 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
| 912 | xsltproc --nonet --xinclude \
|
---|
| 913 | --stringparam server $SERVER \
|
---|
| 914 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 915 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 916 | echo " ...OK"
|
---|
| 917 | ;;
|
---|
[7432834] | 918 | clfs2)
|
---|
| 919 | echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
|
---|
| 920 | xsltproc --nonet --xinclude \
|
---|
| 921 | --stringparam server $SERVER \
|
---|
| 922 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 923 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 924 | echo " ...OK"
|
---|
| 925 | ;;
|
---|
[15cad16] | 926 | hlfs)
|
---|
| 927 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
| 928 | xsltproc --nonet --xinclude \
|
---|
| 929 | --stringparam server $SERVER \
|
---|
| 930 | --stringparam model $MODEL \
|
---|
| 931 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 932 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 933 | echo " ...OK"
|
---|
| 934 | ;;
|
---|
| 935 | lfs)
|
---|
| 936 | echo -n "Creating LFS specific URLs file"
|
---|
| 937 | xsltproc --nonet --xinclude \
|
---|
| 938 | --stringparam server $SERVER \
|
---|
| 939 | -o ../sources/urls.lst urls.xsl \
|
---|
| 940 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 941 | echo " ...OK"
|
---|
| 942 | ;;
|
---|
| 943 | esac
|
---|
[877cc6a] | 944 |
|
---|
[15cad16] | 945 | cd $BUILDDIR/sources
|
---|
[877cc6a] | 946 | }
|
---|