BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
-# Setting this to non-empty will remove the old content of the buildhistory as part of
-# the current bitbake invocation and replace it with information about what was built
-# during the build.
-#
-# This is meant to be used in continuous integration (CI) systems when invoking bitbake
-# for full world builds. The effect in that case is that information about packages
-# that no longer get build also gets removed from the buildhistory, which is not
-# the case otherwise.
-#
-# The advantage over manually cleaning the buildhistory outside of bitbake is that
-# the "version-going-backwards" check still works. When relying on that, be careful
-# about failed world builds: they will lead to incomplete information in the
-# buildhistory because information about packages that could not be built will
-# also get removed. A CI system should handle that by discarding the buildhistory
-# of failed builds.
-#
-# The expected usage is via auto.conf, but passing via the command line also works
-# with: BB_ENV_PASSTHROUGH_ADDITIONS=BUILDHISTORY_RESET BUILDHISTORY_RESET=1
-BUILDHISTORY_RESET ?= ""
-
-BUILDHISTORY_OLD_DIR = "${BUILDHISTORY_DIR}/${@ "old" if "${BUILDHISTORY_RESET}" else ""}"
-BUILDHISTORY_OLD_DIR_PACKAGE = "${BUILDHISTORY_OLD_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
BUILDHISTORY_DIR_SDK = "${BUILDHISTORY_DIR}/sdk/${SDK_NAME}${SDK_EXT}/${IMAGE_BASENAME}"
BUILDHISTORY_IMAGE_FILES ?= "/etc/passwd /etc/group"
BUILDHISTORY_SDK_FILES ?= "conf/local.conf conf/bblayers.conf conf/auto.conf conf/locked-sigs.inc conf/devtool.conf"
# necessary because some of these items (package directories, files that
# we no longer emit) might be obsolete.
#
-# When extending build history, derive your class from buildhistory.bbclass
-# and extend this list here with the additional files created by the derived
-# class.
+# The files listed here are either written by tasks that aren't do_package (e.g.
+# latest_srcrev from do_fetch) so do_package must not remove them, or, they're
+# used to read values in do_package before always being overwritten, e.g. latest,
+# for version backwards checks.
BUILDHISTORY_PRESERVE = "latest latest_srcrev sysroot"
PATCH_GIT_USER_EMAIL ?= "buildhistory@oe"
return 0
pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
- oldpkghistdir = d.getVar('BUILDHISTORY_OLD_DIR_PACKAGE')
class RecipeInfo:
def __init__(self, name):
def getlastpkgversion(pkg):
try:
- histfile = os.path.join(oldpkghistdir, pkg, "latest")
+ histfile = os.path.join(pkghistdir, pkg, "latest")
return readPackageInfo(pkg, histfile)
except EnvironmentError:
return None
items.sort()
return ' '.join(items)
- def preservebuildhistoryfiles(pkg, preserve):
- if os.path.exists(os.path.join(oldpkghistdir, pkg)):
- listofobjs = os.listdir(os.path.join(oldpkghistdir, pkg))
- for obj in listofobjs:
- if obj not in preserve:
- continue
- try:
- bb.utils.mkdirhier(os.path.join(pkghistdir, pkg))
- shutil.copyfile(os.path.join(oldpkghistdir, pkg, obj), os.path.join(pkghistdir, pkg, obj))
- except IOError as e:
- bb.note("Unable to copy file. %s" % e)
- except EnvironmentError as e:
- bb.note("Unable to copy file. %s" % e)
-
pn = d.getVar('PN')
pe = d.getVar('PE') or "0"
pv = d.getVar('PV')
if not os.path.exists(pkghistdir):
bb.utils.mkdirhier(pkghistdir)
else:
- # We need to make sure that all files kept in
- # buildhistory/old are restored successfully
- # otherwise next block of code wont have files to
- # check and purge
- if d.getVar("BUILDHISTORY_RESET"):
- for pkg in packagelist:
- preservebuildhistoryfiles(pkg, preserve)
-
# Remove files for packages that no longer exist
for item in os.listdir(pkghistdir):
if item not in preserve:
python buildhistory_eventhandler() {
if (e.data.getVar('BUILDHISTORY_FEATURES') or "").strip():
- reset = e.data.getVar("BUILDHISTORY_RESET")
- olddir = e.data.getVar("BUILDHISTORY_OLD_DIR")
- if isinstance(e, bb.event.BuildStarted):
- if reset:
- import shutil
- # Clean up after potentially interrupted build.
- if os.path.isdir(olddir):
- shutil.rmtree(olddir)
- rootdir = e.data.getVar("BUILDHISTORY_DIR")
- bb.utils.mkdirhier(rootdir)
- entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
- bb.utils.mkdirhier(olddir)
- for entry in entries:
- bb.utils.rename(os.path.join(rootdir, entry),
- os.path.join(olddir, entry))
- elif isinstance(e, bb.event.BuildCompleted):
- if reset:
- import shutil
- shutil.rmtree(olddir)
+ if isinstance(e, bb.event.BuildCompleted):
if e.data.getVar("BUILDHISTORY_COMMIT") == "1":
bb.note("Writing buildhistory")
bb.build.exec_func("buildhistory_write_sigs", d)