aboutsummaryrefslogtreecommitdiff
blob: 94852a1c1f35d48ce533803e2e04857f6b78a359 (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
#!/bin/sh
# $Id: update-seeds.sh,v 0.2.1 2014/10/12 dolsen Exp $

# configuration to run from a checkout with a custom config
cwd=$(pwd)
source ${cwd}/update-seeds.conf
source ${cwd}/testpath

die(){ echo "$@" 1>&2; echo ""; exit 1; }
success(){ echo "$@"; echo ""; exit 0; }

clone_api(){
    local target=dirname ${API_DIR}
    cd target
    git clone ${API_URL}
}

# start update process
echo "Beginning seed file update"

echo " *** updating api.gentoo.org repo"
# update api checkout
if [[ ! -d ${API_DIR} ]]; then
    clone_api
else
    cd ${API_DIR} && git pull
fi

echo " *** Fetching new seeds from LDAP"
cd ${GKEYS_DIR}
gkey-ldap -c ${GKEYS_CONF} updateseeds || die "Seed file generation failed... aborting"

echo " *** Checking if seed files are up-to-date"
if ! diff -q ${GKEYS_DIR}/${GKEYS_SEEDS} ${API_DIR}/${API_SEEDS} > /dev/null ;then
    echo " *** Spotted differences"
    echo " *** Updating old seeds with a new one"
    # copy seeds to api
    echo "  ... cp ${GKEYS_SEEDS} ${API_DIR}/${API_SEEDS}"
    cp ${GKEYS_SEEDS} ${API_DIR}/${API_SEEDS}
else
    success " *** No changes detected"
fi

echo "Signing new developers.seeds file"
gkeys -c ${GKEYS_CONF} sign -n ${GKEYS_SIGN} -F ${API_DIR}/${API_SEEDS} || die " *** Signing failed... exiting"

echo "Committing changes to api repo..."
cd ${API_DIR}
git add ${API_SEEDS}  || die " *** Failed to add modified developers.seeds file"
git add ${API_SEEDS}.${GKEYS_SIG} || die " *** Failed to add developer.seeds.sig file"
git commit -m "${GKEYS_COMMIT_MSG}" || die " *** Failed to commit updates"
git push origin master || die " *** git push failed"

success "Successfully updated developer.seeds"