default to the nightly build is now the git build module
[infrastructure.git] / scripts / vbuild-nightly.sh
1 #!/bin/bash
2 REVISION=$(echo '$Revision: 1053 $' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
3 COMMAND=$(basename $0)
4 BUILD_SCM_URL="git://git.onelab.eu/build"
5 USE_GIT=""
6
7 # scan args for any -s option, and set BUILD_SCM_URL in this case
8 function scan_build_scm_url () {
9     while [[ -n "$@" ]] ; do
10         if [ "$1" == "-s" ] ; then
11             BUILD_SCM_URL="$2"
12         fi
13         shift
14     done
15
16     # is this a git url ?
17     if echo $BUILD_SCM_URL | grep -q git ; then USE_GIT="true" ; fi
18
19     if [ -n "$USE_GIT" ] ; then
20         GIT_REPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
21         GIT_TAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
22         GIT_TAG=${GIT_TAG:-master}
23     fi
24 }
25
26 scan_build_scm_url "$@"
27
28 tmp=/tmp/$COMMAND-$$
29 if [ -n "$USE_GIT" ] ; then
30     git archive --remote=$GIT_REPO $GIT_TAG $COMMAND | tar -C /tmp -xf -
31     mv /tmp/$COMMAND $tmp
32 else
33     svn cat $BUILD_SCM_URL/$COMMAND  > $tmp
34 fi
35 chmod +x $tmp
36 $tmp "$@"
37 rm $tmp