#!/bin/bash

WEBDIR=$HOME/spamassassin.taint.org

vers=`build/get_version`				# 2.60-rc3
minivers=`echo $vers | sed -e 's/-[a-z0-9A-Z]*$//'`	# 2.60

# delete old CVS files
find . -name '.#*' -print | xargs rm -f

make distclean ; perl Makefile.PL < /dev/null
make
make text_html_doc
make distcheck

echo $vers > $WEBDIR/latest_version

rm -f Mail-SpamAssassin-$vers.tar.bz2 Mail-SpamAssassin-$vers.tar.gz Mail-SpamAssassin-$vers.zip
make tardist
make zipdist
gzip -dc Mail-SpamAssassin-$minivers.tar.gz | bzip2 -9c - > Mail-SpamAssassin-$minivers.tar.bz2

for ext in tar.bz2 tar.gz zip ; do
  if [ $minivers != $vers ] ; then
    mv Mail-SpamAssassin-$minivers.$ext Mail-SpamAssassin-$vers.$ext
  fi

  cp Mail-SpamAssassin-$vers.$ext $WEBDIR/devel

  md5sum Mail-SpamAssassin-$vers.$ext \
	  > $WEBDIR/devel/Mail-SpamAssassin-$vers.$ext.md5

  sha1sum Mail-SpamAssassin-$vers.$ext \
	  > $WEBDIR/devel/Mail-SpamAssassin-$vers.$ext.sha1

  gpgsign=$HOME/bin/gpgsign
  rm -f Mail-SpamAssassin-$vers.$ext.asc
  $gpgsign Mail-SpamAssassin-$vers.$ext
  mv Mail-SpamAssassin-$vers.$ext.asc $WEBDIR/devel/Mail-SpamAssassin-$vers.$ext.asc

  rm -f Mail-SpamAssassin-$vers.$ext
done

test -f Makefile && make distclean

# ( cd $WEBDIR/devel && cvs add -kb *SpamAssassin* )

ls -l $WEBDIR/devel
