[project @ 2000-04-30 01:42:23 by chak]
authorchak <unknown>
Sun, 30 Apr 2000 01:42:23 +0000 (01:42 +0000)
committerchak <unknown>
Sun, 30 Apr 2000 01:42:23 +0000 (01:42 +0000)
The first version of a script that allows building rpm packages directly from
CVS.  It currently works for ghc only, but will be extended to cover the
other fptools.

It should work on all rpm-based systems, as I tried to avoid any dependency on
Red Hat systems (as far as I am aware of them).  In particular, the rpm build
process is carried out below /tmp instead of the standard /usr/src/redhat
hierarchy.

By default the cvs head of the anonymous repository is built, but cvs-style -d
-D, and -r options allow to built from a different repository and revision.

[This version is only half tested, because the CVS head seems to not build
anymore today.]

distrib/cvs-build [new file with mode: 0644]

diff --git a/distrib/cvs-build b/distrib/cvs-build
new file mode 100644 (file)
index 0000000..e2b1d97
--- /dev/null
@@ -0,0 +1,142 @@
+#!/bin/sh
+# *** Does this actually work with sh, or does it have to be bash? ***
+
+# Purpose: Builds rpm binaries out of CVS
+# Author : Manuel M. T. Chakravarty <chak@acm.org>
+# Created: 26 April 2000
+#
+# This file is subject to the same free software license as GHC.
+
+# Usage
+# -----
+#
+# This script checks the given version of an fptools component out of CVS and
+# builds a binary rpm package from it.  By default it builds the CVS head from
+# anonymous CVS.  In the case of anonymous CVS, this script requires that `cvs 
+# login' was already executed.
+#
+# The current version of this script handles ghc only, but in fact it is 
+# planned to extend it to cover the other components in fptools.
+#
+# Options:
+#
+# -d REPOSITORY -- Value passed to CVS's -d option
+# -r TAG       -- build the revision identified by the given CVS tag
+# -D DATE      -- build the revision identified by the given CVS date
+#
+# (if there is more than one of the options -r and -D, the last one takes 
+# effect)
+
+# Requires: autoconf, cvs, GNU tar, gnuopt
+
+# Default values
+# --------------
+
+# Use anonymous CVS by default
+#
+CVS_REPOSITORY=:pserver:anoncvs@glass.cse.ogi.edu:/cvs
+
+# We build the CVS head by default (indicated by an empty tag)
+#
+CVS_TAG=
+
+# This is where we let rpm do the actual build
+#
+BUILD_DIR=/tmp/cvs-build-$$
+
+START_DIR=`pwd`
+
+# Command line option processing
+#
+GETOPT_OUTOUT=`getopt -o d:r:D: -n $0 -- "$@"`
+if [ $? != 0 ]; then 
+  echo "Terminating..." >&2
+  exit 1
+fi
+
+eval set -- "$GETOPT_OUTPUT"
+while [ $# -gt 0 ]; do
+  case "$1" in
+    -d) CVS_REPOSITORY=$2; shift 2;;
+    -r) CVS_TAG="-r $2"; shift 2;;
+    -D) CVS_TAG="-D $2"; shift 2;;
+    --) shift; break;;
+     *) echo "Internal error!" ; exit 1 ;;
+  esac
+done
+
+if [ $# != 0 ]; then
+  echo "Too many arguments..." >&2
+  exit 1
+fi
+
+# Check the sources out of CVS
+#
+echo "*** Checking sources out of 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
+cd fptools
+cvs checkout $CVS_TAG ghc    || exit 1
+cvs checkout $CVS_TAG hslibs || exit 1
+
+VERSION=`sed -e 's/.*\([0-9]\)\.\([0-9]*\).*/\1.\2/' ghc/VERSION`
+echo "*** ...got ghc $VERSION"
+
+
+# Configure the tree (will produce the .spec file)
+#
+echo "*** Configuring sources..."
+autoconf
+cd ghc; autoconf; cd ..
+./configure || exit 1
+
+# Populate the rpm build tree
+#
+echo "*** Setting up the rpm build tree..."
+mkdir $BUILD_DIR/SPEC
+mkdir $BUILD_DIR/SOURCES
+mkdir $BUILD_DIR/BUILD
+mkdir $BUILD_DIR/RPMS
+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
+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
+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/SRPMS/ghc* .
+rm -rf $BUILD_DIR
+
+echo "*** ...done."