source: common/common-functions@ 640e48b

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 640e48b was 64c9caf, checked in by George Boudreau <georgeb@…>, 18 years ago

Handle massaged headers or kernel headers

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