summaryrefslogtreecommitdiffstats
path: root/meta/classes/buildhistory.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r--meta/classes/buildhistory.bbclass135
1 files changed, 45 insertions, 90 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index fd53e92402..4a380c10c6 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -16,28 +16,6 @@ BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" 16BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" 17BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
18 18
19# Setting this to non-empty will remove the old content of the buildhistory as part of
20# the current bitbake invocation and replace it with information about what was built
21# during the build.
22#
23# This is meant to be used in continuous integration (CI) systems when invoking bitbake
24# for full world builds. The effect in that case is that information about packages
25# that no longer get build also gets removed from the buildhistory, which is not
26# the case otherwise.
27#
28# The advantage over manually cleaning the buildhistory outside of bitbake is that
29# the "version-going-backwards" check still works. When relying on that, be careful
30# about failed world builds: they will lead to incomplete information in the
31# buildhistory because information about packages that could not be built will
32# also get removed. A CI system should handle that by discarding the buildhistory
33# of failed builds.
34#
35# The expected usage is via auto.conf, but passing via the command line also works
36# with: BB_ENV_PASSTHROUGH_ADDITIONS=BUILDHISTORY_RESET BUILDHISTORY_RESET=1
37BUILDHISTORY_RESET ?= ""
38
39BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}"
40BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
41BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" 19BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}"
42BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" 20BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
43BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" 21BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf"
@@ -47,25 +25,33 @@ BUILDHISTORY_PUSH_REPO ?= ""
47BUILDHISTORY_TAG ?= "build" 25BUILDHISTORY_TAG ?= "build"
48BUILDHISTORY_PATH_PREFIX_STRIP ?= "" 26BUILDHISTORY_PATH_PREFIX_STRIP ?= ""
49 27
50SSTATEPOSTINSTFUNCS:append = " buildhistory_emit_pkghistory" 28# We want to avoid influencing the signatures of the task so use vardepsexclude
51# We want to avoid influencing the signatures of sstate tasks - first the function itself: 29do_populate_sysroot[postfuncs] += "buildhistory_emit_sysroot"
52sstate_install[vardepsexclude] += "buildhistory_emit_pkghistory" 30do_populate_sysroot_setscene[postfuncs] += "buildhistory_emit_sysroot"
53# then the value added to SSTATEPOSTINSTFUNCS: 31do_populate_sysroot[vardepsexclude] += "buildhistory_emit_sysroot"
54SSTATEPOSTINSTFUNCS[vardepvalueexclude] .= "| buildhistory_emit_pkghistory" 32
33do_package[postfuncs] += "buildhistory_list_pkg_files"
34do_package_setscene[postfuncs] += "buildhistory_list_pkg_files"
35do_package[vardepsexclude] += "buildhistory_list_pkg_files"
36
37do_packagedata[postfuncs] += "buildhistory_emit_pkghistory"
38do_packagedata_setscene[postfuncs] += "buildhistory_emit_pkghistory"
39do_packagedata[vardepsexclude] += "buildhistory_emit_pkghistory"
55 40
56# Similarly for our function that gets the output signatures 41# Similarly for our function that gets the output signatures
57SSTATEPOSTUNPACKFUNCS:append = " buildhistory_emit_outputsigs" 42SSTATEPOSTUNPACKFUNCS:append = " buildhistory_emit_outputsigs"
58sstate_installpkgdir[vardepsexclude] += "buildhistory_emit_outputsigs" 43sstate_installpkgdir[vardepsexclude] += "buildhistory_emit_outputsigs"
59SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs" 44SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs"
60 45
61# All items excepts those listed here will be removed from a recipe's 46# All items except those listed here will be removed from a recipe's
62# build history directory by buildhistory_emit_pkghistory(). This is 47# build history directory by buildhistory_emit_pkghistory(). This is
63# necessary because some of these items (package directories, files that 48# necessary because some of these items (package directories, files that
64# we no longer emit) might be obsolete. 49# we no longer emit) might be obsolete.
65# 50#
66# When extending build history, derive your class from buildhistory.bbclass 51# The files listed here are either written by tasks that aren't do_package (e.g.
67# and extend this list here with the additional files created by the derived 52# latest_srcrev from do_fetch) so do_package must not remove them, or, they're
68# class. 53# used to read values in do_package before always being overwritten, e.g. latest,
54# for version backwards checks.
69BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot" 55BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot"
70 56
71PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" 57PATCH_GIT_USER_EMAIL ?= "buildhistory@oe"
@@ -91,28 +77,16 @@ buildhistory_emit_sysroot() {
91# Write out metadata about this package for comparison when writing future packages 77# Write out metadata about this package for comparison when writing future packages
92# 78#
93python buildhistory_emit_pkghistory() { 79python buildhistory_emit_pkghistory() {
94 if d.getVar('BB_CURRENTTASK') in ['populate_sysroot', 'populate_sysroot_setscene']:
95 bb.build.exec_func("buildhistory_emit_sysroot", d)
96 return 0
97
98 if not "package" in (d.getVar('BUILDHISTORY_FEATURES') or "").split():
99 return 0
100
101 if d.getVar('BB_CURRENTTASK') in ['package', 'package_setscene']:
102 # Create files-in-<package-name>.txt files containing a list of files of each recipe's package
103 bb.build.exec_func("buildhistory_list_pkg_files", d)
104 return 0
105
106 if not d.getVar('BB_CURRENTTASK') in ['packagedata', 'packagedata_setscene']:
107 return 0
108
109 import re 80 import re
110 import json 81 import json
111 import shlex 82 import shlex
112 import errno 83 import errno
84 import shutil
85
86 if not "package" in (d.getVar('BUILDHISTORY_FEATURES') or "").split():
87 return 0
113 88
114 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') 89 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
115 oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
116 90
117 class RecipeInfo: 91 class RecipeInfo:
118 def __init__(self, name): 92 def __init__(self, name):
@@ -153,7 +127,7 @@ python buildhistory_emit_pkghistory() {
153 # Variables that need to be written to their own separate file 127 # Variables that need to be written to their own separate file
154 self.filevars = dict.fromkeys(['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']) 128 self.filevars = dict.fromkeys(['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm'])
155 129
156 # Should check PACKAGES here to see if anything removed 130 # Should check PACKAGES here to see if anything was removed
157 131
158 def readPackageInfo(pkg, histfile): 132 def readPackageInfo(pkg, histfile):
159 pkginfo = PackageInfo(pkg) 133 pkginfo = PackageInfo(pkg)
@@ -207,7 +181,7 @@ python buildhistory_emit_pkghistory() {
207 181
208 def getlastpkgversion(pkg): 182 def getlastpkgversion(pkg):
209 try: 183 try:
210 histfile = os.path.join(oldpkghistdir, pkg, "latest") 184 histfile = os.path.join(pkghistdir, pkg, "latest")
211 return readPackageInfo(pkg, histfile) 185 return readPackageInfo(pkg, histfile)
212 except EnvironmentError: 186 except EnvironmentError:
213 return None 187 return None
@@ -535,7 +509,7 @@ buildhistory_get_installed() {
535 grep -v kernel-module $1/depends-nokernel-nolibc-noupdate.dot > $1/depends-nokernel-nolibc-noupdate-nomodules.dot 509 grep -v kernel-module $1/depends-nokernel-nolibc-noupdate.dot > $1/depends-nokernel-nolibc-noupdate-nomodules.dot
536 fi 510 fi
537 511
538 # add complementary package information 512 # Add complementary package information
539 if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then 513 if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then
540 cp ${WORKDIR}/complementary_pkgs.txt $1 514 cp ${WORKDIR}/complementary_pkgs.txt $1
541 fi 515 fi
@@ -573,7 +547,7 @@ buildhistory_get_sdk_installed_target() {
573 547
574buildhistory_list_files() { 548buildhistory_list_files() {
575 # List the files in the specified directory, but exclude date/time etc. 549 # List the files in the specified directory, but exclude date/time etc.
576 # This is somewhat messy, but handles where the size is not printed for device files under pseudo 550 # This is somewhat messy, but handles cases where the size is not printed for device files under pseudo
577 ( cd $1 551 ( cd $1
578 find_cmd='find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n"' 552 find_cmd='find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n"'
579 if [ "$3" = "fakeroot" ] ; then 553 if [ "$3" = "fakeroot" ] ; then
@@ -587,7 +561,7 @@ buildhistory_list_files_no_owners() {
587 # List the files in the specified directory, but exclude date/time etc. 561 # List the files in the specified directory, but exclude date/time etc.
588 # Also don't output the ownership data, but instead output just - - so 562 # Also don't output the ownership data, but instead output just - - so
589 # that the same parsing code as for _list_files works. 563 # that the same parsing code as for _list_files works.
590 # This is somewhat messy, but handles where the size is not printed for device files under pseudo 564 # This is somewhat messy, but handles cases where the size is not printed for device files under pseudo
591 ( cd $1 565 ( cd $1
592 find_cmd='find . ! -path . -printf "%M - - %10s %p -> %l\n"' 566 find_cmd='find . ! -path . -printf "%M - - %10s %p -> %l\n"'
593 if [ "$3" = "fakeroot" ] ; then 567 if [ "$3" = "fakeroot" ] ; then
@@ -598,16 +572,17 @@ buildhistory_list_files_no_owners() {
598} 572}
599 573
600buildhistory_list_pkg_files() { 574buildhistory_list_pkg_files() {
575 if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'package', '1', '0', d)}" = "0" ] ; then
576 return
577 fi
578
601 # Create individual files-in-package for each recipe's package 579 # Create individual files-in-package for each recipe's package
602 for pkgdir in $(find ${PKGDEST}/* -maxdepth 0 -type d); do 580 pkgdirlist=$(find ${PKGDEST}/* -maxdepth 0 -type d)
581 for pkgdir in $pkgdirlist; do
603 pkgname=$(basename $pkgdir) 582 pkgname=$(basename $pkgdir)
604 outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname" 583 outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname"
605 outfile="$outfolder/files-in-package.txt" 584 outfile="$outfolder/files-in-package.txt"
606 # Make sure the output folder exists so we can create the file 585 mkdir -p $outfolder
607 if [ ! -d $outfolder ] ; then
608 bbdebug 2 "Folder $outfolder does not exist, file $outfile not created"
609 continue
610 fi
611 buildhistory_list_files $pkgdir $outfile fakeroot 586 buildhistory_list_files $pkgdir $outfile fakeroot
612 done 587 done
613} 588}
@@ -842,9 +817,9 @@ END
842 if [ ! -e .git ] ; then 817 if [ ! -e .git ] ; then
843 git init -q 818 git init -q
844 else 819 else
845 git tag -f ${BUILDHISTORY_TAG}-minus-3 ${BUILDHISTORY_TAG}-minus-2 > /dev/null 2>&1 || true 820 git tag -f --no-sign ${BUILDHISTORY_TAG}-minus-3 ${BUILDHISTORY_TAG}-minus-2 > /dev/null 2>&1 || true
846 git tag -f ${BUILDHISTORY_TAG}-minus-2 ${BUILDHISTORY_TAG}-minus-1 > /dev/null 2>&1 || true 821 git tag -f --no-sign ${BUILDHISTORY_TAG}-minus-2 ${BUILDHISTORY_TAG}-minus-1 > /dev/null 2>&1 || true
847 git tag -f ${BUILDHISTORY_TAG}-minus-1 > /dev/null 2>&1 || true 822 git tag -f --no-sign ${BUILDHISTORY_TAG}-minus-1 > /dev/null 2>&1 || true
848 fi 823 fi
849 824
850 check_git_config 825 check_git_config
@@ -855,10 +830,9 @@ END
855 CMDLINE="${@buildhistory_get_cmdline(d)}" 830 CMDLINE="${@buildhistory_get_cmdline(d)}"
856 if [ "$repostatus" != "" ] ; then 831 if [ "$repostatus" != "" ] ; then
857 git add -A . 832 git add -A .
858 # porcelain output looks like "?? packages/foo/bar" 833 # Porcelain output looks like "?? packages/foo/bar"
859 # Ensure we commit metadata-revs with the first commit 834 # Ensure we commit metadata-revs with the first commit
860 buildhistory_single_commit "$CMDLINE" "$HOSTNAME" dummy 835 buildhistory_single_commit "$CMDLINE" "$HOSTNAME" dummy
861 git gc --auto --quiet
862 else 836 else
863 buildhistory_single_commit "$CMDLINE" "$HOSTNAME" 837 buildhistory_single_commit "$CMDLINE" "$HOSTNAME"
864 fi 838 fi
@@ -869,25 +843,7 @@ END
869 843
870python buildhistory_eventhandler() { 844python buildhistory_eventhandler() {
871 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip(): 845 if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip():
872 reset = e.data.getVar("BUILDHISTORY_RESET") 846 if isinstance(e, bb.event.BuildCompleted):
873 olddir = e.data.getVar("BUILDHISTORY_OLD_DIR")
874 if isinstance(e, bb.event.BuildStarted):
875 if reset:
876 import shutil
877 # Clean up after potentially interrupted build.
878 if os.path.isdir(olddir):
879 shutil.rmtree(olddir)
880 rootdir = e.data.getVar("BUILDHISTORY_DIR")
881 bb.utils.mkdirhier(rootdir)
882 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
883 bb.utils.mkdirhier(olddir)
884 for entry in entries:
885 bb.utils.rename(os.path.join(rootdir, entry),
886 os.path.join(olddir, entry))
887 elif isinstance(e, bb.event.BuildCompleted):
888 if reset:
889 import shutil
890 shutil.rmtree(olddir)
891 if e.data.getVar("BUILDHISTORY_COMMIT") == "1": 847 if e.data.getVar("BUILDHISTORY_COMMIT") == "1":
892 bb.note("Writing buildhistory") 848 bb.note("Writing buildhistory")
893 bb.build.exec_func("buildhistory_write_sigs", d) 849 bb.build.exec_func("buildhistory_write_sigs", d)
@@ -925,13 +881,12 @@ def _get_srcrev_values(d):
925 dict_tag_srcrevs = {} 881 dict_tag_srcrevs = {}
926 for scm in scms: 882 for scm in scms:
927 ud = urldata[scm] 883 ud = urldata[scm]
928 for name in ud.names: 884 autoinc, rev = ud.method.sortable_revision(ud, d, ud.name)
929 autoinc, rev = ud.method.sortable_revision(ud, d, name) 885 dict_srcrevs[ud.name] = rev
930 dict_srcrevs[name] = rev 886 if 'tag' in ud.parm:
931 if 'tag' in ud.parm: 887 tag = ud.parm['tag'];
932 tag = ud.parm['tag']; 888 key = ud.name+'_'+tag
933 key = name+'_'+tag 889 dict_tag_srcrevs[key] = rev
934 dict_tag_srcrevs[key] = rev
935 return (dict_srcrevs, dict_tag_srcrevs) 890 return (dict_srcrevs, dict_tag_srcrevs)
936 891
937do_fetch[postfuncs] += "write_srcrev" 892do_fetch[postfuncs] += "write_srcrev"
@@ -990,7 +945,7 @@ def write_latest_ptest_result(d, histdir):
990 output_ptest = os.path.join(histdir, 'ptest') 945 output_ptest = os.path.join(histdir, 'ptest')
991 if os.path.exists(input_ptest): 946 if os.path.exists(input_ptest):
992 try: 947 try:
993 # Lock it avoid race issue 948 # Lock it to avoid race issue
994 lock = bb.utils.lockfile(output_ptest + "/ptest.lock") 949 lock = bb.utils.lockfile(output_ptest + "/ptest.lock")
995 bb.utils.mkdirhier(output_ptest) 950 bb.utils.mkdirhier(output_ptest)
996 oe.path.copytree(input_ptest, output_ptest) 951 oe.path.copytree(input_ptest, output_ptest)