Blame dl-tests.sh

Jared K. Smith 14c2cf2
#!/bin/bash
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
tag=$(sed -n 's/^Version:\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
Jared K. Smith 14c2cf2
url=$(sed -n 's/^URL:\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
Jared K. Smith 14c2cf2
pkgdir=$(basename $url | sed -s 's/\.git$//')
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
echo "tag: $tag"
Jared K. Smith 14c2cf2
echo "URL: $url"
Jared K. Smith 14c2cf2
echo "pkgdir: $pkgdir"
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
set -e
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
tmp=$(mktemp -d)
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
trap cleanup EXIT
Jared K. Smith 14c2cf2
cleanup() {
Jared K. Smith 14c2cf2
    echo Cleaning up...
Jared K. Smith 14c2cf2
    set +e
Jared K. Smith 14c2cf2
    [ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp"
Jared K. Smith 14c2cf2
}
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
unset CDPATH
Jared K. Smith 14c2cf2
pwd=$(pwd)
Jared K. Smith 14c2cf2
Jared K. Smith 14c2cf2
pushd "$tmp"
Jared K. Smith 14c2cf2
git clone $url
Jared K. Smith 14c2cf2
cd $pkgdir
Jared K. Smith 14c2cf2
echo Finding git tag
Jared K. Smith 14c2cf2
gittag=$(git show-ref --tags | cut -d' ' -f2 | grep "${tag}$" || git show-ref --tags | cut -d' ' -f2 | sort -Vr | head -n1)
Jared K. Smith 14c2cf2
if [ -z $gittag ]; then
Jared K. Smith 14c2cf2
	gittag=tags/$tag
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
echo "Git Tag: $gittag"
Jared K. Smith 14c2cf2
if [ -d "test" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='test/' --format=tar ${gittag}:test/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/tests-${tag}.tar.bz2
Jared K. Smith 14c2cf2
elif [ -d "tests" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='tests/' --format=tar ${gittag}:tests/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/tests-${tag}.tar.bz2
Jared K. Smith 14c2cf2
elif [ -d "spec" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='spec/' --format=tar ${gittag}:spec/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/tests-${tag}.tar.bz2
Jared K. Smith 14c2cf2
else
Jared K. Smith 14c2cf2
  echo "No test directory found for tag ${gittag}"
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "support" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='support/' --format=tar ${gittag}:support/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/support-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "fixture" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='fixture/' --format=tar ${gittag}:fixture/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/fixture-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "examples" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='examples/' --format=tar ${gittag}:examples/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/examples-${tag}.tar.bz2
Jared K. Smith 14c2cf2
elif [ -d "example" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='example/' --format=tar ${gittag}:example/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/examples-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "tasks" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='tasks/' --format=tar ${gittag}:tasks/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/tasks-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "docs" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='docs/' --format=tar ${gittag}:docs/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/docs-${tag}.tar.bz2
Jared K. Smith 14c2cf2
elif [ -d "doc" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='doc/' --format=tar ${gittag}:doc/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/docs-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "src" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='src/' --format=tar ${gittag}:src/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/src-${tag}.tar.bz2
Jared K. Smith 14c2cf2
elif [ -d "source" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='source/' --format=tar ${gittag}:source/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/source-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "tools" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='tools/' --format=tar ${gittag}:tools/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/tools-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "scripts" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='scripts/' --format=tar ${gittag}:scripts/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/scripts-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "modules" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='modules/' --format=tar ${gittag}:modules/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/modules-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "ts" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='ts/' --format=tar ${gittag}:ts/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/ts-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "build" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='build/' --format=tar ${gittag}:build/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/build-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "fixtures" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='fixtures/' --format=tar ${gittag}:fixtures/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/fixtures-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "mocks" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='mocks/' --format=tar ${gittag}:mocks/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/mocks-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "typings" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='typings/' --format=tar ${gittag}:typings/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/typings-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
if [ -d "templates" ]; then
Jared K. Smith 14c2cf2
  git archive --prefix='templates/' --format=tar ${gittag}:templates/ \
Jared K. Smith 14c2cf2
      | bzip2 > "$pwd"/templates-${tag}.tar.bz2
Jared K. Smith 14c2cf2
fi
Jared K. Smith 14c2cf2
popd