new file mode 100755
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+# bblock
+# lock/unlock task to latest signature
+#
+# Copyright (c) 2020 BayLibre, SAS
+# Author: Julien Stepahn <jstephan@baylibre.com>
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import os
+import sys
+import logging
+
+scripts_path = os.path.dirname(os.path.realpath(__file__))
+lib_path = scripts_path + "/lib"
+sys.path = sys.path + [lib_path]
+
+import scriptpath
+
+scriptpath.add_bitbake_lib_path()
+
+import bb.tinfoil
+import bb.msg
+
+import argparse_oe
+
+myname = os.path.basename(sys.argv[0])
+logger = bb.msg.logger_create(myname)
+
+
+def find_siginfo(tinfoil, pn, taskname, sigs=None):
+ result = None
+ tinfoil.set_event_mask(
+ [
+ "bb.event.FindSigInfoResult",
+ "logging.LogRecord",
+ "bb.command.CommandCompleted",
+ "bb.command.CommandFailed",
+ ]
+ )
+ ret = tinfoil.run_command("findSigInfo", pn, taskname, sigs)
+ if ret:
+ while True:
+ event = tinfoil.wait_event(1)
+ if event:
+ if isinstance(event, bb.command.CommandCompleted):
+ break
+ elif isinstance(event, bb.command.CommandFailed):
+ logger.error(str(event))
+ sys.exit(2)
+ elif isinstance(event, bb.event.FindSigInfoResult):
+ result = event.result
+ elif isinstance(event, logging.LogRecord):
+ logger.handle(event)
+ else:
+ logger.error("No result returned from findSigInfo command")
+ sys.exit(2)
+ return result
+
+
+def main():
+ parser = argparse_oe.ArgumentParser(description="Lock and unlock a recipe")
+ parser.add_argument("pn", nargs="*", help="Space separated list of recipe to lock")
+
+ global_args, unparsed_args = parser.parse_known_args()
+
+ with bb.tinfoil.Tinfoil() as tinfoil:
+ tinfoil.prepare(config_only=True)
+ builddir = tinfoil.config_data.getVar("TOPDIR")
+ autoconffile = "{builddir}/conf/auto.conf".format(builddir=builddir)
+ lockfile = "{builddir}/conf/bblock.inc".format(builddir=builddir)
+ with open(lockfile, "a") as lockfile:
+ s = ""
+ if lockfile.tell() == 0:
+ s = "# Generated by bblock\n"
+ s += 'SIGGEN_LOCKEDSIGS_TYPES += "t-bblock"\n'
+ s += 'SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"'
+ with open(autoconffile, "a") as autoconffile:
+ autoconffile.write("require bblock.inc")
+ for pn in global_args.pn:
+ taskname = "do_compile"
+ filedates = find_siginfo(tinfoil, pn, taskname)
+ latestfiles = sorted(
+ filedates.keys(), key=lambda f: filedates[f], reverse=True
+ )
+ if not latestfiles:
+ logger.error(
+ "No sigdata files found matching {pn} {taskname}".format(
+ pn=pn, taskname=taskname
+ )
+ )
+ sys.exit(1)
+ sig = latestfiles[0].split("sigdata.")[1]
+ s += "\n"
+ s += 'SIGGEN_LOCKEDSIGS_t-bblock += "{pn}:{taskname}:{sig}"\n'.format(
+ pn=pn, taskname=taskname, sig=sig
+ )
+ lockfile.write(s)
+
+
+if __name__ == "__main__":
+ try:
+ ret = main()
+ except Exception:
+ ret = 1
+ import traceback
+
+ traceback.print_exc()
+ sys.exit(ret)
bblock script allows to lock recipes to latest signatures. The idea is to prevent some recipes to be rebuilt during development. For example when working on rust recipe, one may not want rust-native to be rebuilt. This tool can be used, with proper environment set up, using the following command: bblock <recipe_name> if <recipe_name>'s task signatures change it will not be built again and sstate cache will be used. [YOCTO #13425] Signed-off-by: Julien Stephan <jstephan@baylibre.com> --- scripts/bblock | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 scripts/bblock