Skip to contentSkip to conversation

Tracking parsed configuration files

RFC PATCH In review Joshua Lock 2 participants 5 messages Jul 27, 2011

lore
Share & tools
lore
#0 lore raw

cover Tracking parsed configuration files

All,

This series attempts to address Yocto bug 1246: "Configuration changes could be saved to a file the cooker isn't using".

It's an ugly series and the issue will only present itself if users run the UI trough alternative ways. My main issue is that we can't easily track all loaded conf files at parseConfigurationFiles time so it feels a little brittle.

Thoughts? Comments?

Regards,
Joshua

Please review the following changes for suitability for inclusion. If you have any objections or suggestions for improvement, please respond to the patches. If you agree with the changes, please provide your Acked-by.

The following changes since commit 2650be190afc05f9472aca8b11af99205a342838:

ui/crumbs/tasklistmodel: fix loading a saved recipe (2011-07-26 09:42:28 -0700)

are available in the git repository at:
git://github.com/incandescant/bitbake configfiles
https://github.com/incandescant/bitbake/tree/configfiles

Joshua Lock (3):
cooker: track conf files parsed outside of the usual bitbake.conf
inclusion
cooker|event: notify if pre/post file in ConfigFilePathFound event ui/crumbs/[hobeventhandler|configurator]: don't use unparsed files

 lib/bb/cooker.py                    |   10 +++++++++-
 lib/bb/event.py                     |    3 ++-
 lib/bb/ui/crumbs/configurator.py    |    8 ++++----
 lib/bb/ui/crumbs/hobeventhandler.py |    6 ++++--
 4 files changed, 19 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.6
#1 lore raw

RFC PATCH 1/3 cooker: track conf files parsed outside of the usual bitbake.conf inclusion

Save a list of configuration files loaded pre and post parse of bitbake.conf

---
 lib/bb/cooker.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
lib/bb/cooker.py +3 -0
index 1f305d9..765c58d 100644
@@ -82,6 +82,7 @@ class BBCooker:
         self.status = None
         self.appendlist = {}
         self.skiplist = {}
+        self.extraconf = []
 
         self.server_registration_cb = server_registration_cb
 
@@ -741,6 +742,7 @@ class BBCooker:
         # Parse files for loading *before* bitbake.conf and any includes
         for f in prefiles:
             data = _parse(f, data)
+            self.extraconf.append(f)
 
         layerconf = self._findLayerConf()
         if layerconf:
@@ -766,6 +768,7 @@ class BBCooker:
         # Parse files for loading *after* bitbake.conf and any includes
         for p in postfiles:
             data = _parse(p, data)
+            self.extraconf.append(p)
 
         # Handle any INHERITs and inherit the base class
         bbclasses  = ["base"] + (data.getVar('INHERIT', True) or "").split()
Signature · 1 line
1.7.6
#2 lore raw

RFC PATCH 2/3 cooker|event: notify if pre/post file in ConfigFilePathFound event

In reply to Joshua Lock

When findConfigFilePath called the emitted ConfigFilePathFound event will also include a boolean value indiciating whether the specified config file was loaded using the prefile or postfile options to BitBake.

---
 lib/bb/cooker.py |    7 ++++++-
 lib/bb/event.py  |    3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)
lib/bb/cooker.py +6 -1
index 765c58d..f0c07b5 100644
@@ -605,9 +605,14 @@ class BBCooker:
                 collectlog.warn("No bb files matched BBFILE_PATTERN_%s '%s'" % (collection, pattern))
 
     def findConfigFilePath(self, configfile):
+        additional = False
         path = self._findConfigFile(configfile)
         if path:
