[fbb6b78] | 1 | #!/bin/sh
|
---|
[1236262] | 2 |
|
---|
| 3 | version="
|
---|
[63b2859] | 4 | jhalfs development
|
---|
| 5 |
|
---|
[db9cec6] | 6 | Originally written by Jeremy Huntwork.
|
---|
[557fe91] | 7 | Maintained by Manuel Canales Esparcia.
|
---|
[1236262] | 8 |
|
---|
| 9 | This program is published under the \
|
---|
[557fe91] | 10 | Gnu General Public License, Version 2.
|
---|
| 11 | "
|
---|
[1236262] | 12 |
|
---|
| 13 | usage="\
|
---|
| 14 | Usage: $0 [OPTION]
|
---|
| 15 |
|
---|
| 16 | Options:
|
---|
[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 |
|
---|
| 40 | help="\
|
---|
| 41 | Try '$0 --help' for more information."
|
---|
| 42 |
|
---|
| 43 | exit_missing_arg="\
|
---|
| 44 | echo \"Option '\$1' requires an argument\" >&2
|
---|
| 45 | echo \"\$help\" >&2
|
---|
| 46 | exit 1"
|
---|
| 47 |
|
---|
| 48 | no_dl_client="\
|
---|
| 49 | echo \"Could not find a way to download the LFS sources.\" >&2
|
---|
| 50 | echo \"Attempting to continue.\" >&2"
|
---|
| 51 |
|
---|
| 52 | while 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] | 121 | done
|
---|
| 122 |
|
---|
| 123 | # Test to make sure we're running the build as root
|
---|
| 124 |
|
---|
| 125 | if [ "$UID" != "0" ] ; then
|
---|
[557fe91] | 126 | echo "You must be logged in as root to successfully build LFS."
|
---|
| 127 | exit 1
|
---|
[1236262] | 128 | fi
|
---|
| 129 |
|
---|
| 130 | # Find the download client to use, if not already specified.
|
---|
| 131 |
|
---|
| 132 | if [ -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
|
---|
| 140 | fi
|
---|
| 141 |
|
---|
| 142 | SVN="svn://svn.linuxfromscratch.org"
|
---|
| 143 | HTTP=http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/conglomeration
|
---|
[48d7968] | 144 | if [ -z $BUILDDIR ] ; then BUILDDIR=/mnt/lfs ; fi
|
---|
[4dafc45] | 145 | JHALFSDIR=$BUILDDIR/jhalfs
|
---|
[97a3ffc] | 146 | LOGDIR=/jhalfs/logs
|
---|
[a5e49c6] | 147 | LOG=000-jhalfs.log
|
---|
[f8de156] | 148 | MKFILE=$JHALFSDIR/Makefile
|
---|
[3cfe871] | 149 | XSL=dump-lfs-scripts.xsl
|
---|
[0fc4c75] | 150 | FNC=functions
|
---|
[db9cec6] | 151 | if [ -z $TEST ] ; then TEST=0 ; fi
|
---|
[1236262] | 152 |
|
---|
| 153 | get_book() {
|
---|
| 154 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
| 155 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
[557fe91] | 156 | exit 1"
|
---|
[4dafc45] | 157 | cd $JHALFSDIR
|
---|
[fbb6b78] | 158 |
|
---|
[1236262] | 159 | # Test to make sure the LFS version is set
|
---|
| 160 | if [ -z $LFSVRS ] ; then LFSVRS=development ; fi
|
---|
[24530379] | 161 |
|
---|
[56dd1e2] | 162 | # Set the book's sources directory
|
---|
[24530379] | 163 | if [ -z $BOOK ] ; then BOOK=lfs-$LFSVRS ; fi
|
---|
| 164 |
|
---|
| 165 | if [ -z $WC ] ; then
|
---|
| 166 | echo -n "Downloading the LFS Book, version $LFSVRS... "
|
---|
| 167 |
|
---|
| 168 | # Grab the LFS book fresh if it's missing, otherwise, update it from the
|
---|
| 169 | # repo. If we've already extracted the commands, move on to getting the
|
---|
| 170 | # sources.
|
---|
| 171 | if [ -d lfs-$LFSVRS ] ; then
|
---|
| 172 | cd lfs-$LFSVRS
|
---|
| 173 | if svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
---|
| 174 | test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
---|
| 175 | echo -ne "done\n"
|
---|
| 176 | get_sources
|
---|
| 177 | else
|
---|
| 178 | echo -ne "done\n"
|
---|
| 179 | extract_commands
|
---|
| 180 | fi
|
---|
[557fe91] | 181 | else
|
---|
[24530379] | 182 | if [ $LFSVRS = development ] ; then
|
---|
| 183 | svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$BUILDDIR$LOGDIR/$LOG 2>&1
|
---|
| 184 | else
|
---|
| 185 | svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$BUILDDIR$LOGDIR/$LOG 2>&1
|
---|
| 186 | fi
|
---|
[557fe91] | 187 | echo -ne "done\n"
|
---|
| 188 | extract_commands
|
---|
| 189 | fi
|
---|
[1236262] | 190 | else
|
---|
[24530379] | 191 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
[557fe91] | 192 | extract_commands
|
---|
[1236262] | 193 | fi
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | extract_commands() {
|
---|
| 197 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
| 198 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
[557fe91] | 199 | exit 1"
|
---|
[4dafc45] | 200 | cd $JHALFSDIR
|
---|
[1236262] | 201 |
|
---|
| 202 | # Start clean
|
---|
| 203 | if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
|
---|
| 204 | echo -n "Extracting commands... "
|
---|
| 205 |
|
---|
[dc2fee8] | 206 | # Dump the commands in shell script form from the LFS book.
|
---|
[db9cec6] | 207 | xsltproc --nonet --xinclude --stringparam testsuite $TEST -o ./commands/ \
|
---|
[24530379] | 208 | $XSL $BOOK/index.xml >>$BUILDDIR$LOGDIR/$LOG 2>&1
|
---|
[1236262] | 209 |
|
---|
| 210 | # Grab the patches and package names.
|
---|
[4dafc45] | 211 | cd $JHALFSDIR
|
---|
[1236262] | 212 | for i in patches packages ; do rm -f $i ; done
|
---|
[24530379] | 213 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
---|
[557fe91] | 214 | -e '/generic/d' >> packages
|
---|
[24530379] | 215 | grep "ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
---|
[1236262] | 216 |
|
---|
| 217 | # Done. Moving on...
|
---|
| 218 | echo -ne "done\n"
|
---|
| 219 | get_sources
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | download() {
|
---|
| 223 | cd $BUILDDIR/sources
|
---|
| 224 |
|
---|
| 225 | # Hackish fix for the bash-doc package that doesn't conform
|
---|
| 226 | # to norms in the URL scheme.
|
---|
| 227 | DIR=`echo $1 | sed 's@-doc@@'`
|
---|
| 228 |
|
---|
| 229 | # Find the md5 sum for this package.
|
---|
| 230 | if [ $2 != MD5SUMS ] ; then MD5=`grep " $2" MD5SUMS` ; fi
|
---|
| 231 |
|
---|
| 232 | if [ ! -f $2 ] ; then
|
---|
[557fe91] | 233 | case $DL in
|
---|
| 234 | wget )
|
---|
| 235 | wget $HTTP/$DIR/$2
|
---|
| 236 | ;;
|
---|
| 237 | curl )
|
---|
| 238 | `curl -# $HTTP/$DIR/$2 -o $2`
|
---|
| 239 | ;;
|
---|
| 240 | * )
|
---|
| 241 | echo "$DL not supported at this time."
|
---|
| 242 | ;;
|
---|
| 243 | esac
|
---|
[1236262] | 244 | elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
---|
[557fe91] | 245 | case $DL in
|
---|
| 246 | wget )
|
---|
| 247 | wget -c $HTTP/$DIR/$2
|
---|
| 248 | ;;
|
---|
| 249 | curl )
|
---|
| 250 | `curl -# -C - $HTTP/$DIR/$2 -o $2`
|
---|
| 251 | ;;
|
---|
| 252 | * )
|
---|
| 253 | echo "$DL not supported at this time."
|
---|
| 254 | ;;
|
---|
| 255 | esac
|
---|
[1236262] | 256 | fi
|
---|
| 257 | if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
---|
| 258 | exit 1
|
---|
| 259 | fi
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | get_sources() {
|
---|
| 263 |
|
---|
[07f47df] | 264 | # Test if the packages must be downloaded
|
---|
[d310939] | 265 | if [ "$HPKG" = "1" ] ; then
|
---|
[1236262] | 266 |
|
---|
[07f47df] | 267 | # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
---|
| 268 | # separates each iteration by lines. It is necessary to have the second
|
---|
| 269 | # ' on the next line.
|
---|
| 270 | IFS='
|
---|
| 271 | '
|
---|
[1236262] | 272 |
|
---|
[07f47df] | 273 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
| 274 | cd $BUILDDIR/sources
|
---|
| 275 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
| 276 |
|
---|
| 277 | download "" MD5SUMS
|
---|
| 278 |
|
---|
| 279 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
| 280 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
| 281 | PKG=`echo $i | sed 's/-version.*//'`
|
---|
| 282 |
|
---|
| 283 | # Someone used some silly entities right next to the valid package entities.
|
---|
| 284 | if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
---|
| 285 |
|
---|
| 286 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 287 | if [ "$PKG" = "tcl" ] ; then
|
---|
| 288 | FILE="$PKG$VRS-src.tar.bz2"
|
---|
| 289 | else
|
---|
| 290 | FILE="$PKG-$VRS.tar.bz2"
|
---|
| 291 | fi
|
---|
| 292 | download $PKG $FILE
|
---|
| 293 | for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
|
---|
| 294 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
| 295 | download $PKG $PATCH
|
---|
| 296 | done
|
---|
[fbb6b78] | 297 | done
|
---|
[07f47df] | 298 | fi
|
---|
[1236262] | 299 | }
|
---|
| 300 |
|
---|
[f8de156] | 301 | build_Makefile() {
|
---|
[9e406b5] | 302 | echo -n "Creating Makefile... "
|
---|
[f8de156] | 303 | cd $JHALFSDIR/commands
|
---|
[fbb6b78] | 304 |
|
---|
[f8de156] | 305 | # Start with a clean Makefile.tmp file
|
---|
| 306 | >$MKFILE.tmp
|
---|
| 307 |
|
---|
[0bad6ba] | 308 | for file in chapter05/* ; do
|
---|
[71642ef] | 309 | # Keep the script file name
|
---|
| 310 | i=`basename $file`
|
---|
[63b2859] | 311 |
|
---|
[71642ef] | 312 | # First append each name of the script files to a list (this will become
|
---|
| 313 | # the names of the targets in the Makefile
|
---|
| 314 | chapter5="$chapter5 $i"
|
---|
[557fe91] | 315 |
|
---|
[71642ef] | 316 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
| 317 | # and binutils in chapter 5)
|
---|
| 318 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
[557fe91] | 319 |
|
---|
[e909d9d] | 320 | # Set the dependency for the first target.
|
---|
| 321 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 322 |
|
---|
| 323 | # Drop in the name of the target on a new line, and the previous target
|
---|
[0fc4c75] | 324 | # as a dependency. Also call the echo_message function.
|
---|
[e909d9d] | 325 | echo -e "\n$i: $PREV" >> $MKFILE.tmp
|
---|
[0fc4c75] | 326 | echo -e "\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
[557fe91] | 327 |
|
---|
[71642ef] | 328 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 329 | # a specific package
|
---|
| 330 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
[557fe91] | 331 |
|
---|
[71642ef] | 332 | # If $vrs isn't empty, we've got a package...
|
---|
| 333 | if [ "$vrs" != "" ] ; then
|
---|
| 334 | if [ "$name" = "tcl" ] ; then
|
---|
| 335 | FILE="$name$vrs-src.tar.bz2"
|
---|
| 336 | else
|
---|
| 337 | FILE="$name-$vrs.tar.bz2"
|
---|
| 338 | fi
|
---|
[557fe91] | 339 |
|
---|
[71642ef] | 340 | # Insert instructions for unpacking the package and to set
|
---|
| 341 | # the PKGDIR variable.
|
---|
[0fc4c75] | 342 | echo -e "\t@\$(call unpack-lfs,$FILE)" >> $MKFILE.tmp
|
---|
| 343 | echo -e "\t@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
[71642ef] | 344 | echo -e "\tchown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
| 345 | echo -e "\techo \"PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT\" > envars && \\" >> $MKFILE.tmp
|
---|
| 346 | echo -e "\techo \"export PKGDIR\" >> envars && \\" >> $MKFILE.tmp
|
---|
| 347 | fi
|
---|
[557fe91] | 348 |
|
---|
[97a3ffc] | 349 | # Dump the path to the Binutils pass1 or TCL sources directory.
|
---|
| 350 | if [ "$i" = "027-binutils-pass1" -o "$i" = "032-tcl" ] ; then
|
---|
[0fc4c75] | 351 | echo -e "\techo \"\$(LFS)\$(SRC)/\$\$ROOT\" > sources-dir" >> $MKFILE.tmp
|
---|
[88dcce5] | 352 |
|
---|
[97a3ffc] | 353 | # Dump the path to the Binutils pass2 sources directory.
|
---|
[0fc4c75] | 354 | elif [ "$i" = "036-binutils-pass2" ] ; then
|
---|
| 355 | echo -e "\techo \"\$(SRC)/\$\$ROOT\" > sources-dir" >> $MKFILE.tmp
|
---|
[97a3ffc] | 356 |
|
---|
[71642ef] | 357 | # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
[0fc4c75] | 358 | elif [ "$i" = "031-adjusting" ] ; then
|
---|
[d310939] | 359 | echo -e "\techo \"PKGDIR=\$(LFS)\$(SRC)/binutils-build\" > envars && \\" >> $MKFILE.tmp
|
---|
[0fc4c75] | 360 | echo -e "\techo \"export PKGDIR\" >> envars" >> $MKFILE.tmp
|
---|
[0209bb7] | 361 |
|
---|
[97a3ffc] | 362 | # For the Expect build we need to set the TCLPATH envar.
|
---|
[0fc4c75] | 363 | elif [ "$i" = "033-expect" ] ; then
|
---|
[71642ef] | 364 | echo -e "\techo \"TCLPATH=\`cat sources-dir\`\" >> envars && \\" >> $MKFILE.tmp
|
---|
[0fc4c75] | 365 | echo -e "\techo \"export TCLPATH\" >> envars" >> $MKFILE.tmp
|
---|
| 366 |
|
---|
| 367 | # Everything else, add a true statment so we don't confuse make
|
---|
| 368 | else
|
---|
| 369 | echo -e "\ttrue" >> $MKFILE.tmp
|
---|
[71642ef] | 370 | fi
|
---|
[557fe91] | 371 |
|
---|
[4e4a8d5] | 372 | # Insert date and disk usage at the top of the log file.
|
---|
[0fc4c75] | 373 | echo -e "\t@echo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >logs/$i && \\" >> $MKFILE.tmp
|
---|
[133ecac] | 374 |
|
---|
[71642ef] | 375 | # Insert the script run
|
---|
[7ecd166] | 376 | echo -e "\tsu - lfs -c \". /home/lfs/.bashrc && $JHALFSDIR/commands/$file\" >>logs/$i 2>&1 && \\" >> $MKFILE.tmp
|
---|
[71642ef] | 377 |
|
---|
[4e4a8d5] | 378 | # Insert date and disk usage at the bottom of the log file.
|
---|
[0fc4c75] | 379 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >>logs/$i" >> $MKFILE.tmp
|
---|
[71642ef] | 380 |
|
---|
| 381 | # Remove the build directory(ies) even if the package build fails, except for
|
---|
[d310939] | 382 | # Binutils and TCL. In that cases the sources directories are removed
|
---|
[71642ef] | 383 | # only if the build fails.
|
---|
| 384 | if [ "$vrs" != "" ] ; then
|
---|
[d310939] | 385 | if [ "$i" != "027-binutils-pass1" ] && [ "$i" != "032-tcl" ] && [ "$i" != "036-binutils-pass2" ] ; then
|
---|
[0fc4c75] | 386 | echo -e "\t@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
[71642ef] | 387 | echo -e "\trm -r \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
[d310939] | 388 | echo -e "\tif [ -e \$(LFS)\$(SRC)/$name-build ]; then \\" >> $MKFILE.tmp
|
---|
| 389 | echo -e "\t\trm -r \$(LFS)\$(SRC)/$name-build; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 390 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 391 | fi
|
---|
| 392 | fi
|
---|
[d310939] | 393 | if [ "$i" = "027-binutils-pass1" -o "$i" = "036-binutils-pass2" ] ; then
|
---|
[0fc4c75] | 394 | echo -e "\t@if [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
[71642ef] | 395 | echo -e "\t\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
| 396 | echo -e "\t\trm -r \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
[d310939] | 397 | echo -e "\t\trm -r \$(LFS)\$(SRC)/binutils-build; \\" >> $MKFILE.tmp
|
---|
| 398 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 399 | fi
|
---|
| 400 | if [ "$i" = "032-tcl" ] ; then
|
---|
[0fc4c75] | 401 | echo -e "\t@if [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
[d310939] | 402 | echo -e "\t\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
| 403 | echo -e "\t\trm -r \$(LFS)\$(SRC)/\$\$ROOT; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 404 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 405 | fi
|
---|
[44f88e3] | 406 |
|
---|
[4e4a8d5] | 407 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
[71642ef] | 408 | if [ "$i" = "031-adjusting" ] ; then
|
---|
[0fc4c75] | 409 | echo -e "\t@if [ -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
[71642ef] | 410 | echo -e "\t\trm -r \`cat sources-dir\` && \\" >> $MKFILE.tmp
|
---|
[d310939] | 411 | echo -e "\t\trm -r \$(LFS)\$(SRC)/binutils-build && \\" >> $MKFILE.tmp
|
---|
| 412 | echo -e "\t\trm sources-dir; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 413 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 414 | fi
|
---|
[0209bb7] | 415 |
|
---|
[4e4a8d5] | 416 | # Remove the TCL sources after a successful Expect build.
|
---|
[71642ef] | 417 | if [ "$i" = "033-expect" ] ; then
|
---|
[0fc4c75] | 418 | echo -e "\t@if [ -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
[71642ef] | 419 | echo -e "\t\trm -r \`cat sources-dir\` && \\" >> $MKFILE.tmp
|
---|
[d310939] | 420 | echo -e "\t\trm sources-dir; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 421 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 422 | fi
|
---|
[a5e49c6] | 423 |
|
---|
[968dafd] | 424 | # Include a touch of the target name so make can check
|
---|
| 425 | # if it's already been made.
|
---|
[0fc4c75] | 426 | echo -e "\t@touch \$@" >> $MKFILE.tmp
|
---|
[e909d9d] | 427 |
|
---|
| 428 | # Keep the script file name for Makefile dependencies.
|
---|
| 429 | PREV=$i
|
---|
[f8de156] | 430 | done
|
---|
[9e406b5] | 431 |
|
---|
[97a3ffc] | 432 | for file in chapter06/* ; do
|
---|
| 433 | # Keep the script file name
|
---|
| 434 | i=`basename $file`
|
---|
| 435 |
|
---|
| 436 | # First append each name of the script files to a list (this will become
|
---|
| 437 | # the names of the targets in the Makefile
|
---|
| 438 | chapter6="$chapter6 $i"
|
---|
| 439 |
|
---|
| 440 | # Grab the name of the target
|
---|
| 441 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 442 |
|
---|
| 443 | # Set the dependency for the first target.
|
---|
| 444 | if [ -z $PREV ] ; then PREV=055-stripping ; fi
|
---|
| 445 |
|
---|
| 446 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 447 | # as a dependency.
|
---|
[1936487] | 448 | if echo $i | grep -q "chroot" ; then
|
---|
| 449 | continue
|
---|
| 450 | else
|
---|
[c08d23b] | 451 | echo -e "\n$i: $PREV" >> $MKFILE.tmp
|
---|
| 452 | fi
|
---|
[97a3ffc] | 453 |
|
---|
| 454 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 455 | # a specific package
|
---|
| 456 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 457 |
|
---|
| 458 | # If $vrs isn't empty, we've got a package...
|
---|
| 459 | if [ "$vrs" != "" ] ; then
|
---|
| 460 | FILE="$name-$vrs.tar.bz2"
|
---|
| 461 |
|
---|
| 462 | # Insert instructions for unpacking the package and changing directories
|
---|
[0fc4c75] | 463 | echo -e "\t@\$(call unpack,$FILE)" >> $MKFILE.tmp
|
---|
| 464 | echo -e "\t@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
[56dd1e2] | 465 | echo -e "\techo \"PKGDIR=\$(SRC)/\$\$ROOT\" > envars && \\" >> $MKFILE.tmp
|
---|
| 466 | echo -e "\techo \"export PKGDIR\" >> envars && \\" >> $MKFILE.tmp
|
---|
[97a3ffc] | 467 | fi
|
---|
| 468 |
|
---|
| 469 | # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 470 | if [ "$i" = "067-readjusting" ] ; then
|
---|
[56dd1e2] | 471 | echo -e "\techo \"PKGDIR=\$(SRC)/binutils-build\" > envars && \\" >> $MKFILE.tmp
|
---|
[0fc4c75] | 472 | echo -e "\techo \"export PKGDIR\" >> envars" >> $MKFILE.tmp
|
---|
[97a3ffc] | 473 |
|
---|
| 474 | # Insert the script run
|
---|
[7ecd166] | 475 | # For the mount of kernel filesystems we need to set LFS.
|
---|
[0fc4c75] | 476 | elif [ "$i" = "057-kernfs" ] ; then
|
---|
[7ecd166] | 477 | echo -e "\techo \"LFS=\$(LFS)\" > envars && \\" >> $MKFILE.tmp
|
---|
| 478 | echo -e "\techo \"export LFS\" >> envars && \\" >> $MKFILE.tmp
|
---|
[4e4a8d5] | 479 | # Insert date and disk usage at the top of the log file.
|
---|
[7ecd166] | 480 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >logs/$i && \\" >> $MKFILE.tmp
|
---|
| 481 | echo -e "\t. envars && commands/$file >>logs/$i 2>&1 && \\" >> $MKFILE.tmp
|
---|
[4e4a8d5] | 482 | # Insert date and disk usage at the bottom of the log file.
|
---|
[0fc4c75] | 483 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >>logs/$i" >> $MKFILE.tmp
|
---|
[7ecd166] | 484 | else
|
---|
[4e4a8d5] | 485 | # Insert date and disk usage at the top of the log file.
|
---|
[7ecd166] | 486 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* /\`\\\n\" >logs/$i && \\" >> $MKFILE.tmp
|
---|
[c08d23b] | 487 | echo -e "\t. envars && \$(CHROOT1) 'cd /jhalfs && commands/$file >>logs/$i 2>&1' && \\" >> $MKFILE.tmp
|
---|
[4e4a8d5] | 488 | # Insert date and disk usage at the bottom of the log file.
|
---|
[0fc4c75] | 489 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* /\`\\\n\" >>logs/$i" >> $MKFILE.tmp
|
---|
[7ecd166] | 490 | fi
|
---|
[97a3ffc] | 491 |
|
---|
[6299c11] | 492 | # Remove the build directory(ies) even if the package build fails.
|
---|
[97a3ffc] | 493 | if [ "$vrs" != "" ] ; then
|
---|
[0fc4c75] | 494 | echo -e "\t@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
[97a3ffc] | 495 | echo -e "\trm -r \$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
| 496 | echo -e "\tif [ -e \$(SRC)/$name-build ]; then \\" >> $MKFILE.tmp
|
---|
| 497 | echo -e "\t\trm -r \$(SRC)/$name-build; \\" >> $MKFILE.tmp
|
---|
| 498 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 499 | fi
|
---|
| 500 |
|
---|
[4e4a8d5] | 501 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
[6299c11] | 502 | if [ "$i" = "067-readjusting" ] ; then
|
---|
[0fc4c75] | 503 | echo -e "\t@if [ -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
[97a3ffc] | 504 | echo -e "\t\trm -r \`cat sources-dir\` && \\" >> $MKFILE.tmp
|
---|
| 505 | echo -e "\t\trm -r \$(SRC)/binutils-build && \\" >> $MKFILE.tmp
|
---|
| 506 | echo -e "\t\trm sources-dir; \\" >> $MKFILE.tmp
|
---|
| 507 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 508 | fi
|
---|
| 509 |
|
---|
[732d1f1] | 510 | # Include a touch of the target name so make can check
|
---|
| 511 | # if it's already been made.
|
---|
[0fc4c75] | 512 | echo -e "\t@touch \$@" >> $MKFILE.tmp
|
---|
[732d1f1] | 513 |
|
---|
[97a3ffc] | 514 | # Keep the script file name for Makefile dependencies.
|
---|
| 515 | PREV=$i
|
---|
| 516 | done
|
---|
| 517 |
|
---|
[a5e49c6] | 518 | # Stick variables and some defines at the top of the real makefile
|
---|
[9e406b5] | 519 | echo "export SRC := /sources" > $MKFILE
|
---|
| 520 | echo "export LFS := $BUILDDIR" >> $MKFILE
|
---|
[a5e49c6] | 521 | echo -e "export LOGDIR := $LOGDIR\n" >> $MKFILE
|
---|
[c08d23b] | 522 | echo -e "include functions\n" >> $MKFILE
|
---|
| 523 |
|
---|
| 524 | # Add chroot commands
|
---|
| 525 | i=1
|
---|
| 526 | for file in chapter06/*chroot* ; do
|
---|
| 527 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
---|
| 528 | -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|$| -c|'`
|
---|
| 529 | echo -e "export CHROOT$i := $chroot\n" >> $MKFILE
|
---|
| 530 | i=`expr $i + 1`
|
---|
| 531 | done
|
---|
[9e406b5] | 532 |
|
---|
[0bad6ba] | 533 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 534 | # as a dependency.
|
---|
[6299c11] | 535 | echo "all: chapter4 chapter5" >> $MKFILE
|
---|
[4e4a8d5] | 536 | echo -e "\t@echo -e \"\\\n\\\tYour new LFS system has been successfully built\"\n" >> $MKFILE
|
---|
[0bad6ba] | 537 | echo -e "chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment\n" >> $MKFILE
|
---|
[97a3ffc] | 538 | echo -e "chapter5: chapter4 $chapter5\n" >> $MKFILE >> $MKFILE
|
---|
| 539 | echo -e "chapter6: chapter5 $chapter6\n" >> $MKFILE
|
---|
[0bad6ba] | 540 |
|
---|
| 541 | # Clean targets
|
---|
[0209bb7] | 542 | echo "clean-all: clean" >> $MKFILE
|
---|
[e3e1db0] | 543 | echo -e "\trm -rf ./*\n" >> $MKFILE
|
---|
[0209bb7] | 544 |
|
---|
| 545 | echo -e "clean: clean-chapter5 clean-chapter4\n" >> $MKFILE
|
---|
[44f88e3] | 546 |
|
---|
[0bad6ba] | 547 | echo "clean-chapter4:" >> $MKFILE
|
---|
[0209bb7] | 548 | echo -e "\t-userdel lfs" >> $MKFILE
|
---|
[e3e1db0] | 549 | echo -e "\trm -rf /home/lfs" >> $MKFILE
|
---|
| 550 | echo -e "\trm -rf \$(LFS)/tools" >> $MKFILE
|
---|
| 551 | echo -e "\trm -f /tools" >> $MKFILE
|
---|
| 552 | echo -e "\trm -f envars" >> $MKFILE
|
---|
| 553 | echo -e "\trm -f 02* logs/02*.log\n" >> $MKFILE
|
---|
[44f88e3] | 554 |
|
---|
| 555 | echo "clean-chapter5:" >> $MKFILE
|
---|
[e3e1db0] | 556 | echo -e "\trm -rf \$(LFS)/tools/*" >> $MKFILE
|
---|
| 557 | echo -e "\trm -f envars" >> $MKFILE
|
---|
| 558 | echo -e "\trm -f $chapter5" >> $MKFILE
|
---|
| 559 | echo -e "\tcd logs && rm -f $chapter5 && cd ..\n" >> $MKFILE
|
---|
[0bad6ba] | 560 |
|
---|
[732d1f1] | 561 | # The chapter4 sub-targets are hard-coded to create the lfs user,
|
---|
| 562 | # to make the scripts executable, and to create a clean environment
|
---|
[44f88e3] | 563 | # for the lfs user.
|
---|
[0bad6ba] | 564 | echo "020-creatingtoolsdir:" >> $MKFILE
|
---|
[0fc4c75] | 565 | echo -e "\t@\$(call echo_message, Building)" >> $MKFILE
|
---|
| 566 | echo -e "\t@mkdir -v \$(LFS)/tools && \\" >> $MKFILE
|
---|
[a5e49c6] | 567 | echo -e "\tln -sv \$(LFS)/tools / && \\" >> $MKFILE
|
---|
[0bad6ba] | 568 | echo -e "\ttouch \$@\n" >> $MKFILE
|
---|
| 569 |
|
---|
[e909d9d] | 570 | echo "021-addinguser: 020-creatingtoolsdir" >> $MKFILE
|
---|
[0fc4c75] | 571 | echo -e "\t@\$(call echo_message, Building)" >> $MKFILE
|
---|
| 572 | echo -e "\t@groupadd lfs && \\" >> $MKFILE
|
---|
[0bad6ba] | 573 | echo -e "\tuseradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\" >> $MKFILE
|
---|
| 574 | echo -e "\tchown lfs \$(LFS)/tools && \\" >> $MKFILE
|
---|
| 575 | echo -e "\tchown lfs \$(LFS)/sources && \\" >> $MKFILE
|
---|
[732d1f1] | 576 | # Make the scripts executable
|
---|
[0bad6ba] | 577 | echo -e "\tchmod -R +x $JHALFSDIR/commands && \\" >> $MKFILE
|
---|
| 578 | echo -e "\ttouch \$@\n" >> $MKFILE
|
---|
| 579 |
|
---|
[e909d9d] | 580 | echo "022-settingenvironment: 021-addinguser" >> $MKFILE
|
---|
[0fc4c75] | 581 | echo -e "\t@\$(call echo_message, Building)" >> $MKFILE
|
---|
| 582 | echo -e "\t@echo \"exec env -i HOME=\\\$\$HOME TERM=\\\$\$TERM PS1='\u:\w\$$ ' /bin/bash\" > /home/lfs/.bash_profile && \\" >> $MKFILE
|
---|
[0bad6ba] | 583 | echo -e "\techo \"set +h\" > /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 584 | echo -e "\techo \"umask 022\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 585 | echo -e "\techo \"LFS=/mnt/lfs\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 586 | echo -e "\techo \"LC_ALL=POSIX\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 587 | echo -e "\techo \"PATH=/tools/bin:/bin:/usr/bin\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 588 | echo -e "\techo \"export LFS LC_ALL PATH\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
[44f88e3] | 589 | # Source the file where we place changing variables.
|
---|
| 590 | echo -e "\techo \". $JHALFSDIR/envars\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
[88dcce5] | 591 | echo -e "\tchown lfs:lfs /home/lfs/.bash* && \\" >> $MKFILE
|
---|
[44f88e3] | 592 | echo -e "\ttouch envars && \\" >> $MKFILE
|
---|
[88dcce5] | 593 | echo -e "\ttouch \$@" >> $MKFILE
|
---|
[0bad6ba] | 594 |
|
---|
[9e406b5] | 595 | # Bring over the items from the Makefile.tmp
|
---|
| 596 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 597 | rm $MKFILE.tmp
|
---|
| 598 | echo -ne "done\n"
|
---|
[f8de156] | 599 | }
|
---|
| 600 |
|
---|
[88dcce5] | 601 | run_make() {
|
---|
[d310939] | 602 | # Test if make must be run.
|
---|
| 603 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
| 604 | # Build the system
|
---|
| 605 | if [ -e $MKFILE ] ; then
|
---|
[e3e1db0] | 606 | echo -ne "Building the LFS system...\n"
|
---|
[d310939] | 607 | cd $JHALFSDIR && make
|
---|
| 608 | echo -ne "done\n"
|
---|
| 609 | fi
|
---|
[88dcce5] | 610 | fi
|
---|
| 611 | }
|
---|
[1236262] | 612 |
|
---|
[4dafc45] | 613 | if [ ! -d $JHALFSDIR ] ; then
|
---|
[557fe91] | 614 | mkdir -p $JHALFSDIR
|
---|
[1236262] | 615 | fi
|
---|
| 616 |
|
---|
[97a3ffc] | 617 | if [ ! -d $BUILDDIR$LOGDIR ] ; then
|
---|
| 618 | mkdir $BUILDDIR$LOGDIR
|
---|
[a5e49c6] | 619 | fi
|
---|
| 620 |
|
---|
[97a3ffc] | 621 | >$BUILDDIR$LOGDIR/$LOG
|
---|
[409488e] | 622 |
|
---|
| 623 | if [ "$PWD" != "$JHALFSDIR" ] ; then
|
---|
[0fc4c75] | 624 | cp $0 $XSL $FNC $JHALFSDIR/
|
---|
[409488e] | 625 | fi
|
---|
| 626 |
|
---|
[1236262] | 627 | get_book
|
---|
[f8de156] | 628 | build_Makefile
|
---|
[71642ef] | 629 | run_make
|
---|