Hi,

On 1/17/25 3:25 PM, Kjeld Flarup via lists.yoctoproject.org wrote:
You don't often get email from kjeld.flarup=liberalismen...@lists.yoctoproject.org. 
Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
I try to write an append for do_unpack
do_unpack:append() {
   echo Hello
}

But it looks like it is parsed as Python

                      parser = bb.codeparser.PythonParser(key, logger)
     >                parser.parse_python(value, filename=varflags.get("filename"), 
lineno=varflags.get("lineno"))
                      deps = deps | parser.references
   File "/tmp/yocto/meta-poky/bitbake/lib/bb/codeparser.py", line 358, in 
PythonParser.parse_python(node="\n    bb.build.exec_func('base_do_unpack', d)\n  echo 
Hello\n", lineno=1, filename='autogenerated', fixedhash=None):
              node = "\n" * int(lineno) + node
     >        code = compile(check_indent(str(node)), filename, "exec",
                             ast.PyCF_ONLY_AST)
   File "autogenerated", line 3
     echo Hello
               ^
IndentationError: unindent does not match any outer indentation level

Isn't this possible using shell


Tasks can be python or shell, here do_unpack is Python, so you need to write Python code in :prepend or :append.

Depending on your usecase, you can simply add a new task and insert it between do_unpack and the next task depending on this change for example.

Another option is to use bb.build.exec_func() from Python code to execute a shell function, though I don't think this is widely used outside of core code (and I haven't used it myself, so maybe not the best practice either).

You can also have shell functions run after the python task is run, those are added with:

do_unpack[prefuncs] += "my-shell-func another-shell-func"
do_unpack[postfuncs] += "my-shell-func yet-another-shell-func"

c.f. https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#variable-flags

Cheers,
Quentin
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#64583): https://lists.yoctoproject.org/g/yocto/message/64583
Mute This Topic: https://lists.yoctoproject.org/mt/110666328/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to