Skip to contentSkip to conversation

[1.26][PATCH 0/2] A couple of backports from master

DISCUSSION Paul Eggleton 1 participant 3 messages May 22, 2015

lore
Share & tools
lore
#0 lore raw

Two patches backported from master: a fix for edit_metadata_file() (only used by bitbake-layers in 1.26) and an additional utility function.

The following changes since commit 8e0211d121e4cb1124dfe879db751ad00f5c978b:

bitbake-layers: ensure non-extended recipe name is preferred (2015-05-15 18:10:49 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib paule/bbfixes-1.26
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/bbfixes-1.26

Paul Eggleton (2):
lib/bb/utils: add function to get layer containing a file lib/bb/utils: fix several bugs in edit_metadata_file()

 lib/bb/utils.py | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

[1.26][PATCH 1/2] lib/bb/utils: add function to get layer containing a file

In certain contexts it can be useful to find the layer that a file (e.g. a recipe) appears in.

Implements [YOCTO #7723].

(Bitbake master rev: 3bf9c8830c5d5eea5502230d5af84ebd87ad5849)

---
 lib/bb/utils.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/bb/utils.py +16 -0
index c97f3ef..1681efd 100644
@@ -1097,3 +1097,19 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
 
     return (notadded, notremoved)
 
+
+def get_file_layer(filename, d):
+    """Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
+    collections = (d.getVar('BBFILE_COLLECTIONS', True) or '').split()
+    collection_res = {}
+    for collection in collections:
+        collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection, True) or ''
+
+    # Use longest path so we handle nested layers
+    matchlen = 0
+    match = None
+    for collection, regex in collection_res.iteritems():
+        if len(regex) > matchlen and re.match(regex, filename):
+            matchlen = len(regex)
+            match = collection
+    return match
Signature · 1 line
2.1.0
#2 lore raw

[1.26][PATCH 2/2] lib/bb/utils: fix several bugs in edit_metadata_file()

In reply to Paul Eggleton

* Fix unchanged assignments being dropped if other lines changed
* Fix not passing variable name from single-line assignments to the function
* Fix not trimming the trailing quote from values

(Bitbake master rev: 0b0c82f49cf2de887967d305768cbd95314bb171)

---
 lib/bb/utils.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
lib/bb/utils.py +11 -3
index 1681efd..0db7e56 100644
@@ -974,6 +974,7 @@ def edit_metadata_file(meta_file, variables, func):
 
     updated = False
     varset_start = ''
+    varlines = []
     newlines = []
     in_var = None
     full_value = ''
@@ -1001,14 +1002,19 @@ def edit_metadata_file(meta_file, variables, func):
             else:
                 newlines.append('%s "%s"\n' % (varset_start, newvalue))
             return True
-        return False
+        else:
+            # Put the old lines back where they were
+            newlines.extend(varlines)
+            return False
 
     with open(meta_file, 'r') as f:
         for line in f:
             if in_var:
                 value = line.rstrip()
+                varlines.append(line)
                 full_value += value[:-1]
                 if value.endswith('"') or value.endswith("'"):
+                    full_value = full_value[:-1]
                     if handle_var_end():
                         updated = True
                     in_var = None
@@ -1022,11 +1028,13 @@ def edit_metadata_file(meta_file, variables, func):
                         if value.endswith('\\'):
                             value = value[:-1]
                         full_value = value
+                        varlines = [line]
+                        in_var = varname
                         if value.endswith('"') or value.endswith("'"):
+                            full_value = full_value[:-1]
                             if handle_var_end():
                                 updated = True
-                        else:
-                            in_var = varname
+                            in_var = None
                         matched = True
                         break
                 if not matched:
Signature · 1 line
2.1.0