diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-24 09:13:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-08-06 11:21:31 +0100 |
commit | ca04aaf7b51e3ee2bb04da970d5f20f2c9982cb8 (patch) | |
tree | ee5fe5d5e780cd965bbe7f9a0d25d91d280b1834 /bitbake/lib/bb | |
parent | d9aafb85072bef3b5baa54408969d54a8425a111 (diff) | |
download | poky-ca04aaf7b51e3ee2bb04da970d5f20f2c9982cb8.tar.gz |
bitbake: cooker/hashserv: Allow autostarting of a local hash server using BB_HASHSERVE
Its useful, particularly in the local developer model of usage, for
bitbake to start and stop a hash equivalence server on local port,
rather than relying on one being started by the user before the build.
The new BB_HASHSERVE variable supports this.
The database handling is moved internally into the hashserv code so that
different threads/processes can be used for the server without errors.
(Bitbake rev: a4fa8f1bd88995ae60e10430316fbed63d478587)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index b4851e13ed..84f25ec94e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -31,6 +31,7 @@ import pyinotify | |||
31 | import json | 31 | import json |
32 | import pickle | 32 | import pickle |
33 | import codecs | 33 | import codecs |
34 | import hashserv | ||
34 | 35 | ||
35 | logger = logging.getLogger("BitBake") | 36 | logger = logging.getLogger("BitBake") |
36 | collectlog = logging.getLogger("BitBake.Collection") | 37 | collectlog = logging.getLogger("BitBake.Collection") |
@@ -230,6 +231,8 @@ class BBCooker: | |||
230 | self.state = state.initial | 231 | self.state = state.initial |
231 | 232 | ||
232 | self.parser = None | 233 | self.parser = None |
234 | self.hashserv = None | ||
235 | self.hashservport = None | ||
233 | 236 | ||
234 | signal.signal(signal.SIGTERM, self.sigterm_exception) | 237 | signal.signal(signal.SIGTERM, self.sigterm_exception) |
235 | # Let SIGHUP exit as SIGTERM | 238 | # Let SIGHUP exit as SIGTERM |
@@ -368,6 +371,15 @@ class BBCooker: | |||
368 | 371 | ||
369 | self.data.setVar('BB_CMDLINE', self.ui_cmdline) | 372 | self.data.setVar('BB_CMDLINE', self.ui_cmdline) |
370 | 373 | ||
374 | if self.data.getVar("BB_HASHSERVE") == "localhost:0": | ||
375 | dbfile = (self.data.getVar("PERSISTENT_DIR") or self.data.getVar("CACHE")) + "/hashserv.db" | ||
376 | self.hashserv = hashserv.create_server(('localhost', 0), dbfile, '') | ||
377 | self.hashservport = "localhost:" + str(self.hashserv.server_port) | ||
378 | thread = threading.Thread(target=self.hashserv.serve_forever) | ||
379 | thread.daemon = True | ||
380 | thread.start() | ||
381 | self.data.setVar("BB_HASHSERVE", self.hashservport) | ||
382 | |||
371 | # | 383 | # |
372 | # Copy of the data store which has been expanded. | 384 | # Copy of the data store which has been expanded. |
373 | # Used for firing events and accessing variables where expansion needs to be accounted for | 385 | # Used for firing events and accessing variables where expansion needs to be accounted for |
@@ -1645,9 +1657,10 @@ class BBCooker: | |||
1645 | 1657 | ||
1646 | def post_serve(self): | 1658 | def post_serve(self): |
1647 | prserv.serv.auto_shutdown() | 1659 | prserv.serv.auto_shutdown() |
1660 | if self.hashserv: | ||
1661 | self.hashserv.shutdown() | ||
1648 | bb.event.fire(CookerExit(), self.data) | 1662 | bb.event.fire(CookerExit(), self.data) |
1649 | 1663 | ||
1650 | |||
1651 | def shutdown(self, force = False): | 1664 | def shutdown(self, force = False): |
1652 | if force: | 1665 | if force: |
1653 | self.state = state.forceshutdown | 1666 | self.state = state.forceshutdown |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 05c1200da1..82cc9af81b 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -1254,6 +1254,7 @@ class RunQueue: | |||
1254 | "buildname" : self.cfgData.getVar("BUILDNAME"), | 1254 | "buildname" : self.cfgData.getVar("BUILDNAME"), |
1255 | "date" : self.cfgData.getVar("DATE"), | 1255 | "date" : self.cfgData.getVar("DATE"), |
1256 | "time" : self.cfgData.getVar("TIME"), | 1256 | "time" : self.cfgData.getVar("TIME"), |
1257 | "hashservport" : self.cooker.hashservport, | ||
1257 | } | 1258 | } |
1258 | 1259 | ||
1259 | worker.stdin.write(b"<cookerconfig>" + pickle.dumps(self.cooker.configuration) + b"</cookerconfig>") | 1260 | worker.stdin.write(b"<cookerconfig>" + pickle.dumps(self.cooker.configuration) + b"</cookerconfig>") |