source: jhalfs@ 2ee568e

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

Fixed command typo.

  • Property mode set to 100755
File size: 21.8 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}
239
240extract_commands() {
241 # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
242 test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
243 exit 1"
244 cd $JHALFSDIR
245
246 # Start clean
247 if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
248 echo -n "Extracting commands... "
249
250 # Dump the commands in shell script form from the LFS book.
251 xsltproc --nonet --xinclude --stringparam testsuite $TEST \
252 --stringparam toolchaintest $TOOLCHAINTEST -o ./commands/ \
253 $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
254
255 # Make the scripts executable.
256 chmod -R +x $JHALFSDIR/commands
257
258 # Grab the patches and package names.
259 cd $JHALFSDIR
260 for i in patches packages ; do rm -f $i ; done
261 grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
262 -e '/generic/d' >> packages
263 echo `grep "glibc" packages | sed 's@glibc@glibc-linuxthreads@'` >> packages
264 grep "ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
265
266 # Done. Moving on...
267 echo -ne "done\n"
268 get_sources
269}
270
271download() {
272 cd $BUILDDIR/sources
273
274 # Hackish fix for the bash-doc and glibc-linuxthreads packages that
275 # doesn't conform to norms in the URL scheme.
276 DIR=`echo $1 | sed -e 's@-doc@@' -e 's@-linuxthreads@@'`
277
278 # Find the md5 sum for this package.
279 if [ $2 != MD5SUMS ] ; then MD5=`grep " $2" MD5SUMS` ; fi
280
281 if [ ! -f $2 ] ; then
282 case $DL in
283 wget )
284 wget $HTTP/$DIR/$2
285 ;;
286 curl )
287 `curl -# $HTTP/$DIR/$2 -o $2`
288 ;;
289 * )
290 echo "$DL not supported at this time."
291 ;;
292 esac
293 elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
294 case $DL in
295 wget )
296 wget -c $HTTP/$DIR/$2
297 ;;
298 curl )
299 `curl -# -C - $HTTP/$DIR/$2 -o $2`
300 ;;
301 * )
302 echo "$DL not supported at this time."
303 ;;
304 esac
305 fi
306 if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
307 exit 1
308 fi
309}
310
311get_sources() {
312
313 # Test if the packages must be downloaded
314 if [ "$HPKG" = "1" ] ; then
315
316 # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
317 # separates each iteration by lines. It is necessary to have the second
318 # ' on the next line.
319 IFS='
320'
321
322 if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
323 cd $BUILDDIR/sources
324 if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
325
326 download "" MD5SUMS
327
328 # Iterate through each package and grab it, along with any patches it needs.
329 for i in `cat $JHALFSDIR/packages` ; do
330 PKG=`echo $i | sed 's/-version.*//'`
331
332 # Someone used some silly entities right next to the valid package entities.
333 if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
334
335 VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
336 if [ "$PKG" = "tcl" ] ; then
337 FILE="$PKG$VRS-src.tar.bz2"
338 else
339 FILE="$PKG-$VRS.tar.bz2"
340 fi
341 download $PKG $FILE
342 for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
343 PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
344 download $PKG $PATCH
345 done
346 done
347 # Hardcoded Udev configuration file until find a better way
348 download udev udev-config-3.rules
349 fi
350}
351
352build_Makefile() {
353 echo -n "Creating Makefile... "
354 cd $JHALFSDIR/commands
355
356 # Start with a clean Makefile.tmp file
357 >$MKFILE.tmp
358
359 for file in chapter05/* ; do
360 # Keep the script file name
361 i=`basename $file`
362
363 # If no testsuites will be run, then TCL, Expect and DejaGNU isn't needed
364 if [ "$TOOLCHAINTEST" = "0" ]; then
365 if echo $i | grep -q "tcl" ; then
366 continue
367 elif echo $i | grep -q "expect" ; then
368 continue
369 elif echo $i | grep -q "dejagnu" ; then
370 continue
371 fi
372 fi
373
374 # First append each name of the script files to a list (this will become
375 # the names of the targets in the Makefile
376 chapter5="$chapter5 $i"
377
378 # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
379 # and binutils in chapter 5)
380 name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
381
382 # Set the dependency for the first target.
383 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
384
385 # Drop in the name of the target on a new line, and the previous target
386 # as a dependency. Also call the echo_message function.
387(
388 cat << EOF
389
390$i: $PREV
391 @\$(call echo_message, Building)
392EOF
393) >> $MKFILE.tmp
394
395 # Find the version of the command files, if it corresponds with the building of
396 # a specific package
397 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
398
399 # If $vrs isn't empty, we've got a package...
400 if [ "$vrs" != "" ] ; then
401 if [ "$name" = "tcl" ] ; then
402 FILE="$name$vrs-src.tar.bz2"
403 else
404 FILE="$name-$vrs.tar.bz2"
405 fi
406
407 # Insert instructions for unpacking the package and to set
408 # the PKGDIR variable.
409(
410 cat << EOF
411 @\$(call unpack,$FILE)
412 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
413 chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
414 echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
415 echo "export PKGDIR" >> envars && \\
416EOF
417) >> $MKFILE.tmp
418
419 fi
420
421 # Dump the path to the Binutils or TCL sources directory.
422 if [ "$i" = "027-binutils-pass1" -o "$i" = "032-tcl" -o "$i" = "036-binutils-pass2" ] ; then
423(
424 cat << EOF
425 echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir
426EOF
427) >> $MKFILE.tmp
428
429 # For the Adjusting phase we must to cd to the binutils-build directory.
430 elif [ "$i" = "031-adjusting" ] ; then
431(
432 cat << EOF
433 @echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\
434 echo "export PKGDIR" >> envars
435EOF
436) >> $MKFILE.tmp
437
438 # For the Expect build we need to set the TCLPATH envar.
439 elif [ "$i" = "033-expect" ] ; then
440(
441 cat << EOF
442 echo "TCLPATH=\`cat sources-dir\`" >> envars && \\
443 echo "export TCLPATH" >> envars
444EOF
445) >> $MKFILE.tmp
446
447 # Everything else, add a true statment so we don't confuse make
448 else
449(
450 cat << EOF
451 true
452EOF
453) >> $MKFILE.tmp
454 fi
455
456 # Insert date and disk usage at the top of the log file, the script run
457 # and date and disk usage again at the bottom of the log file.
458(
459 cat << EOF
460 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
461 su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
462 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >>logs/$i
463EOF
464) >> $MKFILE.tmp
465
466 # Remove the build directory(ies) except if the package build fails
467 # (to can review config.cache, config.log, and like.)
468 # For Binutils and TCL the sources must be retained some time.
469 if [ "$vrs" != "" ] ; then
470 if [ "$i" != "027-binutils-pass1" ] && [ "$i" != "032-tcl" ] && [ "$i" != "036-binutils-pass2" ] ; then
471(
472 cat << EOF
473 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
474 rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
475 if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
476 rm -r \$(LFS)\$(SRC)/$name-build; \\
477 fi;
478EOF
479) >> $MKFILE.tmp
480 fi
481 fi
482
483 # Remove the Binutils pass 1 sources after a successful Adjusting phase.
484 if [ "$i" = "031-adjusting" ] ; then
485(
486 cat << EOF
487 @rm -r \`cat sources-dir\` && \\
488 rm -r \$(LFS)\$(SRC)/binutils-build && \\
489 rm sources-dir
490EOF
491) >> $MKFILE.tmp
492 fi
493
494 # Remove the TCL sources after a successful Expect build.
495 if [ "$i" = "033-expect" ] ; then
496(
497 cat << EOF
498 @rm -r \`cat sources-dir\` && \\
499 rm sources-dir
500EOF
501) >> $MKFILE.tmp
502 fi
503
504 # Include a touch of the target name so make can check
505 # if it's already been made.
506(
507 cat << EOF
508 @touch \$@
509EOF
510) >> $MKFILE.tmp
511
512 # Keep the script file name for Makefile dependencies.
513 PREV=$i
514 done
515
516 for file in chapter06/* ; do
517 # Keep the script file name
518 i=`basename $file`
519
520 # We'll run the chroot commands differently than the others, so skip them in the
521 # dependencies and target creation.
522 if echo $i | grep -q "chroot" ; then
523 continue
524 fi
525
526 # First append each name of the script files to a list (this will become
527 # the names of the targets in the Makefile
528 chapter6="$chapter6 $i"
529
530 # Grab the name of the target
531 name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
532
533 # Set the dependency for the first target.
534 if [ -z $PREV ] ; then PREV=055-stripping ; fi
535
536 # Drop in the name of the target on a new line, and the previous target
537 # as a dependency. Also call the echo_message function.
538(
539 cat << EOF
540
541$i: $PREV
542 @\$(call echo_message, Building)
543EOF
544) >> $MKFILE.tmp
545
546 # Find the version of the command files, if it corresponds with the building of
547 # a specific package
548 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
549
550 # If $vrs isn't empty, we've got a package...
551 # Insert instructions for unpacking the package and changing directories
552 if [ "$vrs" != "" ] ; then
553 FILE="$name-$vrs.tar.bz2"
554(
555 cat << EOF
556 @\$(call unpack,$FILE)
557 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
558 echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
559 echo "export PKGDIR" >> envars
560EOF
561) >> $MKFILE.tmp
562 fi
563
564 # For the Re-Adjusting phase we must to cd to the binutils-build directory.
565 if [ "$i" = "067-readjusting" ] ; then
566(
567 cat << EOF
568 @echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\
569 echo "export PKGDIR" >> envars
570EOF
571) >> $MKFILE.tmp
572 fi
573
574 # For Groff we need to set PAGE envar.
575 if [ "$i" = "082-groff" ] ; then
576(
577 cat << EOF
578 @echo "PAGE=\$(PAGE)" >> envars && \\
579 echo "export PAGE" >> envars
580EOF
581) >> $MKFILE.tmp
582 fi
583
584 # In the mount of kernel filesystems we need to set LFS
585 # and not to use chroot.
586 if [ "$i" = "057-kernfs" ] ; then
587(
588 cat << EOF
589 @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
590 export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
591 echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >>logs/$i
592EOF
593) >> $MKFILE.tmp
594
595 # The rest of Chapter06
596 else
597(
598 cat << EOF
599 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
600 \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
601 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(LFS)\`\n" >>logs/$i
602EOF
603) >> $MKFILE.tmp
604
605 fi
606
607 # Remove the build directory(ies) except if the package build fails.
608 if [ "$vrs" != "" ] ; then
609(
610 cat << EOF
611 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
612 rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
613 if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
614 rm -r \$(LFS)\$(SRC)/$name-build; \\
615 fi;
616EOF
617) >> $MKFILE.tmp
618 fi
619
620 # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
621 if [ "$i" = "067-readjusting" ] ; then
622(
623 cat << EOF
624 @rm -r \`cat sources-dir\` && \\
625 rm -r \$(LFS)\$(SRC)/binutils-build && \\
626 rm sources-dir
627EOF
628) >> $MKFILE.tmp
629 fi
630
631 # Include a touch of the target name so make can check
632 # if it's already been made.
633(
634 cat << EOF
635 @touch \$@
636EOF
637) >> $MKFILE.tmp
638
639 # Keep the script file name for Makefile dependencies.
640 PREV=$i
641 done
642
643 for file in chapter0{7,8,9}/* ; do
644 # Keep the script file name
645 i=`basename $file`
646
647 # Grub must be configured manually
648 if echo $i | grep -q "grub" ; then
649 continue
650 fi
651
652 # If no .config file is supplied, the kernel build is skipped
653 if [ -z $CONFIG ] ; then
654 if echo $i | grep -q "kernel" ; then
655 continue
656 fi
657 fi
658
659 # First append each name of the script files to a list (this will become
660 # the names of the targets in the Makefile
661 chapter789="$chapter789 $i"
662
663 # Set the dependency for the first target.
664 if [ -z $PREV ] ; then PREV=116-strippingagain ; fi
665
666 # Drop in the name of the target on a new line, and the previous target
667 # as a dependency. Also call the echo_message function.
668(
669 cat << EOF
670
671$i: $PREV
672 @\$(call echo_message, Building)
673EOF
674) >> $MKFILE.tmp
675
676 # Find the the bootscripts and kernel package names
677 if [ "$i" = "119-bootscripts" -o "$i" = "132-kernel" ] ; then
678 if [ "$i" = "119-bootscripts" ] ; then
679 vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
680 FILE="lfs-bootscripts-$vrs.tar.bz2"
681 elif [ "$i" = "132-kernel" ] ; then
682 vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
683 FILE="linux-$vrs.tar.bz2"
684 fi
685(
686 cat << EOF
687 @\$(call unpack,$FILE)
688 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
689 echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
690 echo "export PKGDIR" >> envars
691EOF
692) >> $MKFILE.tmp
693 fi
694
695 # Put in place the kernel .config file
696 if [ "$i" = "132-kernel" ] ; then
697(
698 cat << EOF
699 @source envars && cp $CONFIG \$(LFS)\$(PKGDIR)
700EOF
701) >> $MKFILE.tmp
702 fi
703
704 # Initialize the log an run the script
705(
706 cat << EOF
707 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
708 \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
709 echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(LFS)\`\n" >>logs/$i
710EOF
711) >> $MKFILE.tmp
712
713 # Remove the build directory except if the package build fails.
714 if [ "$i" = "119-bootscripts" -o "$i" = "132-kernel" ] ; then
715(
716 cat << EOF
717 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
718 rm -r \$(LFS)\$(SRC)/\$\$ROOT
719EOF
720) >> $MKFILE.tmp
721 fi
722
723 # Include a touch of the target name so make can check
724 # if it's already been made.
725(
726 cat << EOF
727 @touch \$@
728EOF
729) >> $MKFILE.tmp
730
731 # Keep the script file name for Makefile dependencies.
732 PREV=$i
733 done
734
735 # Add a header, some variables and include the function file
736 # to the top of the real Makefile.
737(
738 cat << EOF
739$HEADER
740
741SRC= /sources
742LFS= $BUILDDIR
743PAGE= $PAGE
744
745include functions
746
747EOF
748) > $MKFILE
749
750
751 # Add chroot commands
752 i=1
753 for file in chapter06/*chroot* ; do
754 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
755 -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|&&exit||g' -e 's|$| -c|' -e 's|"$$LFS"|$(LFS)|'`
756 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
757 i=`expr $i + 1`
758 done
759
760 # Drop in the main target 'all:' and the chapter targets with each sub-target
761 # as a dependency.
762(
763 cat << EOF
764all: chapter4 chapter5 chapter6 chapter789
765 @echo -e "\n\tYour new LFS system has been successfully built"
766
767chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
768
769chapter5: chapter4 $chapter5
770
771chapter6: chapter5 $chapter6
772
773chapter789: chapter6 $chapter789
774
775clean-all: clean
776 rm -rf ./*
777
778clean: clean-chapter5 clean-chapter4
779
780clean-chapter4:
781 -userdel lfs
782 rm -rf /home/lfs
783 rm -rf \$(LFS)/tools
784 rm -f /tools
785 rm -f envars
786 rm -f 02* logs/02*.log
787
788clean-chapter5:
789 rm -rf \$(LFS)/tools/*
790 rm -f $chapter5
791 cd logs && rm -f $chapter5 && cd ..
792
793020-creatingtoolsdir:
794 @\$(call echo_message, Building)
795 @mkdir -v \$(LFS)/tools && \\
796 ln -sv \$(LFS)/tools / && \\
797 touch \$@
798
799021-addinguser: 020-creatingtoolsdir
800 @\$(call echo_message, Building)
801 @groupadd lfs && \\
802 useradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\
803 chown lfs \$(LFS)/tools && \\
804 chown lfs \$(LFS)/sources && \\
805 touch \$@
806
807022-settingenvironment: 021-addinguser
808 @\$(call echo_message, Building)
809 @echo "exec env -i HOME=\\\$\$HOME TERM=\\\$\$TERM PS1='\u:\w\$$ ' /bin/bash" > /home/lfs/.bash_profile && \\
810 echo "set +h" > /home/lfs/.bashrc && \\
811 echo "umask 022" >> /home/lfs/.bashrc && \\
812 echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
813 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
814 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
815 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
816 echo ". $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
817 chown lfs:lfs /home/lfs/.bash* && \\
818 touch envars && \\
819 touch \$@
820EOF
821) >> $MKFILE
822
823 # Bring over the items from the Makefile.tmp
824 cat $MKFILE.tmp >> $MKFILE
825 rm $MKFILE.tmp
826 echo -ne "done\n"
827}
828
829run_make() {
830 # Test if make must be run.
831 if [ "$RUNMAKE" = "1" ] ; then
832 # Build the system
833 if [ -e $MKFILE ] ; then
834 echo -ne "Building the LFS system...\n"
835 cd $JHALFSDIR && make
836 echo -ne "done\n"
837 fi
838 fi
839}
840
841if [ ! -d $JHALFSDIR ] ; then
842 mkdir -p $JHALFSDIR
843fi
844
845if [ ! -d $LOGDIR ] ; then
846 mkdir $LOGDIR
847fi
848
849>$LOGDIR/$LOG
850
851if [ "$PWD" != "$JHALFSDIR" ] ; then
852 cp $0 $XSL $FNC $JHALFSDIR/
853fi
854
855get_book
856build_Makefile
857run_make
Note: See TracBrowser for help on using the repository browser.