Skip to contentSkip to conversation

image-buildinfo: drop more verbose build configuration

PATCH In review Andreas Müller 2 participants 3 messages Sep 28, 2018 – Nov 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image-buildinfo: drop more verbose build configuration

* before DISTRO and DISTRO_VERSION were written only - this is not enough to get a complete picture in which environmet an image was build. Now same information as displayed on console is written.
* code fragment was based on bass.bbclass

---

I know timing is not the best - we are already feature freezed. But I think it is an enhancement worth to have an exception...

 meta/classes/image-buildinfo.bbclass | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
meta/classes/image-buildinfo.bbclass +12 -16
index 213fb9cf9b..fbb3188040 100644
@@ -15,18 +15,6 @@ IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION"
 # Desired location of the output file in the image.
 IMAGE_BUILDINFO_FILE ??= "${sysconfdir}/build"
 
-# From buildhistory.bbclass
-def image_buildinfo_outputvars(vars, listvars, d): 
-    vars = vars.split()
-    listvars = listvars.split()
-    ret = ""
-    for var in vars:
-        value = d.getVar(var) or ""
-        if (d.getVarFlag(var, 'type') == "list"):
-            value = oe.utils.squashspaces(value)
-        ret += "%s = %s\n" % (var, value)
-    return ret.rstrip('\n')
-
 # Gets git branch's status (clean or dirty)
 def get_layer_git_status(path):
     import subprocess
@@ -57,10 +45,18 @@ def buildinfo_target(d):
         # Get context
         if d.getVar('BB_WORKERCONTEXT') != '1':
                 return ""
