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 \
2011-07-06 00:15:17 +02:00
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
2011-01-21 02:13:28 +01:00
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 \
2011-07-06 00:15:17 +02:00
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
2010-11-06 02:06:12 +01:00
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 \
2011-07-06 00:15:17 +02:00
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
2010-11-06 02:06:12 +01:00
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 \
2011-07-06 00:15:17 +02:00
" usage: $0 [-release a|b|r] [-version some_repository_version] [-issue an_issue_number] [-branch trunk|some_branch] "
2010-11-06 02:06:12 +01:00
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
2011-07-03 17:14:27 +02:00
if [ $? -ne 0 ]
then
echo Build fails. Cleaning up.
cd ..
rm -rvf build
echo "Build failed. Repository export failed."
return 1
fi
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 "
2013-01-31 02:35:39 +01:00
sub2 = 's/4\.0\.1/5\.1\.0/'
sub3 = 's/PURGEDEV = false/PURGEDEV = true/'
2011-07-06 00:15:17 +02:00
for toc in ` find . -iname "*.toc" `
2011-07-01 18:24:53 +02:00
do
echo Replacing version tag in ${ toc } .
cp $toc $toc .bak
sed -e $sub $toc .bak > $toc
rm $toc .bak
cp $toc $toc .bak
sed -e $sub2 $toc .bak > $toc
rm $toc .bak
done
2010-11-08 14:28:59 +01:00
2011-06-29 19:12:20 +02:00
for lua in ` find . -iname "*.lua" `
2010-11-08 14:28:59 +01:00
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
2013-01-31 02:35:39 +01:00
echo Turning on PURGEDEV
cp collect.lua collect.lua.bak
sed -e $sub3 collect.lua.bak > collect.lua
rm collect.lua.bak
2011-07-03 16:24:04 +02:00
echo ${ release_string }
2011-06-29 19:35:17 +02:00
2013-01-31 02:35:39 +01:00
zip -qdgds 1m -r QuestHelper-5.1.0.${ release_string } .zip QuestHelper/ QHData-*
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