source: jhalfs@ 0fd8a9d

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

Added support for UTF-8 branch packages and patches.

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