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