diff mbox series

[v3,1/5] devtool upgrade: enable RECIPE_UPDATE_EXTRA_TASKS

Message ID 20240612172847.3487329-3-tim.orling@konsulko.com
State New
Headers show
Series [v3,1/5] devtool upgrade: enable RECIPE_UPDATE_EXTRA_TASKS | expand

Commit Message

Tim Orling June 12, 2024, 5:28 p.m. UTC
From: Tim Orling <tim.orling@konsulko.com>

For some recipes, such as those that inherit cargo-update-recipe-crates,
we need to run additional tasks once the new sources have been unpacked.

Introduce a new variable RECIPE_UPDATE_EXTRA_TASKS which is a space-
delimited list of tasks to run after the new sources have been
unpacked in scripts/lib/devtool/upgrade.py ugrade() method.

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
Changes in v3:
  * Address rburton review comment
  * Since the variable is recipe scoped (as is the class being tested),
    we do not need the :${PN} appended to RECIPE_UPDATE_EXTRA_TASKS

Changes in v2:
  * Drop the try/except in the _run_recipe_update_extra_tasks method
  * Check the result of each task (tinfoil.build_targets) and raise
    a DevtoolError on failure

 scripts/lib/devtool/upgrade.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index a8130ed23f5..8e13833b51c 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -534,6 +534,15 @@  def _generate_license_diff(old_licenses, new_licenses):
             diff = diff + line
     return diff
 
+def _run_recipe_update_extra_tasks(pn, rd, tinfoil):
+    tasks = []
+    for task in (rd.getVar('RECIPE_UPDATE_EXTRA_TASKS') or '').split():
+        logger.info('Running extra recipe update task: %s' % task)
+        res = tinfoil.build_targets(pn, task, handle_events=True)
+
+        if not res:
+            raise DevtoolError('Running extra recipe update task %s for %s failed' % (task, pn))
+
 def upgrade(args, config, basepath, workspace):
     """Entry point for the devtool 'upgrade' subcommand"""
 
@@ -609,6 +618,8 @@  def upgrade(args, config, basepath, workspace):
                         copied, config.workspace_path, rd)
         standard._add_md5(config, pn, af)
 
+        _run_recipe_update_extra_tasks(pn, rd, tinfoil)
+
         update_unlockedsigs(basepath, workspace, args.fixed_setup, [pn])
 
         logger.info('Upgraded source extracted to %s' % srctree)