source: common/common-functions@ a6b81cd

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

Added missing glibc-libidn package in LFS.
The udev-config file is used only in LFS.

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