bitbake: toaster script: webport option and other improvements

We add the "webport=" command line option as to allow starting
the web server on a custom port.

The bitbake server port is now auto-allocated. This is needed
to be able to run multiple toaster environments on a single machine.

We tackle bug 6023 (toaster refusing to start when lock file is present)
by using more specific checks, and automatically recover from
bitbake server down / webserver up error mode.

Command line parameters are now read on both interactive and managed
modes.

The localhost and ssh controllers are updated to work with the modified
toaster launcher script.

[YOCTO #6023]

(Bitbake rev: cd3eb5b051743463cfe51dba97cae4da75420048)

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexandru DAMIAN
2014-11-03 13:47:16 +00:00
committed by Richard Purdie
parent baa1082c64
commit 0ca70ce37a
4 changed files with 120 additions and 79 deletions

View File

@@ -80,13 +80,18 @@ class SSHBEController(BuildEnvironmentController):
def startBBServer(self, brbe):
assert self.pokydirname and self._pathexists(self.pokydirname)
assert self.islayerset
print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && DATABASE_URL=%s source toaster start noweb brbe=%s\"" % (self.pokydirname, self.be.builddir, self.dburl, brbe))
# FIXME unfortunate sleep 1 - we need to make sure that bbserver is started and the toaster ui is connected
# but since they start async without any return, we just wait a bit
print "Started server"
cmd = self._shellcmd("bash -c \"source %s/oe-init-build-env %s && DATABASE_URL=%s source toaster start noweb brbe=%s\"" % (self.pokydirname, self.be.builddir, self.dburl, brbe))
port = "-1"
for i in cmd.split("\n"):
if i.startswith("Bitbake server address"):
port = i.split(" ")[-1]
print "Found bitbake server port ", port
assert self.be.sourcedir and self._pathexists(self.be.builddir)
self.be.bbaddress = self.be.address.split("@")[-1]
self.be.bbport = "8200"
self.be.bbport = port
self.be.bbstate = BuildEnvironment.SERVER_STARTED
self.be.save()
@@ -99,6 +104,19 @@ class SSHBEController(BuildEnvironmentController):
self.be.save()
print "Stopped server"
def _copyFile(self, filepath1, filepath2):
p = subprocess.Popen("scp '%s' '%s'" % (filepath1, filepath2), stdout=subprocess.PIPE, stderr = subprocess.PIPE, shell=True)
(out, err) = p.communicate()
if p.returncode:
raise ShellCmdException(err)
def pullFile(self, local_filename, remote_filename):
_copyFile(local_filename, "%s:%s" % (self.be.address, remote_filename))
def pushFile(self, local_filename, remote_filename):
_copyFile("%s:%s" % (self.be.address, remote_filename), local_filename)
def setLayers(self, bitbakes, layers):
""" a word of attention: by convention, the first layer for any build will be poky! """
@@ -110,7 +128,7 @@ class SSHBEController(BuildEnvironmentController):
gitrepos = {}
gitrepos[bitbakes[0].giturl] = []
gitrepos[bitbakes[0].giturl].append( ("bitbake", bitbakes[0].dirpath, bitbakes[0].commit) )
for layer in layers:
# we don't process local URLs
if layer.giturl.startswith("file://"):
@@ -171,17 +189,15 @@ class SSHBEController(BuildEnvironmentController):
if not self._pathexists(bblayerconf):
raise BuildSetupException("BE is not consistent: bblayers.conf file missing at %s" % bblayerconf)
conflines = open(bblayerconf, "r").readlines()
import uuid
local_bblayerconf = "/tmp/" + uuid.uuid4() + "-bblayer.conf"
bblayerconffile = open(bblayerconf, "w")
for i in xrange(len(conflines)):
if conflines[i].startswith("# line added by toaster"):
i += 2
else:
bblayerconffile.write(conflines[i])
self.pullFile(bblayerconf, local_bblayerconf)
bblayerconffile.write("\n# line added by toaster build control\nBBLAYERS = \"" + " ".join(layerlist) + "\"")
bblayerconffile.close()
BuildEnvironmentController._updateBBLayers(local_bblayerconf, layerlist)
self.pushFile(local_bblayerconf, bblayerconf)
os.unlink(local_bblayerconf)
self.islayerset = True
return True