All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: toaster@yoctoproject.org
Subject: [PATCH v5 12/19] toaster: reimplement triggerBuild
Date: Wed, 16 Mar 2016 14:05:31 +0200	[thread overview]
Message-ID: <91b3f42a7abe19f727f5e1ca8390b42099b33ea3.1458127353.git.ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <cover.1458127353.git.ed.bartosh@linux.intel.com>
In-Reply-To: <cover.1458127353.git.ed.bartosh@linux.intel.com>

Reimplemented triggerBuild method to support one build directory
per project:
 - start bitbake server from the cloned repository
 - don't run observer
 - run bitbake build directly instead of triggering it
   through xmlrpc

[YOCTO #7880]
[YOCTO #9058]
[YOCTO #8958]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 .../toaster/bldcontrol/localhostbecontroller.py    | 100 +++++++++++++--------
 1 file changed, 65 insertions(+), 35 deletions(-)

diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 833c685..4894b1b 100644
--- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -250,44 +250,74 @@ class LocalhostBEController(BuildEnvironmentController):
 
 
     def triggerBuild(self, bitbake, layers, variables, targets, brbe):
-        # set up the build environment with the needed layers
-        self.setLayers(bitbake, layers, targets)
+        layers = self.setLayers(bitbake, layers, targets)
+
+        # init build environment from the clone
+        builddir = '%s-toaster-%d' % (self.be.builddir, bitbake.req.project.id)
+        oe_init = os.path.join(self.pokydirname, 'oe-init-build-env')
+        # init build environment
+        self._shellcmd('source %s %s' % (oe_init, builddir), self.be.sourcedir)
+
+        # update bblayers.conf
+        bblconfpath = os.path.join(builddir, "conf/bblayers.conf")
+        conflines = open(bblconfpath, "r").readlines()
+        skip = False
+        with open(bblconfpath, 'w') as bblayers:
+            for line in conflines:
+                if line.startswith("# line added by toaster"):
+                    skip = True
+                    continue
+                if skip:
+                    skip = False
+                else:
+                    bblayers.write(line)
+
+            bblayers.write('# line added by toaster build control\n'
+                           'BBLAYERS = "%s"' % ' '.join(layers))
 
         # write configuration file
-        filepath = os.path.join(self.be.builddir, "conf/toaster.conf")
-        with open(filepath, 'w') as conf:
+        confpath = os.path.join(builddir, 'conf/toaster.conf')
+        with open(confpath, 'w') as conf:
             for var in variables:
                 conf.write('%s="%s"\n' % (var.name, var.value))
             conf.write('INHERIT+="toaster buildhistory"')
 
-        # get the bb server running with the build req id and build env id
-        bbctrl = self.getBBController()
-
-        # set variables; TOASTER_BRBE is not set on the server, as this
-        # causes events from command-line builds to be attached to the last
-        # Toaster-triggered build; instead, TOASTER_BRBE is fired as an event so
-        # that toasterui can set it on the buildinfohelper;
-        # see https://bugzilla.yoctoproject.org/show_bug.cgi?id=9021
-        for var in variables:
-            if var.name == 'TOASTER_BRBE':
-                bbctrl.triggerEvent('bb.event.MetadataEvent("SetBRBE", "%s")' \
-                                     % var.value)
-            else:
-                bbctrl.setVariable(var.name, var.value)
-
-        # Add 'toaster' and 'buildhistory' to INHERIT variable
-        inherit = {item.strip() for item in bbctrl.getVariable('INHERIT').split()}
-        inherit = inherit.union(["toaster", "buildhistory"])
-        bbctrl.setVariable('INHERIT', ' '.join(inherit))
-
-        # trigger the build command
-        task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets))
-        if len(task) == 0:
-            task = None
-
-        bbctrl.build(list(map(lambda x:x.target, targets)), task)
-
-        logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir)
-
-        # disconnect from the server
-        bbctrl.disconnect()
+        # run bitbake server from the clone
+        bitbake = os.path.join(self.pokydirname, 'bitbake', 'bin', 'bitbake')
+        self._shellcmd('source %s %s; BITBAKE_UI="" %s --read %s '
+                       '--server-only -t xmlrpc -B 0.0.0.0:0' % (oe_init, builddir,
+                       bitbake, confpath), self.be.sourcedir)
+
+        # read port number from bitbake.lock
+        self.be.bbport = ""
+        bblock = os.path.join(builddir, 'bitbake.lock')
+        with open(bblock) as fplock:
+            for line in fplock:
+                if ":" in line:
+                    self.be.bbport = line.split(":")[-1].strip()
+                    logger.debug("localhostbecontroller: bitbake port %s", self.be.bbport)
+                    break
+
+        if not self.be.bbport:
+            raise BuildSetupException("localhostbecontroller: can't read bitbake port from %s" % bblock)
+
+        self.be.bbaddress = "localhost"
+        self.be.bbstate = BuildEnvironment.SERVER_STARTED
+        self.be.lock = BuildEnvironment.LOCK_RUNNING
+        self.be.save()
+
+        bbtargets = ''
+        for target in targets:
+            task = target.task or 'do_build'
+            if not task.startswith('do_'):
+                task = 'do_' + task
+            bbtargets += '%s:%s ' % (target.target, task)
+
+        # run build with local bitbake
+        log = os.path.join(builddir, 'toaster_ui.log')
+        self._shellcmd('TOASTER_BRBE="%s" BBSERVER="0.0.0.0:-1" '
+                       '../bitbake/bin/bitbake %s -u toasterui '
+                       '>>%s 2>&1 &' % (brbe, bbtargets, log), builddir)
+
+        logger.debug('localhostbecontroller: Build launched, exiting. '
+                     'Follow build logs at %s' % log)
-- 
2.1.4



  parent reply	other threads:[~2016-03-16 14:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 12:05 [PATCH v5 00/19] per project build directory Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 01/19] toaster: don't start bitbake server Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 02/19] toaster: get rid of noui option Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 03/19] toaster: set BITBAKE_UI environment variable Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 04/19] toasterui: add brbe parameter to buildinfohelper Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 05/19] uievent: improve BBUIEventQueue code Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 06/19] buildinfohelper: improve handling of providermap Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 07/19] toasterui: fix brbe reporting Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 08/19] toaster: remove startBBServer API Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 09/19] toaster: remove release API Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 10/19] toaster: add brbe parameter to triggerBuild Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 11/19] toaster: modified setLayers API Ed Bartosh
2016-03-16 12:05 ` Ed Bartosh [this message]
2016-03-16 12:05 ` [PATCH v5 13/19] toaster: add new parameter to _shellcmd Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 14/19] toaster: stop bitbake server after the build Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 15/19] toaster: update conf/local.conf Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 16/19] toaster: fix jethro build Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 17/19] toaster: use bash explicitly Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 18/19] toasterui: detect build run start correctly on Jethro Ed Bartosh
2016-03-16 12:05 ` [PATCH v5 19/19] toasterui: shutdown on BuildCompleted event Ed Bartosh
2016-03-17 17:20 ` [PATCH v5 00/19] per project build directory Barros Pena, Belen
2016-03-17 16:22   ` Ed Bartosh
2016-03-18 17:03     ` Barros Pena, Belen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91b3f42a7abe19f727f5e1ca8390b42099b33ea3.1458127353.git.ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=toaster@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.