source: common/common-functions@ 7acf5ca

experimental
Last change on this file since 7acf5ca was 25b52e2, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Merged r2698 and r2699 from trunk.

  • Property mode set to 100644
File size: 22.2 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set +e
6
7# VT100 colors
8declare -r BLACK=$'\e[1;30m'
9declare -r DK_GRAY=$'\e[0;30m'
10
11declare -r RED=$'\e[31m'
12declare -r GREEN=$'\e[32m'
13declare -r YELLOW=$'\e[33m'
14declare -r BLUE=$'\e[34m'
15declare -r MAGENTA=$'\e[35m'
16declare -r CYAN=$'\e[36m'
17declare -r WHITE=$'\e[37m'
18
19declare -r OFF=$'\e[0m'
20declare -r BOLD=$'\e[1m'
21declare -r REVERSE=$'\e[7m'
22declare -r HIDDEN=$'\e[8m'
23
24declare -r tab_=$'\t'
25declare -r nl_=$'\n'
26
27declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
28declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
29declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
30
31# bold yellow > < pair
32declare -r R_arrow=$'\e[1;33m>\e[0m'
33declare -r L_arrow=$'\e[1;33m<\e[0m'
34
35
36usage() {
37cat <<- -EOF-
38${DD_BORDER}
39${BOLD}
40 Usage: $0 ${BOLD}[OPTION]
41
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
46Options:
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}
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}LFS
57
58${BOLD} -D --directory DIR${OFF}
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.
61 The current setting for BUILDDIR is "$BUILDDIR"
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
68${BOLD} -O, --optimize${OFF}
69 Optimize [0-2]
70 0 = no optimization
71 1 = optimize final system only
72 2 = optimize both temporary tools and final system
73 Edit common/opt_config{,.d/*} and common/opt_override as desired.
74
75${BOLD} -T, --testsuites N ${OFF}
76 Run test suites [0-3]
77 0 = none
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
81 In CLFS, 3 is an alias to 2
82
83${BOLD} -W, --working-copy DIR${OFF}
84 use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
85
86${BOLD} -C, --comparasion TYPE${OFF}
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
92 farce = do the farce analysis designed by Ken Moffat
93 both = perfom both ICA and farce analysis
94
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.
98
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.
102
103${BOLD} -M, --run-make${OFF}
104 run make on the generated Makefile
105
106${BOLD} -R --rebuild${OFF}
107 clean the build directory before perfoming any other task. The directory
108 is cleaned only if it was populated by a previous jhalfs-X run.
109-EOF-
110
111[[ ${PROGNAME} = "clfs" ]] &&
112cat <<- -EOF-
113
114${BOLD} -A, --arch ARCH ${OFF}
115 Select the TARGET architecture, valid selections are:
116 32bit builds
117 x86, i486, i586, ppc, mips, mipsel, sparc
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
122
123${BOLD} --boot-config FILE ${OFF}
124 The configuration file for the bootstrap kernel if method=boot
125
126${BOLD} --method BUILDMETHOD ${OFF}
127 Select the build method, chroot or boot
128-EOF-
129
130[[ ${PROGNAME} = "hlfs" ]] &&
131cat <<- -EOF-
132
133${BOLD} --model STYLE ${OFF}
134 Select the library model for the HLFS system
135 Valid choices are: glibc or uclibc
136-EOF-
137
138cat <<- -EOF-
139${DD_BORDER}
140-EOF-
141 exit
142}
143
144version="
145${BOLD} \"jhalfs-X\"${OFF} builder tool (experimental) \$Rev$
146\$Date$
147
148${BOLD} \"${PROGNAME}\"${OFF} script module
149
150Written by George Boudreau,
151 Manuel Canales Esparcia,
152 Jeremy Huntwork
153
154This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
155"
156
157
158no_empty_builddir() {
159 'clear'
160cat <<- -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
168 a different build directory before running jhalfs-X.
169${OFF}
170${DD_BORDER}
171-EOF-
172 exit
173}
174
175
176help="${nl_}Try '$0 --help' for more information."
177
178exit_missing_arg="\
179echo \"Option '\$1' requires an argument\" >&2
180echo \"\$help\" >&2
181exit 1"
182
183HEADER="# This file is automatically generated by jhalfs-X
184# DO NOT EDIT THIS FILE MANUALLY
185#
186# Generated on `date \"+%F %X %Z\"`"
187
188
189
190#----------------------------------#
191wrt_target() { # Create target and initialize log file
192#----------------------------------#
193 local i=$1
194 local PREV=$2
195 case $i in
196 iteration* ) local LOGFILE=$this_script.log ;;
197 * ) local LOGFILE=$this_script ;;
198 esac
199(
200cat << EOF
201
202$i: $PREV
203 @\$(call echo_message, Building)
204 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$LOGFILE
205EOF
206) >> $MKFILE.tmp
207}
208
209
210#----------------------------------#
211wrt_unpack() { # Unpack and set 'ROOT' var
212#----------------------------------#
213 local FILE=$1
214(
215cat << EOF
216 @\$(call unpack,$FILE)
217 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
218 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
219 chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
220EOF
221) >> $MKFILE.tmp
222}
223
224
225#----------------------------------#
226wrt_unpack2() { #
227#----------------------------------#
228 local FILE=$1
229(
230cat << EOF
231 @\$(call unpack2,$FILE)
232 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
233 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
234EOF
235) >> $MKFILE.tmp
236}
237
238
239#----------------------------------#
240wrt_unpack3() { #
241#----------------------------------#
242 local FILE=$1
243(
244cat << EOF
245 @\$(call unpack3,$FILE)
246 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
247 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
248EOF
249) >> $MKFILE.tmp
250}
251
252
253#----------------------------------#
254wrt_target_vars() { # Target vars for hlfs (cross-build method)
255#----------------------------------#
256(
257cat << EOF
258 @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
259 echo "export ldso=/lib/${LOADER}" >> envars
260EOF
261) >> $MKFILE.tmp
262
263}
264
265
266#----------------------------------#
267wrt_run_as_su() { # Execute script inside time { }, footer to log file
268#----------------------------------#
269 local this_script=$1
270 local file=$2
271(
272cat << EOF
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
275EOF
276) >> $MKFILE.tmp
277}
278
279
280#----------------------------------#
281wrt_run_as_root() { # Some scripts must be run as root..
282#----------------------------------#
283 local this_script=$1
284 local file=$2
285(
286cat << EOF
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
289EOF
290) >> $MKFILE.tmp
291}
292
293
294#----------------------------------#
295wrt_run_as_root2() { #
296#----------------------------------#
297 local this_script=$1
298 local file=$2
299(
300cat << EOF
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
303EOF
304) >> $MKFILE.tmp
305}
306
307
308
309#----------------------------------#
310wrt_run_as_chroot1() { #
311#----------------------------------#
312 local this_script=$1
313 local file=$2
314(
315 cat << EOF
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}
318EOF
319) >> $MKFILE.tmp
320}
321
322
323#----------------------------------#
324wrt_run_as_chroot2() { #
325#----------------------------------#
326 local this_script=$1
327 local file=$2
328(
329cat << EOF
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}
332EOF
333) >> $MKFILE.tmp
334}
335
336
337#----------------------------------#
338wrt_copy_fstab() { #
339#----------------------------------#
340 local i=$1
341(
342 cat << EOF
343 @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
344EOF
345) >> $MKFILE.tmp
346}
347
348#----------------------------------#
349wrt_copy_fstab2() { #
350#----------------------------------#
351 local i=$1
352(
353 cat << EOF
354 @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
355EOF
356) >> $MKFILE.tmp
357}
358
359
360#----------------------------------#
361wrt_remove_build_dirs() { #
362#----------------------------------#
363 local name=$1
364(
365cat << 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;
371EOF
372) >> $MKFILE.tmp
373}
374
375
376#----------------------------------#
377wrt_remove_build_dirs2() { #
378#----------------------------------#
379 local name=$1
380(
381cat << 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;
387EOF
388) >> $MKFILE.tmp
389}
390
391
392#----------------------------------#
393wrt_report() { #
394#----------------------------------#
395(
396cat << EOF
397
398create-sbu_du-report: $PREV
399 @\$(call echo_message, Building)
400 @./create-sbu_du-report.sh logs $VERSION
401 @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
402 @touch \$@
403EOF
404) >> $MKFILE.tmp
405
406chapter789="$chapter789 create-sbu_du-report"
407}
408
409
410#----------------------------#
411run_make() { #
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
417 echo "You must be logged in as root to successfully build the system."
418 exit 1
419 fi
420 # Build the system
421 if [ -e $MKFILE ] ; then
422 echo -ne "Building the system...\n"
423 cd $JHALFSDIR && make
424 echo -ne "done\n"
425 fi
426 fi
427}
428
429
430#----------------------------#
431clean_builddir() { #
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
442 echo "Looks like $BUILDDIR was not populated by a previous jhalfs-X run."
443 exit 1
444 else
445 # Clean the build directory
446 echo -ne "Cleaning $BUILDDIR...\n"
447 rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
448 echo -ne "Cleaning $JHALFSDIR...\n"
449 rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
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#----------------------------#
458get_book() { #
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
475 # Grab a fresh book if it's missing, otherwise, update it from the
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
480 if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/${PROGNAME}-commands && \
481 test -f $JHALFSDIR/packages ; then
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
496 development)
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#----------------------------#
515extract_commands() { #
516#----------------------------#
517
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
526 if [ -d ${PROGNAME}-commands ]; then
527 rm -rf ${PROGNAME}-commands
528 mkdir -v ${PROGNAME}-commands
529 fi
530 echo -n "Extracting commands for"
531
532 # Dump the commands in shell script form from the HLFS book.
533 case ${PROGNAME} in
534 clfs)
535 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
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 \
545 -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
546 ;;
547 hlfs)
548 echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
549 xsltproc --nonet \
550 --xinclude \
551 --stringparam model $MODEL \
552 --stringparam testsuite $TEST \
553 --stringparam timezone $TIMEZONE \
554 --stringparam page $PAGE \
555 --stringparam lang $LANG \
556 --stringparam lc_all $LC_ALL \
557 --stringparam keymap $KEYMAP \
558 --stringparam grsecurity_host $GRSECURITY_HOST \
559 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
560 ;;
561 lfs)
562 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
563 xsltproc --nonet \
564 --xinclude \
565 --stringparam testsuite $TEST \
566 --stringparam vim-lang $VIMLANG \
567 --stringparam timezone $TIMEZONE \
568 --stringparam page $PAGE \
569 --stringparam lang $LANG \
570 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
571 ;;
572 *) exit 1 ;;
573 esac
574
575 echo " ...OK"
576
577 # Make the scripts executable.
578 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
579
580 # Create the packages file. We need it for proper Makefile creation
581 rm -f packages
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"
586
587 # Done. Moving on...
588 get_sources
589}
590
591#----------------------------#
592get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
593#----------------------------#
594 local saveIFS=$IFS
595 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
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
610
611 # Generate URLs file
612 create_urls
613
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
617
618 # Skip some packages if they aren't needed
619 case $line in
620 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
621 [[ "$TEST" = "0" ]] && continue
622 ;;
623 */vim-*-lang* )
624 [[ "$VIMLANG" = "0" ]] && continue
625 ;;
626 *linux/linux-* )
627 [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && continue
628 ;;
629 esac
630
631 # Locations
632 URL1=`echo $line | cut -d" " -f2` # Preferred URL
633 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
634 FILE=`basename $URL1` # File name
635 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
636
637 # Validation pair
638 MD5="$BOOKMD5 $FILE"
639 HAVEMD5=1
640
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
653 # If the file does not exist yet in /sources download a fresh one
654 if [ ! -f $FILE ] ; then
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
659 fi
660 fi
661
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
674 fi
675 fi
676
677 # Validate the MD5SUM one last time
678 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
679 gs_wrt_message "$FILE does not match MD5SUMS value"
680 # Force generation of MD5SUM
681 HAVEMD5=0
682 fi
683
684 # Generate a fresh MD5SUM for this file
685 if [[ "$HAVEMD5" = "0" ]] ; then
686 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
687 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
688 fi
689
690 # Good or bad we write the original md5sum to a file
691 echo "$MD5" >> MD5SUMS
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
710 fi
711}
712
713
714#----------------------------#
715create_urls() { #
716#----------------------------#
717 cd $JHALFSDIR
718
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
746
747 cd $BUILDDIR/sources
748}
Note: See TracBrowser for help on using the repository browser.