diff options
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r-- | meta/classes/buildhistory.bbclass | 267 |
1 files changed, 109 insertions, 158 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 117a44eaf3..4a380c10c6 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
@@ -6,36 +6,16 @@ | |||
6 | # Copyright (C) 2011-2016 Intel Corporation | 6 | # Copyright (C) 2011-2016 Intel Corporation |
7 | # Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org> | 7 | # Copyright (C) 2007-2011 Koen Kooi <koen@openembedded.org> |
8 | # | 8 | # |
9 | # SPDX-License-Identifier: MIT | ||
10 | # | ||
9 | 11 | ||
10 | inherit image-artifact-names | 12 | IMAGE_CLASSES += "image-artifact-names" |
11 | 13 | ||
12 | BUILDHISTORY_FEATURES ?= "image package sdk" | 14 | BUILDHISTORY_FEATURES ?= "image package sdk" |
13 | BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" | 15 | BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory" |
14 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" | 16 | BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}" |
15 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" | 17 | BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" |
16 | 18 | ||
17 | # Setting this to non-empty will remove the old content of the buildhistory as part of | ||
18 | # the current bitbake invocation and replace it with information about what was built | ||
19 | # during the build. | ||
20 | # | ||
21 | # This is meant to be used in continuous integration (CI) systems when invoking bitbake | ||
22 | # for full world builds. The effect in that case is that information about packages | ||
23 | # that no longer get build also gets removed from the buildhistory, which is not | ||
24 | # the case otherwise. | ||
25 | # | ||
26 | # The advantage over manually cleaning the buildhistory outside of bitbake is that | ||
27 | # the "version-going-backwards" check still works. When relying on that, be careful | ||
28 | # about failed world builds: they will lead to incomplete information in the | ||
29 | # buildhistory because information about packages that could not be built will | ||
30 | # also get removed. A CI system should handle that by discarding the buildhistory | ||
31 | # of failed builds. | ||
32 | # | ||
33 | # The expected usage is via auto.conf, but passing via the command line also works | ||
34 | # with: BB_ENV_EXTRAWHITE=BUILDHISTORY_RESET BUILDHISTORY_RESET=1 | ||
35 | BUILDHISTORY_RESET ?= "" | ||
36 | |||
37 | BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}" | ||
38 | BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}" | ||
39 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" | 19 | BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}" |
40 | BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" | 20 | BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group" |
41 | BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" | 21 | BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf" |
@@ -43,26 +23,35 @@ BUILDHISTORY_COMMIT ?= "1" | |||
43 | BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" | 23 | BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" |
44 | BUILDHISTORY_PUSH_REPO ?= "" | 24 | BUILDHISTORY_PUSH_REPO ?= "" |
45 | BUILDHISTORY_TAG ?= "build" | 25 | BUILDHISTORY_TAG ?= "build" |
26 | BUILDHISTORY_PATH_PREFIX_STRIP ?= "" | ||
27 | |||
28 | # We want to avoid influencing the signatures of the task so use vardepsexclude | ||
29 | do_populate_sysroot[postfuncs] += "buildhistory_emit_sysroot" | ||
30 | do_populate_sysroot_setscene[postfuncs] += "buildhistory_emit_sysroot" | ||
31 | do_populate_sysroot[vardepsexclude] += "buildhistory_emit_sysroot" | ||
46 | 32 | ||
47 | SSTATEPOSTINSTFUNCS_append = " buildhistory_emit_pkghistory" | 33 | do_package[postfuncs] += "buildhistory_list_pkg_files" |
48 | # We want to avoid influencing the signatures of sstate tasks - first the function itself: | 34 | do_package_setscene[postfuncs] += "buildhistory_list_pkg_files" |
49 | sstate_install[vardepsexclude] += "buildhistory_emit_pkghistory" | 35 | do_package[vardepsexclude] += "buildhistory_list_pkg_files" |
50 | # then the value added to SSTATEPOSTINSTFUNCS: | 36 | |
51 | SSTATEPOSTINSTFUNCS[vardepvalueexclude] .= "| buildhistory_emit_pkghistory" | 37 | do_packagedata[postfuncs] += "buildhistory_emit_pkghistory" |
38 | do_packagedata_setscene[postfuncs] += "buildhistory_emit_pkghistory" | ||
39 | do_packagedata[vardepsexclude] += "buildhistory_emit_pkghistory" | ||
52 | 40 | ||
53 | # Similarly for our function that gets the output signatures | 41 | # Similarly for our function that gets the output signatures |
54 | SSTATEPOSTUNPACKFUNCS_append = " buildhistory_emit_outputsigs" | 42 | SSTATEPOSTUNPACKFUNCS:append = " buildhistory_emit_outputsigs" |
55 | sstate_installpkgdir[vardepsexclude] += "buildhistory_emit_outputsigs" | 43 | sstate_installpkgdir[vardepsexclude] += "buildhistory_emit_outputsigs" |
56 | SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs" | 44 | SSTATEPOSTUNPACKFUNCS[vardepvalueexclude] .= "| buildhistory_emit_outputsigs" |
57 | 45 | ||
58 | # 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 |
59 | # build history directory by buildhistory_emit_pkghistory(). This is | 47 | # build history directory by buildhistory_emit_pkghistory(). This is |
60 | # necessary because some of these items (package directories, files that | 48 | # necessary because some of these items (package directories, files that |
61 | # we no longer emit) might be obsolete. | 49 | # we no longer emit) might be obsolete. |
62 | # | 50 | # |
63 | # 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. |
64 | # 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 |
65 | # class. | 53 | # used to read values in do_package before always being overwritten, e.g. latest, |
54 | # for version backwards checks. | ||
66 | BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot" | 55 | BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot" |
67 | 56 | ||
68 | PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" | 57 | PATCH_GIT_USER_EMAIL ?= "buildhistory@oe" |
@@ -88,22 +77,16 @@ buildhistory_emit_sysroot() { | |||
88 | # 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 |
89 | # | 78 | # |
90 | python buildhistory_emit_pkghistory() { | 79 | python buildhistory_emit_pkghistory() { |
91 | if d.getVar('BB_CURRENTTASK') in ['populate_sysroot', 'populate_sysroot_setscene']: | ||
92 | bb.build.exec_func("buildhistory_emit_sysroot", d) | ||
93 | |||
94 | if not d.getVar('BB_CURRENTTASK') in ['packagedata', 'packagedata_setscene']: | ||
95 | return 0 | ||
96 | |||
97 | if not "package" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): | ||
98 | return 0 | ||
99 | |||
100 | import re | 80 | import re |
101 | import json | 81 | import json |
102 | import shlex | 82 | import shlex |
103 | import errno | 83 | import errno |
84 | import shutil | ||
85 | |||
86 | if not "package" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): | ||
87 | return 0 | ||
104 | 88 | ||
105 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') | 89 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE') |
106 | oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE') | ||
107 | 90 | ||
108 | class RecipeInfo: | 91 | class RecipeInfo: |
109 | def __init__(self, name): | 92 | def __init__(self, name): |
@@ -144,7 +127,7 @@ python buildhistory_emit_pkghistory() { | |||
144 | # Variables that need to be written to their own separate file | 127 | # Variables that need to be written to their own separate file |
145 | 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']) |
146 | 129 | ||
147 | # Should check PACKAGES here to see if anything removed | 130 | # Should check PACKAGES here to see if anything was removed |
148 | 131 | ||
149 | def readPackageInfo(pkg, histfile): | 132 | def readPackageInfo(pkg, histfile): |
150 | pkginfo = PackageInfo(pkg) | 133 | pkginfo = PackageInfo(pkg) |
@@ -198,7 +181,7 @@ python buildhistory_emit_pkghistory() { | |||
198 | 181 | ||
199 | def getlastpkgversion(pkg): | 182 | def getlastpkgversion(pkg): |
200 | try: | 183 | try: |
201 | histfile = os.path.join(oldpkghistdir, pkg, "latest") | 184 | histfile = os.path.join(pkghistdir, pkg, "latest") |
202 | return readPackageInfo(pkg, histfile) | 185 | return readPackageInfo(pkg, histfile) |
203 | except EnvironmentError: | 186 | except EnvironmentError: |
204 | return None | 187 | return None |
@@ -286,7 +269,7 @@ python buildhistory_emit_pkghistory() { | |||
286 | r = bb.utils.vercmp((pkge, pkgv, pkgr), (last_pkge, last_pkgv, last_pkgr)) | 269 | r = bb.utils.vercmp((pkge, pkgv, pkgr), (last_pkge, last_pkgv, last_pkgr)) |
287 | if r < 0: | 270 | if r < 0: |
288 | msg = "Package version for package %s went backwards which would break package feeds (from %s:%s-%s to %s:%s-%s)" % (pkg, last_pkge, last_pkgv, last_pkgr, pkge, pkgv, pkgr) | 271 | msg = "Package version for package %s went backwards which would break package feeds (from %s:%s-%s to %s:%s-%s)" % (pkg, last_pkge, last_pkgv, last_pkgr, pkge, pkgv, pkgr) |
289 | package_qa_handle_error("version-going-backwards", msg, d) | 272 | oe.qa.handle_error("version-going-backwards", msg, d) |
290 | 273 | ||
291 | pkginfo = PackageInfo(pkg) | 274 | pkginfo = PackageInfo(pkg) |
292 | # Apparently the version can be different on a per-package basis (see Python) | 275 | # Apparently the version can be different on a per-package basis (see Python) |
@@ -318,8 +301,7 @@ python buildhistory_emit_pkghistory() { | |||
318 | 301 | ||
319 | write_pkghistory(pkginfo, d) | 302 | write_pkghistory(pkginfo, d) |
320 | 303 | ||
321 | # Create files-in-<package-name>.txt files containing a list of files of each recipe's package | 304 | oe.qa.exit_if_errors(d) |
322 | bb.build.exec_func("buildhistory_list_pkg_files", d) | ||
323 | } | 305 | } |
324 | 306 | ||
325 | python buildhistory_emit_outputsigs() { | 307 | python buildhistory_emit_outputsigs() { |
@@ -441,11 +423,16 @@ def buildhistory_list_installed(d, rootfs_type="image"): | |||
441 | else: | 423 | else: |
442 | pkgs = sdk_list_installed_packages(d, rootfs_type == "sdk_target") | 424 | pkgs = sdk_list_installed_packages(d, rootfs_type == "sdk_target") |
443 | 425 | ||
426 | if rootfs_type == "sdk_host": | ||
427 | pkgdata_dir = d.getVar('PKGDATA_DIR_SDK') | ||
428 | else: | ||
429 | pkgdata_dir = d.getVar('PKGDATA_DIR') | ||
430 | |||
444 | for output_type, output_file in process_list: | 431 | for output_type, output_file in process_list: |
445 | output_file_full = os.path.join(d.getVar('WORKDIR'), output_file) | 432 | output_file_full = os.path.join(d.getVar('WORKDIR'), output_file) |
446 | 433 | ||
447 | with open(output_file_full, 'w') as output: | 434 | with open(output_file_full, 'w') as output: |
448 | output.write(format_pkg_list(pkgs, output_type)) | 435 | output.write(format_pkg_list(pkgs, output_type, pkgdata_dir)) |
449 | 436 | ||
450 | python buildhistory_list_installed_image() { | 437 | python buildhistory_list_installed_image() { |
451 | buildhistory_list_installed(d) | 438 | buildhistory_list_installed(d) |
@@ -486,6 +473,8 @@ buildhistory_get_installed() { | |||
486 | -e 's:|: -> :' \ | 473 | -e 's:|: -> :' \ |
487 | -e 's:"\[REC\]":[style=dotted]:' \ | 474 | -e 's:"\[REC\]":[style=dotted]:' \ |
488 | -e 's:"\([<>=]\+\)" "\([^"]*\)":[label="\1 \2"]:' \ | 475 | -e 's:"\([<>=]\+\)" "\([^"]*\)":[label="\1 \2"]:' \ |
476 | -e 's:"\([*]\+\)" "\([^"]*\)":[label="\2"]:' \ | ||
477 | -e 's:"\[RPROVIDES\]":[style=dashed]:' \ | ||
489 | $1/depends.tmp | 478 | $1/depends.tmp |
490 | # Add header, sorted and de-duped contents and footer and then delete the temp file | 479 | # Add header, sorted and de-duped contents and footer and then delete the temp file |
491 | printf "digraph depends {\n node [shape=plaintext]\n" > $1/depends.dot | 480 | printf "digraph depends {\n node [shape=plaintext]\n" > $1/depends.dot |
@@ -493,11 +482,22 @@ buildhistory_get_installed() { | |||
493 | echo "}" >> $1/depends.dot | 482 | echo "}" >> $1/depends.dot |
494 | rm $1/depends.tmp | 483 | rm $1/depends.tmp |
495 | 484 | ||
485 | # Set correct pkgdatadir | ||
486 | pkgdatadir=${PKGDATA_DIR} | ||
487 | if [ "$2" = "sdk" ] && [ "$3" = "host" ] ; then | ||
488 | pkgdatadir="${PKGDATA_DIR_SDK}" | ||
489 | fi | ||
490 | |||
496 | # Produce installed package sizes list | 491 | # Produce installed package sizes list |
497 | oe-pkgdata-util -p ${PKGDATA_DIR} read-value "PKGSIZE" -n -f $pkgcache > $1/installed-package-sizes.tmp | 492 | oe-pkgdata-util -p $pkgdatadir read-value "PKGSIZE" -n -f $pkgcache > $1/installed-package-sizes.tmp |
498 | cat $1/installed-package-sizes.tmp | awk '{print $2 "\tKiB\t" $1}' | sort -n -r > $1/installed-package-sizes.txt | 493 | cat $1/installed-package-sizes.tmp | awk '{print $2 "\tKiB\t" $1}' | sort -n -r > $1/installed-package-sizes.txt |
499 | rm $1/installed-package-sizes.tmp | 494 | rm $1/installed-package-sizes.tmp |
500 | 495 | ||
496 | # Produce package info: runtime_name, buildtime_name, recipe, version, size | ||
497 | oe-pkgdata-util -p $pkgdatadir read-value "PACKAGE,PN,PV,PKGSIZE" -n -f $pkgcache > $1/installed-package-info.tmp | ||
498 | cat $1/installed-package-info.tmp | sort -n -r -k 5 > $1/installed-package-info.txt | ||
499 | rm $1/installed-package-info.tmp | ||
500 | |||
501 | # We're now done with the cache, delete it | 501 | # We're now done with the cache, delete it |
502 | rm $pkgcache | 502 | rm $pkgcache |
503 | 503 | ||
@@ -509,7 +509,7 @@ buildhistory_get_installed() { | |||
509 | 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 |
510 | fi | 510 | fi |
511 | 511 | ||
512 | # add complementary package information | 512 | # Add complementary package information |
513 | if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then | 513 | if [ -e ${WORKDIR}/complementary_pkgs.txt ]; then |
514 | cp ${WORKDIR}/complementary_pkgs.txt $1 | 514 | cp ${WORKDIR}/complementary_pkgs.txt $1 |
515 | fi | 515 | fi |
@@ -534,7 +534,7 @@ buildhistory_get_sdk_installed() { | |||
534 | return | 534 | return |
535 | fi | 535 | fi |
536 | 536 | ||
537 | buildhistory_get_installed ${BUILDHISTORY_DIR_SDK}/$1 sdk | 537 | buildhistory_get_installed ${BUILDHISTORY_DIR_SDK}/$1 sdk $1 |
538 | } | 538 | } |
539 | 539 | ||
540 | buildhistory_get_sdk_installed_host() { | 540 | buildhistory_get_sdk_installed_host() { |
@@ -547,7 +547,7 @@ buildhistory_get_sdk_installed_target() { | |||
547 | 547 | ||
548 | buildhistory_list_files() { | 548 | buildhistory_list_files() { |
549 | # 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. |
550 | # 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 |
551 | ( cd $1 | 551 | ( cd $1 |
552 | 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"' |
553 | if [ "$3" = "fakeroot" ] ; then | 553 | if [ "$3" = "fakeroot" ] ; then |
@@ -561,7 +561,7 @@ buildhistory_list_files_no_owners() { | |||
561 | # 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. |
562 | # 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 |
563 | # that the same parsing code as for _list_files works. | 563 | # that the same parsing code as for _list_files works. |
564 | # 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 |
565 | ( cd $1 | 565 | ( cd $1 |
566 | find_cmd='find . ! -path . -printf "%M - - %10s %p -> %l\n"' | 566 | find_cmd='find . ! -path . -printf "%M - - %10s %p -> %l\n"' |
567 | if [ "$3" = "fakeroot" ] ; then | 567 | if [ "$3" = "fakeroot" ] ; then |
@@ -572,16 +572,17 @@ buildhistory_list_files_no_owners() { | |||
572 | } | 572 | } |
573 | 573 | ||
574 | buildhistory_list_pkg_files() { | 574 | buildhistory_list_pkg_files() { |
575 | if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'package', '1', '0', d)}" = "0" ] ; then | ||
576 | return | ||
577 | fi | ||
578 | |||
575 | # Create individual files-in-package for each recipe's package | 579 | # Create individual files-in-package for each recipe's package |
576 | for pkgdir in $(find ${PKGDEST}/* -maxdepth 0 -type d); do | 580 | pkgdirlist=$(find ${PKGDEST}/* -maxdepth 0 -type d) |
581 | for pkgdir in $pkgdirlist; do | ||
577 | pkgname=$(basename $pkgdir) | 582 | pkgname=$(basename $pkgdir) |
578 | outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname" | 583 | outfolder="${BUILDHISTORY_DIR_PACKAGE}/$pkgname" |
579 | outfile="$outfolder/files-in-package.txt" | 584 | outfile="$outfolder/files-in-package.txt" |
580 | # Make sure the output folder exists so we can create the file | 585 | mkdir -p $outfolder |
581 | if [ ! -d $outfolder ] ; then | ||
582 | bbdebug 2 "Folder $outfolder does not exist, file $outfile not created" | ||
583 | continue | ||
584 | fi | ||
585 | buildhistory_list_files $pkgdir $outfile fakeroot | 586 | buildhistory_list_files $pkgdir $outfile fakeroot |
586 | done | 587 | done |
587 | } | 588 | } |
@@ -665,26 +666,29 @@ python buildhistory_get_extra_sdkinfo() { | |||
665 | 666 | ||
666 | # By using ROOTFS_POSTUNINSTALL_COMMAND we get in after uninstallation of | 667 | # By using ROOTFS_POSTUNINSTALL_COMMAND we get in after uninstallation of |
667 | # unneeded packages but before the removal of packaging files | 668 | # unneeded packages but before the removal of packaging files |
668 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_list_installed_image ;" | 669 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_list_installed_image" |
669 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_get_image_installed ;" | 670 | ROOTFS_POSTUNINSTALL_COMMAND += "buildhistory_get_image_installed" |
670 | ROOTFS_POSTUNINSTALL_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_image ;| buildhistory_get_image_installed ;" | 671 | ROOTFS_POSTUNINSTALL_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_image| buildhistory_get_image_installed" |
671 | ROOTFS_POSTUNINSTALL_COMMAND[vardepsexclude] += "buildhistory_list_installed_image buildhistory_get_image_installed" | 672 | ROOTFS_POSTUNINSTALL_COMMAND[vardepsexclude] += "buildhistory_list_installed_image buildhistory_get_image_installed" |
672 | 673 | ||
673 | IMAGE_POSTPROCESS_COMMAND += "buildhistory_get_imageinfo ;" | 674 | IMAGE_POSTPROCESS_COMMAND += "buildhistory_get_imageinfo" |
674 | IMAGE_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_imageinfo ;" | 675 | IMAGE_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_imageinfo" |
675 | IMAGE_POSTPROCESS_COMMAND[vardepsexclude] += "buildhistory_get_imageinfo" | 676 | IMAGE_POSTPROCESS_COMMAND[vardepsexclude] += "buildhistory_get_imageinfo" |
676 | 677 | ||
677 | # We want these to be the last run so that we get called after complementary package installation | 678 | # We want these to be the last run so that we get called after complementary package installation |
678 | POPULATE_SDK_POST_TARGET_COMMAND_append = " buildhistory_list_installed_sdk_target;" | 679 | POPULATE_SDK_POST_TARGET_COMMAND:append = " buildhistory_list_installed_sdk_target" |
679 | POPULATE_SDK_POST_TARGET_COMMAND_append = " buildhistory_get_sdk_installed_target;" | 680 | POPULATE_SDK_POST_TARGET_COMMAND:append = " buildhistory_get_sdk_installed_target" |
680 | POPULATE_SDK_POST_TARGET_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_target;| buildhistory_get_sdk_installed_target;" | 681 | POPULATE_SDK_POST_TARGET_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_target| buildhistory_get_sdk_installed_target" |
682 | POPULATE_SDK_POST_TARGET_COMMAND[vardepsexclude] += "buildhistory_list_installed_sdk_target buildhistory_get_sdk_installed_target" | ||
681 | 683 | ||
682 | POPULATE_SDK_POST_HOST_COMMAND_append = " buildhistory_list_installed_sdk_host;" | 684 | POPULATE_SDK_POST_HOST_COMMAND:append = " buildhistory_list_installed_sdk_host" |
683 | POPULATE_SDK_POST_HOST_COMMAND_append = " buildhistory_get_sdk_installed_host;" | 685 | POPULATE_SDK_POST_HOST_COMMAND:append = " buildhistory_get_sdk_installed_host" |
684 | POPULATE_SDK_POST_HOST_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_host;| buildhistory_get_sdk_installed_host;" | 686 | POPULATE_SDK_POST_HOST_COMMAND[vardepvalueexclude] .= "| buildhistory_list_installed_sdk_host| buildhistory_get_sdk_installed_host" |
687 | POPULATE_SDK_POST_HOST_COMMAND[vardepsexclude] += "buildhistory_list_installed_sdk_host buildhistory_get_sdk_installed_host" | ||
685 | 688 | ||
686 | SDK_POSTPROCESS_COMMAND_append = " buildhistory_get_sdkinfo ; buildhistory_get_extra_sdkinfo; " | 689 | SDK_POSTPROCESS_COMMAND:append = " buildhistory_get_sdkinfo buildhistory_get_extra_sdkinfo" |
687 | SDK_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_sdkinfo ; buildhistory_get_extra_sdkinfo; " | 690 | SDK_POSTPROCESS_COMMAND[vardepvalueexclude] .= "| buildhistory_get_sdkinfo buildhistory_get_extra_sdkinfo" |
691 | SDK_POSTPROCESS_COMMAND[vardepsexclude] += "buildhistory_get_sdkinfo buildhistory_get_extra_sdkinfo" | ||
688 | 692 | ||
689 | python buildhistory_write_sigs() { | 693 | python buildhistory_write_sigs() { |
690 | if not "task" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): | 694 | if not "task" in (d.getVar('BUILDHISTORY_FEATURES') or "").split(): |
@@ -694,7 +698,7 @@ python buildhistory_write_sigs() { | |||
694 | if hasattr(bb.parse.siggen, 'dump_siglist'): | 698 | if hasattr(bb.parse.siggen, 'dump_siglist'): |
695 | taskoutdir = os.path.join(d.getVar('BUILDHISTORY_DIR'), 'task') | 699 | taskoutdir = os.path.join(d.getVar('BUILDHISTORY_DIR'), 'task') |
696 | bb.utils.mkdirhier(taskoutdir) | 700 | bb.utils.mkdirhier(taskoutdir) |
697 | bb.parse.siggen.dump_siglist(os.path.join(taskoutdir, 'tasksigs.txt')) | 701 | bb.parse.siggen.dump_siglist(os.path.join(taskoutdir, 'tasksigs.txt'), d.getVar("BUILDHISTORY_PATH_PREFIX_STRIP")) |
698 | } | 702 | } |
699 | 703 | ||
700 | def buildhistory_get_build_id(d): | 704 | def buildhistory_get_build_id(d): |
@@ -714,30 +718,10 @@ def buildhistory_get_build_id(d): | |||
714 | statusheader = d.getVar('BUILDCFG_HEADER') | 718 | statusheader = d.getVar('BUILDCFG_HEADER') |
715 | return('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) | 719 | return('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) |
716 | 720 | ||
717 | def buildhistory_get_modified(path): | ||
718 | # copied from get_layer_git_status() in image-buildinfo.bbclass | ||
719 | import subprocess | ||
720 | try: | ||
721 | subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e; | ||
722 | git diff --quiet --no-ext-diff | ||
723 | git diff --quiet --no-ext-diff --cached""" % path, | ||
724 | shell=True, | ||
725 | stderr=subprocess.STDOUT) | ||
726 | return "" | ||
727 | except subprocess.CalledProcessError as ex: | ||
728 | # Silently treat errors as "modified", without checking for the | ||
729 | # (expected) return code 1 in a modified git repo. For example, we get | ||
730 | # output and a 129 return code when a layer isn't a git repo at all. | ||
731 | return " -- modified" | ||
732 | |||
733 | def buildhistory_get_metadata_revs(d): | 721 | def buildhistory_get_metadata_revs(d): |
734 | # We want an easily machine-readable format here, so get_layers_branch_rev isn't quite what we want | 722 | # We want an easily machine-readable format here |
735 | layers = (d.getVar("BBLAYERS") or "").split() | 723 | revisions = oe.buildcfg.get_layer_revisions(d) |
736 | medadata_revs = ["%-17s = %s:%s%s" % (os.path.basename(i), \ | 724 | medadata_revs = ["%-17s = %s:%s%s" % (r[1], r[2], r[3], r[4]) for r in revisions] |
737 | base_get_metadata_git_branch(i, None).strip(), \ | ||
738 | base_get_metadata_git_revision(i, None), \ | ||
739 | buildhistory_get_modified(i)) \ | ||
740 | for i in layers] | ||
741 | return '\n'.join(medadata_revs) | 725 | return '\n'.join(medadata_revs) |
742 | 726 | ||
743 | def outputvars(vars, listvars, d): | 727 | def outputvars(vars, listvars, d): |
@@ -762,11 +746,11 @@ def buildhistory_get_imagevars(d): | |||
762 | def buildhistory_get_sdkvars(d): | 746 | def buildhistory_get_sdkvars(d): |
763 | if d.getVar('BB_WORKERCONTEXT') != '1': | 747 | if d.getVar('BB_WORKERCONTEXT') != '1': |
764 | return "" | 748 | return "" |
765 | sdkvars = "DISTRO DISTRO_VERSION SDK_NAME SDK_VERSION SDKMACHINE SDKIMAGE_FEATURES BAD_RECOMMENDATIONS NO_RECOMMENDATIONS PACKAGE_EXCLUDE" | 749 | sdkvars = "DISTRO DISTRO_VERSION SDK_NAME SDK_VERSION SDKMACHINE SDKIMAGE_FEATURES TOOLCHAIN_HOST_TASK TOOLCHAIN_TARGET_TASK BAD_RECOMMENDATIONS NO_RECOMMENDATIONS PACKAGE_EXCLUDE" |
766 | if d.getVar('BB_CURRENTTASK') == 'populate_sdk_ext': | 750 | if d.getVar('BB_CURRENTTASK') == 'populate_sdk_ext': |
767 | # Extensible SDK uses some additional variables | 751 | # Extensible SDK uses some additional variables |
768 | sdkvars += " SDK_LOCAL_CONF_WHITELIST SDK_LOCAL_CONF_BLACKLIST SDK_INHERIT_BLACKLIST SDK_UPDATE_URL SDK_EXT_TYPE SDK_RECRDEP_TASKS SDK_INCLUDE_PKGDATA SDK_INCLUDE_TOOLCHAIN" | 752 | sdkvars += " ESDK_LOCALCONF_ALLOW ESDK_LOCALCONF_REMOVE ESDK_CLASS_INHERIT_DISABLE SDK_UPDATE_URL SDK_EXT_TYPE SDK_RECRDEP_TASKS SDK_INCLUDE_PKGDATA SDK_INCLUDE_TOOLCHAIN" |
769 | listvars = "SDKIMAGE_FEATURES BAD_RECOMMENDATIONS PACKAGE_EXCLUDE SDK_LOCAL_CONF_WHITELIST SDK_LOCAL_CONF_BLACKLIST SDK_INHERIT_BLACKLIST" | 753 | listvars = "SDKIMAGE_FEATURES BAD_RECOMMENDATIONS PACKAGE_EXCLUDE ESDK_LOCALCONF_ALLOW ESDK_LOCALCONF_REMOVE ESDK_CLASS_INHERIT_DISABLE" |
770 | return outputvars(sdkvars, listvars, d) | 754 | return outputvars(sdkvars, listvars, d) |
771 | 755 | ||
772 | 756 | ||
@@ -833,9 +817,9 @@ END | |||
833 | if [ ! -e .git ] ; then | 817 | if [ ! -e .git ] ; then |
834 | git init -q | 818 | git init -q |
835 | else | 819 | else |
836 | 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 |
837 | 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 |
838 | 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 |
839 | fi | 823 | fi |
840 | 824 | ||
841 | check_git_config | 825 | check_git_config |
@@ -846,10 +830,9 @@ END | |||
846 | CMDLINE="${@buildhistory_get_cmdline(d)}" | 830 | CMDLINE="${@buildhistory_get_cmdline(d)}" |
847 | if [ "$repostatus" != "" ] ; then | 831 | if [ "$repostatus" != "" ] ; then |
848 | git add -A . | 832 | git add -A . |
849 | # porcelain output looks like "?? packages/foo/bar" | 833 | # Porcelain output looks like "?? packages/foo/bar" |
850 | # Ensure we commit metadata-revs with the first commit | 834 | # Ensure we commit metadata-revs with the first commit |
851 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" dummy | 835 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" dummy |
852 | git gc --auto --quiet | ||
853 | else | 836 | else |
854 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" | 837 | buildhistory_single_commit "$CMDLINE" "$HOSTNAME" |
855 | fi | 838 | fi |
@@ -860,24 +843,7 @@ END | |||
860 | 843 | ||
861 | python buildhistory_eventhandler() { | 844 | python buildhistory_eventhandler() { |
862 | if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip(): | 845 | if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip(): |
863 | reset = e.data.getVar("BUILDHISTORY_RESET") | 846 | if isinstance(e, bb.event.BuildCompleted): |
864 | olddir = e.data.getVar("BUILDHISTORY_OLD_DIR") | ||
865 | if isinstance(e, bb.event.BuildStarted): | ||
866 | if reset: | ||
867 | import shutil | ||
868 | # Clean up after potentially interrupted build. | ||
869 | if os.path.isdir(olddir): | ||
870 | shutil.rmtree(olddir) | ||
871 | rootdir = e.data.getVar("BUILDHISTORY_DIR") | ||
872 | entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ] | ||
873 | bb.utils.mkdirhier(olddir) | ||
874 | for entry in entries: | ||
875 | os.rename(os.path.join(rootdir, entry), | ||
876 | os.path.join(olddir, entry)) | ||
877 | elif isinstance(e, bb.event.BuildCompleted): | ||
878 | if reset: | ||
879 | import shutil | ||
880 | shutil.rmtree(olddir) | ||
881 | if e.data.getVar("BUILDHISTORY_COMMIT") == "1": | 847 | if e.data.getVar("BUILDHISTORY_COMMIT") == "1": |
882 | bb.note("Writing buildhistory") | 848 | bb.note("Writing buildhistory") |
883 | bb.build.exec_func("buildhistory_write_sigs", d) | 849 | bb.build.exec_func("buildhistory_write_sigs", d) |
@@ -911,27 +877,16 @@ def _get_srcrev_values(d): | |||
911 | if urldata[u].method.supports_srcrev(): | 877 | if urldata[u].method.supports_srcrev(): |
912 | scms.append(u) | 878 | scms.append(u) |
913 | 879 | ||
914 | autoinc_templ = 'AUTOINC+' | ||
915 | dict_srcrevs = {} | 880 | dict_srcrevs = {} |
916 | dict_tag_srcrevs = {} | 881 | dict_tag_srcrevs = {} |
917 | for scm in scms: | 882 | for scm in scms: |
918 | ud = urldata[scm] | 883 | ud = urldata[scm] |
919 | for name in ud.names: | 884 | autoinc, rev = ud.method.sortable_revision(ud, d, ud.name) |
920 | try: | 885 | dict_srcrevs[ud.name] = rev |
921 | rev = ud.method.sortable_revision(ud, d, name) | 886 | if 'tag' in ud.parm: |
922 | except TypeError: | 887 | tag = ud.parm['tag']; |
923 | # support old bitbake versions | 888 | key = ud.name+'_'+tag |
924 | rev = ud.method.sortable_revision(scm, ud, d, name) | 889 | dict_tag_srcrevs[key] = rev |
925 | # Clean this up when we next bump bitbake version | ||
926 | if type(rev) != str: | ||
927 | autoinc, rev = rev | ||
928 | elif rev.startswith(autoinc_templ): | ||
929 | rev = rev[len(autoinc_templ):] | ||
930 | dict_srcrevs[name] = rev | ||
931 | if 'tag' in ud.parm: | ||
932 | tag = ud.parm['tag']; | ||
933 | key = name+'_'+tag | ||
934 | dict_tag_srcrevs[key] = rev | ||
935 | return (dict_srcrevs, dict_tag_srcrevs) | 890 | return (dict_srcrevs, dict_tag_srcrevs) |
936 | 891 | ||
937 | do_fetch[postfuncs] += "write_srcrev" | 892 | do_fetch[postfuncs] += "write_srcrev" |
@@ -957,23 +912,19 @@ def write_latest_srcrev(d, pkghistdir): | |||
957 | value = value.replace('"', '').strip() | 912 | value = value.replace('"', '').strip() |
958 | old_tag_srcrevs[key] = value | 913 | old_tag_srcrevs[key] = value |
959 | with open(srcrevfile, 'w') as f: | 914 | with open(srcrevfile, 'w') as f: |
960 | orig_srcrev = d.getVar('SRCREV', False) or 'INVALID' | 915 | for name, srcrev in sorted(srcrevs.items()): |
961 | if orig_srcrev != 'INVALID': | 916 | suffix = "_" + name |
962 | f.write('# SRCREV = "%s"\n' % orig_srcrev) | 917 | if name == "default": |
963 | if len(srcrevs) > 1: | 918 | suffix = "" |
964 | for name, srcrev in sorted(srcrevs.items()): | 919 | orig_srcrev = d.getVar('SRCREV%s' % suffix, False) |
965 | orig_srcrev = d.getVar('SRCREV_%s' % name, False) | 920 | if orig_srcrev: |
966 | if orig_srcrev: | 921 | f.write('# SRCREV%s = "%s"\n' % (suffix, orig_srcrev)) |
967 | f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev)) | 922 | f.write('SRCREV%s = "%s"\n' % (suffix, srcrev)) |
968 | f.write('SRCREV_%s = "%s"\n' % (name, srcrev)) | 923 | for name, srcrev in sorted(tag_srcrevs.items()): |
969 | else: | 924 | f.write('# tag_%s = "%s"\n' % (name, srcrev)) |
970 | f.write('SRCREV = "%s"\n' % next(iter(srcrevs.values()))) | 925 | if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev: |
971 | if len(tag_srcrevs) > 0: | 926 | pkg = d.getVar('PN') |
972 | for name, srcrev in sorted(tag_srcrevs.items()): | 927 | bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev)) |
973 | f.write('# tag_%s = "%s"\n' % (name, srcrev)) | ||
974 | if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev: | ||
975 | pkg = d.getVar('PN') | ||
976 | bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev)) | ||
977 | 928 | ||
978 | else: | 929 | else: |
979 | if os.path.exists(srcrevfile): | 930 | if os.path.exists(srcrevfile): |
@@ -994,7 +945,7 @@ def write_latest_ptest_result(d, histdir): | |||
994 | output_ptest = os.path.join(histdir, 'ptest') | 945 | output_ptest = os.path.join(histdir, 'ptest') |
995 | if os.path.exists(input_ptest): | 946 | if os.path.exists(input_ptest): |
996 | try: | 947 | try: |
997 | # Lock it avoid race issue | 948 | # Lock it to avoid race issue |
998 | lock = bb.utils.lockfile(output_ptest + "/ptest.lock") | 949 | lock = bb.utils.lockfile(output_ptest + "/ptest.lock") |
999 | bb.utils.mkdirhier(output_ptest) | 950 | bb.utils.mkdirhier(output_ptest) |
1000 | oe.path.copytree(input_ptest, output_ptest) | 951 | oe.path.copytree(input_ptest, output_ptest) |