yocto-autobuilder2/steps/writelayerinfo.py
Joshua Lock 4fd189ab38 Initial prototype of using yocto-autobuilder-helper scripts
Initial prototype of using yocto-autobuilder-helper scripts from vanilla
buildbot to replicate yocto-autobuilder configuration.

* README.md is updated to describe goals and approach
* TODO contains known issues and work items, TODO: comments in the code
  point to specific locations of work

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
2018-02-22 10:38:19 +00:00

49 lines
1.5 KiB
Python

from twisted.internet import defer
from buildbot.process import buildstep
import json
import os
from yoctoab import config
class WriteLayerInfo(buildstep.ShellMixin, buildstep.BuildStep):
name = "WriteLayerInfo"
def __init__(self, **kwargs):
buildstep.BuildStep.__init__(self, **kwargs)
def generateLayerInfo(self):
layerinfo = {}
writerepos = config.buildertorepos.get(self.getProperty("buildername"))
if not writerepos:
writerepos = config.buildertorepos["default"]
for repo in writerepos:
repodict = {}
repodict["url"] = self.getProperty("repo_{}".format(repo))
repodict["branch"] = self.getProperty("branch_{}".format(repo))
repodict["revision"] = self.getProperty("commit_{}".format(repo))
layerinfo[repo] = repodict
return json.dumps(layerinfo, sort_keys=True, indent=4,
separators=(',', ': '))
@defer.inlineCallbacks
def run(self):
repojson = self.generateLayerInfo()
layerinfo = os.path.join(self.getProperty("builddir"),
"layerinfo.json")
writerepos = "printf '%s' >> %s" % (repojson, layerinfo)
cmd = yield self.makeRemoteShellCommand(
command=writerepos)
yield self.runCommand(cmd)
defer.returnValue(cmd.results())
@defer.inlineCallbacks
def run(self):
cmd = RemoteCommand(args)
log = yield self.addLog('output')
cmd.useLog(log, closeWhenFinished=True)
yield self.runCommand(cmd)