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