2 # Check out or update a SVN repository
9 SVNV
=`svn --version --quiet`
11 if [ "$?" != "0" ]; then
12 echo "You don't have SVN installed."
16 # Simple case - the repository doesn't exist
18 if [ ! -d $DIR/svn
/.svn
]; then
19 echo "Fetching $URL..."
20 svn co
-r $REV $URL $DIR/svn
21 if [ "$?" != "0" ]; then
22 echo "Couldn't fetch the code from $URL"
26 CURREV
=`svn info $DIR/svn | grep "Last Changed Rev" | awk '{ print $4 }'`
28 if [ "$CURREV" != "$REV" ]; then
30 echo "Updating from $CURREV to $REV"
31 svn update
-r $REV ||
{
32 echo "Couldn't update the repository."
35 if [ "$?" != "0" ]; then
36 # The parentheses around the cd $DIR/svn; svn update ... commands above
37 # cause those commands to be executed as a list, in a subshell. As a
38 # consequence, if something goes wrong the exit command exits the
39 # subshell, not the script. And that means that the tar command below was
40 # still being executed even if the svn checkout failed, which could lead
41 # to nasty, nasty situations where we had a tarball that claimed to be a
42 # certain SVN revision, but was really some other revision...
48 tar -C $DIR -zcf $TARBALL svn