diff options
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/bbcontroller.py')
| -rw-r--r-- | bitbake/lib/toaster/bldcontrol/bbcontroller.py | 35 |
1 files changed, 24 insertions, 11 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 | |||
| 25 | import re | 25 | import re |
| 26 | from django.db import transaction | 26 | from django.db import transaction |
| 27 | from django.db.models import Q | 27 | from django.db.models import Q |
| 28 | from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget | 28 | from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake |
| 29 | import subprocess | 29 | import subprocess |
| 30 | 30 | ||
| 31 | from toastermain import settings | 31 | from 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 | ||
