summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/hashserv
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-04 11:21:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-04 12:12:45 +0000
commitf271a6773a4fb8cbf26acc3a050618cb81eda481 (patch)
treefeeaeb832df270f843cfed418f77293814ef3b75 /bitbake/lib/hashserv
parent8a3a1e4a350657050eb04564ce2c49db82af86e5 (diff)
downloadpoky-f271a6773a4fb8cbf26acc3a050618cb81eda481.tar.gz
bitbake: hashserv: Add support for equivalent hash reporting
The reason for this should be recorded in the commit logs. Imagine you have a target recipe (e.g. meta-extsdk-toolchain) which depends on gdb-cross. sstate in OE-Core allows gdb-cross to have the same hash regardless of whether its built on x86 or arm. The outhash will be different. We need hashequiv to be able to adapt to the prescence of sstate artefacts for meta-extsdk-toolchain and allow the hashes to re-intersect, rather than trying to force a rebuild of meta-extsdk-toolchain. By this point in the build, it would have already been installed from sstate so the build needs to adapt. Equivalent hashes should be reported to the server as a taskhash that needs to map to an specific unihash. This patch adds API to the hashserv client/server to allow this. [Thanks to Joshua Watt for help with this patch] (Bitbake rev: 674692fd46a7691a1de59ace6af0556cc5dd6a71) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv')
-rw-r--r--bitbake/lib/hashserv/client.py8
-rw-r--r--bitbake/lib/hashserv/server.py36
2 files changed, 44 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py
index f65956617b..ae0cce9df4 100644
--- a/bitbake/lib/hashserv/client.py
+++ b/bitbake/lib/hashserv/client.py
@@ -148,6 +148,14 @@ class Client(object):
148 m['unihash'] = unihash 148 m['unihash'] = unihash
149 return self.send_message({'report': m}) 149 return self.send_message({'report': m})
150 150
151 def report_unihash_equiv(self, taskhash, method, unihash, extra={}):
152 self._set_mode(self.MODE_NORMAL)
153 m = extra.copy()
154 m['taskhash'] = taskhash
155 m['method'] = method
156 m['unihash'] = unihash
157 return self.send_message({'report-equiv': m})
158
151 def get_stats(self): 159 def get_stats(self):
152 self._set_mode(self.MODE_NORMAL) 160 self._set_mode(self.MODE_NORMAL)
153 return self.send_message({'get-stats': None}) 161 return self.send_message({'get-stats': None})
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py
index 0aff77688e..cc7e48233b 100644
--- a/bitbake/lib/hashserv/server.py
+++ b/bitbake/lib/hashserv/server.py
@@ -143,6 +143,7 @@ class ServerClient(object):
143 handlers = { 143 handlers = {
144 'get': self.handle_get, 144 'get': self.handle_get,
145 'report': self.handle_report, 145 'report': self.handle_report,
146 'report-equiv': self.handle_equivreport,
146 'get-stream': self.handle_get_stream, 147 'get-stream': self.handle_get_stream,
147 'get-stats': self.handle_get_stats, 148 'get-stats': self.handle_get_stats,
148 'reset-stats': self.handle_reset_stats, 149 'reset-stats': self.handle_reset_stats,
@@ -303,6 +304,41 @@ class ServerClient(object):
303 304
304 self.write_message(d) 305 self.write_message(d)
305 306
307 async def handle_equivreport(self, data):
308 with closing(self.db.cursor()) as cursor:
309 insert_data = {
310 'method': data['method'],
311 'outhash': "",
312 'taskhash': data['taskhash'],
313 'unihash': data['unihash'],
314 'created': datetime.now()
315 }
316
317 for k in ('owner', 'PN', 'PV', 'PR', 'task', 'outhash_siginfo'):
318 if k in data:
319 insert_data[k] = data[k]
320
321 cursor.execute('''INSERT OR IGNORE INTO tasks_v2 (%s) VALUES (%s)''' % (
322 ', '.join(sorted(insert_data.keys())),
323 ', '.join(':' + k for k in sorted(insert_data.keys()))),
324 insert_data)
325
326 self.db.commit()
327
328 # Fetch the unihash that will be reported for the taskhash. If the
329 # unihash matches, it means this row was inserted (or the mapping
330 # was already valid)
331 row = self.query_equivalent(data['method'], data['taskhash'])
332
333 if row['unihash'] == data['unihash']:
334 logger.info('Adding taskhash equivalence for %s with unihash %s',
335 data['taskhash'], row['unihash'])
336
337 d = {k: row[k] for k in ('taskhash', 'method', 'unihash')}
338
339 self.write_message(d)
340
341
306 async def handle_get_stats(self, request): 342 async def handle_get_stats(self, request):
307 d = { 343 d = {
308 'requests': self.request_stats.todict(), 344 'requests': self.request_stats.todict(),