source: common/common-functions@ d057075

experimental
Last change on this file since d057075 was 6608a67, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Fixed version for experimental code.

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