source: common/common-functions@ 821a2c6

experimental
Last change on this file since 821a2c6 was 6aeb5b7, checked in by George Boudreau <georgeb@…>, 19 years ago

Added udev_update as valid book

  • Property mode set to 100644
File size: 23.1 KB
RevLine 
[0170229]1#!/bin/bash
2set +e
3
4# VT100 colors
5declare -r BLACK=$'\e[1;30m'
6declare -r DK_GRAY=$'\e[0;30m'
7
8declare -r RED=$'\e[31m'
9declare -r GREEN=$'\e[32m'
10declare -r YELLOW=$'\e[33m'
11declare -r BLUE=$'\e[34m'
12declare -r MAGENTA=$'\e[35m'
13declare -r CYAN=$'\e[36m'
14declare -r WHITE=$'\e[37m'
15
16declare -r OFF=$'\e[0m'
17declare -r BOLD=$'\e[1m'
18declare -r REVERSE=$'\e[7m'
19declare -r HIDDEN=$'\e[8m'
20
21declare -r tab_=$'\t'
22declare -r nl_=$'\n'
23
24declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
25declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
26declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
27
28# bold yellow > < pair
29declare -r R_arrow=$'\e[1;33m>\e[0m'
30declare -r L_arrow=$'\e[1;33m<\e[0m'
31
32
33
34usage() {
35 'clear'
36cat <<- -EOF-
37${DD_BORDER}
38${BOLD}
39 Usage: $0 ${BOLD}[OPTION]
40
41Options:
42${BOLD} -h, --help${OFF}
43 print this help, then exit
44${BOLD} --readme${OFF}
45 print a small readme file, then exit
46${BOLD} -V, --version${OFF}
47 print version number, then exit
48${BOLD} -d --directory DIR${OFF}
49 use DIR directory for building HLFS; all files jhahlfs produces will be
50 in the directory DIR/jhahlfs. Default is \"/mnt/lfs\".
51${BOLD} --rebuild${OFF}
52 clean the build directory before to perfom any other task. The directory
53 is cleaned only if it was populated by a previous jhahlfs run.
54${BOLD} -P, --get-packages${OFF}
55 download the packages and patches. This assumes that the server declared in the
56 jhahlfs.conf file has the proper packages and patches for the book version being
57 processed.
58${BOLD} -D, --download-client CLIENT
59 use CLIENT as the program for retrieving packages (use in conjunction with -P)
60${BOLD} -W, --working-copy DIR${OFF}
61 use the local working copy placed in DIR as the HLFS book
62${BOLD} -L, --HLFS-version VER${OFF}
63 checkout VER version of the HLFS book. Supported versions at this time are:
64 dev* | trunk | SVN aliases for Development HLFS
[6aeb5b7]65 alpha* aliases for the alphabetical branch
66 udev* aliases for the udev_update branch
[0170229]67${BOLD} --fstab FILE${OFF}
68 use FILE as the /etc/fstab file for the HLFS system. If not specified,
69 a default /etc/fstab file with dummy values is created.
70${BOLD} -C, --kernel-config FILE${OFF}
71 use the kernel configuration file specified in FILE to build the kernel.
72 if the file is not found, or if not specified, the kernel build is skipped.
73${BOLD} -M, --run-make${OFF}
74 run make on the generated Makefile
75${DD_BORDER}
76-EOF-
77 exit
78}
79
80
81blfs_usage() {
82 'clear'
83cat <<- -EOF-
84${DD_BORDER}
85${BOLD}
86 Usage: $0 ${BOLD}[OPTION]
87
88Options:
89${BOLD} -h, --help${OFF}
90 print this help, then exit
91
92${BOLD} -V, --version${OFF}
93 print version number, then exit
94
95${BOLD} -B, --BLFS-version VER${OFF}
96 checkout VER version of the BLFS book.
97 If not set, the development version is used.
98
99 Supported versions at this time are:
100 dev* | trunk | SVN aliases for Development BLFS
101
102${BOLD} -W, --working-copy DIR${OFF}
103 use the local working copy placed in DIR as the BLFS book
104
105${BOLD} -D, --dependencies TYPE${OFF}
106 add dependencies of type TYPE to the build tree.
107 If not set, both required a recommended are used.
108
109 Possible values are:
110
111 required only required dependecies are used
112 recommended both required a recommended dependencies are used
113 optional all dependencies are used
114
115${BOLD} -S, --server SERVER${OFF}
116 set the FTP/HTTP server used as fallback to download the packages.
117 If not specified, the one set in jhablfs.conf is used.
118
119${BOLD} -T, --testsuites${OFF}
120 add support to run the optional testsuites
121${DD_BORDER}
122-EOF-
123 exit
124}
125
126
127_inline_doc="
128 This script, ${PROGNAME}, strives to create an accurate makefile
129 directly from the xml files used to generate the Hardened Linux From
130 Scratch document.
131 The usage of this script assumes you have read and are familiar with
132 the book and therefore the configuration variables found in jhahlfs.conf
133 will have meaning to you. There are a limited number of command line
134 switches which, if used, will override the config file settings.
135
136 NOTES::
137 *. The resulting Makefile takes considerable time to run to completion,
138 lay in a supply of caffeine beverages.
139
140 *. It is recommended that you temporarily unpack your linux kernel and
141 run <make menuconfig> and configure the kernal as per the book and save
142 the resulting .config file.
143
144 *. Chapter07 contains numerous command files which require customizing
145 before you start console, profile, hosts, network, fstab, kernel.
146"
147
148version="
149${BOLD}\"${PROGNAME}\"${OFF} script module (development) \$Date$
150
151Written by Jeremy Huntwork,
152 Manuel Caneles Esparcia,
153 George Boudreau
154
155This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
156"
157
158
159no_empty_builddir() {
160 'clear'
161cat <<- -EOF-
162${DD_BORDER}
163
164${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
165 Looks like the \$BUILDDIR directory contains subdirectories
166 from a previous HLFS build.
167
168 Please format the partition mounted on \$BUILDDIR or set
169 a different build directory before running jhahlfs.
170${OFF}
171${DD_BORDER}
172-EOF-
173 exit
174}
175
176
177help="${nl_}Try '$0 --help' for more information."
178
179
180exit_missing_arg="\
181echo \"Option '\$1' requires an argument\" >&2
182echo \"\$help\" >&2
183exit 1"
184
185no_dl_client="\
186echo \"Could not find a way to download the CLFS sources.\" >&2
187echo \"Attempting to continue.\" >&2"
188
189HEADER="# This file is automatically generated by jhalfs
190# DO NOT EDIT THIS FILE MANUALLY
191#
192# Generated on `date \"+%F %X %Z\"`"
193
194
195
196
197
198#----------------------------------#
199wrt_target() { #
200#----------------------------------#
201 local i=$1
202 local PREV=$2
203(
204cat << EOF
205
206$i: $PREV
207 @\$(call echo_message, Building)
208EOF
209) >> $MKFILE.tmp
210}
211
212
213#----------------------------------#
214wrt_unpack() { #
215#----------------------------------#
216 local FILE=$1
217(
218cat << EOF
219 @\$(call unpack,$FILE)
220 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
221 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
222 chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
223EOF
224) >> $MKFILE.tmp
225}
226
227
228#=============================#
229wrt_unpack3() { # Unpack and set 'ROOT' var
230#=============================#
231 local FILE=$1
232(
233cat << EOF
234 @\$(call unpack3,$FILE)
235 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
236 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
237
238 chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
239EOF
240) >> $MKFILE.tmp
241}
242
243
244#----------------------------------#
245wrt_unpack2() { #
246#----------------------------------#
247 local FILE=$1
248(
249cat << EOF
250 @\$(call unpack2,$FILE)
251 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
252 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
253EOF
254) >> $MKFILE.tmp
255}
256
257
258#=============================#
259wrt_unpack4() { # Unpack and set 'ROOT' var
260#=============================#
261 local FILE=$1
262(
263cat << EOF
264 @\$(call unpack4,$FILE)
265 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
266 echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
267EOF
268) >> $MKFILE.tmp
269}
270
271
272
273#----------------------------------#
274wrt_target_vars() { # Target vars for hlfs (cross-build method)
275#----------------------------------#
276(
277cat << EOF
278 echo "export target=$(uname -m)-${TARGET}" >> envars && \\
279 echo "export ldso=/lib/${LOADER}" >> envars
280EOF
281) >> $MKFILE.tmp
282
283}
284
285
286#----------------------------------#
287wrt_run_as_su() { #
288#----------------------------------#
289 local this_script=$1
290 local file=$2
291(
292cat << EOF
293 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
294 su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
295 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
296EOF
297) >> $MKFILE.tmp
298}
299
300
301#==================================#
302wrt_run_as_lfs() { # header to log file, execute script, footer to log file
303#==================================#
304 local this_script=$1
305 local file=$2
306(
307cat << EOF
308 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
309 su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
310 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
311EOF
312) >> $MKFILE.tmp
313}
314
315
316#----------------------------------#
317wrt_run_as_root() { #
318#----------------------------------#
319 local this_script=$1
320 local file=$2
321(
322cat << EOF
323 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
324 export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
325 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
326EOF
327) >> $MKFILE.tmp
328}
329
330
331#=============================#
332wrt_run_as_root2() { # Some scripts must be run as root..
333#=============================#
334 local this_script=$1
335 local file=$2
336(
337cat << EOF
338 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\
339 source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
340 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script
341EOF
342) >> $MKFILE.tmp
343}
344
345
346#----------------------------------#
347wrt_remove_build_dirs() { #
348#----------------------------------#
349 local name=$1
350(
351cat << EOF
352 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
353 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
354 if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
355 rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
356 fi;
357EOF
358) >> $MKFILE.tmp
359}
360
361
362#----------------------------------#
363wrt_remove_build_dirs2() { #
364#----------------------------------#
365 local name=$1
366(
367cat << EOF
368 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
369 rm -r \$(SRC)/\$\$ROOT && \\
370 if [ -e \$(SRC)/$name-build ]; then \\
371 rm -r \$(SRC)/$name-build; \\
372 fi;
373EOF
374) >> $MKFILE.tmp
375}
376
377
378
379#----------------------------------#
380wrt_run_as_chroot1() { #
381#----------------------------------#
382 local this_script=$1
383 local file=$2
384(
385 cat << EOF
386 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
387 \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
388 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
389EOF
390) >> $MKFILE.tmp
391}
392
393
394#----------------------------------#
395wrt_run_as_chroot2() { #
396#----------------------------------#
397 local this_script=$1
398 local file=$2
399(
400cat << EOF
401 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
402 \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
403 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
404EOF
405) >> $MKFILE.tmp
406}
407
408
409#----------------------------------#
410wrt_copy_fstab() { #
411#----------------------------------#
412 local i=$1
413(
414 cat << EOF
415 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\
416 cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\
417 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i
418EOF
419) >> $MKFILE.tmp
420}
421
422#----------------------------------#
423wrt_copy_fstab2() { #
424#----------------------------------#
425 local i=$1
426(
427 cat << EOF
428 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\
429 cp -v $FSTAB /etc/fstab >>logs/$i 2>&1 && \\
430 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i
431EOF
432) >> $MKFILE.tmp
433}
434
435
436#----------------------------------#
437wrt_export_timezone() { #
438#----------------------------------#
439 echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp
440}
441
442
443#----------------------------------#
444wrt_export_pagesize() { #
445#----------------------------------#
446 echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp
447}
448
449
450#----------------------------------#
451wrt_export_pkgdir() { #
452#----------------------------------#
453(
454 cat << EOF
455 @echo "export PKGDIR=\$(SRC)/binutils-build" > envars
456EOF
457) >> $MKFILE.tmp
458}
459
460
461#----------------------------#
462run_make() {
463#----------------------------#
464 # Test if make must be run.
465 if [ "$RUNMAKE" = "1" ] ; then
466 # Test to make sure we're running the build as root
467 if [ "$UID" != "0" ] ; then
468 echo "You must be logged in as root to successfully build LFS."
469 exit 1
470 fi
471 # Build the system
472 if [ -e $MKFILE ] ; then
473 echo -ne "Building the LFS system...\n"
474 cd $JHALFSDIR && make -f ${PROGNAME}-Makefile
475 echo -ne "done\n"
476 fi
477 fi
478}
479
480
481#----------------------------#
482clean_builddir() {
483#----------------------------#
484 # Test if the clean must be done.
485 if [ "$CLEAN" = "1" ] ; then
486 # Test to make sure we're running the clean as root
487 if [ "$UID" != "0" ] ; then
488 echo "You must be logged in as root to clean the build directory."
489 exit 1
490 fi
491 # Test to make sure that the build directory was populated by jhalfs
492 if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
493 echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
494 exit 1
495 else
496 # Clean the build directory
497 echo -ne "Cleaning $BUILDDIR...\n"
498 rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
499 echo -ne "Cleaning $JHALFSDIR...\n"
500 rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
501 echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
502 rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
503 echo -ne "done\n"
504 fi
505 fi
506}
507
508#----------------------------#
509get_book() {
510#----------------------------#
511 cd $JHALFSDIR
512
513 if [ -z $WC ] ; then
514 # Check for Subversion instead of just letting the script hit 'svn' and fail.
515 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
516 exit 1"
517 echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
518
519 case $PROGNAME in
520 lfs) svn_root="LFS" ;;
521 hlfs) svn_root="HLFS" ;;
522 clfs) svn_root="cross-lfs" ;;
523 blfs) svn_root="BLFS" ;;
524 *) echo "BOOK not defined in function <get_book>"
525 exit 1 ;;
526 esac
527 # Grab a fresh LFS book if it's missing, otherwise, update it from the
528 # repo. If we've already extracted the commands, move on to getting the
529 # sources.
530 if [ -d ${PROGNAME}-$LFSVRS ] ; then
531 cd ${PROGNAME}-$LFSVRS
532 if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
533 test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
534 echo -ne "done\n"
535 # Set the canonical book version
536 cd $JHALFSDIR
537 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
538 get_sources
539 else
540 echo -ne "done\n"
541 # Set the canonical book version
542 cd $JHALFSDIR
543 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
544 extract_commands
545 fi
546 else
547 case $LFSVRS in
548 development)
549 svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
550 alphabetical)
551 svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
[6aeb5b7]552 udev_update)
553 svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
[0170229]554 esac
555 echo -ne "done\n"
556 # Set the canonical book version
557 cd $JHALFSDIR
558 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
559 extract_commands
560 fi
561 else
562 echo -ne "Using $BOOK as book's sources ...\n"
563 # Set the canonical book version
564 cd $JHALFSDIR
565 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
566 extract_commands
567 fi
568}
569
570
571#----------------------------#
572build_patches_file() { # Supply a suitably formated list of patches.
573#----------------------------#
[bef0a98]574 local IFS
575 echo -ne "Creating the patch file list "
[0170229]576
577 LOC_add_patches_entry() {
578 for f in `grep "/$1-" patcheslist_.wget`; do
579 basename $f | sed "s|${2}|\&${1}-version;|" >> patches
580 done
581 }
582
583 xsltproc --nonet \
584 --xinclude \
585 -o patcheslist_.wget \
[bef0a98]586 patcheslist.xsl \
587 $BOOK/index.xml
588 #> /dev/null 2>&1
[0170229]589
590 rm -f patches
591
592 IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
593 for f in `cat packages`; do
594 LOC_add_patches_entry \
595 `echo $f | sed -e 's/-version//' \
596 -e 's/-file.*//' \
597 -e 's/"//g' \
598 -e 's/uclibc/uClibc/'`
599 done
600
601 # .... U G L Y .... what to do with the grsecurity patch to the kernel..
602 for f in `grep "/grsecurity-" patcheslist_.wget`; do
603 basename $f >> patches
604 done
605
606 rm -f patcheslist_.wget
[bef0a98]607 echo "...OK"
[0170229]608}
609
610
611
612#----------------------------#
613extract_commands() { #
614#----------------------------#
615 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
616 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
617 exit 1"
618
619 cd $JHALFSDIR
620 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
621
622 # Start clean
623 if [ -d commands ]; then
624 rm -rf commands
625 mkdir -v commands
626 fi
[bef0a98]627 echo -n "Extracting commands for"
[0170229]628
629 # Dump the commands in shell script form from the HLFS book.
630 case ${PROGNAME} in
631 clfs)
[bef0a98]632 echo -n "${tab_} ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
[0170229]633 xsltproc --xinclude \
634 --nonet \
635 --output ./${PROGNAME}-commands/ \
636 $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml
637 ;;
638 hlfs)
[bef0a98]639 echo -n "${tab_} ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS architecture"
[0170229]640 xsltproc --nonet \
641 --xinclude \
642 --stringparam model $MODEL \
643 --stringparam testsuite $TEST \
[bef0a98]644 --stringparam testchaintest 0 \
[0170229]645 --stringparam vim-lang $VIMLANG \
646 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
647 ;;
648 lfs)
[bef0a98]649 echo -n "${tab_} ${L_arrow}${BOLD}LFS${R_arrow} build"
[0170229]650 xsltproc --nonet \
651 --xinclude \
652 --stringparam testsuite $TEST \
653 --stringparam vim-lang $VIMLANG \
654 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
655 ;;
656 blfs)
[bef0a98]657 echo -n "${tab_} ${L_arrow}${BOLD}BLFS${R_arrow} build"
[0170229]658 xsltproc --nonet \
659 --xinclude \
660 --stringparam testsuite $TEST \
661 --stringparam server $SERVER \
662 -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
663 ;;
664 *) exit 1
665 esac
666
[bef0a98]667 echo " ...OK"
[0170229]668
669 # Make the scripts executable.
670 chmod -R +x $JHALFSDIR/${PROGNAME}-commands
671
672 # Grab the patches and package names.
673 cd $JHALFSDIR
674 for i in patches packages ; do rm -f $i ; done
675 grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
676 -e '/generic/d' >> packages
677
678 # Download the vim-lang package if it must be installed
679 if [ "$VIMLANG" = "1" ] ; then
680 echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
681 fi
682 echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
683
684 # There is no HLFS patches.ent file so we will create one.
685
686 case "${PROGNAME}" in
687 hlfs) build_patches_file ;;
688 clfs) ;;
689 lfs) ;;
690 blfs) ;;
691 *) exit 1
692 esac
693
694 # Done. Moving on...
695 get_sources
696}
697
698
699#----------------------------#
700download() { # Download file, write name to MISSING_FILES.DMP if an error
701#----------------------------#
702 cd $BUILDDIR/sources
703
[12a5707]704 # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
705 # that don't conform to norms in the URL scheme.
[0170229]706 DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
707
708 # Find the md5 sum for this package.
709 if [ $2 != MD5SUMS ] ; then
710 set +e
711 MD5=`grep " $2" MD5SUMS`
712 if [ $? -ne 0 ]; then
713 set -e
714 echo "${RED}$2 not found in MD5SUMS${OFF}"
715 echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
716 return
717 fi
718 set -e
719 fi
720
721 if [ ! -f $2 ] ; then
722 case $DL in
[12a5707]723 wget ) wget --passive $FTP/$DIR/$2 ;;
724 curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
[0170229]725 * ) echo "$DL not supported at this time." ;;
726 esac
727 elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
728 case $DL in
[12a5707]729 wget ) wget --passive -c $FTP/$DIR/$2 ;;
730 curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
[0170229]731 * ) echo "$DL not supported at this time." ;;
732 esac
733 fi
734
735 if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
736 exit 1
737 fi
738 if [ $2 != MD5SUMS ] ; then
739 echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
740 fi
741}
742
743
744#----------------------------#
745get_sources() {
746#----------------------------#
747
748 # Test if the packages must be downloaded
749 if [ "$HPKG" = "1" ] ; then
750
751 # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
752 # separates each iteration by lines. It is necessary to have the second
753 # ' on the next line.
754 IFS='
755'
756
757 if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
758 cd $BUILDDIR/sources
759 if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
760 if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
761
762 download "" MD5SUMS
763
764 # Iterate through each package and grab it, along with any patches it needs.
765 for i in `cat $JHALFSDIR/packages` ; do
766 PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
767
768 # There are some entities that aren't valid packages.
[12a5707]769 if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
[0170229]770
771 VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
772 case $PKG in
773 tcl) FILE="$PKG$VRS-src.tar.bz2" ;;
774 vim-lang) PKG="vim"
775 FILE="vim-$VRS-lang.tar.bz2" ;;
776 udev-config) PKG="udev"
777 FILE="$VRS" ;;
778 *) FILE="$PKG-$VRS.tar.bz2" ;;
779 esac
780 download $PKG $FILE
781
782 # Download any associated patches
783 for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
784 PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
785 download $PKG $PATCH
786 done
787 done
788 fi
789}
790
791#-----------------------------------------------#
792_IS_() # Function to test build scripts names
793#-----------------------------------------------#
794{
795 # Returns substr $2 or null str
796 # Must use string testing
797 case $1 in
798 *$2*) echo "$2" ;;
799 *) echo "" ;;
800 esac
801}
Note: See TracBrowser for help on using the repository browser.