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