source: common/common-functions@ b9ec725

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since b9ec725 was a858a78, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

POC for progress bar.

  • Property mode set to 100644
File size: 22.3 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 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 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\"${OFF} builder tool (development) \$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.
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
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 @./progress_bar.sh \$@ \$(MAKE_PID) &
205 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$LOGFILE
206EOF
207) >> $MKFILE.tmp
208}
209
210
211#----------------------------------#
212wrt_unpack() { # Unpack and set 'ROOT' var
213#----------------------------------#
214 local FILE=$1
215(
216cat << EOF
217 @\$(call unpack,$FILE)
218 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
219 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
220 chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
221EOF
222) >> $MKFILE.tmp
223}
224
225
226#----------------------------------#
227wrt_unpack2() { #
228#----------------------------------#
229 local FILE=$1
230(
231cat << EOF
232 @\$(call unpack2,$FILE)
233 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
234 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
235EOF
236) >> $MKFILE.tmp
237}
238
239
240#----------------------------------#
241wrt_unpack3() { #
242#----------------------------------#
243 local FILE=$1
244(
245cat << EOF
246 @\$(call unpack3,$FILE)
247 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
248 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
249EOF
250) >> $MKFILE.tmp
251}
252
253
254#----------------------------------#
255wrt_target_vars() { # Target vars for hlfs (cross-build method)
256#----------------------------------#
257(
258cat << EOF
259 @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
260 echo "export ldso=/lib/${LOADER}" >> envars
261EOF
262) >> $MKFILE.tmp
263
264}
265
266
267#----------------------------------#
268wrt_run_as_su() { # Execute script inside time { }, footer to log file
269#----------------------------------#
270 local this_script=$1
271 local file=$2
272(
273cat << EOF
274 @( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
275 echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
276EOF
277) >> $MKFILE.tmp
278}
279
280
281#----------------------------------#
282wrt_run_as_root() { # Some scripts must be run as root..
283#----------------------------------#
284 local this_script=$1
285 local file=$2
286(
287cat << EOF
288 @( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
289 echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
290EOF
291) >> $MKFILE.tmp
292}
293
294
295#----------------------------------#
296wrt_run_as_root2() { #
297#----------------------------------#
298 local this_script=$1
299 local file=$2
300(
301cat << EOF
302 @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
303 echo -e "\nKB: \`du -skx --exclude=jhalfs \`\n" >>logs/$this_script
304EOF
305) >> $MKFILE.tmp
306}
307
308
309
310#----------------------------------#
311wrt_run_as_chroot1() { #
312#----------------------------------#
313 local this_script=$1
314 local file=$2
315(
316 cat << EOF
317 @( time { \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
318 echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
319EOF
320) >> $MKFILE.tmp
321}
322
323
324#----------------------------------#
325wrt_run_as_chroot2() { #
326#----------------------------------#
327 local this_script=$1
328 local file=$2
329(
330cat << EOF
331 @( time { \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
332 echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
333EOF
334) >> $MKFILE.tmp
335}
336
337
338#----------------------------------#
339wrt_copy_fstab() { #
340#----------------------------------#
341 local i=$1
342(
343 cat << EOF
344 @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
345EOF
346) >> $MKFILE.tmp
347}
348
349#----------------------------------#
350wrt_copy_fstab2() { #
351#----------------------------------#
352 local i=$1
353(
354 cat << EOF
355 @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
356EOF
357) >> $MKFILE.tmp
358}
359
360
361#----------------------------------#
362wrt_remove_build_dirs() { #
363#----------------------------------#
364 local name=$1
365(
366cat << EOF
367 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
368 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
369 if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
370 rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
371 fi;
372EOF
373) >> $MKFILE.tmp
374}
375
376
377#----------------------------------#
378wrt_remove_build_dirs2() { #
379#----------------------------------#
380 local name=$1
381(
382cat << EOF
383 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
384 rm -r \$(SRC)/\$\$ROOT && \\
385 if [ -e \$(SRC)/$name-build ]; then \\
386 rm -r \$(SRC)/$name-build; \\
387 fi;
388EOF
389) >> $MKFILE.tmp
390}
391
392
393#----------------------------------#
394wrt_report() { #
395#----------------------------------#
396(
397cat << EOF
398
399create-sbu_du-report: $PREV
400 @\$(call echo_message, Building)
401 @./create-sbu_du-report.sh logs $VERSION
402 @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
403 @touch \$@
404EOF
405) >> $MKFILE.tmp
406
407chapter789="$chapter789 create-sbu_du-report"
408}
409
410
411#----------------------------#
412run_make() { #
413#----------------------------#
414 # Test if make must be run.
415 if [ "$RUNMAKE" = "1" ] ; then
416 # Test to make sure we're running the build as root
417 if [ "$UID" != "0" ] ; then
418 echo "You must be logged in as root to successfully build the system."
419 exit 1
420 fi
421 # Build the system
422 if [ -e $MKFILE ] ; then
423 echo -ne "Building the system...\n"
424 cd $JHALFSDIR && make
425 echo -ne "done\n"
426 fi
427 fi
428}
429
430
431#----------------------------#
432clean_builddir() { #
433#----------------------------#
434 # Test if the clean must be done.
435 if [ "$CLEAN" = "1" ] ; then
436 # Test to make sure we're running the clean as root
437 if [ "$UID" != "0" ] ; then
438 echo "You must be logged in as root to clean the build directory."
439 exit 1
440 fi
441 # Test to make sure that the build directory was populated by jhalfs
442 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
443 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
444 exit 1
445 else
446 # Clean the build directory
447 echo -ne "Cleaning $BUILDDIR...\n"
448 rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
449 echo -ne "Cleaning $JHALFSDIR...\n"
450 rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
451 echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
452 rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
453 echo -ne "done\n"
454 fi
455 fi
456}
457
458#----------------------------#
459get_book() { #
460#----------------------------#
461 cd $JHALFSDIR
462
463 if [ -z $WC ] ; then
464 # Check for Subversion instead of just letting the script hit 'svn' and fail.
465 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
466 exit 1"
467 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
468
469 case $PROGNAME in
470 lfs) svn_root="LFS" ;;
471 hlfs) svn_root="HLFS" ;;
472 clfs) svn_root="cross-lfs" ;;
473 *) echo "BOOK not defined in function <get_book>"
474 exit 1 ;;
475 esac
476 # Grab a fresh book if it's missing, otherwise, update it from the
477 # repo. If we've already extracted the commands, move on to getting the
478 # sources.
479 if [ -d ${PROGNAME}-$LFSVRS ] ; then
480 cd ${PROGNAME}-$LFSVRS
481 if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/${PROGNAME}-commands && \
482 test -f $JHALFSDIR/packages ; then
483 echo -ne "done\n"
484 # Set the canonical book version
485 cd $JHALFSDIR
486 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
487 get_sources
488 else
489 echo -ne "done\n"
490 # Set the canonical book version
491 cd $JHALFSDIR
492 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
493 extract_commands
494 fi
495 else
496 case $LFSVRS in
497 development)
498 svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
499 esac
500 echo -ne "done\n"
501 # Set the canonical book version
502 cd $JHALFSDIR
503 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
504 extract_commands
505 fi
506 else
507 echo -ne "Using $BOOK as book's sources ...\n"
508 # Set the canonical book version
509 cd $JHALFSDIR
510 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
511 extract_commands
512 fi
513}
514
515#----------------------------#
516extract_commands() { #
517#----------------------------#
518
519 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
520 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
521 exit 1"
522
523 cd $JHALFSDIR
524 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
525
526 # Start clean
527 if [ -d ${PROGNAME}-commands ]; then
528 rm -rf ${PROGNAME}-commands
529 mkdir -v ${PROGNAME}-commands
530 fi
531 echo -n "Extracting commands for"
532
533 # Dump the commands in shell script form from the HLFS book.
534 case ${PROGNAME} in
535 clfs)
536 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
537 xsltproc --nonet \
538 --xinclude \
539 --stringparam method $METHOD \
540 --stringparam testsuite $TEST \
541 --stringparam vim-lang $VIMLANG \
542 --stringparam timezone $TIMEZONE \
543 --stringparam page $PAGE \
544 --stringparam lang $LANG \
545 --stringparam keymap $KEYMAP \
546 -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
547 ;;
548 hlfs)
549 echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
550 xsltproc --nonet \
551 --xinclude \
552 --stringparam model $MODEL \
553 --stringparam testsuite $TEST \
554 --stringparam timezone $TIMEZONE \
555 --stringparam page $PAGE \
556 --stringparam lang $LANG \
557 --stringparam lc_all $LC_ALL \
558 --stringparam keymap $KEYMAP \
559 --stringparam grsecurity_host $GRSECURITY_HOST \
560 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
561 ;;
562 lfs)
563 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
564 xsltproc --nonet \
565 --xinclude \
566 --stringparam testsuite $TEST \
567 --stringparam vim-lang $VIMLANG \
568 --stringparam timezone $TIMEZONE \
569 --stringparam page $PAGE \
570 --stringparam lang $LANG \
571 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
572 ;;
573 *) exit 1 ;;
574 esac
575
576 echo " ...OK"
577
578 # Make the scripts executable.
579 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
580
581 # Create the packages file. We need it for proper Makefile creation
582 rm -f packages
583 echo -n "Creating <${PROGNAME}> specific packages file"
584 grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
585 -e 's@">@"@' > packages
586 echo " ...OK"
587
588 # Done. Moving on...
589 get_sources
590}
591
592#----------------------------#
593get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
594#----------------------------#
595 local saveIFS=$IFS
596 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
597
598 # Test if the packages must be downloaded
599 [ ! "$GETPKG" = "1" ] && return
600
601 gs_wrt_message(){
602 echo "${RED}$1${OFF}"
603 echo "$1" >> MISSING_FILES.DMP
604 }
605 # Housekeeping
606 [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
607 cd $BUILDDIR/sources
608 [[ -f MD5SUMS ]] && rm MD5SUMS
609 [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
610 [[ -f urls.lst ]] && rm urls.lst
611
612 # Generate URLs file
613 create_urls
614
615 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
616 for line in `cat urls.lst`; do
617 IFS=$saveIFS # Restore the system defaults
618
619 # Skip some packages if they aren't needed
620 case $line in
621 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
622 [[ "$TEST" = "0" ]] && continue
623 ;;
624 */vim-*-lang* )
625 [[ "$VIMLANG" = "0" ]] && continue
626 ;;
627 *linux/linux-* )
628 [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
629 [[ "$GETKERNEL" = "0" ]] && continue
630 ;;
631 esac
632
633 # Locations
634 URL1=`echo $line | cut -d" " -f2` # Preferred URL
635 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
636 FILE=`basename $URL1` # File name
637 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
638
639 # Validation pair
640 MD5="$BOOKMD5 $FILE"
641 HAVEMD5=1
642
643 set -e
644 # If the file exists in the archive copy it to the
645 # $BUILDDIR/sources dir. MD5SUM will be validated later.
646 if [ ! -z ${SRC_ARCHIVE} ] &&
647 [ -d ${SRC_ARCHIVE} ] &&
648 [ -f ${SRC_ARCHIVE}/$FILE ]; then
649 cp ${SRC_ARCHIVE}/$FILE .
650 echo "$FILE: -- copied from $SRC_ARCHIVE"
651 fromARCHIVE=1
652 else
653 echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
654 fromARCHIVE=0
655 # If the file does not exist yet in /sources download a fresh one
656 if [ ! -f $FILE ] ; then
657 if ! wget $URL1 && ! wget $URL2 ; then
658 gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
659 continue
660 fi
661 fi
662 fi
663
664 # IF the md5sum does not match the existing files
665 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
666 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
667 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
668 # Remove the old file and download a new one
669 rm -fv $FILE
670 # Force storage in SRC_ARCHIVE
671 fromARCHIVE=0;
672 # Try to retrieve again the file. Servers in reverse order.
673 if ! wget $URL2 && ! wget $URL1 ; then
674 gs_wrt_message "$FILE not found on the servers.. SKIPPING"
675 continue
676 fi
677 fi
678
679 # Validate the MD5SUM one last time
680 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
681 gs_wrt_message "$FILE does not match MD5SUMS value"
682 # Force generation of MD5SUM
683 HAVEMD5=0
684 fi
685
686 # Generate a fresh MD5SUM for this file
687 if [[ "$HAVEMD5" = "0" ]] ; then
688 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
689 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
690 fi
691
692 # Good or bad we write the original md5sum to a file
693 echo "$MD5" >> MD5SUMS
694
695 # Copy the freshly downloaded file
696 # to the source archive.
697 if [ ! -z ${SRC_ARCHIVE} ] &&
698 [ -d ${SRC_ARCHIVE} ] &&
699 [ -w ${SRC_ARCHIVE} ] &&
700 [ "$fromARCHIVE" = "0" ] ; then
701 echo "Storing file:<$FILE> in the package archive"
702 cp -f $FILE ${SRC_ARCHIVE}
703 fi
704
705 done
706
707 if [[ -s MISSING_FILES.DMP ]]; then
708 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"
709 # Do not allow the automatic exection of the Makefile.
710 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
711 RUNMAKE=0
712 fi
713}
714
715
716#----------------------------#
717create_urls() { #
718#----------------------------#
719 cd $JHALFSDIR
720
721 case ${PROGNAME} in
722 clfs)
723 echo -n "Creating CLFS <${ARCH}> specific URLs file"
724 xsltproc --nonet --xinclude \
725 --stringparam server $SERVER \
726 -o $BUILDDIR/sources/urls.lst urls.xsl \
727 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
728 echo " ...OK"
729 ;;
730 hlfs)
731 echo -n "Creating HLFS <${MODEL}> specific URLs file"
732 xsltproc --nonet --xinclude \
733 --stringparam server $SERVER \
734 --stringparam model $MODEL \
735 -o $BUILDDIR/sources/urls.lst urls.xsl \
736 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
737 echo " ...OK"
738 ;;
739 lfs)
740 echo -n "Creating LFS specific URLs file"
741 xsltproc --nonet --xinclude \
742 --stringparam server $SERVER \
743 -o ../sources/urls.lst urls.xsl \
744 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
745 echo " ...OK"
746 ;;
747 esac
748
749 cd $BUILDDIR/sources
750}
Note: See TracBrowser for help on using the repository browser.