2010-10-30 04:34:30 +02:00
#!/bin/bash
2010-11-06 02:06:12 +01:00
release = a
2010-11-06 03:45:24 +01:00
version = 0
issue = 0
2010-11-06 02:06:12 +01:00
branch = trunk
2011-01-21 02:13:28 +01:00
if [ $# -eq 0 ]
then
echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1
fi
2010-11-06 02:06:12 +01:00
while [ $# -gt 0 ]
do
case " $1 " in
2010-11-06 03:45:24 +01:00
-release) release = " $2 " ; shift; ;
-version) version = " $2 " ; shift; ;
-issue) issue = " $2 " ; shift; ;
2010-11-06 02:06:12 +01:00
-branch) branch = " $2 " ; shift; ;
-*) echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1; ;
*) break; ; # terminate while loop
esac
2010-11-06 03:45:24 +01:00
shift
2010-11-06 02:06:12 +01:00
done
if [ $release != "a" -a $release != "b" -a $release != "r" ]
2010-11-06 02:08:31 +01:00
then
2010-11-06 02:06:12 +01:00
echo >& 2 \
"Release must be 'a', 'b' or 'r'."
echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1
fi
2010-11-06 03:45:24 +01:00
if [ $version -ne $version 2> /dev/null ]
2010-11-06 02:06:12 +01:00
then
echo >& 2 \
"Version must be a number."
echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1
fi
2010-11-02 11:00:26 +01:00
2010-11-06 03:45:24 +01:00
if [ $issue -ne $issue 2> /dev/null ]
2010-11-06 02:06:12 +01:00
then
echo >& 2 \
"Issue must be a number."
echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1
fi
2010-10-30 04:34:30 +02:00
2010-11-06 03:45:24 +01:00
if [ $branch != "trunk" ]
2010-11-06 02:06:12 +01:00
then
branch = branches/$branch
svn ls https://questhelperredux.googlecode.com/svn/$branch >/dev/null 2>& 1
if [ $? -ne 0 ]
then
echo >& 2 \
"Branch exists."
echo >& 2 \
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
exit 1
fi
fi
command =
2010-11-06 03:45:24 +01:00
if [ $version -gt 0 ]
2010-11-06 02:06:12 +01:00
then
2011-04-28 04:04:07 +02:00
command = " export -r $version https://questhelperredux.googlecode.com/svn/ $branch build "
2010-11-06 02:06:12 +01:00
else
2011-04-28 04:04:07 +02:00
command = " export https://questhelperredux.googlecode.com/svn/ $branch build "
2010-11-06 02:06:12 +01:00
cd trunk
2010-11-06 03:45:24 +01:00
let version = ` svnversion`
2010-11-06 02:06:12 +01:00
cd ..
fi
echo Exporting files.
svn $command
2010-10-30 04:34:30 +02:00
2010-11-06 02:06:12 +01:00
cd build
2010-10-30 04:34:30 +02:00
2010-11-22 00:33:57 +01:00
release_string = ${ version } ${ release }
2010-11-08 14:28:59 +01:00
2010-11-06 02:06:12 +01:00
echo Replacing version tag and creating package.
2010-11-06 03:45:24 +01:00
if [ $issue -gt 0 ]
2010-11-06 02:06:12 +01:00
then
2010-11-08 14:28:59 +01:00
release_string = " ${ release_string } -i ${ issue } "
2010-11-06 02:06:12 +01:00
fi
2010-10-30 04:34:30 +02:00
2010-11-22 00:33:57 +01:00
sub = " s/\\\$svnversion\\\$/ ${ release_string } /g "
2011-07-01 13:41:00 +02:00
sub2 = 's/4\.0\.1/4\.2\.0/'
2011-04-28 04:04:07 +02:00
echo Replacing version tag in QuestHelper.toc
2010-11-08 14:28:59 +01:00
cp QuestHelper/QuestHelper.toc QuestHelper/QuestHelper.toc.bak
sed -e $sub QuestHelper/QuestHelper.toc.bak > QuestHelper/QuestHelper.toc
rm QuestHelper/QuestHelper.toc.bak
2010-11-28 01:43:26 +01:00
cp QuestHelper/QuestHelper.toc QuestHelper/QuestHelper.toc.bak
sed -e $sub2 QuestHelper/QuestHelper.toc.bak > QuestHelper/QuestHelper.toc
rm QuestHelper/QuestHelper.toc.bak
2010-11-08 14:28:59 +01:00
for lua in ` find QuestHelper -iname "*.lua" `
do
2011-04-28 04:04:07 +02:00
echo Replacing version tag in ${ lua } .
2010-11-08 14:28:59 +01:00
cp $lua $lua .bak
sed -e $sub $lua .bak > $lua
rm $lua .bak
2010-11-28 01:43:26 +01:00
cp $lua $lua .bak
sed -e $sub2 $lua .bak > $lua
rm $lua .bak
2010-11-08 14:28:59 +01:00
done
2011-04-28 04:04:07 +02:00
zip -qdgds 1m -r QuestHelper-4.1.0.${ release_string } .zip QuestHelper/
2010-11-08 14:28:59 +01:00
2010-10-30 04:34:30 +02:00
echo Moving the package up one directory level.
mv -v *.zip ..
cd ..
echo Cleaning up.
rm -rvf build
echo Completed exporting and packaging revision $version