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