# Requires: autoconf, cvs, GNU tar, gnuopt
+# TODO
+# ----
+#
+# * cover other fptools
+# * it would be convenient to be able to specify an alternative .spec file
+# (instead of using that in the repository)
+
# Default values
# --------------
#
CVS_REPOSITORY=:pserver:anoncvs@glass.cse.ogi.edu:/cvs
-# We build the CVS head by default (indicated by an empty tag)
+# We build the CVS head by default (a date of `tomorrow' guarantees to catch
+# the most recent check ins in the presence of clock skews - `now' wouldn't do
+# that)
#
-CVS_TAG=
+CVS_TAG="-D tomorrow"
# This is where we let rpm do the actual build
#
BUILD_DIR=/tmp/cvs-build-$$
+# Works only for i386 for the moment...
+# !!!IMPROVE THIS
+ARCH=i386
+
START_DIR=`pwd`
# Command line option processing
# Check the sources out of CVS
#
-echo "*** Checking sources out of CVS... (will build in $BUILD_DIR)"
+echo "*** Exporting sources from CVS... (will build in $BUILD_DIR)"
mkdir -p $BUILD_DIR || exit 1
cd $BUILD_DIR
-cvs -d $CVS_REPOSITORY checkout $CVS_TAG fpconfig || exit 1
+cvs -d $CVS_REPOSITORY export $CVS_TAG fpconfig || exit 1
cd fptools
-cvs checkout $CVS_TAG ghc || exit 1
-cvs checkout $CVS_TAG hslibs || exit 1
+cvs -d $CVS_REPOSITORY export $CVS_TAG ghc || exit 1
+cvs -d $CVS_REPOSITORY export $CVS_TAG hslibs || exit 1
VERSION=`sed -e 's/.*\([0-9]\)\.\([0-9]*\).*/\1.\2/' ghc/VERSION`
echo "*** ...got ghc $VERSION"
mkdir $BUILD_DIR/SOURCES
mkdir $BUILD_DIR/BUILD
mkdir $BUILD_DIR/RPMS
+mkdir $BUILD_DIR/RPMS/$ARCH
mkdir $BUILD_DIR/SRPMS
-# !!!not nice
-mkdir $BUILD_DIR/RPMS/i386
-
cp ghc/ghc.spec $BUILD_DIR/SPEC/ghc-${VERSION}.spec
cd $BUILD_DIR
-tar -cz --exclude='*CVS' -f $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz fptools\
- || exit 1
+tar -cz -f $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz fptools || exit 1
rm -rf $BUILD_DIR/fptools
-# set up the configuration for rpm
-#
-# * !!! this is not really elegant - any better idea?
-#
-our_rcfile=$BUILD_DIR/rpmrc
-our_macrofile=$BUILD_DIR/rpmmacros
-cat >$our_rcfile <<END
-macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:$our_macrofile
-END
-
-cat >$our_macrofile <<END
-%_topdir $BUILD_DIR
-END
-
# Build packages with rpm
#
echo "*** Building packages..."
-rcfiles=/usr/lib/rpm/rpmrc:$our_rcfile
-rpm --rcfile "$rcfiles" -ba SPEC/ghc-${VERSION}.spec || exit 1
+rpm --define "_topdir $BUILD_DIR" -ba SPEC/ghc-${VERSION}.spec || exit 1
echo "*** ...made the packages"
# Cleaning up
echo "*** Cleaning up..."
cd $START_DIR
cp $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz .
-cp $BUILD_DIR/RPMS/ghc* .
+cp $BUILD_DIR/RPMS/$ARCH/ghc* .
cp $BUILD_DIR/SRPMS/ghc* .
rm -rf $BUILD_DIR