2005-09-12 20:23:41 +02:00
|
|
|
#!/bin/sh
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
version="
|
2005-09-27 00:36:40 +02:00
|
|
|
jhalfs development
|
|
|
|
|
2005-09-28 21:30:31 +02:00
|
|
|
Originally written by Jeremy Huntwork.
|
2005-09-25 18:56:00 +02:00
|
|
|
Maintained by 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-09-25 18:56:00 +02:00
|
|
|
-d --directory=DIR use DIR directory for building LFS; all files
|
|
|
|
jhalfs produces will be in the directory
|
|
|
|
DIR/jhalfs
|
2005-10-02 16:06:01 +02:00
|
|
|
|
|
|
|
-P, --get-packages download the packages and patches
|
|
|
|
|
2005-09-25 18:56:00 +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)
|
|
|
|
|
|
|
|
-W, --working-copy=DIR use the local working copy placed in DIR
|
|
|
|
as the LFS book
|
|
|
|
|
|
|
|
-L, --LFS-version=VER ckeckout VER version of the LFS book
|
|
|
|
|
|
|
|
-T, --testsuites add support to run the optional testsuites
|
|
|
|
|
2005-10-02 11:14:02 +02:00
|
|
|
-M, --run-make run make on the generated Makefile
|
2005-09-11 23:03:26 +02:00
|
|
|
"
|
|
|
|
|
|
|
|
help="\
|
|
|
|
Try '$0 --help' for more information."
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
while test $# -gt 0 ; do
|
2005-09-25 18:56:00 +02:00
|
|
|
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
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "$1 is an unsupported version at this time."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--directory | -d )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
BUILDDIR=$1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
--download-client | -D )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
DL=$1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2005-10-02 16:06:01 +02:00
|
|
|
--working-copy | -W )
|
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
WC=1
|
|
|
|
BOOK=$1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2005-10-02 11:14:02 +02:00
|
|
|
--testsuites | -T )
|
2005-09-28 21:30:31 +02:00
|
|
|
TEST=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2005-10-02 11:14:02 +02:00
|
|
|
--get-packages | -P )
|
2005-09-29 21:14:06 +02:00
|
|
|
HPKG=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2005-10-02 11:14:02 +02:00
|
|
|
--run-make | -M )
|
|
|
|
RUNMAKE=1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
2005-09-25 18:56:00 +02:00
|
|
|
* )
|
|
|
|
echo "$usage"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2005-09-11 23:03:26 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Test to make sure we're running the build as root
|
|
|
|
|
|
|
|
if [ "$UID" != "0" ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
echo "You must be logged in as root to successfully build LFS."
|
|
|
|
exit 1
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Find the download client to use, if not already specified.
|
|
|
|
|
|
|
|
if [ -z $DL ] ; then
|
|
|
|
if [ `type -p wget` ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
DL=wget
|
2005-09-11 23:03:26 +02:00
|
|
|
elif [ `type -p curl` ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
DL=curl
|
2005-09-11 23:03:26 +02:00
|
|
|
else
|
2005-09-25 18:56:00 +02:00
|
|
|
eval "$no_dl_client"
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SVN="svn://svn.linuxfromscratch.org"
|
|
|
|
HTTP=http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/conglomeration
|
2005-09-12 04:04:26 +02:00
|
|
|
if [ -z $BUILDDIR ] ; then BUILDDIR=/mnt/lfs ; fi
|
2005-09-11 23:33:50 +02:00
|
|
|
JHALFSDIR=$BUILDDIR/jhalfs
|
2005-10-04 00:00:09 +02:00
|
|
|
LOGDIR=$JHALFSDIR/logs
|
2005-09-30 00:05:00 +02:00
|
|
|
LOG=000-jhalfs.log
|
2005-09-12 03:01:10 +02:00
|
|
|
MKFILE=$JHALFSDIR/Makefile
|
2005-10-02 11:26:10 +02:00
|
|
|
XSL=dump-lfs-scripts.xsl
|
2005-10-03 02:56:55 +02:00
|
|
|
FNC=functions
|
2005-09-28 21:30:31 +02:00
|
|
|
if [ -z $TEST ] ; then TEST=0 ; fi
|
2005-09-11 23:03:26 +02:00
|
|
|
|
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-09-11 23:03:26 +02:00
|
|
|
get_book() {
|
|
|
|
# Check for Subversion instead of just letting the script hit 'svn' and fail.
|
|
|
|
test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
2005-09-25 18:56:00 +02:00
|
|
|
exit 1"
|
2005-09-11 23:33:50 +02:00
|
|
|
cd $JHALFSDIR
|
2005-09-12 20:23:41 +02:00
|
|
|
|
2005-09-11 23:03:26 +02:00
|
|
|
# Test to make sure the LFS version is set
|
|
|
|
if [ -z $LFSVRS ] ; then LFSVRS=development ; fi
|
2005-10-02 16:06:01 +02:00
|
|
|
|
2005-10-02 16:28:31 +02:00
|
|
|
# Set the book's sources directory
|
2005-10-02 16:06:01 +02:00
|
|
|
if [ -z $BOOK ] ; then BOOK=lfs-$LFSVRS ; fi
|
|
|
|
|
|
|
|
if [ -z $WC ] ; then
|
|
|
|
echo -n "Downloading the LFS Book, version $LFSVRS... "
|
|
|
|
|
|
|
|
# Grab the LFS book fresh if it's missing, otherwise, update it from the
|
|
|
|
# repo. If we've already extracted the commands, move on to getting the
|
|
|
|
# sources.
|
|
|
|
if [ -d lfs-$LFSVRS ] ; then
|
|
|
|
cd lfs-$LFSVRS
|
|
|
|
if svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
|
|
|
test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
|
|
|
echo -ne "done\n"
|
|
|
|
get_sources
|
|
|
|
else
|
|
|
|
echo -ne "done\n"
|
|
|
|
extract_commands
|
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
else
|
2005-10-02 16:06:01 +02:00
|
|
|
if [ $LFSVRS = development ] ; then
|
2005-10-04 00:00:09 +02:00
|
|
|
svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
2005-10-02 16:06:01 +02:00
|
|
|
else
|
2005-10-04 00:00:09 +02:00
|
|
|
svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1
|
2005-10-02 16:06:01 +02:00
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
echo -ne "done\n"
|
|
|
|
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-09-25 18:56:00 +02:00
|
|
|
extract_commands
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_commands() {
|
|
|
|
# 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-09-28 21:30:31 +02:00
|
|
|
xsltproc --nonet --xinclude --stringparam testsuite $TEST -o ./commands/ \
|
2005-10-04 00:00:09 +02:00
|
|
|
$XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
2005-09-11 23:03:26 +02:00
|
|
|
|
2005-10-05 19:26:35 +02:00
|
|
|
# Make the scripts executables.
|
|
|
|
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-10-06 20:03:52 +02:00
|
|
|
echo `grep "glibc" packages | sed 's@glibc@glibc-linuxthreads@'` >> packages
|
2005-10-02 16:06:01 +02: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
|
|
|
|
}
|
|
|
|
|
|
|
|
download() {
|
|
|
|
cd $BUILDDIR/sources
|
|
|
|
|
2005-10-06 20:03:52 +02:00
|
|
|
# Hackish fix for the bash-doc and glibc-linuxthreads packages that
|
|
|
|
# doesn't conform to norms in the URL scheme.
|
|
|
|
DIR=`echo $1 | sed -e 's@-doc@@' -e 's@-linuxthreads@@'`
|
2005-09-11 23:03:26 +02:00
|
|
|
|
|
|
|
# Find the md5 sum for this package.
|
|
|
|
if [ $2 != MD5SUMS ] ; then MD5=`grep " $2" MD5SUMS` ; fi
|
|
|
|
|
|
|
|
if [ ! -f $2 ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
case $DL in
|
|
|
|
wget )
|
|
|
|
wget $HTTP/$DIR/$2
|
|
|
|
;;
|
|
|
|
curl )
|
|
|
|
`curl -# $HTTP/$DIR/$2 -o $2`
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
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 )
|
|
|
|
wget -c $HTTP/$DIR/$2
|
|
|
|
;;
|
|
|
|
curl )
|
|
|
|
`curl -# -C - $HTTP/$DIR/$2 -o $2`
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
get_sources() {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
download "" MD5SUMS
|
|
|
|
|
|
|
|
# Iterate through each package and grab it, along with any patches it needs.
|
|
|
|
for i in `cat $JHALFSDIR/packages` ; do
|
|
|
|
PKG=`echo $i | sed 's/-version.*//'`
|
|
|
|
|
|
|
|
# Someone used some silly entities right next to the valid package entities.
|
|
|
|
if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
|
|
|
|
|
|
|
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
|
|
|
if [ "$PKG" = "tcl" ] ; then
|
|
|
|
FILE="$PKG$VRS-src.tar.bz2"
|
|
|
|
else
|
|
|
|
FILE="$PKG-$VRS.tar.bz2"
|
|
|
|
fi
|
|
|
|
download $PKG $FILE
|
|
|
|
for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
|
|
|
|
PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
|
|
|
download $PKG $PATCH
|
|
|
|
done
|
2005-09-12 20:23:41 +02:00
|
|
|
done
|
2005-10-06 20:03:52 +02:00
|
|
|
# Hardcoded Udev configuration file until find a better way
|
|
|
|
download udev udev-config-3.rules
|
2005-09-29 21:14:06 +02:00
|
|
|
fi
|
2005-09-11 23:03:26 +02:00
|
|
|
}
|
|
|
|
|
2005-09-12 03:01:10 +02:00
|
|
|
build_Makefile() {
|
2005-09-12 04:53:48 +02:00
|
|
|
echo -n "Creating Makefile... "
|
2005-09-12 03:01:10 +02:00
|
|
|
cd $JHALFSDIR/commands
|
2005-09-12 20:23:41 +02:00
|
|
|
|
2005-09-12 03:01:10 +02:00
|
|
|
# Start with a clean Makefile.tmp file
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
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-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
|
|
|
|
FILE="$name$vrs-src.tar.bz2"
|
|
|
|
else
|
|
|
|
FILE="$name-$vrs.tar.bz2"
|
|
|
|
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)
|
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
|
|
|
|
echo "export PKGDIR" >> envars && \\
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
fi
|
2005-09-25 18:56:00 +02:00
|
|
|
|
2005-10-04 00:00:09 +02:00
|
|
|
# Dump the path to the Binutils or TCL sources directory.
|
|
|
|
if [ "$i" = "027-binutils-pass1" -o "$i" = "032-tcl" -o "$i" = "036-binutils-pass2" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-09-30 22:47:34 +02:00
|
|
|
|
2005-10-01 14:21:30 +02:00
|
|
|
# For the Adjusting phase we must to cd to the binutils-build directory.
|
2005-10-03 02:56:55 +02:00
|
|
|
elif [ "$i" = "031-adjusting" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\
|
|
|
|
echo "export PKGDIR" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-09-30 20:51:32 +02:00
|
|
|
|
2005-10-02 14:05:57 +02:00
|
|
|
# For the Expect build we need to set the TCLPATH envar.
|
2005-10-03 02:56:55 +02:00
|
|
|
elif [ "$i" = "033-expect" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
echo "TCLPATH=\`cat sources-dir\`" >> envars && \\
|
|
|
|
echo "export TCLPATH" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 02:56:55 +02:00
|
|
|
|
|
|
|
# Everything else, add a true statment so we don't confuse make
|
|
|
|
else
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
true
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
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
|
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
|
|
|
|
su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
|
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >>logs/$i
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-01 14:21:30 +02:00
|
|
|
|
|
|
|
# Remove the build directory(ies) even if the package build fails, except for
|
2005-10-02 11:14:02 +02:00
|
|
|
# Binutils and TCL. In that cases the sources directories are removed
|
2005-10-01 14:21:30 +02:00
|
|
|
# only if the build fails.
|
|
|
|
if [ "$vrs" != "" ] ; then
|
2005-10-02 11:14:02 +02:00
|
|
|
if [ "$i" != "027-binutils-pass1" ] && [ "$i" != "032-tcl" ] && [ "$i" != "036-binutils-pass2" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/$name-build; \\
|
|
|
|
fi;
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-01 14:21:30 +02:00
|
|
|
fi
|
|
|
|
fi
|
2005-10-03 20:28:57 +02:00
|
|
|
|
|
|
|
# Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
|
|
|
if [ "$i" = "031-adjusting" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@rm -r \`cat sources-dir\` && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/binutils-build && \\
|
|
|
|
rm sources-dir
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-03 20:28:57 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove the TCL sources after a successful Expect build.
|
|
|
|
if [ "$i" = "033-expect" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@rm -r \`cat sources-dir\` && \\
|
|
|
|
rm sources-dir
|
|
|
|
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
|
|
|
|
|
|
|
# The next two "if" must be after the touch to can check if the sources
|
|
|
|
# directories should be retained or deleted.
|
2005-10-02 11:14:02 +02:00
|
|
|
if [ "$i" = "027-binutils-pass1" -o "$i" = "036-binutils-pass2" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@if [ ! -e \$@ ] ; then \\
|
|
|
|
ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/binutils-build; \\
|
|
|
|
fi;
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-02 11:14:02 +02:00
|
|
|
fi
|
2005-10-04 20:37:09 +02:00
|
|
|
|
2005-10-02 11:14:02 +02:00
|
|
|
if [ "$i" = "032-tcl" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@if [ ! -e \$@ ] ; then \\
|
|
|
|
ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/\$\$ROOT; \\
|
|
|
|
fi;
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-01 14:21:30 +02:00
|
|
|
fi
|
2005-09-29 20:50:18 +02:00
|
|
|
|
2005-10-02 12:28:59 +02:00
|
|
|
# Keep the script file name for Makefile dependencies.
|
|
|
|
PREV=$i
|
2005-09-12 03:01:10 +02:00
|
|
|
done
|
2005-09-12 04:53:48 +02:00
|
|
|
|
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.
|
|
|
|
if echo $i | grep -q "chroot" ; 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\}-@@'`
|
|
|
|
|
|
|
|
# Set the dependency for the first target.
|
|
|
|
if [ -z $PREV ] ; then PREV=055-stripping ; fi
|
|
|
|
|
|
|
|
# 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
|
|
|
|
FILE="$name-$vrs.tar.bz2"
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@\$(call unpack,$FILE)
|
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
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
|
|
|
|
|
|
|
|
# For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
|
|
|
if [ "$i" = "067-readjusting" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\
|
|
|
|
echo "export PKGDIR" >> envars
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
2005-10-04 00:00:09 +02:00
|
|
|
fi
|
2005-10-02 14:05:57 +02:00
|
|
|
|
2005-10-04 21:12:07 +02:00
|
|
|
# In the mount of kernel filesystems we need to set LFS for CHROOT1
|
|
|
|
# and not to use chroot.
|
2005-10-04 00:00:09 +02:00
|
|
|
if [ "$i" = "057-kernfs" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
2005-10-05 19:34:45 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >logs/$i && \\
|
2005-10-05 02:48:28 +02:00
|
|
|
commands/$file >>logs/$i 2>&1 && \\
|
2005-10-04 20:37:09 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=0??-* \$(LFS)\`\n" >>logs/$i
|
|
|
|
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-04 21:12:07 +02:00
|
|
|
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(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-04 20:37:09 +02:00
|
|
|
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=0??-* \$(LFS)\`\n" >>logs/$i
|
|
|
|
EOF
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
2005-10-02 20:03:13 +02:00
|
|
|
fi
|
2005-10-02 14:05:57 +02:00
|
|
|
|
2005-10-02 14:27:21 +02:00
|
|
|
# Remove the build directory(ies) even 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
|
|
|
|
@ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\
|
|
|
|
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 00:39:48 +02:00
|
|
|
# Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
2005-10-02 14:27:21 +02:00
|
|
|
if [ "$i" = "067-readjusting" ] ; then
|
2005-10-04 20:37:09 +02:00
|
|
|
(
|
|
|
|
cat << EOF
|
|
|
|
@rm -r \`cat sources-dir\` && \\
|
|
|
|
rm -r \$(LFS)\$(SRC)/binutils-build && \\
|
|
|
|
rm sources-dir
|
|
|
|
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
|
|
|
|
done
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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-05 02:35:13 +02:00
|
|
|
-e 's/ */ /g' -e 's|\\$|&&|g' -e 's|&&exit||g' -e 's|$| -c|' -e 's|"$$LFS"|$(LFS)|'`
|
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-05 02:13:29 +02:00
|
|
|
all: chapter4 chapter5 chapter6
|
2005-10-04 20:37:09 +02:00
|
|
|
@echo -e "\n\tYour new LFS system has been successfully built"
|
|
|
|
|
|
|
|
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
|
|
|
|
|
|
|
chapter5: chapter4 $chapter5
|
|
|
|
|
|
|
|
chapter6: chapter5 $chapter6
|
|
|
|
|
|
|
|
clean-all: clean
|
|
|
|
rm -rf ./*
|
|
|
|
|
|
|
|
clean: clean-chapter5 clean-chapter4
|
|
|
|
|
|
|
|
clean-chapter4:
|
|
|
|
-userdel lfs
|
|
|
|
rm -rf /home/lfs
|
|
|
|
rm -rf \$(LFS)/tools
|
|
|
|
rm -f /tools
|
|
|
|
rm -f envars
|
|
|
|
rm -f 02* logs/02*.log
|
|
|
|
|
|
|
|
clean-chapter5:
|
|
|
|
rm -rf \$(LFS)/tools/*
|
|
|
|
rm -f envars
|
|
|
|
rm -f $chapter5
|
|
|
|
cd logs && rm -f $chapter5 && cd ..
|
|
|
|
|
|
|
|
020-creatingtoolsdir:
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@mkdir -v \$(LFS)/tools && \\
|
|
|
|
ln -sv \$(LFS)/tools / && \\
|
|
|
|
touch \$@
|
|
|
|
|
|
|
|
021-addinguser: 020-creatingtoolsdir
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@groupadd lfs && \\
|
|
|
|
useradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\
|
|
|
|
chown lfs \$(LFS)/tools && \\
|
|
|
|
chown lfs \$(LFS)/sources && \\
|
|
|
|
touch \$@
|
|
|
|
|
|
|
|
022-settingenvironment: 021-addinguser
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
@echo "exec env -i HOME=\\\$\$HOME TERM=\\\$\$TERM PS1='\u:\w\$$ ' /bin/bash" > /home/lfs/.bash_profile && \\
|
|
|
|
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 ". $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
|
|
|
chown lfs:lfs /home/lfs/.bash* && \\
|
|
|
|
touch envars && \\
|
|
|
|
touch \$@
|
|
|
|
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-09-30 22:47:34 +02:00
|
|
|
run_make() {
|
2005-10-02 11:14:02 +02:00
|
|
|
# Test if make must be run.
|
|
|
|
if [ "$RUNMAKE" = "1" ] ; then
|
|
|
|
# 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-09-11 23:33:50 +02:00
|
|
|
if [ ! -d $JHALFSDIR ] ; then
|
2005-09-25 18:56:00 +02:00
|
|
|
mkdir -p $JHALFSDIR
|
2005-09-11 23:03:26 +02:00
|
|
|
fi
|
|
|
|
|
2005-10-04 00:00:09 +02:00
|
|
|
if [ ! -d $LOGDIR ] ; then
|
|
|
|
mkdir $LOGDIR
|
2005-09-30 00:05:00 +02:00
|
|
|
fi
|
|
|
|
|
2005-10-04 00:00:09 +02:00
|
|
|
>$LOGDIR/$LOG
|
2005-09-26 20:11:48 +02:00
|
|
|
|
|
|
|
if [ "$PWD" != "$JHALFSDIR" ] ; then
|
2005-10-03 02:56:55 +02:00
|
|
|
cp $0 $XSL $FNC $JHALFSDIR/
|
2005-09-26 20:11:48 +02:00
|
|
|
fi
|
|
|
|
|
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
|