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