summaryrefslogtreecommitdiffstats
path: root/meta/classes/image-buildinfo.bbclass
diff options
context:
space:
mode:
authorAlejandro Hernandez <alejandro.hernandez@linux.intel.com>2014-11-05 13:21:58 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-09 10:21:22 +0000
commited3e25379c22da57a829f323b9404dd240de2272 (patch)
tree396ede688a54146e2302232640213984730f8d05 /meta/classes/image-buildinfo.bbclass
parentc58237560dcb20283b27a816ffbafa0818ffc98e (diff)
downloadpoky-ed3e25379c22da57a829f323b9404dd240de2272.tar.gz
image-buildinfo.bbclass: new class, writes build information to image
Writes build information to target filesystem on /etc/build such as enabled layers, their current status and commit. squashspaces was moved to oe/utils.py to make it available to different classes and avoid code duplication. [YOCTO #6770] (From OE-Core rev: c9cc652e88ddedddf8a2f23fb9b8c024616526d7) Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/image-buildinfo.bbclass')
-rw-r--r--meta/classes/image-buildinfo.bbclass69
1 files changed, 69 insertions, 0 deletions
diff --git a/meta/classes/image-buildinfo.bbclass b/meta/classes/image-buildinfo.bbclass
new file mode 100644
index 0000000000..aa17cc8f9e
--- /dev/null
+++ b/meta/classes/image-buildinfo.bbclass
@@ -0,0 +1,69 @@
1#
2# Writes build information to target filesystem on /etc/build
3#
4# Copyright (C) 2014 Intel Corporation
5# Author: Alejandro Enedino Hernandez Samaniego <alejandro.hernandez@intel.com>
6#
7# Licensed under the MIT license, see COPYING.MIT for details
8#
9# Usage: add INHERIT += "image-buildinfo" to your conf file
10#
11
12# Desired variables to display
13IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION"
14
15# From buildhistory.bbclass
16def image_buildinfo_outputvars(vars, listvars, d):
17 vars = vars.split()
18 listvars = listvars.split()
19 ret = ""
20 for var in vars:
21 value = d.getVar(var, True) or ""
22 if (d.getVarFlag(var, 'type') == "list"):
23 value = oe.utils.squashspaces(value)
24 ret += "%s = %s\n" % (var, value)
25 return ret.rstrip('\n')
26
27# Gets git branch's status (clean or dirty)
28def get_layer_git_status(path):
29 f = os.popen("cd %s; git diff --stat 2>&1 | tail -n 1" % path)
30 data = f.read()
31 if f.close() is None:
32 if len(data) != 0:
33 return "-- modified"
34 return ""
35
36# Returns layer revisions along with their respective status
37def get_layer_revs(d):
38 layers = (d.getVar("BBLAYERS", True) or "").split()
39 medadata_revs = ["%-17s = %s:%s %s" % (os.path.basename(i), \
40 base_get_metadata_git_branch(i, None).strip(), \
41 base_get_metadata_git_revision(i, None), \
42 get_layer_git_status(i)) \
43 for i in layers]
44 return '\n'.join(medadata_revs)
45
46def buildinfo_target(d):
47 # Get context
48 if d.getVar('BB_WORKERCONTEXT', True) != '1':
49 return ""
50 # Single and list variables to be read
51 vars = (d.getVar("IMAGE_BUILDINFO_VARS", True) or "")
52 listvars = (d.getVar("IMAGE_BUILDINFO_LVARS", True) or "")
53 return image_buildinfo_outputvars(vars, listvars, d)
54
55# Write build information to target filesystem
56buildinfo () {
57cat > ${IMAGE_ROOTFS}${sysconfdir}/build << END
58-----------------------
59Build Configuration: |
60-----------------------
61${@buildinfo_target(d)}
62-----------------------
63Layer Revisions: |
64-----------------------
65${@get_layer_revs(d)}
66END
67}
68
69IMAGE_PREPROCESS_COMMAND += "buildinfo;"