Duplicate openembedded-core layer issues
RFC PATCH 1/1 Duplicate openembedded-core layer issues
Currently we have multiple openembedded-core layers appearing in the UI, we have some mechanisms to conflate these layers but these have been proven to be fragile and cause issues when trying to relate the layer <-> recipe <-> build information.
What this patch does is check when downloading layers from the layer index as to whether this layer already exists. The flow is like this:
1 - Load toasterconf.json (toasterconf.json specifies a layer 'openembedded-core' as a local layer as this is included in poky)
2 - Layer 'openembedded-core' is created in database
3 - Layer Version HEAD or "Local" is created and no other versions
4 - Layer index update is triggered this then pulls in all the available layers for the releases specified in the toasterconf.json all these new layers are assigned to the layer_source of layerindex.
5 - If a layer by the name of openembedded-core comes in when loading from the layer index we see if this layer already exists from a different layer_source. If it does exist the layer's layer_source is then taken over by the layer index and the metadata from the layer index then updates this layer (though not all fields). The layer index then will continue in the normal way in downloading layer versions for this layer e.g. master, fido and dizzy. (Rather than creating these layers versions from toasterconf.json
This means that when you start up toaster we now have recipes and machines and meta data about the 3 default core layers allowing selecting any of these things without having to remove the default layers and add them from the layer index version of this (where it gets further confused because it thinks that openembedded-core is inherently inside poky).
There is a further issue to solve where the build information coming back doesn't relate back to (any?) of the layers, but I think this is orthogonal as the built layer has a different revision so doesn't match the existing one. e.g. layer master built turn into 'layer abcdef1234' which then appears to be a new layer.
Michael Wood (1):
toaster: Special case the openembedded-core layer to avoid duplicates
bitbake/lib/toaster/orm/models.py | 21 +++++++++++++++++++++ meta-yocto/conf/toasterconf.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.4
PATCH 1/1 toaster: Special case the openembedded-core layer to avoid duplicates
If the openembedded-core layer is specified in the toasterconf we need to treat it differently because we may also get this layer either from the layerindex source or I can also be provided locally.
--- bitbake/lib/toaster/orm/models.py | 21 +++++++++++++++++++++ meta-yocto/conf/toasterconf.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-)
bitbake/lib/toaster/orm/models.py +21 -0
@@ -828,6 +828,7 @@ class LayerIndexLayerSource(LayerSource): import urllib2, urlparse, json import os proxy_settings = os.environ.get("http_proxy", None) + oe_core_layer = 'openembedded-core' def _get_json_response(apiurl = self.apiurl): _parsedurl = urlparse.urlparse(apiurl)
@@ -872,6 +873,25 @@ class LayerIndexLayerSource(LayerSource): if not connection.features.autocommits_when_autocommit_is_off: transaction.set_autocommit(False) for li in layers_info: + # Special case for the openembedded-core layer + if li['name'] == oe_core_layer: + try: + # If we have an existing openembedded-core for example + # from the toasterconf.json augment the info using the + # layerindex rather than duplicate it + oe_core_l = Layer.objects.get(name=oe_core_layer) + # Take ownership of the layer as now coming from the + # layerindex + oe_core_l.layer_source = self + oe_core_l.up_id = li['id'] + oe_core_l.summary = li['summary'] + oe_core_l.description = li['description'] + oe_core_l.save() + continue + + except DoesNotExist: + pass + l, created = Layer.objects.get_or_create(layer_source = self, name = li['name']) l.up_id = li['id'] l.up_date = li['updated']
@@ -882,6 +902,7 @@ class LayerIndexLayerSource(LayerSource): l.summary = li['summary'] l.description = li['description'] l.save() + if not connection.features.autocommits_when_autocommit_is_off: transaction.set_autocommit(True)
meta-yocto/conf/toasterconf.json +1 -1
@@ -12,7 +12,7 @@ "name": "Local Yocto Project", "sourcetype": "local", "apiurl": "../../", - "branches": ["HEAD", "master", "fido", "dizzy"], + "branches": ["HEAD" ], "layers": [ { "name": "openembedded-core",
Signature · 1 line
2.1.4
Re: [PATCH] toaster: Special case the openembedded-core layer to avoid duplicates
Quoted 3 lines · On 10/09/2015 18:47, "[email protected] on behalf of Michael…
If the openembedded-core layer is specified in the toasterconf we need to treat it differently because we may also get this layer either from the layerindex source or I can also be provided locally.
I have been able to build with this for all releases (local, dizzy, fido and master). The only issue I've found is with the openembedded-core layer entries generated after each build. If you try to view their layer details page, you get an error (pasted below), although the cause seems to be a piece of information we don't need and can be removed.
Cheers
Belén
Environment:
Request Method: GET
Request URL: http://192.168.2.55:8000/toastergui/project/3/layer/370
Django Version: 1.6
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.staticfiles', 'django.contrib.humanize',
'bldcollector',
'toastermain',
'south',
'bldcontrol',
'orm',
'toastergui')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')
Template error:
In template /home/yocto/master/bitbake/lib/toaster/toastergui/templates/layerdetails.ht ml, error at line 268
Undefined variable or unknown value for: "layerversion.up_branch.name"
258 : <textarea class="span12" rows="6">{% if
layerversion.layer.description %}{{layerversion.layer.description}}{% endif %}</textarea>
259 : <button class="btn change-btn"
data-layer-prop="description" type="button" >Save</button>
260 : <a href="#" class="btn btn-link cancel">Cancel</a>
261 : </form>
262 : <i class="icon-pencil"></i>
263 : <span class="icon-trash delete-current-value"
data-toggle="tooltip" title="Delete"></span>
264 : </dd>
265 : {% if layerversion.layer.up_id %}
266 : <dt>Layer index</dt>
267 : <dd>
268 : <a
href="http://layers.openembedded.org/layerindex/branch/ {{layerversion.up_branch.name}} /layer/{{layerversion.layer.name}}">layer index link</a>
269 :
270 : </dd>
271 : {% endif %}
272 :
273 : </dl>
274 : </div>
275 :
276 : {% endblock %}
277 :
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request,*callback_args, **callback_kwargs)
File "/home/yocto/master/bitbake/lib/toaster/toastergui/views.py" in returned_wrapper
167. return render(request, template, context)
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render
53. return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
169. return t.render(context_instance)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
140. return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
305. return nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render
88. output = self.filter_expression.resolve(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in resolve
595. return
settings.TEMPLATE_STRING_IF_INVALID % self.var
File "/home/yocto/master/bitbake/lib/toaster/toastermain/settings.py" in __mod__
399. "Undefined variable or unknown value for: \"%s\"" %
other)
Exception Type: TemplateSyntaxError at /toastergui/project/3/layer/370 Exception Value: Undefined variable or unknown value for:
"layerversion.up_branch.name"
Quoted 79 lines
Signed-off-by Michael Wood <[email protected]>---
bitbake/lib/toaster/orm/models.py| 21 +++++++++++++++++++++meta-yocto/conf/toasterconf.json| 2 +-2 files changed, 22 insertions(+), 1 deletion(-)bitbake/lib/toaster/orm/models.py +5
-0@@ -828,6 +828,7 @@ class LayerIndexLayerSource(LayerSource): import urllib2, urlparse, json import os proxy_settings = os.environ.get("http_proxy", None) + oe_core_layer = 'openembedded-core' def _get_json_response(apiurl = self.apiurl): _parsedurl = urlparse.urlparse(apiurl)@@ -872,6 +873,25 @@ class LayerIndexLayerSource(LayerSource): if not connection.features.autocommits_when_autocommit_is_off: transaction.set_autocommit(False) for li in layers_info: + # Special case for the openembedded-core layer + if li['name'] == oe_core_layer: + try: + # If we have an existing openembedded-core forexample
+ # from the toasterconf.json augment the info using
thebitbake/lib/toaster/orm/models.py +14
-0+ # layerindex rather than duplicate it + oe_core_l = Layer.objects.get(name=oe_core_layer) + # Take ownership of the layer as now coming from the + # layerindex + oe_core_l.layer_source = self + oe_core_l.up_id = li['id'] + oe_core_l.summary = li['summary'] + oe_core_l.description = li['description'] + oe_core_l.save() + continue + + except DoesNotExist: + pass + l, created = Layer.objects.get_or_create(layer_source =self, name = li['name'])
l.up_id = li['id'] l.up_date = li['updated']bitbake/lib/toaster/orm/models.py +1
-0@@ -882,6 +902,7 @@ class LayerIndexLayerSource(LayerSource): l.summary = li['summary'] l.description = li['description'] l.save() + if not connection.features.autocommits_when_autocommit_is_off: transaction.set_autocommit(True)meta-yocto/conf/toasterconf.json +1
-1@@ -12,7 +12,7 @@ "name": "Local Yocto Project", "sourcetype": "local", "apiurl": "../../", - "branches": ["HEAD", "master", "fido", "dizzy"], + "branches": ["HEAD" ], "layers": [ { "name": "openembedded-core",Signature · 7 lines
2.1.4 -- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster