#!/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=luatexja

cd "$tmp"
git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git $dirname
cd $dirname
VERSION=0.0.0
REVISION=`date +%Y%m%d`
find . -type d -name .git -print0 | xargs -0r rm -rf
find . -type f -name ".git*" | xargs rm -f
cd ..
mv $dirname ${dirname}-${VERSION}
tar Jcf "$pwd"/${dirname}-${VERSION}.git${REVISION}.tar.xz ${dirname}-${VERSION}
cd ${pwd} >/dev/null

exit
