Skip to contentSkip to conversation

Add reparseFile command and adopt the saved environment

PATCH Applied Joshua Lock 2 participants 6 messages Jul 25, 2011 – Jul 26, 2011

lore
Share & tools
lore
#0 lore raw

cover Add reparseFile command and adopt the saved environment

This series adapts the cooker to use the saved OS environment instead of the current os.environ and adds the reparseFiles command which triggered the changes.

The following changes since commit f0b5d16426b983a67c51c47f3542162108bd4156:

Update version to 1.13.3 (2011-07-25 13:50:38 +0100)

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

Joshua Lock (4):
data|cooker: use saved environment variables when calling
inheritFromOS
bitbake-layers: adapt to cooker change for saved environment command|cooker: Add reparseFiles command
cooker: only append files once

 bin/bitbake-layers |    7 ++++---
 lib/bb/command.py  |    8 ++++++++
 lib/bb/cooker.py   |   51 +++++++++++++++++++++++++++++++--------------------
 lib/bb/data.py     |    8 ++++----
 4 files changed, 47 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.6
#2 lore raw

PATCH 2/4 bitbake-layers: adapt to cooker change for saved environment

The Cooker requires a copy of the environment mapping, modify bitbake-layers to take one and pass it to the cooker.

---
 bin/bitbake-layers |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
bin/bitbake-layers +4 -3
index 3d563b5..d9f95d1 100755
@@ -8,7 +8,7 @@
 
 import cmd
 import logging
-import os.path
+import os
 import sys
 
 bindir = os.path.dirname(__file__)
@@ -41,11 +41,12 @@ def main(args):
 class Commands(cmd.Cmd):
     def __init__(self):
         cmd.Cmd.__init__(self)
-
+        initialenv = os.environ.copy()
         self.returncode = 0
         self.config = Config(parse_only=True)
         self.cooker = bb.cooker.BBCooker(self.config,
-                                         self.register_idle_function)
+                                         self.register_idle_function,
+                                         initialenv)
         self.config_data = self.cooker.configuration.data
         bb.providers.logger.setLevel(logging.ERROR)
         self.cooker_data = None
Signature · 1 line
1.7.6
#4 lore raw

PATCH 4/4 cooker: only append files once

In reply to Joshua Lock

A list can contain the same value twice, therefore only append to the appendlist for a recipe if the append file is not already in the list.

---
 lib/bb/cooker.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
lib/bb/cooker.py +2 -1
index 94e8d09..1f305d9 100644
@@ -1205,7 +1205,8 @@ class BBCooker:
             base = os.path.basename(f).replace('.bbappend', '.bb')
             if not base in self.appendlist:
                self.appendlist[base] = []
-            self.appendlist[base].append(f)
+            if f not in self.appendlist[base]:
+                self.appendlist[base].append(f)
 
         # Find overlayed recipes
         # bbfiles will be in priority order which makes this easy
Signature · 1 line
1.7.6
#3 lore raw

PATCH 3/4 command|cooker: Add reparseFiles command

In reply to Joshua Lock

Add command reparseFiles to reparse bb files in a running cooker instance.

Fixes [YOCTO #1249]

---
 lib/bb/command.py |    8 ++++++++
 lib/bb/cooker.py  |   48 +++++++++++++++++++++++++++++-------------------
 2 files changed, 37 insertions(+), 19 deletions(-)
lib/bb/command.py +8 -0
index a902da2..893a6d9 100644
@@ -311,6 +311,14 @@ class CommandsAsync:
         command.finishAsyncCommand()
     parseFiles.needcache = True
 
+    def reparseFiles(self, command, params):
+        """
+        Reparse .bb files
+        """
+        command.cooker.reparseFiles()
+        command.finishAsyncCommand()
+    reparseFiles.needcache = True
+
     def compareRevisions(self, command, params):
         """
         Parse the .bb files
lib/bb/cooker.py +29 -19

90 lines not on this page · raw message

Signature · 1 line
1.7.6
#1 lore raw

PATCH 1/4 data|cooker: use saved environment variables when calling inheritFromOS

In reply to Joshua Lock

Now that we have a pristine copy of the variables available at launch time we can use them when looking to inherit the OS's environment.

---
 lib/bb/cooker.py |    2 +-
 lib/bb/data.py   |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
lib/bb/cooker.py +1 -1
index d8535a7..1b5101d 100644
@@ -132,7 +132,7 @@ class BBCooker:
 
         self.configuration.data = bb.data.init()
 
-        bb.data.inheritFromOS(self.configuration.data)
+        bb.data.inheritFromOS(self.configuration.data, self.savedenv)
 
         try:
             self.parseConfigurationFiles(self.configuration.prefile,
lib/bb/data.py +4 -4
index 2269f9d..65144bf 100644
@@ -159,12 +159,12 @@ def expandKeys(alterdata, readdata = None):
         ekey = todolist[key]
         renameVar(key, ekey, alterdata)
 
-def inheritFromOS(d):
-    """Inherit variables from the environment."""
+def inheritFromOS(d, savedenv):
+    """Inherit variables from the initial environment."""
     exportlist = bb.utils.preserved_envvars_exported()
-    for s in os.environ.keys():
+    for s in savedenv.keys():
         try:
-            setVar(s, os.environ[s], d)
+            setVar(s, getVar(s, savedenv, True), d)
             if s in exportlist:
                 setVarFlag(s, "export", True, d)
         except TypeError:
Signature · 1 line
1.7.6
#5 lore raw
In reply to Joshua Lock
Quoted 12 lines · Joshua Lock

This series adapts the cooker to use the saved OS environment instead of the current os.environ and adds the reparseFiles command which triggered the changes.

The following changes since commit f0b5d16426b983a67c51c47f3542162108bd4156:

Update version to 1.13.3 (2011-07-25 13:50:38 +0100)

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

Quoted 6 lines

Joshua Lock (4):
data|cooker: use saved environment variables when calling
inheritFromOS
bitbake-layers: adapt to cooker change for saved environment command|cooker: Add reparseFiles command
cooker: only append files once

Merged to master, thanks.

Richard