[OE-core] [PATCH] image-buildinfo: make the build file shell compatible

nick83ola nick83ola at gmail.com
Wed Jan 23 12:14:13 UTC 2019


this patch permit to simplify extracting build information from
the /etc/build file from a script, f ex shell or python.

Signed-off-by: Nicola Lunghi <nick83ola at gmail.com>
---
 meta/classes/image-buildinfo.bbclass | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/meta/classes/image-buildinfo.bbclass
b/meta/classes/image-buildinfo.bbclass
index 94c585d4cd..3ef6ad129d 100644
--- a/meta/classes/image-buildinfo.bbclass
+++ b/meta/classes/image-buildinfo.bbclass
@@ -23,7 +23,7 @@ def image_buildinfo_outputvars(vars, d):
         value = d.getVar(var) or ""
         if (d.getVarFlag(var, 'type') == "list"):
             value = oe.utils.squashspaces(value)
-        ret += "%s = %s\n" % (var, value)
+        ret += '%s="%s"\n' % (var, value)
     return ret.rstrip('\n')

 # Gets git branch's status (clean or dirty)
@@ -40,12 +40,12 @@ def get_layer_git_status(path):
         # Silently treat errors as "modified", without checking for the
         # (expected) return code 1 in a modified git repo. For example, we get
         # output and a 129 return code when a layer isn't a git repo at all.
-        return "-- modified"
+        return "modified"

 # Returns layer revisions along with their respective status
 def get_layer_revs(d):
     layers = (d.getVar("BBLAYERS") or "").split()
-    medadata_revs = ["%-17s = %s:%s %s" % (os.path.basename(i), \
+    medadata_revs = ['BBLAYERS_%s="%s:%s:%s"' % (os.path.basename(i), \
         base_get_metadata_git_branch(i, None).strip(), \
         base_get_metadata_git_revision(i, None), \
         get_layer_git_status(i)) \
@@ -66,19 +66,16 @@ python buildinfo () {
         return
     with open(d.expand('${IMAGE_ROOTFS}${IMAGE_BUILDINFO_FILE}'),
'w') as build:
         build.writelines((
-            '''-----------------------
-Build Configuration:  |
------------------------
-''',
+            '############################################################\n',
+            '# Build Configuration                                      #\n',
+            '############################################################\n',
             buildinfo_target(d),
-            '''
------------------------
-Layer Revisions:      |
------------------------
-''',
+            '\n\n',
+            '############################################################\n',
+            '# Layer Revisions                                          #\n',
+            '############################################################\n',
             get_layer_revs(d),
-            '''
-'''
+            '\n',
        ))
 }

-- 
2.19.1


More information about the Openembedded-core mailing list