summaryrefslogtreecommitdiff
path: root/buildbot/update-sources.sh
blob: 8c953406464cee86d6f6933d3200c5ce629e4492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# This file is in the public domain.

# Used by the checker-builder to get the latest code.

# First argument is the base URL from where to clone the Gits.
# Subsequent arguments must be the names of the Git repositories to clone.
# All repositories are either freshly cloned or updated to the latest 'master' branch

BASE_URL=$1
shift 1

mkdir -p $HOME/sources/

for n in "$@"
do
    P=$HOME/sources/$n
    echo "Updating $P"

    if test -x "$P"
    then
        git -C $P clean -fdx
        git -C $P fetch
        git -C $P reset --hard origin/master
        git submodule update --init
    else
        cd $HOME/sources
        git clone ${BASE_URL}$n
        git submodule update --init
        cd -
    fi
done