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