summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-02-12 09:37:15 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-15 17:47:08 +0000
commitda13f0bce5d1b3c52f5716ae8d104372a820e5f9 (patch)
treeef08feb4936523ad98b22a27151aeac007a6b3c8 /meta/classes
parenta56da4a0fc792c854d1201b22969dc48fe437a0b (diff)
downloadpoky-da13f0bce5d1b3c52f5716ae8d104372a820e5f9.tar.gz
buildhistory.bbclass: remove out-dated information on request
buildhistory.bbclass by design is incremental: each build adds or updates information. Information is never removed. Sometimes it can be useful to reduce the information only to those recipes that were build during a specific bitbake invocation, for example when the invocation does a full world build. This is now possible by setting BUILDHISTORY_RESET as explained in the modified class. The comment on the variable also mentions the caveats associated with using this mode. In this mode, buildhistory.bbclass first moves all existing information into a temporary directory called "old" inside the build history directory. There the information is used for the "version going backwards" QA check. Then when the build is complete and before (potentially) committing to git, the temporary directory gets deleted. Because information that has not changed during the build will be reconstructed during full world rebuilds, a git log will then only show real updates, additions and removals. (From OE-Core rev: 51f4eb5bfcd25f7160e50314f433cad126aa3e9a) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/buildhistory.bbclass60
1 files changed, 51 insertions, 9 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 4854862a6e..fac7fed9f0 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -11,6 +11,29 @@ BUILDHISTORY_FEATURES ?= "image package sdk"
11BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" 11BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
12BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" 12BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
13BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" 13BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
14
15# Setting this to non-empty will remove the old content of the buildhistory as part of
16# the current bitbake invocation and replace it with information about what was built
17# during the build.
18#
19# This is meant to be used in continuous integration (CI) systems when invoking bitbake
20# for full world builds. The effect in that case is that information about packages
21# that no longer get build also gets removed from the buildhistory, which is not
22# the case otherwise.
23#
24# The advantage over manually cleaning the buildhistory outside of bitbake is that
25# the "version-going-backwards" check still works. When relying on that, be careful
26# about failed world builds: they will lead to incomplete information in the
27# buildhistory because information about packages that could not be built will
28# also get removed. A CI system should handle that by discarding the buildhistory
29# of failed builds.
30#
31# The expected usage is via auto.conf, but passing via the command line also works
32# with: BB_ENV_EXTRAWHITE=BUILDHISTORY_RESET BUILDHISTORY_RESET=1
33BUILDHISTORY_RESET ?= ""
34
35BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}"
36BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
14BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" 37BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}"
15BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" 38BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
16BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" 39BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf"
@@ -49,6 +72,7 @@ python buildhistory_emit_pkghistory() {
49 import errno 72 import errno
50 73
51 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 74 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
75 oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE', True)
52 76
53 class RecipeInfo: 77 class RecipeInfo:
54 def __init__(self, name): 78 def __init__(self, name):
@@ -139,7 +163,7 @@ python buildhistory_emit_pkghistory() {
139 163
140 def getlastpkgversion(pkg): 164 def getlastpkgversion(pkg):
141 try: 165 try:
142 histfile = os.path.join(pkghistdir, pkg, "latest") 166 histfile = os.path.join(oldpkghistdir, pkg, "latest")
143 return readPackageInfo(pkg, histfile) 167 return readPackageInfo(pkg, histfile)
144 except EnvironmentError: 168 except EnvironmentError:
145 return None 169 return None
@@ -722,17 +746,35 @@ END
722 746
723python buildhistory_eventhandler() { 747python buildhistory_eventhandler() {
724 if e.data.getVar('BUILDHISTORY_FEATURES', True).strip(): 748 if e.data.getVar('BUILDHISTORY_FEATURES', True).strip():
725 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1": 749 reset = e.data.getVar("BUILDHISTORY_RESET", True)
726 bb.note("Writing buildhistory") 750 olddir = e.data.getVar("BUILDHISTORY_OLD_DIR", True)
727 localdata = bb.data.createCopy(e.data) 751 if isinstance(e, bb.event.BuildStarted):
728 localdata.setVar('BUILDHISTORY_BUILD_FAILURES', str(e._failures)) 752 if reset:
729 interrupted = getattr(e, '_interrupted', 0) 753 import shutil
730 localdata.setVar('BUILDHISTORY_BUILD_INTERRUPTED', str(interrupted)) 754 # Clean up after potentially interrupted build.
731 bb.build.exec_func("buildhistory_commit", localdata) 755 if os.path.isdir(olddir):
756 shutil.rmtree(olddir)
757 rootdir = e.data.getVar("BUILDHISTORY_DIR", True)
758 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
759 bb.utils.mkdirhier(olddir)
760 for entry in entries:
761 os.rename(os.path.join(rootdir, entry),
762 os.path.join(olddir, entry))
763 elif isinstance(e, bb.event.BuildCompleted):
764 if reset:
765 import shutil
766 shutil.rmtree(olddir)
767 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1":
768 bb.note("Writing buildhistory")
769 localdata = bb.data.createCopy(e.data)
770 localdata.setVar('BUILDHISTORY_BUILD_FAILURES', str(e._failures))
771 interrupted = getattr(e, '_interrupted', 0)
772 localdata.setVar('BUILDHISTORY_BUILD_INTERRUPTED', str(interrupted))
773 bb.build.exec_func("buildhistory_commit", localdata)
732} 774}
733 775
734addhandler buildhistory_eventhandler 776addhandler buildhistory_eventhandler
735buildhistory_eventhandler[eventmask] = "bb.event.BuildCompleted" 777buildhistory_eventhandler[eventmask] = "bb.event.BuildCompleted bb.event.BuildStarted"
736 778
737 779
738# FIXME this ought to be moved into the fetcher 780# FIXME this ought to be moved into the fetcher