summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py2
-rw-r--r--bitbake/lib/toaster/orm/management/commands/lsupdates.py23
-rw-r--r--bitbake/lib/toaster/orm/models.py32
-rw-r--r--bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml21
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py2
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py8
6 files changed, 43 insertions, 45 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
index 1f57fc16f1..59324acbc5 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
@@ -1,5 +1,5 @@
1from django.core.management.base import BaseCommand, CommandError 1from django.core.management.base import BaseCommand, CommandError
2from orm.models import LayerSource, ToasterSetting, Branch, Layer, Layer_Version 2from orm.models import LayerSource, ToasterSetting, Layer, Layer_Version
3from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer 3from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer
4from django.db import IntegrityError 4from django.db import IntegrityError
5import os 5import os
diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index 138b686eb5..be63a85859 100644
--- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -102,14 +102,24 @@ class Command(NoArgsCommand):
102 logger.info("Fetching metadata releases for %s", 102 logger.info("Fetching metadata releases for %s",
103 " ".join(whitelist_branch_names)) 103 " ".join(whitelist_branch_names))
104 104
105 # keep a track of the id mappings so that layer_versions can be created 105 branches_info = _get_json_response(apilinks['branches'] +
106 # for these layers later on 106 "?filter=name:%s"
107 % "OR".join(whitelist_branch_names))
108
109 # Map the layer index branches to toaster releases
110 li_branch_id_to_toaster_release = {}
111
112 total = len(branches_info)
113 for i, branch in enumerate(branches_info):
114 li_branch_id_to_toaster_release[branch['id']] = \
115 Release.objects.get(name=branch['name'])
116 self.mini_progress("Releases", i, total)
117
118 # keep a track of the layerindex (li) id mappings so that
119 # layer_versions can be created for these layers later on
107 li_layer_id_to_toaster_layer_id = {} 120 li_layer_id_to_toaster_layer_id = {}
108 121
109 # We may need this? TODO 122 logger.info("Fetching layers")
110 #branches_info = _get_json_response(apilinks['branches'] +
111 # "?filter=name:%s"
112 # % "OR".join(whitelist_branch_names))
113 123
114 layers_info = _get_json_response(apilinks['layerItems']) 124 layers_info = _get_json_response(apilinks['layerItems'])
115 125
@@ -179,6 +189,7 @@ class Command(NoArgsCommand):
179 lbi['layer']) 189 lbi['layer'])
180 continue 190 continue
181 191
192 lv.release = li_branch_id_to_toaster_release[lbi['branch']]
182 lv.up_date = lbi['updated'] 193 lv.up_date = lbi['updated']
183 lv.commit = lbi['actual_branch'] 194 lv.commit = lbi['actual_branch']
184 lv.dirpath = lbi['vcs_subdir'] 195 lv.dirpath = lbi['vcs_subdir']
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 34ea28c270..72b9dfeaa8 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -144,7 +144,7 @@ class ProjectManager(models.Manager):
144 for rdl in release.releasedefaultlayer_set.all(): 144 for rdl in release.releasedefaultlayer_set.all():
145 lv = Layer_Version.objects.filter( 145 lv = Layer_Version.objects.filter(
146 layer__name=rdl.layer_name, 146 layer__name=rdl.layer_name,
147 up_branch__name=release.branch_name).first() 147 release=release).first()
148 148
149 if lv: 149 if lv:
150 ProjectLayer.objects.create(project=prj, 150 ProjectLayer.objects.create(project=prj,
@@ -280,7 +280,7 @@ class Project(models.Model):
280 # guard on release, as it can be null 280 # guard on release, as it can be null
281 if self.release: 281 if self.release:
282 queryset = Layer_Version.objects.filter( 282 queryset = Layer_Version.objects.filter(
283 (Q(up_branch__name=self.release.branch_name) & 283 (Q(release=self.release) &
284 Q(build=None) & 284 Q(build=None) &
285 Q(project=None)) | 285 Q(project=None)) |
286 Q(project=self)) 286 Q(project=self))
@@ -1257,22 +1257,6 @@ class ReleaseDefaultLayer(models.Model):
1257 layer_name = models.CharField(max_length=100, default="") 1257 layer_name = models.CharField(max_length=100, default="")
1258 1258
1259 1259
1260# Branch class is synced with layerindex.Branch, branches can only come
1261# from remote layer indexes
1262class Branch(models.Model):
1263 # id of branch in the layerindex
1264 up_date = models.DateTimeField(null=True, default=None)
1265
1266 name = models.CharField(max_length=50)
1267 short_description = models.CharField(max_length=50, blank=True)
1268
1269 class Meta:
1270 verbose_name_plural = "Branches"
1271
1272 def __unicode__(self):
1273 return self.name
1274
1275
1276class LayerSource(object): 1260class LayerSource(object):
1277 """ Where the layer metadata came from """ 1261 """ Where the layer metadata came from """
1278 TYPE_LOCAL = 0 1262 TYPE_LOCAL = 0
@@ -1321,7 +1305,7 @@ class Layer_Version(models.Model):
1321 """ 1305 """
1322 search_allowed_fields = ["layer__name", "layer__summary", 1306 search_allowed_fields = ["layer__name", "layer__summary",
1323 "layer__description", "layer__vcs_url", 1307 "layer__description", "layer__vcs_url",
1324 "dirpath", "up_branch__name", "commit", "branch"] 1308 "dirpath", "release__name", "commit", "branch"]
1325 1309
1326 build = models.ForeignKey(Build, related_name='layer_version_build', 1310 build = models.ForeignKey(Build, related_name='layer_version_build',
1327 default=None, null=True) 1311 default=None, null=True)
@@ -1333,8 +1317,8 @@ class Layer_Version(models.Model):
1333 1317
1334 up_date = models.DateTimeField(null=True, default=timezone.now) 1318 up_date = models.DateTimeField(null=True, default=timezone.now)
1335 1319
1336 # layerindex specific field 1320 # To which metadata release does this layer version belong to
1337 up_branch = models.ForeignKey(Branch, null=True, default=None) 1321 release = models.ForeignKey(Release, null=True, default=None)
1338 1322
1339 branch = models.CharField(max_length=80) 1323 branch = models.CharField(max_length=80)
1340 commit = models.CharField(max_length=100) 1324 commit = models.CharField(max_length=100)
@@ -1368,7 +1352,7 @@ class Layer_Version(models.Model):
1368 extra_path = self.dirpath 1352 extra_path = self.dirpath
1369 else: 1353 else:
1370 extra_path = path 1354 extra_path = path
1371 branchname = self.up_branch.name 1355 branchname = self.release.name
1372 url = base_url.replace('%branch%', branchname) 1356 url = base_url.replace('%branch%', branchname)
1373 1357
1374 # If there's a % in the path (e.g. a wildcard bbappend) we need to encode it 1358 # If there's a % in the path (e.g. a wildcard bbappend) we need to encode it
@@ -1404,8 +1388,8 @@ class Layer_Version(models.Model):
1404 def get_vcs_reference(self): 1388 def get_vcs_reference(self):
1405 if self.branch is not None and len(self.branch) > 0: 1389 if self.branch is not None and len(self.branch) > 0:
1406 return self.branch 1390 return self.branch
1407 if self.up_branch is not None: 1391 if self.release is not None:
1408 return self.up_branch.name 1392 return self.release.name
1409 if self.commit is not None and len(self.commit) > 0: 1393 if self.commit is not None and len(self.commit) > 0:
1410 return self.commit 1394 return self.commit
1411 return 'N/A' 1395 return 'N/A'
diff --git a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
index 80c1e19dda..4517ed1765 100644
--- a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
+++ b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
@@ -1,5 +1,16 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<django-objects version="1.0"> 2<django-objects version="1.0">
3 <object pk="1" model="orm.bitbakeversion">
4 <field type="CharField" name="name">v2.3</field>
5 <field type="GitURLField" name="giturl">git://git.openembedded.org/bitbake</field>
6 <field type="CharField" name="dirpath">b</field>
7 <field type="CharField" name="branch">a</field>
8 </object>
9 <object pk="1" model="orm.release">
10 <field type="CharField" name="name">master</field>
11 <field type="CharField" name="description">master project</field>
12 <field to="orm.bitbake_version" name="bitbake_version">1</field>
13 </object>
3 <object pk="1" model="orm.project"> 14 <object pk="1" model="orm.project">
4 <field type="CharField" name="name">a test project</field> 15 <field type="CharField" name="name">a test project</field>
5 <field type="CharField" name="short_description"></field> 16 <field type="CharField" name="short_description"></field>
@@ -332,10 +343,6 @@
332 <field type="CharField" name="branch_name">master</field> 343 <field type="CharField" name="branch_name">master</field>
333 <field type="TextField" name="helptext"><None></None></field> 344 <field type="TextField" name="helptext"><None></None></field>
334 </object> 345 </object>
335 <object pk="1" model="orm.branch">
336 <field type="CharField" name="name">master</field>
337 <field type="CharField" name="short_description"></field>
338 </object>
339 <object pk="1" model="orm.layer"> 346 <object pk="1" model="orm.layer">
340 <field type="DateTimeField" name="up_date"><None></None></field> 347 <field type="DateTimeField" name="up_date"><None></None></field>
341 <field type="CharField" name="name">a layer</field> 348 <field type="CharField" name="name">a layer</field>
@@ -351,7 +358,7 @@
351 <field to="orm.build" name="build" rel="ManyToOneRel">1</field> 358 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
352 <field to="orm.layer" name="layer" rel="ManyToOneRel">1</field> 359 <field to="orm.layer" name="layer" rel="ManyToOneRel">1</field>
353 <field type="DateTimeField" name="up_date"><None></None></field> 360 <field type="DateTimeField" name="up_date"><None></None></field>
354 <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field> 361 <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
355 <field type="CharField" name="branch">master</field> 362 <field type="CharField" name="branch">master</field>
356 <field type="CharField" name="commit">abcdef123</field> 363 <field type="CharField" name="commit">abcdef123</field>
357 <field type="CharField" name="dirpath">/tmp/</field> 364 <field type="CharField" name="dirpath">/tmp/</field>
@@ -363,7 +370,7 @@
363 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field> 370 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
364 <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field> 371 <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field>
365 <field type="DateTimeField" name="up_date"><None></None></field> 372 <field type="DateTimeField" name="up_date"><None></None></field>
366 <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field> 373 <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
367 <field type="CharField" name="branch">testing-branch</field> 374 <field type="CharField" name="branch">testing-branch</field>
368 <field type="CharField" name="commit">9876fedcba</field> 375 <field type="CharField" name="commit">9876fedcba</field>
369 <field type="CharField" name="dirpath"><None></None></field> 376 <field type="CharField" name="dirpath"><None></None></field>
@@ -375,7 +382,7 @@
375 <field to="orm.build" name="build" rel="ManyToOneRel">1</field> 382 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
376 <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field> 383 <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field>
377 <field type="DateTimeField" name="up_date"><None></None></field> 384 <field type="DateTimeField" name="up_date"><None></None></field>
378 <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field> 385 <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
379 <field type="CharField" name="branch">testing-branch</field> 386 <field type="CharField" name="branch">testing-branch</field>
380 <field type="CharField" name="commit">9876fedcba</field> 387 <field type="CharField" name="commit">9876fedcba</field>
381 <field type="CharField" name="dirpath"><None></None></field> 388 <field type="CharField" name="dirpath"><None></None></field>
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 03b73a9d69..61ac4773f3 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -31,7 +31,7 @@ from orm.models import Project, Release, BitbakeVersion, Package, LogMessage
31from orm.models import LayerSource, Layer, Build 31from orm.models import LayerSource, Layer, Build
32from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target 32from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target
33from orm.models import CustomImageRecipe, ProjectVariable 33from orm.models import CustomImageRecipe, ProjectVariable
34from orm.models import Branch, CustomImagePackage 34from orm.models import CustomImagePackage
35 35
36import toastermain 36import toastermain
37import inspect 37import inspect
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index d19815f661..a40ceef942 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -161,7 +161,7 @@ def _lv_to_dict(prj, x = None):
161 return {"id": x.pk, 161 return {"id": x.pk,
162 "name": x.layer.name, 162 "name": x.layer.name,
163 "tooltip": "%s | %s" % (x.layer.vcs_url,x.get_vcs_reference()), 163 "tooltip": "%s | %s" % (x.layer.vcs_url,x.get_vcs_reference()),
164 "detail": "(%s" % x.layer.vcs_url + (")" if x.up_branch == None else " | "+x.get_vcs_reference()+")"), 164 "detail": "(%s" % x.layer.vcs_url + (")" if x.release == None else " | "+x.get_vcs_reference()+")"),
165 "giturl": x.layer.vcs_url, 165 "giturl": x.layer.vcs_url,
166 "layerdetailurl" : reverse('layerdetails', args=(prj.id,x.pk)), 166 "layerdetailurl" : reverse('layerdetails', args=(prj.id,x.pk)),
167 "revision" : x.get_vcs_reference(), 167 "revision" : x.get_vcs_reference(),
@@ -1288,7 +1288,7 @@ if True:
1288 from django.contrib.auth import authenticate, login 1288 from django.contrib.auth import authenticate, login
1289 from django.contrib.auth.decorators import login_required 1289 from django.contrib.auth.decorators import login_required
1290 1290
1291 from orm.models import Branch, LayerSource, ToasterSetting, Release, Machine, LayerVersionDependency 1291 from orm.models import LayerSource, ToasterSetting, Release, Machine, LayerVersionDependency
1292 from bldcontrol.models import BuildRequest 1292 from bldcontrol.models import BuildRequest
1293 1293
1294 import traceback 1294 import traceback
@@ -1667,9 +1667,6 @@ if True:
1667 post_data[key] = val.strip() 1667 post_data[key] = val.strip()
1668 1668
1669 1669
1670 # We need to know what release the current project is so that we
1671 # can set the imported layer's up_branch_id
1672
1673 try: 1670 try:
1674 layer, layer_created = Layer.objects.get_or_create(name=post_data['name']) 1671 layer, layer_created = Layer.objects.get_or_create(name=post_data['name'])
1675 except MultipleObjectsReturned: 1672 except MultipleObjectsReturned:
@@ -1759,7 +1756,6 @@ if True:
1759 1756
1760 return HttpResponse(jsonfilter(json_response), content_type = "application/json") 1757 return HttpResponse(jsonfilter(json_response), content_type = "application/json")
1761 1758
1762
1763 @xhr_response 1759 @xhr_response
1764 def xhr_customrecipe(request): 1760 def xhr_customrecipe(request):
1765 """ 1761 """