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