yocto-autobuilder-helper/scripts/run-config
Richard Purdie 376ad36d4d Move buildhistory init to run-config (and factor common functionality to utils)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-23 13:49:38 +00:00

98 lines
3.3 KiB
Python
Executable File

#!/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 '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
#
import json
import os
import sys
import subprocess
import errno
import utils
if len(sys.argv) != 7:
print("Incorrect number of parameters, please call as %s <nightly-target> <stepnumber> <target-builddir> <branch-name> <repo-name> <build-app-srcrev" % 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]
scriptsdir = os.path.dirname(os.path.realpath(__file__))
ourconfig = utils.loadconfig(__file__)
# Find out the number of steps this target has
maxsteps = 1
if target in ourconfig['overrides']:
for v in ourconfig['overrides'][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))
finalret = 0
def flush():
sys.stdout.flush()
sys.stderr.flush()
def bitbakecmd(builddir, cmd):
global finalret
flush()
ret = subprocess.call(". ./oe-init-build-env; %s" % cmd, shell=True, cwd=builddir + "/..")
if ret:
utils.printheader("ERROR: Command %s failed with exit code %d, see errors above." % (cmd, ret))
finalret = 1
bh_path, remoterepo, remotebranch, baseremotebranch = utils.getbuildhistoryconfig(ourconfig, target, reponame, branchname)
if bh_path:
utils.runcmd([os.path.join(scriptsdir, "buildhistory-init"), bh_path, remoterepo, remotebranch, baseremotebranch])
for stepnum in range(maxsteps):
# Add any layers specified
layers = utils.getconfiglist("ADDLAYER", ourconfig, target, stepnum + 1)
for layer in layers:
bitbakecmd(builddir, "bitbake-layers add-layer %s" % layer)
# Generate the configuration files needed for this step
flush()
subprocess.check_call([scriptsdir + "/setup-config", target, str(stepnum), builddir, branchname, reponame, sstate_release, buildappsrcrev])
# Execute the targets for this configuration
targets = utils.getconfigvar("BBTARGETS", ourconfig, target, stepnum + 1)
if targets:
utils.printheader("Running bitbake %s" % targets)
bitbakecmd(builddir, "bitbake %s" % targets)
# Execute the sanity targets for this configuration
sanitytargets = utils.getconfigvar("SANITYTARGETS", ourconfig, target, stepnum + 1)
if sanitytargets:
utils.printheader("Running bitbake %s" % sanitytargets)
bitbakecmd(builddir, "checkvnc; DISPLAY=:1 bitbake %s" % sanitytargets)
# Remove any layers we added
for layer in layers:
bitbakecmd(builddir, "bitbake-layers remove-layer %s" % layer)
# Run any extra commands specified
cmds = utils.getconfiglist("EXTRACMDS", ourconfig, target, stepnum + 1)
for cmd in cmds:
bitbakecmd(builddir, cmd)
sys.exit(finalret)