source: jhalfs@ bf1c3ba

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

The remove_db patch for IPRoute2 has been changed by a sed command in the 6.1.1 testing branch.

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