Jared K. Smith 6fbe359
#!/bin/bash
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
tag=$(sed -n 's/^Version:\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
Jared K. Smith 6fbe359
url=https://github.com/babel/babel/
Jared K. Smith 6fbe359
subpackage=$(sed -n 's/^.global packagename\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
echo "*** Working on [$subpackage] version [$tag] *** "
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
set -e
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
tmp=$(mktemp -d)
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
trap cleanup EXIT
Jared K. Smith 6fbe359
cleanup() {
Jared K. Smith 6fbe359
    echo Cleaning up...
Jared K. Smith 6fbe359
    set +e
Jared K. Smith 6fbe359
    [ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp"
Jared K. Smith 6fbe359
}
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
unset CDPATH
Jared K. Smith 6fbe359
pwd=$(pwd)
Jared K. Smith 6fbe359
Jared K. Smith 6fbe359
pushd "$tmp"
Jared K. Smith 6fbe359
git clone $url
Jared K. Smith 6fbe359
cd babel
Jared K. Smith 6fbe359
subdir=packages/${subpackage}
Jared K. Smith 6fbe359
if [ -d "${subdir}/test" ]; then
Jared K. Smith 6fbe359
  git archive --prefix='test/' --format=tar refs/tags/v${tag}:${subdir}/test/ \
Jared K. Smith 6fbe359
      |  bzip2 > "$pwd"/${subpackage}-tests-${tag}.tar.bz2
Jared K. Smith 6fbe359
elif [ -d "${subdir}/tests" ]; then
Jared K. Smith 6fbe359
  git archive --prefix='tests/' --format=tar refs/tags/v${tag}:${subdir}/tests/ \
Jared K. Smith 6fbe359
      |  bzip2 > "$pwd"/${subpackage}-tests-${tag}.tar.bz2
Jared K. Smith 6fbe359
else
Jared K. Smith 6fbe359
  echo "No test directory found for tag ${gittag}"
Jared K. Smith 6fbe359
fi
Jared K. Smith 6fbe359
if [ -d "${subdir}/src" ]; then
Jared K. Smith 6fbe359
  git archive --prefix='src/' --format=tar refs/tags/v${tag}:${subdir}/src/ \
Jared K. Smith 6fbe359
      | bzip2 > "$pwd"/${subpackage}-src-${tag}.tar.bz2
Jared K. Smith 6fbe359
fi
Jared K. Smith 6fbe359
if [ -d "${subdir}/scripts" ]; then
Jared K. Smith 6fbe359
  git archive --prefix='scripts/' --format=tar refs/tags/v${tag}:${subdir}/scripts/ \
Jared K. Smith 6fbe359
      | bzip2 > "$pwd"/${subpackage}-scripts-${tag}.tar.bz2
Jared K. Smith 6fbe359
fi
Jared K. Smith 6fbe359
popd