source: common/common-functions@ 1ba5024

experimental
Last change on this file since 1ba5024 was 1ba5024, checked in by George Boudreau <georgeb@…>, 18 years ago

Remove unnecessary flow tests. Added missing function, wrt_report. Added restore-luser-env to chroot build

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