aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/prepare-shared-repos
blob: eb89f5b4918f614c4df97be3f2691a5ec9cec5e3 (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
#!/usr/bin/env python3
#
# Iterate over a set of repositories in a json file and setup a shared directory containing them
#

import json
import os
import sys
import subprocess
import errno

import utils


parser = utils.ArgParser(description='Iterates over a set of repositories in a json file and sets up a shared directory containing them.')

parser.add_argument('repojson',
                    help="The json file containing the repositories to use")
parser.add_argument('sharedsrcdir',
                    help="The shared directory where the repos are to be transferred")
parser.add_argument('-p', '--publish-dir',
                    action='store',
                    help="Where to publish artefacts to (optional)")

args = parser.parse_args()

ourconfig = utils.loadconfig()

with open(args.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(args.sharedsrcdir, repo, repos[repo], stashdir)
    if args.publish_dir:
        utils.publishrepo(args.sharedsrcdir, repo, args.publish_dir)