source: common/common-functions@ 1cc1575

experimental
Last change on this file since 1cc1575 was ffd8c5a, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Merged r3102 from trunk.

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