diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-14 20:05:37 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 04:26:31 +0300 |
commit | eb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch) | |
tree | de291a73dc37168da6370e2cf16c347d1eba9df8 /poky/meta/classes/image-buildinfo.bbclass | |
parent | 9c3cf826d853102535ead04cebc2d6023eff3032 (diff) | |
download | openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz |
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers
content to the top level.
Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'poky/meta/classes/image-buildinfo.bbclass')
-rw-r--r-- | poky/meta/classes/image-buildinfo.bbclass | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/poky/meta/classes/image-buildinfo.bbclass b/poky/meta/classes/image-buildinfo.bbclass new file mode 100644 index 0000000000..213fb9cf9b --- /dev/null +++ b/poky/meta/classes/image-buildinfo.bbclass @@ -0,0 +1,85 @@ +# +# 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" + +# 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 + try: + subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e; + git diff --quiet --no-ext-diff + git diff --quiet --no-ext-diff --cached""" % path, + shell=True, + stderr=subprocess.STDOUT) + return "" + except subprocess.CalledProcessError as ex: + # 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" + +# 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), \ + 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') != '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) + +# Write build information to target filesystem +python buildinfo () { + with open(d.expand('${IMAGE_ROOTFS}${IMAGE_BUILDINFO_FILE}'), 'w') as build: + build.writelines(( + '''----------------------- +Build Configuration: | +----------------------- +''', + buildinfo_target(d), + ''' +----------------------- +Layer Revisions: | +----------------------- +''', + get_layer_revs(d), + ''' +''' + )) +} + +IMAGE_PREPROCESS_COMMAND += "buildinfo;" |