aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/prepare-shared-repos
blob: 46b164714fc3f2b80073cc3d8cece51867abfedd (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
#!/usr/bin/env python3
#
# Iterate over a set of repositories in a json file and setup a shared directory containing them
#
# Called with $1 - The json file containing the repositories to use
#             $2 - The shared directory where the repos are to be transferred
#             $3 - Directory to publish artefacts to
#

import json
import os
import sys
import subprocess
import errno

import utils

if len(sys.argv) != 4:
    print("Incorrect number of parameters, please call as %s <repo.json> <shared-sources-dir> <publish-dir>" % sys.argv[0])
    sys.exit(1)

repojson = sys.argv[1]
shared = sys.argv[2]
publish = None
if sys.argv[3] != "None":
    publish = sys.argv[3]

ourconfig = utils.loadconfig()

with open(repojson) as f:
    repos = json.load(f)

stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)

for repo in sorted(repos.keys()):
    utils.printheader("Intially fetching repo %s" % repo)
    utils.fetchgitrepo(shared, repo, repos[repo], stashdir)
    if publish:
        utils.publishrepo(shared, repo, publish)