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