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