siggen: Fix dump of non-runtime sigdata
PATCH 1/1 siggen: Fix dump of non-runtime sigdata
If the debug code is uncommented in SignatureGeneratorBasic.finalise(), sigtask stamp file are created without runtime data such as 'runtaskdeps' and 'file_checksum_values'. If we then try to run bitbake-dumpsig on one of these files, we will see a traceback as the expected keys are not present in the sigdata dictionary:
Traceback (most recent call last):
File ".../bitbake/bin/bitbake-dumpsig", line 195, in <module>
output = bb.siggen.dump_sigfile(options.sigdatafile1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../bitbake/lib/bb/siggen.py", line 1266, in dump_sigfile
computed_taskhash = calc_taskhash(a_data)
^^^^^^^^^^^^^^^^^^^^^
File ".../bitbake/lib/bb/siggen.py", line 1199, in calc_taskhash
for dep in sigdata['runtaskdeps']:
~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'runtaskdeps'To fix this, treat these entries as empty lists if they are not present.
---
Richard,
This patch attempts to fix an issue reported on IRC last week [1]. It prevents the traceback, but I'll have to defer to you on whether the taskhash calculated without 'runtimedeps' and 'file_checksum_values' is meaningful.
I guess an alternative approach would be to call calc_taskhash in a try block and not print out a task hash if the call fails.
Thanks!
--- lib/bb/siggen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/siggen.py +2 -2
@@ -1196,10 +1196,10 @@ def calc_basehash(sigdata): def calc_taskhash(sigdata): data = sigdata['basehash'] - for dep in sigdata['runtaskdeps']: + for dep in sigdata.get('runtaskdeps', []): data = data + sigdata['runtaskhashes'][dep] - for c in sigdata['file_checksum_values']: + for c in sigdata.get('file_checksum_values', []): if c[1]: if "./" in c[0]: data = data + c[0]
---
base-commit: 35a421cdcafb3595b9de5489ffdc567825400d26
change-id: 20251027-fix-dumpsig-e945637ad89f
Best regards,
Signature · 1 line
Paul Barker
Quoted 24 lines · Paul Barker
If the debug code is uncommented in
SignatureGeneratorBasic.finalise(), sigtask stamp file are created without runtime data such as 'runtaskdeps' and 'file_checksum_values'. If we then try to run bitbake-dumpsig on one of these files, we will see a traceback as the expected keys are not present in the sigdata dictionary:Traceback (most recent call last):
File ".../bitbake/bin/bitbake-dumpsig", line 195, in <module> output =bb.siggen.dump_sigfile(options.sigdatafile1)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../bitbake/lib/bb/siggen.py", line 1266, indump_sigfilecomputed_taskhash=calc_taskhash(a_data)^^^^^^^^^^^^^^^^^^^^^
File ".../bitbake/lib/bb/siggen.py", line 1199, incalc_taskhashfor dep in sigdata['runtaskdeps']:
~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'runtaskdeps'To fix this, treat these entries as empty lists if they are not present.
Signed-off-by Paul Barker <[email protected]>---
Richard,
Quoted 7 lines
This patch attempts to fix an issue reported on IRC last week [1]. It prevents the traceback, but I'll have to defer to you on whether the taskhash calculated without 'runtimedeps' and '
file_checksum_values' is meaningful.I guess an alternative approach would be to call
calc_taskhashin a try block and not print out a task hash if the call fails.
Rather than compute a hash which will never work, we should just skip calculating/printing it or print something indicating it can't be calculated. I've not looked into the details yet but I will at some point unless someone beats me to it with a different patch.
Cheers,
Richard
Quoted 31 lines
Thanks!
[1]: https://irc.yoctoproject.org/irc/%23yocto.2025-10-24.log.html#yocto.2025-10-24.log.html#t2025-10-24T11:09:20
---
lib/bb/siggen.py | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)lib/bb/siggen.py +0
-0@@ -1196,10 +1196,10 @@ def calc_basehash(sigdata):def
calc_taskhash(sigdata):
data = sigdata['basehash']
- for dep in sigdata['runtaskdeps']:
+ for dep insigdata.get('runtaskdeps', []):
data = data + sigdata['runtaskhashes'][dep]
- for c in sigdata['file_checksum_values']:
+ for c insigdata.get('file_checksum_values', []):
if c[1]:
if "./" in c[0]:
data = data + c[0]---
base-commit:35a421cdcafb3595b9de5489ffdc567825400d26
change-id: 20251027-fix-dumpsig-e945637ad89fBest regards,
Quoted 30 lines · Richard Purdie
Quoted 29 lines · Paul Barker
If the debug code is uncommented in
SignatureGeneratorBasic.finalise(), sigtask stamp file are created without runtime data such as 'runtaskdeps' and 'file_checksum_values'. If we then try to run bitbake-dumpsig on one of these files, we will see a traceback as the expected keys are not present in the sigdata dictionary:Traceback (most recent call last):
File ".../bitbake/bin/bitbake-dumpsig", line 195, in <module> output =bb.siggen.dump_sigfile(options.sigdatafile1)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../bitbake/lib/bb/siggen.py", line 1266, indump_sigfilecomputed_taskhash=calc_taskhash(a_data)^^^^^^^^^^^^^^^^^^^^^
File ".../bitbake/lib/bb/siggen.py", line 1199, incalc_taskhashfor dep in sigdata['runtaskdeps']:
~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'runtaskdeps'To fix this, treat these entries as empty lists if they are not present.
Signed-off-by Paul Barker <[email protected]>---
Richard,This patch attempts to fix an issue reported on IRC last week [1]. It prevents the traceback, but I'll have to defer to you on whether the taskhash calculated without 'runtimedeps' and '
file_checksum_values' is meaningful.
Quoted 7 lines
Quoted 2 lines
I guess an alternative approach would be to call
calc_taskhashin a try block and not print out a task hash if the call fails.Rather than compute a hash which will never work, we should just skip calculating/printing it or print something indicating it can't be calculated. I've not looked into the details yet but I will at some point unless someone beats me to it with a different patch.
Is calc_taskhash likely to change in the forseeable future to depend on additional keys in sigdata? If not, we could just check for 'runtimedeps' and 'file_checksum_values' in dump_sigfile before calling calc_taskhash and say "unable to compute task hash" if they're missing.
I can send a v2 implementing that.
Thanks,
Signature · 1 line
Paul Barker
Quoted 39 lines · Paul Barker
Quoted 30 lines · Richard Purdie
Quoted 29 lines · Paul Barker
If the debug code is uncommented in
SignatureGeneratorBasic.finalise(), sigtask stamp file are created without runtime data such as 'runtaskdeps' and 'file_checksum_values'. If we then try to run bitbake-dumpsig on one of these files, we will see a traceback as the expected keys are not present in the sigdata dictionary:Traceback (most recent call last):
File ".../bitbake/bin/bitbake-dumpsig", line 195, in <module> output =bb.siggen.dump_sigfile(options.sigdatafile1)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../bitbake/lib/bb/siggen.py", line 1266, indump_sigfilecomputed_taskhash=calc_taskhash(a_data)^^^^^^^^^^^^^^^^^^^^^
File ".../bitbake/lib/bb/siggen.py", line 1199, incalc_taskhashfor dep in sigdata['runtaskdeps']:
~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'runtaskdeps'To fix this, treat these entries as empty lists if they are not present.
Signed-off-by Paul Barker <[email protected]>---
Richard,This patch attempts to fix an issue reported on IRC last week [1]. It prevents the traceback, but I'll have to defer to you on whether the taskhash calculated without 'runtimedeps' and '
file_checksum_values' is meaningful.Quoted 7 lines
Quoted 2 lines
I guess an alternative approach would be to call
calc_taskhashin a try block and not print out a task hash if the call fails.Rather than compute a hash which will never work, we should just skip calculating/printing it or print something indicating it can't be calculated. I've not looked into the details yet but I will at some point unless someone beats me to it with a different patch.
Quoted 6 lines
Is
calc_taskhashlikely to change in the forseeable future to depend on additional keys in sigdata? If not, we could just check for 'runtimedeps' and 'file_checksum_values' indump_sigfilebefore callingcalc_taskhashand say "unable to compute task hash" if they're missing.I can send a v2 implementing that.
Potentially it can change but it wouldn't lose the runtimedeps so keying off that is probably safe enough.
Cheers,
Richard