source: common/common-functions@ e66ee70

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

Small change required by customization support.

  • Property mode set to 100644
File size: 26.1 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set -e
6
7
8no_empty_builddir() {
9 'clear'
10cat <<- -EOF-
11${DD_BORDER}
12
13${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
14 Looks like the \$BUILDDIR directory contains subdirectories
15 from a previous HLFS build.
16
17 Please format the partition mounted on \$BUILDDIR or set
18 a different build directory before running jhalfs.
19${OFF}
20${DD_BORDER}
21-EOF-
22 exit
23}
24
25
26HEADER="# This file is automatically generated by jhalfs
27# DO NOT EDIT THIS FILE MANUALLY
28#
29# Generated on `date \"+%F %X %Z\"`"
30
31
32#------------------------------------------------------#
33# NEW Makefile scripting functions #
34#------------------------------------------------------#
35
36
37unset get_package_tarball_name
38#----------------------------------#
39get_package_tarball_name() { #
40#----------------------------------#
41 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
42
43 # The use of 'head' is necessary to limit the return value to the FIRST match..
44 # hopefully this will not cause problems.
45 #
46 case $script_name in
47 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
48 ;;
49 linux-headers)
50 if [ "${PROGNAME}" = "lfs" ]; then
51 # Uses kernel headers directly
52 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
53 else
54 # CLFS/HLFS use massaged headers package
55 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
56 fi
57 ;;
58 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
59 ;;
60 esac
61
62}
63
64
65unset wrt_RunaAsRoot
66#----------------------------------#
67wrt_RunAsRoot() { # Some scripts must be run as root..
68#----------------------------------#
69 local MOUNT_ENV
70 local this_script=$1
71 local file=$2
72
73 case ${PROGNAME} in
74 lfs ) MOUNT_ENV="LFS" ;;
75 blfs ) MOUNT_ENV="BLFS" ;;
76 clfs ) MOUNT_ENV="CLFS" ;;
77 clfs2 ) MOUNT_ENV="CLFS" ;;
78 hlfs ) MOUNT_ENV="HLFS" ;;
79 *) echo "undefined progname $PROGNAME"; exit 1 ;;
80 esac
81
82(
83cat << EOF
84 @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
85 \$(PRT_DU) >>logs/\$@
86EOF
87) >> $MKFILE.tmp
88}
89
90
91#------------------------------------------------------#
92#------------------------------------------------------#
93
94#----------------------------------#
95ROOT_RunAsRoot() { #
96#----------------------------------#
97 local file=$1
98(
99cat << EOF
100 @( time { source envars && \$(CMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
101 \$(PRT_DU_CR) >>logs/\$@
102EOF
103) >> $MKFILE.tmp
104}
105
106#----------------------------------#
107ROOT_Unpack() { # An alias, for clairity
108#----------------------------------#
109 local FILE=$1
110 local optSAVE_PREVIOUS=$2
111
112 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
113(
114cat << EOF
115 @\$(call remove_existing_dirs,$FILE)
116EOF
117) >> $MKFILE.tmp
118 fi
119
120(
121cat << EOF
122 @\$(call unpack,$FILE)
123 @\$(call get_pkg_root_LUSER)
124EOF
125) >> $MKFILE.tmp
126}
127
128#------------------------------------------------------#
129#------------------------------------------------------#
130
131#----------------------------------#
132LUSER_wrt_target() { # Create target and initialize log file
133#----------------------------------#
134 local i=$1
135 local PREV=$2
136(
137cat << EOF
138
139$i: $PREV
140 @\$(call echo_message, Building)
141 @./progress_bar.sh \$@ \$\$PPID &
142 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
143 @\$(PRT_DU) >>logs/\$@
144EOF
145) >> $MKFILE.tmp
146}
147
148
149#----------------------------------#
150LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
151#----------------------------------#
152 local file=$1
153
154(
155cat << EOF
156 @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
157 \$(PRT_DU) >> logs/\$@
158EOF
159) >> $MKFILE.tmp
160}
161
162
163#----------------------------------#
164LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
165#----------------------------------#
166 local FILE=$1
167 local optSAVE_PREVIOUS=$2
168
169 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
170(
171cat << EOF
172 @\$(call remove_existing_dirs,$FILE)
173EOF
174) >> $MKFILE.tmp
175 fi
176
177(
178cat << EOF
179 @\$(call unpack,$FILE)
180 @\$(call get_pkg_root_LUSER)
181EOF
182) >> $MKFILE.tmp
183
184}
185
186
187#----------------------------------#
188LUSER_wrt_CopyFstab() { #
189#----------------------------------#
190(
191cat << EOF
192 @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
193EOF
194) >> $MKFILE.tmp
195}
196
197
198#----------------------------------#
199LUSER_wrt_test_log() { # Initialize testsuite log file
200#----------------------------------#
201 local TESTLOGFILE=$1
202(
203cat << EOF
204 @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
205 echo '\$(nl_)\`date\`\$(nl_)' >$TESTLOGDIR/$TESTLOGFILE
206EOF
207) >> $MKFILE.tmp
208}
209
210
211#----------------------------------#
212LUSER_RemoveBuildDirs() { #
213#----------------------------------#
214 local name=$1
215(
216cat << EOF
217 @\$(call remove_build_dirs,$name)
218EOF
219) >> $MKFILE.tmp
220}
221
222#-----------------------------------------------------------------#
223#-----------------------------------------------------------------#
224
225#----------------------------------#
226CHROOT_wrt_target() { # Create target and initialize log file
227#----------------------------------#
228 local i=$1
229 local PREV=$2
230 case $i in
231 iteration* ) local LOGFILE="${this_script}.log" ;;
232 * ) local LOGFILE="\$@" ;;
233 esac
234(
235cat << EOF
236
237$i: $PREV
238 @\$(call echo_message, Building)
239 @./progress_bar.sh \$@ \$\$PPID &
240 @echo "\$(nl_)\`date\`\$(nl_)" >logs/$LOGFILE
241 @\$(PRT_DU_CR) >>logs/$LOGFILE
242EOF
243) >> $MKFILE.tmp
244}
245
246
247#----------------------------------#
248CHROOT_Unpack() { #
249#----------------------------------#
250 local FILE=$1
251 local optSAVE_PREVIOUS=$2
252
253 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
254(
255cat << EOF
256 @\$(call remove_existing_dirs2,$FILE)
257EOF
258) >> $MKFILE.tmp
259 fi
260(
261cat << EOF
262 @\$(call unpack3,$FILE)
263 @\$(call get_pkg_root2)
264EOF
265) >> $MKFILE.tmp
266}
267
268
269#----------------------------------#
270CHROOT_wrt_test_log() { #
271#----------------------------------#
272 local TESTLOGFILE=$1
273(
274cat << EOF
275 @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
276 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/$TESTLOGFILE
277EOF
278) >> $MKFILE.tmp
279}
280
281
282#----------------------------------#
283CHROOT_wrt_RunAsRoot() { #
284#----------------------------------#
285 local file=$1
286(
287cat << EOF
288 @( time { source envars && \$(crCMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
289 \$(PRT_DU_CR) >>logs/\$@
290EOF
291) >> $MKFILE.tmp
292
293}
294
295
296#----------------------------------#
297CHROOT_wrt_CopyFstab() { #
298#----------------------------------#
299(
300cat << EOF
301 @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
302EOF
303) >> $MKFILE.tmp
304}
305
306
307#----------------------------------#
308CHROOT_wrt_RemoveBuildDirs() { #
309#----------------------------------#
310 local name=$1
311(
312cat << EOF
313 @\$(call remove_build_dirs2,$name)
314EOF
315) >> $MKFILE.tmp
316}
317
318
319unset wrt_touch
320#----------------------------------#
321wrt_touch() { #
322#----------------------------------#
323(
324cat << EOF
325 @\$(call housekeeping)
326EOF
327) >> $MKFILE.tmp
328}
329
330
331#----------------------------------#
332wrt_blfs_tool_targets() { #
333#----------------------------------#
334
335 echo "${tab_}${GREEN}Processing... ${L_arrow}BLFS_TOOL ${R_arrow}"
336
337 for file in blfs-tool-deps/* ; do
338 # Keep the script file name
339 this_script=`basename $file`
340
341 # Grab the name of the target
342 name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@'`
343
344 # Find the package.
345 case $name in
346 tidy ) pkg_tarball=${TIDY_PKG} ;;
347 unzip ) pkg_tarball=${UNZIP_PKG} ;;
348 * ) pkg_tarball=$(get_package_tarball_name $name) ;;
349 esac
350
351 # Append each name of the script files to a list (this will become
352 # the names of the targets in the Makefile)
353 blfs_tool="$blfs_tool ${this_script}"
354
355 #--------------------------------------------------------------------#
356 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
357 #--------------------------------------------------------------------#
358 #
359 # Drop in the name of the target on a new line, and the previous target
360 # as a dependency. Also call the echo_message function.
361 CHROOT_wrt_target "${this_script}" "$PREV"
362
363 # Insert instructions for unpacking the package and changing directories
364 # DocBook-XML is a zip, the build script will handle that.
365 [[ ! "$name" = "docbook-xml" ]] && CHROOT_Unpack "$pkg_tarball"
366
367 # Run the script.
368 CHROOT_wrt_RunAsRoot "$file"
369
370 # Remove the build directory(ies) except if the package build fails.
371 [[ ! "$name" = "docbook-xml" ]] && CHROOT_wrt_RemoveBuildDirs "$name"
372
373 # Touch the tracking file.
374 case $name in
375 tidy ) pkg_ver=tidy-051026 ;;
376 unzip ) pkg_ver=unzip-5.52 ;;
377 * ) pkg_ver=$(echo $pkg_tarball | sed -e 's/.tar.*//;s/.tgz//;s/.zip//') ;;
378 esac
379 echo "\$(tab_)@touch $TRACKING_DIR/$pkg_ver" >> $MKFILE.tmp
380
381 # Include a touch of the target name so make can check
382 # if it's already been made.
383 wrt_touch
384 #
385 #--------------------------------------------------------------------#
386 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
387 #--------------------------------------------------------------------#
388
389 # Keep the script file name for Makefile dependencies.
390 PREV=${this_script}
391 done
392}
393
394#------------------------------------------------------#
395# END Makefile scripting functions #
396#------------------------------------------------------#
397
398
399
400#----------------------------#
401run_make() { #
402#----------------------------#
403 # Test if make must be run.
404 if [ "$RUNMAKE" = "y" ] ; then
405 # Test to make sure we're running the build as root
406 if [ "$UID" = "0" ] ; then
407 echo "You must not be logged in as root to build the system."
408 exit 1
409 fi
410 # Build the system
411 if [ -e $MKFILE ] ; then
412 echo -ne "Building the system...\n"
413 cd $JHALFSDIR && make
414 echo -ne "done\n"
415 fi
416 fi
417}
418
419
420#----------------------------#
421clean_builddir() { #
422#----------------------------#
423 # Test if the clean must be done.
424 if [ "${CLEAN}" = "y" ]; then
425 # Test to make sure that the build directory was populated by jhalfs
426 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
427 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
428 exit 1
429 else
430 # Clean the build directory
431 echo -n "Cleaning $BUILDDIR ..."
432 sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
433 echo "done"
434 echo -n "Cleaning $JHALFSDIR ..."
435 sudo rm -rf $JHALFSDIR
436 echo "done"
437 echo -n "Cleaning remainig extracted sources in $BUILDDIR/sources ..."
438 sudo rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
439 echo "done"
440 fi
441 fi
442}
443
444#----------------------------#
445get_book() { #
446#----------------------------#
447 cd $JHALFSDIR
448
449 if [ -z $WORKING_COPY ] ; then
450 # Check for Subversion instead of just letting the script hit 'svn' and fail.
451 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
452 exit 1"
453 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
454
455 case $PROGNAME in
456 lfs) svn_root="LFS" ;;
457 hlfs) svn_root="HLFS" ;;
458 clfs) svn_root="cross-lfs" ;;
459 clfs2) svn_root="cross-lfs" ;;
460 *) echo "BOOK not defined in function <get_book>"
461 exit 1 ;;
462 esac
463 # Grab a fresh book if it's missing, otherwise, update it from the
464 # repo. If we've already extracted the commands, move on to getting the
465 # sources.
466 if [ -d ${PROGNAME}-$LFSVRS ] ; then
467 cd ${PROGNAME}-$LFSVRS
468 if LC_ALL=C svn up | grep -q At && \
469 test -d $JHALFSDIR/${PROGNAME}-commands && \
470 test -f $JHALFSDIR/pkg_tarball_list ; then
471 # Set the canonical book version
472 echo -ne "done\n"
473 cd $JHALFSDIR
474 case $PROGNAME in
475 clfs | clfs2)
476 VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
477 *)
478 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
479 esac
480 get_sources
481 else
482 echo -ne "done\n"
483 extract_commands
484 fi
485 else
486 svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
487 echo -ne "done\n"
488 extract_commands
489 fi
490
491 else
492 echo -ne "Using $BOOK as book's sources ...\n"
493 extract_commands
494 fi
495 echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
496}
497
498#----------------------------#
499extract_commands() { #
500#----------------------------#
501
502 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
503 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
504 exit 1"
505
506 cd $JHALFSDIR
507 case $PROGNAME in
508 clfs | clfs2 )
509 VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
510 *)
511 VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
512 esac
513
514 # Start clean
515 if [ -d ${PROGNAME}-commands ]; then
516 rm -rf ${PROGNAME}-commands
517 mkdir -v ${PROGNAME}-commands
518 fi
519 echo -n "Extracting commands for"
520
521 # Dump the commands in shell script form from the HLFS book.
522 case ${PROGNAME} in
523 clfs)
524 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
525 xsltproc --nonet \
526 --xinclude \
527 --stringparam method $METHOD \
528 --stringparam testsuite $TEST \
529 --stringparam bomb-testsuite $BOMB_TEST \
530 --stringparam vim-lang $VIMLANG \
531 --stringparam timezone $TIMEZONE \
532 --stringparam page $PAGE \
533 --stringparam lang $LANG \
534 -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
535 ;;
536
537 clfs2)
538 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
539 xsltproc --nonet \
540 --xinclude \
541 --stringparam vim-lang $VIMLANG \
542 --stringparam timezone $TIMEZONE \
543 --stringparam page $PAGE \
544 --stringparam lang $LANG \
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 bomb-testsuite $BOMB_TEST \
554 --stringparam timezone $TIMEZONE \
555 --stringparam page $PAGE \
556 --stringparam lang $LANG \
557 --stringparam lc_all $LC_ALL \
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 bomb-testsuite $BOMB_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 [[ "${BLFS_TOOL}" = "y" ]] && copy_blfs_deps_scripts
577
578 echo " ...OK"
579
580 # Make the scripts executable.
581 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
582
583 # Create the packages file. We need it for proper Makefile creation
584 create_package_list
585
586 # Done. Moving on...
587 get_sources
588
589}
590
591#----------------------------#
592create_package_list() { #
593#----------------------------#
594
595 # Create the packages file. We need it for proper Makefile creation
596 rm -f pkg_tarball_list
597 echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
598 case ${PROGNAME} in
599 clfs | clfs2)
600 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
601 $BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
602 ;;
603 hlfs)
604 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
605 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
606 ;;
607 lfs)
608 xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
609 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
610 ;;
611 esac
612
613 if [[ "${BLFS_TOOL}" = "y" ]] ; then
614(
615cat << EOF
616$LIBXML_PKG
617$LIBXSLT_PKG
618$TIDY_PKG
619$UNZIP_PKG
620$DBXML_PKG
621$DBXSL_PKG
622$LINKS_PKG
623$SUDO_PKG
624$WGET_PKG
625$SVN_PKG
626$GPM_PKG
627EOF
628) >> pkg_tarball_list
629 fi
630
631 echo " ...OK"
632
633}
634
635
636#----------------------------#
637get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
638#----------------------------#
639 local saveIFS=$IFS
640 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
641
642 # Test if the packages must be downloaded
643 [ ! "$GETPKG" = "y" ] && return
644
645 gs_wrt_message(){
646 echo "${RED}$1${OFF}"
647 echo "$1" >> MISSING_FILES.DMP
648 }
649 # Housekeeping
650 [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
651 cd $BUILDDIR/sources
652 [[ -f MD5SUMS ]] && rm MD5SUMS
653 [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
654 [[ -f urls.lst ]] && rm urls.lst
655
656 # Generate URLs file
657 create_urls
658
659 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
660 for line in `cat urls.lst`; do
661 IFS=$saveIFS # Restore the system defaults
662
663 # Skip some packages if they aren't needed
664 case $line in
665 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
666 [[ "$TEST" = "0" ]] && continue
667 ;;
668 */vim-*-lang* )
669 [[ "$VIMLANG" = "0" ]] && continue
670 ;;
671 *linux/linux-* )
672 [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
673 [[ "$GETKERNEL" = "n" ]] && continue
674 ;;
675 esac
676
677 # Locations
678 URL1=`echo $line | cut -d" " -f2` # Preferred URL
679 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
680 FILE=`basename $URL1` # File name
681 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
682
683 # Validation pair
684 MD5="$BOOKMD5 $FILE"
685 HAVEMD5=1
686
687 set -e
688 # If the file exists in the archive copy it to the
689 # $BUILDDIR/sources dir. MD5SUM will be validated later.
690 if [ ! -z ${SRC_ARCHIVE} ] &&
691 [ -d ${SRC_ARCHIVE} ] &&
692 [ -f ${SRC_ARCHIVE}/$FILE ]; then
693 cp ${SRC_ARCHIVE}/$FILE .
694 echo "$FILE: -- copied from $SRC_ARCHIVE"
695 fromARCHIVE=1
696 else
697 echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
698 fromARCHIVE=0
699 # If the file does not exist yet in /sources download a fresh one
700 if [ ! -f $FILE ] ; then
701 if ! wget $URL1 && ! wget $URL2 ; then
702 gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
703 continue
704 fi
705 fi
706 fi
707
708 # IF the md5sum does not match the existing files
709 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
710 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
711 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
712 # Remove the old file and download a new one
713 rm -fv $FILE
714 # Force storage in SRC_ARCHIVE
715 fromARCHIVE=0;
716 # Try to retrieve again the file. Servers in reverse order.
717 if ! wget $URL2 && ! wget $URL1 ; then
718 gs_wrt_message "$FILE not found on the servers.. SKIPPING"
719 continue
720 fi
721 fi
722
723 # Validate the MD5SUM one last time
724 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
725 gs_wrt_message "$FILE does not match MD5SUMS value"
726 # Force generation of MD5SUM
727 HAVEMD5=0
728 fi
729
730 # Generate a fresh MD5SUM for this file
731 if [[ "$HAVEMD5" = "0" ]] ; then
732 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
733 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
734 fi
735
736 # Good or bad we write the original md5sum to a file
737 echo "$MD5" >> MD5SUMS
738
739 # Copy the freshly downloaded file
740 # to the source archive.
741 if [ ! -z ${SRC_ARCHIVE} ] &&
742 [ -d ${SRC_ARCHIVE} ] &&
743 [ -w ${SRC_ARCHIVE} ] &&
744 [ "$fromARCHIVE" = "0" ] ; then
745 echo "Storing file:<$FILE> in the package archive"
746 cp -f $FILE ${SRC_ARCHIVE}
747 fi
748
749 done
750
751 if [[ -s MISSING_FILES.DMP ]]; then
752 echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have bad MD5SUMS.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
753 # Do not allow the automatic execution of the Makefile.
754 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
755 RUNMAKE="n"
756 fi
757}
758
759#----------------------------#
760create_urls() { #
761#----------------------------#
762 cd $JHALFSDIR
763
764 case ${PROGNAME} in
765 clfs)
766 echo -n "Creating CLFS <${ARCH}> specific URLs file"
767 xsltproc --nonet --xinclude \
768 --stringparam server $SERVER \
769 -o $BUILDDIR/sources/urls.lst urls.xsl \
770 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
771 echo " ...OK"
772 ;;
773 clfs2)
774 echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
775 xsltproc --nonet --xinclude \
776 --stringparam server $SERVER \
777 -o $BUILDDIR/sources/urls.lst urls.xsl \
778 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
779 echo " ...OK"
780 ;;
781 hlfs)
782 echo -n "Creating HLFS <${MODEL}> specific URLs file"
783 xsltproc --nonet --xinclude \
784 --stringparam server $SERVER \
785 --stringparam model $MODEL \
786 -o $BUILDDIR/sources/urls.lst urls.xsl \
787 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
788 echo " ...OK"
789 ;;
790 lfs)
791 echo -n "Creating LFS specific URLs file"
792 xsltproc --nonet --xinclude \
793 --stringparam server $SERVER \
794 -o ../sources/urls.lst urls.xsl \
795 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
796 echo " ...OK"
797 ;;
798 esac
799
800 cd $BUILDDIR/sources
801
802 if [[ "${BLFS_TOOL}" = "y" ]]; then
803 add_blfs_deps_urls
804 fi
805
806 if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
807 add_CustomToolsURLS
808 fi
809
810}
811
812#----------------------------# Hardcoded URLs and MD5.
813add_blfs_deps_urls() { # No easy way to extract it.
814#----------------------------# Some FTP mirrors may not work
815
816 local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
817
818 if [[ "${DEP_LIBXML}" = "y" ]] ; then
819 echo "${LIBXML_URL} ${BLFS_SERVER}libxml2/${LIBXML_PKG} ${LIBXML_MD5}" >> urls.lst
820 fi
821
822 if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
823 echo "${LIBXSLT_URL} ${BLFS_SERVER}libxslt/${LIBXSLT_PKG} ${LIBXSLT_MD5}" >> urls.lst
824 fi
825
826 if [[ "${DEP_TIDY}" = "y" ]] ; then
827 echo "${TIDY_URL} ${BLFS_SERVER}tidy/${TIDY_PKG} ${TIDY_MD5}" >> urls.lst
828 echo "${TIDY_PATCH_URL} ${BLFS_SERVER}tidy/${TIDY_PATCH} ${TIDY_PATCH_MD5}" >> urls.lst
829 echo "${TIDY_DOCS_URL} ${BLFS_SERVER}tidy/${TIDY_DOCS} ${TIDY_DOCS_MD5}" >> urls.lst
830 fi
831
832 if [[ "${DEP_UNZIP}" = "y" ]] ; then
833 echo "${UNZIP_URL} ${BLFS_SERVER}unzip/${UNZIP_PKG} ${UNZIP_MD5}" >> urls.lst
834 fi
835
836 if [[ "${DEP_DBXML}" = "y" ]] ; then
837 echo "${DBXML_URL} ${BLFS_SERVER}docbook-xml/${DBXML_PKG} ${DBXML_MD5}" >> urls.lst
838 fi
839
840 if [[ "${DEP_DBXSL}" = "y" ]] ; then
841 echo "${DBXSL_URL} ${BLFS_SERVER}docbook-xsl/${DBXSL_PKG} ${DBXSL_MD5}" >> urls.lst
842 fi
843
844 if [[ "${DEP_LINKS}" = "y" ]] ; then
845 echo "${LINKS_URL} ${BLFS_SERVER}links/${LINKS_PKG} ${LINKS_MD5}" >> urls.lst
846 fi
847
848 if [[ "${DEP_SUDO}" = "y" ]] ; then
849 echo "${SUDO_URL} ${BLFS_SERVER}sudo/${SUDO_PKG} ${SUDO_MD5}" >> urls.lst
850 echo "${SUDO_PATCH_URL} ${BLFS_SERVER}sudo/${SUDO_PATCH} ${SUDO_PATCH_MD5}" >> urls.lst
851 fi
852
853 if [[ "${DEP_WGET}" = "y" ]] ; then
854 echo "${WGET_URL} ${BLFS_SERVER}wget/${WGET_PKG} ${WGET_MD5}" >> urls.lst
855 fi
856
857 if [[ "${DEP_SVN}" = "y" ]] ; then
858 echo "${SVN_URL} ${BLFS_SERVER}subversion/${SVN_PKG} ${SVN_MD5}" >> urls.lst
859 fi
860
861 if [[ "${DEP_GPM}" = "y" ]] ; then
862 echo "${GPM_URL} ${BLFS_SERVER}gpm/${GPM_PKG} ${GPM_MD5}" >> urls.lst
863 echo "${GPM_PATCH_1_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_1} ${GPM_PATCH_1_MD5}" >> urls.lst
864 echo "${GPM_PATCH_2_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_2} ${GPM_PATCH_2_MD5}" >> urls.lst
865 fi
866
867}
868
869#----------------------------# Maybe there is a better way to do this, but this
870copy_blfs_deps_scripts() { # method avoid to place the test on all
871#----------------------------# $PROGNAME/master.sh scripts.
872
873 mkdir -p ${PROGNAME}-commands/blfs-tool-deps
874
875 if [[ "${DEP_LIBXML}" = "y" ]] ; then
876 mv blfs-tool-deps/901-libxml2 ${PROGNAME}-commands/blfs-tool-deps
877 fi
878
879 if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
880 mv blfs-tool-deps/902-libxslt ${PROGNAME}-commands/blfs-tool-deps
881 fi
882
883 if [[ "${DEP_TIDY}" = "y" ]] ; then
884 mv blfs-tool-deps/903-tidy ${PROGNAME}-commands/blfs-tool-deps
885 fi
886
887 if [[ "${DEP_UNZIP}" = "y" ]] ; then
888 mv blfs-tool-deps/904-unzip ${PROGNAME}-commands/blfs-tool-deps
889 fi
890
891 if [[ "${DEP_DBXML}" = "y" ]] ; then
892 mv blfs-tool-deps/905-docbook-xml ${PROGNAME}-commands/blfs-tool-deps
893 fi
894
895 if [[ "${DEP_DBXSL}" = "y" ]] ; then
896 mv blfs-tool-deps/906-docbook-xsl ${PROGNAME}-commands/blfs-tool-deps
897 fi
898
899 if [[ "${DEP_LINKS}" = "y" ]] ; then
900 mv blfs-tool-deps/908-links ${PROGNAME}-commands/blfs-tool-deps
901 fi
902
903 if [[ "${DEP_SUDO}" = "y" ]] ; then
904 mv blfs-tool-deps/909-sudo ${PROGNAME}-commands/blfs-tool-deps
905 fi
906
907 if [[ "${DEP_WGET}" = "y" ]] ; then
908 mv blfs-tool-deps/910-wget ${PROGNAME}-commands/blfs-tool-deps
909 fi
910
911 if [[ "${DEP_SVN}" = "y" ]] ; then
912 mv blfs-tool-deps/911-subversion ${PROGNAME}-commands/blfs-tool-deps
913 fi
914
915 if [[ "${DEP_GPM}" = "y" ]] ; then
916 mv blfs-tool-deps/907-gpm ${PROGNAME}-commands/blfs-tool-deps
917 fi
918
919 rm -rf blfs-tool-deps
920
921}
Note: See TracBrowser for help on using the repository browser.