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