source: jhalfs@ 4e9a3b3

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

Added support for the Module-init-tools-testsuite package.

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