source: common/common-functions@ 0921cae

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

Fixed create-sbu_du-report target run (I think)

  • Property mode set to 100644
File size: 22.9 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5set -e
6
7
8no_empty_builddir() {
9 'clear'
10cat <<- -EOF-
11${DD_BORDER}
12
13${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
14 Looks like the \$BUILDDIR directory contains subdirectories
15 from a previous HLFS build.
16
17 Please format the partition mounted on \$BUILDDIR or set
18 a different build directory before running jhalfs-X.
19${OFF}
20${DD_BORDER}
21-EOF-
22 exit
23}
24
25
26HEADER="# This file is automatically generated by jhalfs-X
27# DO NOT EDIT THIS FILE MANUALLY
28#
29# Generated on `date \"+%F %X %Z\"`"
30
31
32#------------------------------------------------------#
33# NEW Makefile scripting functions #
34#------------------------------------------------------#
35
36
37unset get_package_tarball_name
38#----------------------------------#
39get_package_tarball_name() { #
40#----------------------------------#
41 local script_name=$1
42
43 # The use of 'head' is necessary to limit the return value to the FIRST match..
44 # hopefully this will not cause problems.
45 #
46 case $script_name in
47 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
48 linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
49 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
50 esac
51
52}
53
54
55unset wrt_RunaAsRoot
56#----------------------------------#
57wrt_RunAsRoot() { # Some scripts must be run as root..
58#----------------------------------#
59 local ENV_MOUNT
60 local this_script=$1
61 local file=$2
62
63 case ${PROGNAME} in
64 lfs ) MOUNT_ENV="LFS" ;;
65 blfs ) MOUNT_ENV="BLFS" ;;
66 clfs ) MOUNT_ENV="CLFS" ;;
67 clfs2 ) MOUNT_ENV="CLFS" ;;
68 hlfs ) MOUNT_ENV="HLFS" ;;
69 *) echo "undefined progname $PROGNAME"; exit 1 ;;
70 esac
71
72(
73cat << EOF
74 @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
75 \$(PRT_DU_CR) >>logs/\$@
76EOF
77) >> $MKFILE.tmp
78}
79
80
81#------------------------------------------------------#
82#------------------------------------------------------#
83
84#----------------------------------#
85ROOT_RunAsRoot() { #
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#------------------------------------------------------#
120
121#----------------------------------#
122LUSER_wrt_target() { # Create target and initialize log file
123#----------------------------------#
124 local i=$1
125 local PREV=$2
126(
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/\$@
133EOF
134) >> $MKFILE.tmp
135}
136
137
138#----------------------------------#
139LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
140#----------------------------------#
141 local file=$1
142
143(
144cat << EOF
145 @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
146 \$(PRT_DU) >> logs/\$@
147EOF
148) >> $MKFILE.tmp
149}
150
151
152#----------------------------------#
153LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
154#----------------------------------#
155 local FILE=$1
156 local optSAVE_PREVIOUS=$2
157
158 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
159(
160cat << EOF
161 @\$(call remove_existing_dirs,$FILE)
162EOF
163) >> $MKFILE.tmp
164 fi
165
166(
167cat << EOF
168 @\$(call unpack,$FILE)
169 @\$(call get_pkg_root_LUSER)
170EOF
171) >> $MKFILE.tmp
172
173}
174
175
176#----------------------------------#
177LUSER_wrt_CopyFstab() { #
178#----------------------------------#
179(
180cat << EOF
181 @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
182EOF
183) >> $MKFILE.tmp
184}
185
186
187#----------------------------------#
188LUSER_wrt_test_log() { # Initialize testsuite log file
189#----------------------------------#
190 local TESTLOGFILE=$1
191(
192cat << EOF
193 @echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
194 echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE
195EOF
196) >> $MKFILE.tmp
197}
198
199
200#----------------------------------#
201LUSER_RemoveBuildDirs() { #
202#----------------------------------#
203 local name=$1
204(
205cat << EOF
206 @\$(call remove_build_dirs,$name)
207EOF
208) >> $MKFILE.tmp
209}
210
211#-----------------------------------------------------------------#
212#-----------------------------------------------------------------#
213
214#----------------------------------#
215CHROOT_wrt_target() { # Create target and initialize log file
216#----------------------------------#
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
223(
224cat << EOF
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
230EOF
231) >> $MKFILE.tmp
232}
233
234
235#----------------------------------#
236CHROOT_Unpack() { #
237#----------------------------------#
238 local FILE=$1
239 local optSAVE_PREVIOUS=$2
240
241 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
242(
243cat << EOF
244 @\$(call remove_existing_dirs2,$FILE)
245EOF
246) >> $MKFILE.tmp
247 fi
248(
249cat << EOF
250 @\$(call unpack3,$FILE)
251 @\$(call get_pkg_root2)
252EOF
253) >> $MKFILE.tmp
254}
255
256
257#----------------------------------#
258CHROOT_wrt_test_log() { #
259#----------------------------------#
260 local TESTLOGFILE=$1
261(
262cat << EOF
263 @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
264 echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
265EOF
266) >> $MKFILE.tmp
267}
268
269
270#----------------------------------#
271CHROOT_wrt_RunAsRoot() { #
272#----------------------------------#
273 local file=$1
274(
275cat << EOF
276 @( time { source envars && \$(crCMDSDIR)/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
277 \$(PRT_DU_CR) >>logs/$this_script
278EOF
279) >> $MKFILE.tmp
280
281}
282
283
284#----------------------------------#
285CHROOT_wrt_CopyFstab() { #
286#----------------------------------#
287(
288cat << EOF
289 @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
290EOF
291) >> $MKFILE.tmp
292}
293
294
295#----------------------------------#
296CHROOT_wrt_RemoveBuildDirs() { #
297#----------------------------------#
298 local name=$1
299(
300cat << EOF
301 @\$(call remove_build_dirs2,$name)
302EOF
303) >> $MKFILE.tmp
304}
305
306
307unset wrt_touch
308#----------------------------------#
309wrt_touch() { #
310#----------------------------------#
311(
312cat << EOF
313 @\$(call housekeeping)
314EOF
315) >> $MKFILE.tmp
316}
317
318#------------------------------------------------------#
319# END Makefile scripting functions #
320#------------------------------------------------------#
321
322
323
324#----------------------------#
325run_make() { #
326#----------------------------#
327 # Test if make must be run.
328 if [ "$RUNMAKE" = "y" ] ; then
329 # Test to make sure we're running the build as root
330 if [ "$UID" = "0" ] ; then
331 echo "You must not be logged in as root to build the system."
332 exit 1
333 fi
334 # Build the system
335 if [ -e $MKFILE ] ; then
336 echo -ne "Building the system...\n"
337 cd $JHALFSDIR && make
338 echo -ne "done\n"
339 fi
340 fi
341}
342
343
344#----------------------------#
345clean_builddir() { #
346#----------------------------#
347 # Test if the clean must be done.
348 if [ "${CLEAN}" = "y" ]; then
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
356 echo "Looks like $BUILDDIR was not populated by a previous jhalfs-X run."
357 exit 1
358 else
359 # Clean the build directory
360 echo -ne "Cleaning $BUILDDIR...\n"
361 rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
362 echo -ne "Cleaning $JHALFSDIR...\n"
363 rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
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#----------------------------#
372get_book() { #
373#----------------------------#
374 cd $JHALFSDIR
375
376 if [ -z $WORKING_COPY ] ; then
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" ;;
386 clfs2) svn_root="cross-lfs" ;;
387 *) echo "BOOK not defined in function <get_book>"
388 exit 1 ;;
389 esac
390 # Grab a fresh book if it's missing, otherwise, update it from the
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
395 if LC_ALL=C svn up | grep -q At && \
396 test -d $JHALFSDIR/${PROGNAME}-commands && \
397 test -f $JHALFSDIR/pkg_tarball_list ; then
398 # Set the canonical book version
399 echo -ne "done\n"
400 cd $JHALFSDIR
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
407 get_sources
408 else
409 echo -ne "done\n"
410 extract_commands
411 fi
412 else
413 svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
414 echo -ne "done\n"
415 extract_commands
416 fi
417
418 else
419 echo -ne "Using $BOOK as book's sources ...\n"
420 extract_commands
421 fi
422 echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
423}
424
425#----------------------------#
426extract_commands() { #
427#----------------------------#
428
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
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
440
441 # Start clean
442 if [ -d ${PROGNAME}-commands ]; then
443 rm -rf ${PROGNAME}-commands
444 mkdir -v ${PROGNAME}-commands
445 fi
446 echo -n "Extracting commands for"
447
448 # Dump the commands in shell script form from the HLFS book.
449 case ${PROGNAME} in
450 clfs)
451 echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
452 xsltproc --nonet \
453 --xinclude \
454 --stringparam method $METHOD \
455 --stringparam testsuite $TEST \
456 --stringparam bomb-testsuite $BOMB_TEST \
457 --stringparam vim-lang $VIMLANG \
458 --stringparam timezone $TIMEZONE \
459 --stringparam page $PAGE \
460 --stringparam lang $LANG \
461 -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
462 ;;
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 ;;
474 hlfs)
475 echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
476 xsltproc --nonet \
477 --xinclude \
478 --stringparam model $MODEL \
479 --stringparam testsuite $TEST \
480 --stringparam bomb-testsuite $BOMB_TEST \
481 --stringparam timezone $TIMEZONE \
482 --stringparam page $PAGE \
483 --stringparam lang $LANG \
484 --stringparam lc_all $LC_ALL \
485 --stringparam grsecurity_host $GRSECURITY_HOST \
486 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
487 ;;
488 lfs)
489 echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
490 xsltproc --nonet \
491 --xinclude \
492 --stringparam testsuite $TEST \
493 --stringparam bomb-testsuite $BOMB_TEST \
494 --stringparam vim-lang $VIMLANG \
495 --stringparam timezone $TIMEZONE \
496 --stringparam page $PAGE \
497 --stringparam lang $LANG \
498 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
499 ;;
500 *) exit 1 ;;
501 esac
502
503 [[ "${BLFS_TOOL}" = "y" ]] && copy_blfs_deps_scripts
504
505 echo " ...OK"
506
507 # Make the scripts executable.
508 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
509
510 # Create the packages file. We need it for proper Makefile creation
511 create_package_list
512
513 # Done. Moving on...
514 get_sources
515
516}
517
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
539
540 if [[ "${BLFS_TOOL}" = "y" ]] ; then
541(
542cat << EOF
543$LIBXML_PKG
544$LIBXSLT_PKG
545$DBXSL_PKG
546$LINKS_PKG
547$SUDO_PKG
548$WGET_PKG
549$SVN_PKG
550$GPM_PKG
551EOF
552) >> pkg_tarball_list
553 fi
554
555 echo " ...OK"
556
557}
558
559
560#----------------------------#
561get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
562#----------------------------#
563 local saveIFS=$IFS
564 local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
565
566 # Test if the packages must be downloaded
567 [ ! "$GETPKG" = "y" ] && return
568
569 gs_wrt_message(){
570 echo "${RED}$1${OFF}"
571 echo "$1" >> MISSING_FILES.DMP
572 }
573 # Housekeeping
574 [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
575 cd $BUILDDIR/sources
576 [[ -f MD5SUMS ]] && rm MD5SUMS
577 [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
578 [[ -f urls.lst ]] && rm urls.lst
579
580 # Generate URLs file
581 create_urls
582
583 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
584 for line in `cat urls.lst`; do
585 IFS=$saveIFS # Restore the system defaults
586
587 # Skip some packages if they aren't needed
588 case $line in
589 */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
590 [[ "$TEST" = "0" ]] && continue
591 ;;
592 */vim-*-lang* )
593 [[ "$VIMLANG" = "0" ]] && continue
594 ;;
595 *linux/linux-* )
596 [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
597 [[ "$GETKERNEL" = "n" ]] && continue
598 ;;
599 esac
600
601 # Locations
602 URL1=`echo $line | cut -d" " -f2` # Preferred URL
603 URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
604 FILE=`basename $URL1` # File name
605 BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
606
607 # Validation pair
608 MD5="$BOOKMD5 $FILE"
609 HAVEMD5=1
610
611 set -e
612 # If the file exists in the archive copy it to the
613 # $BUILDDIR/sources dir. MD5SUM will be validated later.
614 if [ ! -z ${SRC_ARCHIVE} ] &&
615 [ -d ${SRC_ARCHIVE} ] &&
616 [ -f ${SRC_ARCHIVE}/$FILE ]; then
617 cp ${SRC_ARCHIVE}/$FILE .
618 echo "$FILE: -- copied from $SRC_ARCHIVE"
619 fromARCHIVE=1
620 else
621 echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
622 fromARCHIVE=0
623 # If the file does not exist yet in /sources download a fresh one
624 if [ ! -f $FILE ] ; then
625 if ! wget $URL1 && ! wget $URL2 ; then
626 gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
627 continue
628 fi
629 fi
630 fi
631
632 # IF the md5sum does not match the existing files
633 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
634 [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
635 [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
636 # Remove the old file and download a new one
637 rm -fv $FILE
638 # Force storage in SRC_ARCHIVE
639 fromARCHIVE=0;
640 # Try to retrieve again the file. Servers in reverse order.
641 if ! wget $URL2 && ! wget $URL1 ; then
642 gs_wrt_message "$FILE not found on the servers.. SKIPPING"
643 continue
644 fi
645 fi
646
647 # Validate the MD5SUM one last time
648 if ! echo "$MD5" | md5sum -c - >/dev/null ; then
649 gs_wrt_message "$FILE does not match MD5SUMS value"
650 # Force generation of MD5SUM
651 HAVEMD5=0
652 fi
653
654 # Generate a fresh MD5SUM for this file
655 if [[ "$HAVEMD5" = "0" ]] ; then
656 echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
657 echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
658 fi
659
660 # Good or bad we write the original md5sum to a file
661 echo "$MD5" >> MD5SUMS
662
663 # Copy the freshly downloaded file
664 # to the source archive.
665 if [ ! -z ${SRC_ARCHIVE} ] &&
666 [ -d ${SRC_ARCHIVE} ] &&
667 [ -w ${SRC_ARCHIVE} ] &&
668 [ "$fromARCHIVE" = "0" ] ; then
669 echo "Storing file:<$FILE> in the package archive"
670 cp -f $FILE ${SRC_ARCHIVE}
671 fi
672
673 done
674
675 if [[ -s MISSING_FILES.DMP ]]; then
676 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"
677 # Do not allow the automatic execution of the Makefile.
678 echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
679 RUNMAKE="n"
680 fi
681}
682
683#----------------------------#
684create_urls() { #
685#----------------------------#
686 cd $JHALFSDIR
687
688 case ${PROGNAME} in
689 clfs)
690 echo -n "Creating CLFS <${ARCH}> specific URLs file"
691 xsltproc --nonet --xinclude \
692 --stringparam server $SERVER \
693 -o $BUILDDIR/sources/urls.lst urls.xsl \
694 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
695 echo " ...OK"
696 ;;
697 clfs2)
698 echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
699 xsltproc --nonet --xinclude \
700 --stringparam server $SERVER \
701 -o $BUILDDIR/sources/urls.lst urls.xsl \
702 $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
703 echo " ...OK"
704 ;;
705 hlfs)
706 echo -n "Creating HLFS <${MODEL}> specific URLs file"
707 xsltproc --nonet --xinclude \
708 --stringparam server $SERVER \
709 --stringparam model $MODEL \
710 -o $BUILDDIR/sources/urls.lst urls.xsl \
711 $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
712 echo " ...OK"
713 ;;
714 lfs)
715 echo -n "Creating LFS specific URLs file"
716 xsltproc --nonet --xinclude \
717 --stringparam server $SERVER \
718 -o ../sources/urls.lst urls.xsl \
719 $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
720 echo " ...OK"
721 ;;
722 esac
723
724 cd $BUILDDIR/sources
725
726 if [[ "${BLFS_TOOL}" = "y" ]]; then
727 add_blfs_deps_urls
728 fi
729
730}
731
732#----------------------------# Hardcoded URLs and MD5.
733add_blfs_deps_urls() { # No easy way to extract it.
734#----------------------------# Some FTP mirrors may not work
735
736 local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
737
738 if [[ "${DEP_LIBXML}" = "y" ]] ; then
739 echo "${LIBXML_URL} ${BLFS_SERVER}libxml2/${LIBXML_PKG} ${LIBXML_MD5}" >> urls.lst
740 fi
741
742 if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
743 echo "${LIBXSLT_URL} ${BLFS_SERVER}libxslt/${LIBXSLT_PKG} ${LIBXSLT_MD5}" >> urls.lst
744 fi
745
746 if [[ "${DEP_DBXSL}" = "y" ]] ; then
747 echo "${DBXSL_URL} ${BLFS_SERVER}docbook-xsl/${DBXSL_PKG} ${DBXSL_MD5}" >> urls.lst
748 fi
749
750 if [[ "${DEP_LINKS}" = "y" ]] ; then
751 echo "${LINKS_URL} ${BLFS_SERVER}links/${LINKS_PKG} ${LINKS_MD5}" >> urls.lst
752 fi
753
754 if [[ "${DEP_SUDO}" = "y" ]] ; then
755 echo "${SUDO_URL} ${BLFS_SERVER}sudo/${SUDO_PKG} ${SUDO_MD5}" >> urls.lst
756 echo "${SUDO_PATCH_URL} ${BLFS_SERVER}sudo/${SUDO_PATCH} ${SUDO_PATCH_MD5}" >> urls.lst
757 fi
758
759 if [[ "${DEP_WGET}" = "y" ]] ; then
760 echo "${WGET_URL} ${BLFS_SERVER}wget/${WGET_PKG} ${WGET_MD5}" >> urls.lst
761 fi
762
763 if [[ "${DEP_SVN}" = "y" ]] ; then
764 echo "${SVN_URL} ${BLFS_SERVER}subversion/${SVN_PKG} ${SVN_MD5}" >> urls.lst
765 fi
766
767 if [[ "${DEP_GPM}" = "y" ]] ; then
768 echo "${GPM_URL} ${BLFS_SERVER}gpm/${GPM_PKG} ${GPM_MD5}" >> urls.lst
769 echo "${GPM_PATCH_1_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_1} ${GPM_PATCH_1_MD5}" >> urls.lst
770 echo "${GPM_PATCH_2_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_2} ${GPM_PATCH_2_MD5}" >> urls.lst
771 fi
772
773}
774
775#----------------------------# Maybe there is a better way to do this, but this
776copy_blfs_deps_scripts() { # method avoid to place the test on all
777#----------------------------# $PROGNAME/master.sh scripts.
778
779 mkdir -p ${PROGNAME}-commands/blfs-tool-deps
780
781 if [[ "${DEP_LIBXML}" = "y" ]] ; then
782 mv blfs-tool-deps/901-libxml2 ${PROGNAME}-commands/blfs-tool-deps
783 fi
784
785 if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
786 mv blfs-tool-deps/902-libxslt ${PROGNAME}-commands/blfs-tool-deps
787 fi
788
789 if [[ "${DEP_DBXSL}" = "y" ]] ; then
790 mv blfs-tool-deps/903-docbook-xsl ${PROGNAME}-commands/blfs-tool-deps
791 fi
792
793 if [[ "${DEP_LINKS}" = "y" ]] ; then
794 mv blfs-tool-deps/905-links ${PROGNAME}-commands/blfs-tool-deps
795 fi
796
797 if [[ "${DEP_SUDO}" = "y" ]] ; then
798 mv blfs-tool-deps/906-sudo ${PROGNAME}-commands/blfs-tool-deps
799 fi
800
801 if [[ "${DEP_WGET}" = "y" ]] ; then
802 mv blfs-tool-deps/907-wget ${PROGNAME}-commands/blfs-tool-deps
803 fi
804
805 if [[ "${DEP_SVN}" = "y" ]] ; then
806 mv blfs-tool-deps/908-subversion ${PROGNAME}-commands/blfs-tool-deps
807 fi
808
809 if [[ "${DEP_GPM}" = "y" ]] ; then
810 mv blfs-tool-deps/904-gpm ${PROGNAME}-commands/blfs-tool-deps
811 fi
812
813 rm -rf blfs-tool-deps
814
815}
Note: See TracBrowser for help on using the repository browser.