source: jhalfs@ 898f47a

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

Added echo_finished function.

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