summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-06-03 16:26:10 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-06 10:32:54 +0100
commita5d01e9ec7176ad16e106b100861b488bc22081f (patch)
treeecdfd1b3a02d5753705bed1ab64ee4076e6430e5 /bitbake
parent307d0e13c08d0c9dc43170eb259be7a30ea67529 (diff)
downloadpoky-a5d01e9ec7176ad16e106b100861b488bc22081f.tar.gz
bitbake: bitbake: move configuration reading code
The configuration reading code should live in the main bitbake entry point, and the server modules should be supplied with correct configuration instead of attempting to parse from configuration files. This patch moves the endpoint address reading from XMLRPC to the bitbake main script. (Bitbake rev: ac5753274ff932e1d6f073ab4dab7bd6fe5355a1) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake23
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py24
2 files changed, 22 insertions, 25 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 86d32cff09..fcfe0434ce 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -200,6 +200,28 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
200 options.servertype = "xmlrpc" 200 options.servertype = "xmlrpc"
201 options.remote_server = os.environ["BBSERVER"] 201 options.remote_server = os.environ["BBSERVER"]
202 202
203 # if BBSERVER says to autodetect, let's do that
204 if options.remote_server:
205 [host, port] = options.remote_server.split(":", 2)
206 port = int(port)
207 # use automatic port if port set to -1, means read it from
208 # the bitbake.lock file; this is a bit tricky, but we always expect
209 # to be in the base of the build directory if we need to have a
210 # chance to start the server later, anyway
211 if port == -1:
212 lock_location = "./bitbake.lock"
213 # we try to read the address at all times; if the server is not started,
214 # we'll try to start it after the first connect fails, below
215 try:
216 lf = open(lock_location, 'r')
217 remotedef = lf.readline()
218 [host, port] = remotedef.split(":")
219 port = int(port)
220 lf.close()
221 options.remote_server = remotedef
222 except Exception as e:
223 sys.exit("Failed to read bitbake.lock (%s), invalid port" % str(e))
224
203 return options, targets[1:] 225 return options, targets[1:]
204 226
205 227
@@ -309,7 +331,6 @@ def main():
309 # we start a stub server that is actually a XMLRPClient that connects to a real server 331 # we start a stub server that is actually a XMLRPClient that connects to a real server
310 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only) 332 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only)
311 server.saveConnectionDetails(configParams.remote_server) 333 server.saveConnectionDetails(configParams.remote_server)
312 server.saveConnectionConfigParams(configParams)
313 334
314 if not configParams.server_only: 335 if not configParams.server_only:
315 if configParams.status_only: 336 if configParams.status_only:
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 5dcaa6c7b0..6fc5543a80 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -340,9 +340,6 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
340 def saveConnectionDetails(self, remote): 340 def saveConnectionDetails(self, remote):
341 self.remote = remote 341 self.remote = remote
342 342
343 def saveConnectionConfigParams(self, configParams):
344 self.configParams = configParams
345
346 def establishConnection(self, featureset): 343 def establishConnection(self, featureset):
347 # The format of "remote" must be "server:port" 344 # The format of "remote" must be "server:port"
348 try: 345 try:
@@ -351,27 +348,6 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
351 except Exception as e: 348 except Exception as e:
352 bb.fatal("Failed to read remote definition (%s)" % str(e)) 349 bb.fatal("Failed to read remote definition (%s)" % str(e))
353 350
354 # use automatic port if port set to -1, meaning read it from
355 # the bitbake.lock file
356 if port == -1:
357 lock_location = "%s/bitbake.lock" % self.configParams.environment.get('BUILDDIR')
358 lock = bb.utils.lockfile(lock_location, False, False)
359 if lock:
360 # This means there is no server running which we can
361 # connect to on the local system.
362 bb.utils.unlockfile(lock)
363 return None
364
365 try:
366 lf = open(lock_location, 'r')
367 remotedef = lf.readline()
368 [host, port] = remotedef.split(":")
369 port = int(port)
370 lf.close()
371 self.remote = remotedef
372 except Exception as e:
373 bb.fatal("Failed to read bitbake.lock (%s)" % str(e))
374
375 # We need our IP for the server connection. We get the IP 351 # We need our IP for the server connection. We get the IP
376 # by trying to connect with the server 352 # by trying to connect with the server
377 try: 353 try: