diff options
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r-- | meta/classes/buildhistory.bbclass | 60 |
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" | |||
11 | BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" | 11 | BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" |
12 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" | 12 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" |
13 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" | 13 | BUILDHISTORY_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 | ||
33 | BUILDHISTORY_RESET ?= "" | ||
34 | |||
35 | BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}" | ||
36 | BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" | ||
14 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" | 37 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" |
15 | BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" | 38 | BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" |
16 | BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" | 39 | BUILDHISTORY_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 | ||
723 | python buildhistory_eventhandler() { | 747 | python 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 | ||
734 | addhandler buildhistory_eventhandler | 776 | addhandler buildhistory_eventhandler |
735 | buildhistory_eventhandler[eventmask] = "bb.event.BuildCompleted" | 777 | buildhistory_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 |