Tinfoil rework
cover Tinfoil rework
Tinfoil is an API that allows you to write simple utilities that call into BitBake code to read variables, parse recipes, etc. (as used by various scripts in BitBake & OE, including bitbake-layers, devtool, etc.) This patchset reworks tinfoil in order to address several limitations of the current implementation, first and foremost that it doesn't currently work in bitbake's memory resident mode. This rework is also known as "tinfoil2" although the classes and modules have not changed name. Fixes for a few other related issues I found along the way are also included. There is an additional set of patches for OE-Core that make corresponding changes there - both sets should be applied together in order for things to remain working.
Note that whilst these patchsets make some significant improvements to how the system behaves in memory resident mode, there are still a number of issues that prevent memory resident mode from being reliable. See this wiki page for a few more details:
https://wiki.yoctoproject.org/wiki/index.php?title=Tinfoil2
I will be converting some of these into bugzilla entries after this patchset and the corresponding one for OE-Core get merged.
The following changes since commit b65a8193368ffa1d15af24a6acde8dce6bd4d383:
toaster: views Remove old code that converts template context to JSON (2016-12-12 20:44:47 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib paule/tinfoil2-bb
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/tinfoil2-bb
Paul Eggleton (15):
data_smart: fix resetting of reference on variablehistory
knotty: make quiet option a level option
knotty: fix --observe-only option
server/xmlrpc: send back 503 response with correct encoding
data_smart: implement remote datastore functionality
command: provide a means to shut down from the client in memres mode
tinfoil: rewrite as a wrapper around the UI
remotedata: enable transporting datastore from the client to the server
tinfoil: implement server-side recipe parsing
tinfoil: pass datastore to server when expanding python references
cooker: allow buildFile warning to be hidden programmatically
data_smart: support serialisation
runqueue: enable setVariable command to affect task execution
siggen: add means of ignoring basehash mismatch server/process: don't change UI process signal handler on terminate
bin/bitbake-worker | 12 +- lib/bb/command.py | 253 ++++++++++++++++++++++++++- lib/bb/cooker.py | 36 +++- lib/bb/cookerdata.py | 1 + lib/bb/data_smart.py | 54 +++++- lib/bb/main.py | 87 ++++++---- lib/bb/remotedata.py | 116 +++++++++++++ lib/bb/runqueue.py | 1 + lib/bb/server/process.py | 1 - lib/bb/server/xmlrpc.py | 2 +- lib/bb/siggen.py | 3 +- lib/bb/tests/data.py | 68 ++++++++ lib/bb/tinfoil.py | 439 +++++++++++++++++++++++++++++++++++++++-------- lib/bb/ui/knotty.py | 45 +++-- lib/bblayers/query.py | 28 +-- 15 files changed, 982 insertions(+), 164 deletions(-) create mode 100644 lib/bb/remotedata.py
Signature · 1 line
2.5.5
PATCH 1/15 data_smart: fix resetting of reference on variablehistory
There is no "datasmart" member, only dataroot. This dates back to the original implementation of variable history support - it's surprising we haven't noticed the issue until now, but I guess it's rare to change a copy of a datastore in a manner which using the old reference would cause an issue.
--- lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data_smart.py +1 -1
@@ -844,7 +844,7 @@ class DataSmart(MutableMapping): data = DataSmart() data.dict["_data"] = self.dict data.varhistory = self.varhistory.copy() - data.varhistory.datasmart = data + data.varhistory.dataroot = data data.inchistory = self.inchistory.copy() data._tracking = self._tracking
Signature · 1 line
2.5.5
PATCH 2/15 knotty: make quiet option a level option
In reply to Paul EggletonAllow you to specify -q / --quiet more than once to reduce the messages even further. It will now operate as follows:
Level Option Result ----- ------ ---------------------------------------- 0 Print usual output 1 -q Only show progress and warnings or above 2 -qq Only show warnings or above 3+ -qqq Only show errors
--- lib/bb/main.py | 4 ++-- lib/bb/ui/knotty.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-)
lib/bb/main.py +2 -2
@@ -179,8 +179,8 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters): parser.add_option("-D", "--debug", action="count", dest="debug", default=0, help="Increase the debug level. You can specify this more than once.") - parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, - help="Output less log message data to the terminal.") + parser.add_option("-q", "--quiet", action="count", dest="quiet", default=0, + help="Output less log message data to the terminal. You can specify this more than once.") parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False, help="Don't execute, just go through the motions.")
lib/bb/ui/knotty.py +28 -7
@@ -284,7 +284,7 @@ class TerminalFilter(object): content = self.main_progress.update(progress) print('') lines = 1 + int(len(content) / (self.columns + 1)) - if not self.quiet: + if self.quiet == 0: for tasknum, task in enumerate(tasks[:(self.rows - 2)]): if isinstance(task, tuple): pbar, progress, rate, start_time = task
@@ -353,10 +353,13 @@ def main(server, eventHandler, params, tf = TerminalFilter): errconsole = logging.StreamHandler(sys.stderr) format_str = "%(levelname)s: %(message)s" format = bb.msg.BBLogFormatter(format_str) - if params.options.quiet: - bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, bb.msg.BBLogFormatter.WARNING) + if params.options.quiet == 0: + forcelevel = None + elif params.options.quiet > 2: + forcelevel = bb.msg.BBLogFormatter.ERROR else: - bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut) + forcelevel = bb.msg.BBLogFormatter.WARNING + bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, forcelevel) bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr) console.setFormatter(format) errconsole.setFormatter(format)
@@ -506,35 +509,47 @@ def main(server, eventHandler, params, tf = TerminalFilter): logger.info(event._message) continue if isinstance(event, bb.event.ParseStarted): + if params.options.quiet > 1: + continue if event.total == 0: continue parseprogress = new_progress("Parsing recipes", event.total).start() continue if isinstance(event, bb.event.ParseProgress): + if params.options.quiet > 1: + continue if parseprogress: parseprogress.update(event.current) else: bb.warn("Got ParseProgress event for parsing that never started?") continue if isinstance(event, bb.event.ParseCompleted): + if params.options.quiet > 1: + continue if not parseprogress: continue parseprogress.finish() pasreprogress = None - if not params.options.quiet: + if params.options.quiet == 0: print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) continue if isinstance(event, bb.event.CacheLoadStarted): + if params.options.quiet > 1: + continue cacheprogress = new_progress("Loading cache", event.total).start() continue if isinstance(event, bb.event.CacheLoadProgress): + if params.options.quiet > 1: + continue cacheprogress.update(event.current) continue if isinstance(event, bb.event.CacheLoadCompleted): + if params.options.quiet > 1: + continue cacheprogress.finish() - if not params.options.quiet: + if params.options.quiet == 0: print("Loaded %d entries from dependency cache." % event.num_entries) continue
@@ -620,16 +635,22 @@ def main(server, eventHandler, params, tf = TerminalFilter): continue if isinstance(event, bb.event.ProcessStarted): + if params.options.quiet > 1: + continue parseprogress = new_progress(event.processname, event.total) parseprogress.start(False) continue if isinstance(event, bb.event.ProcessProgress): + if params.options.quiet > 1: + continue if parseprogress: parseprogress.update(event.progress) else: bb.warn("Got ProcessProgress event for someting that never started?") continue if isinstance(event, bb.event.ProcessFinished): + if params.options.quiet > 1: + continue if parseprogress: parseprogress.finish() parseprogress = None
@@ -701,7 +722,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): if return_value and errors: summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) - if summary and not params.options.quiet: + if summary and params.options.quiet == 0: print(summary) if interrupted:
Signature · 1 line
2.5.5
PATCH 3/15 knotty: fix --observe-only option
In reply to Paul EggletonIf we're in observe-only mode then we cannot run commands that would affect the server's state, including getSetVariable, so prevent that from being called in observe-only mode.
--- lib/bb/ui/knotty.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
lib/bb/ui/knotty.py +7 -3
@@ -312,7 +312,7 @@ class TerminalFilter(object): fd = sys.stdin.fileno() self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) -def _log_settings_from_server(server): +def _log_settings_from_server(server, observe_only): # Get values of variables which control our output includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) if error:
@@ -322,7 +322,11 @@ def _log_settings_from_server(server): if error: logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error) raise BaseException(error) - consolelogfile, error = server.runCommand(["getSetVariable", "BB_CONSOLELOG"]) + if observe_only: + cmd = 'getVariable' + else: + cmd = 'getSetVariable' + consolelogfile, error = server.runCommand([cmd, "BB_CONSOLELOG"]) if error: logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error) raise BaseException(error)
@@ -340,7 +344,7 @@ _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.Lo def main(server, eventHandler, params, tf = TerminalFilter): - includelogs, loglines, consolelogfile = _log_settings_from_server(server) + includelogs, loglines, consolelogfile = _log_settings_from_server(server, params.observe_only) if sys.stdin.isatty() and sys.stdout.isatty(): log_exec_tty = True
Signature · 1 line
2.5.5
PATCH 4/15 server/xmlrpc: send back 503 response with correct encoding
In reply to Paul EggletonIf you send back a string here you get "TypeError: 'str' does not support the buffer interface" errors in bitbake-cookerdaemon.log and "IncompleteRead(0 bytes read, 22 more expected)" errors on the client side.
--- lib/bb/server/xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/server/xmlrpc.py +1 -1
@@ -190,7 +190,7 @@ class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): self.send_header("Content-type", "text/plain") self.send_header("Content-length", str(len(response))) self.end_headers() - self.wfile.write(response) + self.wfile.write(bytes(response, 'utf-8')) class XMLRPCProxyServer(BaseImplServer):
Signature · 1 line
2.5.5
PATCH 5/15 data_smart: implement remote datastore functionality
In reply to Paul EggletonThis allows you to maintain a local reference to a remote datastore. The actual implementation of the remote connection is delegated to a connector object that the caller must define and supply. There is support for getting variable values and expanding python references (i.e. ${@...} remotely, however setting variables remotely is not supported - any variable setting is done locally as if the datastore were a copy (which it kind of is).
Loosely based on an earlier prototype implementation by Qing He.
--- lib/bb/data_smart.py | 39 +++++++++++++++++++++++++++++++++------ lib/bb/tests/data.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-)
lib/bb/data_smart.py +33 -6
@@ -116,7 +116,15 @@ class VariableParse: return match.group() def python_sub(self, match): - code = match.group()[3:-1] + if isinstance(match, str): + code = match + else: + code = match.group()[3:-1] + + if "_remote_data" in self.d: + connector = self.d["_remote_data"] + return connector.expandPythonRef(self.varname, code) + codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") parser = bb.codeparser.PythonParser(self.varname, logger)
@@ -247,10 +255,15 @@ class VariableHistory(object): self.variables[var].append(loginfo.copy()) def variable(self, var): - if var in self.variables: - return self.variables[var] + remote_connector = self.dataroot.getVar('_remote_data', False) + if remote_connector: + varhistory = remote_connector.getVarHistory(var) else: - return [] + varhistory = [] + + if var in self.variables: + varhistory.extend(self.variables[var]) + return varhistory def emit(self, var, oval, val, o, d): history = self.variable(var)
@@ -449,6 +462,10 @@ class DataSmart(MutableMapping): if var in dest: return dest[var] + if "_remote_data" in dest: + connector = dest["_remote_data"]["_content"] + return connector.getVar(var) + if "_data" not in dest: break dest = dest["_data"]
@@ -471,6 +488,12 @@ class DataSmart(MutableMapping): if 'parsing' in loginfo: parsing=True + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.setVar(var, value) + if not res: + return + if 'op' not in loginfo: loginfo['op'] = "set" self.expand_cache = {}
@@ -875,7 +898,7 @@ class DataSmart(MutableMapping): def localkeys(self): for key in self.dict: - if key != '_data': + if key not in ['_data', '_remote_data']: yield key def __iter__(self):
@@ -884,7 +907,7 @@ class DataSmart(MutableMapping): def keylist(d): klist = set() for key in d: - if key == "_data": + if key in ["_data", "_remote_data"]: continue if key in deleted: continue
@@ -898,6 +921,10 @@ class DataSmart(MutableMapping): if "_data" in d: klist |= keylist(d["_data"]) + if "_remote_data" in d: + connector = d["_remote_data"]["_content"] + klist |= connector.getKeys() + return klist self.need_overrides()
lib/bb/tests/data.py +39 -0
@@ -444,3 +444,42 @@ class Contains(unittest.TestCase): self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x", True, False, self.d)) self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) + + +class Remote(unittest.TestCase): + def test_remote(self): + class TestConnector: + d = None + def __init__(self, d): + self.d = d + def getVar(self, name): + return self.d._findVar(name) + def getKeys(self): + return self.d.localkeys() + def getVarHistory(self, name): + return self.d.varhistory.variable(name) + def expandPythonRef(self, varname, expr): + varparse = bb.data_smart.VariableParse(varname, self.d) + return varparse.python_sub(expr) + def setVar(self, name, value): + self.d.setVar(name, value) + + d1 = bb.data.init() + d1.enableTracking() + d2 = bb.data.init() + d2.enableTracking() + connector = TestConnector(d1) + + d2.setVar('_remote_data', connector) + + d1.setVar('HELLO', 'world') + d1.setVarFlag('OTHER', 'flagname', 'flagvalue') + self.assertEqual(d2.getVar('HELLO'), 'world') + self.assertEqual(d2.expand('${HELLO}'), 'world') + self.assertEqual(d2.expand('${@d.getVar("HELLO")}'), 'world') + self.assertIn('flagname', d2.getVarFlags('OTHER')) + self.assertEqual(d2.getVarFlag('OTHER', 'flagname'), 'flagvalue') + self.assertEqual(d1.varhistory.variable('HELLO'), d2.varhistory.variable('HELLO')) + # Test setVar on client side affects server + d2.setVar('HELLO', 'other-world') + self.assertEqual(d1.getVar('HELLO'), 'other-world')
Signature · 1 line
2.5.5
PATCH 6/15 command: provide a means to shut down from the client in memres mode
In reply to Paul EggletonIn memory resident mode we don't really want to actually shut down since it's only the client going away.
--- lib/bb/command.py | 8 ++++++++ lib/bb/cooker.py | 7 +++++++ lib/bb/cookerdata.py | 1 + 3 files changed, 16 insertions(+)
lib/bb/command.py +8 -0
@@ -472,3 +472,11 @@ class CommandsAsync: command.finishAsyncCommand() resetCooker.needcache = False + def clientComplete(self, command, params): + """ + Do the right thing when the controlling client exits + """ + command.cooker.clientComplete() + command.finishAsyncCommand() + clientComplete.needcache = False +
lib/bb/cooker.py +7 -0
@@ -1725,6 +1725,13 @@ class BBCooker: def reset(self): self.initConfigurationData() + def clientComplete(self): + """Called when the client is done using the server""" + if self.configuration.server_only: + self.finishcommand() + else: + self.shutdown(True) + def lockBitbake(self): if not hasattr(self, 'lock'): self.lock = None
lib/bb/cookerdata.py +1 -0
@@ -146,6 +146,7 @@ class CookerConfiguration(object): self.tracking = False self.interface = [] self.writeeventlog = False + self.server_only = False self.env = {}
Signature · 1 line
2.5.5
PATCH 7/15 tinfoil: rewrite as a wrapper around the UI
In reply to Paul EggletonRewrite tinfoil as a wrapper around the UI, instead of the earlier approach of starting up just enough of cooker to do what we want. This has several advantages:
* It now works when bitbake is memory-resident instead of failing with "ERROR: Only one copy of bitbake should be run against a build directory".
* We can now connect an actual UI, thus you get things like the recipe parsing / cache loading progress bar and parse error handling for free
* We can now handle events generated by the server if we wish to do so
* We can potentially extend this to do more stuff, e.g. actually running build operations - this needs to be made more practical before we can use it though (since you effectively have to become the UI yourself for this at the moment.)
The downside is that tinfoil no longer has direct access to cooker, the global datastore, or the cache. To mitigate this I have extended data_smart to provide remote access capability for the datastore, and created "fake" cooker and cooker.recipecache / cooker.collection adapter objects in order to avoid breaking too many tinfoil-using scripts that might be out there (we've never officially documented tinfoil or BitBake's internal code, but we can still make accommodations where practical). I've at least gone far enough to support all of the utilities that use tinfoil in OE-Core with some changes, but I know there are scripts such as Chris Larson's "bb" out there that do make other calls into BitBake code that I'm not currently providing access to through the adapters.
Part of the fix for [YOCTO #5470].
--- lib/bb/command.py | 195 +++++++++++++++++++++++++ lib/bb/cooker.py | 19 ++- lib/bb/main.py | 83 ++++++----- lib/bb/remotedata.py | 74 ++++++++++ lib/bb/tinfoil.py | 385 ++++++++++++++++++++++++++++++++++++++++++-------- lib/bblayers/query.py | 28 +--- 6 files changed, 665 insertions(+), 119 deletions(-) create mode 100644 lib/bb/remotedata.py
lib/bb/command.py +195 -0
@@ -28,8 +28,15 @@ and must not trigger events, directly or indirectly. Commands are queued in a CommandQueue """ +from collections import OrderedDict, defaultdict + import bb.event import bb.cooker +import bb.remotedata + +class DataStoreConnectionHandle(object): + def __init__(self, dsindex=0): + self.dsindex = dsindex class CommandCompleted(bb.event.Event): pass
@@ -55,6 +62,7 @@ class Command: self.cooker = cooker self.cmds_sync = CommandsSync() self.cmds_async = CommandsAsync() + self.remotedatastores = bb.remotedata.RemoteDatastores(cooker) # FIXME Add lock for this self.currentAsyncCommand = None
@@ -298,6 +306,193 @@ class CommandsSync: command.cooker.updateConfigOpts(options, environment) updateConfig.needconfig = False + def parseConfiguration(self, command, params): + """Instruct bitbake to parse its configuration + NOTE: it is only necessary to call this if you aren't calling any normal action + (otherwise parsing is taken care of automatically) + """ + command.cooker.parseConfiguration() + parseConfiguration.needconfig = False + + def getLayerPriorities(self, command, params): + ret = [] + # regex objects cannot be marshalled by xmlrpc + for collection, pattern, regex, pri in command.cooker.bbfile_config_priorities: + ret.append((collection, pattern, regex.pattern, pri)) + return ret + getLayerPriorities.readonly = True + + def getRecipes(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return list(command.cooker.recipecaches[mc].pkg_pn.items()) + getRecipes.readonly = True + + def getRecipeDepends(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return list(command.cooker.recipecaches[mc].deps.items()) + getRecipeDepends.readonly = True + + def getRecipeVersions(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return command.cooker.recipecaches[mc].pkg_pepvpr + getRecipeVersions.readonly = True + + def getRuntimeDepends(self, command, params): + ret = [] + try: + mc = params[0] + except IndexError: + mc = '' + rundeps = command.cooker.recipecaches[mc].rundeps + for key, value in rundeps.items(): + if isinstance(value, defaultdict): + value = dict(value) + ret.append((key, value)) + return ret + getRuntimeDepends.readonly = True + + def getRuntimeRecommends(self, command, params): + ret = [] + try: + mc = params[0] + except IndexError: + mc = '' + runrecs = command.cooker.recipecaches[mc].runrecs + for key, value in runrecs.items(): + if isinstance(value, defaultdict): + value = dict(value) + ret.append((key, value)) + return ret + getRuntimeRecommends.readonly = True + + def getRecipeInherits(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return command.cooker.recipecaches[mc].inherits + getRecipeInherits.readonly = True + + def getBbFilePriority(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return command.cooker.recipecaches[mc].bbfile_priority + getBbFilePriority.readonly = True + + def getDefaultPreference(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return command.cooker.recipecaches[mc].pkg_dp + getDefaultPreference.readonly = True + + def getSkippedRecipes(self, command, params): + # Return list sorted by reverse priority order + import bb.cache + skipdict = OrderedDict(sorted(command.cooker.skiplist.items(), + key=lambda x: (-command.cooker.collection.calc_bbfile_priority(bb.cache.virtualfn2realfn(x[0])[0]), x[0]))) + return list(skipdict.items()) + getSkippedRecipes.readonly = True + + def getOverlayedRecipes(self, command, params): + return list(command.cooker.collection.overlayed.items()) + getOverlayedRecipes.readonly = True + + def getFileAppends(self, command, params): + fn = params[0] + return command.cooker.collection.get_file_appends(fn) + getFileAppends.readonly = True + + def getAllAppends(self, command, params): + return command.cooker.collection.bbappends + getAllAppends.readonly = True + + def findProviders(self, command, params): + return command.cooker.findProviders() + findProviders.readonly = True + + def findBestProvider(self, command, params): + pn = params[0] + return command.cooker.findBestProvider(pn) + findBestProvider.readonly = True + + def allProviders(self, command, params): + try: + mc = params[0] + except IndexError: + mc = '' + return list(bb.providers.allProviders(command.cooker.recipecaches[mc]).items()) + allProviders.readonly = True + + def getRuntimeProviders(self, command, params): + rprovide = params[0] + try: + mc = params[1] + except IndexError: + mc = '' + all_p = bb.providers.getRuntimeProviders(command.cooker.recipecaches[mc], rprovide) + if all_p: + best = bb.providers.filterProvidersRunTime(all_p, rprovide, + command.cooker.data, + command.cooker.recipecaches[mc])[0][0] + else: + best = None + return all_p, best + getRuntimeProviders.readonly = True + + def dataStoreConnectorFindVar(self, command, params): + dsindex = params[0] + name = params[1] + datastore = command.remotedatastores[dsindex] + value = datastore._findVar(name) + + if value: + content = value.get('_content', None) + if isinstance(content, bb.data_smart.DataSmart): + # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully + idx = command.remotedatastores.check_store(content, True) + return {'_content': DataStoreConnectionHandle(idx), '_connector_origtype': 'DataStoreConnectionHandle'} + elif isinstance(content, set): + return {'_content': list(content), '_connector_origtype': 'set'} + return value + dataStoreConnectorFindVar.readonly = True + + def dataStoreConnectorGetKeys(self, command, params): + dsindex = params[0] + datastore = command.remotedatastores[dsindex] + return list(datastore.keys()) + dataStoreConnectorGetKeys.readonly = True + + def dataStoreConnectorGetVarHistory(self, command, params): + dsindex = params[0] + name = params[1] + datastore = command.remotedatastores[dsindex] + return datastore.varhistory.variable(name) + dataStoreConnectorGetVarHistory.readonly = True + + def dataStoreConnectorExpandPythonRef(self, command, params): + dsindex = params[0] + varname = params[1] + expr = params[2] + if dsindex: + datastore = self.dataStores[dsindex] + else: + datastore = command.cooker.data + varparse = bb.data_smart.VariableParse(varname, datastore) + return varparse.python_sub(expr) + class CommandsAsync: """ A class of asynchronous commands
lib/bb/cooker.py +16 -3
@@ -583,13 +583,12 @@ class BBCooker: def showVersions(self): - pkg_pn = self.recipecaches[''].pkg_pn - (latest_versions, preferred_versions) = bb.providers.findProviders(self.data, self.recipecaches[''], pkg_pn) + (latest_versions, preferred_versions) = self.findProviders() logger.plain("%-35s %25s %25s", "Recipe Name", "Latest Version", "Preferred Version") logger.plain("%-35s %25s %25s\n", "===========", "==============", "=================") - for p in sorted(pkg_pn): + for p in sorted(self.recipecaches[''].pkg_pn): pref = preferred_versions[p] latest = latest_versions[p]
@@ -1084,6 +1083,20 @@ class BBCooker: if matches: bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data) + def findProviders(self, mc=''): + return bb.providers.findProviders(self.data, self.recipecaches[mc], self.recipecaches[mc].pkg_pn) + + def findBestProvider(self, pn, mc=''): + if pn in self.recipecaches[mc].providers: + filenames = self.recipecaches[mc].providers[pn] + eligible, foundUnique = bb.providers.filterProviders(filenames, pn, self.expanded_data, self.recipecaches[mc]) + filename = eligible[0] + return None, None, None, filename + elif pn in self.recipecaches[mc].pkg_pn: + return bb.providers.findBestProvider(pn, self.data, self.recipecaches[mc], self.recipecaches[mc].pkg_pn) + else: + return None, None, None, None + def findConfigFiles(self, varname): """ Find config files which are appropriate values for varname.
lib/bb/main.py +49 -34
129 lines not on this page · raw message
lib/bb/remotedata.py new file +74 -0
74 lines not on this page · raw message
lib/bb/tinfoil.py +325 -60
430 lines not on this page · raw message
lib/bblayers/query.py +6 -22
@@ -5,8 +5,6 @@ import sys import os import re -import bb.cache -import bb.providers import bb.utils from bblayers.common import LayerPlugin
@@ -122,15 +120,13 @@ skipped recipes will also be listed, with a " (skipped)" suffix. sys.exit(1) pkg_pn = self.tinfoil.cooker.recipecaches[''].pkg_pn - (latest_versions, preferred_versions) = bb.providers.findProviders(self.tinfoil.config_data, self.tinfoil.cooker.recipecaches[''], pkg_pn) - allproviders = bb.providers.allProviders(self.tinfoil.cooker.recipecaches['']) + (latest_versions, preferred_versions) = self.tinfoil.find_providers() + allproviders = self.tinfoil.get_all_providers() # Ensure we list skipped recipes # We are largely guessing about PN, PV and the preferred version here, # but we have no choice since skipped recipes are not fully parsed skiplist = list(self.tinfoil.cooker.skiplist.keys()) - skiplist.sort( key=lambda fileitem: self.tinfoil.cooker.collection.calc_bbfile_priority(fileitem) ) - skiplist.reverse() for fn in skiplist: recipe_parts = os.path.splitext(os.path.basename(fn))[0].split('_') p = recipe_parts[0]
@@ -265,10 +261,7 @@ Lists recipes with the bbappends that apply to them as subitems. def show_appends_for_pn(self, pn): filenames = self.tinfoil.cooker_data.pkg_pn[pn] - best = bb.providers.findBestProvider(pn, - self.tinfoil.config_data, - self.tinfoil.cooker_data, - self.tinfoil.cooker_data.pkg_pn) + best = self.tinfoil.find_best_provider(pn) best_filename = os.path.basename(best[3]) return self.show_appends_output(filenames, best_filename)
@@ -336,10 +329,7 @@ NOTE: .bbappend files can impact the dependencies. deps = self.tinfoil.cooker_data.deps[f] for pn in deps: if pn in self.tinfoil.cooker_data.pkg_pn: - best = bb.providers.findBestProvider(pn, - self.tinfoil.config_data, - self.tinfoil.cooker_data, - self.tinfoil.cooker_data.pkg_pn) + best = self.tinfoil.find_best_provider(pn) self.check_cross_depends("DEPENDS", layername, f, best[3], args.filenames, ignore_layers) # The RDPENDS
@@ -352,14 +342,11 @@ NOTE: .bbappend files can impact the dependencies. sorted_rdeps[k2] = 1 all_rdeps = sorted_rdeps.keys() for rdep in all_rdeps: - all_p = bb.providers.getRuntimeProviders(self.tinfoil.cooker_data, rdep) + all_p, best = self.tinfoil.get_runtime_providers(rdep) if all_p: if f in all_p: # The recipe provides this one itself, ignore continue - best = bb.providers.filterProvidersRunTime(all_p, rdep, - self.tinfoil.config_data, - self.tinfoil.cooker_data)[0][0] self.check_cross_depends("RDEPENDS", layername, f, best, args.filenames, ignore_layers) # The RRECOMMENDS
@@ -372,14 +359,11 @@ NOTE: .bbappend files can impact the dependencies. sorted_rrecs[k2] = 1 all_rrecs = sorted_rrecs.keys() for rrec in all_rrecs: - all_p = bb.providers.getRuntimeProviders(self.tinfoil.cooker_data, rrec) + all_p, best = self.tinfoil.get_runtime_providers(rrec) if all_p: if f in all_p: # The recipe provides this one itself, ignore continue - best = bb.providers.filterProvidersRunTime(all_p, rrec, - self.tinfoil.config_data, - self.tinfoil.cooker_data)[0][0] self.check_cross_depends("RRECOMMENDS", layername, f, best, args.filenames, ignore_layers) # The inherit class
Signature · 1 line
2.5.5
PATCH 8/15 remotedata: enable transporting datastore from the client to the server
In reply to Paul EggletonFor the purposes of server-side parsing and expansion allowing for client-side use of the datastore, we need a means of sending a datastore from the client back to the server, where the datastore probably consists of a remote (server-side) original plus some client-side modifications. To do this we need to take care of a couple of things:
1) xmlrpc can't handle nested dicts, so if you enable memres and simply try passing a serialised datastore then things break. Instead of serialising the entire datastore, just take the naive option of transferring the internal dict alone (as a list of tuples) for now.
2) Change the TinfoilDataStoreConnector object into simply the handle (number) when transmitting; it gets substituted with the real datastore when the server receives it.
--- lib/bb/remotedata.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
lib/bb/remotedata.py +42 -0
@@ -72,3 +72,45 @@ class RemoteDatastores: if idx in self.locked: raise Exception('Tried to release locked datastore %d' % idx) del self.datastores[idx] + + def receive_datastore(self, remote_data): + """Receive a datastore object sent from the client (as prepared by transmit_datastore())""" + dct = dict(remote_data) + d = bb.data_smart.DataSmart() + d.dict = dct + while True: + if '_remote_data' in dct: + dsindex = dct['_remote_data']['_content'] + del dct['_remote_data'] + if dsindex is None: + dct['_data'] = self.cooker.data.dict + else: + dct['_data'] = self.datastores[dsindex].dict + break + elif '_data' in dct: + idct = dict(dct['_data']) + dct['_data'] = idct + dct = idct + else: + break + return d + + @staticmethod + def transmit_datastore(d): + """Prepare a datastore object for sending over IPC from the client end""" + # FIXME content might be a dict, need to turn that into a list as well + def copy_dicts(dct): + if '_remote_data' in dct: + dsindex = dct['_remote_data']['_content'].dsindex + newdct = dct.copy() + newdct['_remote_data'] = {'_content': dsindex} + return list(newdct.items()) + elif '_data' in dct: + newdct = dct.copy() + newdata = copy_dicts(dct['_data']) + if newdata: + newdct['_data'] = newdata + return list(newdct.items()) + return None + main_dict = copy_dicts(d.dict) + return main_dict
Signature · 1 line
2.5.5
PATCH 9/15 tinfoil: implement server-side recipe parsing
In reply to Paul EggletonIt's not really practical for us to parse recipes on the client side, we need to do it on the server because that's where we have the full python environment (including any "pure" python functions defined in classes). Thus, add some functions to tinfoil do this including a few shortcut functions.
--- lib/bb/command.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/bb/tinfoil.py | 54 +++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 81 insertions(+), 17 deletions(-)
lib/bb/command.py +44 -0
@@ -493,6 +493,50 @@ class CommandsSync: varparse = bb.data_smart.VariableParse(varname, datastore) return varparse.python_sub(expr) + def dataStoreConnectorRelease(self, command, params): + dsindex = params[0] + if dsindex <= 0: + raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex) + command.remotedatastores.release(dsindex) + + def parseRecipeFile(self, command, params): + """ + Parse the specified recipe file (with or without bbappends) + and return a datastore object representing the environment + for the recipe. + """ + fn = params[0] + appends = params[1] + appendlist = params[2] + if len(params) > 3: + config_data_dict = params[3] + config_data = command.remotedatastores.receive_datastore(config_data_dict) + else: + config_data = None + + if appends: + if appendlist is not None: + appendfiles = appendlist + else: + appendfiles = command.cooker.collection.get_file_appends(fn) + else: + appendfiles = [] + # We are calling bb.cache locally here rather than on the server, + # but that's OK because it doesn't actually need anything from + # the server barring the global datastore (which we have a remote + # version of) + if config_data: + # We have to use a different function here if we're passing in a datastore + # NOTE: we took a copy above, so we don't do it here again + envdata = bb.cache.parse_recipe(config_data, fn, appendfiles)[''] + else: + # Use the standard path + parser = bb.cache.NoCache(command.cooker.databuilder) + envdata = parser.loadDataFull(fn, appendfiles) + idx = command.remotedatastores.store(envdata) + return DataStoreConnectionHandle(idx) + parseRecipeFile.readonly = True + class CommandsAsync: """ A class of asynchronous commands
lib/bb/tinfoil.py +37 -17
80 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH 10/15 tinfoil: pass datastore to server when expanding python references
In reply to Paul EggletonIf you're expanding a value that refers to the value of a variable in python code, we need to ensure that the datastore that gets used to get the value of that variable is the client-side datastore and not just the part of it that's on the server side. For example, suppose you are in client code doing the following:
d.setVar('HELLO', 'there')
result = d.expand('${@d.getVar("HELLO", True)}')
result should be "there" but if the client part wasn't taken into account, it would be whatever value HELLO had in the server portion of the datastore (if any).
--- lib/bb/command.py | 11 +++++------ lib/bb/data_smart.py | 2 +- lib/bb/tests/data.py | 10 ++++++++-- lib/bb/tinfoil.py | 6 ++++-- 4 files changed, 18 insertions(+), 11 deletions(-)
lib/bb/command.py +5 -6
@@ -483,14 +483,13 @@ class CommandsSync: dataStoreConnectorGetVarHistory.readonly = True def dataStoreConnectorExpandPythonRef(self, command, params): - dsindex = params[0] + config_data_dict = params[0] varname = params[1] expr = params[2] - if dsindex: - datastore = self.dataStores[dsindex] - else: - datastore = command.cooker.data - varparse = bb.data_smart.VariableParse(varname, datastore) + + config_data = command.remotedatastores.receive_datastore(config_data_dict) + + varparse = bb.data_smart.VariableParse(varname, config_data) return varparse.python_sub(expr) def dataStoreConnectorRelease(self, command, params):
lib/bb/data_smart.py +1 -1
@@ -123,7 +123,7 @@ class VariableParse: if "_remote_data" in self.d: connector = self.d["_remote_data"] - return connector.expandPythonRef(self.varname, code) + return connector.expandPythonRef(self.varname, code, self.d) codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
lib/bb/tests/data.py +8 -2
@@ -458,8 +458,11 @@ class Remote(unittest.TestCase): return self.d.localkeys() def getVarHistory(self, name): return self.d.varhistory.variable(name) - def expandPythonRef(self, varname, expr): - varparse = bb.data_smart.VariableParse(varname, self.d) + def expandPythonRef(self, varname, expr, d): + localdata = self.d.createCopy() + for key in d.localkeys(): + localdata.setVar(d.getVar(key)) + varparse = bb.data_smart.VariableParse(varname, localdata) return varparse.python_sub(expr) def setVar(self, name, value): self.d.setVar(name, value)
@@ -483,3 +486,6 @@ class Remote(unittest.TestCase): # Test setVar on client side affects server d2.setVar('HELLO', 'other-world') self.assertEqual(d1.getVar('HELLO'), 'other-world') + # Test client side data is incorporated in python expansion (which is done on server) + d2.setVar('FOO', 'bar') + self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar')
lib/bb/tinfoil.py +4 -2
@@ -29,6 +29,7 @@ import bb.providers import bb.taskdata import bb.utils import bb.command +import bb.remotedata from bb.cookerdata import CookerConfiguration, ConfigParameters from bb.main import setup_bitbake, BitBakeConfigParameters, BBMainException import bb.fetch2
@@ -69,8 +70,9 @@ class TinfoilDataStoreConnector: return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex)) def getVarHistory(self, name): return self.tinfoil.run_command('dataStoreConnectorGetVarHistory', self.dsindex, name) - def expandPythonRef(self, varname, expr): - ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', self.dsindex, varname, expr) + def expandPythonRef(self, varname, expr, d): + ds = bb.remotedata.RemoteDatastores.transmit_datastore(d) + ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', ds, varname, expr) return ret def setVar(self, varname, value): if self.dsindex is None:
Signature · 1 line
2.5.5
PATCH 11/15 cooker: allow buildFile warning to be hidden programmatically
In reply to Paul EggletonIf we want to use this function/command internally, we don't want this warning shown.
--- lib/bb/command.py | 6 +++++- lib/bb/cooker.py | 9 +++++---- lib/bb/tinfoil.py | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-)
lib/bb/command.py +5 -1
@@ -549,8 +549,12 @@ class CommandsAsync: """ bfile = params[0] task = params[1] + if len(params) > 2: + hidewarning = params[2] + else: + hidewarning = False - command.cooker.buildFile(bfile, task) + command.cooker.buildFile(bfile, task, hidewarning) buildFile.needcache = False def buildTargets(self, command, params):
lib/bb/cooker.py +5 -4
@@ -1334,15 +1334,16 @@ class BBCooker: raise NoSpecificMatch return matches[0] - def buildFile(self, buildfile, task): + def buildFile(self, buildfile, task, hidewarning=False): """ Build the file matching regexp buildfile """ bb.event.fire(bb.event.BuildInit(), self.expanded_data) - # Too many people use -b because they think it's how you normally - # specify a target to be built, so show a warning - bb.warn("Buildfile specified, dependencies will not be handled. If this is not what you want, do not use -b / --buildfile.") + if not hidewarning: + # Too many people use -b because they think it's how you normally + # specify a target to be built, so show a warning + bb.warn("Buildfile specified, dependencies will not be handled. If this is not what you want, do not use -b / --buildfile.") # Parse the configuration here. We need to do it explicitly here since # buildFile() doesn't use the cache
lib/bb/tinfoil.py +2 -2
@@ -366,9 +366,9 @@ class Tinfoil: def build_file(self, buildfile, task): """ Runs the specified task for just a single recipe (i.e. no dependencies). - This is equivalent to bitbake -b. + This is equivalent to bitbake -b, except no warning will be printed. """ - return self.run_command('buildFile', buildfile, task) + return self.run_command('buildFile', buildfile, task, True) def shutdown(self): if self.server_connection:
Signature · 1 line
2.5.5
PATCH 12/15 data_smart: support serialisation
In reply to Paul EggletonThe COW object used within VariableHistory can't be serialised itself, but we can convert it to a dict when serializing and then back when deserialising. This finally allows DataSmart objects to be serialized.
NOTE: "serialisation" here means pickling, not over XMLRPC or any other transport.
--- lib/bb/data_smart.py | 13 +++++++++++++ lib/bb/tests/data.py | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+)
lib/bb/data_smart.py +13 -0
@@ -230,6 +230,19 @@ class VariableHistory(object): new.variables = self.variables.copy() return new + def __getstate__(self): + vardict = {} + for k, v in self.variables.iteritems(): + vardict[k] = v + return {'dataroot': self.dataroot, + 'variables': vardict} + + def __setstate__(self, state): + self.dataroot = state['dataroot'] + self.variables = COWDictBase.copy() + for k, v in state['variables'].items(): + self.variables[k] = v + def record(self, *kwonly, **loginfo): if not self.dataroot._tracking: return
lib/bb/tests/data.py +23 -0
@@ -446,6 +446,29 @@ class Contains(unittest.TestCase): self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) +class Serialize(unittest.TestCase): + + def test_serialize(self): + import tempfile + import pickle + d = bb.data.init() + d.enableTracking() + d.setVar('HELLO', 'world') + d.setVarFlag('HELLO', 'other', 'planet') + with tempfile.NamedTemporaryFile(delete=False) as tmpfile: + tmpfilename = tmpfile.name + pickle.dump(d, tmpfile) + + with open(tmpfilename, 'rb') as f: + newd = pickle.load(f) + + os.remove(tmpfilename) + + self.assertEqual(d, newd) + self.assertEqual(newd.getVar('HELLO', True), 'world') + self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet') + + class Remote(unittest.TestCase): def test_remote(self): class TestConnector:
Signature · 1 line
2.5.5
PATCH 13/15 runqueue: enable setVariable command to affect task execution
In reply to Paul EggletonAllow the client to set variables with the setVariable command and have those changes take effect when running tasks. This is accomplished by collecting changes made by setVariable separately and pass these to the worker so it can be applied on top of the datastore it creates.
--- bin/bitbake-worker | 12 ++++++++++-- lib/bb/command.py | 1 + lib/bb/cooker.py | 1 + lib/bb/runqueue.py | 1 + 4 files changed, 13 insertions(+), 2 deletions(-)
bin/bitbake-worker +10 -2
@@ -136,7 +136,7 @@ def sigterm_handler(signum, frame): os.killpg(0, signal.SIGTERM) sys.exit() -def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, appends, taskdepdata, quieterrors=False): +def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, appends, taskdepdata, extraconfigdata, quieterrors=False): # We need to setup the environment BEFORE the fork, since # a fork() or exec*() activates PSEUDO...
@@ -223,6 +223,9 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append the_data.setVar("BUILDNAME", workerdata["buildname"]) the_data.setVar("DATE", workerdata["date"]) the_data.setVar("TIME", workerdata["time"]) + for varname, value in extraconfigdata.items(): + the_data.setVar(varname, value) + bb.parse.siggen.set_taskdata(workerdata["sigdata"]) ret = 0
@@ -329,6 +332,7 @@ class BitbakeWorker(object): self.cookercfg = None self.databuilder = None self.data = None + self.extraconfigdata = None self.build_pids = {} self.build_pipes = {}
@@ -363,6 +367,7 @@ class BitbakeWorker(object): pass if len(self.queue): self.handle_item(b"cookerconfig", self.handle_cookercfg) + self.handle_item(b"extraconfigdata", self.handle_extraconfigdata) self.handle_item(b"workerdata", self.handle_workerdata) self.handle_item(b"runtask", self.handle_runtask) self.handle_item(b"finishnow", self.handle_finishnow)
@@ -391,6 +396,9 @@ class BitbakeWorker(object): self.databuilder.parseBaseConfiguration() self.data = self.databuilder.data + def handle_extraconfigdata(self, data): + self.extraconfigdata = pickle.loads(data) + def handle_workerdata(self, data): self.workerdata = pickle.loads(data) bb.msg.loggerDefaultDebugLevel = self.workerdata["logdefaultdebug"]
@@ -416,7 +424,7 @@ class BitbakeWorker(object): fn, task, taskname, quieterrors, appends, taskdepdata = pickle.loads(data) workerlog_write("Handling runtask %s %s %s\n" % (task, fn, taskname)) - pid, pipein, pipeout = fork_off_task(self.cookercfg, self.data, self.databuilder, self.workerdata, fn, task, taskname, appends, taskdepdata, quieterrors) + pid, pipein, pipeout = fork_off_task(self.cookercfg, self.data, self.databuilder, self.workerdata, fn, task, taskname, appends, taskdepdata, self.extraconfigdata, quieterrors) self.build_pids[pid] = task self.build_pipes[pid] = runQueueWorkerPipe(pipein, pipeout)
lib/bb/command.py +1 -0
@@ -187,6 +187,7 @@ class CommandsSync: """ varname = params[0] value = str(params[1]) + command.cooker.extraconfigdata[varname] = value command.cooker.data.setVar(varname, value) def getSetVariable(self, command, params):
lib/bb/cooker.py +1 -0
@@ -358,6 +358,7 @@ class BBCooker: self.databuilder.parseBaseConfiguration() self.data = self.databuilder.data self.data_hash = self.databuilder.data_hash + self.extraconfigdata = {} if consolelog: self.data.setVar("BB_CONSOLELOG", consolelog)
lib/bb/runqueue.py +1 -0
@@ -1036,6 +1036,7 @@ class RunQueue: } worker.stdin.write(b"<cookerconfig>" + pickle.dumps(self.cooker.configuration) + b"</cookerconfig>") + worker.stdin.write(b"<extraconfigdata>" + pickle.dumps(self.cooker.extraconfigdata) + b"</extraconfigdata>") worker.stdin.write(b"<workerdata>" + pickle.dumps(workerdata) + b"</workerdata>") worker.stdin.flush()
Signature · 1 line
2.5.5
PATCH 14/15 siggen: add means of ignoring basehash mismatch
In reply to Paul EggletonIf you run the setVariable command to set variables then you end up causing the basehash to not match the previously computed values, which triggers error messages. These mismatches are expected, so add a means of disabling them.
--- lib/bb/siggen.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/siggen.py +2 -1
@@ -101,6 +101,7 @@ class SignatureGeneratorBasic(SignatureGenerator): def _build_data(self, fn, d): + ignore_mismatch = ((d.getVar("BB_HASH_IGNORE_MISMATCH", True) or '') == '1') tasklist, gendeps, lookupcache = bb.data.generate_dependencies(d) taskdeps = {}
@@ -135,7 +136,7 @@ class SignatureGeneratorBasic(SignatureGenerator): data = data + str(var) datahash = hashlib.md5(data.encode("utf-8")).hexdigest() k = fn + "." + task - if k in self.basehash and self.basehash[k] != datahash: + if not ignore_mismatch and k in self.basehash and self.basehash[k] != datahash: bb.error("When reparsing %s, the basehash value changed from %s to %s. The metadata is not deterministic and this needs to be fixed." % (k, self.basehash[k], datahash)) self.basehash[k] = datahash taskdeps[task] = alldeps
Signature · 1 line
2.5.5
PATCH 15/15 server/process: don't change UI process signal handler on terminate
In reply to Paul EggletonOn terminating the connection to the server, we were disabling SIGINT - and this is executed on the UI side. I'm not sure whether the intention here was to undo the SIGINT disabling we did in the server, and it was just a mistake that it disabled rather than restored and it's run on the wrong side, or whether we wanted to stop the user from breaking out of the shutdown code - the commit message provides no clues either way. Regardless, we do not want to permanently disable Ctrl+C here - it's legitimate to terminate the connection to the server and then re-establish it within the same process; at least currently, devtool modify by virtue of using tinfoil in two separate parts of the code does this, and the result of this disabling is that during the second tinfoil usage we can potentially be parsing all recipes without the ability to easily interrupt the process.
--- lib/bb/server/process.py | 1 - 1 file changed, 1 deletion(-)
lib/bb/server/process.py +0 -1
@@ -224,7 +224,6 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection): if isinstance(event, logging.LogRecord): logger.handle(event) - signal.signal(signal.SIGINT, signal.SIG_IGN) self.procserver.stop() while self.procserver.is_alive():
Signature · 1 line
2.5.5
Re: [PATCH 02/15] knotty: make quiet option a level option
In reply to Paul EggletonQuoted 10 lines · Paul Eggleton
Allow you to specify -q / --quiet more than once to reduce the messages
even further. It will now operate as follows:Level Option Result
----- ------ ---------------------------------------- 0 Print usual output
1 -q Only show progress and warnings or above 2 -qq Only show warnings or above
3+ -qqq Only show errors
I like this change, can we document the levels somewhere other than the commit message?
Thanks,
Joshua
Quoted 162 lines
Signed-off-by Paul Eggleton <[email protected]>---
lib/bb/main.py | 4 ++--
lib/bb/ui/knotty.py | 35 ++++++++++++++++++++++++++++-------2 files changed, 30 insertions(+), 9 deletions(-)lib/bb/main.py +0
-0@@ -179,8 +179,8 @@ classBitBakeConfigParameters(cookerdata.ConfigParameters):
parser.add_option("-D", "--debug", action="count", dest="debug", default=0,
help="Increase the debug level. You can specify this more than once.")
- parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
- help="Output less log message data to the terminal.")
+ parser.add_option("-q", "--quiet", action="count", dest="quiet", default=0,
+ help="Output less log message data to the terminal. You can specify this more than once.")
parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False,
help="Don't execute, just go through the motions.")lib/bb/ui/knotty.py +1
-1@@ -284,7 +284,7 @@ class TerminalFilter(object): content = self.main_progress.update(progress) print('') lines = 1 + int(len(content) / (self.columns + 1)) - if not self.quiet: + if self.quiet == 0:for tasknum, task in
enumerate(tasks[:(self.rows - 2)]):
ifisinstance(task, tuple):
pbar, progress, rate,start_time= tasklib/bb/ui/knotty.py +0
-0@@ -353,10 +353,13 @@ def main(server, eventHandler, params, tf =TerminalFilter):
errconsole =logging.StreamHandler(sys.stderr)format_str= "%(levelname)s: %(message)s"
format =bb.msg.BBLogFormatter(format_str)
- if params.options.quiet:
- bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, bb.msg.BBLogFormatter.WARNING)
+ if params.options.quiet == 0:
+ forcelevel = None
+ elif params.options.quiet > 2:
+ forcelevel = bb.msg.BBLogFormatter.ERROR
else:
- bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
+ forcelevel = bb.msg.BBLogFormatter.WARNING
+ bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, forcelevel)
bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)console.setFormatter(format)errconsole.setFormatter(format)lib/bb/ui/knotty.py +0
-0@@ -506,35 +509,47 @@ def main(server, eventHandler, params, tf =TerminalFilter):
logger.info(event._message)
continue
ifisinstance(event, bb.event.ParseStarted):
+ if params.options.quiet > 1:
+ continue
if event.total == 0:
continue
parseprogress =new_progress("Parsing recipes", event.total).start()
continue
ifisinstance(event, bb.event.ParseProgress):
+ if params.options.quiet > 1:
+ continue
if parseprogress:
parseprogress.update(event.current) else:
bb.warn("Got ParseProgress event for parsing that never started?")
continue
ifisinstance(event, bb.event.ParseCompleted):
+ if params.options.quiet > 1:
+ continue
if not parseprogress:
continue
parseprogress.finish()
pasreprogress = None
- if not params.options.quiet:
+ if params.options.quiet == 0:
print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) continue
ifisinstance(event, bb.event.CacheLoadStarted):
+ if params.options.quiet > 1:
+ continue
cacheprogress =new_progress("Loading cache", event.total).start()
continue
ifisinstance(event, bb.event.CacheLoadProgress):
+ if params.options.quiet > 1:
+ continuecacheprogress.update(event.current)continue
ifisinstance(event, bb.event.CacheLoadCompleted):
+ if params.options.quiet > 1:
+ continue
cacheprogress.finish()
- if not params.options.quiet:
+ if params.options.quiet == 0:
print("Loaded %d entries from dependency cache." % event.num_entries)
continuelib/bb/ui/knotty.py +0
-0@@ -620,16 +635,22 @@ def main(server, eventHandler, params, tf =TerminalFilter):
continue
ifisinstance(event, bb.event.ProcessStarted):
+ if params.options.quiet > 1:
+ continue
parseprogress =new_progress(event.processname, event.total)
parseprogress.start(False)
continue
ifisinstance(event, bb.event.ProcessProgress):
+ if params.options.quiet > 1:
+ continue
if parseprogress:
parseprogress.update(event.progress) else:
bb.warn("Got ProcessProgress event for someting that never started?")
continue
ifisinstance(event, bb.event.ProcessFinished):
+ if params.options.quiet > 1:
+ continue
if parseprogress:
parseprogress.finish()
parseprogress = Nonelib/bb/ui/knotty.py +0
-0@@ -701,7 +722,7 @@ def main(server, eventHandler, params, tf =TerminalFilter):
ifreturn_valueand errors:
summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) - if summary and not params.options.quiet:
+ if summary and params.options.quiet == 0:
print(summary)
if interrupted:
--
2.5.5