[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 |
|
---|
[abe936d] | 423 | # Should be handled inside xsl script
|
---|
| 424 | if [[ `_IS_ $i adjusting` ]]; then
|
---|
| 425 | sed '/cd $PKGDIR/d' -i chapter05/$i
|
---|
| 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
|
---|
[0fc4c75] | 472 |
|
---|
[71642ef] | 473 | fi
|
---|
[557fe91] | 474 |
|
---|
[3f990d1] | 475 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 476 | # and date and disk usage again at the bottom of the log file.
|
---|
| 477 | (
|
---|
| 478 | cat << EOF
|
---|
[43757c2] | 479 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
[3f990d1] | 480 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
|
---|
[43757c2] | 481 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
[3f990d1] | 482 | EOF
|
---|
| 483 | ) >> $MKFILE.tmp
|
---|
[71642ef] | 484 |
|
---|
[cf7f294] | 485 | # Remove the build directory(ies) except if the package build fails
|
---|
[9349479] | 486 | # (so we can review config.cache, config.log, etc.)
|
---|
| 487 | # For Binutils the sources must be retained for some time.
|
---|
[71642ef] | 488 | if [ "$vrs" != "" ] ; then
|
---|
[3f990d1] | 489 | (
|
---|
| 490 | cat << EOF
|
---|
[eaa021a] | 491 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[3f990d1] | 492 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
| 493 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
| 494 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
| 495 | fi;
|
---|
| 496 | EOF
|
---|
| 497 | ) >> $MKFILE.tmp
|
---|
[7bbd436] | 498 | fi
|
---|
| 499 |
|
---|
| 500 | # Include a touch of the target name so make can check
|
---|
| 501 | # if it's already been made.
|
---|
[3f990d1] | 502 | (
|
---|
| 503 | cat << EOF
|
---|
| 504 | @touch \$@
|
---|
| 505 | EOF
|
---|
| 506 | ) >> $MKFILE.tmp
|
---|
[7bbd436] | 507 |
|
---|
[e909d9d] | 508 | # Keep the script file name for Makefile dependencies.
|
---|
| 509 | PREV=$i
|
---|
[49aea5e] | 510 | done # end for file in chapter05/*
|
---|
| 511 | }
|
---|
[9e406b5] | 512 |
|
---|
[49aea5e] | 513 | #----------------------------#
|
---|
| 514 | chapter6_Makefiles() {
|
---|
| 515 | #----------------------------#
|
---|
[97a3ffc] | 516 | for file in chapter06/* ; do
|
---|
| 517 | # Keep the script file name
|
---|
| 518 | i=`basename $file`
|
---|
| 519 |
|
---|
[16c67ed] | 520 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 521 | # dependencies and target creation.
|
---|
[e1093cd] | 522 | if [[ `_IS_ $i chroot` ]] ; then
|
---|
[16c67ed] | 523 | continue
|
---|
| 524 | fi
|
---|
| 525 |
|
---|
[70a223e] | 526 | # Test if the stripping phase must be skipped
|
---|
| 527 | if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
---|
| 528 | continue
|
---|
| 529 | fi
|
---|
| 530 |
|
---|
[abe936d] | 531 | # Should be handled by xsl script
|
---|
| 532 | if [[ `_IS_ $i adjusting` ]]; then
|
---|
| 533 | sed '/cd $PKGDIR/d' -i chapter06/$i
|
---|
| 534 | fi
|
---|
| 535 |
|
---|
[97a3ffc] | 536 | # First append each name of the script files to a list (this will become
|
---|
| 537 | # the names of the targets in the Makefile
|
---|
| 538 | chapter6="$chapter6 $i"
|
---|
| 539 |
|
---|
| 540 | # Grab the name of the target
|
---|
| 541 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 542 |
|
---|
| 543 | # Drop in the name of the target on a new line, and the previous target
|
---|
[4c62c61] | 544 | # as a dependency. Also call the echo_message function.
|
---|
[3f990d1] | 545 | (
|
---|
| 546 | cat << EOF
|
---|
| 547 |
|
---|
| 548 | $i: $PREV
|
---|
| 549 | @\$(call echo_message, Building)
|
---|
| 550 | EOF
|
---|
| 551 | ) >> $MKFILE.tmp
|
---|
[97a3ffc] | 552 |
|
---|
| 553 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 554 | # a specific package
|
---|
| 555 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 556 |
|
---|
| 557 | # If $vrs isn't empty, we've got a package...
|
---|
[3f990d1] | 558 | # Insert instructions for unpacking the package and changing directories
|
---|
[97a3ffc] | 559 | if [ "$vrs" != "" ] ; then
|
---|
[be9970b] | 560 | FILE="$name-$vrs.tar.*"
|
---|
[3f990d1] | 561 | (
|
---|
| 562 | cat << EOF
|
---|
[be9970b] | 563 | @\$(call unpack2,$FILE)
|
---|
[eaa021a] | 564 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[3f990d1] | 565 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
[2e51f44] | 566 | echo "export PKGDIR" >> envars
|
---|
[3f990d1] | 567 | EOF
|
---|
| 568 | ) >> $MKFILE.tmp
|
---|
[97a3ffc] | 569 | fi
|
---|
| 570 |
|
---|
[2a54650] | 571 | # For Glibc we need to set TIMEZONE envar.
|
---|
[abe936d] | 572 | if [[ `_IS_ $i glibc` ]] ; then
|
---|
[2a54650] | 573 | (
|
---|
| 574 | cat << EOF
|
---|
| 575 | @echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
|
---|
| 576 | echo "export TIMEZONE" >> envars
|
---|
| 577 | EOF
|
---|
| 578 | ) >> $MKFILE.tmp
|
---|
| 579 |
|
---|
[a41ce58] | 580 | # For Groff we need to set PAGE envar.
|
---|
[e1093cd] | 581 | elif [[ `_IS_ $i groff` ]] ; then
|
---|
[a41ce58] | 582 | (
|
---|
| 583 | cat << EOF
|
---|
| 584 | @echo "PAGE=\$(PAGE)" >> envars && \\
|
---|
| 585 | echo "export PAGE" >> envars
|
---|
| 586 | EOF
|
---|
| 587 | ) >> $MKFILE.tmp
|
---|
| 588 | fi
|
---|
| 589 |
|
---|
[50408d5] | 590 | # In the mount of kernel filesystems we need to set LFS
|
---|
[80c00fc] | 591 | # and not to use chroot.
|
---|
[e1093cd] | 592 | if [[ `_IS_ $i kernfs` ]] ; then
|
---|
[3f990d1] | 593 | (
|
---|
| 594 | cat << EOF
|
---|
[43757c2] | 595 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
[b51d2ec] | 596 | export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
|
---|
[43757c2] | 597 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
[3f990d1] | 598 | EOF
|
---|
[a7d20b8] | 599 | ) >> $MKFILE.tmp
|
---|
| 600 |
|
---|
| 601 | # The rest of Chapter06
|
---|
[7ecd166] | 602 | else
|
---|
[3f990d1] | 603 | (
|
---|
| 604 | cat << EOF
|
---|
[43757c2] | 605 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
[2e51f44] | 606 | \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
[43757c2] | 607 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
[3f990d1] | 608 | EOF
|
---|
| 609 | ) >> $MKFILE.tmp
|
---|
[7ecd166] | 610 | fi
|
---|
[97a3ffc] | 611 |
|
---|
[cf7f294] | 612 | # Remove the build directory(ies) except if the package build fails.
|
---|
[97a3ffc] | 613 | if [ "$vrs" != "" ] ; then
|
---|
[3f990d1] | 614 | (
|
---|
| 615 | cat << EOF
|
---|
[eaa021a] | 616 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[3f990d1] | 617 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
| 618 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
| 619 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
| 620 | fi;
|
---|
| 621 | EOF
|
---|
| 622 | ) >> $MKFILE.tmp
|
---|
[97a3ffc] | 623 | fi
|
---|
| 624 |
|
---|
[732d1f1] | 625 | # Include a touch of the target name so make can check
|
---|
| 626 | # if it's already been made.
|
---|
[3f990d1] | 627 | (
|
---|
| 628 | cat << EOF
|
---|
| 629 | @touch \$@
|
---|
| 630 | EOF
|
---|
| 631 | ) >> $MKFILE.tmp
|
---|
[732d1f1] | 632 |
|
---|
[97a3ffc] | 633 | # Keep the script file name for Makefile dependencies.
|
---|
| 634 | PREV=$i
|
---|
[49aea5e] | 635 | done # end for file in chapter06/*
|
---|
| 636 | }
|
---|
[97a3ffc] | 637 |
|
---|
[49aea5e] | 638 | #----------------------------#
|
---|
| 639 | chapter789_Makefiles() {
|
---|
| 640 | #----------------------------#
|
---|
[cf7f294] | 641 | for file in chapter0{7,8,9}/* ; do
|
---|
| 642 | # Keep the script file name
|
---|
| 643 | i=`basename $file`
|
---|
| 644 |
|
---|
[e1093cd] | 645 | # Grub must be configured manually.
|
---|
| 646 | # The filesystems can't be unmounted via Makefile and the user
|
---|
[ff4cb2e] | 647 | # should enter the chroot environment to create the root
|
---|
| 648 | # password, edit several files and setup Grub.
|
---|
[e1093cd] | 649 | if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
|
---|
[83f64dc] | 650 | continue
|
---|
[cf7f294] | 651 | fi
|
---|
| 652 |
|
---|
| 653 | # If no .config file is supplied, the kernel build is skipped
|
---|
[e1093cd] | 654 | if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
|
---|
| 655 | continue
|
---|
[cf7f294] | 656 | fi
|
---|
| 657 |
|
---|
| 658 | # First append each name of the script files to a list (this will become
|
---|
| 659 | # the names of the targets in the Makefile
|
---|
| 660 | chapter789="$chapter789 $i"
|
---|
| 661 |
|
---|
| 662 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 663 | # as a dependency. Also call the echo_message function.
|
---|
| 664 | (
|
---|
| 665 | cat << EOF
|
---|
| 666 |
|
---|
| 667 | $i: $PREV
|
---|
| 668 | @\$(call echo_message, Building)
|
---|
| 669 | EOF
|
---|
| 670 | ) >> $MKFILE.tmp
|
---|
| 671 |
|
---|
[ff4cb2e] | 672 | # Find the bootscripts and kernel package names
|
---|
[e1093cd] | 673 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
| 674 | if [[ `_IS_ $i bootscripts` ]] ; then
|
---|
[cf7f294] | 675 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
[be9970b] | 676 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
[e1093cd] | 677 | elif [[ `_IS_ $i kernel` ]] ; then
|
---|
[cf7f294] | 678 | vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
[be9970b] | 679 | FILE="linux-$vrs.tar.*"
|
---|
[cf7f294] | 680 | fi
|
---|
| 681 | (
|
---|
| 682 | cat << EOF
|
---|
[be9970b] | 683 | @\$(call unpack2,$FILE)
|
---|
[cf7f294] | 684 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
| 685 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
| 686 | echo "export PKGDIR" >> envars
|
---|
| 687 | EOF
|
---|
| 688 | ) >> $MKFILE.tmp
|
---|
| 689 | fi
|
---|
[50408d5] | 690 |
|
---|
[cf7f294] | 691 | # Put in place the kernel .config file
|
---|
[e1093cd] | 692 | if [[ `_IS_ $i kernel` ]] ; then
|
---|
[cf7f294] | 693 | (
|
---|
| 694 | cat << EOF
|
---|
[f0f60d0] | 695 | @cp $CONFIG \$(LFS)/sources/kernel-config
|
---|
[cf7f294] | 696 | EOF
|
---|
| 697 | ) >> $MKFILE.tmp
|
---|
| 698 | fi
|
---|
| 699 |
|
---|
[50408d5] | 700 | # Check if we have a real /etc/fstab file
|
---|
[e1093cd] | 701 | if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
[50408d5] | 702 | (
|
---|
| 703 | cat << EOF
|
---|
[43757c2] | 704 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
[50408d5] | 705 | cp -v $FSTAB \$(LFS)/etc/fstab >>logs/$i 2>&1 && \\
|
---|
[43757c2] | 706 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
[50408d5] | 707 | EOF
|
---|
| 708 | ) >> $MKFILE.tmp
|
---|
| 709 | else
|
---|
[ff4cb2e] | 710 | # Initialize the log and run the script
|
---|
[cf7f294] | 711 | (
|
---|
| 712 | cat << EOF
|
---|
[43757c2] | 713 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
[cf7f294] | 714 | \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
[43757c2] | 715 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
[cf7f294] | 716 | EOF
|
---|
| 717 | ) >> $MKFILE.tmp
|
---|
[50408d5] | 718 | fi
|
---|
[cf7f294] | 719 |
|
---|
| 720 | # Remove the build directory except if the package build fails.
|
---|
[e1093cd] | 721 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
[cf7f294] | 722 | (
|
---|
| 723 | cat << EOF
|
---|
| 724 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[50408d5] | 725 | rm -r \$(LFS)\$(SRC)/\$\$ROOT
|
---|
[cf7f294] | 726 | EOF
|
---|
| 727 | ) >> $MKFILE.tmp
|
---|
| 728 | fi
|
---|
| 729 |
|
---|
| 730 | # Include a touch of the target name so make can check
|
---|
| 731 | # if it's already been made.
|
---|
| 732 | (
|
---|
| 733 | cat << EOF
|
---|
| 734 | @touch \$@
|
---|
| 735 | EOF
|
---|
| 736 | ) >> $MKFILE.tmp
|
---|
| 737 |
|
---|
| 738 | # Keep the script file name for Makefile dependencies.
|
---|
| 739 | PREV=$i
|
---|
[49aea5e] | 740 | done # for file in chapter0{7,8,9}/*
|
---|
[7ced71e] | 741 | }
|
---|
[49aea5e] | 742 |
|
---|
| 743 |
|
---|
| 744 | #----------------------------#
|
---|
| 745 | build_Makefile() {
|
---|
| 746 | #----------------------------#
|
---|
| 747 | echo -n "Creating Makefile... "
|
---|
| 748 | cd $JHALFSDIR/commands
|
---|
| 749 |
|
---|
| 750 | # Start with a clean Makefile.tmp file
|
---|
| 751 | >$MKFILE.tmp
|
---|
| 752 |
|
---|
| 753 | chapter4_Makefiles
|
---|
| 754 | chapter5_Makefiles
|
---|
[7ced71e] | 755 | chapter6_Makefiles
|
---|
| 756 | chapter789_Makefiles
|
---|
[49aea5e] | 757 |
|
---|
[cf7f294] | 758 |
|
---|
[3f990d1] | 759 | # Add a header, some variables and include the function file
|
---|
| 760 | # to the top of the real Makefile.
|
---|
| 761 | (
|
---|
| 762 | cat << EOF
|
---|
| 763 | $HEADER
|
---|
| 764 |
|
---|
| 765 | SRC= /sources
|
---|
| 766 | LFS= $BUILDDIR
|
---|
[a41ce58] | 767 | PAGE= $PAGE
|
---|
[2a54650] | 768 | TIMEZONE= $TIMEZONE
|
---|
[3f990d1] | 769 |
|
---|
| 770 | include functions
|
---|
| 771 |
|
---|
| 772 | EOF
|
---|
| 773 | ) > $MKFILE
|
---|
[8bb92e7] | 774 |
|
---|
[c08d23b] | 775 |
|
---|
| 776 | # Add chroot commands
|
---|
| 777 | i=1
|
---|
| 778 | for file in chapter06/*chroot* ; do
|
---|
| 779 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
---|
[49aea5e] | 780 | -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
---|
| 781 | -e 's|"$$LFS"|$(LFS)|' -e 's|set -e||'`
|
---|
[d7fd195] | 782 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
[c08d23b] | 783 | i=`expr $i + 1`
|
---|
| 784 | done
|
---|
[9e406b5] | 785 |
|
---|
[0bad6ba] | 786 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 787 | # as a dependency.
|
---|
[3f990d1] | 788 | (
|
---|
| 789 | cat << EOF
|
---|
[cf7f294] | 790 | all: chapter4 chapter5 chapter6 chapter789
|
---|
[898f47a] | 791 | @\$(call echo_finished,$VERSION)
|
---|
[3f990d1] | 792 |
|
---|
| 793 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
| 794 |
|
---|
[8ebf154] | 795 | chapter5: chapter4 $chapter5 restore-lfs-env
|
---|
[3f990d1] | 796 |
|
---|
| 797 | chapter6: chapter5 $chapter6
|
---|
| 798 |
|
---|
[cf7f294] | 799 | chapter789: chapter6 $chapter789
|
---|
| 800 |
|
---|
[3f990d1] | 801 | clean-all: clean
|
---|
[5adc3fd] | 802 | rm -rf ./{commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
---|
[3f990d1] | 803 |
|
---|
[0bd7b91] | 804 | clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
[3f990d1] | 805 |
|
---|
| 806 | clean-chapter4:
|
---|
[5adc3fd] | 807 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 808 | userdel lfs; \\
|
---|
| 809 | rm -rf /home/lfs; \\
|
---|
| 810 | fi;
|
---|
[3f990d1] | 811 | rm -rf \$(LFS)/tools
|
---|
| 812 | rm -f /tools
|
---|
[5adc3fd] | 813 | rm -f envars user-lfs-exist
|
---|
[3f990d1] | 814 | rm -f 02* logs/02*.log
|
---|
| 815 |
|
---|
| 816 | clean-chapter5:
|
---|
| 817 | rm -rf \$(LFS)/tools/*
|
---|
[5adc3fd] | 818 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
[3f990d1] | 819 | cd logs && rm -f $chapter5 && cd ..
|
---|
[7ced71e] | 820 |
|
---|
[0bd7b91] | 821 | clean-chapter6:
|
---|
[3338588] | 822 | -umount \$(LFS)/sys
|
---|
| 823 | -umount \$(LFS)/proc
|
---|
| 824 | -umount \$(LFS)/dev/shm
|
---|
| 825 | -umount \$(LFS)/dev/pts
|
---|
| 826 | -umount \$(LFS)/dev
|
---|
[0bd7b91] | 827 | rm -rf \$(LFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
| 828 | rm -f $chapter6
|
---|
| 829 | cd logs && rm -f $chapter6 && cd ..
|
---|
| 830 |
|
---|
[7ced71e] | 831 | clean-chapter789:
|
---|
[0bd7b91] | 832 | rm -f $chapter789
|
---|
| 833 | cd logs && rm -f $chapter789 && cd ..
|
---|
| 834 |
|
---|
[8ebf154] | 835 | restore-lfs-env:
|
---|
| 836 | @\$(call echo_message, Building)
|
---|
| 837 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
| 838 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
| 839 | fi;
|
---|
| 840 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
| 841 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
| 842 | fi;
|
---|
| 843 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
[ebd1409] | 844 | touch \$@
|
---|
[3f990d1] | 845 |
|
---|
| 846 | EOF
|
---|
| 847 | ) >> $MKFILE
|
---|
[0bad6ba] | 848 |
|
---|
[9e406b5] | 849 | # Bring over the items from the Makefile.tmp
|
---|
| 850 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 851 | rm $MKFILE.tmp
|
---|
| 852 | echo -ne "done\n"
|
---|
[f8de156] | 853 | }
|
---|
| 854 |
|
---|
[49aea5e] | 855 | #----------------------------#
|
---|
[88dcce5] | 856 | run_make() {
|
---|
[49aea5e] | 857 | #----------------------------#
|
---|
[d310939] | 858 | # Test if make must be run.
|
---|
| 859 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
[38150e5] | 860 | # Test to make sure we're running the build as root
|
---|
| 861 | if [ "$UID" != "0" ] ; then
|
---|
| 862 | echo "You must be logged in as root to successfully build LFS."
|
---|
| 863 | exit 1
|
---|
| 864 | fi
|
---|
[d310939] | 865 | # Build the system
|
---|
| 866 | if [ -e $MKFILE ] ; then
|
---|
[e3e1db0] | 867 | echo -ne "Building the LFS system...\n"
|
---|
[d310939] | 868 | cd $JHALFSDIR && make
|
---|
| 869 | echo -ne "done\n"
|
---|
| 870 | fi
|
---|
[88dcce5] | 871 | fi
|
---|
| 872 | }
|
---|
[1236262] | 873 |
|
---|
| 874 |
|
---|
[49aea5e] | 875 |
|
---|
| 876 | ###################################
|
---|
| 877 | ### MAIN ###
|
---|
| 878 | ###################################
|
---|
| 879 |
|
---|
| 880 | # Evaluate any command line switches
|
---|
| 881 |
|
---|
| 882 | while test $# -gt 0 ; do
|
---|
| 883 | case $1 in
|
---|
| 884 | --version | -V )
|
---|
| 885 | echo "$version"
|
---|
| 886 | exit 0
|
---|
| 887 | ;;
|
---|
| 888 |
|
---|
| 889 | --help | -h )
|
---|
| 890 | echo "$usage"
|
---|
| 891 | exit 0
|
---|
| 892 | ;;
|
---|
| 893 |
|
---|
| 894 | --LFS-version | -L )
|
---|
| 895 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 896 | shift
|
---|
| 897 | case $1 in
|
---|
| 898 | dev* | SVN | trunk )
|
---|
| 899 | LFSVRS=development
|
---|
| 900 | ;;
|
---|
[5aa36d5] | 901 |
|
---|
[c506b99] | 902 | 6.1.1 )
|
---|
[e90c0c3] | 903 | echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
---|
| 904 | exit 0
|
---|
[49aea5e] | 905 | ;;
|
---|
[7ced71e] | 906 |
|
---|
[ef94414] | 907 | alpha*)
|
---|
| 908 | LFSVRS=alphabetical
|
---|
| 909 | ;;
|
---|
[5aa36d5] | 910 |
|
---|
| 911 | udev*)
|
---|
| 912 | LFSVRS=udev_update
|
---|
| 913 | ;;
|
---|
| 914 |
|
---|
[49aea5e] | 915 | * )
|
---|
| 916 | echo "$1 is an unsupported version at this time."
|
---|
| 917 | exit 1
|
---|
| 918 | ;;
|
---|
| 919 | esac
|
---|
| 920 | ;;
|
---|
| 921 |
|
---|
| 922 | --directory | -d )
|
---|
| 923 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 924 | shift
|
---|
| 925 | BUILDDIR=$1
|
---|
[911fe33] | 926 | JHALFSDIR=$BUILDDIR/jhalfs
|
---|
| 927 | LOGDIR=$JHALFSDIR/logs
|
---|
| 928 | MKFILE=$JHALFSDIR/Makefile
|
---|
[49aea5e] | 929 | ;;
|
---|
| 930 |
|
---|
[da5860a] | 931 | --rebuild ) CLEAN=1 ;;
|
---|
| 932 |
|
---|
[49aea5e] | 933 | --download-client | -D )
|
---|
| 934 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 935 | shift
|
---|
| 936 | DL=$1
|
---|
| 937 | ;;
|
---|
| 938 |
|
---|
| 939 | --working-copy | -W )
|
---|
| 940 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 941 | shift
|
---|
| 942 | if [ -f $1/patches.ent ] ; then
|
---|
| 943 | WC=1
|
---|
| 944 | BOOK=$1
|
---|
| 945 | else
|
---|
| 946 | echo -e "\nLook like $1 isn't a supported working copy."
|
---|
| 947 | echo -e "Verify your selection and the command line.\n"
|
---|
| 948 | exit 1
|
---|
| 949 | fi
|
---|
| 950 | ;;
|
---|
| 951 |
|
---|
| 952 | --testsuites | -T ) TEST=1 ;;
|
---|
| 953 |
|
---|
| 954 | --get-packages | -P ) HPKG=1 ;;
|
---|
| 955 |
|
---|
| 956 | --run-make | -M ) RUNMAKE=1 ;;
|
---|
| 957 |
|
---|
| 958 | --no-toolchain-test ) TOOLCHAINTEST=0 ;;
|
---|
[db181c47] | 959 |
|
---|
[70a223e] | 960 | --no-strip ) STRIP=0 ;;
|
---|
| 961 |
|
---|
[db181c47] | 962 | --no-vim-lang ) VIMLANG=0 ;;
|
---|
[7ced71e] | 963 |
|
---|
[49aea5e] | 964 | --page_size )
|
---|
| 965 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 966 | shift
|
---|
| 967 | case $1 in
|
---|
| 968 | letter | A4 )
|
---|
| 969 | PAGE=$1
|
---|
| 970 | ;;
|
---|
| 971 | * )
|
---|
| 972 | echo "$1 isn't a supported page size."
|
---|
| 973 | exit 1
|
---|
| 974 | ;;
|
---|
| 975 | esac
|
---|
| 976 | ;;
|
---|
| 977 |
|
---|
| 978 |
|
---|
| 979 | --timezone )
|
---|
| 980 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 981 | shift
|
---|
| 982 | if [ -f /usr/share/zoneinfo/$1 ] ; then
|
---|
| 983 | TIMEZONE=$1
|
---|
| 984 | else
|
---|
[ff4cb2e] | 985 | echo -e "\nLooks like $1 isn't a valid timezone description."
|
---|
[49aea5e] | 986 | echo -e "Verify your selection and the command line.\n"
|
---|
| 987 | exit 1
|
---|
| 988 | fi
|
---|
| 989 | ;;
|
---|
| 990 |
|
---|
| 991 | --fstab )
|
---|
| 992 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 993 | shift
|
---|
| 994 | if [ -f $1 ] ; then
|
---|
| 995 | FSTAB=$1
|
---|
| 996 | else
|
---|
| 997 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
| 998 | exit 1
|
---|
| 999 | fi
|
---|
| 1000 | ;;
|
---|
| 1001 |
|
---|
| 1002 | --kernel-config | -C )
|
---|
| 1003 | test $# = 1 && eval "$exit_missing_arg"
|
---|
| 1004 | shift
|
---|
| 1005 | if [ -f $1 ] ; then
|
---|
| 1006 | CONFIG=$1
|
---|
| 1007 | else
|
---|
| 1008 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
| 1009 | exit 1
|
---|
| 1010 | fi
|
---|
| 1011 | ;;
|
---|
| 1012 |
|
---|
| 1013 | * )
|
---|
| 1014 | echo "$usage"
|
---|
| 1015 | exit 1
|
---|
| 1016 | ;;
|
---|
| 1017 | esac
|
---|
| 1018 | shift
|
---|
| 1019 | done
|
---|
| 1020 |
|
---|
[7ced71e] | 1021 | # Prevents setting "-d /" by mistake.
|
---|
[da5860a] | 1022 |
|
---|
| 1023 | if [ $BUILDDIR = / ] ; then
|
---|
| 1024 | echo -ne "\nThe root directory can't be used to build LFS.\n\n"
|
---|
| 1025 | exit 1
|
---|
| 1026 | fi
|
---|
| 1027 |
|
---|
[ff4cb2e] | 1028 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
[7ced71e] | 1029 | # and notify the user about that.
|
---|
[4618749] | 1030 |
|
---|
[da5860a] | 1031 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
[4618749] | 1032 | eval "$no_empty_builddir"
|
---|
| 1033 | fi
|
---|
| 1034 |
|
---|
[da5860a] | 1035 | # If requested, clean the build directory
|
---|
| 1036 | clean_builddir
|
---|
| 1037 |
|
---|
[e1093cd] | 1038 | # Find the download client to use, if not already specified.
|
---|
| 1039 |
|
---|
| 1040 | if [ -z $DL ] ; then
|
---|
| 1041 | if [ `type -p wget` ] ; then
|
---|
| 1042 | DL=wget
|
---|
| 1043 | elif [ `type -p curl` ] ; then
|
---|
| 1044 | DL=curl
|
---|
| 1045 | else
|
---|
| 1046 | eval "$no_dl_client"
|
---|
| 1047 | fi
|
---|
| 1048 | fi
|
---|
| 1049 |
|
---|
[1136382] | 1050 | if [ -z $BOOK ] ; then
|
---|
| 1051 | BOOK=lfs-$LFSVRS
|
---|
| 1052 | fi
|
---|
| 1053 |
|
---|
[49aea5e] | 1054 | [[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
|
---|
[db181c47] | 1055 | [[ "$PWD" != "$JHALFSDIR" ]] && cp -v $FILES $JHALFSDIR/ && \
|
---|
[1136382] | 1056 | sed 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/dump-lfs-scripts.xsl && \
|
---|
[db181c47] | 1057 | export XSL=$JHALFSDIR/dump-lfs-scripts.xsl
|
---|
[49aea5e] | 1058 | [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
|
---|
| 1059 | >$LOGDIR/$LOG
|
---|
| 1060 |
|
---|
[1236262] | 1061 | get_book
|
---|
[f8de156] | 1062 | build_Makefile
|
---|
[71642ef] | 1063 | run_make
|
---|
[49aea5e] | 1064 |
|
---|