#!/bin/bash
set -e

NAME=eclipse-remote-services-api
VERSION=8.0
DEB_VERSION=8.0.0

ECLIPSE_GIT_WEB=http://git.eclipse.org/c

rm -rf ${NAME}-${DEB_VERSION}

VERSION_UNDERSCORE=$(echo $VERSION | sed "s/\./_/g")
REPO_NAME=org.eclipse.remote

TARBALL=PTP_${VERSION_UNDERSCORE}.tar.bz2

wget "$ECLIPSE_GIT_WEB/ptp/$REPO_NAME.git/snapshot/$TARBALL"
tar xf $TARBALL
rm -f $TARBALL

mv $(basename $TARBALL .tar.bz2) ${NAME}-${DEB_VERSION}
cd ${NAME}-${DEB_VERSION}

rm -rf releng tests

find -type f -name .gitignore -delete
find -type f -name .cvsignore -delete

# remove empty directories
find . -depth -type d -empty -delete

cd ..

echo "Creating tarball '${NAME}_${DEB_VERSION}.orig.tar.xz'..."
tar -cJf ../${NAME}_${DEB_VERSION}.orig.tar.xz $NAME-$DEB_VERSION

rm -rf ${NAME}-${DEB_VERSION}
