File buildtarball.sh of Package guam-selfcontained-otp18

#!/bin/bash

set -e
set -x

VERSION=0.9.13
NAME=guam-$VERSION
BRANCH=master

ROOT_DIR=$(pwd)

REBAR=$(which rebar3 || echo './rebar3')

rm -Rf /tmp/$NAME
mkdir /tmp/$NAME
cd /tmp/$NAME

rm -f $NAME.tar.gz
[ -d "$NAME" ] && rm -rf "$NAME"
git clone --branch ${BRANCH} ssh://git@git.kolab.org/diffusion/G/guam.git $NAME

pushd $NAME
$REBAR deps

# Copy all dependencies to _checkouts, so they are available when building the rpm without internet access
mkdir -p _checkouts
cp -R _build/default/lib/* _checkouts/
cp -R _build/default/plugins/* _checkouts/

mkdir -p cache
cp -r ~/.cache/rebar3 cache/rebar3
tar --transform "s,^\.,guam-${VERSION}," --exclude="_build/test" --exclude=".git" --exclude="_build" -czf "$ROOT_DIR/$NAME.tar.gz" .
popd

cd $ROOT_DIR