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 # Use anonymous CVS by default
37 CVS_REPOSITORY=:pserver:anoncvs@glass.cse.ogi.edu:/cvs
39 # We build the CVS head by default (indicated by an empty tag)
43 # This is where we let rpm do the actual build
45 BUILD_DIR=/tmp/cvs-build-$$
49 # Command line option processing
51 GETOPT_OUTOUT=`getopt -o d:r:D: -n $0 -- "$@"`
53 echo "Terminating..." >&2
57 eval set -- "$GETOPT_OUTPUT"
58 while [ $# -gt 0 ]; do
60 -d) CVS_REPOSITORY=$2; shift 2;;
61 -r) CVS_TAG="-r $2"; shift 2;;
62 -D) CVS_TAG="-D $2"; shift 2;;
64 *) echo "Internal error!" ; exit 1 ;;
69 echo "Too many arguments..." >&2
73 # Check the sources out of CVS
75 echo "*** Checking sources out of CVS... (will build in $BUILD_DIR)"
76 mkdir -p $BUILD_DIR || exit 1
78 cvs -d $CVS_REPOSITORY checkout $CVS_TAG fpconfig || exit 1
80 cvs checkout $CVS_TAG ghc || exit 1
81 cvs checkout $CVS_TAG hslibs || exit 1
83 VERSION=`sed -e 's/.*\([0-9]\)\.\([0-9]*\).*/\1.\2/' ghc/VERSION`
84 echo "*** ...got ghc $VERSION"
87 # Configure the tree (will produce the .spec file)
89 echo "*** Configuring sources..."
91 cd ghc; autoconf; cd ..
94 # Populate the rpm build tree
96 echo "*** Setting up the rpm build tree..."
98 mkdir $BUILD_DIR/SOURCES
99 mkdir $BUILD_DIR/BUILD
100 mkdir $BUILD_DIR/RPMS
101 mkdir $BUILD_DIR/SRPMS
104 mkdir $BUILD_DIR/RPMS/i386
106 cp ghc/ghc.spec $BUILD_DIR/SPEC/ghc-${VERSION}.spec
108 tar -cz --exclude='*CVS' -f $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz fptools\
110 rm -rf $BUILD_DIR/fptools
112 # set up the configuration for rpm
114 # * !!! this is not really elegant - any better idea?
116 our_rcfile=$BUILD_DIR/rpmrc
117 our_macrofile=$BUILD_DIR/rpmmacros
118 cat >$our_rcfile <<END
119 macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:$our_macrofile
122 cat >$our_macrofile <<END
126 # Build packages with rpm
128 echo "*** Building packages..."
129 rcfiles=/usr/lib/rpm/rpmrc:$our_rcfile
130 rpm --rcfile "$rcfiles" -ba SPEC/ghc-${VERSION}.spec || exit 1
131 echo "*** ...made the packages"
135 echo "*** Cleaning up..."
137 cp $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz .
138 cp $BUILD_DIR/RPMS/ghc* .
139 cp $BUILD_DIR/SRPMS/ghc* .