[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
|
---|
| 256 | tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
| 257 | *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
---|
| 258 | esac
|
---|
| 259 |
|
---|
| 260 | }
|
---|
[877cc6a] | 261 |
|
---|
[5842156] | 262 | #----------------------------------#
|
---|
| 263 | wrt_remove_existing_dirs() { #
|
---|
| 264 | #----------------------------------#
|
---|
| 265 | local PKG_NAME=$1
|
---|
| 266 | (
|
---|
| 267 | cat << EOF
|
---|
[3b3251a] | 268 | @PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 269 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 270 | [[ -n \$\$ROOT ]] && \\
|
---|
| 271 | rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 272 | if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 273 | rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 274 | fi;
|
---|
| 275 | EOF
|
---|
| 276 | ) >> $MKFILE.tmp
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | #----------------------------------#
|
---|
| 280 | wrt_remove_existing_dirs2() { #
|
---|
| 281 | #----------------------------------#
|
---|
| 282 | local PKG_NAME=$1
|
---|
| 283 | (
|
---|
| 284 | cat << EOF
|
---|
[3b3251a] | 285 | @PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\
|
---|
| 286 | ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
|
---|
[5842156] | 287 | [[ -n \$\$ROOT ]] && \\
|
---|
| 288 | rm -rf \$(SRC)/\$\$ROOT && \\
|
---|
[15787a3] | 289 | if [ -e \$(SRC)/${PKG_NAME%-*}-build ]; then \\
|
---|
| 290 | rm -rf \$(SRC)/${PKG_NAME%-*}-build; \\
|
---|
[5842156] | 291 | fi;
|
---|
| 292 | EOF
|
---|
| 293 | ) >> $MKFILE.tmp
|
---|
| 294 | }
|
---|
| 295 |
|
---|
| 296 |
|
---|
| 297 |
|
---|
[877cc6a] | 298 | #----------------------------------#
|
---|
| 299 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
| 300 | #----------------------------------#
|
---|
| 301 | local FILE=$1
|
---|
[5842156] | 302 | local optSAVE_PREVIOUS=$2
|
---|
[82eb8c1] | 303 |
|
---|
[5842156] | 304 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 305 | wrt_remove_existing_dirs "$FILE"
|
---|
| 306 | fi
|
---|
[877cc6a] | 307 | (
|
---|
| 308 | cat << EOF
|
---|
| 309 | @\$(call unpack,$FILE)
|
---|
[82eb8c1] | 310 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 311 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
[15537d5] | 312 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
[877cc6a] | 313 | EOF
|
---|
| 314 | ) >> $MKFILE.tmp
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 |
|
---|
[e5f5970] | 318 | #----------------------------------#
|
---|
| 319 | wrt_unpack_clfs() { # Unpack and set 'ROOT' var
|
---|
| 320 | #----------------------------------#
|
---|
| 321 | local FILE=$1
|
---|
| 322 | local optSAVE_PREVIOUS=$2
|
---|
| 323 |
|
---|
| 324 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 325 | wrt_remove_existing_dirs "$FILE"
|
---|
| 326 | fi
|
---|
| 327 | (
|
---|
| 328 | cat << EOF
|
---|
| 329 | @\$(call unpack,$FILE)
|
---|
| 330 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 331 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
| 332 | chown -R clfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 333 | EOF
|
---|
| 334 | ) >> $MKFILE.tmp
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 |
|
---|
[877cc6a] | 338 | #----------------------------------#
|
---|
| 339 | wrt_unpack2() { #
|
---|
| 340 | #----------------------------------#
|
---|
| 341 | local FILE=$1
|
---|
[5842156] | 342 | local optSAVE_PREVIOUS=$2
|
---|
| 343 |
|
---|
| 344 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 345 | wrt_remove_existing_dirs "$FILE"
|
---|
| 346 | fi
|
---|
[877cc6a] | 347 | (
|
---|
| 348 | cat << EOF
|
---|
| 349 | @\$(call unpack2,$FILE)
|
---|
[a229600] | 350 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 351 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 352 | EOF
|
---|
| 353 | ) >> $MKFILE.tmp
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 |
|
---|
[261eea6] | 357 | #----------------------------------#
|
---|
| 358 | wrt_unpack3() { #
|
---|
| 359 | #----------------------------------#
|
---|
[877cc6a] | 360 | local FILE=$1
|
---|
[5842156] | 361 | local optSAVE_PREVIOUS=$2
|
---|
| 362 |
|
---|
| 363 | if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
---|
| 364 | wrt_remove_existing_dirs2 "$FILE"
|
---|
| 365 | fi
|
---|
[877cc6a] | 366 | (
|
---|
| 367 | cat << EOF
|
---|
| 368 | @\$(call unpack3,$FILE)
|
---|
[82eb8c1] | 369 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 370 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
| 371 | EOF
|
---|
| 372 | ) >> $MKFILE.tmp
|
---|
| 373 | }
|
---|
| 374 |
|
---|
[a229600] | 375 | #----------------------------------#
|
---|
| 376 | wrt_test_log() { # Initialize testsuite log file
|
---|
| 377 | #----------------------------------#
|
---|
| 378 | local TESTLOGFILE=$1
|
---|
| 379 | (
|
---|
| 380 | cat << EOF
|
---|
| 381 | @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
|
---|
| 382 | su - lfs -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
|
---|
| 383 | EOF
|
---|
| 384 | ) >> $MKFILE.tmp
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | #----------------------------------#
|
---|
| 388 | wrt_test_log2() { #
|
---|
| 389 | #----------------------------------#
|
---|
| 390 | local TESTLOGFILE=$1
|
---|
| 391 | (
|
---|
| 392 | cat << EOF
|
---|
| 393 | @echo "export TEST_LOG=/$SCRIPT_ROOT/test-logs/$TESTLOGFILE" >> envars && \\
|
---|
| 394 | echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
|
---|
| 395 | EOF
|
---|
| 396 | ) >> $MKFILE.tmp
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[877cc6a] | 399 | #----------------------------------#
|
---|
| 400 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
| 401 | #----------------------------------#
|
---|
| 402 | (
|
---|
| 403 | cat << EOF
|
---|
| 404 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
| 405 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
| 406 | EOF
|
---|
| 407 | ) >> $MKFILE.tmp
|
---|
| 408 |
|
---|
| 409 | }
|
---|
| 410 |
|
---|
| 411 |
|
---|
| 412 | #----------------------------------#
|
---|
[3a321ea] | 413 | wrt_run_as_su() { # Execute script inside time { }, footer to log file
|
---|
[877cc6a] | 414 | #----------------------------------#
|
---|
| 415 | local this_script=$1
|
---|
| 416 | local file=$2
|
---|
| 417 | (
|
---|
| 418 | cat << EOF
|
---|
[3a321ea] | 419 | @( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 420 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
[877cc6a] | 421 | EOF
|
---|
| 422 | ) >> $MKFILE.tmp
|
---|
| 423 | }
|
---|
| 424 |
|
---|
| 425 |
|
---|
| 426 | #----------------------------------#
|
---|
[3a321ea] | 427 | wrt_run_as_root() { # Some scripts must be run as root..
|
---|
[877cc6a] | 428 | #----------------------------------#
|
---|
| 429 | local this_script=$1
|
---|
| 430 | local file=$2
|
---|
| 431 | (
|
---|
| 432 | cat << EOF
|
---|
[3a321ea] | 433 | @( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 434 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
[877cc6a] | 435 | EOF
|
---|
| 436 | ) >> $MKFILE.tmp
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 |
|
---|
[e5f5970] | 440 | #----------------------------------#
|
---|
| 441 | wrt_run_as_clfs_su() { # Execute script inside time { }, footer to log file
|
---|
| 442 | #----------------------------------#
|
---|
| 443 | local this_script=$1
|
---|
| 444 | local file=$2
|
---|
| 445 | (
|
---|
| 446 | cat << EOF
|
---|
| 447 | @( time { su - clfs -c "source /home/clfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
| 448 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 449 | EOF
|
---|
| 450 | ) >> $MKFILE.tmp
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 |
|
---|
[ac1d897] | 454 | #----------------------------------#
|
---|
| 455 | wrt_run_as_clfs_root() { # Some scripts must be run as root..
|
---|
| 456 | #----------------------------------#
|
---|
| 457 | local this_script=$1
|
---|
| 458 | local file=$2
|
---|
| 459 | (
|
---|
| 460 | cat << EOF
|
---|
| 461 | @( time { export CLFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
| 462 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
| 463 | EOF
|
---|
| 464 | ) >> $MKFILE.tmp
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 |
|
---|
[261eea6] | 468 | #----------------------------------#
|
---|
| 469 | wrt_run_as_root2() { #
|
---|
| 470 | #----------------------------------#
|
---|
[877cc6a] | 471 | local this_script=$1
|
---|
| 472 | local file=$2
|
---|
| 473 | (
|
---|
| 474 | cat << EOF
|
---|
[3a321ea] | 475 | @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
[1a1f099] | 476 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
|
---|
[877cc6a] | 477 | EOF
|
---|
| 478 | ) >> $MKFILE.tmp
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 |
|
---|
| 482 |
|
---|
| 483 | #----------------------------------#
|
---|
| 484 | wrt_run_as_chroot1() { #
|
---|
| 485 | #----------------------------------#
|
---|
| 486 | local this_script=$1
|
---|
| 487 | local file=$2
|
---|
| 488 | (
|
---|
| 489 | cat << EOF
|
---|
[1a1f099] | 490 | @( time { \$(CHROOT1) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
| 491 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
[877cc6a] | 492 | EOF
|
---|
| 493 | ) >> $MKFILE.tmp
|
---|
| 494 | }
|
---|
| 495 |
|
---|
| 496 |
|
---|
| 497 | #----------------------------------#
|
---|
| 498 | wrt_run_as_chroot2() { #
|
---|
| 499 | #----------------------------------#
|
---|
| 500 | local this_script=$1
|
---|
| 501 | local file=$2
|
---|
| 502 | (
|
---|
| 503 | cat << EOF
|
---|
[1a1f099] | 504 | @( time { \$(CHROOT2) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
| 505 | echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
[877cc6a] | 506 | EOF
|
---|
| 507 | ) >> $MKFILE.tmp
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 |
|
---|
| 511 | #----------------------------------#
|
---|
| 512 | wrt_copy_fstab() { #
|
---|
| 513 | #----------------------------------#
|
---|
| 514 | local i=$1
|
---|
| 515 | (
|
---|
| 516 | cat << EOF
|
---|
[3a321ea] | 517 | @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 518 | EOF
|
---|
| 519 | ) >> $MKFILE.tmp
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 | #----------------------------------#
|
---|
[3a321ea] | 523 | wrt_copy_fstab2() { #
|
---|
[877cc6a] | 524 | #----------------------------------#
|
---|
| 525 | local i=$1
|
---|
| 526 | (
|
---|
| 527 | cat << EOF
|
---|
[3a321ea] | 528 | @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
|
---|
[877cc6a] | 529 | EOF
|
---|
| 530 | ) >> $MKFILE.tmp
|
---|
| 531 | }
|
---|
| 532 |
|
---|
| 533 |
|
---|
| 534 | #----------------------------------#
|
---|
[0bdf6ed] | 535 | wrt_remove_build_dirs() { #
|
---|
[877cc6a] | 536 | #----------------------------------#
|
---|
[0bdf6ed] | 537 | local name=$1
|
---|
[877cc6a] | 538 | (
|
---|
[0bdf6ed] | 539 | cat << EOF
|
---|
[82eb8c1] | 540 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[b7faa5a] | 541 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
| 542 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
[0bdf6ed] | 543 | rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
| 544 | fi;
|
---|
| 545 | EOF
|
---|
| 546 | ) >> $MKFILE.tmp
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 |
|
---|
| 550 | #----------------------------------#
|
---|
| 551 | wrt_remove_build_dirs2() { #
|
---|
| 552 | #----------------------------------#
|
---|
| 553 | local name=$1
|
---|
| 554 | (
|
---|
| 555 | cat << EOF
|
---|
[82eb8c1] | 556 | @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[b7faa5a] | 557 | rm -r \$(SRC)/\$\$ROOT && \\
|
---|
| 558 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
[0bdf6ed] | 559 | rm -r \$(SRC)/$name-build; \\
|
---|
| 560 | fi;
|
---|
[877cc6a] | 561 | EOF
|
---|
| 562 | ) >> $MKFILE.tmp
|
---|
| 563 | }
|
---|
| 564 |
|
---|
| 565 |
|
---|
[e2ef100] | 566 | #----------------------------------#
|
---|
| 567 | wrt_touch() { #
|
---|
| 568 | #----------------------------------#
|
---|
| 569 | (
|
---|
| 570 | cat << EOF
|
---|
| 571 | @touch \$@ && \\
|
---|
| 572 | sleep .25 && \\
|
---|
[4a444f1] | 573 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 574 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
[e2ef100] | 575 | EOF
|
---|
| 576 | ) >> $MKFILE.tmp
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 |
|
---|
[453bef0] | 580 | #----------------------------------#
|
---|
[261eea6] | 581 | wrt_report() { #
|
---|
[453bef0] | 582 | #----------------------------------#
|
---|
| 583 | (
|
---|
| 584 | cat << EOF
|
---|
| 585 |
|
---|
| 586 | create-sbu_du-report: $PREV
|
---|
| 587 | @\$(call echo_message, Building)
|
---|
[a9429d5] | 588 | @./create-sbu_du-report.sh logs $VERSION
|
---|
[453bef0] | 589 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
| 590 | @touch \$@
|
---|
| 591 | EOF
|
---|
| 592 | ) >> $MKFILE.tmp
|
---|
| 593 |
|
---|
| 594 | chapter789="$chapter789 create-sbu_du-report"
|
---|
| 595 | }
|
---|
| 596 |
|
---|
| 597 |
|
---|
[877cc6a] | 598 | #----------------------------#
|
---|
[261eea6] | 599 | run_make() { #
|
---|
[877cc6a] | 600 | #----------------------------#
|
---|
| 601 | # Test if make must be run.
|
---|
| 602 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
| 603 | # Test to make sure we're running the build as root
|
---|
| 604 | if [ "$UID" != "0" ] ; then
|
---|
| 605 | echo "You must be logged in as root to successfully build the system."
|
---|
| 606 | exit 1
|
---|
| 607 | fi
|
---|
| 608 | # Build the system
|
---|
| 609 | if [ -e $MKFILE ] ; then
|
---|
| 610 | echo -ne "Building the system...\n"
|
---|
[a167246] | 611 | cd $JHALFSDIR && make
|
---|
[877cc6a] | 612 | echo -ne "done\n"
|
---|
| 613 | fi
|
---|
| 614 | fi
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 |
|
---|
| 618 | #----------------------------#
|
---|
[261eea6] | 619 | clean_builddir() { #
|
---|
[877cc6a] | 620 | #----------------------------#
|
---|
| 621 | # Test if the clean must be done.
|
---|
| 622 | if [ "$CLEAN" = "1" ] ; then
|
---|
| 623 | # Test to make sure we're running the clean as root
|
---|
| 624 | if [ "$UID" != "0" ] ; then
|
---|
| 625 | echo "You must be logged in as root to clean the build directory."
|
---|
| 626 | exit 1
|
---|
| 627 | fi
|
---|
| 628 | # Test to make sure that the build directory was populated by jhalfs
|
---|
| 629 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
[73e5448] | 630 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
[877cc6a] | 631 | exit 1
|
---|
| 632 | else
|
---|
| 633 | # Clean the build directory
|
---|
| 634 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
| 635 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
|
---|
| 636 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
[dd29d02] | 637 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
|
---|
[877cc6a] | 638 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
| 639 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
| 640 | echo -ne "done\n"
|
---|
| 641 | fi
|
---|
| 642 | fi
|
---|
| 643 | }
|
---|
| 644 |
|
---|
| 645 | #----------------------------#
|
---|
[261eea6] | 646 | get_book() { #
|
---|
[877cc6a] | 647 | #----------------------------#
|
---|
| 648 | cd $JHALFSDIR
|
---|
| 649 |
|
---|
| 650 | if [ -z $WC ] ; then
|
---|
| 651 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
| 652 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
| 653 | exit 1"
|
---|
| 654 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
| 655 |
|
---|
| 656 | case $PROGNAME in
|
---|
| 657 | lfs) svn_root="LFS" ;;
|
---|
| 658 | hlfs) svn_root="HLFS" ;;
|
---|
| 659 | clfs) svn_root="cross-lfs" ;;
|
---|
[7432834] | 660 | clfs2) svn_root="cross-lfs" ;;
|
---|
[877cc6a] | 661 | *) echo "BOOK not defined in function <get_book>"
|
---|
| 662 | exit 1 ;;
|
---|
| 663 | esac
|
---|
| 664 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
| 665 | # repo. If we've already extracted the commands, move on to getting the
|
---|
| 666 | # sources.
|
---|
| 667 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
| 668 | cd ${PROGNAME}-$LFSVRS
|
---|
[1ff6768] | 669 | if LC_ALL=C svn up | grep -q At && \
|
---|
| 670 | test -d $JHALFSDIR/${PROGNAME}-commands && \
|
---|
| 671 | test -f $JHALFSDIR/pkg_tarball_list ; then
|
---|
[877cc6a] | 672 | # Set the canonical book version
|
---|
[a6655ff] | 673 | echo -ne "done\n"
|
---|
[877cc6a] | 674 | cd $JHALFSDIR
|
---|
[1ff6768] | 675 | case $PROGNAME in
|
---|
[7432834] | 676 | clfs | clfs2)
|
---|
[1ff6768] | 677 | VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 678 | *)
|
---|
| 679 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 680 | esac
|
---|
[877cc6a] | 681 | get_sources
|
---|
| 682 | else
|
---|
| 683 | echo -ne "done\n"
|
---|
| 684 | extract_commands
|
---|
| 685 | fi
|
---|
| 686 | else
|
---|
[cb39f79] | 687 | svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
[877cc6a] | 688 | echo -ne "done\n"
|
---|
| 689 | extract_commands
|
---|
| 690 | fi
|
---|
[1ff6768] | 691 |
|
---|
[877cc6a] | 692 | else
|
---|
| 693 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
| 694 | extract_commands
|
---|
| 695 | fi
|
---|
[a6655ff] | 696 | echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
|
---|
[877cc6a] | 697 | }
|
---|
| 698 |
|
---|
| 699 | #----------------------------#
|
---|
| 700 | extract_commands() { #
|
---|
| 701 | #----------------------------#
|
---|
| 702 |
|
---|
| 703 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
| 704 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
| 705 | exit 1"
|
---|
| 706 |
|
---|
| 707 | cd $JHALFSDIR
|
---|
[1ff6768] | 708 | case $PROGNAME in
|
---|
[7432834] | 709 | clfs | clfs2 )
|
---|
[1ff6768] | 710 | VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 711 | *)
|
---|
| 712 | VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
---|
| 713 | esac
|
---|
[877cc6a] | 714 |
|
---|
| 715 | # Start clean
|
---|
[bfc07d6] | 716 | if [ -d ${PROGNAME}-commands ]; then
|
---|
| 717 | rm -rf ${PROGNAME}-commands
|
---|
| 718 | mkdir -v ${PROGNAME}-commands
|
---|
[877cc6a] | 719 | fi
|
---|
| 720 | echo -n "Extracting commands for"
|
---|
| 721 |
|
---|
| 722 | # Dump the commands in shell script form from the HLFS book.
|
---|
| 723 | case ${PROGNAME} in
|
---|
| 724 | clfs)
|
---|
| 725 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 726 | xsltproc --nonet \
|
---|
| 727 | --xinclude \
|
---|
| 728 | --stringparam method $METHOD \
|
---|
| 729 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 730 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 731 | --stringparam vim-lang $VIMLANG \
|
---|
| 732 | --stringparam timezone $TIMEZONE \
|
---|
| 733 | --stringparam page $PAGE \
|
---|
| 734 | --stringparam lang $LANG \
|
---|
| 735 | --stringparam keymap $KEYMAP \
|
---|
| 736 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 737 | ;;
|
---|
[7432834] | 738 |
|
---|
| 739 | clfs2)
|
---|
| 740 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
| 741 | xsltproc --nonet \
|
---|
| 742 | --xinclude \
|
---|
| 743 | --stringparam vim-lang $VIMLANG \
|
---|
| 744 | --stringparam timezone $TIMEZONE \
|
---|
| 745 | --stringparam page $PAGE \
|
---|
| 746 | --stringparam lang $LANG \
|
---|
| 747 | --stringparam keymap $KEYMAP \
|
---|
| 748 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 749 | ;;
|
---|
[877cc6a] | 750 | hlfs)
|
---|
| 751 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
| 752 | xsltproc --nonet \
|
---|
| 753 | --xinclude \
|
---|
| 754 | --stringparam model $MODEL \
|
---|
| 755 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 756 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 757 | --stringparam timezone $TIMEZONE \
|
---|
| 758 | --stringparam page $PAGE \
|
---|
| 759 | --stringparam lang $LANG \
|
---|
| 760 | --stringparam lc_all $LC_ALL \
|
---|
| 761 | --stringparam keymap $KEYMAP \
|
---|
| 762 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
| 763 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 764 | ;;
|
---|
| 765 | lfs)
|
---|
| 766 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
| 767 | xsltproc --nonet \
|
---|
| 768 | --xinclude \
|
---|
| 769 | --stringparam testsuite $TEST \
|
---|
[28f4756] | 770 | --stringparam bomb-testsuite $BOMB_TEST \
|
---|
[877cc6a] | 771 | --stringparam vim-lang $VIMLANG \
|
---|
| 772 | --stringparam timezone $TIMEZONE \
|
---|
| 773 | --stringparam page $PAGE \
|
---|
| 774 | --stringparam lang $LANG \
|
---|
| 775 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 776 | ;;
|
---|
[15cad16] | 777 | *) exit 1 ;;
|
---|
[877cc6a] | 778 | esac
|
---|
| 779 |
|
---|
| 780 | echo " ...OK"
|
---|
| 781 |
|
---|
| 782 | # Make the scripts executable.
|
---|
| 783 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
| 784 |
|
---|
[15cad16] | 785 | # Create the packages file. We need it for proper Makefile creation
|
---|
[dd29d02] | 786 | create_package_list
|
---|
[877cc6a] | 787 |
|
---|
| 788 | # Done. Moving on...
|
---|
| 789 | get_sources
|
---|
| 790 | }
|
---|
| 791 |
|
---|
[dd29d02] | 792 | #----------------------------#
|
---|
| 793 | create_package_list() { #
|
---|
| 794 | #----------------------------#
|
---|
| 795 |
|
---|
| 796 | # Create the packages file. We need it for proper Makefile creation
|
---|
| 797 | rm -f pkg_tarball_list
|
---|
| 798 | echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
|
---|
| 799 | case ${PROGNAME} in
|
---|
[7432834] | 800 | clfs | clfs2)
|
---|
[dd29d02] | 801 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 802 | $BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 803 | ;;
|
---|
| 804 | hlfs)
|
---|
| 805 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 806 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 807 | ;;
|
---|
| 808 | lfs)
|
---|
| 809 | xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
|
---|
| 810 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 811 | ;;
|
---|
| 812 | esac
|
---|
| 813 | echo " ...OK"
|
---|
| 814 |
|
---|
| 815 | }
|
---|
| 816 |
|
---|
| 817 |
|
---|
[877cc6a] | 818 | #----------------------------#
|
---|
[15cad16] | 819 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
[93135fd] | 820 | #----------------------------#
|
---|
| 821 | local saveIFS=$IFS
|
---|
[26053c4] | 822 | local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
|
---|
[93135fd] | 823 |
|
---|
| 824 | # Test if the packages must be downloaded
|
---|
| 825 | [ ! "$GETPKG" = "1" ] && return
|
---|
| 826 |
|
---|
| 827 | gs_wrt_message(){
|
---|
| 828 | echo "${RED}$1${OFF}"
|
---|
[c7dbe78] | 829 | echo "$1" >> MISSING_FILES.DMP
|
---|
| 830 | }
|
---|
[93135fd] | 831 | # Housekeeping
|
---|
| 832 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
| 833 | cd $BUILDDIR/sources
|
---|
| 834 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
| 835 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
| 836 | [[ -f urls.lst ]] && rm urls.lst
|
---|
| 837 |
|
---|
| 838 | # Generate URLs file
|
---|
| 839 | create_urls
|
---|
| 840 |
|
---|
| 841 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
| 842 | for line in `cat urls.lst`; do
|
---|
| 843 | IFS=$saveIFS # Restore the system defaults
|
---|
| 844 |
|
---|
| 845 | # Skip some packages if they aren't needed
|
---|
| 846 | case $line in
|
---|
| 847 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
| 848 | [[ "$TEST" = "0" ]] && continue
|
---|
| 849 | ;;
|
---|
| 850 | */vim-*-lang* )
|
---|
| 851 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
| 852 | ;;
|
---|
[0c3f2f9] | 853 | *linux/linux-* )
|
---|
[294c937] | 854 | [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
|
---|
| 855 | [[ "$GETKERNEL" = "0" ]] && continue
|
---|
[0c3f2f9] | 856 | ;;
|
---|
[93135fd] | 857 | esac
|
---|
| 858 |
|
---|
| 859 | # Locations
|
---|
[296ae69] | 860 | URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
---|
| 861 | URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
---|
[26053c4] | 862 | FILE=`basename $URL1` # File name
|
---|
| 863 | BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
---|
| 864 |
|
---|
[8a43b5b] | 865 | # Validation pair
|
---|
| 866 | MD5="$BOOKMD5 $FILE"
|
---|
| 867 | HAVEMD5=1
|
---|
[93135fd] | 868 |
|
---|
| 869 | set -e
|
---|
[c7dbe78] | 870 | # If the file exists in the archive copy it to the
|
---|
[93135fd] | 871 | # $BUILDDIR/sources dir. MD5SUM will be validated later.
|
---|
| 872 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 873 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 874 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
| 875 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
| 876 | echo "$FILE: -- copied from $SRC_ARCHIVE"
|
---|
| 877 | fromARCHIVE=1
|
---|
| 878 | else
|
---|
| 879 | echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
|
---|
| 880 | fromARCHIVE=0
|
---|
[8a43b5b] | 881 | # If the file does not exist yet in /sources download a fresh one
|
---|
[93135fd] | 882 | if [ ! -f $FILE ] ; then
|
---|
| 883 | if ! wget $URL1 && ! wget $URL2 ; then
|
---|
[c7dbe78] | 884 | gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
---|
| 885 | continue
|
---|
[93135fd] | 886 | fi
|
---|
| 887 | fi
|
---|
| 888 | fi
|
---|
| 889 |
|
---|
[8a43b5b] | 890 | # IF the md5sum does not match the existing files
|
---|
| 891 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
| 892 | [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
---|
| 893 | [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
---|
| 894 | # Remove the old file and download a new one
|
---|
| 895 | rm -fv $FILE
|
---|
| 896 | # Force storage in SRC_ARCHIVE
|
---|
| 897 | fromARCHIVE=0;
|
---|
| 898 | # Try to retrieve again the file. Servers in reverse order.
|
---|
| 899 | if ! wget $URL2 && ! wget $URL1 ; then
|
---|
| 900 | gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
---|
| 901 | continue
|
---|
[93135fd] | 902 | fi
|
---|
| 903 | fi
|
---|
| 904 |
|
---|
| 905 | # Validate the MD5SUM one last time
|
---|
[8a43b5b] | 906 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
[93135fd] | 907 | gs_wrt_message "$FILE does not match MD5SUMS value"
|
---|
[0910f55] | 908 | # Force generation of MD5SUM
|
---|
| 909 | HAVEMD5=0
|
---|
[93135fd] | 910 | fi
|
---|
| 911 |
|
---|
| 912 | # Generate a fresh MD5SUM for this file
|
---|
| 913 | if [[ "$HAVEMD5" = "0" ]] ; then
|
---|
| 914 | echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
---|
[8a43b5b] | 915 | echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
---|
[93135fd] | 916 | fi
|
---|
| 917 |
|
---|
| 918 | # Good or bad we write the original md5sum to a file
|
---|
[8a43b5b] | 919 | echo "$MD5" >> MD5SUMS
|
---|
[93135fd] | 920 |
|
---|
| 921 | # Copy the freshly downloaded file
|
---|
| 922 | # to the source archive.
|
---|
| 923 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
| 924 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
| 925 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
| 926 | [ "$fromARCHIVE" = "0" ] ; then
|
---|
| 927 | echo "Storing file:<$FILE> in the package archive"
|
---|
| 928 | cp -f $FILE ${SRC_ARCHIVE}
|
---|
| 929 | fi
|
---|
| 930 |
|
---|
| 931 | done
|
---|
| 932 |
|
---|
| 933 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
[d385453] | 934 | 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"
|
---|
| 935 | # Do not allow the automatic execution of the Makefile.
|
---|
[261eea6] | 936 | echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
|
---|
[93135fd] | 937 | RUNMAKE=0
|
---|
| 938 | fi
|
---|
| 939 | }
|
---|
| 940 |
|
---|
[877cc6a] | 941 | #----------------------------#
|
---|
[15cad16] | 942 | create_urls() { #
|
---|
[877cc6a] | 943 | #----------------------------#
|
---|
[15cad16] | 944 | cd $JHALFSDIR
|
---|
[877cc6a] | 945 |
|
---|
[15cad16] | 946 | case ${PROGNAME} in
|
---|
| 947 | clfs)
|
---|
| 948 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
| 949 | xsltproc --nonet --xinclude \
|
---|
| 950 | --stringparam server $SERVER \
|
---|
| 951 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 952 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 953 | echo " ...OK"
|
---|
| 954 | ;;
|
---|
[7432834] | 955 | clfs2)
|
---|
| 956 | echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
|
---|
| 957 | xsltproc --nonet --xinclude \
|
---|
| 958 | --stringparam server $SERVER \
|
---|
| 959 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 960 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 961 | echo " ...OK"
|
---|
| 962 | ;;
|
---|
[15cad16] | 963 | hlfs)
|
---|
| 964 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
| 965 | xsltproc --nonet --xinclude \
|
---|
| 966 | --stringparam server $SERVER \
|
---|
| 967 | --stringparam model $MODEL \
|
---|
| 968 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
| 969 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 970 | echo " ...OK"
|
---|
| 971 | ;;
|
---|
| 972 | lfs)
|
---|
| 973 | echo -n "Creating LFS specific URLs file"
|
---|
| 974 | xsltproc --nonet --xinclude \
|
---|
| 975 | --stringparam server $SERVER \
|
---|
| 976 | -o ../sources/urls.lst urls.xsl \
|
---|
| 977 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
| 978 | echo " ...OK"
|
---|
| 979 | ;;
|
---|
| 980 | esac
|
---|
[877cc6a] | 981 |
|
---|
[15cad16] | 982 | cd $BUILDDIR/sources
|
---|
[877cc6a] | 983 | }
|
---|