]> code.ossystems Code Review - openembedded-core.git/commitdiff
meta: add search, replace strings to export2json
authorbrian avery <brian.avery@intel.com>
Wed, 19 Apr 2017 19:49:02 +0000 (12:49 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 20 Apr 2017 06:54:58 +0000 (07:54 +0100)
We want to be able to save relative paths so that we can relocate the
deploy dir images and kernels, yet still have qemu and testimage work
correctly.  This extends export2json with 2 named arguments so a
search/replace operation can be done to remove the leading path.

[YOCTO #11375]

Signed-off-by: brian avery <brian.avery@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oe/data.py

index 80bba2b9d2451954dd11999593e152fbcd2566ef..b8901e63f526bc51f7a03611295319321c7b4c11 100644 (file)
@@ -17,7 +17,7 @@ def typed_value(key, d):
     except (TypeError, ValueError) as exc:
         bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
 
-def export2json(d, json_file, expand=True):
+def export2json(d, json_file, expand=True, searchString="",replaceString=""):
     data2export = {}
     keys2export = []
 
@@ -37,9 +37,11 @@ def export2json(d, json_file, expand=True):
 
     for key in keys2export:
         try:
-            data2export[key] = d.getVar(key, expand)
+            data2export[key] = d.getVar(key, expand).replace(searchString,replaceString)
         except bb.data_smart.ExpansionError:
             data2export[key] = ''
+        except AttributeError:
+            pass
 
     with open(json_file, "w") as f:
         json.dump(data2export, f, skipkeys=True, indent=4, sort_keys=True)