summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/bldcontrol/bbcontroller.py35
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py2
-rw-r--r--bitbake/lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py128
-rw-r--r--bitbake/lib/toaster/bldcontrol/models.py5
4 files changed, 158 insertions, 12 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/bbcontroller.py b/bitbake/lib/toaster/bldcontrol/bbcontroller.py
index 1e58c67fcd..bf9cdf9f67 100644
--- a/bitbake/lib/toaster/bldcontrol/bbcontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/bbcontroller.py
@@ -25,7 +25,7 @@ import sys
25import re 25import re
26from django.db import transaction 26from django.db import transaction
27from django.db.models import Q 27from django.db.models import Q
28from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget 28from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake
29import subprocess 29import subprocess
30 30
31from toastermain import settings 31from toastermain import settings
@@ -123,8 +123,10 @@ class BuildEnvironmentController(object):
123 self.connection must be none. 123 self.connection must be none.
124 """ 124 """
125 125
126 def setLayers(self,ls): 126 def setLayers(self, bbs, ls):
127 """ Sets the layer variables in the config file, after validating local layer paths. 127 """ Checks-out bitbake executor and layers from git repositories.
128 Sets the layer variables in the config file, after validating local layer paths.
129 The bitbakes must be a 1-length list of BRBitbake
128 The layer paths must be in a list of BRLayer object 130 The layer paths must be in a list of BRLayer object
129 131
130 a word of attention: by convention, the first layer for any build will be poky! 132 a word of attention: by convention, the first layer for any build will be poky!
@@ -230,15 +232,22 @@ class LocalhostBEController(BuildEnvironmentController):
230 self.be.save() 232 self.be.save()
231 print "Stopped server" 233 print "Stopped server"
232 234
233 def setLayers(self, layers): 235 def setLayers(self, bitbakes, layers):
234 """ a word of attention: by convention, the first layer for any build will be poky! """ 236 """ a word of attention: by convention, the first layer for any build will be poky! """
235 237
236 assert self.be.sourcedir is not None 238 assert self.be.sourcedir is not None
239 assert len(bitbakes) == 1
237 # set layers in the layersource 240 # set layers in the layersource
238 241
239 # 1. get a list of repos, and map dirpaths for each layer 242 # 1. get a list of repos, and map dirpaths for each layer
240 gitrepos = {} 243 gitrepos = {}
244 gitrepos[bitbakes[0].giturl] = []
245 gitrepos[bitbakes[0].giturl].append( ("bitbake", bitbakes[0].dirpath, bitbakes[0].commit) )
246
241 for layer in layers: 247 for layer in layers:
248 # we don't process local URLs
249 if layer.giturl.startswith("file://"):
250 continue
242 if not layer.giturl in gitrepos: 251 if not layer.giturl in gitrepos:
243 gitrepos[layer.giturl] = [] 252 gitrepos[layer.giturl] = []
244 gitrepos[layer.giturl].append( (layer.name, layer.dirpath, layer.commit)) 253 gitrepos[layer.giturl].append( (layer.name, layer.dirpath, layer.commit))
@@ -250,7 +259,7 @@ class LocalhostBEController(BuildEnvironmentController):
250 259
251 def _getgitdirectoryname(url): 260 def _getgitdirectoryname(url):
252 import re 261 import re
253 components = re.split(r'[\.\/]', url) 262 components = re.split(r'[:\.\/]', url)
254 return components[-2] if components[-1] == "git" else components[-1] 263 return components[-2] if components[-1] == "git" else components[-1]
255 264
256 layerlist = [] 265 layerlist = []
@@ -258,7 +267,7 @@ class LocalhostBEController(BuildEnvironmentController):
258 # 2. checkout the repositories 267 # 2. checkout the repositories
259 for giturl in gitrepos.keys(): 268 for giturl in gitrepos.keys():
260 localdirname = os.path.join(self.be.sourcedir, _getgitdirectoryname(giturl)) 269 localdirname = os.path.join(self.be.sourcedir, _getgitdirectoryname(giturl))
261 print "DEBUG: giturl checking out in current directory", localdirname 270 print "DEBUG: giturl ", giturl ,"checking out in current directory", localdirname
262 271
263 # make sure our directory is a git repository 272 # make sure our directory is a git repository
264 if os.path.exists(localdirname): 273 if os.path.exists(localdirname):
@@ -268,11 +277,14 @@ class LocalhostBEController(BuildEnvironmentController):
268 self._shellcmd("git clone \"%s\" \"%s\"" % (giturl, localdirname)) 277 self._shellcmd("git clone \"%s\" \"%s\"" % (giturl, localdirname))
269 # checkout the needed commit 278 # checkout the needed commit
270 commit = gitrepos[giturl][0][2] 279 commit = gitrepos[giturl][0][2]
271 self._shellcmd("git fetch --all && git checkout \"%s\"" % commit , localdirname)
272 print "DEBUG: checked out commit ", commit, "to", localdirname
273 280
274 # if this is the first checkout, take the localdirname as poky dir 281 # branch magic name "HEAD" will inhibit checkout
275 if self.pokydirname is None: 282 if commit != "HEAD":
283 print "DEBUG: checking out commit ", commit, "to", localdirname
284 self._shellcmd("git fetch --all && git checkout \"%s\"" % commit , localdirname)
285
286 # take the localdirname as poky dir if we can find the oe-init-build-env
287 if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")):
276 print "DEBUG: selected poky dir name", localdirname 288 print "DEBUG: selected poky dir name", localdirname
277 self.pokydirname = localdirname 289 self.pokydirname = localdirname
278 290
@@ -282,7 +294,8 @@ class LocalhostBEController(BuildEnvironmentController):
282 if not os.path.exists(localdirpath): 294 if not os.path.exists(localdirpath):
283 raise BuildSetupException("Cannot find layer git path '%s' in checked out repository '%s:%s'. Aborting." % (localdirpath, giturl, commit)) 295 raise BuildSetupException("Cannot find layer git path '%s' in checked out repository '%s:%s'. Aborting." % (localdirpath, giturl, commit))
284 296
285 layerlist.append(localdirpath) 297 if name != "bitbake":
298 layerlist.append(localdirpath)
286 299
287 print "DEBUG: current layer list ", layerlist 300 print "DEBUG: current layer list ", layerlist
288 301
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index fa8c1a9906..8efe8e62bc 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -43,7 +43,7 @@ class Command(NoArgsCommand):
43 43
44 # set up the buid environment with the needed layers 44 # set up the buid environment with the needed layers
45 print "Build %s, Environment %s" % (br, bec.be) 45 print "Build %s, Environment %s" % (br, bec.be)
46 bec.setLayers(br.brlayer_set.all()) 46 bec.setLayers(br.brbitbake_set.all(), br.brlayer_set.all())
47 47
48 # get the bb server running 48 # get the bb server running
49 bbctrl = bec.getBBController() 49 bbctrl = bec.getBBController()
diff --git a/bitbake/lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py b/bitbake/lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py
new file mode 100644
index 0000000000..74388f8434
--- /dev/null
+++ b/bitbake/lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py
@@ -0,0 +1,128 @@
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 model 'BRBitbake'
12 db.create_table(u'bldcontrol_brbitbake', (
13 (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14 ('req', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['bldcontrol.BuildRequest'], unique=True)),
15 ('giturl', self.gf('django.db.models.fields.CharField')(max_length=254)),
16 ('commit', self.gf('django.db.models.fields.CharField')(max_length=254)),
17 ('dirpath', self.gf('django.db.models.fields.CharField')(max_length=254)),
18 ))
19 db.send_create_signal(u'bldcontrol', ['BRBitbake'])
20
21
22 def backwards(self, orm):
23 # Deleting model 'BRBitbake'
24 db.delete_table(u'bldcontrol_brbitbake')
25
26
27 models = {
28 u'bldcontrol.brbitbake': {
29 'Meta': {'object_name': 'BRBitbake'},
30 'commit': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
31 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
32 'giturl': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
33 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
34 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']", 'unique': 'True'})
35 },
36 u'bldcontrol.brerror': {
37 'Meta': {'object_name': 'BRError'},
38 'errmsg': ('django.db.models.fields.TextField', [], {}),
39 'errtype': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
40 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
41 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
42 'traceback': ('django.db.models.fields.TextField', [], {})
43 },
44 u'bldcontrol.brlayer': {
45 'Meta': {'object_name': 'BRLayer'},
46 'commit': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
47 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
48 'giturl': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
49 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
50 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
51 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"})
52 },
53 u'bldcontrol.brtarget': {
54 'Meta': {'object_name': 'BRTarget'},
55 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
56 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
57 'target': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
58 'task': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'})
59 },
60 u'bldcontrol.brvariable': {
61 'Meta': {'object_name': 'BRVariable'},
62 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
63 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
64 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
65 'value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
66 },
67 u'bldcontrol.buildenvironment': {
68 'Meta': {'object_name': 'BuildEnvironment'},
69 'address': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
70 'bbaddress': ('django.db.models.fields.CharField', [], {'max_length': '254', 'blank': 'True'}),
71 'bbport': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
72 'bbstate': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
73 'bbtoken': ('django.db.models.fields.CharField', [], {'max_length': '126', 'blank': 'True'}),
74 'betype': ('django.db.models.fields.IntegerField', [], {}),
75 'builddir': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
76 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
77 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
78 'lock': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
79 'sourcedir': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
80 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
81 },
82 u'bldcontrol.buildrequest': {
83 'Meta': {'object_name': 'BuildRequest'},
84 'build': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Build']", 'null': 'True'}),
85 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
86 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
87 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"}),
88 'state': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
89 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
90 },
91 u'orm.bitbakeversion': {
92 'Meta': {'object_name': 'BitbakeVersion'},
93 'branch': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
94 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
95 'giturl': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
96 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
97 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
98 },
99 u'orm.build': {
100 'Meta': {'object_name': 'Build'},
101 'bitbake_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
102 'build_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
103 'completed_on': ('django.db.models.fields.DateTimeField', [], {}),
104 'cooker_log_path': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
105 'distro': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
106 'distro_version': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
107 'errors_no': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
108 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
109 'machine': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
110 'outcome': ('django.db.models.fields.IntegerField', [], {'default': '2'}),
111 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']", 'null': 'True'}),
112 'started_on': ('django.db.models.fields.DateTimeField', [], {}),
113 'timespent': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
114 'warnings_no': ('django.db.models.fields.IntegerField', [], {'default': '0'})
115 },
116 u'orm.project': {
117 'Meta': {'object_name': 'Project'},
118 'bitbake_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.BitbakeVersion']"}),
119 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
120 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
121 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
122 'short_description': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
123 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
124 'user_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'})
125 }
126 }
127
128 complete_apps = ['bldcontrol'] \ No newline at end of file
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py
index 8c271ffa94..4c54a59b1a 100644
--- a/bitbake/lib/toaster/bldcontrol/models.py
+++ b/bitbake/lib/toaster/bldcontrol/models.py
@@ -75,6 +75,11 @@ class BRLayer(models.Model):
75 commit = models.CharField(max_length = 254) 75 commit = models.CharField(max_length = 254)
76 dirpath = models.CharField(max_length = 254) 76 dirpath = models.CharField(max_length = 254)
77 77
78class BRBitbake(models.Model):
79 req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request
80 giturl = models.CharField(max_length =254)
81 commit = models.CharField(max_length = 254)
82 dirpath = models.CharField(max_length = 254)
78 83
79class BRVariable(models.Model): 84class BRVariable(models.Model):
80 req = models.ForeignKey(BuildRequest) 85 req = models.ForeignKey(BuildRequest)