2 # *** Does this actually work with sh, or does it have to be bash? ***
4 # Purpose: Builds rpm binaries out of CVS
5 # Author : Manuel M. T. Chakravarty <chak@acm.org>
6 # Created: 26 April 2000
8 # This file is subject to the same free software license as GHC.
13 # This script checks the given version of an fptools component out of CVS and
14 # builds a binary rpm package from it. By default it builds the CVS head from
15 # anonymous CVS. In the case of anonymous CVS, this script requires that `cvs
16 # login' was already executed.
18 # The current version of this script handles ghc only, but in fact it is
19 # planned to extend it to cover the other components in fptools.
23 # -d REPOSITORY -- Value passed to CVS's -d option
24 # -r TAG -- build the revision identified by the given CVS tag
25 # -D DATE -- build the revision identified by the given CVS date
27 # (if there is more than one of the options -r and -D, the last one takes
30 # Requires: autoconf, cvs, GNU tar, gnuopt
35 # * cover other fptools
36 # * it would be convenient to be able to specify an alternative .spec file
37 # (instead of using that in the repository)
42 # Use anonymous CVS by default
44 CVS_REPOSITORY=:pserver:anoncvs@glass.cse.ogi.edu:/cvs
46 # We build the CVS head by default (a date of `tomorrow' guarantees to catch
47 # the most recent check ins in the presence of clock skews - `now' wouldn't do
52 # This is where we let rpm do the actual build
54 BUILD_DIR=/tmp/cvs-build-$$
56 # Works only for i386 for the moment...
62 # Command line option processing
64 GETOPT_OUTOUT=`getopt -o d:r:D: -n $0 -- "$@"`
66 echo "Terminating..." >&2
70 eval set -- "$GETOPT_OUTPUT"
71 while [ $# -gt 0 ]; do
73 -d) CVS_REPOSITORY=$2; shift 2;;
74 -r) CVS_TAG="-r $2"; shift 2;;
75 -D) CVS_TAG="-D $2"; shift 2;;
77 *) echo "Internal error!" ; exit 1 ;;
82 echo "Too many arguments..." >&2
86 # Check the sources out of CVS
88 echo "*** Exporting sources from CVS... (will build in $BUILD_DIR)"
89 mkdir -p $BUILD_DIR || exit 1
91 cvs -d $CVS_REPOSITORY export $CVS_TAG fpconfig || exit 1
93 cvs -d $CVS_REPOSITORY export $CVS_TAG ghc || exit 1
94 cvs -d $CVS_REPOSITORY export $CVS_TAG hslibs || exit 1
96 VERSION=`sed -e 's/.*\([0-9]\)\.\([0-9]*\).*/\1.\2/' ghc/VERSION`
97 echo "*** ...got ghc $VERSION"
100 # Configure the tree (will produce the .spec file)
102 echo "*** Configuring sources..."
104 cd ghc; autoconf; cd ..
105 ./configure || exit 1
107 # Populate the rpm build tree
109 echo "*** Setting up the rpm build tree..."
110 mkdir $BUILD_DIR/SPEC
111 mkdir $BUILD_DIR/SOURCES
112 mkdir $BUILD_DIR/BUILD
113 mkdir $BUILD_DIR/RPMS
114 mkdir $BUILD_DIR/RPMS/$ARCH
115 mkdir $BUILD_DIR/SRPMS
117 cp ghc/ghc.spec $BUILD_DIR/SPEC/ghc-${VERSION}.spec
119 tar -cz -f $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz fptools || exit 1
120 rm -rf $BUILD_DIR/fptools
122 # Build packages with rpm
124 echo "*** Building packages..."
125 rpm --define "_topdir $BUILD_DIR" -ba SPEC/ghc-${VERSION}.spec || exit 1
126 echo "*** ...made the packages"
130 echo "*** Cleaning up..."
132 cp $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz .
133 cp $BUILD_DIR/RPMS/$ARCH/ghc* .
134 cp $BUILD_DIR/SRPMS/ghc* .