diff options
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 394c886973..8816fe0ec9 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -337,20 +337,45 @@ class Project(models.Model): | |||
337 | 337 | ||
338 | return queryset | 338 | return queryset |
339 | 339 | ||
340 | |||
341 | def schedule_build(self): | 340 | def schedule_build(self): |
342 | from bldcontrol.models import BuildRequest, BRTarget, BRLayer, BRVariable, BRBitbake | 341 | |
343 | br = BuildRequest.objects.create(project = self) | 342 | from bldcontrol.models import BuildRequest, BRTarget, BRLayer |
343 | from bldcontrol.models import BRBitbake, BRVariable | ||
344 | |||
344 | try: | 345 | try: |
346 | now = timezone.now() | ||
347 | build = Build.objects.create(project=self, | ||
348 | completed_on=now, | ||
349 | started_on=now) | ||
350 | |||
351 | br = BuildRequest.objects.create(project=self, | ||
352 | state=BuildRequest.REQ_QUEUED, | ||
353 | build=build) | ||
354 | BRBitbake.objects.create(req=br, | ||
355 | giturl=self.bitbake_version.giturl, | ||
356 | commit=self.bitbake_version.branch, | ||
357 | dirpath=self.bitbake_version.dirpath) | ||
345 | 358 | ||
346 | BRBitbake.objects.create(req = br, | 359 | for t in self.projecttarget_set.all(): |
347 | giturl = self.bitbake_version.giturl, | 360 | BRTarget.objects.create(req=br, target=t.target, task=t.task) |
348 | commit = self.bitbake_version.branch, | 361 | Target.objects.create(build=br.build, target=t.target, |
349 | dirpath = self.bitbake_version.dirpath) | 362 | task=t.task) |
363 | # If we're about to build a custom image recipe make sure | ||
364 | # that layer is currently in the project before we create the | ||
365 | # BRLayer objects | ||
366 | customrecipe = CustomImageRecipe.objects.filter( | ||
367 | name=t.target, | ||
368 | project=self).first() | ||
369 | if customrecipe: | ||
370 | ProjectLayer.objects.get_or_create( | ||
371 | project=self, | ||
372 | layercommit=customrecipe.layer_version, | ||
373 | optional=False) | ||
350 | 374 | ||
351 | for l in self.projectlayer_set.all().order_by("pk"): | 375 | for l in self.projectlayer_set.all().order_by("pk"): |
352 | commit = l.layercommit.get_vcs_reference() | 376 | commit = l.layercommit.get_vcs_reference() |
353 | print("ii Building layer ", l.layercommit.layer.name, " at vcs point ", commit) | 377 | logger.debug("Adding layer to build %s" % |
378 | l.layercommit.layer.name) | ||
354 | BRLayer.objects.create( | 379 | BRLayer.objects.create( |
355 | req=br, | 380 | req=br, |
356 | name=l.layercommit.layer.name, | 381 | name=l.layercommit.layer.name, |
@@ -361,25 +386,16 @@ class Project(models.Model): | |||
361 | local_source_dir=l.layercommit.layer.local_source_dir | 386 | local_source_dir=l.layercommit.layer.local_source_dir |
362 | ) | 387 | ) |
363 | 388 | ||
364 | br.state = BuildRequest.REQ_QUEUED | ||
365 | now = timezone.now() | ||
366 | br.build = Build.objects.create(project = self, | ||
367 | completed_on=now, | ||
368 | started_on=now, | ||
369 | ) | ||
370 | for t in self.projecttarget_set.all(): | ||
371 | BRTarget.objects.create(req = br, target = t.target, task = t.task) | ||
372 | Target.objects.create(build = br.build, target = t.target, task = t.task) | ||
373 | |||
374 | for v in self.projectvariable_set.all(): | 389 | for v in self.projectvariable_set.all(): |
375 | BRVariable.objects.create(req = br, name = v.name, value = v.value) | 390 | BRVariable.objects.create(req=br, name=v.name, value=v.value) |
376 | |||
377 | 391 | ||
378 | try: | 392 | try: |
379 | br.build.machine = self.projectvariable_set.get(name = 'MACHINE').value | 393 | br.build.machine = self.projectvariable_set.get( |
394 | name='MACHINE').value | ||
380 | br.build.save() | 395 | br.build.save() |
381 | except ProjectVariable.DoesNotExist: | 396 | except ProjectVariable.DoesNotExist: |
382 | pass | 397 | pass |
398 | |||
383 | br.save() | 399 | br.save() |
384 | signal_runbuilds() | 400 | signal_runbuilds() |
385 | 401 | ||