diff mbox series

[1/2] devtool: standard: fix finish/update-recipe for recipes using AUTOREV

Message ID 20260713060444.7-2-bbnpreetsingh@gmail.com
State New
Headers show
Series devtool: fix finish for recipes using AUTOREV | expand

Commit Message

Babanpreet Singh July 13, 2026, 6:04 a.m. UTC
For a recipe with SRCREV = "${AUTOREV}" (e.g. created by devtool add
--autorev), devtool finish and devtool update-recipe in srcrev mode
crash:

    INFO: Updating SRCREV in recipe minit_git.bb
    ...
    oe.patch.CmdError: Command Error: 'git format-patch --no-signature
    --no-numbered AUTOINC -o /tmp/oepatchxu0ig0v0 -- .' exited with 128
    Output: stderr: fatal: bad revision 'AUTOINC'

_update_recipe_srcrev() uses the recipe's SRCREV as the base revision
for exporting patches from the source tree, but for AUTOREV recipes
getVar('SRCREV') expands to the literal placeholder "AUTOINC", which is
not a valid git revision. Use the initial revision(s) recorded in the
workspace bbappend instead, as patch mode already does via
_get_patchset_revs().

Do not replace SRCREV with the current source tree HEAD for such
recipes either: pinning the revision on finish would silently drop the
floating revision the user explicitly asked for.

This is not a recent regression: the same crash reproduces at least as
far back as kirkstone, so it most likely dates back to the introduction
of devtool add --autorev.

[YOCTO #16354]

Reported-by: Gyorgy Sarvari <skandigraun@gmail.com>
AI-Generated: Uses Claude (claude-sonnet-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
 scripts/lib/devtool/standard.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 2a3a62d081..386e628d88 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1530,7 +1530,18 @@  def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi
     old_srcrev = rd.getVar('SRCREV') or ''
     if old_srcrev == "INVALID":
             raise DevtoolError('Update mode srcrev is only valid for recipe fetched from an SCM repository')
-    old_srcrev = {'.': old_srcrev}
+    autorev = old_srcrev == 'AUTOINC'
+    if autorev:
+        # SRCREV is set to "${AUTOREV}" so there is no fixed revision to
+        # use as the base for exporting patches; use the initial revision(s)
+        # recorded when the source tree was set up, as patch mode does
+        append = workspace[recipename]['bbappend']
+        old_srcrev, _, _, _ = _get_patchset_revs(srctree, append)
+        if not old_srcrev:
+            raise DevtoolError('Unable to find the initial revision of the '
+                               'source tree for %s in the workspace' % recipename)
+    else:
+        old_srcrev = {'.': old_srcrev}
 
     # Get HEAD revision
     try:
@@ -1545,7 +1556,8 @@  def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi
     destpath = None
     remove_files = []
     patchfields = {}
-    patchfields['SRCREV'] = srcrev
+    if not autorev:
+        patchfields['SRCREV'] = srcrev
     orig_src_uri = rd.getVar('SRC_URI', False) or ''
     srcuri = orig_src_uri.split()
     tempdir = tempfile.mkdtemp(prefix='devtool')