-            bb.event.fire(bb.event.ConfigFilePathFound(path), self.configuration.data)
+            for path in self.extraconf:
+                _, cf, _ = path.rpartition(configfile)
+                if cf:
+                    additional = True
+            bb.event.fire(bb.event.ConfigFilePathFound(path, additional), self.configuration.data)
 
     def findFilesMatchingInDir(self, filepattern, directory):
         """
lib/bb/event.py +2 -1
index 93c04ba..01700dc 100644
@@ -412,9 +412,10 @@ class ConfigFilePathFound(Event):
     """
     Event when a path for a config file has been found
     """
-    def __init__(self, path):
+    def __init__(self, path, extraconf):
         Event.__init__(self)
         self._path = path
+        self._extraconf = extraconf
 
 class MsgBase(Event):
     """Base class for messages"""
Signature · 1 line
1.7.6
#3 lore raw

RFC PATCH 3/3 ui/crumbs/[hobeventhandler|configurator]: don't use unparsed files

In reply to Joshua Lock

Use the new field in the ConfigFilePathFound event to track whether the hob.local.conf file was parsed when BitBake was launched.

Fixes [YOCTO #1246]

---
 lib/bb/ui/crumbs/configurator.py    |    8 ++++----
 lib/bb/ui/crumbs/hobeventhandler.py |    6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)
lib/bb/ui/crumbs/configurator.py +4 -4
index ec48a4f..f5eae28 100644
@@ -115,9 +115,9 @@ class Configurator(gobject.GObject):
         self.enabled_layers = copy.deepcopy(self.loaded_layers)
         self.emit("layers-loaded")
 
-    def _addConfigFile(self, path):
+    def _addConfigFile(self, path, additional):
         pref, sep, filename = path.rpartition("/")
-        if filename == "local.conf" or filename == "hob.local.conf":
+        if filename == "local.conf" or (filename == "hob.local.conf" and additional):
             self._loadLocalConf(path)
         elif filename == "bblayers.conf":
             self._loadLayerConf(path)
@@ -293,8 +293,8 @@ class Configurator(gobject.GObject):
 
         self.emit("layers-changed")
 
-    def configFound(self, handler, path):
-        self._addConfigFile(path)
+    def configFound(self, handler, path, additional):
+        self._addConfigFile(path, additional)
 
     def loadConfig(self, path):
         self._addConfigFile(path)
lib/bb/ui/crumbs/hobeventhandler.py +4 -2
index 4897bcc..9cfa7c2 100644
@@ -42,7 +42,8 @@ class HobHandler(gobject.GObject):
                                   (gobject.TYPE_PYOBJECT,)),
          "config-found"        : (gobject.SIGNAL_RUN_LAST,
                                   gobject.TYPE_NONE,
-                                  (gobject.TYPE_STRING,)),
+                                  (gobject.TYPE_STRING,
+                                   gobject.TYPE_BOOLEAN)),
          "generating-data"     : (gobject.SIGNAL_RUN_LAST,
                                   gobject.TYPE_NONE,
                                   ()),
@@ -150,7 +151,8 @@ class HobHandler(gobject.GObject):
                 self.emit("sdk-machines-updated", sdk_machines)
         elif isinstance(event, bb.event.ConfigFilePathFound):
             path = event._path
-            self.emit("config-found", path)
+            extraconf = event._extraconf
+            self.emit("config-found", path, extraconf)
         elif isinstance(event, bb.event.FilesMatchingFound):
             # FIXME: hard coding, should at least be a variable shared between
             # here and the caller
Signature · 1 line
1.7.6
#4 lore raw
In reply to Joshua Lock
Quoted 11 lines · Joshua Lock

All,

This series attempts to address Yocto bug 1246: "Configuration changes could be saved to a file the cooker isn't using".

It's an ugly series and the issue will only present itself if users run the UI trough alternative ways. My main issue is that we can't easily track all loaded conf files at parseConfigurationFiles time so it feels a little brittle.

Thoughts? Comments?

Likely bitbake should be maintaining a list of files the given parsing process has included up to a given point. I believe we already have something along those lines and might just want to expose it...

Cheers,

Richard