source: common/common-functions@ f7590ba

experimental
Last change on this file since f7590ba was 67e3bc3, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Small text fixes.
Placing authors in alphabetical order.

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