summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol/bbcontroller.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-07-15 12:35:43 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-07-23 20:06:57 +0100
commit6cfb76fa8bd1c192e6a0524b7670e2172e5d8e26 (patch)
tree8210bd00ecda985d8498c3d4ebc41bf38fb65540 /bitbake/lib/toaster/bldcontrol/bbcontroller.py
parent5ba68f32a86a20b3f3544903fea2a24f2e59afbf (diff)
downloadpoky-6cfb76fa8bd1c192e6a0524b7670e2172e5d8e26.tar.gz
bitbake: toaster: add fields for sourcedir and builddir paths
We add explicit absolute paths for a directory where the layer sources will be checked out (sourcedir) and where the build activities will take place. Adding minimal checking when starting the application in order to make sure that BuildEnvironment (BE) settings are usable. This check is ran by the toaster script at startup. Modify the localhost bbcontroller to use the BE settings instead of trying to self-configure on checked out sources. (Bitbake rev: d17500d3f73fdeeef5f11fb3773a65e927be3f02) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/bbcontroller.py')
-rw-r--r--bitbake/lib/toaster/bldcontrol/bbcontroller.py51
1 files changed, 25 insertions, 26 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/bbcontroller.py b/bitbake/lib/toaster/bldcontrol/bbcontroller.py
index d2b2a236bd..c3beba96f0 100644
--- a/bitbake/lib/toaster/bldcontrol/bbcontroller.py
+++ b/bitbake/lib/toaster/bldcontrol/bbcontroller.py
@@ -170,27 +170,16 @@ class LocalhostBEController(BuildEnvironmentController):
170 this controller manages the default build directory, 170 this controller manages the default build directory,
171 the server setup and system start and stop for the localhost-type build environment 171 the server setup and system start and stop for the localhost-type build environment
172 172
173 The address field is used as working directory; if not set, the build/ directory
174 is created
175 """ 173 """
174 from os.path import dirname as DN
176 175
177 def __init__(self, be): 176 def __init__(self, be):
178 super(LocalhostBEController, self).__init__(be) 177 super(LocalhostBEController, self).__init__(be)
179 from os.path import dirname as DN 178 from os.path import dirname as DN
180 self.cwd = DN(DN(DN(DN(DN(os.path.realpath(__file__))))))
181 if self.be.address is None or len(self.be.address) == 0:
182 self.be.address = "build"
183 self.be.save()
184 self.bwd = self.be.address
185 self.dburl = settings.getDATABASE_URL() 179 self.dburl = settings.getDATABASE_URL()
186 180
187 # transform relative paths to absolute ones
188 if not self.bwd.startswith("/"):
189 self.bwd = os.path.join(self.cwd, self.bwd)
190 self._createBE()
191
192 def _shellcmd(self, command): 181 def _shellcmd(self, command):
193 p = subprocess.Popen(command, cwd=self.cwd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 182 p = subprocess.Popen(command, cwd=self.be.sourcedir, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
194 (out,err) = p.communicate() 183 (out,err) = p.communicate()
195 if p.returncode: 184 if p.returncode:
196 if len(err) == 0: 185 if len(err) == 0:
@@ -201,39 +190,49 @@ class LocalhostBEController(BuildEnvironmentController):
201 else: 190 else:
202 return out 191 return out
203 192
204 def _createBE(self): 193 def _createdirpath(self, path):
205 assert self.cwd and os.path.exists(self.cwd) 194 if not os.path.exists(DN(path)):
206 self._shellcmd("bash -c \"source %s/oe-init-build-env %s\"" % (self.cwd, self.bwd)) 195 self._createdirpath(DN(path))
196 if not os.path.exists(path):
197 os.mkdir(path, 0755)
198
199 def _startBE(self):
200 assert self.be.sourcedir and os.path.exists(self.be.sourcedir)
201 self._createdirpath(self.be.builddir)
202 self._shellcmd("bash -c \"source %s/oe-init-build-env %s\"" % (self.be.sourcedir, self.be.builddir))
207 203
208 def startBBServer(self): 204 def startBBServer(self):
209 assert self.cwd and os.path.exists(self.cwd) 205 assert self.be.sourcedir and os.path.exists(self.be.sourcedir)
210 print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && DATABASE_URL=%s source toaster start noweb && sleep 1\"" % (self.cwd, self.bwd, self.dburl)) 206
207 self._startBE()
208
209 print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && DATABASE_URL=%s source toaster start noweb && sleep 1\"" % (self.be.sourcedir, self.be.builddir, self.dburl))
211 # FIXME unfortunate sleep 1 - we need to make sure that bbserver is started and the toaster ui is connected 210 # FIXME unfortunate sleep 1 - we need to make sure that bbserver is started and the toaster ui is connected
212 # but since they start async without any return, we just wait a bit 211 # but since they start async without any return, we just wait a bit
213 print "Started server" 212 print "Started server"
214 assert self.cwd and os.path.exists(self.bwd) 213 assert self.be.sourcedir and os.path.exists(self.be.builddir)
215 self.be.bbaddress = "localhost" 214 self.be.bbaddress = "localhost"
216 self.be.bbport = "8200" 215 self.be.bbport = "8200"
217 self.be.bbstate = BuildEnvironment.SERVER_STARTED 216 self.be.bbstate = BuildEnvironment.SERVER_STARTED
218 self.be.save() 217 self.be.save()
219 218
220 def stopBBServer(self): 219 def stopBBServer(self):
221 assert self.cwd 220 assert self.be.sourcedir
222 print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && %s source toaster stop\"" % 221 print self._shellcmd("bash -c \"source %s/oe-init-build-env %s && %s source toaster stop\"" %
223 (self.cwd, self.bwd, (lambda: "" if self.be.bbtoken is None else "BBTOKEN=%s" % self.be.bbtoken)())) 222 (self.be.sourcedir, self.be.builddir, (lambda: "" if self.be.bbtoken is None else "BBTOKEN=%s" % self.be.bbtoken)()))
224 self.be.bbstate = BuildEnvironment.SERVER_STOPPED 223 self.be.bbstate = BuildEnvironment.SERVER_STOPPED
225 self.be.save() 224 self.be.save()
226 print "Stopped server" 225 print "Stopped server"
227 226
228 def setLayers(self, layers): 227 def setLayers(self, layers):
229 assert self.cwd is not None 228 assert self.be.sourcedir is not None
230 layerconf = os.path.join(self.bwd, "conf/bblayers.conf") 229 layerconf = os.path.join(self.be.builddir, "conf/bblayers.conf")
231 if not os.path.exists(layerconf): 230 if not os.path.exists(layerconf):
232 raise Exception("BE is not consistent: bblayers.conf file missing at ", layerconf) 231 raise Exception("BE is not consistent: bblayers.conf file missing at ", layerconf)
233 return True 232 return True
234 233
235 def release(self): 234 def release(self):
236 assert self.cwd and os.path.exists(self.bwd) 235 assert self.be.sourcedir and os.path.exists(self.be.builddir)
237 import shutil 236 import shutil
238 shutil.rmtree(os.path.join(self.cwd, "build")) 237 shutil.rmtree(os.path.join(self.be.sourcedir, "build"))
239 assert not os.path.exists(self.bwd) 238 assert not os.path.exists(self.be.builddir)