2008-11-25 02:52:10 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
set -e
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
[ $# -ne 1 -o ! -r $1 ] && echo "Usage: $0 hackage-version.tar.gz" && exit 1
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
HACKAGE=$1
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
INPUT=$(basename $HACKAGE .tar.gz)
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
VERSION=$(echo $INPUT | sed -e "s/.*-//")
|
2008-11-25 02:52:10 +00:00
|
|
|
NAME=$(echo $INPUT | sed -e "s/-$VERSION//")
|
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
CURRENT_DIR=$PWD
|
|
|
|
cd $TMPDIR
|
|
|
|
tar zxf $HACKAGE "*.cabal"
|
|
|
|
|
|
|
|
if grep -qi exposed-modules: */*.cabal; then
|
|
|
|
HAS_LIB=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -qi executable */*.cabal; then
|
|
|
|
HAS_BIN=yes
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
rm -rf $TMPDIR
|
|
|
|
|
|
|
|
if [ "$HAS_LIB" -a ! "$HAS_BIN" ]; then
|
|
|
|
PREFIX=ghc-
|
|
|
|
fi
|
|
|
|
|
|
|
|
SPECFILE=$PREFIX$NAME.spec
|
|
|
|
|
|
|
|
[ -r $SPECFILE ] && echo "$SPECFILE already exists!" && exit 1
|
|
|
|
|
|
|
|
cp /usr/share/ghc/cabal-${HAS_BIN:+bin}${HAS_LIB:+lib}-template.spec.in $SPECFILE
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
echo "created $SPECFILE (${HAS_BIN:+bin}${HAS_LIB:+lib})"
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
DATE=$(env LANG=C date +"%a %b %e %Y")
|
2008-11-25 02:52:10 +00:00
|
|
|
|
2008-11-25 09:15:17 +00:00
|
|
|
sed -i -e "s/@PACKAGE@/$NAME/" -e "s/@GHC_VERSION@/$(ghc --numeric-version)/" -e "s/@VERSION@/$VERSION/" -e "s/@DATE@/$DATE/" $SPECFILE
|