- make cabal2spec work on .cabal files too, and read and check name and
version from .cabal
This commit is contained in:
parent
9c2030439c
commit
74a3f2521e
46
cabal2spec
46
cabal2spec
@ -2,29 +2,47 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
[ $# -ne 1 -o ! -r "$1" ] && echo "Usage: $0 hackage-version.tar.gz" && exit 1
|
[ $# -ne 1 -o ! -r "$1" ] && echo "Usage: $(basename $0) [hackage.tar.gz|hackage.cabal]" && exit 1
|
||||||
|
|
||||||
HACKAGE=$1
|
FILE=$1
|
||||||
|
|
||||||
INPUT=$(basename $HACKAGE .tar.gz)
|
case $FILE in
|
||||||
|
*.tar.gz)
|
||||||
|
TARNAME_VER=$(basename $FILE .tar.gz)
|
||||||
|
TARVERSION=$(echo $TARNAME_VER | sed -e "s/.*-//")
|
||||||
|
TARNAME=$(echo $TARNAME_VER | sed -e "s/-$TARVERSION//")
|
||||||
|
WORKDIR=$(mktemp -d)
|
||||||
|
tar zxf $FILE -C $WORKDIR "*.cabal"
|
||||||
|
CABAL="$WORKDIR/*/*.cabal" ;;
|
||||||
|
*.cabal)
|
||||||
|
CABAL=$FILE ;;
|
||||||
|
esac
|
||||||
|
|
||||||
VERSION=$(echo $INPUT | sed -e "s/.*-//")
|
NAME=$(grep -i ^name: $CABAL | sed -e "s/[Nn]ame:[ \t]*//")
|
||||||
NAME=$(echo $INPUT | sed -e "s/-$VERSION//")
|
if [ -n "$TARNAME" -a "$TARNAME" != "$NAME" ]; then
|
||||||
|
echo "Warning: tarball name ($TARNAME) and cabal name ($NAME) differ!"
|
||||||
|
fi
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
VERSION=$(grep -i ^version: $CABAL | sed -e "s/[Vv]ersion:[ \t]*//")
|
||||||
CURRENT_DIR=$PWD
|
if [ -n "$TARVERSION" -a "$TARVERSION" != "$VERSION" ]; then
|
||||||
cd $TMPDIR
|
echo "Warning: tarball version ($TARVERSION) and cabal version ($VERSION) differ!"
|
||||||
tar zxf $HACKAGE "*.cabal"
|
fi
|
||||||
|
|
||||||
if grep -qi exposed-modules: */*.cabal; then
|
CABALFILENAME=$(basename $CABAL .cabal)
|
||||||
|
if [ "$CABALFILENAME" != "$NAME" ]; then
|
||||||
|
echo "Warning: .cabal filename ($CABALFILENAME) and cabal Name field ($NAME) differ!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if grep -qi exposed-modules: $CABAL; then
|
||||||
HAS_LIB=yes
|
HAS_LIB=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -qi executable */*.cabal; then
|
if grep -qi executable $CABAL; then
|
||||||
HAS_BIN=yes
|
HAS_BIN=yes
|
||||||
fi
|
fi
|
||||||
cd -
|
|
||||||
rm -rf $TMPDIR
|
[ -d "$WORKDIR" ] && rm -r $WORKDIR
|
||||||
|
|
||||||
if [ "$HAS_LIB" -a ! "$HAS_BIN" ]; then
|
if [ "$HAS_LIB" -a ! "$HAS_BIN" ]; then
|
||||||
PREFIX=ghc-
|
PREFIX=ghc-
|
||||||
@ -36,7 +54,7 @@ SPECFILE=$PREFIX$NAME.spec
|
|||||||
|
|
||||||
cp /usr/share/ghc/cabal-${HAS_BIN:+bin}${HAS_LIB:+lib}-template.spec.in $SPECFILE
|
cp /usr/share/ghc/cabal-${HAS_BIN:+bin}${HAS_LIB:+lib}-template.spec.in $SPECFILE
|
||||||
|
|
||||||
echo "created $SPECFILE (${HAS_BIN:+bin}${HAS_LIB:+lib})"
|
echo "created $SPECFILE (${HAS_BIN:+bin}${HAS_LIB:+lib}) for $NAME-$VERSION"
|
||||||
|
|
||||||
DATE=$(env LANG=C date +"%a %b %e %Y")
|
DATE=$(env LANG=C date +"%a %b %e %Y")
|
||||||
|
|
||||||
|
4
ghc.spec
4
ghc.spec
@ -229,6 +229,10 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Nov 28 2008 Jens Petersen <petersen@redhat.com>
|
||||||
|
- make cabal2spec work on .cabal files too, and
|
||||||
|
read and check name and version from .cabal
|
||||||
|
|
||||||
* Tue Nov 25 2008 Jens Petersen <petersen@redhat.com> - 6.10.1-5
|
* Tue Nov 25 2008 Jens Petersen <petersen@redhat.com> - 6.10.1-5
|
||||||
- add cabal2spec and template files for easy cabal hackage packaging
|
- add cabal2spec and template files for easy cabal hackage packaging
|
||||||
- simplify script macros: make ghc_preinst_script and ghc_postun_script no-ops
|
- simplify script macros: make ghc_preinst_script and ghc_postun_script no-ops
|
||||||
|
Loading…
Reference in New Issue
Block a user