File libuhd_update.sh of Package libuhd
#!/bin/bash
REPO=git://ettus.sourcerepo.com/ettus/uhd.git
WORK_TREE=$(mktemp -d)
NAME=libuhd002
SPECFILE=libuhd.spec
VERSION=1
RELEASE=1
echo "============================="
echo "Checking out gnuradio repository..."
echo "============================="
git clone ${REPO} ${WORK_TREE}
git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} checkout
VERSION=$(git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} show --pretty=format:"%ai" | head -n1 | cut -s -d' ' -f1 | sed -e 's/-//g')
echo ""
echo "============================="
echo "Archiving local repository..."
echo "============================="
# not possible, as CMake needs the .git-Directory
# git --git-dir=${WORK_TREE}/.git --work-tree=${WORK_TREE} archive --prefix=${NAME}-${VERSION}/ --format=tar HEAD:host/ | bzip2 -c > ${NAME}-${VERSION}.tar.bz2
tar -cjvf ${NAME}-${VERSION}.tar.bz2 --absolute-names --transform="s,^${WORK_TREE}/,${NAME}-${VERSION}/," --show-transformed-names ${WORK_TREE}
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}
rm -rf ${WORK_TREE}