File update-snapshots.sh of Package flashrom

#!/bin/bash

export LC_ALL=C
# get upstream revisions
printf "Checking flashrom revision... "
VERSION=`svn cat svn://flashrom.org/flashrom/trunk/Makefile|grep ^RELEASE\ | cut -f2 -d= |cut -c2-`
REV=$(svn info svn://flashrom.org/flashrom/trunk |grep  ^Revision|cut -c11-)
printf "done. (r$REV)\n"

printf "Continue? (YES/no) "
read answer
answer=$(echo $answer|tr "a-z" "A-Z")
if [ "$answer" == "YES" -o "$answer" == "Y" -o "$answer" == "" ]; then
  printf "Updating tree... \n"
else
  printf "Good bye.\n"
  exit 0
fi

if [ ! -r flashrom-${VERSION}_r$REV.tar.bz2 ]; then
	osc rm flashrom-*.tar.bz2
fi

# clean up
printf "Cleaning up... "
rm -rf flashrom-${VERSION}_r????
rm -rf flashrom-${VERSION}_r???
printf "done.\n"

# check out flashrom
printf "Checking out flashrom $VERSION r$REV... "
svn export -q svn://flashrom.org/flashrom/trunk flashrom-${VERSION}_r$REV
sed -i "s/^SVNVERSION.*/SVNVERSION := $REV/" flashrom-${VERSION}_r$REV/Makefile
LC_ALL=C svn log svn://flashrom.org/flashrom/trunk/ >flashrom-${VERSION}_r$REV/ChangeLog

printf "packing... "
tar cjf flashrom-${VERSION}_r$REV.tar.bz2 flashrom-${VERSION}_r$REV
printf "done.\n"

sed -i s/Version:.*r[0-9].*$/Version:\ \ \ \ \ \ \ \ ${VERSION}_r$REV/ \
	flashrom.spec

osc add flashrom-${VERSION}_r$REV.tar.bz2
mv flashrom.changes flashrom.changes.old
echo "-------------------------------------------------------------------" > \
	     flashrom.changes
echo "`date` - stepan@coresystems.de" >> \
	     flashrom.changes
echo >> flashrom.changes
echo "- update to $VERSION r$REV." >> flashrom.changes
echo >> flashrom.changes
cat flashrom.changes.old >> flashrom.changes
rm flashrom.changes.old

rm -rf flashrom-${VERSION}_r$REV

# finished.
ls -la *.bz2
openSUSE Build Service is sponsored by