git+svn fetcher script
authorthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Fri, 21 May 2010 21:00:41 +0000 (21:00 +0000)
committerthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Fri, 21 May 2010 21:00:41 +0000 (21:00 +0000)
scripts/vbuild-nightly.sh

index aabceb9..36b1fe6 100755 (executable)
@@ -1,22 +1,37 @@
 #!/bin/bash
 REVISION=$(echo '$Revision: 1053 $' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
 COMMAND=$(basename $0)
-SVNPATH="http://svn.planet-lab.org/svn/build/trunk"
+BUILD_SCM_URL="http://svn.planet-lab.org/svn/build/trunk"
+USE_GIT=""
 
-# scan args for any -s option, and SVNPATH in this case
-function scan_svnpath () {
+# scan args for any -s option, and set BUILD_SCM_URL in this case
+function scan_build_scm_url () {
     while [[ -n "$@" ]] ; do
        if [ "$1" == "-s" ] ; then
-           SVNPATH="$2"
+           BUILD_SCM_URL="$2"
        fi
        shift
     done
+
+    # is this a git url ?
+    echo $BUILD_SCM_URL | grep -q git && USE_GIT="true"
+
+    if [ -n "$USE_GIT" ] ; then
+       GITREPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
+       GITTAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
+       GITTAG=${GITTAG:-master}
+    fi
 }
 
-scan_svnpath "$@"
+scan_build_scm_url "$@"
 
 tmp=/tmp/$COMMAND-$$
-svn cat $SVNPATH/$COMMAND  > $tmp
+if [ -n "$USE_GIT" ] ; then
+    git archive --remote=$GITREPO $GITTAG $COMMAND | tar -C /tmp -xf -
+    mv /tmp/$COMMAND $tmp
+else
+    svn cat $BUILD_SCM_URL/$COMMAND  > $tmp
+fi
 chmod +x $tmp
 $tmp "$@"
 rm $tmp