source: jhalfs@ a41ce58

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

Setting the PAGE envar needed build Groff.
Added --page_size switch to can change the PAGE value.

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