source: jhalfs@ 1f1d6a1

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

Removed harcoded build order numbers.
Thanks to Alexander E. Patrakov for pointing the issue
and David Fix for their suggestion about how to fix it.

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