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