Patchwork [bitbake-devel,14/16] command.py: add a new API findCoreBaseFiles

login
register
mail settings
Submitter Dongxiao Xu
Date Jan. 6, 2012, 9:02 a.m.
Message ID <efb093371394fc61e1a639c8e93b245d64058d72.1325840050.git.dongxiao.xu@intel.com>
Download mbox | patch
Permalink /patch/18629/
State Accepted
Commit c353316b2efcc7a893d6b4aa9a9647d51a6f69e3
Headers show

Comments

Dongxiao Xu - Jan. 6, 2012, 9:02 a.m.
This new API is to find the available layers in server side.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
---
 lib/bb/command.py |   11 +++++++++++
 lib/bb/cooker.py  |   12 ++++++++++++
 lib/bb/event.py   |    8 ++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)

Patch

diff --git a/lib/bb/command.py b/lib/bb/command.py
index e52041d..141b51e 100644
--- a/lib/bb/command.py
+++ b/lib/bb/command.py
@@ -245,6 +245,17 @@  class CommandsAsync:
         command.finishAsyncCommand()
     generateTargetsTree.needcache = True
 
+    def findCoreBaseFiles(self, command, params):
+        """
+        Find certain files in COREBASE directory. i.e. Layers
+        """
+        subdir = params[0]
+        filename = params[1]
+
+        command.cooker.findCoreBaseFiles(subdir, filename)
+        command.finishAsyncCommand()
+    findCoreBaseFiles.needcache = False
+
     def findConfigFiles(self, command, params):
         """
         Find config files which provide appropriate values
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index bfd61a9..b02fdd7 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -681,6 +681,18 @@  class BBCooker:
             if regex in unmatched:
                 collectlog.warn("No bb files matched BBFILE_PATTERN_%s '%s'" % (collection, pattern))
 
+    def findCoreBaseFiles(self, subdir, configfile):
+        corebase = self.configuration.data.getVar('COREBASE', True) or ""
+        paths = []
+        for root, dirs, files in os.walk(corebase + '/' + subdir):
+            for d in dirs:
+                configfilepath = os.path.join(root, d, configfile)
+                if os.path.exists(configfilepath):
+                    paths.append(os.path.join(root, d))
+
+        if paths:
+            bb.event.fire(bb.event.CoreBaseFilesFound(paths), self.configuration.data)
+
     def findConfigFilePath(self, configfile):
         """
         Find the location on disk of configfile and if it exists and was parsed by BitBake
diff --git a/lib/bb/event.py b/lib/bb/event.py
index d120ba5..ffd4213 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -439,6 +439,14 @@  class FilesMatchingFound(Event):
         self._pattern = pattern
         self._matches = matches
 
+class CoreBaseFilesFound(Event):
+    """
+    Event when a list of appropriate config files has been generated
+    """
+    def __init__(self, paths):
+        Event.__init__(self)
+        self._paths = paths
+
 class ConfigFilesFound(Event):
     """
     Event when a list of appropriate config files has been generated