Blame SOURCES/dl-tests.sh

f0733c
#!/bin/bash
f0733c
f0733c
tag=$(sed -n 's/^Version:\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
f0733c
url=$(sed -n 's/^URL:\s\(.*\)$/\1/p' ./*.spec | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
f0733c
pkgdir=$(basename $url | sed -s 's/\.git$//')
f0733c
f0733c
echo "tag: $tag"
f0733c
echo "URL: $url"
f0733c
echo "pkgdir: $pkgdir"
f0733c
f0733c
set -e
f0733c
f0733c
tmp=$(mktemp -d)
f0733c
f0733c
trap cleanup EXIT
f0733c
cleanup() {
f0733c
    echo Cleaning up...
f0733c
    set +e
f0733c
    [ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp"
f0733c
}
f0733c
f0733c
unset CDPATH
f0733c
pwd=$(pwd)
f0733c
f0733c
pushd "$tmp"
f0733c
git clone $url
f0733c
cd $pkgdir
f0733c
echo Finding git tag
f0733c
gittag=$(git show-ref --tags | cut -d' ' -f2 | grep '${tag}$'||git show-ref --tags | cut -d' ' -f2 | sort -nr | head -n1)
f0733c
echo "Git Tag: $gittag"
f0733c
if [ -z $gittag ]; then
f0733c
	gittag=tags/$tag
f0733c
fi
f0733c
git archive --prefix='test/' --format=tar ${gittag}:test/ \
f0733c
    | bzip2 > "$pwd"/tests-${tag}.tar.bz2
f0733c
popd