source: common/common-functions@ 582feec

experimental
Last change on this file since 582feec was d540567, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Handled and via XSL.
Fixed the chapter05 GCC installation test run.
Fixed blfs-bootscripts installation.
The build_Makefile code need be adapted to that new XSL code.

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