aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/layer-config33
-rwxr-xr-xscripts/prepare-shared-repos31
-rwxr-xr-xscripts/run-config100
-rwxr-xr-xscripts/send-qa-email41
-rwxr-xr-xscripts/setup-config79
-rwxr-xr-xscripts/shared-repo-unpack47
-rw-r--r--scripts/utils.py7
7 files changed, 174 insertions, 164 deletions
diff --git a/scripts/layer-config b/scripts/layer-config
index ac12d85fd2c..bfc62dae81a 100755
--- a/scripts/layer-config
+++ b/scripts/layer-config
@@ -2,9 +2,6 @@
#
# Move the repositories into the correct layout and generate bblayers.conf
#
-# Called with $1 - The autobuilder working directory
-# $2 - The target to filter the repos to
-#
import json
import os
@@ -14,22 +11,24 @@ import errno
import utils
-if len(sys.argv) != 3:
- print("Incorrect number of parameters, please call as %s <autobuilder-workdir> <target>" % sys.argv[0])
- sys.exit(1)
-targetdir = sys.argv[1]
-target = sys.argv[2]
-targetbuilddir = targetdir
+parser = utils.ArgParser(description='Moves the repositories into the correct layout and generates bblayers.conf.')
+
+parser.add_argument('abworkdir',
+ help="The autobuilder working directory")
+parser.add_argument('target',
+ help="The target to filter the repos to")
+
+args = parser.parse_args()
ourconfig = utils.loadconfig()
-def bitbakecmd(targetbuilddir, cmd):
- ret = subprocess.call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=targetbuilddir)
+def bitbakecmd(targetdir, cmd):
+ ret = subprocess.call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=targetdir)
if ret:
utils.printheader("ERROR: Command %s failed with exit code %d, see errors above." % (cmd, ret))
-needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, target, None)
+needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, args.target, None)
callinit = False
@@ -42,15 +41,15 @@ for repo in needrepos:
callinit = True
if "checkout-dirname" in repos[repo]:
checkdir = repos[repo]["checkout-dirname"]
- utils.mkdir(targetbuilddir + "/" + checkdir)
- for f in os.listdir(targetdir + "/repos/" + repo):
- subprocess.check_call(['mv', targetdir + "/repos/" + repo + "/" + f, targetbuilddir + "/" + checkdir + "/"])
+ utils.mkdir(args.abworkdir + "/" + checkdir)
+ for f in os.listdir(args.abworkdir + "/repos/" + repo):
+ subprocess.check_call(['mv', args.abworkdir + "/repos/" + repo + "/" + f, args.abworkdir + "/" + checkdir + "/"])
if callinit:
- subprocess.check_call(". ./oe-init-build-env", shell=True, cwd=targetbuilddir)
+ subprocess.check_call(". ./oe-init-build-env", shell=True, cwd=args.abworkdir)
for repo in needrepos:
if repo in repos and "no-layer-add" in repos[repo] and repos[repo]["no-layer-add"]:
continue
- bitbakecmd(targetbuilddir, "bitbake-layers add-layer %s" % (targetbuilddir + "/" + repo))
+ bitbakecmd(args.abworkdir, "bitbake-layers add-layer %s" % (args.abworkdir + "/" + repo))
diff --git a/scripts/prepare-shared-repos b/scripts/prepare-shared-repos
index 46b164714fc..eb89f5b4918 100755
--- a/scripts/prepare-shared-repos
+++ b/scripts/prepare-shared-repos
@@ -2,10 +2,6 @@
#
# 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
@@ -15,25 +11,28 @@ 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]
+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(repojson) as f:
+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(shared, repo, repos[repo], stashdir)
- if publish:
- utils.publishrepo(shared, repo, publish)
+ utils.fetchgitrepo(args.sharedsrcdir, repo, repos[repo], stashdir)
+ if args.publish_dir:
+ utils.publishrepo(args.sharedsrcdir, repo, args.publish_dir)
diff --git a/scripts/run-config b/scripts/run-config
index 9fede1e845d..39e04745c66 100755
--- a/scripts/run-config
+++ b/scripts/run-config
@@ -2,15 +2,6 @@
#
# Iterate over a set of configurations from json.conf, calling setup-config for each one, then running the build.
#
-# Called with $1 - The 'nightly' target the autobuilder is running
-# $2 - The target build directory to configure
-# $3 - The poky branch name the build is running on
-# $4 - The name of the repository the build is running on
-# $5 - The directory to publish sstate into
-# $6 - A build-appliance SRCREV to use
-# $7 - Where to publish artefacts to (or None)
-# $8 - URL back to this build (for the error reporting system)
-#
import json
import os
@@ -20,41 +11,50 @@ import errno
import utils
-if len(sys.argv) != 9:
- print("Incorrect number of parameters, please call as %s <nightly-target> <target-builddir> <branch-name> <repo-name> <sstate-publish-dir> <build-app-srcrev> <publish-dir> <error-report-url>" % sys.argv[0])
- sys.exit(1)
-target = sys.argv[1]
-builddir = sys.argv[2]
-branchname = sys.argv[3]
-reponame = sys.argv[4]
-sstate_release = sys.argv[5]
-buildappsrcrev = sys.argv[6]
-publish = None
-if sys.argv[7] != "None":
- publish = sys.argv[7]
-errorurl = None
-if sys.argv[8] != "None":
- errorurl = sys.argv[8]
+parser = utils.ArgParser(description='Runs configurations in json.conf.')
+
+parser.add_argument('target',
+ help="The 'nightly' target the autobuilder is running")
+parser.add_argument('builddir',
+ help="The target build directory to configure")
+parser.add_argument('branchname',
+ help="The poky branch name the build is running on")
+parser.add_argument('reponame',
+ help="The name of the repository the build is running on")
+parser.add_argument('sstatepubdir',
+ help="The directory to publish sstate into")
+parser.add_argument('buildappsrcrev',
+ help="A build appliance SRCREV to use")
+parser.add_argument('-p', '--publish-dir',
+ action='store',
+ help="Where to publish artefacts to (optional)")
+parser.add_argument('-u', '--build-url',
+ action='store',
+ help="URL back to this build (for the error reporting system)")
+parser.add_argument('-t', '--test',
+ action='store_true',
+ default=False,
+ help="Test mode - perform setup and dry-run of commands only")
+
+args = parser.parse_args()
scriptsdir = os.path.dirname(os.path.realpath(__file__))
ourconfig = utils.loadconfig()
-testmode = False
-if "ABHELPERTEST" in os.environ:
- testmode = True
+testmode = args.test
# Find out the number of steps this target has
maxsteps = 1
-if target in ourconfig['overrides']:
- for v in ourconfig['overrides'][target]:
+if args.target in ourconfig['overrides']:
+ for v in ourconfig['overrides'][args.target]:
if v.startswith("step"):
n = int(v[4:])
if n <= maxsteps:
continue
maxsteps = n
-utils.printheader("Target task %s has %d steps" % (target, maxsteps))
+utils.printheader("Target task %s has %d steps" % (args.target, maxsteps))
finalret = 0
@@ -69,8 +69,8 @@ def logname(path):
return path + "/command.log.%s" % lognum
revision = "unknown"
-report = utils.ErrorReport(ourconfig, target, builddir, branchname, revision)
-errordir = utils.errorreportdir(builddir)
+report = utils.ErrorReport(ourconfig, args.target, args.builddir, args.branchname, revision)
+errordir = utils.errorreportdir(args.builddir)
utils.mkdir(errordir)
@@ -115,54 +115,54 @@ def runcmd(cmd, *args, **kwargs):
return
subprocess.check_call(cmd, *args, **kwargs)
-bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, builddir, target, reponame, branchname)
+bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, args.builddir, args.target, args.reponame, args.branchname)
if bh_path:
runcmd([os.path.join(scriptsdir, "buildhistory-init"), bh_path, remoterepo, remotebranch, baseremotebranch])
for stepnum in range(1, maxsteps + 1):
# Add any layers specified
- layers = utils.getconfiglist("ADDLAYER", ourconfig, target, stepnum)
+ layers = utils.getconfiglist("ADDLAYER", ourconfig, args.target, stepnum)
for layer in layers:
- bitbakecmd(builddir, "bitbake-layers add-layer %s" % layer, report, stepnum)
+ bitbakecmd(args.builddir, "bitbake-layers add-layer %s" % layer, report, stepnum)
flush()
# Generate the configuration files needed for this step
- if utils.getconfigvar("WRITECONFIG", ourconfig, target, stepnum):
- runcmd([scriptsdir + "/setup-config", target, str(stepnum - 1), builddir, branchname, reponame, sstate_release, buildappsrcrev])
+ if utils.getconfigvar("WRITECONFIG", ourconfig, args.target, stepnum):
+ runcmd([scriptsdir + "/setup-config", args.target, str(stepnum - 1), args.builddir, args.branchname, args.reponame, args.sstatepubdir, args.buildappsrcrev])
# Execute the targets for this configuration
- targets = utils.getconfigvar("BBTARGETS", ourconfig, target, stepnum)
+ targets = utils.getconfigvar("BBTARGETS", ourconfig, args.target, stepnum)
if targets:
utils.printheader("Step %s/%s: Running bitbake %s" % (stepnum, maxsteps, targets))
- bitbakecmd(builddir, "bitbake %s" % targets, report, stepnum)
+ bitbakecmd(args.builddir, "bitbake %s" % targets, report, stepnum)
# Execute the sanity targets for this configuration
- sanitytargets = utils.getconfigvar("SANITYTARGETS", ourconfig, target, stepnum)
+ sanitytargets = utils.getconfigvar("SANITYTARGETS", ourconfig, args.target, stepnum)
if sanitytargets:
utils.printheader("Step %s/%s: Running bitbake %s" % (stepnum, maxsteps, sanitytargets))
- bitbakecmd(builddir, "checkvnc; DISPLAY=:1 bitbake %s" % sanitytargets, report, stepnum)
+ bitbakecmd(args.builddir, "checkvnc; DISPLAY=:1 bitbake %s" % sanitytargets, report, stepnum)
# Run any extra commands specified
- cmds = utils.getconfiglist("EXTRACMDS", ourconfig, target, stepnum)
+ cmds = utils.getconfiglist("EXTRACMDS", ourconfig, args.target, stepnum)
for cmd in cmds:
utils.printheader("Step %s/%s: Running command %s" % (stepnum, maxsteps, cmd))
- bitbakecmd(builddir, cmd, report, stepnum)
- cmds = utils.getconfiglist("EXTRAPLAINCMDS", ourconfig, target, stepnum)
+ bitbakecmd(args.builddir, cmd, report, stepnum)
+ cmds = utils.getconfiglist("EXTRAPLAINCMDS", ourconfig, args.target, stepnum)
for cmd in cmds:
utils.printheader("Step %s/%s: Running 'plain' command %s" % (stepnum, maxsteps, cmd))
- bitbakecmd(builddir, cmd, report, stepnum, oeenv=False)
+ bitbakecmd(args.builddir, cmd, report, stepnum, oeenv=False)
# Remove any layers we added in a reverse order
for layer in reversed(layers):
- bitbakecmd(builddir, "bitbake-layers remove-layer %s" % layer, report, stepnum)
+ bitbakecmd(args.builddir, "bitbake-layers remove-layer %s" % layer, report, stepnum)
-if publish:
+if args.publish_dir:
utils.printheader("Running publish artefacts")
- runcmd([scriptsdir + "/publish-artefacts", builddir, publish, target])
+ runcmd([scriptsdir + "/publish-artefacts", args.builddir, args.publish_dir, args.target])
-if errorurl and utils.getconfigvar("SENDERRORS", ourconfig, target, stepnum):
+if args.build_url and utils.getconfigvar("SENDERRORS", ourconfig, args.target, stepnum):
utils.printheader("Sending any error reports")
- runcmd([scriptsdir + "/upload-error-reports", builddir, errorurl])
+ runcmd([scriptsdir + "/upload-error-reports", args.builddir, args.build_url])
if finalret:
utils.printheader("There were %s failures" % finalret)
diff --git a/scripts/send-qa-email b/scripts/send-qa-email
index df3c1b50633..b2406cce0d8 100755
--- a/scripts/send-qa-email
+++ b/scripts/send-qa-email
@@ -1,11 +1,6 @@
#!/usr/bin/env python3
#
-# Iterate over a set of configurations from json.conf, calling setup-config for each one, then running the build.
-#
-# Called with $1 - The json file containing the repositories to use
-# $2 - Where the artefacts were published
-# $3 - The build/release 'name' for release purposes
-# $4 - The shared repos directory (to resolve the repo revision hashes)
+# Send email about the build to prompt QA to begin testing
#
import json
@@ -16,30 +11,38 @@ import errno
import utils
-if len(sys.argv) != 6:
- print("Incorrect number of parameters, please call as %s <send-email> <repojson> <publish-dir> <release-name> <sharedrepodir>" % sys.argv[0])
- sys.exit(1)
-send = sys.argv[1]
-repojson = sys.argv[2]
-publish = sys.argv[3]
-rel_name = sys.argv[4]
-repodir = sys.argv[5]
+parser = utils.ArgParser(description='Sends an email about the build to prompt QA to begin testing.')
+
+parser.add_argument('send',
+ help="True to send email, otherwise the script will display a message and exit")
+parser.add_argument('repojson',
+ help="The json file containing the repositories to use")
+parser.add_argument('sharedrepodir',
+ help="The shared repos directory (to resolve the repo revision hashes)")
+parser.add_argument('-p', '--publish-dir',
+ action='store',
+ help="Where the artefacts were published")
+parser.add_argument('-r', '--release',
+ action='store',
+ help="The build/release 'name' for release purposes (optional)")
+
+args = parser.parse_args()
-if send != "True" or publish == "None" or rel_name == "None":
+if args.send.lower() != 'true' or not args.publish_dir or not args.release:
utils.printheader("Not sending QA email")
sys.exit(0)
scriptsdir = os.path.dirname(os.path.realpath(__file__))
ourconfig = utils.loadconfig()
-with open(repojson) as f:
+with open(args.repojson) as f:
repos = json.load(f)
buildhashes = ""
for repo in sorted(repos.keys()):
# Need the finalised revisions (not 'HEAD')
- targetrepodir = "%s/%s" % (repodir, repo)
+ targetrepodir = "%s/%s" % (args.sharedrepodir, repo)
revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=targetrepodir).decode('utf-8').strip()
buildhashes += "%s: %s\n" % (repo, revision)
@@ -57,7 +60,7 @@ mailbcc = utils.getconfig("QAMAIL_BCC", ourconfig)
if mailbcc:
email += "Bcc: " + mailbcc + "\n"
-email += "Subject: " + "QA notification for completed autobuilder build (%s)\n" % rel_name
+email += "Subject: " + "QA notification for completed autobuilder build (%s)\n" % args.release
email += '''\n
A build flagged for QA (%s) was completed on the autobuilder and is available at:\n\n
%s\n\n
@@ -66,7 +69,7 @@ Build hash information: \n
\nThis is an automated message from the Yocto Project Autobuilder\nGit: git://git.yoctoproject.org/yocto-autobuilder2\nEmail: richard.purdie@linuxfoundation.org\n
-''' % (rel_name, publish.replace(web_root, web_url), buildhashes)
+''' % (args.release, args.publish_dir.replace(web_root, web_url), buildhashes)
utils.printheader("Sending QA email")
subprocess.check_call('echo "' + email +' " | sendmail -t', shell=True)
diff --git a/scripts/setup-config b/scripts/setup-config
index 5c1d393aa9c..e90eda720a3 100755
--- a/scripts/setup-config
+++ b/scripts/setup-config
@@ -2,14 +2,6 @@
#
# Generate an auto.conf and associated other config files for a given autobuilder configuration
#
-# Called with $1 - The 'nightly' target the autobuilder is running
-# $2 - The autobuilder step number (a given target can run multiple steps with different configurations)
-# $3 - The target build directory to configure
-# $4 - The poky branch name the build is running on
-# $5 - The name of the repository the build is running on
-# $6 - The directory to publish sstate into
-# $7 - A build-appliance SRCREV to use
-#
import json
import os
@@ -17,44 +9,55 @@ import sys
import subprocess
import errno
import copy
+
import utils
-if len(sys.argv) != 8:
- print("Incorrect number of parameters, please call as %s <nightly-target> <stepnumber> <target-builddir> <branch-name> <repo-name> <sstate-publish-dir> <build-app-srcrev>" % sys.argv[0])
- sys.exit(1)
-target = sys.argv[1]
-stepnum = int(sys.argv[2]) + 1 # Our step numbering is 1 2 3 etc., not 0 of buildbot
-builddir = sys.argv[3]
-branchname = sys.argv[4]
-reponame = sys.argv[5]
-sstate_release = sys.argv[6]
-buildappsrcrev = sys.argv[7]
+parser = utils.ArgParser(description='Generates an auto.conf and associated other config files for a given autobuilder configuration.')
+
+parser.add_argument('target',
+ help="The 'nightly' target the autobuilder is running")
+parser.add_argument('stepnumber',
+ help="The autobuilder step number (a given target can run multiple steps with different configurations)")
+parser.add_argument('builddir',
+ help="The target build directory to configure")
+parser.add_argument('branchname',
+ help="The poky branch name the build is running on")
+parser.add_argument('reponame',
+ help="The name of the repository the build is running on")
+parser.add_argument('sstatepubdir',
+ help="The directory to publish sstate into")
+parser.add_argument('buildappsrcrev',
+ help="A build appliance SRCREV to use")
+
+args = parser.parse_args()
+
+stepnum = int(args.stepnumber) + 1 # Our step numbering is 1 2 3 etc., not 0 of buildbot
ourconfig = utils.loadconfig()
variables = []
-autoconf = os.path.join(builddir, "conf", "auto.conf")
+autoconf = os.path.join(args.builddir, "conf", "auto.conf")
if os.path.exists(autoconf):
os.remove(autoconf)
# Ensure autoconf's directory exists
utils.mkdir(os.path.dirname(autoconf))
-sdkextraconf = os.path.join(builddir, "conf", "sdk-extra.conf")
+sdkextraconf = os.path.join(args.builddir, "conf", "sdk-extra.conf")
if os.path.exists(sdkextraconf):
os.remove(sdkextraconf)
for v in ["MACHINE", "DISTRO", "SDKMACHINE"]:
- value = utils.getconfigvar(v, ourconfig, target, stepnum)
+ value = utils.getconfigvar(v, ourconfig, args.target, stepnum)
if value and value != "None":
variables.append(v + ' = "%s"' % value)
-distro = utils.getconfigvar("DISTRO", ourconfig, target, stepnum)
+distro = utils.getconfigvar("DISTRO", ourconfig, args.target, stepnum)
for v in ["DLDIR", "PRSERV"]:
- value = utils.getconfigvar(v, ourconfig, target, stepnum)
+ value = utils.getconfigvar(v, ourconfig, args.target, stepnum)
if value:
variables.append(value)
@@ -63,30 +66,30 @@ for v in ["DLDIR", "PRSERV"]:
# have a directory of symlinks to sstate objects
# that can be published for the release
key = "SSTATEDIR"
-if sstate_release != "None":
+if args.sstatepubdir:
key = "SSTATEDIR_RELEASE"
-value = utils.getconfiglist(key, ourconfig, target, stepnum)
+value = utils.getconfiglist(key, ourconfig, args.target, stepnum)
for v in value:
- v = v.replace("@RELEASENUM@", sstate_release)
+ v = v.replace("@RELEASENUM@", args.sstatepubdir or "None")
variables.append(v)
-if buildappsrcrev != "None" and buildappsrcrev != "DEFAULT":
- if buildappsrcrev == "AUTOREV":
- buildappsrcrev = "${AUTOREV}"
- value = utils.getconfiglist("BUILDAPP_SRCREV", ourconfig, target, stepnum)
+if args.buildappsrcrev != "None" and args.buildappsrcrev != "DEFAULT":
+ if args.buildappsrcrev == "AUTOREV":
+ args.buildappsrcrev = "${AUTOREV}"
+ value = utils.getconfiglist("BUILDAPP_SRCREV", ourconfig, args.target, stepnum)
for v in value:
- v = v.replace("@SRCREV@", buildappsrcrev)
+ v = v.replace("@SRCREV@", args.buildappsrcrev)
variables.append(v)
-if utils.getconfigvar("BUILDINFO", ourconfig, target, stepnum):
- infovars = utils.getconfiglist("BUILDINFOVARS", ourconfig, target, stepnum)
+if utils.getconfigvar("BUILDINFO", ourconfig, args.target, stepnum):
+ infovars = utils.getconfiglist("BUILDINFOVARS", ourconfig, args.target, stepnum)
variables.extend(infovars)
-extravars = utils.getconfiglist("extravars", ourconfig, target, stepnum)
+extravars = utils.getconfiglist("extravars", ourconfig, args.target, stepnum)
if extravars:
variables.extend(extravars)
-bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, builddir, target, reponame, branchname)
+bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, args.builddir, args.target, args.reponame, args.branchname)
if bh_path:
variables.append('INHERIT += "buildhistory"')
variables.append('BUILDHISTORY_DIR = "%s"' % bh_path)
@@ -105,10 +108,10 @@ with open(autoconf, "w") as f:
utils.printheader("Writing %s with contents:" % sdkextraconf)
with open(sdkextraconf, "w") as f:
- for v in utils.getconfiglist("SDKEXTRAS", ourconfig, target, stepnum):
+ for v in utils.getconfiglist("SDKEXTRAS", ourconfig, args.target, stepnum):
replace = ""
- if sstate_release != "None":
- replace = sstate_release + "/"
+ if args.sstatepubdir:
+ replace = args.sstatepubdir + "/"
v = v.replace("@RELEASENUM@", replace)
print(" " + v)
f.write(v + "\n")
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])
diff --git a/scripts/utils.py b/scripts/utils.py
index 0ec690ef643..f23de369d66 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -7,6 +7,7 @@ import time
import codecs
import sys
import re
+import argparse
#
# Check if config contains all the listed params
@@ -302,3 +303,9 @@ class ErrorReport(object):
with codecs.open(filename, 'w', 'utf-8') as f:
json.dump(report, f, indent=4, sort_keys=True)
+class ArgParser(argparse.ArgumentParser):
+ def error(self, message):
+ # Show the help if there's an argument parsing error (e.g. no arguments, missing argument, ...)
+ sys.stderr.write('error: %s\n' % message)
+ self.print_help()
+ sys.exit(2)