#!/bin/bash

set -e

tmp=$(mktemp -d)

trap cleanup EXIT
cleanup() {
    set +e
    [ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp"
}

unset CDPATH
pwd=$(pwd)

dirname=gecko-mediaplayer

cd "$tmp"
svn checkout http://gecko-mediaplayer.googlecode.com/svn/trunk/ $dirname
cd $dirname
eval `autoconf configure.in | egrep '^[[:blank:]]*VERSION='`
REVISION=`LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2`
find . -type d -name .svn -print0 | xargs -0r rm -rf
cd ..
mv $dirname ${dirname}-${VERSION}
#tar jcf "$pwd"/${dirname}-${VERSION}.svn${REVISION}.tar.bz2 ${dirname}-${VERSION}
tar Jcf "$pwd"/${dirname}-${VERSION}.svn${REVISION}.tar.xz ${dirname}-${VERSION}
cd ${pwd} >/dev/null

exit
