source: common/common-functions@ e8fb8ef

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

Finished addition of missing BLFS_TOOL dependencies.

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