bitbake: toaster: reimplemented startBBServer method
Rewritten LocalhostBEController.startBBServer to use 'toaster restart-bitbake' and read bitbake port number from bitbake.lock. Removed complicated logic of running oe-init-memres and looking for bitbake port number in the logs. (Bitbake rev: 4b065353c3454923a1ef88e9f0a8702e5626060e) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
76d53b5856
commit
95a3cf7549
|
@ -88,82 +88,28 @@ class LocalhostBEController(BuildEnvironmentController):
|
|||
# find our own toasterui listener/bitbake
|
||||
from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path
|
||||
|
||||
own_bitbake = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/bitbake"))
|
||||
toaster = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/toaster"))
|
||||
assert os.path.exists(toaster) and os.path.isfile(toaster)
|
||||
|
||||
assert os.path.exists(own_bitbake) and os.path.isfile(own_bitbake)
|
||||
# restart bitbake server and toastergui observer
|
||||
self._shellcmd("bash -c 'source %s restart-bitbake'" % toaster, self.be.builddir)
|
||||
logger.debug("localhostbecontroller: restarted bitbake server")
|
||||
|
||||
logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake)
|
||||
|
||||
toaster_ui_log_filepath = os.path.join(self.be.builddir, "toaster_ui.log")
|
||||
# get the file length; we need to detect the _last_ start of the toaster UI, not the first
|
||||
toaster_ui_log_filelength = 0
|
||||
if os.path.exists(toaster_ui_log_filepath):
|
||||
with open(toaster_ui_log_filepath, "w") as f:
|
||||
f.seek(0, 2) # jump to the end
|
||||
toaster_ui_log_filelength = f.tell()
|
||||
|
||||
cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir)
|
||||
|
||||
port = "-1"
|
||||
logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd)
|
||||
|
||||
cmdoutput = self._shellcmd(cmd)
|
||||
with open(self.be.builddir + "/toaster_server.log", "r") as f:
|
||||
for i in f.readlines():
|
||||
if i.startswith("Bitbake server address"):
|
||||
port = i.split(" ")[-1]
|
||||
logger.debug("localhostbecontroller: Found bitbake server port %s" % port)
|
||||
|
||||
cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \
|
||||
(self.pokydirname, self.be.builddir, own_bitbake)
|
||||
|
||||
# Use a copy of the current environment and add the DATABASE_URL
|
||||
# for the bitbake observer process.
|
||||
env = os.environ.copy()
|
||||
env['DATABASE_URL'] = settings.getDATABASE_URL()
|
||||
|
||||
with open(toaster_ui_log_filepath, "a+") as f:
|
||||
p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True,
|
||||
stdout=f, stderr=f, env=env)
|
||||
|
||||
def _toaster_ui_started(filepath, filepos = 0):
|
||||
if not os.path.exists(filepath):
|
||||
return False
|
||||
with open(filepath, "r") as f:
|
||||
f.seek(filepos)
|
||||
for line in f:
|
||||
if line.startswith("NOTE: ToasterUI waiting for events"):
|
||||
return True
|
||||
return False
|
||||
|
||||
retries = 0
|
||||
started = False
|
||||
while not started and retries < 50:
|
||||
started = _toaster_ui_started(toaster_ui_log_filepath, toaster_ui_log_filelength)
|
||||
import time
|
||||
logger.debug("localhostbecontroller: Waiting bitbake server to start")
|
||||
time.sleep(0.5)
|
||||
retries += 1
|
||||
|
||||
if not started:
|
||||
toaster_ui_log = open(os.path.join(self.be.builddir, "toaster_ui.log"), "r").read()
|
||||
toaster_server_log = open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read()
|
||||
raise BuildSetupException("localhostbecontroller: Bitbake server did not start in 25 seconds, aborting (Error: '%s' '%s')" % (toaster_ui_log, toaster_server_log))
|
||||
|
||||
logger.debug("localhostbecontroller: Started bitbake server")
|
||||
|
||||
while port == "-1":
|
||||
# the port specification is "autodetect"; read the bitbake.lock file
|
||||
with open("%s/bitbake.lock" % self.be.builddir, "r") as f:
|
||||
for line in f.readlines():
|
||||
# read port number from bitbake.lock
|
||||
self.be.bbport = ""
|
||||
bblock = os.path.join(self.be.builddir, 'bitbake.lock')
|
||||
if os.path.exists(bblock):
|
||||
with open(bblock) as fplock:
|
||||
for line in fplock:
|
||||
if ":" in line:
|
||||
port = line.split(":")[1].strip()
|
||||
logger.debug("localhostbecontroller: Autodetected bitbake port %s", port)
|
||||
self.be.bbport = line.split(":")[-1].strip()
|
||||
logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport)
|
||||
break
|
||||
|
||||
assert self.be.sourcedir and os.path.exists(self.be.builddir)
|
||||
if not self.be.bbport:
|
||||
raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock)
|
||||
|
||||
self.be.bbaddress = "localhost"
|
||||
self.be.bbport = port
|
||||
self.be.bbstate = BuildEnvironment.SERVER_STARTED
|
||||
self.be.save()
|
||||
|
||||
|
|
Loading…
Reference in New Issue