source: jhalfs@ dc44153

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

Making the scripts executables at generation time, instead of as part of a target.

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