[bitbake-devel] [PATCH 06/17] toasterui: identify proper layer in build mode

Alex DAMIAN alexandru.damian at intel.com
Thu Mar 12 10:46:39 UTC 2015


From: Alexandru DAMIAN <alexandru.damian at intel.com>

In build mode, instead of creating our own layer objects,
we identify the layer objects that the build system set up.

[YOCTO #7378]

Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
 lib/bb/ui/buildinfohelper.py                    | 23 ++++++++++++++++++-----
 lib/toaster/bldcontrol/localhostbecontroller.py |  4 ++--
 lib/toaster/orm/models.py                       | 10 ++--------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 19ddd8e..ae2ac9f 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -270,15 +270,28 @@ class ORMWrapper(object):
         else:
             # we are under managed mode; we must match the layer used in the Project Layer
             from bldcontrol.models import BuildEnvironment, BuildRequest
-            br, be = brbe.split(":")
+            br_id, be_id = brbe.split(":")
 
-            buildrequest = BuildRequest.objects.get(pk = br)
+            # find layer by checkout path;
+            from bldcontrol import bbcontroller
+            bc = bbcontroller.getBuildEnvironmentController(pk = be_id)
 
             # we might have a race condition here, as the project layers may change between the build trigger and the actual build execution
             # but we can only match on the layer name, so the worst thing can happen is a mis-identification of the layer, not a total failure
-            layer_object = buildrequest.project.projectlayer_set.get(layercommit__layer__name=layer_information['name']).layercommit.layer
 
-            return layer_object
+            from pprint import pformat
+            # note that this is different
+            buildrequest = BuildRequest.objects.get(pk = br_id)
+            for brl in buildrequest.brlayer_set.all():
+                localdirname = os.path.join(bc.getGitCloneDirectory(brl.giturl, brl.commit), brl.dirpath)
+                logger.warn("Matched %s to BRlayer %s" % (pformat(layer_information["local_path"]), localdirname))
+                if localdirname.startswith(layer_information['local_path']):
+                    # we matched the BRLayer, but we need the layer_version that generated this BR; reverse of the Project.schedule_build()
+                    for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name):
+                        if pl.layercommit.layer.vcs_url == brl.giturl :
+                            return pl.layercommit.layer
+
+            raise Exception("Unidentified layer %s" % pformat(layer_information))
 
 
     def save_target_file_information(self, build_obj, target_obj, filedata):
@@ -683,7 +696,7 @@ class BuildInfoHelper(object):
 
             # Heuristics: we match the path to where the layers have been checked out
             for brl in sorted(BuildRequest.objects.get(pk = br_id).brlayer_set.all(), reverse = True, key = _slkey_managed):
-                localdirname = os.path.join(os.path.join(bc.be.sourcedir, bc.getGitCloneDirectory(brl.giturl, brl.commit)), brl.dirpath)
+                localdirname = os.path.join(bc.getGitCloneDirectory(brl.giturl, brl.commit), brl.dirpath)
                 if path.startswith(localdirname):
                     #logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname))
                     # we matched the BRLayer, but we need the layer_version that generated this br
diff --git a/lib/toaster/bldcontrol/localhostbecontroller.py b/lib/toaster/bldcontrol/localhostbecontroller.py
index 25ce052..aef9b60 100644
--- a/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -180,7 +180,7 @@ class LocalhostBEController(BuildEnvironmentController):
         base = components[-2] if components[-1] == "git" else components[-1]
 
         if branch != "HEAD":
-            return "_%s_%s.toaster_cloned" % (base, branch)
+            return os.path.join(self.be.sourcedir, "_%s_%s.toaster_cloned" % (base, branch))
 
 
         # word of attention; this is a localhost-specific issue; only on the localhost we expect to have "HEAD" releases
@@ -239,7 +239,7 @@ class LocalhostBEController(BuildEnvironmentController):
 
         # 3. checkout the repositories
         for giturl, commit in gitrepos.keys():
-            localdirname = os.path.join(self.be.sourcedir, self.getGitCloneDirectory(giturl, commit))
+            localdirname = self.getGitCloneDirectory(giturl, commit)
             logger.debug("localhostbecontroller: giturl %s:%s checking out in current directory %s" % (giturl, commit, localdirname))
 
             # make sure our directory is a git repository
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 4d1dcbc..80e6d92 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -195,14 +195,8 @@ class Project(models.Model):
                 dirpath = self.bitbake_version.dirpath)
 
             for l in self.projectlayer_set.all().order_by("pk"):
-                commit = l.layercommit.commit
-                print("ii Building layer ", l.layercommit.layer.name, " at commit ", commit)
-                if l.layercommit.up_branch:
-                    commit = l.layercommit.up_branch.name
-                    print("ii Building layer ", l.layercommit.layer.name, " at upbranch ", commit)
-                if l.layercommit.branch:
-                    commit = l.layercommit.branch
-                    print("ii Building layer ", l.layercommit.layer.name, " at actual_branch ", commit)
+                commit = l.layercommit.get_vcs_reference()
+                print("ii Building layer ", l.layercommit.layer.name, " at vcs point ", commit)
                 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = commit, dirpath = l.layercommit.dirpath)
             for t in self.projecttarget_set.all():
                 BRTarget.objects.create(req = br, target = t.target, task = t.task)
-- 
1.9.1




More information about the bitbake-devel mailing list