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