aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/shared-repo-unpack
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/shared-repo-unpack')
-rwxr-xr-xscripts/shared-repo-unpack47
1 files changed, 23 insertions, 24 deletions
diff --git a/scripts/shared-repo-unpack b/scripts/shared-repo-unpack
index 209aa83658f..fb88bf2ea4a 100755
--- a/scripts/shared-repo-unpack
+++ b/scripts/shared-repo-unpack
@@ -2,12 +2,6 @@
#
# Unpack a shared directory of repos to the autobuilder working directory
#
-# Called with $1 - The json file containing the repositories to use
-# $2 - The shared directory where the repos are to be transferred from (can be 'None')
-# $3 - The autobuilder working directory
-# $4 - The target to filter the repos to
-# $5 - Directory to publish artefacts to
-#
import json
import os
@@ -19,43 +13,48 @@ import random
import utils
-if len(sys.argv) != 6:
- print("Incorrect number of parameters, please call as %s repo.json <shared-sources-dir> <autobuilder-workdir> <target> <publish-dir>" % sys.argv[0])
- sys.exit(1)
-repojson = sys.argv[1]
-shared = sys.argv[2]
-targetdir = sys.argv[3]
-target = sys.argv[4]
-publish = None
-if sys.argv[5] != "None":
- publish = sys.argv[5]
+parser = utils.ArgParser(description='Unpacks a shared directory of repos to the autobuilder working directory.')
+
+parser.add_argument('repojson',
+ help="The json file containing the repositories to use")
+parser.add_argument('abworkdir',
+ help="The autobuilder working directory")
+parser.add_argument('target',
+ help="The target to filter the repos to")
+parser.add_argument('-p', '--publish-dir',
+ action='store',
+ help="Where to publish artefacts to (optional)")
+parser.add_argument('-t', '--transfer-to',
+ action='store',
+ help="The shared directory where the repos are to be transferred")
+args = parser.parse_args()
scriptsdir = os.path.dirname(os.path.realpath(__file__))
ourconfig = utils.loadconfig()
stashdir = utils.getconfig("REPO_STASH_DIR", ourconfig)
-needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, target, None)
+needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, args.target, None)
-with open(repojson) as f:
+with open(args.repojson) as f:
repos = json.load(f)
-targetsubdir = targetdir + "/repos"
+targetsubdir = args.abworkdir + "/repos"
for repo in sorted(repos.keys()):
if repo not in needrepos:
continue
targetrepodir = "%s/%s" % (targetsubdir, repo)
- if shared != "None":
+ if args.transfer_to:
utils.printheader("Copying in repo %s" % repo)
utils.mkdir(targetrepodir)
- subprocess.check_call(["rsync", "-a", "%s/%s" % (shared, repo), targetsubdir])
+ subprocess.check_call(["rsync", "-a", "%s/%s" % (args.transfer_to, repo), targetsubdir])
else:
utils.printheader("Fetching repo %s" % repo)
utils.fetchgitrepo(targetsubdir, repo, repos[repo], stashdir)
- if publish:
- utils.publishrepo(shared, repo, publish)
+ if args.publish_dir:
+ utils.publishrepo(args.transfer_to, repo, args.publish_dir)
-subprocess.check_call([scriptsdir + "/layer-config", targetdir, target])
+subprocess.check_call([scriptsdir + "/layer-config", args.abworkdir, args.target])