-        # Single and list variables to be read
-        vars = (d.getVar("IMAGE_BUILDINFO_VARS") or "")
-        listvars = (d.getVar("IMAGE_BUILDINFO_LVARS") or "")
-        return image_buildinfo_outputvars(vars, listvars, d)
+        # taken from base.bbclass
+        localdata = bb.data.createCopy(d)
+        statuslines = []
+        g = globals()
+        func = 'buildcfg_vars'
+        if func not in g:
+            bb.warn("Build configuration function '%s' does not exist" % func)
+        else:
+            flines = g[func](localdata)
+            if flines:
+                statuslines.extend(flines)
+        return ('\n%s\n' % '\n'.join(statuslines))
 
 # Write build information to target filesystem
 python buildinfo () {
Signature · 1 line
2.14.4
#1 lore raw
Quoted 7 lines · Andreas Müller

* before DISTRO and DISTRO_VERSION were written only - this is not enough to
get a complete picture in which environmet an image was build. Now
same
information as displayed on console is written.
* code fragment was based on bass.bbclass

Quoted 5 lines

---

I know timing is not the best - we are already feature freezed. But I think it is an enhancement worth to have an exception...

It sounds good from the commit message but anyone IMAGE_BUILDINFO_VARS or IMAGE_BUILDINFO_LVARS is going to find a significant change in behaviour? At the point past feature freeze I'm not sure we can do that...

Cheers,

Richard

Quoted 55 lines
 meta/classes/image-buildinfo.bbclass | 28 ++++++++++++------------
----
 1 file changed, 12 insertions(+), 16 deletions(-)
meta/classes/image-buildinfo.bbclass +12 -16
index 213fb9cf9b..fbb3188040 100644
@@ -15,18 +15,6 @@ IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION"
 # Desired location of the output file in the image.
 IMAGE_BUILDINFO_FILE ??= "${sysconfdir}/build"
 
-# From buildhistory.bbclass
-def image_buildinfo_outputvars(vars, listvars, d): 
-    vars = vars.split()
-    listvars = listvars.split()
-    ret = ""
-    for var in vars:
-        value = d.getVar(var) or ""
-        if (d.getVarFlag(var, 'type') == "list"):
-            value = oe.utils.squashspaces(value)
-        ret += "%s = %s\n" % (var, value)
-    return ret.rstrip('\n')
-
 # Gets git branch's status (clean or dirty)
 def get_layer_git_status(path):
     import subprocess
@@ -57,10 +45,18 @@ def buildinfo_target(d):
         # Get context
         if d.getVar('BB_WORKERCONTEXT') != '1':
                 return ""
-        # Single and list variables to be read
-        vars = (d.getVar("IMAGE_BUILDINFO_VARS") or "")
-        listvars = (d.getVar("IMAGE_BUILDINFO_LVARS") or "")
-        return image_buildinfo_outputvars(vars, listvars, d)
+        # taken from base.bbclass
+        localdata = bb.data.createCopy(d)
+        statuslines = []
+        g = globals()
+        func = 'buildcfg_vars'
+        if func not in g:
+            bb.warn("Build configuration function '%s' does not
 exist" % func)
+        else:
+            flines = g[func](localdata)
+            if flines:
+                statuslines.extend(flines)
+        return ('\n%s\n' % '\n'.join(statuslines))
 
 # Write build information to target filesystem

python buildinfo () {

Signature · 1 line
2.14.4
#2 lore raw
Quoted 74 lines · Richard Purdie
Quoted 7 lines · Andreas Müller

* before DISTRO and DISTRO_VERSION were written only - this is not enough to
get a complete picture in which environmet an image was build. Now
same
information as displayed on console is written.
* code fragment was based on bass.bbclass

Quoted 5 lines

---

I know timing is not the best - we are already feature freezed. But I think it is an enhancement worth to have an exception...

It sounds good from the commit message but anyone IMAGE_BUILDINFO_VARS or IMAGE_BUILDINFO_LVARS is going to find a significant change in behaviour? At the point past feature freeze I'm not sure we can do that...

Cheers,

Richard

Quoted 50 lines
 meta/classes/image-buildinfo.bbclass | 28 ++++++++++++------------
----
 1 file changed, 12 insertions(+), 16 deletions(-)
meta/classes/image-buildinfo.bbclass +12 -16
index 213fb9cf9b..fbb3188040 100644
@@ -15,18 +15,6 @@ IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION"
 # Desired location of the output file in the image.
 IMAGE_BUILDINFO_FILE ??= "${sysconfdir}/build"
 
-# From buildhistory.bbclass
-def image_buildinfo_outputvars(vars, listvars, d):
-    vars = vars.split()
-    listvars = listvars.split()
-    ret = ""
-    for var in vars:
-        value = d.getVar(var) or ""
-        if (d.getVarFlag(var, 'type') == "list"):
-            value = oe.utils.squashspaces(value)
-        ret += "%s = %s\n" % (var, value)
-    return ret.rstrip('\n')
-
 # Gets git branch's status (clean or dirty)
 def get_layer_git_status(path):
     import subprocess
@@ -57,10 +45,18 @@ def buildinfo_target(d):
         # Get context
         if d.getVar('BB_WORKERCONTEXT') != '1':
                 return ""
-        # Single and list variables to be read
-        vars = (d.getVar("IMAGE_BUILDINFO_VARS") or "")
-        listvars = (d.getVar("IMAGE_BUILDINFO_LVARS") or "")
-        return image_buildinfo_outputvars(vars, listvars, d)
+        # taken from base.bbclass
+        localdata = bb.data.createCopy(d)
+        statuslines = []
+        g = globals()
+        func = 'buildcfg_vars'
+        if func not in g:
+            bb.warn("Build configuration function '%s' does not
 exist" % func)
+        else:
+            flines = g[func](localdata)
+            if flines:
+                statuslines.extend(flines)
+        return ('\n%s\n' % '\n'.join(statuslines))
 
Quoted 5 lines
Quoted 5 lines
meta/classes/image-buildinfo.bbclass +0 -0
 # Write build information to target filesystem

python buildinfo () {
--
2.14.4

Is this something for time after feature freeze?

Andreas