[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
|
---|
[a5e49c6] | 128 | LOGDIR=$JHALFSDIR/logs
|
---|
| 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
|
---|
[a5e49c6] | 159 | svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
---|
[557fe91] | 160 | else
|
---|
[a5e49c6] | 161 | svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$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/ \
|
---|
[a5e49c6] | 180 | $XSL lfs-$LFSVRS/index.xml >>$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 |
|
---|
[d310939] | 320 | # Dump the path to the Binutils or TCL sources directory.
|
---|
| 321 | if [ "$i" = "027-binutils-pass1" -o "$i" = "032-tcl" -o "$i" = "036-binutils-pass2" ] ; then
|
---|
[71642ef] | 322 | echo -e "\techo \"\$(LFS)\$(SRC)/\$\$ROOT\" > sources-dir && \\" >> $MKFILE.tmp
|
---|
| 323 | fi
|
---|
[88dcce5] | 324 |
|
---|
[71642ef] | 325 | # Inser date and disk usage at the top of the log file.
|
---|
| 326 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >\$(LOGDIR)/$i && \\" >> $MKFILE.tmp
|
---|
[88dcce5] | 327 |
|
---|
[71642ef] | 328 | # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 329 | if [ "$i" = "031-adjusting" ] ; then
|
---|
[d310939] | 330 | echo -e "\techo \"PKGDIR=\$(LFS)\$(SRC)/binutils-build\" > envars && \\" >> $MKFILE.tmp
|
---|
[71642ef] | 331 | echo -e "\techo \"export PKGDIR\" >> envars && \\" >> $MKFILE.tmp
|
---|
| 332 | fi
|
---|
[0209bb7] | 333 |
|
---|
[71642ef] | 334 | # For the Exp0ect build we need to set the TCLPATH envar.
|
---|
| 335 | if [ "$i" = "033-expect" ] ; then
|
---|
| 336 | echo -e "\techo \"TCLPATH=\`cat sources-dir\`\" >> envars && \\" >> $MKFILE.tmp
|
---|
| 337 | echo -e "\techo \"export TCLPATH\" >> envars && \\" >> $MKFILE.tmp
|
---|
| 338 | fi
|
---|
[557fe91] | 339 |
|
---|
[71642ef] | 340 | # Insert the script run
|
---|
| 341 | echo -e "\tsu - lfs -c \". /home/lfs/.bashrc && $JHALFSDIR/commands/$file\" >>\$(LOGDIR)/$i 2>&1 && \\" >> $MKFILE.tmp
|
---|
| 342 |
|
---|
| 343 | # Inser date and disk usage at the bottom of the log file.
|
---|
| 344 | echo -e "\techo -e \"\\\n\`date\`\\\n\\\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\\\n\" >>\$(LOGDIR)/$i && \\" >> $MKFILE.tmp
|
---|
| 345 |
|
---|
| 346 | # Include a touch of the target name so make can check
|
---|
| 347 | # if it's already been made.
|
---|
| 348 | echo -e "\ttouch \$@" >> $MKFILE.tmp
|
---|
| 349 |
|
---|
| 350 | # Remove the build directory(ies) even if the package build fails, except for
|
---|
[d310939] | 351 | # Binutils and TCL. In that cases the sources directories are removed
|
---|
[71642ef] | 352 | # only if the build fails.
|
---|
| 353 | if [ "$vrs" != "" ] ; then
|
---|
[d310939] | 354 | if [ "$i" != "027-binutils-pass1" ] && [ "$i" != "032-tcl" ] && [ "$i" != "036-binutils-pass2" ] ; then
|
---|
[71642ef] | 355 | echo -e "\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
| 356 | echo -e "\trm -r \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
[d310939] | 357 | echo -e "\tif [ -e \$(LFS)\$(SRC)/$name-build ]; then \\" >> $MKFILE.tmp
|
---|
| 358 | echo -e "\t\trm -r \$(LFS)\$(SRC)/$name-build; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 359 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 360 | fi
|
---|
| 361 | fi
|
---|
[d310939] | 362 | if [ "$i" = "027-binutils-pass1" -o "$i" = "036-binutils-pass2" ] ; then
|
---|
[71642ef] | 363 | echo -e "\tif [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
| 364 | echo -e "\t\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
| 365 | echo -e "\t\trm -r \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
|
---|
[d310939] | 366 | echo -e "\t\trm -r \$(LFS)\$(SRC)/binutils-build; \\" >> $MKFILE.tmp
|
---|
| 367 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 368 | fi
|
---|
| 369 | if [ "$i" = "032-tcl" ] ; then
|
---|
| 370 | echo -e "\tif [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
| 371 | echo -e "\t\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
|
---|
| 372 | echo -e "\t\trm -r \$(LFS)\$(SRC)/\$\$ROOT; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 373 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 374 | fi
|
---|
[44f88e3] | 375 |
|
---|
[d310939] | 376 | # Remove the Binutils pass 1 sources after a sucessfull Adjusting phase.
|
---|
[71642ef] | 377 | if [ "$i" = "031-adjusting" ] ; then
|
---|
| 378 | echo -e "\tif [ -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
| 379 | echo -e "\t\trm -r \`cat sources-dir\` && \\" >> $MKFILE.tmp
|
---|
[d310939] | 380 | echo -e "\t\trm -r \$(LFS)\$(SRC)/binutils-build && \\" >> $MKFILE.tmp
|
---|
| 381 | echo -e "\t\trm sources-dir; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 382 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 383 | fi
|
---|
[0209bb7] | 384 |
|
---|
[71642ef] | 385 | # Remove the TCL sources after a sucessfull Expect build.
|
---|
| 386 | if [ "$i" = "033-expect" ] ; then
|
---|
| 387 | echo -e "\tif [ -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
| 388 | echo -e "\t\trm -r \`cat sources-dir\` && \\" >> $MKFILE.tmp
|
---|
[d310939] | 389 | echo -e "\t\trm sources-dir; \\" >> $MKFILE.tmp
|
---|
[71642ef] | 390 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
| 391 | fi
|
---|
[a5e49c6] | 392 |
|
---|
[71642ef] | 393 | # Check if the package has been sucessfully build.
|
---|
| 394 | echo -e "\tif [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
|
---|
| 395 | echo -e "\t\techo \"The build of \$@ has failed\" && exit 1; \\" >> $MKFILE.tmp
|
---|
| 396 | echo -e "\tfi;" >> $MKFILE.tmp
|
---|
[e909d9d] | 397 |
|
---|
| 398 | # Keep the script file name for Makefile dependencies.
|
---|
| 399 | PREV=$i
|
---|
[f8de156] | 400 | done
|
---|
[9e406b5] | 401 |
|
---|
[a5e49c6] | 402 | # Stick variables and some defines at the top of the real makefile
|
---|
[9e406b5] | 403 | echo "export SRC := /sources" > $MKFILE
|
---|
| 404 | echo "export LFS := $BUILDDIR" >> $MKFILE
|
---|
[a5e49c6] | 405 | echo -e "export LOGDIR := $LOGDIR\n" >> $MKFILE
|
---|
[0bad6ba] | 406 | echo "define unpack-lfs" >> $MKFILE
|
---|
| 407 | echo -e "\t@cd \$(LFS)\$(SRC) ; tar -xvjf \$(1) > /tmp/unpacked" >> $MKFILE
|
---|
| 408 | echo -e "endef\n" >> $MKFILE
|
---|
[9e406b5] | 409 | echo "define unpack" >> $MKFILE
|
---|
| 410 | echo -e "\t@cd \$(SRC) ; tar -xvf \$(1) > /tmp/unpacked" >> $MKFILE
|
---|
| 411 | echo -e "endef\n" >> $MKFILE
|
---|
| 412 |
|
---|
[0bad6ba] | 413 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 414 | # as a dependency.
|
---|
| 415 | echo -e "all: chapter4 chapter5\n" >> $MKFILE
|
---|
| 416 | echo -e "chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment\n" >> $MKFILE
|
---|
[0209bb7] | 417 | echo -e "chapter5: chapter4 $chapter5\n" >> $MKFILE
|
---|
[0bad6ba] | 418 |
|
---|
| 419 | # Clean targets
|
---|
[0209bb7] | 420 | echo "clean-all: clean" >> $MKFILE
|
---|
| 421 | echo -e "\trm -rfv ./*\n" >> $MKFILE
|
---|
| 422 |
|
---|
| 423 | echo -e "clean: clean-chapter5 clean-chapter4\n" >> $MKFILE
|
---|
[44f88e3] | 424 |
|
---|
[0bad6ba] | 425 | echo "clean-chapter4:" >> $MKFILE
|
---|
[0209bb7] | 426 | echo -e "\t-userdel lfs" >> $MKFILE
|
---|
| 427 | echo -e "\trm -rfv /home/lfs" >> $MKFILE
|
---|
| 428 | echo -e "\trm -rfv \$(LFS)/tools" >> $MKFILE
|
---|
| 429 | echo -e "\trm -fv /tools" >> $MKFILE
|
---|
| 430 | echo -e "\trm -fv envars" >> $MKFILE
|
---|
| 431 | echo -e "\trm -fv 02* logs/02*.log\n" >> $MKFILE
|
---|
[44f88e3] | 432 |
|
---|
| 433 | echo "clean-chapter5:" >> $MKFILE
|
---|
[0209bb7] | 434 | echo -e "\trm -rfv \$(LFS)/tools/*" >> $MKFILE
|
---|
| 435 | echo -e "\trm -fv envars" >> $MKFILE
|
---|
| 436 | echo -e "\trm -fv $chapter5" >> $MKFILE
|
---|
| 437 | echo -e "\tcd logs && rm -fv $chapter5 && cd ..\n" >> $MKFILE
|
---|
[0bad6ba] | 438 |
|
---|
[44f88e3] | 439 | # The chapter4 sub-targets are hard-coded to can create the lfs user,
|
---|
| 440 | # to make the scripts executables, and to create a clean environment
|
---|
| 441 | # for the lfs user.
|
---|
[0bad6ba] | 442 | echo "020-creatingtoolsdir:" >> $MKFILE
|
---|
[a5e49c6] | 443 | echo -e "\tmkdir -v \$(LFS)/tools && \\" >> $MKFILE
|
---|
| 444 | echo -e "\tln -sv \$(LFS)/tools / && \\" >> $MKFILE
|
---|
[0bad6ba] | 445 | echo -e "\ttouch \$@\n" >> $MKFILE
|
---|
| 446 |
|
---|
[e909d9d] | 447 | echo "021-addinguser: 020-creatingtoolsdir" >> $MKFILE
|
---|
[0bad6ba] | 448 | echo -e "\tgroupadd lfs && \\" >> $MKFILE
|
---|
| 449 | echo -e "\tuseradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\" >> $MKFILE
|
---|
| 450 | echo -e "\tchown lfs \$(LFS)/tools && \\" >> $MKFILE
|
---|
| 451 | echo -e "\tchown lfs \$(LFS)/sources && \\" >> $MKFILE
|
---|
| 452 | # Make the scripts executables
|
---|
| 453 | echo -e "\tchmod -R +x $JHALFSDIR/commands && \\" >> $MKFILE
|
---|
| 454 | echo -e "\ttouch \$@\n" >> $MKFILE
|
---|
| 455 |
|
---|
[e909d9d] | 456 | echo "022-settingenvironment: 021-addinguser" >> $MKFILE
|
---|
[0bad6ba] | 457 | echo -e "\techo \"exec env -i HOME=\\\$\$HOME TERM=\\\$\$TERM PS1='\u:\w\$$ ' /bin/bash\" > /home/lfs/.bash_profile && \\" >> $MKFILE
|
---|
| 458 | echo -e "\techo \"set +h\" > /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 459 | echo -e "\techo \"umask 022\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 460 | echo -e "\techo \"LFS=/mnt/lfs\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 461 | echo -e "\techo \"LC_ALL=POSIX\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 462 | echo -e "\techo \"PATH=/tools/bin:/bin:/usr/bin\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
| 463 | echo -e "\techo \"export LFS LC_ALL PATH\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
[44f88e3] | 464 | # Source the file where we place changing variables.
|
---|
| 465 | echo -e "\techo \". $JHALFSDIR/envars\" >> /home/lfs/.bashrc && \\" >> $MKFILE
|
---|
[88dcce5] | 466 | echo -e "\tchown lfs:lfs /home/lfs/.bash* && \\" >> $MKFILE
|
---|
[44f88e3] | 467 | echo -e "\ttouch envars && \\" >> $MKFILE
|
---|
[88dcce5] | 468 | echo -e "\ttouch \$@" >> $MKFILE
|
---|
[0bad6ba] | 469 |
|
---|
[9e406b5] | 470 | # Bring over the items from the Makefile.tmp
|
---|
| 471 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 472 | rm $MKFILE.tmp
|
---|
| 473 | echo -ne "done\n"
|
---|
[f8de156] | 474 | }
|
---|
| 475 |
|
---|
[88dcce5] | 476 | run_make() {
|
---|
[d310939] | 477 | # Test if make must be run.
|
---|
| 478 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
| 479 | # Build the system
|
---|
| 480 | if [ -e $MKFILE ] ; then
|
---|
| 481 | echo -ne "Building the LFS system\n"
|
---|
| 482 | cd $JHALFSDIR && make
|
---|
| 483 | echo -ne "done\n"
|
---|
| 484 | fi
|
---|
[88dcce5] | 485 | fi
|
---|
| 486 | }
|
---|
[1236262] | 487 |
|
---|
[4dafc45] | 488 | if [ ! -d $JHALFSDIR ] ; then
|
---|
[557fe91] | 489 | mkdir -p $JHALFSDIR
|
---|
[1236262] | 490 | fi
|
---|
| 491 |
|
---|
[a5e49c6] | 492 | if [ ! -d $LOGDIR ] ; then
|
---|
| 493 | mkdir $LOGDIR
|
---|
| 494 | fi
|
---|
| 495 |
|
---|
| 496 | >$LOGDIR/$LOG
|
---|
[409488e] | 497 |
|
---|
| 498 | if [ "$PWD" != "$JHALFSDIR" ] ; then
|
---|
| 499 | cp $0 $XSL $JHALFSDIR/
|
---|
| 500 | fi
|
---|
| 501 |
|
---|
[1236262] | 502 | get_book
|
---|
[f8de156] | 503 | build_Makefile
|
---|
[71642ef] | 504 | run_make
|
---|