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