2005-09-12 20:23:41 +02:00
|
|
|
#!/bin/sh
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#
|
|
|
|
# Load the configuration file
|
|
|
|
#
|
2005-10-24 21:21:09 +02:00
|
|
|
source jhalfs.conf
|
2005-10-24 19:53:50 +02:00
|
|
|
|
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
version="
|
2005-10-12 12:58:20 +02:00
|
|
|
jhalfs development \$Date$
|
2005-09-27 00:36:40 +02:00
|
|
|
|
2005-11-01 03:53:15 +01:00
|
|
|
Written by Jeremy Huntwork and Manuel Canales Esparcia.
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
This program is published under the \
|
2005-09-25 18:56:00 +02:00
|
|
|
Gnu General Public License, Version 2.
|
|
|
|
"
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
usage="\
|
|
|
|
Usage: $0 [OPTION]
|
|
|
|
|
|
|
|
Options:
|
2005-09-25 18:56:00 +02:00
|
|
|
-h, --help print this help, then exit
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-09-25 18:56:00 +02:00
|
|
|
-V, --version print version number, then exit
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-10-06 23:09:53 +02:00
|
|
|
-d --directory DIR use DIR directory for building LFS; all files
|
2005-09-25 18:56:00 +02:00
|
|
|
jhalfs produces will be in the directory
|
2005-10-08 01:01:40 +02:00
|
|
|
DIR/jhalfs. Default is \"/mnt/lfs\".
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-11-23 22:55:01 +01:00
|
|
|
--rebuild clean the build directory before to perfom
|
|
|
|
any other task. The directory is cleaned
|
|
|
|
only if it was populated by a previous
|
|
|
|
jhalfs run.
|
|
|
|
|
2005-11-01 16:50:31 +01:00
|
|
|
-P, --get-packages download the packages and patches. This
|
2005-12-09 18:49:30 +01:00
|
|
|
assumes that the server declared in the
|
2005-11-01 16:50:31 +01:00
|
|
|
jhalfs.conf file has the proper packages
|
|
|
|
and patches for the book version being
|
|
|
|
processed.
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-10-06 23:09:53 +02:00
|
|
|
-D, --download-client CLIENT use CLIENT as the program for retrieving
|
2005-10-02 16:06:01 +02:00
|
|
|
packages (for use in conjunction with -P)
|
|
|
|
|
2005-10-06 23:09:53 +02:00
|
|
|
-W, --working-copy DIR use the local working copy placed in DIR
|
2005-10-02 16:06:01 +02:00
|
|
|
as the LFS book
|
|
|
|
|
2005-11-02 04:09:44 +01:00
|
|
|
-L, --LFS-version VER checkout VER version of the LFS book.
|
2005-10-16 10:47:48 +02:00
|
|
|
Supported versions at this time are:
|
2005-12-09 18:49:30 +01:00
|
|
|
|
2005-11-01 16:50:31 +01:00
|
|
|
dev* | trunk | SVN aliases for Development LFS
|
2005-12-04 13:24:26 +01:00
|
|
|
alpha* aliases for the alphabetical branch
|
2006-03-07 20:04:11 +01:00
|
|
|
udev* aliases for the udev_update branch
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-12-17 13:55:04 +01:00
|
|
|
For stable 6.1.1 book, please use jhalfs-0.2.
|
|
|
|
|
2005-10-02 16:06:01 +02:00
|
|
|
-T, --testsuites add support to run the optional testsuites
|
|
|
|
|
2005-10-07 21:13:20 +02:00
|
|
|
--no-toolchain-test don't run the toolchain testsuites. This
|
2005-11-01 16:50:31 +01:00
|
|
|
also disables the build of TCL, Expect
|
2005-10-07 21:13:20 +02:00
|
|
|
and DejaGNU
|
2005-10-14 23:57:22 +02:00
|
|
|
|
2005-11-16 23:39:12 +01:00
|
|
|
--no-strip don't run the strip command on both the
|
|
|
|
temporary system and the final system
|
|
|
|
|
2005-10-14 23:57:22 +02:00
|
|
|
--timezone TIMEZONE set TIMEZONE as the local timezone. If not
|
2005-11-01 16:50:31 +01:00
|
|
|
specified, \"Europe/London\" will be used.
|
2005-10-07 21:13:20 +02:00
|
|
|
|
2005-10-12 12:07:29 +02:00
|
|
|
--page_size PAGE set PAGE as the default page size (letter
|
|
|
|
or A4). This setting is required to
|
2005-10-08 01:01:40 +02:00
|
|
|
build Groff. If not specified, \"letter\"
|
|
|
|
will be used.
|
2005-10-08 21:48:42 +02:00
|
|
|
|
2005-10-14 23:57:22 +02:00
|
|
|
--fstab FILE use FILE as the /etc/fstab file for the
|
|
|
|
LFS system. If not specified, a default
|
|
|
|
/etc/fstab file with dummy values is
|
|
|
|
created.
|
2005-12-09 18:49:30 +01:00
|
|
|
|
2005-11-16 19:16:52 +01:00
|
|
|
--no-vim-lang don't install the optional vim-lang package
|
2005-10-14 23:57:22 +02:00
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
-C, --kernel-config FILE use the kernel configuration file specified
|
2005-11-01 16:50:31 +01:00
|
|
|
in FILE to build the kernel. If the file is
|
|
|
|
not found, or if not specified, the kernel
|
|
|
|
build is skipped.
|
2005-10-08 21:48:42 +02:00
|
|
|
|
|
|
|
-M, --run-make run make on the generated Makefile
|
2005-10-14 23:57:22 +02:00
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
"
|
|
|
|
|
|
|
|
help="\
|
|
|
|
Try '$0 --help' for more information."
|
|
|
|
|
2005-11-17 20:16:55 +01:00
|
|
|
no_empty_builddir="\
|
|
|
|
echo \"\" >&2
|
|
|
|
echo \" W A R N I N G\" >&2
|
|
|
|
echo \"\" >&2
|
2005-11-17 20:39:10 +01:00
|
|
|
echo \"Looks like the \$BUILDDIR directory contains subdirectories\" >&2
|
2005-11-17 20:16:55 +01:00
|
|
|
echo \"from a previous LFS build.\" >&2
|
|
|
|
echo \"\" >&2
|
2005-11-17 20:39:10 +01:00
|
|
|
echo \"Please format the partition mounted on \$BUILDDIR or set\" >&2
|
2005-12-20 05:14:41 +01:00
|
|
|
echo \"a different build directory before running jhalfs.\" >&2
|
2005-11-17 20:16:55 +01:00
|
|
|
echo \"\" >&2
|
|
|
|
exit 1"
|
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
exit_missing_arg="\
|
|
|
|
echo \"Option '\$1' requires an argument\" >&2
|
|
|
|
echo \"\$help\" >&2
|
|
|
|
exit 1"
|
|
|
|
|
|
|
|
no_dl_client="\
|
|
|
|
echo \"Could not find a way to download the LFS sources.\" >&2
|
|
|
|
echo \"Attempting to continue.\" >&2"
|
|
|
|
|
2005-10-03 05:24:16 +02:00
|
|
|
HEADER="# This file is automatically generated by jhalfs
|
|
|
|
# DO NOT EDIT THIS FILE MANUALLY
|
|
|
|
#
|
|
|
|
# Generated on `date \"+%F %X %Z\"`"
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### FUNCTIONS ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
2005-11-23 22:55:01 +01:00
|
|
|
#----------------------------#
|
|
|
|
clean_builddir() {
|
|
|
|
#----------------------------#
|
|
|
|
# Test if the clean must be done.
|
|
|
|
if [ "$CLEAN" = "1" ] ; then
|
|
|
|
# Test to make sure we're running the clean as root
|
|
|
|
if [ "$UID" != "0" ] ; then
|
|
|
|
echo "You must be logged in as root to clean the build directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Test to make sure that the build directory was populated by jhalfs
|
|
|
|
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
2005-12-20 21:39:13 +01:00
|
|
|
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
2005-11-23 22:55:01 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
# Clean the build directory
|
|
|
|
echo -ne "Cleaning $BUILDDIR...\n"
|
|
|
|
rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
|
|
|
|
echo -ne "Cleaning $JHALFSDIR...\n"
|
|
|
|
rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
2005-11-24 20:13:29 +01:00
|
|
|
echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
|
|
|
rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
2005-11-23 22:55:01 +01:00
|
|
|
echo -ne "done\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
get_book() {
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:33:50 +02:00
|
|
|
cd $JHALFSDIR
|
2005-09-12 20:23:41 +02:00
|
|
|
|
2005-10-02 16:06:01 +02:00
|
|
|
if [ -z $WC ] ; then
|
2006-01-12 19:42:14 +01:00
|
|
|
# Check for Subversion instead of just letting the script hit 'svn' and fail.
|
|
|
|
test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
|
|
|
exit 1"
|
2005-10-02 16:06:01 +02:00
|
|
|
echo -n "Downloading the LFS Book, version $LFSVRS... "
|
|
|
|
|
2005-12-20 21:39:13 +01:00
|
|
|
# Grab a fresh LFS book if it's missing, otherwise, update it from the
|
2005-10-02 16:06:01 +02:00
|
|
|
# repo. If we've already extracted the commands, move on to getting the
|
|
|
|
# sources.
|
|
|
|
if [ -d lfs-$LFSVRS ] ; then
|
|
|
|
cd lfs-$LFSVRS
|
2005-12-09 18:54:48 +01:00
|
|
|
if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
2005-10-02 16:06:01 +02:00
|
|
|
test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
|
|
|
echo -ne "done\n"
|
2005-11-16 22:27:53 +01:00
|
|
|
# Set the canonical book version
|
|
|
|
cd $JHALFSDIR
|
|
|
|
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
2005-10-02 16:06:01 +02:00
|
|
|
get_sources
|
|
|
|
else
|
|
|
|
echo -ne "done\n"
|
2005-11-16 22:27:53 +01:00
|
|
|
# Set the canonical book version
|
|
|
|
cd $JHALFSDIR
|
|
|
|
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
2005-10-02 16:06:01 +02:00
|
|
|
extract_commands
|
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
else
|
2005-12-01 01:54:52 +01:00
|
|
|
case $LFSVRS in
|
|
|
|
development)
|
|
|
|
svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
|
|
|
alphabetical)
|
|
|
|
svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
2006-03-07 20:04:11 +01:00
|
|
|
udev_update)
|
|
|
|
svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
2005-12-01 01:54:52 +01:00
|
|
|
esac
|
2005-09-25 18:56:00 +02:00
|
|
|
echo -ne "done\n"
|
2005-11-16 22:27:53 +01:00
|
|
|
# Set the canonical book version
|
|
|
|
cd $JHALFSDIR
|
|
|
|
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
2005-09-25 18:56:00 +02:00
|
|
|
extract_commands
|
|
|
|
fi
|
2005-09-11 23:03:26 +02:00
|
|
|
else
|
2005-10-02 16:06:01 +02:00
|
|
|
echo -ne "Using $BOOK as book's sources ...\n"
|
2005-11-16 22:27:53 +01:00
|
|
|
# Set the canonical book version
|
|
|
|
cd $JHALFSDIR
|
|
|
|
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
2005-09-25 18:56:00 +02:00
|
|
|
extract_commands
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
extract_commands() {
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
# Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
|
|
|
test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
2005-09-25 18:56:00 +02:00
|
|
|
exit 1"
|
2005-09-11 23:33:50 +02:00
|
|
|
cd $JHALFSDIR
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
# Start clean
|
|
|
|
if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
|
|
|
|
echo -n "Extracting commands... "
|
|
|
|
|
2005-09-27 20:13:19 +02:00
|
|
|
# Dump the commands in shell script form from the LFS book.
|
2005-10-07 21:13:20 +02:00
|
|
|
xsltproc --nonet --xinclude --stringparam testsuite $TEST \
|
2005-11-16 19:16:52 +01:00
|
|
|
--stringparam toolchaintest $TOOLCHAINTEST --stringparam vim-lang $VIMLANG \
|
|
|
|
-o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-10-08 01:01:40 +02:00
|
|
|
# Make the scripts executable.
|
2005-10-05 19:26:35 +02:00
|
|
|
chmod -R +x $JHALFSDIR/commands
|
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
# Grab the patches and package names.
|
2005-09-11 23:33:50 +02:00
|
|
|
cd $JHALFSDIR
|
2005-09-11 23:03:26 +02:00
|
|
|
for i in patches packages ; do rm -f $i ; done
|
2005-10-02 16:06:01 +02:00
|
|
|
grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
2005-09-25 18:56:00 +02:00
|
|
|
-e '/generic/d' >> packages
|
2005-11-16 19:16:52 +01:00
|
|
|
# Download the vim-lang package if it must be installed
|
|
|
|
if [ "$VIMLANG" = "1" ] ; then
|
|
|
|
echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
|
|
|
fi
|
2005-10-31 22:13:32 +01:00
|
|
|
echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
2006-01-07 14:32:13 +01:00
|
|
|
echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
|
2006-01-10 04:58:23 +01:00
|
|
|
grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
2005-09-11 23:03:26 +02:00
|
|
|
# Done. Moving on...
|
|
|
|
echo -ne "done\n"
|
|
|
|
get_sources
|
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
download() {
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
cd $BUILDDIR/sources
|
|
|
|
|
2006-03-07 19:55:15 +01:00
|
|
|
# Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} that don't
|
|
|
|
# conform to norms in the URL scheme.
|
2006-01-07 14:32:13 +01:00
|
|
|
DIR=`echo $1 | sed 's@-doc@@;s@-libidn@@'`
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
# Find the md5 sum for this package.
|
2006-01-10 04:40:18 +01:00
|
|
|
if [ $2 != MD5SUMS ] ; then MD5=`grep " $2$" MD5SUMS` ; fi
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
if [ ! -f $2 ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
case $DL in
|
|
|
|
wget )
|
2006-03-03 21:58:07 +01:00
|
|
|
wget --passive $FTP/$DIR/$2
|
2005-09-25 18:56:00 +02:00
|
|
|
;;
|
|
|
|
curl )
|
2006-03-03 21:58:07 +01:00
|
|
|
`curl -# $FTP/$DIR/$2 -o $2`
|
2005-09-25 18:56:00 +02:00
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "$DL not supported at this time."
|
|
|
|
;;
|
|
|
|
esac
|
2005-09-11 23:03:26 +02:00
|
|
|
elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
case $DL in
|
|
|
|
wget )
|
2006-03-03 21:58:07 +01:00
|
|
|
wget --passive -c $FTP/$DIR/$2
|
2005-09-25 18:56:00 +02:00
|
|
|
;;
|
|
|
|
curl )
|
2006-03-03 21:58:07 +01:00
|
|
|
`curl -# -C - $FTP/$DIR/$2 -o $2`
|
2005-09-25 18:56:00 +02:00
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "$DL not supported at this time."
|
|
|
|
;;
|
|
|
|
esac
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-11-16 22:27:53 +01:00
|
|
|
if [ $2 != MD5SUMS ] ; then
|
|
|
|
echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
|
|
|
fi
|
2005-09-11 23:03:26 +02:00
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
get_sources() {
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-09-29 21:14:06 +02:00
|
|
|
# Test if the packages must be downloaded
|
2005-10-02 11:14:02 +02:00
|
|
|
if [ "$HPKG" = "1" ] ; then
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-09-29 21:14:06 +02:00
|
|
|
# This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
|
|
|
# separates each iteration by lines. It is necessary to have the second
|
|
|
|
# ' on the next line.
|
|
|
|
IFS='
|
|
|
|
'
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-09-29 21:14:06 +02:00
|
|
|
if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
|
|
|
cd $BUILDDIR/sources
|
|
|
|
if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
2005-11-16 22:27:53 +01:00
|
|
|
if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
2005-09-29 21:14:06 +02:00
|
|
|
|
|
|
|
download "" MD5SUMS
|
|
|
|
|
|
|
|
# Iterate through each package and grab it, along with any patches it needs.
|
|
|
|
for i in `cat $JHALFSDIR/packages` ; do
|
2005-10-31 22:13:32 +01:00
|
|
|
PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
|
2005-09-29 21:14:06 +02:00
|
|
|
|
2005-12-16 17:42:49 +01:00
|
|
|
# There are some entities that aren't valid packages.
|
2006-03-07 19:55:15 +01:00
|
|
|
if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
2005-09-29 21:14:06 +02:00
|
|
|
|
|
|
|
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
2006-03-07 19:55:15 +01:00
|
|
|
case $PKG in
|
2006-01-10 04:40:18 +01:00
|
|
|
tcl)
|
|
|
|
FILE="$PKG$VRS-src.tar.bz2"
|
|
|
|
;;
|
|
|
|
vim-lang)
|
|
|
|
PKG="vim"
|
|
|
|
FILE="vim-$VRS-lang.tar.bz2"
|
|
|
|
;;
|
|
|
|
udev-config)
|
|
|
|
PKG="udev"
|
|
|
|
FILE="$VRS"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
FILE="$PKG-$VRS.tar.bz2"
|
|
|
|
;;
|
|
|
|
esac
|
2005-09-29 21:14:06 +02:00
|
|
|
download $PKG $FILE
|
2006-01-10 04:40:18 +01:00
|
|
|
|
|
|
|
# Download any associated patches
|
|
|
|
for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
|
2005-10-24 21:52:18 +02:00
|
|
|
PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
|
|
|
download $PKG $PATCH
|
2005-09-29 21:14:06 +02:00
|
|
|
done
|
2005-09-12 20:23:41 +02:00
|
|
|
done
|
2005-09-29 21:14:06 +02:00
|
|
|
fi
|
2005-09-11 23:03:26 +02:00
|
|
|
}
|
|
|
|
|
2005-10-24 21:21:09 +02:00
|
|
|
#-----------------------------------------------#
|
|
|
|
_IS_() # Function to test build scripts names
|
|
|
|
#-----------------------------------------------#
|
|
|
|
{
|
|
|
|
# Returns substr $2 or null str
|
|
|
|
# Must use string testing
|
|
|
|
case $1 in
|
|
|
|
*$2*) echo "$2" ;;
|
|
|
|
*) echo "" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter4_Makefiles() {
|
|
|
|
#----------------------------#
|
2005-11-17 22:21:39 +01:00
|
|
|
|
|
|
|
# If /home/lfs is already present in the host, we asume that the
|
|
|
|
# lfs user and group are also presents in the host, and a backup
|
|
|
|
# of their bash init files is made.
|
2005-10-24 19:53:50 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
020-creatingtoolsdir:
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@mkdir -v \$(LFS)/tools && \\
|
2005-11-17 20:30:39 +01:00
|
|
|
rm -fv /tools && \\
|
2005-10-24 19:53:50 +02:00
|
|
|
ln -sv \$(LFS)/tools / && \\
|
|
|
|
touch \$@
|
2005-09-12 20:23:41 +02:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
021-addinguser: 020-creatingtoolsdir
|
|
|
|
@\$(call echo_message, Building)
|
2005-11-17 22:21:39 +01:00
|
|
|
@if [ ! -d /home/lfs ]; then \\
|
|
|
|
groupadd lfs; \\
|
|
|
|
useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
2005-11-23 21:21:17 +01:00
|
|
|
else \\
|
|
|
|
touch user-lfs-exist; \\
|
2005-11-17 22:21:39 +01:00
|
|
|
fi;
|
|
|
|
@chown lfs \$(LFS)/tools && \\
|
2005-10-24 19:53:50 +02:00
|
|
|
chown lfs \$(LFS)/sources && \\
|
|
|
|
touch \$@
|
|
|
|
|
|
|
|
022-settingenvironment: 021-addinguser
|
|
|
|
@\$(call echo_message, Building)
|
2005-11-17 22:21:39 +01:00
|
|
|
@if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
|
|
|
mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
|
|
|
fi;
|
|
|
|
@if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
|
|
|
mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
|
|
|
fi;
|
2005-10-24 19:53:50 +02:00
|
|
|
@echo "set +h" > /home/lfs/.bashrc && \\
|
|
|
|
echo "umask 022" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
|
|
|
echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
|
|
|
chown lfs:lfs /home/lfs/.bashrc && \\
|
|
|
|
touch envars && \\
|
|
|
|
touch \$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
}
|
2005-09-12 03:01:10 +02:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter5_Makefiles() {
|
|
|
|
#----------------------------#
|
2005-09-28 00:33:06 +02:00
|
|
|
for file in chapter05/* ; do
|
2005-10-01 14:21:30 +02:00
|
|
|
# Keep the script file name
|
|
|
|
i=`basename $file`
|
2005-09-27 00:36:40 +02:00
|
|
|
|
2005-12-16 17:42:49 +01:00
|
|
|
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
2005-10-07 21:13:20 +02:00
|
|
|
if [ "$TOOLCHAINTEST" = "0" ]; then
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i tcl` ]] || [[ `_IS_ $i expect` ]] || [[ `_IS_ $i dejagnu` ]] ; then
|
2005-10-07 21:13:20 +02:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2005-11-16 23:39:12 +01:00
|
|
|
# Test if the stripping phase must be skipped
|
|
|
|
if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
chapter5="$chapter5 $i"
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
|
|
|
# and binutils in chapter 5)
|
|
|
|
name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-02 12:28:59 +02:00
|
|
|
# Set the dependency for the first target.
|
|
|
|
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
|
|
|
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
2005-10-03 02:56:55 +02:00
|
|
|
# as a dependency. Also call the echo_message function.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# Find the version of the command files, if it corresponds with the building of
|
|
|
|
# a specific package
|
|
|
|
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# If $vrs isn't empty, we've got a package...
|
|
|
|
if [ "$vrs" != "" ] ; then
|
|
|
|
if [ "$name" = "tcl" ] ; then
|
2005-10-28 20:48:53 +02:00
|
|
|
FILE="$name$vrs-src.tar"
|
2005-10-01 14:21:30 +02:00
|
|
|
else
|
2005-10-28 20:48:53 +02:00
|
|
|
FILE="$name-$vrs.tar"
|
2005-10-01 14:21:30 +02:00
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# Insert instructions for unpacking the package and to set
|
|
|
|
# the PKGDIR variable.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call unpack,$FILE)
|
2005-10-08 17:34:32 +02:00
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
|
|
|
|
echo "export PKGDIR" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 02:56:55 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-04 20:37:09 +02:00
|
|
|
# Insert date and disk usage at the top of the log file, the script run
|
|
|
|
# and date and disk usage again at the bottom of the log file.
|
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-15 00:32:33 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
|
2005-10-15 00:32:33 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
2005-10-04 20:37:09 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-01 14:21:30 +02:00
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
# Remove the build directory(ies) except if the package build fails
|
2005-12-16 17:42:49 +01:00
|
|
|
# (so we can review config.cache, config.log, etc.)
|
|
|
|
# For Binutils the sources must be retained for some time.
|
2005-10-01 14:21:30 +02:00
|
|
|
if [ "$vrs" != "" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-08 17:34:32 +02:00
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/$name-build; \\
|
|
|
|
fi;
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 20:28:57 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@touch \$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 20:28:57 +02:00
|
|
|
|
2005-10-02 12:28:59 +02:00
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$i
|
2005-10-24 19:53:50 +02:00
|
|
|
done # end for file in chapter05/*
|
|
|
|
}
|
2005-09-12 04:53:48 +02:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter6_Makefiles() {
|
|
|
|
#----------------------------#
|
2005-10-02 14:05:57 +02:00
|
|
|
for file in chapter06/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
i=`basename $file`
|
|
|
|
|
2005-10-05 02:13:29 +02:00
|
|
|
# We'll run the chroot commands differently than the others, so skip them in the
|
|
|
|
# dependencies and target creation.
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i chroot` ]] ; then
|
2005-10-05 02:13:29 +02:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2005-11-16 23:39:12 +01:00
|
|
|
# Test if the stripping phase must be skipped
|
|
|
|
if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2005-10-02 14:05:57 +02:00
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
chapter6="$chapter6 $i"
|
|
|
|
|
|
|
|
# Grab the name of the target
|
|
|
|
name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
|
|
|
|
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
2005-10-04 00:00:09 +02:00
|
|
|
# as a dependency. Also call the echo_message function.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-02 14:05:57 +02:00
|
|
|
|
|
|
|
# Find the version of the command files, if it corresponds with the building of
|
|
|
|
# a specific package
|
|
|
|
vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
|
|
|
|
|
|
|
# If $vrs isn't empty, we've got a package...
|
2005-10-04 20:37:09 +02:00
|
|
|
# Insert instructions for unpacking the package and changing directories
|
2005-10-02 14:05:57 +02:00
|
|
|
if [ "$vrs" != "" ] ; then
|
2005-10-28 20:48:53 +02:00
|
|
|
FILE="$name-$vrs.tar.*"
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-28 20:48:53 +02:00
|
|
|
@\$(call unpack2,$FILE)
|
2005-10-08 17:34:32 +02:00
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
2005-10-05 03:14:48 +02:00
|
|
|
echo "export PKGDIR" >> envars
|
2005-10-04 20:37:09 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-02 14:05:57 +02:00
|
|
|
fi
|
|
|
|
|
2005-10-12 12:32:31 +02:00
|
|
|
# For Glibc we need to set TIMEZONE envar.
|
2006-02-10 12:53:29 +01:00
|
|
|
if [[ `_IS_ $i glibc` ]] ; then
|
2005-10-12 12:32:31 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
|
|
|
|
echo "export TIMEZONE" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2005-10-06 23:09:53 +02:00
|
|
|
# For Groff we need to set PAGE envar.
|
2005-10-24 21:21:09 +02:00
|
|
|
elif [[ `_IS_ $i groff` ]] ; then
|
2005-10-06 23:09:53 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "PAGE=\$(PAGE)" >> envars && \\
|
|
|
|
echo "export PAGE" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
|
2005-10-14 23:57:22 +02:00
|
|
|
# In the mount of kernel filesystems we need to set LFS
|
2005-10-04 21:12:07 +02:00
|
|
|
# and not to use chroot.
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i kernfs` ]] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-15 00:32:33 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-08 18:13:32 +02:00
|
|
|
export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
|
2005-10-15 00:32:33 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
2005-10-04 20:37:09 +02:00
|
|
|
EOF
|
2005-10-05 02:58:01 +02:00
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
# The rest of Chapter06
|
2005-10-02 20:03:13 +02:00
|
|
|
else
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-15 00:32:33 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-05 03:14:48 +02:00
|
|
|
\$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
2005-10-15 00:32:33 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
2005-10-04 20:37:09 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-02 20:03:13 +02:00
|
|
|
fi
|
2005-10-02 14:05:57 +02:00
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
# Remove the build directory(ies) except if the package build fails.
|
2005-10-02 14:05:57 +02:00
|
|
|
if [ "$vrs" != "" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-08 17:34:32 +02:00
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/$name-build; \\
|
|
|
|
fi;
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-02 14:05:57 +02:00
|
|
|
fi
|
|
|
|
|
2005-10-03 01:21:16 +02:00
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@touch \$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 01:21:16 +02:00
|
|
|
|
2005-10-02 14:05:57 +02:00
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$i
|
2005-10-24 19:53:50 +02:00
|
|
|
done # end for file in chapter06/*
|
|
|
|
}
|
2005-10-02 14:05:57 +02:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
|
|
|
chapter789_Makefiles() {
|
|
|
|
#----------------------------#
|
2005-10-08 21:48:42 +02:00
|
|
|
for file in chapter0{7,8,9}/* ; do
|
|
|
|
# Keep the script file name
|
|
|
|
i=`basename $file`
|
|
|
|
|
2005-10-24 21:21:09 +02:00
|
|
|
# Grub must be configured manually.
|
|
|
|
# The filesystems can't be unmounted via Makefile and the user
|
2005-12-20 21:39:13 +01:00
|
|
|
# should enter the chroot environment to create the root
|
|
|
|
# password, edit several files and setup Grub.
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
|
2005-10-09 10:46:38 +02:00
|
|
|
continue
|
2005-10-08 21:48:42 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If no .config file is supplied, the kernel build is skipped
|
2005-10-24 21:21:09 +02:00
|
|
|
if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
|
|
|
|
continue
|
2005-10-08 21:48:42 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# First append each name of the script files to a list (this will become
|
|
|
|
# the names of the targets in the Makefile
|
|
|
|
chapter789="$chapter789 $i"
|
|
|
|
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
# as a dependency. Also call the echo_message function.
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2005-12-20 21:39:13 +01:00
|
|
|
# Find the bootscripts and kernel package names
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
|
|
|
if [[ `_IS_ $i bootscripts` ]] ; then
|
2005-10-08 21:48:42 +02:00
|
|
|
vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
2005-10-28 20:48:53 +02:00
|
|
|
FILE="lfs-bootscripts-$vrs.tar.*"
|
2005-10-24 21:21:09 +02:00
|
|
|
elif [[ `_IS_ $i kernel` ]] ; then
|
2005-10-08 21:48:42 +02:00
|
|
|
vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
2005-10-28 20:48:53 +02:00
|
|
|
FILE="linux-$vrs.tar.*"
|
2005-10-08 21:48:42 +02:00
|
|
|
fi
|
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-28 20:48:53 +02:00
|
|
|
@\$(call unpack2,$FILE)
|
2005-10-08 21:48:42 +02:00
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
|
|
|
echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
|
|
|
echo "export PKGDIR" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
2005-10-14 23:57:22 +02:00
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
# Put in place the kernel .config file
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i kernel` ]] ; then
|
2005-10-08 21:48:42 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-09 19:53:54 +02:00
|
|
|
@cp $CONFIG \$(LFS)/sources/kernel-config
|
2005-10-08 21:48:42 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
|
2005-10-14 23:57:22 +02:00
|
|
|
# Check if we have a real /etc/fstab file
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
2005-10-14 23:57:22 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-15 00:32:33 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-14 23:57:22 +02:00
|
|
|
cp -v $FSTAB \$(LFS)/etc/fstab >>logs/$i 2>&1 && \\
|
2005-10-15 00:32:33 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
2005-10-14 23:57:22 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
else
|
2005-12-20 21:39:13 +01:00
|
|
|
# Initialize the log and run the script
|
2005-10-08 21:48:42 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-15 00:32:33 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-08 21:48:42 +02:00
|
|
|
\$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
2005-10-15 00:32:33 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
2005-10-08 21:48:42 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-14 23:57:22 +02:00
|
|
|
fi
|
2005-10-08 21:48:42 +02:00
|
|
|
|
|
|
|
# Remove the build directory except if the package build fails.
|
2005-10-24 21:21:09 +02:00
|
|
|
if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
2005-10-08 21:48:42 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
2005-10-14 23:57:22 +02:00
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT
|
2005-10-08 21:48:42 +02:00
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
# if it's already been made.
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@touch \$@
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$i
|
2005-10-24 19:53:50 +02:00
|
|
|
done # for file in chapter0{7,8,9}/*
|
2005-12-09 18:49:30 +01:00
|
|
|
}
|
2005-10-24 19:53:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
build_Makefile() {
|
|
|
|
#----------------------------#
|
|
|
|
echo -n "Creating Makefile... "
|
|
|
|
cd $JHALFSDIR/commands
|
|
|
|
|
|
|
|
# Start with a clean Makefile.tmp file
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
|
|
chapter4_Makefiles
|
|
|
|
chapter5_Makefiles
|
2005-12-09 18:49:30 +01:00
|
|
|
chapter6_Makefiles
|
|
|
|
chapter789_Makefiles
|
2005-10-24 19:53:50 +02:00
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
|
2005-10-04 20:37:09 +02:00
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
# to the top of the real Makefile.
|
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
$HEADER
|
|
|
|
|
|
|
|
SRC= /sources
|
|
|
|
LFS= $BUILDDIR
|
2005-10-06 23:09:53 +02:00
|
|
|
PAGE= $PAGE
|
2005-10-12 12:32:31 +02:00
|
|
|
TIMEZONE= $TIMEZONE
|
2005-10-04 20:37:09 +02:00
|
|
|
|
|
|
|
include functions
|
|
|
|
|
|
|
|
EOF
|
|
|
|
) > $MKFILE
|
2005-10-03 05:24:16 +02:00
|
|
|
|
2005-10-03 04:40:33 +02:00
|
|
|
|
|
|
|
# Add chroot commands
|
|
|
|
i=1
|
|
|
|
for file in chapter06/*chroot* ; do
|
|
|
|
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
2005-10-24 19:53:50 +02:00
|
|
|
-e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
|
|
|
-e 's|"$$LFS"|$(LFS)|' -e 's|set -e||'`
|
2005-10-03 05:33:19 +02:00
|
|
|
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
2005-10-03 04:40:33 +02:00
|
|
|
i=`expr $i + 1`
|
|
|
|
done
|
2005-09-12 04:53:48 +02:00
|
|
|
|
2005-09-28 00:33:06 +02:00
|
|
|
# Drop in the main target 'all:' and the chapter targets with each sub-target
|
|
|
|
# as a dependency.
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-08 21:48:42 +02:00
|
|
|
all: chapter4 chapter5 chapter6 chapter789
|
2005-10-09 12:20:10 +02:00
|
|
|
@\$(call echo_finished,$VERSION)
|
2005-10-04 20:37:09 +02:00
|
|
|
|
|
|
|
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
|
|
|
|
2005-11-17 22:21:39 +01:00
|
|
|
chapter5: chapter4 $chapter5 restore-lfs-env
|
2005-10-04 20:37:09 +02:00
|
|
|
|
|
|
|
chapter6: chapter5 $chapter6
|
|
|
|
|
2005-10-08 21:48:42 +02:00
|
|
|
chapter789: chapter6 $chapter789
|
|
|
|
|
2005-10-04 20:37:09 +02:00
|
|
|
clean-all: clean
|
2005-11-23 21:21:17 +01:00
|
|
|
rm -rf ./{commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
2005-10-04 20:37:09 +02:00
|
|
|
|
2005-10-28 22:07:50 +02:00
|
|
|
clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
2005-10-04 20:37:09 +02:00
|
|
|
|
|
|
|
clean-chapter4:
|
2005-11-23 21:21:17 +01:00
|
|
|
-if [ ! -f user-lfs-exist ]; then \\
|
|
|
|
userdel lfs; \\
|
|
|
|
rm -rf /home/lfs; \\
|
|
|
|
fi;
|
2005-10-04 20:37:09 +02:00
|
|
|
rm -rf \$(LFS)/tools
|
|
|
|
rm -f /tools
|
2005-11-23 21:21:17 +01:00
|
|
|
rm -f envars user-lfs-exist
|
2005-10-04 20:37:09 +02:00
|
|
|
rm -f 02* logs/02*.log
|
|
|
|
|
|
|
|
clean-chapter5:
|
|
|
|
rm -rf \$(LFS)/tools/*
|
2005-11-23 21:21:17 +01:00
|
|
|
rm -f $chapter5 restore-lfs-env sources-dir
|
2005-10-04 20:37:09 +02:00
|
|
|
cd logs && rm -f $chapter5 && cd ..
|
2005-12-09 18:49:30 +01:00
|
|
|
|
2005-10-28 22:07:50 +02:00
|
|
|
clean-chapter6:
|
2005-10-29 18:48:54 +02:00
|
|
|
-umount \$(LFS)/sys
|
|
|
|
-umount \$(LFS)/proc
|
|
|
|
-umount \$(LFS)/dev/shm
|
|
|
|
-umount \$(LFS)/dev/pts
|
|
|
|
-umount \$(LFS)/dev
|
2005-10-28 22:07:50 +02:00
|
|
|
rm -rf \$(LFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
|
|
|
rm -f $chapter6
|
|
|
|
cd logs && rm -f $chapter6 && cd ..
|
|
|
|
|
2005-12-09 18:49:30 +01:00
|
|
|
clean-chapter789:
|
2005-10-28 22:07:50 +02:00
|
|
|
rm -f $chapter789
|
|
|
|
cd logs && rm -f $chapter789 && cd ..
|
|
|
|
|
2005-11-17 22:21:39 +01:00
|
|
|
restore-lfs-env:
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
|
|
|
mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
|
|
|
fi;
|
|
|
|
@if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
|
|
|
mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
|
|
|
fi;
|
|
|
|
@chown lfs:lfs /home/lfs/.bash* && \\
|
2005-11-17 22:34:20 +01:00
|
|
|
touch \$@
|
2005-10-04 20:37:09 +02:00
|
|
|
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE
|
2005-09-28 00:33:06 +02:00
|
|
|
|
2005-09-12 04:53:48 +02:00
|
|
|
# Bring over the items from the Makefile.tmp
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
rm $MKFILE.tmp
|
|
|
|
echo -ne "done\n"
|
2005-09-12 03:01:10 +02:00
|
|
|
}
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-09-30 22:47:34 +02:00
|
|
|
run_make() {
|
2005-10-24 19:53:50 +02:00
|
|
|
#----------------------------#
|
2005-10-02 11:14:02 +02:00
|
|
|
# Test if make must be run.
|
|
|
|
if [ "$RUNMAKE" = "1" ] ; then
|
2005-11-01 13:45:16 +01:00
|
|
|
# Test to make sure we're running the build as root
|
|
|
|
if [ "$UID" != "0" ] ; then
|
|
|
|
echo "You must be logged in as root to successfully build LFS."
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-10-02 11:14:02 +02:00
|
|
|
# Build the system
|
|
|
|
if [ -e $MKFILE ] ; then
|
2005-10-02 18:34:41 +02:00
|
|
|
echo -ne "Building the LFS system...\n"
|
2005-10-02 11:14:02 +02:00
|
|
|
cd $JHALFSDIR && make
|
|
|
|
echo -ne "done\n"
|
|
|
|
fi
|
2005-09-30 22:47:34 +02:00
|
|
|
fi
|
|
|
|
}
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### MAIN ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
# Evaluate any command line switches
|
|
|
|
|
|
|
|
while test $# -gt 0 ; do
|
|
|
|
case $1 in
|
|
|
|
--version | -V )
|
|
|
|
echo "$version"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--help | -h )
|
|
|
|
echo "$usage"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--LFS-version | -L )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
case $1 in
|
|
|
|
dev* | SVN | trunk )
|
|
|
|
LFSVRS=development
|
|
|
|
;;
|
2006-03-07 20:04:11 +01:00
|
|
|
|
2005-12-01 01:54:52 +01:00
|
|
|
6.1.1 )
|
2005-12-17 13:55:04 +01:00
|
|
|
echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
|
|
|
exit 0
|
2005-10-24 19:53:50 +02:00
|
|
|
;;
|
2005-12-09 18:49:30 +01:00
|
|
|
|
2005-11-13 02:40:28 +01:00
|
|
|
alpha*)
|
|
|
|
LFSVRS=alphabetical
|
|
|
|
;;
|
2006-03-07 20:04:11 +01:00
|
|
|
|
|
|
|
udev*)
|
|
|
|
LFSVRS=udev_update
|
|
|
|
;;
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
* )
|
|
|
|
echo "$1 is an unsupported version at this time."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
--directory | -d )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
BUILDDIR=$1
|
2005-11-18 20:10:55 +01:00
|
|
|
JHALFSDIR=$BUILDDIR/jhalfs
|
|
|
|
LOGDIR=$JHALFSDIR/logs
|
|
|
|
MKFILE=$JHALFSDIR/Makefile
|
2005-10-24 19:53:50 +02:00
|
|
|
;;
|
|
|
|
|
2005-11-23 22:55:01 +01:00
|
|
|
--rebuild ) CLEAN=1 ;;
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
--download-client | -D )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
DL=$1
|
|
|
|
;;
|
|
|
|
|
|
|
|
--working-copy | -W )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1/patches.ent ] ; then
|
|
|
|
WC=1
|
|
|
|
BOOK=$1
|
|
|
|
else
|
|
|
|
echo -e "\nLook like $1 isn't a supported working copy."
|
|
|
|
echo -e "Verify your selection and the command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--testsuites | -T ) TEST=1 ;;
|
|
|
|
|
|
|
|
--get-packages | -P ) HPKG=1 ;;
|
|
|
|
|
|
|
|
--run-make | -M ) RUNMAKE=1 ;;
|
|
|
|
|
|
|
|
--no-toolchain-test ) TOOLCHAINTEST=0 ;;
|
2005-11-16 19:16:52 +01:00
|
|
|
|
2005-11-16 23:39:12 +01:00
|
|
|
--no-strip ) STRIP=0 ;;
|
|
|
|
|
2005-11-16 19:16:52 +01:00
|
|
|
--no-vim-lang ) VIMLANG=0 ;;
|
2005-12-09 18:49:30 +01:00
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
--page_size )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
case $1 in
|
|
|
|
letter | A4 )
|
|
|
|
PAGE=$1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "$1 isn't a supported page size."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
--timezone )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f /usr/share/zoneinfo/$1 ] ; then
|
|
|
|
TIMEZONE=$1
|
|
|
|
else
|
2005-12-20 21:39:13 +01:00
|
|
|
echo -e "\nLooks like $1 isn't a valid timezone description."
|
2005-10-24 19:53:50 +02:00
|
|
|
echo -e "Verify your selection and the command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--fstab )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
FSTAB=$1
|
|
|
|
else
|
|
|
|
echo -e "\nFile $1 not found. Verify your command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--kernel-config | -C )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
CONFIG=$1
|
|
|
|
else
|
|
|
|
echo -e "\nFile $1 not found. Verify your command line.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
echo "$usage"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2005-12-09 18:49:30 +01:00
|
|
|
# Prevents setting "-d /" by mistake.
|
2005-11-23 22:55:01 +01:00
|
|
|
|
|
|
|
if [ $BUILDDIR = / ] ; then
|
|
|
|
echo -ne "\nThe root directory can't be used to build LFS.\n\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-12-20 21:39:13 +01:00
|
|
|
# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
2005-12-09 18:49:30 +01:00
|
|
|
# and notify the user about that.
|
2005-11-17 20:16:55 +01:00
|
|
|
|
2005-11-23 22:55:01 +01:00
|
|
|
if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
2005-11-17 20:16:55 +01:00
|
|
|
eval "$no_empty_builddir"
|
|
|
|
fi
|
|
|
|
|
2005-11-23 22:55:01 +01:00
|
|
|
# If requested, clean the build directory
|
|
|
|
clean_builddir
|
|
|
|
|
2005-10-24 21:21:09 +02:00
|
|
|
# Find the download client to use, if not already specified.
|
|
|
|
|
|
|
|
if [ -z $DL ] ; then
|
|
|
|
if [ `type -p wget` ] ; then
|
|
|
|
DL=wget
|
|
|
|
elif [ `type -p curl` ] ; then
|
|
|
|
DL=curl
|
|
|
|
else
|
|
|
|
eval "$no_dl_client"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2005-11-25 00:15:52 +01:00
|
|
|
if [ -z $BOOK ] ; then
|
|
|
|
BOOK=lfs-$LFSVRS
|
|
|
|
fi
|
|
|
|
|
2005-10-24 19:53:50 +02:00
|
|
|
[[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
|
2005-11-16 19:16:52 +01:00
|
|
|
[[ "$PWD" != "$JHALFSDIR" ]] && cp -v $FILES $JHALFSDIR/ && \
|
2005-11-25 00:15:52 +01:00
|
|
|
sed 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/dump-lfs-scripts.xsl && \
|
2005-11-16 19:16:52 +01:00
|
|
|
export XSL=$JHALFSDIR/dump-lfs-scripts.xsl
|
2005-10-24 19:53:50 +02:00
|
|
|
[[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
|
|
|
|
>$LOGDIR/$LOG
|
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
get_book
|
2005-09-12 03:01:10 +02:00
|
|
|
build_Makefile
|
2005-10-01 14:21:30 +02:00
|
|
|
run_make
|
2005-10-24 19:53:50 +02:00
|
|
|
|