source: jhalfs@ 4e9a3b3

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 4e9a3b3 was 4e9a3b3, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added support for the Module-init-tools-testsuite package.

  • Property mode set to 100755
File size: 26.2 KB
Line 
1#!/bin/sh
2
3#
4# Load the configuration file
5#
6source jhalfs.conf
7
8
9version="
10jhalfs development \$Date$
11
12Written by Jeremy Huntwork and Manuel Canales Esparcia.
13
14This program is published under the \
15Gnu General Public License, Version 2.
16"
17
18usage="\
19Usage: $0 [OPTION]
20
21Options:
22 -h, --help print this help, then exit
23
24 -V, --version print version number, then exit
25
26 -d --directory DIR use DIR directory for building LFS; all files
27 jhalfs produces will be in the directory
28 DIR/jhalfs. Default is \"/mnt/lfs\".
29
30 -P, --get-packages download the packages and patches. This
31 assumes that the server declared in the
32 jhalfs.conf file has the proper packages
33 and patches for the book version being
34 processed.
35
36 -D, --download-client CLIENT use CLIENT as the program for retrieving
37 packages (for use in conjunction with -P)
38
39 -W, --working-copy DIR use the local working copy placed in DIR
40 as the LFS book
41
42 -L, --LFS-version VER checkout VER version of the LFS book.
43 Supported versions at this time are:
44
45 dev* | trunk | SVN aliases for Development LFS
46 testing | 6.1.1 aliases for the testing 6.1.1 branch
47
48 -T, --testsuites add support to run the optional testsuites
49
50 --no-toolchain-test don't run the toolchain testsuites. This
51 also disables the build of TCL, Expect
52 and DejaGNU
53
54 --timezone TIMEZONE set TIMEZONE as the local timezone. If not
55 specified, \"Europe/London\" will be used.
56
57 --page_size PAGE set PAGE as the default page size (letter
58 or A4). This setting is required to
59 build Groff. If not specified, \"letter\"
60 will be used.
61
62 --fstab FILE use FILE as the /etc/fstab file for the
63 LFS system. If not specified, a default
64 /etc/fstab file with dummy values is
65 created.
66
67 -C, --kernel-config FILE use the kernel configuration file specified
68 in FILE to build the kernel. If the file is
69 not found, or if not specified, the kernel
70 build is skipped.
71
72 -M, --run-make run make on the generated Makefile
73
74"
75
76help="\
77Try '$0 --help' for more information."
78
79exit_missing_arg="\
80echo \"Option '\$1' requires an argument\" >&2
81echo \"\$help\" >&2
82exit 1"
83
84no_dl_client="\
85echo \"Could not find a way to download the LFS sources.\" >&2
86echo \"Attempting to continue.\" >&2"
87
88
89HEADER="# This file is automatically generated by jhalfs
90# DO NOT EDIT THIS FILE MANUALLY
91#
92# Generated on `date \"+%F %X %Z\"`"
93
94
95###################################
96### FUNCTIONS ###
97###################################
98
99
100#----------------------------#
101get_book() {
102#----------------------------#
103 # Check for Subversion instead of just letting the script hit 'svn' and fail.
104 test `type -p svn` || eval "echo \"This feature requires Subversion.\"
105 exit 1"
106 cd $JHALFSDIR
107
108 # Test to make sure the LFS version is set
109 if [ -z $LFSVRS ] ; then LFSVRS=development ; fi
110
111 # Set the book's sources directory
112 if [ -z $BOOK ] ; then BOOK=lfs-$LFSVRS ; fi
113
114 if [ -z $WC ] ; then
115 echo -n "Downloading the LFS Book, version $LFSVRS... "
116
117 # Grab the LFS book fresh if it's missing, otherwise, update it from the
118 # repo. If we've already extracted the commands, move on to getting the
119 # sources.
120 if [ -d lfs-$LFSVRS ] ; then
121 cd lfs-$LFSVRS
122 if svn up | grep -q At && test -d $JHALFSDIR/commands && \
123 test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
124 echo -ne "done\n"
125 get_sources
126 else
127 echo -ne "done\n"
128 extract_commands
129 fi
130 else
131 if [ $LFSVRS = development ] ; then
132 svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1
133 else
134 svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1
135 fi
136 echo -ne "done\n"
137 extract_commands
138 fi
139 else
140 echo -ne "Using $BOOK as book's sources ...\n"
141 extract_commands
142 fi
143 # Set the canonical book version
144 cd $JHALFSDIR
145 VERSION=`grep "ENTITY version " $BOOK/general.ent | sed -e 's@<!ENTITY version "@@' -e 's@">@@'`
146}
147
148#----------------------------#
149extract_commands() {
150#----------------------------#
151 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
152 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
153 exit 1"
154 cd $JHALFSDIR
155
156 # Start clean
157 if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
158 echo -n "Extracting commands... "
159
160 # Dump the commands in shell script form from the LFS book.
161 xsltproc --nonet --xinclude --stringparam testsuite $TEST \
162 --stringparam toolchaintest $TOOLCHAINTEST -o ./commands/ \
163 $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
164
165 # Make the scripts executable.
166 chmod -R +x $JHALFSDIR/commands
167
168 # Grab the patches and package names.
169 cd $JHALFSDIR
170 for i in patches packages ; do rm -f $i ; done
171 grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
172 -e '/generic/d' >> packages
173 echo `grep "glibc" packages | sed 's@glibc@&-linuxthreads@'` >> packages
174 echo `grep "module" packages | sed 's@tools@&-testsuite@'` >> packages
175 echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
176 # If we are buildind the UTF-8 branch, the glibc-libidn package is required
177 if grep -q "man-db-version" $BOOK/general.ent ; then
178 echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
179 fi
180 grep "ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
181
182 # Done. Moving on...
183 echo -ne "done\n"
184 get_sources
185}
186
187#----------------------------#
188download() {
189#----------------------------#
190 cd $BUILDDIR/sources
191
192 # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} and
193 # module-init-tools-testsuite packages that doesn't conform to
194 # norms in the URL scheme.
195 DIR=`echo $1 | sed 's@-doc@@';'s@-linuxthreads@@';'s@-libidn@@';'s@-testsuite@@'`
196
197 # Find the md5 sum for this package.
198 if [ $2 != MD5SUMS ] ; then MD5=`grep " $2" MD5SUMS` ; fi
199
200 if [ ! -f $2 ] ; then
201 case $DL in
202 wget )
203 wget $HTTP/$DIR/$2
204 ;;
205 curl )
206 `curl -# $HTTP/$DIR/$2 -o $2`
207 ;;
208 * )
209 echo "$DL not supported at this time."
210 ;;
211 esac
212 elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
213 case $DL in
214 wget )
215 wget -c $HTTP/$DIR/$2
216 ;;
217 curl )
218 `curl -# -C - $HTTP/$DIR/$2 -o $2`
219 ;;
220 * )
221 echo "$DL not supported at this time."
222 ;;
223 esac
224 fi
225 if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
226 exit 1
227 fi
228}
229
230#----------------------------#
231get_sources() {
232#----------------------------#
233
234 # Test if the packages must be downloaded
235 if [ "$HPKG" = "1" ] ; then
236
237 # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
238 # separates each iteration by lines. It is necessary to have the second
239 # ' on the next line.
240 IFS='
241'
242
243 if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
244 cd $BUILDDIR/sources
245 if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
246
247 download "" MD5SUMS
248
249 # Iterate through each package and grab it, along with any patches it needs.
250 for i in `cat $JHALFSDIR/packages` ; do
251 PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
252 # Needed for Groff patchlevel patch on UTF-8 branch
253 GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
254
255 # There is some entities that aren't valid package entities.
256 if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" -o "$PKG" = "groff-patchlevel" ] ; then continue ; fi
257
258 VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
259 if [ "$PKG" = "tcl" ] ; then
260 FILE="$PKG$VRS-src.tar.bz2"
261 elif [ "$PKG" = "udev-config" ] ; then
262 PKG="udev"
263 FILE="$VRS"
264 else
265 FILE="$PKG-$VRS.tar.bz2"
266 fi
267 download $PKG $FILE
268 for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
269 PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
270 download $PKG $PATCH
271 done
272 # Needed for Groff patchlevel patch on UTF-8 branch
273 for patch in `grep "patchlevel" $JHALFSDIR/patches` ; do
274 PATCH=`echo $patch | sed 's@&'$PKG'-version;-&'$PKG'-patchlevel;@'$VRS'-'$GROFFLEVEL'@'`
275 download $PKG $PATCH
276 done
277 done
278 fi
279}
280
281#-----------------------------------------------#
282_IS_() # Function to test build scripts names
283#-----------------------------------------------#
284{
285 # Returns substr $2 or null str
286 # Must use string testing
287 case $1 in
288 *$2*) echo "$2" ;;
289 *) echo "" ;;
290 esac
291}
292
293#----------------------------#
294chapter4_Makefiles() {
295#----------------------------#
296(
297 cat << EOF
298020-creatingtoolsdir:
299 @\$(call echo_message, Building)
300 @mkdir -v \$(LFS)/tools && \\
301 ln -sv \$(LFS)/tools / && \\
302 touch \$@
303
304021-addinguser: 020-creatingtoolsdir
305 @\$(call echo_message, Building)
306 @groupadd lfs && \\
307 useradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\
308 chown lfs \$(LFS)/tools && \\
309 chown lfs \$(LFS)/sources && \\
310 touch \$@
311
312022-settingenvironment: 021-addinguser
313 @\$(call echo_message, Building)
314 @echo "set +h" > /home/lfs/.bashrc && \\
315 echo "umask 022" >> /home/lfs/.bashrc && \\
316 echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
317 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
318 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
319 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
320 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
321 chown lfs:lfs /home/lfs/.bashrc && \\
322 touch envars && \\
323 touch \$@
324EOF
325) >> $MKFILE.tmp
326}
327
328#----------------------------#
329chapter5_Makefiles() {
330#----------------------------#
331 for file in chapter05/* ; do
332 # Keep the script file name
333 i=`basename $file`
334
335 # If no testsuites will be run, then TCL, Expect and DejaGNU isn't needed
336 if [ "$TOOLCHAINTEST" = "0" ]; then
337 if [[ `_IS_ $i tcl` ]] || [[ `_IS_ $i expect` ]] || [[ `_IS_ $i dejagnu` ]] ; then
338 continue
339 fi
340 fi
341
342 # First append each name of the script files to a list (this will become
343 # the names of the targets in the Makefile
344 chapter5="$chapter5 $i"
345
346 # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
347 # and binutils in chapter 5)
348 name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
349
350 # Set the dependency for the first target.
351 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
352
353 # Drop in the name of the target on a new line, and the previous target
354 # as a dependency. Also call the echo_message function.
355(
356 cat << EOF
357
358$i: $PREV
359 @\$(call echo_message, Building)
360EOF
361) >> $MKFILE.tmp
362
363 # Find the version of the command files, if it corresponds with the building of
364 # a specific package
365 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
366
367 # If $vrs isn't empty, we've got a package...
368 if [ "$vrs" != "" ] ; then
369 if [ "$name" = "tcl" ] ; then
370 FILE="$name$vrs-src.tar"
371 else
372 FILE="$name-$vrs.tar"
373 fi
374
375 # Insert instructions for unpacking the package and to set
376 # the PKGDIR variable.
377(
378 cat << EOF
379 @\$(call unpack,$FILE)
380 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
381 chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
382 echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
383 echo "export PKGDIR" >> envars && \\
384EOF
385) >> $MKFILE.tmp
386
387 fi
388
389 # Dump the path to the Binutils or TCL sources directory.
390 if [[ `_IS_ $i binutils` ]] || [[ `_IS_ $i tcl` ]] ; then
391(
392 cat << EOF
393 echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir
394EOF
395) >> $MKFILE.tmp
396
397 # For the Adjusting phase we must to cd to the binutils-build directory.
398 elif [[ `_IS_ $i adjusting` ]] ; then
399(
400 cat << EOF
401 @echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\
402 echo "export PKGDIR" >> envars
403EOF
404) >> $MKFILE.tmp
405
406 # For the Expect build we need to set the TCLPATH envar.
407 elif [[ `_IS_ $i expect` ]] ; then
408(
409 cat << EOF
410 echo "TCLPATH=\`cat sources-dir\`" >> envars && \\
411 echo "export TCLPATH" >> envars
412EOF
413) >> $MKFILE.tmp
414
415 # Everything else, add a true statment so we don't confuse make
416 else
417(
418 cat << EOF
419 true
420EOF
421) >> $MKFILE.tmp
422 fi
423
424 # Insert date and disk usage at the top of the log file, the script run
425 # and date and disk usage again at the bottom of the log file.
426(
427 cat << EOF
428 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
429 su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
430 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
431EOF
432) >> $MKFILE.tmp
433
434 # Remove the build directory(ies) except if the package build fails
435 # (to can review config.cache, config.log, and like.)
436 # For Binutils and TCL the sources must be retained some time.
437 if [ "$vrs" != "" ] ; then
438 if [[ ! `_IS_ $i binutils` ]] && [[ ! `_IS_ $i tcl` ]] ; then
439(
440 cat << EOF
441 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
442 rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
443 if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
444 rm -r \$(LFS)\$(SRC)/$name-build; \\
445 fi;
446EOF
447) >> $MKFILE.tmp
448 fi
449 fi
450
451 # Remove the Binutils pass 1 sources after a successful Adjusting phase.
452 if [[ `_IS_ $i adjusting` ]] ; then
453(
454 cat << EOF
455 @rm -r \`cat sources-dir\` && \\
456 rm -r \$(LFS)\$(SRC)/binutils-build && \\
457 rm sources-dir
458EOF
459) >> $MKFILE.tmp
460 fi
461
462 # Remove the TCL sources after a successful Expect build.
463 if [[ `_IS_ $i expect` ]] ; then
464(
465 cat << EOF
466 @rm -r \`cat sources-dir\` && \\
467 rm sources-dir
468EOF
469) >> $MKFILE.tmp
470 fi
471
472 # Include a touch of the target name so make can check
473 # if it's already been made.
474(
475 cat << EOF
476 @touch \$@
477EOF
478) >> $MKFILE.tmp
479
480 # Keep the script file name for Makefile dependencies.
481 PREV=$i
482 done # end for file in chapter05/*
483}
484
485#----------------------------#
486chapter6_Makefiles() {
487#----------------------------#
488 for file in chapter06/* ; do
489 # Keep the script file name
490 i=`basename $file`
491
492 # We'll run the chroot commands differently than the others, so skip them in the
493 # dependencies and target creation.
494 if [[ `_IS_ $i chroot` ]] ; then
495 continue
496 fi
497
498 # First append each name of the script files to a list (this will become
499 # the names of the targets in the Makefile
500 chapter6="$chapter6 $i"
501
502 # Grab the name of the target
503 name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
504
505 # Drop in the name of the target on a new line, and the previous target
506 # as a dependency. Also call the echo_message function.
507(
508 cat << EOF
509
510$i: $PREV
511 @\$(call echo_message, Building)
512EOF
513) >> $MKFILE.tmp
514
515 # Find the version of the command files, if it corresponds with the building of
516 # a specific package
517 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
518
519 # If $vrs isn't empty, we've got a package...
520 # Insert instructions for unpacking the package and changing directories
521 if [ "$vrs" != "" ] ; then
522 FILE="$name-$vrs.tar.*"
523(
524 cat << EOF
525 @\$(call unpack2,$FILE)
526 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
527 echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
528 echo "export PKGDIR" >> envars
529EOF
530) >> $MKFILE.tmp
531 fi
532
533 # For the Re-Adjusting phase we must to cd to the binutils-build directory.
534 if [[ `_IS_ $i readjusting` ]] ; then
535(
536 cat << EOF
537 @echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\
538 echo "export PKGDIR" >> envars
539EOF
540) >> $MKFILE.tmp
541
542 # For Glibc we need to set TIMEZONE envar.
543 elif [[ `_IS_ $i glibc` ]] ; then
544(
545 cat << EOF
546 @echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
547 echo "export TIMEZONE" >> envars
548EOF
549) >> $MKFILE.tmp
550
551 # For Groff we need to set PAGE envar.
552 elif [[ `_IS_ $i groff` ]] ; then
553(
554 cat << EOF
555 @echo "PAGE=\$(PAGE)" >> envars && \\
556 echo "export PAGE" >> envars
557EOF
558) >> $MKFILE.tmp
559 fi
560
561 # In the mount of kernel filesystems we need to set LFS
562 # and not to use chroot.
563 if [[ `_IS_ $i kernfs` ]] ; then
564(
565 cat << EOF
566 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
567 export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
568 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
569EOF
570) >> $MKFILE.tmp
571
572 # The rest of Chapter06
573 else
574(
575 cat << EOF
576 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
577 \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
578 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
579EOF
580) >> $MKFILE.tmp
581 fi
582
583 # Remove the build directory(ies) except if the package build fails.
584 if [ "$vrs" != "" ] ; then
585(
586 cat << EOF
587 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
588 rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
589 if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
590 rm -r \$(LFS)\$(SRC)/$name-build; \\
591 fi;
592EOF
593) >> $MKFILE.tmp
594 fi
595
596 # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
597 if [[ `_IS_ $i readjusting` ]] ; then
598(
599 cat << EOF
600 @rm -r \`cat sources-dir\` && \\
601 rm -r \$(LFS)\$(SRC)/binutils-build && \\
602 rm sources-dir
603EOF
604) >> $MKFILE.tmp
605 fi
606
607 # Include a touch of the target name so make can check
608 # if it's already been made.
609(
610 cat << EOF
611 @touch \$@
612EOF
613) >> $MKFILE.tmp
614
615 # Keep the script file name for Makefile dependencies.
616 PREV=$i
617 done # end for file in chapter06/*
618}
619
620#----------------------------#
621chapter789_Makefiles() {
622#----------------------------#
623 for file in chapter0{7,8,9}/* ; do
624 # Keep the script file name
625 i=`basename $file`
626
627 # Grub must be configured manually.
628 # The filesystems can't be unmounted via Makefile and the user
629 # should to enter to the chroot environment to create the root
630 # password, edit several files and setup Grub,
631 if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
632 continue
633 fi
634
635 # If no .config file is supplied, the kernel build is skipped
636 if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
637 continue
638 fi
639
640 # First append each name of the script files to a list (this will become
641 # the names of the targets in the Makefile
642 chapter789="$chapter789 $i"
643
644 # Drop in the name of the target on a new line, and the previous target
645 # as a dependency. Also call the echo_message function.
646(
647 cat << EOF
648
649$i: $PREV
650 @\$(call echo_message, Building)
651EOF
652) >> $MKFILE.tmp
653
654 # Find the the bootscripts and kernel package names
655 if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
656 if [[ `_IS_ $i bootscripts` ]] ; then
657 vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
658 FILE="lfs-bootscripts-$vrs.tar.*"
659 elif [[ `_IS_ $i kernel` ]] ; then
660 vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
661 FILE="linux-$vrs.tar.*"
662 fi
663(
664 cat << EOF
665 @\$(call unpack2,$FILE)
666 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
667 echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
668 echo "export PKGDIR" >> envars
669EOF
670) >> $MKFILE.tmp
671 fi
672
673 # Put in place the kernel .config file
674 if [[ `_IS_ $i kernel` ]] ; then
675(
676 cat << EOF
677 @cp $CONFIG \$(LFS)/sources/kernel-config
678EOF
679) >> $MKFILE.tmp
680 fi
681
682 # Check if we have a real /etc/fstab file
683 if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
684(
685 cat << EOF
686 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
687 cp -v $FSTAB \$(LFS)/etc/fstab >>logs/$i 2>&1 && \\
688 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
689EOF
690) >> $MKFILE.tmp
691 else
692 # Initialize the log an run the script
693(
694 cat << EOF
695 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
696 \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
697 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
698EOF
699) >> $MKFILE.tmp
700 fi
701
702 # Remove the build directory except if the package build fails.
703 if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
704(
705 cat << EOF
706 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
707 rm -r \$(LFS)\$(SRC)/\$\$ROOT
708EOF
709) >> $MKFILE.tmp
710 fi
711
712 # Include a touch of the target name so make can check
713 # if it's already been made.
714(
715 cat << EOF
716 @touch \$@
717EOF
718) >> $MKFILE.tmp
719
720 # Keep the script file name for Makefile dependencies.
721 PREV=$i
722 done # for file in chapter0{7,8,9}/*
723}
724
725
726#----------------------------#
727build_Makefile() {
728#----------------------------#
729 echo -n "Creating Makefile... "
730 cd $JHALFSDIR/commands
731
732 # Start with a clean Makefile.tmp file
733 >$MKFILE.tmp
734
735 chapter4_Makefiles
736 chapter5_Makefiles
737 chapter6_Makefiles
738 chapter789_Makefiles
739
740
741 # Add a header, some variables and include the function file
742 # to the top of the real Makefile.
743(
744 cat << EOF
745$HEADER
746
747SRC= /sources
748LFS= $BUILDDIR
749PAGE= $PAGE
750TIMEZONE= $TIMEZONE
751
752include functions
753
754EOF
755) > $MKFILE
756
757
758 # Add chroot commands
759 i=1
760 for file in chapter06/*chroot* ; do
761 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
762 -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
763 -e 's|"$$LFS"|$(LFS)|' -e 's|set -e||'`
764 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
765 i=`expr $i + 1`
766 done
767
768 # Drop in the main target 'all:' and the chapter targets with each sub-target
769 # as a dependency.
770(
771 cat << EOF
772all: chapter4 chapter5 chapter6 chapter789
773 @\$(call echo_finished,$VERSION)
774
775chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
776
777chapter5: chapter4 $chapter5
778
779chapter6: chapter5 $chapter6
780
781chapter789: chapter6 $chapter789
782
783clean-all: clean
784 rm -rf ./*
785
786clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
787
788clean-chapter4:
789 -userdel lfs
790 rm -rf /home/lfs
791 rm -rf \$(LFS)/tools
792 rm -f /tools
793 rm -f envars
794 rm -f 02* logs/02*.log
795
796clean-chapter5:
797 rm -rf \$(LFS)/tools/*
798 rm -f $chapter5
799 cd logs && rm -f $chapter5 && cd ..
800
801clean-chapter6:
802 -umount \$(LFS)/sys
803 -umount \$(LFS)/proc
804 -umount \$(LFS)/dev/shm
805 -umount \$(LFS)/dev/pts
806 -umount \$(LFS)/dev
807 rm -rf \$(LFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
808 rm -f $chapter6
809 cd logs && rm -f $chapter6 && cd ..
810
811clean-chapter789:
812 rm -f $chapter789
813 cd logs && rm -f $chapter789 && cd ..
814
815
816EOF
817) >> $MKFILE
818
819 # Bring over the items from the Makefile.tmp
820 cat $MKFILE.tmp >> $MKFILE
821 rm $MKFILE.tmp
822 echo -ne "done\n"
823}
824
825#----------------------------#
826run_make() {
827#----------------------------#
828 # Test if make must be run.
829 if [ "$RUNMAKE" = "1" ] ; then
830 # Test to make sure we're running the build as root
831 if [ "$UID" != "0" ] ; then
832 echo "You must be logged in as root to successfully build LFS."
833 exit 1
834 fi
835 # Build the system
836 if [ -e $MKFILE ] ; then
837 echo -ne "Building the LFS system...\n"
838 cd $JHALFSDIR && make
839 echo -ne "done\n"
840 fi
841 fi
842}
843
844
845
846###################################
847### MAIN ###
848###################################
849
850# Evaluate any command line switches
851
852while test $# -gt 0 ; do
853 case $1 in
854 --version | -V )
855 echo "$version"
856 exit 0
857 ;;
858
859 --help | -h )
860 echo "$usage"
861 exit 0
862 ;;
863
864 --LFS-version | -L )
865 test $# = 1 && eval "$exit_missing_arg"
866 shift
867 case $1 in
868 dev* | SVN | trunk )
869 LFSVRS=development
870 ;;
871 testing | 6.1.1 )
872 LFSVRS=6.1.1
873 ;;
874 * )
875 echo "$1 is an unsupported version at this time."
876 exit 1
877 ;;
878 esac
879 ;;
880
881 --directory | -d )
882 test $# = 1 && eval "$exit_missing_arg"
883 shift
884 BUILDDIR=$1
885 ;;
886
887 --download-client | -D )
888 test $# = 1 && eval "$exit_missing_arg"
889 shift
890 DL=$1
891 ;;
892
893 --working-copy | -W )
894 test $# = 1 && eval "$exit_missing_arg"
895 shift
896 if [ -f $1/patches.ent ] ; then
897 WC=1
898 BOOK=$1
899 else
900 echo -e "\nLook like $1 isn't a supported working copy."
901 echo -e "Verify your selection and the command line.\n"
902 exit 1
903 fi
904 ;;
905
906 --testsuites | -T ) TEST=1 ;;
907
908 --get-packages | -P ) HPKG=1 ;;
909
910 --run-make | -M ) RUNMAKE=1 ;;
911
912 --no-toolchain-test ) TOOLCHAINTEST=0 ;;
913
914 --page_size )
915 test $# = 1 && eval "$exit_missing_arg"
916 shift
917 case $1 in
918 letter | A4 )
919 PAGE=$1
920 ;;
921 * )
922 echo "$1 isn't a supported page size."
923 exit 1
924 ;;
925 esac
926 ;;
927
928
929 --timezone )
930 test $# = 1 && eval "$exit_missing_arg"
931 shift
932 if [ -f /usr/share/zoneinfo/$1 ] ; then
933 TIMEZONE=$1
934 else
935 echo -e "\nLook like $1 isn't a valid timezone description."
936 echo -e "Verify your selection and the command line.\n"
937 exit 1
938 fi
939 ;;
940
941 --fstab )
942 test $# = 1 && eval "$exit_missing_arg"
943 shift
944 if [ -f $1 ] ; then
945 FSTAB=$1
946 else
947 echo -e "\nFile $1 not found. Verify your command line.\n"
948 exit 1
949 fi
950 ;;
951
952 --kernel-config | -C )
953 test $# = 1 && eval "$exit_missing_arg"
954 shift
955 if [ -f $1 ] ; then
956 CONFIG=$1
957 else
958 echo -e "\nFile $1 not found. Verify your command line.\n"
959 exit 1
960 fi
961 ;;
962
963 * )
964 echo "$usage"
965 exit 1
966 ;;
967 esac
968 shift
969done
970
971# Find the download client to use, if not already specified.
972
973if [ -z $DL ] ; then
974 if [ `type -p wget` ] ; then
975 DL=wget
976 elif [ `type -p curl` ] ; then
977 DL=curl
978 else
979 eval "$no_dl_client"
980 fi
981fi
982
983[[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
984[[ "$PWD" != "$JHALFSDIR" ]] && cp -v $FILES $JHALFSDIR/
985[[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
986>$LOGDIR/$LOG
987
988get_book
989build_Makefile
990run_make
991
Note: See TracBrowser for help on using the repository browser.