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