aboutsummaryrefslogtreecommitdiff
path: root/toolchain-tools
blob: ad8b79db28533727ad32c7afa57b7e27cc6f63ae (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#
# This script is used to sync the upstream gcc repository, plus a series of
# other related toolchain repositories.
#
# It is highly dependant on the git setup Linaro has on its server. Setup that
# is done with gitolite and gitweb.
#
# How the mirrorin has been done:
# - mirrorin happens in /srv/mirror on the server
# - depending on the mirror type, we can create a git-svn clone in a separate
#   directory, add a new remote on the "original" repo, and then make sure
#   everything is pushed to the real bare repo.
#
# For more info: https://wiki.linaro.org/Platform/Systems/ToolchainsMirror
#

umask 0022  # cron runs us with 0002

GITOLITE_BIN="/home/git/bin/gitolite"
REPOSITORIES_DIR="/srv/repositories"
TOOLCHAIN_DIR="$REPOSITORIES_DIR/toolchain"
GCC_REPO="$TOOLCHAIN_DIR/gcc.git"
BINUTILS_GDB_REPO="$TOOLCHAIN_DIR/binutils-gdb.git"
MIRROR_DIR="/srv/mirror"


function errcho() {
    # Print on stderr passed messages.
    >&2 echo $1
}

function logiferr() {
    LOG=$($1 2>&1)
    STATUS=$?
    if [ ${STATUS} != 0 ]
    then
        errcho "CMD: '$1' exited with status ${STATUS}"
        if [ "${LOG}" != "" ]
        then
            errcho "WITH LOG OUTPUT: ${LOG}"
        fi
    fi
    return ${STATUS}
}

# Retry command which tends to have transient failures
function stubborn_do() {
    for i in 5 15 60 180 180; do
        LOG=$("$@" 2>&1)
        STATUS=$?
        if [ $STATUS -eq 0 ]; then
            return 0
        fi
        sleep $i
    done
    errcho "CMD: '$@' exited with status $STATUS"
    errcho "WITH LOG OUTPUT: '$LOG'"
    errcho "Last retry delay: ${i}s"
    return $STATUS
}

function new2_gcc() {
    if [ ! -d $MIRROR_DIR/gcc-upstream-pristine.git ]; then
        git clone --mirror git://gcc.gnu.org/git/gcc.git $MIRROR_DIR/gcc-upstream-pristine.git
    fi

    QUIET="${QUIET---quiet}"
    cd $MIRROR_DIR/gcc-upstream-pristine.git
    stubborn_do git fetch $QUIET
    # Set up gitolite environment for local push
    export GL_BYPASS_ACCESS_CHECKS=1
    export GL_LIBDIR=~/gitolite/src/lib
    git push $QUIET --force /srv/repositories/toolchain/gcc.git 'refs/heads/*' 'refs/tags/*' 2>&1 | grep -v "remote: Sending notification emails to"
}

function update_newlib_mirror() {
    cd $TOOLCHAIN_DIR/newlib.git
    stubborn_do git remote update
}

function update_glibc_mirror() {
    cd $TOOLCHAIN_DIR/glibc.git
    stubborn_do git remote update
}

function update_binutils_gdb() {
    cd $BINUTILS_GDB_REPO
    stubborn_do git remote update
}

function update_dejagnu_mirror() {
    cd "$MIRROR_DIR/dejagnu.git"
    stubborn_do git remote update
    if [ $? == 0 ]
    then
        logiferr "$GITOLITE_BIN push"
    fi
}

function all() {
    update_binutils_gdb
}

$@

all_repos="gcc.git glibc.git dejagnu.git newlib.git binutils-gdb.git"
cd /srv/repositories
for repo in $all_repos ; do
    logiferr "/usr/local/bin/grok-manifest -m /var/www/git.linaro.org/manifest.js.gz -t /srv/repositories/ -v -n toolchain/$repo"
    logiferr "git --git-dir=$TOOLCHAIN_DIR/$repo update-server-info"
done