File gnuradio_update.sh of Package gnuradio

#!/bin/bash
REPO=git://gnuradio.org/gnuradio
WORK_TREE=/tmp/gnuradio
NAME=gnuradio
SPECFILE=gnuradio.spec
VERSION=3.3.0
RELEASE=1
VERSION_GIT=v3.3.0

echo "============================="
echo "Checking local repository..."
echo "============================="
git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} status > /dev/null 2>&1
if [ $? -ne 0 ]; then
	echo ""
	echo "============================="
	echo "Git repository ${REPO} isn't checked out yet... doing it..."	
	echo "============================="
	git clone ${REPO} ${WORK_TREE}
else
	echo ""
	echo "============================="
	echo "Switching to ${VERSION_GIT}..."
	echo "============================="
	git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} checkout ${VERSION_GIT}
	echo ""
	echo "============================="
	echo "Cleaning up..."
	echo "============================="
	git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} clean -d -f -x
	echo ""
	echo "============================="
	echo "Resetting..."
	echo "============================="
	git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} reset --hard
fi

if [ ${VERSION_GIT} == 'master' ]; then
	VERSION=$(git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} describe | sed -r 's/^v?(.*)-([0-9]+)-g.*$/\1/')
	RELEASE=$(git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} describe | sed -r 's/^v?(.*)-([0-9]+)-g.*$/\2/')
fi

echo ""
echo "============================="
echo "Archiving local repository..."
echo "============================="
git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} archive --prefix=${NAME}-${VERSION}/ --format=tar HEAD | bzip2 -c > ${NAME}-${VERSION}.tar.bz2
echo ""
echo "============================="
echo "Updateing specfile to"
echo -e "\tName: ${NAME}"
echo -e "\tVersion: ${VERSION}"
echo -e "\tRelease: ${RELEASE}"
echo -e "\tSource: ${NAME}-${VERSION}.tar.gz"
echo "============================="
sed -i \
	-e "s,^%define _name .*$,%define _name ${NAME}," \
	-e "s,^%define _version .*$,%define _version ${VERSION}," \
	-e "s,^%define _release .*$,%define _release ${RELEASE}," \
	-e "s,^%define _src .*$,%define _src ${NAME}-${VERSION}.tar.bz2," \
	${SPECFILE}
openSUSE Build Service is sponsored by