summaryrefslogtreecommitdiffstats
path: root/meta/classes/buildhistory.bbclass
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2011-11-30 16:48:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-12-05 16:23:53 +0000
commit6ba6f4a6f744895741c82f93756439292f563bf6 (patch)
tree64b35044e9730c94fb12b747cc658d1a2d23ef51 /meta/classes/buildhistory.bbclass
parent45c4f0a5870cf3a089b0edd02f52297865f5b5db (diff)
downloadpoky-6ba6f4a6f744895741c82f93756439292f563bf6.tar.gz
classes/buildhistory: add new output history collection class
Create a new build output history reporting class, using testlab.bbclass from meta-oe as a base. This records information from images produced by the build process in text files structured suitably for tracking within a git repository, thus enabling monitoring of changes over time. Build history collection can be enabled simply by adding the following to your local.conf: INHERIT += "buildhistory" The output after a build can then be found in BUILDHISTORY_DIR (defaults to TMPDIR/buildhistory). If you set up this directory as a git repository and set BUILDHISTORY_COMMIT to "1" in local.conf, the build history data will be committed on every build. (From OE-Core rev: 14acb530a27a3b088d0bfd56db291f4e72ace8ab) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r--meta/classes/buildhistory.bbclass105
1 files changed, 105 insertions, 0 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
new file mode 100644
index 0000000000..21f8493ce5
--- /dev/null
+++ b/meta/classes/buildhistory.bbclass
@@ -0,0 +1,105 @@
1#
2# Records history of build output in order to detect regressions
3#
4# Based in part on testlab.bbclass
5#
6# Copyright (C) 2011 Intel Corporation
7# Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org>
8#
9
10BUILDHISTORY_DIR ?= "${TMPDIR}/buildhistory"
11BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
12BUILDHISTORY_COMMIT ?= "0"
13BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
14BUILDHISTORY_PUSH_REPO ?= ""
15
16buildhistory_get_image_installed() {
17 # Anything requiring the use of the packaging system should be done in here
18 # in case the packaging files are going to be removed for this image
19
20 mkdir -p ${BUILDHISTORY_DIR_IMAGE}
21
22 # Get list of installed packages
23 list_installed_packages | sort > ${BUILDHISTORY_DIR_IMAGE}/installed-package-names.txt
24 INSTALLED_PKGS=`cat ${BUILDHISTORY_DIR_IMAGE}/installed-package-names.txt`
25
26 # Produce installed package file and size lists and dependency graph
27 echo -n > ${BUILDHISTORY_DIR_IMAGE}/installed-packages.txt
28 echo -n > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
29 echo -e "digraph depends {\n node [shape=plaintext]" > ${BUILDHISTORY_DIR_IMAGE}/depends.dot
30 for pkg in $INSTALLED_PKGS; do
31 pkgfile=`get_package_filename $pkg`
32 echo `basename $pkgfile` >> ${BUILDHISTORY_DIR_IMAGE}/installed-packages.txt
33 if [ -f $pkgfile ] ; then
34 pkgsize=`du -k $pkgfile | head -n1 | awk '{ print $1 }'`
35 echo $pkgsize $pkg >> ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
36 fi
37
38 deps=`list_package_depends $pkg`
39 for dep in $deps ; do
40 echo "$pkg OPP $dep;" | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' | sed 's:OPP:->:g' >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
41 done
42
43 recs=`list_package_recommends $pkg`
44 for rec in $recs ; do
45 echo "$pkg OPP $rec [style=dotted];" | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' | sed 's:OPP:->:g' >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
46 done
47 done
48 echo "}" >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
49
50 cat ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.txt
51 rm ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
52
53 # Produce some cut-down graphs (for readability)
54 grep -v kernel_image ${BUILDHISTORY_DIR_IMAGE}/depends.dot | grep -v kernel_2 | grep -v kernel_3 > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot
55 grep -v libc6 ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot | grep -v libgcc > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot
56 grep -v update_ ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot
57 grep -v kernel_module ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate-nomodules.dot
58
59 # Workaround for broken shell function dependencies
60 if false ; then
61 get_package_filename
62 list_package_depends
63 list_package_recommends
64 fi
65}
66
67buildhistory_get_imageinfo() {
68 # List the files in the image, but exclude date/time etc.
69 # This awk script is somewhat messy, but handles where the size is not printed for device files under pseudo
70 find ${IMAGE_ROOTFS} -ls | awk '{ if ( $7 ~ /[0-9]/ ) printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, $7, $11, $12, $13 ; else printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, 0, $10, $11, $12 }' > ${BUILDHISTORY_DIR_IMAGE}/files-in-image.txt
71
72 # Add some configuration information
73 echo "${MACHINE}: ${IMAGE_BASENAME} configured for ${DISTRO} ${DISTRO_VERSION}" > ${BUILDHISTORY_DIR_IMAGE}/build-id
74 echo "${@buildhistory_get_layers(d)}" >> ${BUILDHISTORY_DIR_IMAGE}/build-id
75}
76
77# By prepending we get in before the removal of packaging files
78ROOTFS_POSTPROCESS_COMMAND =+ "buildhistory_get_image_installed ; "
79
80IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; "
81
82def buildhistory_get_layers(d):
83 layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d))
84 return layertext
85
86
87buildhistory_commit() {
88 ( cd ${BUILDHISTORY_DIR}/
89 git add ${BUILDHISTORY_DIR}/*
90 git commit ${BUILDHISTORY_DIR}/ -m "Build ${BUILDNAME} for machine ${MACHINE} configured for ${DISTRO} ${DISTRO_VERSION}" --author "${BUILDHISTORY_COMMIT_AUTHOR}" > /dev/null
91 if [ "${BUILDHISTORY_PUSH_REPO}" != "" ] ; then
92 git push -q ${BUILDHISTORY_PUSH_REPO}
93 fi) || true
94}
95
96python buildhistory_eventhandler() {
97 import bb.build
98 import bb.event
99
100 if isinstance(e, bb.event.BuildCompleted):
101 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1":
102 bb.build.exec_func("buildhistory_commit", e.data)
103}
104
105addhandler buildhistory_eventhandler