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