* [PATCH 0/3] Tinfoil fixes
@ 2016-08-30 4:36 Paul Eggleton
2016-08-30 4:36 ` [PATCH 1/3] tinfoil: add context manager functions Paul Eggleton
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-08-30 4:36 UTC (permalink / raw)
To: bitbake-devel
Add context management and a parsing function, and ensure tinfoil using
utilities within the bitbake repo shut down tinfoil properly at the end.
The parsing function in particular is going to be needed to properly
fix the layer index update script that has been broken since the
multiconfig changes.
(This series borrows a few things from my tinfoil2 branch.)
The following changes since commit 0ed8975c42718342a104a9764a58816f964ec4ea:
fetch2: clean up remaining cwd saves/changes (2016-08-24 13:55:36 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib paule/tinfoil-fixes-bb
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/tinfoil-fixes-bb
Paul Eggleton (3):
tinfoil: add context manager functions
Ensure tinfoil is shut down correctly in utilities that use it
tinfoil: add a parse_recipe_file function
bin/bitbake-diffsigs | 6 +++---
bin/bitbake-layers | 53 +++++++++++++++++++++++++++-------------------------
lib/bb/tinfoil.py | 27 ++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 28 deletions(-)
--
2.5.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] tinfoil: add context manager functions
2016-08-30 4:36 [PATCH 0/3] Tinfoil fixes Paul Eggleton
@ 2016-08-30 4:36 ` Paul Eggleton
2016-08-30 4:36 ` [PATCH 2/3] Ensure tinfoil is shut down correctly in utilities that use it Paul Eggleton
2016-08-30 4:36 ` [PATCH 3/3] tinfoil: add a parse_recipe_file function Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-08-30 4:36 UTC (permalink / raw)
To: bitbake-devel
Since calling the shutdown() function is highly recommended, make
tinfoil objects a little easier to deal with by adding context manager
support - so you can do the following:
with bb.tinfoil.Tinfoil() as tinfoil:
tinfoil.prepare(True)
...
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/tinfoil.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 95608ae..441be2c 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -59,6 +59,12 @@ class Tinfoil:
def register_idle_function(self, function, data):
pass
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.shutdown()
+
def parseRecipes(self):
sys.stderr.write("Parsing recipes..")
self.logger.setLevel(logging.WARNING)
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] Ensure tinfoil is shut down correctly in utilities that use it
2016-08-30 4:36 [PATCH 0/3] Tinfoil fixes Paul Eggleton
2016-08-30 4:36 ` [PATCH 1/3] tinfoil: add context manager functions Paul Eggleton
@ 2016-08-30 4:36 ` Paul Eggleton
2016-08-30 4:36 ` [PATCH 3/3] tinfoil: add a parse_recipe_file function Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-08-30 4:36 UTC (permalink / raw)
To: bitbake-devel
We should always shut down tinfoil when we're finished with it, either
by explicitly calling the shutdown() method or by using it as a
context manager ("with ...").
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
bin/bitbake-diffsigs | 6 +++---
bin/bitbake-layers | 53 +++++++++++++++++++++++++++-------------------------
2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/bin/bitbake-diffsigs b/bin/bitbake-diffsigs
index 3b6ef88..527d2c7 100755
--- a/bin/bitbake-diffsigs
+++ b/bin/bitbake-diffsigs
@@ -115,9 +115,9 @@ parser.add_option("-t", "--task",
options, args = parser.parse_args(sys.argv)
if options.taskargs:
- tinfoil = bb.tinfoil.Tinfoil()
- tinfoil.prepare(config_only = True)
- find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1])
+ with bb.tinfoil.Tinfoil() as tinfoil:
+ tinfoil.prepare(config_only=True)
+ find_compare_task(tinfoil, options.taskargs[0], options.taskargs[1])
else:
if len(args) == 1:
parser.print_help()
diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index 0c973df..946def2 100755
--- a/bin/bitbake-layers
+++ b/bin/bitbake-layers
@@ -87,31 +87,34 @@ def main():
plugins = []
tinfoil = tinfoil_init(False)
- for path in ([topdir] +
- tinfoil.config_data.getVar('BBPATH', True).split(':')):
- pluginpath = os.path.join(path, 'lib', 'bblayers')
- bb.utils.load_plugins(logger, plugins, pluginpath)
-
- registered = False
- for plugin in plugins:
- if hasattr(plugin, 'register_commands'):
- registered = True
- plugin.register_commands(subparsers)
- if hasattr(plugin, 'tinfoil_init'):
- plugin.tinfoil_init(tinfoil)
-
- if not registered:
- logger.error("No commands registered - missing plugins?")
- sys.exit(1)
-
- args = parser.parse_args(unparsed_args, namespace=global_args)
-
- if getattr(args, 'parserecipes', False):
- tinfoil.config_data.disableTracking()
- tinfoil.parseRecipes()
- tinfoil.config_data.enableTracking()
-
- return args.func(args)
+ try:
+ for path in ([topdir] +
+ tinfoil.config_data.getVar('BBPATH', True).split(':')):
+ pluginpath = os.path.join(path, 'lib', 'bblayers')
+ bb.utils.load_plugins(logger, plugins, pluginpath)
+
+ registered = False
+ for plugin in plugins:
+ if hasattr(plugin, 'register_commands'):
+ registered = True
+ plugin.register_commands(subparsers)
+ if hasattr(plugin, 'tinfoil_init'):
+ plugin.tinfoil_init(tinfoil)
+
+ if not registered:
+ logger.error("No commands registered - missing plugins?")
+ sys.exit(1)
+
+ args = parser.parse_args(unparsed_args, namespace=global_args)
+
+ if getattr(args, 'parserecipes', False):
+ tinfoil.config_data.disableTracking()
+ tinfoil.parseRecipes()
+ tinfoil.config_data.enableTracking()
+
+ return args.func(args)
+ finally:
+ tinfoil.shutdown()
if __name__ == "__main__":
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] tinfoil: add a parse_recipe_file function
2016-08-30 4:36 [PATCH 0/3] Tinfoil fixes Paul Eggleton
2016-08-30 4:36 ` [PATCH 1/3] tinfoil: add context manager functions Paul Eggleton
2016-08-30 4:36 ` [PATCH 2/3] Ensure tinfoil is shut down correctly in utilities that use it Paul Eggleton
@ 2016-08-30 4:36 ` Paul Eggleton
2 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-08-30 4:36 UTC (permalink / raw)
To: bitbake-devel
Parsing a recipe is such a common task for tinfoil-using scripts, and is
a little awkward to do properly, so we should add an API function to do
it. This should also isolate scripts a little from future changes to the
internal code.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
lib/bb/tinfoil.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 441be2c..793565f 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -90,6 +90,27 @@ class Tinfoil:
else:
self.parseRecipes()
+ def parse_recipe_file(self, fn, appends=True, appendlist=None):
+ """
+ Parse the specified recipe file (with or without bbappends)
+ and return a datastore object representing the environment
+ for the recipe.
+ """
+ if appends and appendlist == []:
+ appends = False
+ parser = bb.cache.NoCache(self.cooker.databuilder)
+ if appends:
+ if appendlist:
+ appendfiles = appendlist
+ else:
+ if not hasattr(self.cooker, 'collection'):
+ raise Exception('You must call tinfoil.prepare() with config_only=False in order to get bbappends')
+ appendfiles = self.cooker.collection.get_file_appends(fn)
+ else:
+ appendfiles = None
+ envdata = parser.loadDataFull(fn, appendfiles)
+ return envdata
+
def shutdown(self):
self.cooker.shutdown(force=True)
self.cooker.post_serve()
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-30 4:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-30 4:36 [PATCH 0/3] Tinfoil fixes Paul Eggleton
2016-08-30 4:36 ` [PATCH 1/3] tinfoil: add context manager functions Paul Eggleton
2016-08-30 4:36 ` [PATCH 2/3] Ensure tinfoil is shut down correctly in utilities that use it Paul Eggleton
2016-08-30 4:36 ` [PATCH 3/3] tinfoil: add a parse_recipe_file function Paul Eggleton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.