source: common/common-functions@ d14903f

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

First commit of CLFS changes to new Makefile scheme.. work still to be done on optimize function and ICA/farce tools

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