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