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
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" ;;
69 *) echo "undefined progname $PROGNAME"; exit 1
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
[1ba5024]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
[50fb011]97#------------------------------------------------------#
98#------------------------------------------------------#
99
[d14903f]100#----------------------------------#
[d66cbc2]101ROOT_RunAsRoot() { #
[d14903f]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#------------------------------------------------------#
[50fb011]136
[398a037]137#----------------------------------#
[50fb011]138LUSER_wrt_target() { # Create target and initialize log file
[398a037]139#----------------------------------#
140 local i=$1
[50fb011]141 local PREV=$2
[398a037]142(
[50fb011]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/\$@
[460ea63]149EOF
150) >> $MKFILE.tmp
151}
152
153
[398a037]154#----------------------------------#
[50fb011]155LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
[398a037]156#----------------------------------#
[50fb011]157 local file=$1
158
[398a037]159(
160cat << EOF
[50fb011]161 @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
162 \$(PRT_DU) >> logs/\$@
[398a037]163EOF
164) >> $MKFILE.tmp
165}
166
[50fb011]167
[0170229]168#----------------------------------#
[50fb011]169LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
[0170229]170#----------------------------------#
171 local FILE=$1
[460ea63]172 local optSAVE_PREVIOUS=$2
173
[398a037]174 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
175(
176cat << EOF
177 @\$(call remove_existing_dirs,$FILE)
178EOF
179) >> $MKFILE.tmp
[460ea63]180 fi
[398a037]181
[0170229]182(
183cat << EOF
184 @\$(call unpack,$FILE)
[50fb011]185 @\$(call get_pkg_root_LUSER)
[3b63c8c]186EOF
187) >> $MKFILE.tmp
188
[398a037]189}
[3b63c8c]190
[50fb011]191
[0170229]192#----------------------------------#
[50fb011]193LUSER_wrt_CopyFstab() { #
[0170229]194#----------------------------------#
[398a037]195(
196cat << EOF
[50fb011]197 @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
[0170229]198EOF
199) >> $MKFILE.tmp
200}
201
[50fb011]202
[65d83a6]203#----------------------------------#
[50fb011]204LUSER_wrt_test_log() { # Initialize testsuite log file
[65d83a6]205#----------------------------------#
[50fb011]206 local TESTLOGFILE=$1
[0170229]207(
208cat << EOF
[50fb011]209 @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
210 echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE
[0170229]211EOF
212) >> $MKFILE.tmp
213}
214
[398a037]215
[e35e794]216#----------------------------------#
[50fb011]217LUSER_RemoveBuildDirs() { #
[e35e794]218#----------------------------------#
[398a037]219 local name=$1
[e35e794]220(
[398a037]221cat << EOF
222 @\$(call remove_build_dirs,$name)
[e35e794]223EOF
224) >> $MKFILE.tmp
225}
226
[50fb011]227#-----------------------------------------------------------------#
228#-----------------------------------------------------------------#
229
[e35e794]230#----------------------------------#
[50fb011]231CHROOT_wrt_target() { # Create target and initialize log file
[e35e794]232#----------------------------------#
[50fb011]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
[e35e794]239(
[398a037]240cat << EOF
[50fb011]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
[e35e794]246EOF
247) >> $MKFILE.tmp
248}
249
[398a037]250
[0170229]251#----------------------------------#
[50fb011]252CHROOT_Unpack() { #
[0170229]253#----------------------------------#
[50fb011]254 local FILE=$1
255 local optSAVE_PREVIOUS=$2
256
257 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
[0170229]258(
[398a037]259cat << EOF
[50fb011]260 @\$(call remove_existing_dirs2,$FILE)
[0170229]261EOF
262) >> $MKFILE.tmp
[50fb011]263 fi
[0170229]264(
[50fb011]265cat << EOF
266 @\$(call unpack3,$FILE)
267 @\$(call get_pkg_root2)
[0170229]268EOF
269) >> $MKFILE.tmp
270}
271
272
273#----------------------------------#
[50fb011]274CHROOT_wrt_test_log() { #
[0170229]275#----------------------------------#
[50fb011]276 local TESTLOGFILE=$1
[3b63c8c]277(
[50fb011]278cat << EOF
279 @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
280 echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
[3b63c8c]281EOF
282) >> $MKFILE.tmp
283}
284
[50fb011]285
[65d83a6]286#----------------------------------#
[50fb011]287CHROOT_wrt_RunAsRoot() { #
[65d83a6]288#----------------------------------#
[50fb011]289 local file=$1
[0170229]290(
291cat << EOF
[50fb011]292 @( time { source envars && \$(crCMDSDIR)/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
293 \$(PRT_DU_CR) >>logs/$this_script
[0170229]294EOF
295) >> $MKFILE.tmp
[50fb011]296
[0170229]297}
298
299
300#----------------------------------#
[50fb011]301CHROOT_wrt_CopyFstab() { #
[0170229]302#----------------------------------#
303(
[398a037]304cat << EOF
[50fb011]305 @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
[0170229]306EOF
307) >> $MKFILE.tmp
308}
309
310
311#----------------------------------#
[50fb011]312CHROOT_wrt_RemoveBuildDirs() { #
[0170229]313#----------------------------------#
[50fb011]314 local name=$1
[5359c48]315(
316cat << EOF
[50fb011]317 @\$(call remove_build_dirs2,$name)
[9199a13]318EOF
319) >> $MKFILE.tmp
320}
321
[50fb011]322
323unset wrt_touch
[9e4b9a1]324#----------------------------------#
[50fb011]325wrt_touch() { #
[9e4b9a1]326#----------------------------------#
327(
328cat << EOF
[50fb011]329 @\$(call housekeeping)
[9e4b9a1]330EOF
331) >> $MKFILE.tmp
332}
333
[50fb011]334#------------------------------------------------------#
335# END Makefile scripting functions #
336#------------------------------------------------------#
337
[9e4b9a1]338
[398a037]339
[0170229]340#----------------------------#
[65d83a6]341run_make() { #
[0170229]342#----------------------------#
343 # Test if make must be run.
[47fddc8]344 if [ "$RUNMAKE" = "y" ] ; then
[0170229]345 # Test to make sure we're running the build as root
346 if [ "$UID" != "0" ] ; then
[60b56fd]347 echo "You must be logged in as root to successfully build the system."
[0170229]348 exit 1
349 fi
350 # Build the system
351 if [ -e $MKFILE ] ; then
[60b56fd]352 echo -ne "Building the system...\n"
[54b4b32]353 cd $JHALFSDIR && make
[0170229]354 echo -ne "done\n"
355 fi
356 fi
357}
358
359
360#----------------------------#
[65d83a6]361clean_builddir() { #
[0170229]362#----------------------------#
363 # Test if the clean must be done.
[47fddc8]364 if [ "${CLEAN}" = "y" ]; then
[0170229]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
[60b56fd]372 echo "Looks like $BUILDDIR was not populated by a previous jhalfs-X run."
[0170229]373 exit 1
374 else
375 # Clean the build directory
376 echo -ne "Cleaning $BUILDDIR...\n"
[3465451]377 rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
[0170229]378 echo -ne "Cleaning $JHALFSDIR...\n"
[3b63c8c]379 rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
[0170229]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#----------------------------#
[65d83a6]388get_book() { #
[0170229]389#----------------------------#
390 cd $JHALFSDIR
391
[2b0f8a5]392 if [ -z $WORKING_COPY ] ; then
[0170229]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" ;;
[3b63c8c]402 clfs2) svn_root="cross-lfs" ;;
[0170229]403 *) echo "BOOK not defined in function <get_book>"
404 exit 1 ;;
405 esac
[60b56fd]406 # Grab a fresh book if it's missing, otherwise, update it from the
[0170229]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
[3b63c8c]411 if LC_ALL=C svn up | grep -q At && \
412 test -d $JHALFSDIR/${PROGNAME}-commands && \
413 test -f $JHALFSDIR/pkg_tarball_list ; then
[0170229]414 # Set the canonical book version
[3b63c8c]415 echo -ne "done\n"
[0170229]416 cd $JHALFSDIR
[3b63c8c]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
[0170229]423 get_sources
424 else
425 echo -ne "done\n"
426 extract_commands
427 fi
428 else
[3b63c8c]429 svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
[0170229]430 echo -ne "done\n"
431 extract_commands
432 fi
[3b63c8c]433
[0170229]434 else
435 echo -ne "Using $BOOK as book's sources ...\n"
436 extract_commands
437 fi
[3b63c8c]438 echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
[0170229]439}
440
441#----------------------------#
442extract_commands() { #
443#----------------------------#
[9e1915a]444
[0170229]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
[3b63c8c]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
[0170229]456
457 # Start clean
[3e3e28b]458 if [ -d ${PROGNAME}-commands ]; then
459 rm -rf ${PROGNAME}-commands
460 mkdir -v ${PROGNAME}-commands
[0170229]461 fi
[bef0a98]462 echo -n "Extracting commands for"
[0170229]463
464 # Dump the commands in shell script form from the HLFS book.
465 case ${PROGNAME} in
466 clfs)
[9c90294]467 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
[e676ffa]468 xsltproc --nonet \
469 --xinclude \
470 --stringparam method $METHOD \
471 --stringparam testsuite $TEST \
[056486c]472 --stringparam bomb-testsuite $BOMB_TEST \
[e676ffa]473 --stringparam vim-lang $VIMLANG \
474 --stringparam timezone $TIMEZONE \
475 --stringparam page $PAGE \
476 --stringparam lang $LANG \
[a9490ab]477 -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
[0170229]478 ;;
[3b63c8c]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 ;;
[0170229]490 hlfs)
[60b56fd]491 echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
[ad71d98]492 xsltproc --nonet \
493 --xinclude \
494 --stringparam model $MODEL \
495 --stringparam testsuite $TEST \
[056486c]496 --stringparam bomb-testsuite $BOMB_TEST \
[ad71d98]497 --stringparam timezone $TIMEZONE \
498 --stringparam page $PAGE \
[d87b293]499 --stringparam lang $LANG \
500 --stringparam lc_all $LC_ALL \
[ad71d98]501 --stringparam grsecurity_host $GRSECURITY_HOST \
502 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
[0170229]503 ;;
504 lfs)
[9c90294]505 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
[0170229]506 xsltproc --nonet \
507 --xinclude \
508 --stringparam testsuite $TEST \
[056486c]509 --stringparam bomb-testsuite $BOMB_TEST \
[0170229]510 --stringparam vim-lang $VIMLANG \
[ad71d98]511 --stringparam timezone $TIMEZONE \
512 --stringparam page $PAGE \
[d87b293]513 --stringparam lang $LANG \
[0170229]514 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
515 ;;
[3e7af38]516 *) exit 1 ;;
[0170229]517 esac
[dd810ea]518
[3c5ca23]519 [[ "${BLFS_TOOL}" = "y" ]] && copy_blfs_deps_scripts
520
[bef0a98]521 echo " ...OK"
[0170229]522
523 # Make the scripts executable.
524 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
525
[3e7af38]526 # Create the packages file. We need it for proper Makefile creation
[3b63c8c]527 create_package_list
[0170229]528
529 # Done. Moving on...
530 get_sources
[50fb011]531
[0170229]532}
533
[3b63c8c]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
[f67691e]555
556 if [[ "${BLFS_TOOL}" = "y" ]] ; then
557(
558cat << EOF
[c03e5d0]559$LIBXML_PKG
560$LIBXSLT_PKG
561$DBXSL_PKG
562$LINKS_PKG
563$SUDO_PKG
564$WGET_PKG
565$SVN_PKG
566$GPM_PKG
[f67691e]567EOF
568) >> pkg_tarball_list
569 fi
570
[3b63c8c]571 echo " ...OK"
572
573}
574
575
[0170229]576#----------------------------#
[3e7af38]577get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
[0170229]578#----------------------------#
[3e7af38]579 local saveIFS=$IFS
[7a100d96]580 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
[65d83a6]581
582 # Test if the packages must be downloaded
[47fddc8]583 [ ! "$GETPKG" = "y" ] && return
[65d83a6]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
[4aede02]595
[3e7af38]596 # Generate URLs file
[65d83a6]597 create_urls
[3e7af38]598
[65d83a6]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
[3e7af38]602
603 # Skip some packages if they aren't needed
[65d83a6]604 case $line in
[3e7af38]605 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
606 [[ "$TEST" = "0" ]] && continue
607 ;;
608 */vim-*-lang* )
609 [[ "$VIMLANG" = "0" ]] && continue
610 ;;
[3a27393]611 *linux/linux-* )
[34933b4]612 [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
[47fddc8]613 [[ "$GETKERNEL" = "n" ]] && continue
[3a27393]614 ;;
[65d83a6]615 esac
[3e7af38]616
[65d83a6]617 # Locations
618 URL1=`echo $line | cut -d" " -f2` # Preferred URL
619 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
[7a100d96]620 FILE=`basename $URL1` # File name
621 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
622
[3a27393]623 # Validation pair
624 MD5="$BOOKMD5 $FILE"
625 HAVEMD5=1
[0170229]626
[65d83a6]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
[3a27393]639 # If the file does not exist yet in /sources download a fresh one
[3e7af38]640 if [ ! -f $FILE ] ; then
[65d83a6]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
[3e7af38]645 fi
[65d83a6]646 fi
[0170229]647
[3a27393]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
[3e7af38]660 fi
[65d83a6]661 fi
[e1edff3]662
[65d83a6]663 # Validate the MD5SUM one last time
[3a27393]664 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
[65d83a6]665 gs_wrt_message "$FILE does not match MD5SUMS value"
[b61a4a9]666 # Force generation of MD5SUM
667 HAVEMD5=0
[65d83a6]668 fi
[3e7af38]669
[65d83a6]670 # Generate a fresh MD5SUM for this file
671 if [[ "$HAVEMD5" = "0" ]] ; then
672 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
[3a27393]673 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
[3e7af38]674 fi
[e1edff3]675
[65d83a6]676 # Good or bad we write the original md5sum to a file
[3a27393]677 echo "$MD5" >> MD5SUMS
[65d83a6]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
[3b63c8c]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.
[65d83a6]694 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
[47fddc8]695 RUNMAKE="n"
[3e7af38]696 fi
[0170229]697}
698
699#----------------------------#
[3e7af38]700create_urls() { #
[0170229]701#----------------------------#
[3e7af38]702 cd $JHALFSDIR
[0170229]703
[3e7af38]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 ;;
[3b63c8c]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 ;;
[3e7af38]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
[0170229]739
[3e7af38]740 cd $BUILDDIR/sources
[865f4f6]741
[01b6d52]742 if [[ "${BLFS_TOOL}" = "y" ]]; then
[d66cbc2]743 add_blfs_deps_urls
[01b6d52]744 fi
[50fb011]745
[865f4f6]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
[c03e5d0]755 echo "${LIBXML_URL} ${BLFS_SERVER}libxml2/${LIBXML_PKG} ${LIBXML_MD5}" >> urls.lst
[865f4f6]756 fi
757
758 if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
[c03e5d0]759 echo "${LIBXSLT_URL} ${BLFS_SERVER}libxslt/${LIBXSLT_PKG} ${LIBXSLT_MD5}" >> urls.lst
[865f4f6]760 fi
761
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
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
[44994cb]831}
Note: See TracBrowser for help on using the repository browser.