From: Julien Stephan <jstephan@baylibre.com>
To: openembedded-core@lists.openembedded.org
Cc: Julien Stephan <jstephan@baylibre.com>
Subject: [RFC 1/1] scripts/bblock: add a script to lock/unlock recipes
Date: Wed, 19 Jul 2023 16:27:58 +0200 [thread overview]
Message-ID: <20230719142758.84540-2-jstephan@baylibre.com> (raw)
In-Reply-To: <20230719142758.84540-1-jstephan@baylibre.com>
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
diff --git a/scripts/bblock b/scripts/bblock
new file mode 100755
index 00000000000..d463ade6212
--- /dev/null
+++ b/scripts/bblock
@@ -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)
--
2.41.0
next prev parent reply other threads:[~2023-07-19 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 14:27 [RFC 0/1] Add bblock helper script Julien Stephan
2023-07-19 14:27 ` Julien Stephan [this message]
2023-07-19 14:59 ` [OE-core] " Richard Purdie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230719142758.84540-2-jstephan@baylibre.com \
--to=jstephan@baylibre.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox