updated busybox
[kvm-coreboot.git] / bin / fetchsvn.sh
blobc0fad1c4b7a1859f50e8e0e186f1eb6e9f36ea4d
1 #!/bin/sh
2 # Check out or update a SVN repository
4 URL=$1
5 DIR=$2
6 REV=$3
7 TARBALL=$4
9 SVNV=`svn --version --quiet`
11 if [ $? -ne 0 ]; then
12 echo "You don't have SVN installed."
13 exit 1
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 [ $? -ne 0 ]; then
22 echo "Couldn't fetch the code from $URL"
23 exit 1
24 fi
25 else
26 CURREV=`svn info $DIR/svn | grep "Last Changed Rev" | awk '{ print $4 }'`
28 if [ $CURREV -ne $REV ]; then
29 (cd $DIR/svn; \
30 echo "Updating from $CURREV to $REV"
31 svn update -r $REV || {
32 echo "Couldn't update the repository."
33 exit 1
35 if [ `echo $?` -ne 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...
43 exit 1
48 tar -C $DIR -zcf $TARBALL svn