diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2015-09-15 22:41:29 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2015-09-15 22:41:29 +0300 |
commit | 21f9b84b4b729fbd7acbd465e7a3f726e4d20f91 (patch) | |
tree | eb2d091d427ca0813b445509d59cc8e27e8ad25f /yocto-poky/meta/classes/image-buildinfo.bbclass | |
parent | 101cef31e2bf54c678501155cd2106251acbd076 (diff) | |
parent | c124f4f2e04dca16a428a76c89677328bc7bf908 (diff) | |
download | openbmc-21f9b84b4b729fbd7acbd465e7a3f726e4d20f91.tar.xz |
Merge commit 'c124f4f2e04dca16a428a76c89677328bc7bf908' as 'yocto-poky'
Diffstat (limited to 'yocto-poky/meta/classes/image-buildinfo.bbclass')
-rw-r--r-- | yocto-poky/meta/classes/image-buildinfo.bbclass | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/yocto-poky/meta/classes/image-buildinfo.bbclass b/yocto-poky/meta/classes/image-buildinfo.bbclass new file mode 100644 index 000000000..aa17cc8f9 --- /dev/null +++ b/yocto-poky/meta/classes/image-buildinfo.bbclass @@ -0,0 +1,69 @@ +# +# Writes build information to target filesystem on /etc/build +# +# Copyright (C) 2014 Intel Corporation +# Author: Alejandro Enedino Hernandez Samaniego <alejandro.hernandez@intel.com> +# +# Licensed under the MIT license, see COPYING.MIT for details +# +# Usage: add INHERIT += "image-buildinfo" to your conf file +# + +# Desired variables to display +IMAGE_BUILDINFO_VARS ?= "DISTRO DISTRO_VERSION" + +# 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, True) 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): + f = os.popen("cd %s; git diff --stat 2>&1 | tail -n 1" % path) + data = f.read() + if f.close() is None: + if len(data) != 0: + return "-- modified" + return "" + +# Returns layer revisions along with their respective status +def get_layer_revs(d): + layers = (d.getVar("BBLAYERS", True) or "").split() + medadata_revs = ["%-17s = %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)) \ + for i in layers] + return '\n'.join(medadata_revs) + +def buildinfo_target(d): + # Get context + if d.getVar('BB_WORKERCONTEXT', True) != '1': + return "" + # Single and list variables to be read + vars = (d.getVar("IMAGE_BUILDINFO_VARS", True) or "") + listvars = (d.getVar("IMAGE_BUILDINFO_LVARS", True) or "") + return image_buildinfo_outputvars(vars, listvars, d) + +# Write build information to target filesystem +buildinfo () { +cat > ${IMAGE_ROOTFS}${sysconfdir}/build << END +----------------------- +Build Configuration: | +----------------------- +${@buildinfo_target(d)} +----------------------- +Layer Revisions: | +----------------------- +${@get_layer_revs(d)} +END +} + +IMAGE_PREPROCESS_COMMAND += "buildinfo;" |