[yocto] [layerindex-web][PATCH 5/5] update_layer.py: only call init_parser when needed

Robert Yang liezhi.yang at windriver.com
Tue Jan 2 21:42:26 PST 2018


The tinoil is not needed in cases like the layer is already up-to-date or the
layer is invalid, so only init it when needed.

This can save about 1min when run "update.py -b <branch>" (124 layers).

Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
---
 layerindex/update_layer.py | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index 329c30c..c012404 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -244,22 +244,8 @@ def main(options, queue):
             logger.info("Skipping update of layer %s - branch %s doesn't exist" % (layer.name, branchdesc))
         return (1, '')
 
-    try:
-        (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout, logger=logger)
-    except recipeparse.RecipeParseError as e:
-        logger.error(str(e))
-        return(1, '')
-    logger.debug('Using temp directory %s' % tempdir)
-    # Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set
-    tinfoil.config_data.setVar('SUMMARY', '')
-    # Clear the default value of DESCRIPTION so that we can see where it's not set
-    tinfoil.config_data.setVar('DESCRIPTION', '')
-    # Clear the default value of HOMEPAGE ('unknown')
-    tinfoil.config_data.setVar('HOMEPAGE', '')
-    # Set a blank value for LICENSE so that it doesn't cause the parser to die (e.g. with meta-ti -
-    # why won't they just fix that?!)
-    tinfoil.config_data.setVar('LICENSE', '')
-
+    tinfoil = None
+    tempdir = None
     try:
         with transaction.atomic():
             newbranch = False
@@ -323,6 +309,20 @@ def main(options, queue):
                     return (1, '')
 
                 logger.info("Collecting data for layer %s on branch %s" % (layer.name, branchdesc))
+                try:
+                    (tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout, logger=logger)
+                except recipeparse.RecipeParseError as e:
+                    logger.error(str(e))
+                    return(1, '')
+                # Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set
+                tinfoil.config_data.setVar('SUMMARY', '')
+                # Clear the default value of DESCRIPTION so that we can see where it's not set
+                tinfoil.config_data.setVar('DESCRIPTION', '')
+                # Clear the default value of HOMEPAGE ('unknown')
+                tinfoil.config_data.setVar('HOMEPAGE', '')
+                # Set a blank value for LICENSE so that it doesn't cause the parser to die (e.g. with meta-ti -
+                # why won't they just fix that?!)
+                tinfoil.config_data.setVar('LICENSE', '')
 
                 layerconfparser = layerconfparse.LayerConfParse(logger=logger, tinfoil=tinfoil)
                 layer_config_data = layerconfparser.parse_layer(layerdir)
@@ -687,12 +687,13 @@ def main(options, queue):
         import traceback
         traceback.print_exc()
     finally:
-        if LooseVersion(bb.__version__) > LooseVersion("1.27"):
+        if tinfoil and (LooseVersion(bb.__version__) > LooseVersion("1.27")):
             tinfoil.shutdown()
 
-    if options.keep_temp:
-        logger.debug('Preserving temp directory %s' % tempdir)
-    else:
-        logger.debug('Deleting temp directory')
-        shutil.rmtree(tempdir)
+    if tempdir:
+        if options.keep_temp:
+            logger.debug('Preserving temp directory %s' % tempdir)
+        else:
+            logger.debug('Deleting temp directory')
+            shutil.rmtree(tempdir)
     return(0, '')
-- 
2.7.4




More information about the yocto mailing list