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