source: jhalfs@ af47a19

0.2 1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since af47a19 was af47a19, checked in by Jeremy Huntwork <jhuntwork@…>, 19 years ago

Fixed a couple of typos and added a comment to the directory argument

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