[gnome-continuous-yocto/gnomeostree-3.28-rocko: 3677/8267] devtool: Load plugins in a well defined order



commit 14abe7982c94ec44737866f89274d80b03ffb08c
Author: Ola x Nilsson <ola x nilsson axis com>
Date:   Tue Oct 25 13:03:34 2016 +0200

    devtool: Load plugins in a well defined order
    
    To allow devtool plugins in one layer to shadow another in a well
    defined way, first search BBPATH/lib/devtool directories and then
    scripts/lib/devool and load only the first found.
    
    The previous search and load loop would load all found plugins with the
    ones found later replacing any found before.
    
    (From OE-Core rev: 1b2b8a0a80de17ea053002fdd124055d2798029a)
    
    Signed-off-by: Ola x Nilsson <ola x nilsson axis com>
    Signed-off-by: Ross Burton <ross burton intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 scripts/devtool            |    3 ++-
 scripts/lib/scriptutils.py |    8 ++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/scripts/devtool b/scripts/devtool
index 0c32c50..2197493 100755
--- a/scripts/devtool
+++ b/scripts/devtool
@@ -294,7 +294,8 @@ def main():
         finally:
             tinfoil.shutdown()
 
-    for path in [scripts_path] + global_args.bbpath.split(':'):
+    # Search BBPATH first to allow layers to override plugins in scripts_path
+    for path in global_args.bbpath.split(':') + [scripts_path]:
         pluginpath = os.path.join(path, 'lib', 'devtool')
         scriptutils.load_plugins(logger, plugins, pluginpath)
 
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 5ccc027..27d82b6 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -52,10 +52,14 @@ def load_plugins(logger, plugins, pluginpath):
             if fp:
                 fp.close()
 
+    def plugin_name(filename):
+        return os.path.splitext(os.path.basename(filename))[0]
+
+    known_plugins = [plugin_name(p.__name__) for p in plugins]
     logger.debug('Loading plugins from %s...' % pluginpath)
     for fn in glob.glob(os.path.join(pluginpath, '*.py')):
-        name = os.path.splitext(os.path.basename(fn))[0]
-        if name != '__init__':
+        name = plugin_name(fn)
+        if name != '__init__' and name not in known_plugins:
             plugin = load_plugin(name)
             if hasattr(plugin, 'plugin_init'):
                 plugin.plugin_init(plugins)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]