diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2014-09-23 16:48:52 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-10-30 13:39:49 +0000 |
commit | 1a463ab98ec1220b22a721a1f88ff5af61c33dc3 (patch) | |
tree | 873e4f21bc8b61e27d3c2a2f46215e42794b4131 /bitbake | |
parent | b27fc6f18f66fcb738b3aed2c278986f79de8413 (diff) | |
download | poky-1a463ab98ec1220b22a721a1f88ff5af61c33dc3.tar.gz |
bitbake: toaster: fix layer source update code
We fix problems in the layer source update code related to
non-null field restrictions.
We add missing layer dependency update.
(Bitbake rev: e1169127405ce10a044ac9cdf4a892838a99d01f)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 77afe35861..1b3bb22e79 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -585,25 +585,48 @@ class LayerIndexLayerSource(LayerSource): | |||
585 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), Branch.objects.filter(layer_source = self))) | 585 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), Branch.objects.filter(layer_source = self))) |
586 | ) | 586 | ) |
587 | for lbi in layerbranches_info: | 587 | for lbi in layerbranches_info: |
588 | lv, created = Layer_Version.objects.get_or_create(layer_source = self, up_id = lbi['id']) | 588 | lv, created = Layer_Version.objects.get_or_create(layer_source = self, |
589 | up_id = lbi['id'], | ||
590 | layer=Layer.objects.get(layer_source = self, up_id = lbi['layer']) | ||
591 | ) | ||
589 | 592 | ||
590 | lv.up_date = lbi['updated'] | 593 | lv.up_date = lbi['updated'] |
591 | lv.layer = Layer.objects.get(layer_source = self, up_id = lbi['layer']) | ||
592 | lv.up_branch = Branch.objects.get(layer_source = self, up_id = lbi['branch']) | 594 | lv.up_branch = Branch.objects.get(layer_source = self, up_id = lbi['branch']) |
593 | lv.branch = lbi['actual_branch'] | 595 | lv.branch = lbi['actual_branch'] |
594 | lv.commit = lbi['vcs_last_rev'] | 596 | lv.commit = lbi['vcs_last_rev'] |
595 | lv.dirpath = lbi['vcs_subdir'] | 597 | lv.dirpath = lbi['vcs_subdir'] |
596 | lv.save() | 598 | lv.save() |
597 | 599 | ||
600 | # update layer dependencies | ||
601 | layerdependencies_info = _get_json_response(apilinks['layerDependencies']) | ||
602 | dependlist = {} | ||
603 | for ldi in layerdependencies_info: | ||
604 | try: | ||
605 | lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch']) | ||
606 | except Layer_Version.DoesNotExist as e: | ||
607 | continue | ||
608 | |||
609 | if lv not in dependlist: | ||
610 | dependlist[lv] = [] | ||
611 | try: | ||
612 | dependlist[lv].append(Layer_Version.objects.get(layer_source = self, layer__up_id = ldi['dependency'], up_branch = lv.up_branch)) | ||
613 | except Layer_Version.DoesNotExist as e: | ||
614 | print "Cannot find layer version ", self, ldi['dependency'], lv.up_branch | ||
615 | raise e | ||
616 | |||
617 | for lv in dependlist: | ||
618 | LayerVersionDependency.objects.filter(layer_version = lv).delete() | ||
619 | for lvd in dependlist[lv]: | ||
620 | LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd) | ||
621 | |||
598 | 622 | ||
599 | # update machines | 623 | # update machines |
600 | machines_info = _get_json_response(apilinks['machines'] | 624 | machines_info = _get_json_response(apilinks['machines'] |
601 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 625 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
602 | ) | 626 | ) |
603 | for mi in machines_info: | 627 | for mi in machines_info: |
604 | mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id']) | 628 | mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) |
605 | mo.up_date = mi['updated'] | 629 | mo.up_date = mi['updated'] |
606 | mo.layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']) | ||
607 | mo.name = mi['name'] | 630 | mo.name = mi['name'] |
608 | mo.description = mi['description'] | 631 | mo.description = mi['description'] |
609 | mo.save() | 632 | mo.save() |
@@ -613,10 +636,9 @@ class LayerIndexLayerSource(LayerSource): | |||
613 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 636 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
614 | ) | 637 | ) |
615 | for ri in recipes_info: | 638 | for ri in recipes_info: |
616 | ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id']) | 639 | ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) |
617 | 640 | ||
618 | ro.up_date = ri['updated'] | 641 | ro.up_date = ri['updated'] |
619 | ro.layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']) | ||
620 | 642 | ||
621 | ro.name = ri['pn'] | 643 | ro.name = ri['pn'] |
622 | ro.version = ri['pv'] | 644 | ro.version = ri['pv'] |