default to the nightly build is now the git build module
[infrastructure.git] / scripts / vbuild-nightly.sh
index b8d4dd9..65da0bb 100755 (executable)
@@ -1,9 +1,37 @@
 #!/bin/bash
 REVISION=$(echo '$Revision: 1053 $' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
 COMMAND=$(basename $0)
-SVNPATH="http://svn.one-lab.org/build/trunk"
+BUILD_SCM_URL="git://git.onelab.eu/build"
+USE_GIT=""
 
-cd /tmp
-svn cat $SVNPATH/$COMMAND  > $COMMAND
-chmod +x $COMMAND
-$COMMAND "$@"
+# 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
+           BUILD_SCM_URL="$2"
+       fi
+       shift
+    done
+
+    # is this a git url ?
+    if echo $BUILD_SCM_URL | grep -q git ; then USE_GIT="true" ; fi
+
+    if [ -n "$USE_GIT" ] ; then
+       GIT_REPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
+       GIT_TAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
+       GIT_TAG=${GIT_TAG:-master}
+    fi
+}
+
+scan_build_scm_url "$@"
+
+tmp=/tmp/$COMMAND-$$
+if [ -n "$USE_GIT" ] ; then
+    git archive --remote=$GIT_REPO $GIT_TAG $COMMAND | tar -C /tmp -xf -
+    mv /tmp/$COMMAND $tmp
+else
+    svn cat $BUILD_SCM_URL/$COMMAND  > $tmp
+fi
+chmod +x $tmp
+$tmp "$@"
+rm $tmp