diff mbox series

[10/16] devtool: Prefer workspace recipes now layer priorities are gone

Message ID 20261130152704.3471590-10-richard.purdie@linuxfoundation.org
State New
Headers show
Series [01/16] bitbake/base: Implement RECIPE_HOSTTOOLS | expand

Commit Message

Richard Purdie Nov. 30, 2026, 3:26 p.m. UTC
The workspace layer's priority of 99 used to ensure recipes from devtool
add and devtool upgrade were used over any other recipe with the same name.
Without priorities an equal or higher version elsewhere now wins, for
example devtool add of i2c-tools 3.1.2 picked up OE-Core's 4.4 in
test_devtool_rename. Set DEFAULT_PREFERENCE in the bbappend devtool writes
for these recipes, which only applies to the workspace's version of the
recipe and is removed by devtool finish/reset.

Tested that a lower version workspace recipe is now selected.

AI-Generated: Uses Claude Opus 5.5
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/lib/devtool/__init__.py | 6 ++++++
 scripts/lib/devtool/standard.py | 3 ++-
 scripts/lib/devtool/upgrade.py  | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index ff32cf115f8..5a9ac5cd005 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -26,6 +26,12 @@  WORKSPACE_LAYERDEPENDS = 'oe-core'
 # to match that pattern.
 WORKSPACE_APPENDS_DIR = 'recipes-appends'
 
+# Written to the bbappend for recipes which live in the workspace (from
+# 'devtool add' and 'devtool upgrade'). Layers no longer have priorities so
+# without this a recipe elsewhere with the same name and an equal or higher
+# version would be used instead.
+WORKSPACE_PREFERENCE_LINES = 'DEFAULT_PREFERENCE = "99"\n'
+
 def get_workspace_appends_dir(workspace_path):
     """Return the directory within the workspace layer holding bbappends"""
     return os.path.join(workspace_path, WORKSPACE_APPENDS_DIR)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 37ee404c176..ca90e8089ea 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -21,7 +21,7 @@  import glob
 from collections import OrderedDict
 
 from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, setup_git_repo, recipe_to_append, get_bbclassextend_targets, update_unlockedsigs, check_prerelease_version, check_git_repo_dirty, check_git_repo_op, DevtoolError
-from devtool import parse_recipe, get_workspace_appends_dir
+from devtool import parse_recipe, get_workspace_appends_dir, WORKSPACE_PREFERENCE_LINES
 
 import bb.utils
 
@@ -255,6 +255,7 @@  def add(args, config, basepath, workspace):
         with open(appendfile, 'w') as f:
             f.write('inherit externalsrc\n')
             f.write('EXTERNALSRC = "%s"\n' % srctree)
+            f.write(WORKSPACE_PREFERENCE_LINES)
 
             b_is_s = use_external_build(args.same_dir, args.no_same_dir, rd)
             if b_is_s:
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 1923b5a7b6b..3b5db4f2bf0 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -26,7 +26,7 @@  sys.path = sys.path + [devtool_path]
 
 import oe.recipeutils
 from devtool import standard
-from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build, update_unlockedsigs, check_prerelease_version, get_workspace_appends_dir
+from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build, update_unlockedsigs, check_prerelease_version, get_workspace_appends_dir, WORKSPACE_PREFERENCE_LINES
 
 logger = logging.getLogger('devtool')
 
@@ -158,6 +158,7 @@  def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, revs, copied,
         f.write(('# NOTE: We use pn- overrides here to avoid affecting'
                  'multiple variants in the case where the recipe uses BBCLASSEXTEND\n'))
         f.write('EXTERNALSRC:pn-%s = "%s"\n' % (pn, srctree))
+        f.write(WORKSPACE_PREFERENCE_LINES)
         b_is_s = use_external_build(same_dir, no_same_dir, d)
         if b_is_s:
             f.write('EXTERNALSRC_BUILD:pn-%s = "%s"\n' % (pn, srctree))