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