File release-snapshot.sh of Package python-pyside-tools

#!/bin/bash -x
# based on Emulators:Wine/wine by meissner
appname="pyside-tools"
specfile="python-pyside-tools"
bsdir="/home/carlos/devel/obs/home:cgoncalves:pyside:devel/$specfile"
snapdir="/home/carlos/devel/scm/pyside/"
xdate=`date +%Y%m%d`

cd $bsdir
rm $appname-*.tar.bz2

cd $snapdir/$appname
head=`cat .git/refs/heads/master`
git pull
newhead=`cat .git/refs/heads/master`
if [ "$newhead" == "$head" ]; then
	echo "*** No git change found ($head/$newhead), no rebuilt package."
  if [ "$1" != "-f" ]; then
	  exit 0
  fi
fi
major=`grep -E '^set\(pyside_tools_MAJOR_VERSION \"' CMakeLists.txt | awk '{print $2}' | cut -b 2`
minor=`grep -E '^set\(pyside_tools_MINOR_VERSION \"' CMakeLists.txt | awk '{print $2}' | cut -b 2`
micro=`grep -E '^set\(pyside_tools_MICRO_VERSION \"' CMakeLists.txt | awk '{print $2}' | cut -b 2`
version=$major.$minor.$micro.$xdate
rversion=$major.$minor.$micro
cd ..
rm $appname-*
ln -s $appname $appname-$version
tar --exclude=.git --exclude=build -cjf $appname-$version.tar.bz2 $appname-$version/.
mv $appname-$version.tar.bz2 $bsdir
cd $bsdir
perl -pi -e "s/$specfile \(Version.*/$specfile \(Version $version\)/;" $specfile.spec
perl -pi -e "s/Version:.*/Version:        $version/;" $specfile.spec
perl -pi -e "s/define rversion.*/define rversion $rversion/;" $specfile.spec
osc addremove
osc vc -m "update to $version"
osc ci -m "update to $version"