summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-11-05 14:47:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-12 17:04:48 +0000
commit78e3a7877b361e9c3ae4865231d97a47bd8220bc (patch)
tree1d8e76e4228ab6f17d2c198dd4f5df1d6f192326
parent990fb9ed6cc8414e9a0b1baed8990261650af1db (diff)
downloadpoky-78e3a7877b361e9c3ae4865231d97a47bd8220bc.tar.gz
bitbake: toaster: update Release model to pinpoint to specific Branch
We update the release model to pinpoint to specific branch, instead of holding a branch name that needs to be matched. This is needed because we move away from mixing branches on different layer sources. Various minor changes to models file. (Bitbake rev: d58aacc69b1832f99758b941803123329e06082d) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py9
-rw-r--r--bitbake/lib/toaster/bldcontrol/models.py2
-rw-r--r--bitbake/lib/toaster/bldcontrol/tests.py2
-rw-r--r--bitbake/lib/toaster/orm/migrations/0016_auto__add_field_release_helptext__chg_field_release_branch__add_index_.py359
-rw-r--r--bitbake/lib/toaster/orm/models.py65
5 files changed, 406 insertions, 31 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 9b58587316..08eebceaab 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -150,16 +150,15 @@ class Command(NoArgsCommand):
150 bvo = BitbakeVersion.objects.get(name = ri['bitbake']) 150 bvo = BitbakeVersion.objects.get(name = ri['bitbake'])
151 assert bvo is not None 151 assert bvo is not None
152 152
153 ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo) 153 ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo, branch = Branch.objects.get( layer_source__name = ri['layersource'], name=ri['branch']))
154 ro.description = ri['description'] 154 ro.description = ri['description']
155 ro.branch = ri['branch'] 155 ro.helptext = ri['helptext']
156 ro.save() 156 ro.save()
157 157
158 for dli in ri['defaultlayers']: 158 for dli in ri['defaultlayers']:
159 lsi, layername = dli.split(":")
160 layer, created = Layer.objects.get_or_create( 159 layer, created = Layer.objects.get_or_create(
161 layer_source = LayerSource.objects.get(name = lsi), 160 layer_source = LayerSource.objects.get(name = ri['layersource']),
162 name = layername 161 name = dli
163 ) 162 )
164 ReleaseDefaultLayer.objects.get_or_create( release = ro, layer = layer) 163 ReleaseDefaultLayer.objects.get_or_create( release = ro, layer = layer)
165 164
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py
index 15270c3a57..f72fb8fbc9 100644
--- a/bitbake/lib/toaster/bldcontrol/models.py
+++ b/bitbake/lib/toaster/bldcontrol/models.py
@@ -62,6 +62,7 @@ class BuildRequest(models.Model):
62 REQ_INPROGRESS = 2 62 REQ_INPROGRESS = 2
63 REQ_COMPLETED = 3 63 REQ_COMPLETED = 3
64 REQ_FAILED = 4 64 REQ_FAILED = 4
65 REQ_DELETED = 5
65 66
66 REQUEST_STATE = ( 67 REQUEST_STATE = (
67 (REQ_CREATED, "created"), 68 (REQ_CREATED, "created"),
@@ -69,6 +70,7 @@ class BuildRequest(models.Model):
69 (REQ_INPROGRESS, "in progress"), 70 (REQ_INPROGRESS, "in progress"),
70 (REQ_COMPLETED, "completed"), 71 (REQ_COMPLETED, "completed"),
71 (REQ_FAILED, "failed"), 72 (REQ_FAILED, "failed"),
73 (REQ_DELETED, "deleted"),
72 ) 74 )
73 75
74 project = models.ForeignKey(Project) 76 project = models.ForeignKey(Project)
diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py
index 65e337a31b..37d6524c36 100644
--- a/bitbake/lib/toaster/bldcontrol/tests.py
+++ b/bitbake/lib/toaster/bldcontrol/tests.py
@@ -130,7 +130,7 @@ class RunBuildsCommandTests(TestCase):
130 130
131 def test_br_select(self): 131 def test_br_select(self):
132 from orm.models import Project, Release, BitbakeVersion 132 from orm.models import Project, Release, BitbakeVersion
133 p = Project.objects.create_project("test", Release.objects.get_or_create(name = "HEAD", bitbake_version = BitbakeVersion.objects.get_or_create(name="HEAD", branch="HEAD")[0])[0]) 133 p = Project.objects.create_project("test", Release.objects.get_or_create(name = "HEAD", bitbake_version = BitbakeVersion.objects.get_or_create(name="HEAD", branch=Branch.objects.get_or_create(name="HEAD"))[0])[0])
134 obr = BuildRequest.objects.create(state = BuildRequest.REQ_QUEUED, project = p) 134 obr = BuildRequest.objects.create(state = BuildRequest.REQ_QUEUED, project = p)
135 command = Command() 135 command = Command()
136 br = command._selectBuildRequest() 136 br = command._selectBuildRequest()
diff --git a/bitbake/lib/toaster/orm/migrations/0016_auto__add_field_release_helptext__chg_field_release_branch__add_index_.py b/bitbake/lib/toaster/orm/migrations/0016_auto__add_field_release_helptext__chg_field_release_branch__add_index_.py
new file mode 100644
index 0000000000..545c0ba586
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0016_auto__add_field_release_helptext__chg_field_release_branch__add_index_.py
@@ -0,0 +1,359 @@
1# -*- coding: utf-8 -*-
2from south.utils import datetime_utils as datetime
3from south.db import db
4from south.v2 import SchemaMigration
5from django.db import models
6
7
8class Migration(SchemaMigration):
9
10 def forwards(self, orm):
11 # Adding field 'Release.helptext'
12 db.add_column(u'orm_release', 'helptext',
13 self.gf('django.db.models.fields.TextField')(null=True),
14 keep_default=False)
15
16
17 # Renaming column for 'Release.branch' to match new field type.
18 db.delete_column(u'orm_release', 'branch')
19
20 # Changing field 'Release.branch'
21 db.add_column(u'orm_release', 'branch', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['orm.Branch'], default=-1))
22
23 # Deleting field 'Branch.bitbake_branch'
24 db.delete_column(u'orm_branch', 'bitbake_branch')
25
26 # Adding unique constraint on 'Recipe', fields ['layer_version', 'file_path']
27 db.create_unique(u'orm_recipe', ['layer_version_id', 'file_path'])
28
29 # Adding unique constraint on 'ProjectLayer', fields ['project', 'layercommit']
30 db.create_unique(u'orm_projectlayer', ['project_id', 'layercommit_id'])
31
32
33 def backwards(self, orm):
34 # Removing unique constraint on 'ProjectLayer', fields ['project', 'layercommit']
35 db.delete_unique(u'orm_projectlayer', ['project_id', 'layercommit_id'])
36
37 # Removing unique constraint on 'Recipe', fields ['layer_version', 'file_path']
38 db.delete_unique(u'orm_recipe', ['layer_version_id', 'file_path'])
39
40 # Deleting field 'Release.helptext'
41 db.delete_column(u'orm_release', 'helptext')
42
43 # Renaming column for 'Release.branch' to match new field type.
44 db.rename_column(u'orm_release', 'branch_id', 'branch')
45 # Changing field 'Release.branch'
46 db.alter_column(u'orm_release', 'branch', self.gf('django.db.models.fields.CharField')(max_length=32))
47 # Adding field 'Branch.bitbake_branch'
48 db.add_column(u'orm_branch', 'bitbake_branch',
49 self.gf('django.db.models.fields.CharField')(default='', max_length=50, blank=True),
50 keep_default=False)
51
52
53 models = {
54 u'orm.bitbakeversion': {
55 'Meta': {'object_name': 'BitbakeVersion'},
56 'branch': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
57 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
58 'giturl': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
59 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
60 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
61 },
62 u'orm.branch': {
63 'Meta': {'unique_together': "(('layer_source', 'name'), ('layer_source', 'up_id'))", 'object_name': 'Branch'},
64 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
65 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'True', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
66 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
67 'short_description': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
68 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
69 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
70 },
71 u'orm.build': {
72 'Meta': {'object_name': 'Build'},
73 'bitbake_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
74 'build_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
75 'completed_on': ('django.db.models.fields.DateTimeField', [], {}),
76 'cooker_log_path': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
77 'distro': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
78 'distro_version': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
79 'errors_no': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
80 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
81 'machine': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
82 'outcome': ('django.db.models.fields.IntegerField', [], {'default': '2'}),
83 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']", 'null': 'True'}),
84 'started_on': ('django.db.models.fields.DateTimeField', [], {}),
85 'timespent': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
86 'warnings_no': ('django.db.models.fields.IntegerField', [], {'default': '0'})
87 },
88 u'orm.helptext': {
89 'Meta': {'object_name': 'HelpText'},
90 'area': ('django.db.models.fields.IntegerField', [], {}),
91 'build': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'helptext_build'", 'to': u"orm['orm.Build']"}),
92 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
93 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
94 'text': ('django.db.models.fields.TextField', [], {})
95 },
96 u'orm.layer': {
97 'Meta': {'unique_together': "(('layer_source', 'up_id'), ('layer_source', 'name'))", 'object_name': 'Layer'},
98 'description': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}),
99 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
100 'layer_index_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
101 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
102 'local_path': ('django.db.models.fields.FilePathField', [], {'default': 'None', 'max_length': '255', 'null': 'True'}),
103 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
104 'summary': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}),
105 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
106 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'}),
107 'vcs_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
108 'vcs_web_file_base_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
109 'vcs_web_tree_base_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
110 'vcs_web_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'})
111 },
112 u'orm.layer_version': {
113 'Meta': {'unique_together': "(('layer_source', 'up_id'),)", 'object_name': 'Layer_Version'},
114 'branch': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
115 'build': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'layer_version_build'", 'null': 'True', 'to': u"orm['orm.Build']"}),
116 'commit': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
117 'dirpath': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True'}),
118 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
119 'layer': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'layer_version_layer'", 'to': u"orm['orm.Layer']"}),
120 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
121 'priority': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
122 'up_branch': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.Branch']", 'null': 'True'}),
123 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
124 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
125 },
126 u'orm.layersource': {
127 'Meta': {'unique_together': "(('sourcetype', 'apiurl'),)", 'object_name': 'LayerSource'},
128 'apiurl': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True'}),
129 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
130 'name': ('django.db.models.fields.CharField', [], {'max_length': '63'}),
131 'sourcetype': ('django.db.models.fields.IntegerField', [], {})
132 },
133 u'orm.layerversiondependency': {
134 'Meta': {'unique_together': "(('layer_source', 'up_id'),)", 'object_name': 'LayerVersionDependency'},
135 'depends_on': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'dependees'", 'to': u"orm['orm.Layer_Version']"}),
136 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
137 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
138 'layer_version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'dependencies'", 'to': u"orm['orm.Layer_Version']"}),
139 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
140 },
141 u'orm.logmessage': {
142 'Meta': {'object_name': 'LogMessage'},
143 'build': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Build']"}),
144 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
145 'level': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
146 'lineno': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
147 'message': ('django.db.models.fields.CharField', [], {'max_length': '240'}),
148 'pathname': ('django.db.models.fields.FilePathField', [], {'max_length': '255', 'blank': 'True'}),
149 'task': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Task']", 'null': 'True', 'blank': 'True'})
150 },
151 u'orm.machine': {
152 'Meta': {'unique_together': "(('layer_source', 'up_id'),)", 'object_name': 'Machine'},
153 'description': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
154 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
155 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
156 'layer_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Layer_Version']"}),
157 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
158 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
159 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
160 },
161 u'orm.package': {
162 'Meta': {'object_name': 'Package'},
163 'build': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Build']"}),
164 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
165 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
166 'installed_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'}),
167 'installed_size': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
168 'license': ('django.db.models.fields.CharField', [], {'max_length': '80', 'blank': 'True'}),
169 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
170 'recipe': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Recipe']", 'null': 'True'}),
171 'revision': ('django.db.models.fields.CharField', [], {'max_length': '32', 'blank': 'True'}),
172 'section': ('django.db.models.fields.CharField', [], {'max_length': '80', 'blank': 'True'}),
173 'size': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
174 'summary': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
175 'version': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
176 },
177 u'orm.package_dependency': {
178 'Meta': {'object_name': 'Package_Dependency'},
179 'dep_type': ('django.db.models.fields.IntegerField', [], {}),
180 'depends_on': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'package_dependencies_target'", 'to': u"orm['orm.Package']"}),
181 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
182 'package': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'package_dependencies_source'", 'to': u"orm['orm.Package']"}),
183 'target': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Target']", 'null': 'True'})
184 },
185 u'orm.package_file': {
186 'Meta': {'object_name': 'Package_File'},
187 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
188 'package': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'buildfilelist_package'", 'to': u"orm['orm.Package']"}),
189 'path': ('django.db.models.fields.FilePathField', [], {'max_length': '255', 'blank': 'True'}),
190 'size': ('django.db.models.fields.IntegerField', [], {})
191 },
192 u'orm.project': {
193 'Meta': {'object_name': 'Project'},
194 'bitbake_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.BitbakeVersion']"}),
195 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
196 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
197 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
198 'release': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Release']"}),
199 'short_description': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
200 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
201 'user_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'})
202 },
203 u'orm.projectlayer': {
204 'Meta': {'unique_together': "(('project', 'layercommit'),)", 'object_name': 'ProjectLayer'},
205 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
206 'layercommit': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Layer_Version']", 'null': 'True'}),
207 'optional': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
208 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"})
209 },
210 u'orm.projecttarget': {
211 'Meta': {'object_name': 'ProjectTarget'},
212 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
213 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"}),
214 'target': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
215 'task': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'})
216 },
217 u'orm.projectvariable': {
218 'Meta': {'object_name': 'ProjectVariable'},
219 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
220 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
221 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"}),
222 'value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
223 },
224 u'orm.recipe': {
225 'Meta': {'unique_together': "(('layer_version', 'file_path'),)", 'object_name': 'Recipe'},
226 'bugtracker': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
227 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
228 'file_path': ('django.db.models.fields.FilePathField', [], {'max_length': '255'}),
229 'homepage': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
230 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
231 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
232 'layer_version': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'recipe_layer_version'", 'to': u"orm['orm.Layer_Version']"}),
233 'license': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
234 'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
235 'section': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
236 'summary': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
237 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
238 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'}),
239 'version': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
240 },
241 u'orm.recipe_dependency': {
242 'Meta': {'object_name': 'Recipe_Dependency'},
243 'dep_type': ('django.db.models.fields.IntegerField', [], {}),
244 'depends_on': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'r_dependencies_depends'", 'to': u"orm['orm.Recipe']"}),
245 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
246 'recipe': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'r_dependencies_recipe'", 'to': u"orm['orm.Recipe']"})
247 },
248 u'orm.release': {
249 'Meta': {'object_name': 'Release'},
250 'bitbake_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.BitbakeVersion']"}),
251 'branch': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Branch']"}),
252 'description': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
253 'helptext': ('django.db.models.fields.TextField', [], {'null': 'True'}),
254 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
255 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
256 },
257 u'orm.releasedefaultlayer': {
258 'Meta': {'object_name': 'ReleaseDefaultLayer'},
259 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
260 'layer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Layer']"}),
261 'release': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Release']"})
262 },
263 u'orm.target': {
264 'Meta': {'object_name': 'Target'},
265 'build': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Build']"}),
266 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
267 'image_size': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
268 'is_image': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
269 'license_manifest_path': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
270 'target': ('django.db.models.fields.CharField', [], {'max_length': '100'})
271 },
272 u'orm.target_file': {
273 'Meta': {'object_name': 'Target_File'},
274 'directory': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'directory_set'", 'null': 'True', 'to': u"orm['orm.Target_File']"}),
275 'group': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
276 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
277 'inodetype': ('django.db.models.fields.IntegerField', [], {}),
278 'owner': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
279 'path': ('django.db.models.fields.FilePathField', [], {'max_length': '100'}),
280 'permission': ('django.db.models.fields.CharField', [], {'max_length': '16'}),
281 'size': ('django.db.models.fields.IntegerField', [], {}),
282 'sym_target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'symlink_set'", 'null': 'True', 'to': u"orm['orm.Target_File']"}),
283 'target': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Target']"})
284 },
285 u'orm.target_image_file': {
286 'Meta': {'object_name': 'Target_Image_File'},
287 'file_name': ('django.db.models.fields.FilePathField', [], {'max_length': '254'}),
288 'file_size': ('django.db.models.fields.IntegerField', [], {}),
289 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
290 'target': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Target']"})
291 },
292 u'orm.target_installed_package': {
293 'Meta': {'object_name': 'Target_Installed_Package'},
294 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
295 'package': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'buildtargetlist_package'", 'to': u"orm['orm.Package']"}),
296 'target': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Target']"})
297 },
298 u'orm.task': {
299 'Meta': {'ordering': "('order', 'recipe')", 'unique_together': "(('build', 'recipe', 'task_name'),)", 'object_name': 'Task'},
300 'build': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'task_build'", 'to': u"orm['orm.Build']"}),
301 'cpu_usage': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '2'}),
302 'disk_io': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
303 'elapsed_time': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '2'}),
304 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
305 'line_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
306 'logfile': ('django.db.models.fields.FilePathField', [], {'max_length': '255', 'blank': 'True'}),
307 'message': ('django.db.models.fields.CharField', [], {'max_length': '240'}),
308 'order': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
309 'outcome': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
310 'path_to_sstate_obj': ('django.db.models.fields.FilePathField', [], {'max_length': '500', 'blank': 'True'}),
311 'recipe': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'build_recipe'", 'to': u"orm['orm.Recipe']"}),
312 'script_type': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
313 'source_url': ('django.db.models.fields.FilePathField', [], {'max_length': '255', 'blank': 'True'}),
314 'sstate_checksum': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
315 'sstate_result': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
316 'task_executed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
317 'task_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
318 'work_directory': ('django.db.models.fields.FilePathField', [], {'max_length': '255', 'blank': 'True'})
319 },
320 u'orm.task_dependency': {
321 'Meta': {'object_name': 'Task_Dependency'},
322 'depends_on': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'task_dependencies_depends'", 'to': u"orm['orm.Task']"}),
323 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
324 'task': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'task_dependencies_task'", 'to': u"orm['orm.Task']"})
325 },
326 u'orm.toastersetting': {
327 'Meta': {'object_name': 'ToasterSetting'},
328 'helptext': ('django.db.models.fields.TextField', [], {}),
329 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
330 'name': ('django.db.models.fields.CharField', [], {'max_length': '63'}),
331 'value': ('django.db.models.fields.CharField', [], {'max_length': '255'})
332 },
333 u'orm.toastersettingdefaultlayer': {
334 'Meta': {'object_name': 'ToasterSettingDefaultLayer'},
335 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
336 'layer_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Layer_Version']"})
337 },
338 u'orm.variable': {
339 'Meta': {'object_name': 'Variable'},
340 'build': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'variable_build'", 'to': u"orm['orm.Build']"}),
341 'changed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
342 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
343 'human_readable_name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
344 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
345 'variable_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
346 'variable_value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
347 },
348 u'orm.variablehistory': {
349 'Meta': {'object_name': 'VariableHistory'},
350 'file_name': ('django.db.models.fields.FilePathField', [], {'max_length': '255'}),
351 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
352 'line_number': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
353 'operation': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
354 'value': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
355 'variable': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'vhistory'", 'to': u"orm['orm.Variable']"})
356 }
357 }
358
359 complete_apps = ['orm']
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 503b43c5db..d99a4c2129 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -108,8 +108,16 @@ class Project(models.Model):
108 commit = self.bitbake_version.branch, 108 commit = self.bitbake_version.branch,
109 dirpath = self.bitbake_version.dirpath) 109 dirpath = self.bitbake_version.dirpath)
110 110
111 for l in self.projectlayer_set.all(): 111 for l in self.projectlayer_set.all().order_by("pk"):
112 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = l.layercommit.commit, dirpath = l.layercommit.dirpath) 112 commit = l.layercommit.commit
113 print("ii Building layer ", l.layercommit.layer.name, " at commit ", commit)
114 if l.layercommit.up_branch:
115 commit = l.layercommit.up_branch.name
116 print("ii Building layer ", l.layercommit.layer.name, " at upbranch ", commit)
117 if l.layercommit.branch:
118 commit = l.layercommit.branch
119 print("ii Building layer ", l.layercommit.layer.name, " at actual_branch ", commit)
120 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = commit, dirpath = l.layercommit.dirpath)
113 for t in self.projecttarget_set.all(): 121 for t in self.projecttarget_set.all():
114 BRTarget.objects.create(req = br, target = t.target, task = t.task) 122 BRTarget.objects.create(req = br, target = t.target, task = t.task)
115 for v in self.projectvariable_set.all(): 123 for v in self.projectvariable_set.all():
@@ -414,7 +422,7 @@ class Package_File(models.Model):
414 size = models.IntegerField() 422 size = models.IntegerField()
415 423
416class Recipe(models.Model): 424class Recipe(models.Model):
417 search_allowed_fields = ['name', 'version', 'file_path', 'section', 'license', 'layer_version__layer__name', 'layer_version__branch', 'layer_version__commit', 'layer_version__layer__local_path'] 425 search_allowed_fields = ['name', 'version', 'file_path', 'section', 'description', 'license', 'layer_version__layer__name', 'layer_version__branch', 'layer_version__commit', 'layer_version__layer__local_path', 'layer_version__layer_source__name']
418 426
419 layer_source = models.ForeignKey('LayerSource', default = None, null = True) # from where did we get this recipe 427 layer_source = models.ForeignKey('LayerSource', default = None, null = True) # from where did we get this recipe
420 up_id = models.IntegerField(null = True, default = None) # id of entry in the source 428 up_id = models.IntegerField(null = True, default = None) # id of entry in the source
@@ -446,6 +454,9 @@ class Recipe(models.Model):
446 def __unicode__(self): 454 def __unicode__(self):
447 return "Recipe " + self.name + ":" + self.version 455 return "Recipe " + self.name + ":" + self.version
448 456
457 class Meta:
458 unique_together = ("layer_version", "file_path")
459
449class Recipe_DependencyManager(models.Manager): 460class Recipe_DependencyManager(models.Manager):
450 use_for_related_fields = True 461 use_for_related_fields = True
451 462
@@ -559,6 +570,7 @@ class LayerIndexLayerSource(LayerSource):
559 Fetches layer, recipe and machine information from remote repository 570 Fetches layer, recipe and machine information from remote repository
560 ''' 571 '''
561 assert self.apiurl is not None 572 assert self.apiurl is not None
573 from django.db import IntegrityError
562 574
563 def _get_json_response(apiurl = self.apiurl): 575 def _get_json_response(apiurl = self.apiurl):
564 import httplib, urlparse, json 576 import httplib, urlparse, json
@@ -589,7 +601,7 @@ class LayerIndexLayerSource(LayerSource):
589 return 601 return
590 602
591 # update branches; only those that we already have names listed in the Releases table 603 # update branches; only those that we already have names listed in the Releases table
592 whitelist_branch_names = map(lambda x: x.branch, Release.objects.all()) 604 whitelist_branch_names = map(lambda x: x.branch.name, Release.objects.all())
593 605
594 branches_info = _get_json_response(apilinks['branches'] 606 branches_info = _get_json_response(apilinks['branches']
595 + "?filter=name:%s" % "OR".join(whitelist_branch_names)) 607 + "?filter=name:%s" % "OR".join(whitelist_branch_names))
@@ -598,16 +610,15 @@ class LayerIndexLayerSource(LayerSource):
598 b.up_id = bi['id'] 610 b.up_id = bi['id']
599 b.up_date = bi['updated'] 611 b.up_date = bi['updated']
600 b.name = bi['name'] 612 b.name = bi['name']
601 b.bitbake_branch = bi['bitbake_branch']
602 b.short_description = bi['short_description'] 613 b.short_description = bi['short_description']
603 b.save() 614 b.save()
604 615
605 # update layers 616 # update layers
606 layers_info = _get_json_response(apilinks['layerItems']) 617 layers_info = _get_json_response(apilinks['layerItems'])
607 for li in layers_info: 618 for li in layers_info:
608 l, created = Layer.objects.get_or_create(layer_source = self, up_id = li['id']) 619 l, created = Layer.objects.get_or_create(layer_source = self, name = li['name'])
620 l.up_id = li['id']
609 l.up_date = li['updated'] 621 l.up_date = li['updated']
610 l.name = li['name']
611 l.vcs_url = li['vcs_url'] 622 l.vcs_url = li['vcs_url']
612 l.vcs_web_url = li['vcs_web_url'] 623 l.vcs_web_url = li['vcs_web_url']
613 l.vcs_web_tree_base_url = li['vcs_web_tree_base_url'] 624 l.vcs_web_tree_base_url = li['vcs_web_tree_base_url']
@@ -672,21 +683,22 @@ class LayerIndexLayerSource(LayerSource):
672 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) 683 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
673 ) 684 )
674 for ri in recipes_info: 685 for ri in recipes_info:
675 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 = ri['layerbranch'])) 686 try:
676 687 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 = ri['layerbranch']))
677 ro.up_date = ri['updated'] 688 ro.up_date = ri['updated']
678 689 ro.name = ri['pn']
679 ro.name = ri['pn'] 690 ro.version = ri['pv']
680 ro.version = ri['pv'] 691 ro.summary = ri['summary']
681 ro.summary = ri['summary'] 692 ro.description = ri['description']
682 ro.description = ri['description'] 693 ro.section = ri['section']
683 ro.section = ri['section'] 694 ro.license = ri['license']
684 ro.license = ri['license'] 695 ro.homepage = ri['homepage']
685 ro.homepage = ri['homepage'] 696 ro.bugtracker = ri['bugtracker']
686 ro.bugtracker = ri['bugtracker'] 697 ro.file_path = ri['filepath'] + "/" + ri['filename']
687 ro.file_path = ri['filepath'] + ri['filename'] 698 ro.save()
688 ro.save() 699 except:
689 700 print "Duplicate Recipe, ignoring: ", vars(ro)
701 pass
690 pass 702 pass
691 703
692class BitbakeVersion(models.Model): 704class BitbakeVersion(models.Model):
@@ -704,7 +716,8 @@ class Release(models.Model):
704 name = models.CharField(max_length=32, unique = True) 716 name = models.CharField(max_length=32, unique = True)
705 description = models.CharField(max_length=255) 717 description = models.CharField(max_length=255)
706 bitbake_version = models.ForeignKey(BitbakeVersion) 718 bitbake_version = models.ForeignKey(BitbakeVersion)
707 branch = models.CharField(max_length=32) 719 branch = models.ForeignKey('Branch')
720 helptext = models.TextField(null=True)
708 721
709 722
710class ReleaseDefaultLayer(models.Model): 723class ReleaseDefaultLayer(models.Model):
@@ -719,7 +732,6 @@ class Branch(models.Model):
719 up_date = models.DateTimeField(null = True, default = None) 732 up_date = models.DateTimeField(null = True, default = None)
720 733
721 name = models.CharField(max_length=50) 734 name = models.CharField(max_length=50)
722 bitbake_branch = models.CharField(max_length=50, blank=True)
723 short_description = models.CharField(max_length=50, blank=True) 735 short_description = models.CharField(max_length=50, blank=True)
724 736
725 class Meta: 737 class Meta:
@@ -756,7 +768,7 @@ class Layer(models.Model):
756 768
757# LayerCommit class is synced with layerindex.LayerBranch 769# LayerCommit class is synced with layerindex.LayerBranch
758class Layer_Version(models.Model): 770class Layer_Version(models.Model):
759 search_allowed_fields = ["layer__name", "layer__summary",] 771 search_allowed_fields = ["layer__name", "layer__summary", "layer__description", "layer__vcs_url", "dirpath", "up_branch__name", "commit", "branch"]
760 build = models.ForeignKey(Build, related_name='layer_version_build', default = None, null = True) 772 build = models.ForeignKey(Build, related_name='layer_version_build', default = None, null = True)
761 layer = models.ForeignKey(Layer, related_name='layer_version_layer') 773 layer = models.ForeignKey(Layer, related_name='layer_version_layer')
762 774
@@ -841,6 +853,9 @@ class ProjectLayer(models.Model):
841 layercommit = models.ForeignKey(Layer_Version, null=True) 853 layercommit = models.ForeignKey(Layer_Version, null=True)
842 optional = models.BooleanField(default = True) 854 optional = models.BooleanField(default = True)
843 855
856 class Meta:
857 unique_together = (("project", "layercommit"),)
858
844class ProjectVariable(models.Model): 859class ProjectVariable(models.Model):
845 project = models.ForeignKey(Project) 860 project = models.ForeignKey(Project)
846 name = models.CharField(max_length=100) 861 name = models.CharField(max_length=100)