Modifying SRC_URI before it is parsed by the fetcher

EXT-Antti Gärding <[email protected]> Tue, 12 May 2026 14:47:32 +0000
Newsgroups org.yoctoproject.lists.yocto
Message-ID <AS8PR08MB72519491BFB65260C510C104D5392@AS8PR08MB7251.eurprd08.prod.outlook.com>
Hi,

I am developing a .bbclass file that modifies SRC_URI of the inheriting recipe before bitbake (in this case, the git fetcher) initializes its internal data structures with that data. Prepended to any task or as a dedicated task before any other tasks is too late, but a Python function declared __anonymous seems to be invoked right after parsing the recipe, which is early enough.

My log prints, however, revealed that such function is invoked not only at that point but also multiple times when building the recipe. I didn't inspect it thoroughly enough to be sure, but I got the impression that it might be invoked once during each task. That is not a critical issue right now, but it makes the logs look weird and requires extra care to make sure that running the function multiple times doesn't have any unwanted side-effects.

Is there any way to have code executed only right after parsing the recipe? In this case, the initialization of the internal data structures which it must precede seems to happen in urldata_init() of class Git in poky/bitbake/lib/bb/fetch2/git.py.

I discovered that there is variable BB_CURRENTTASK which is None on the very first run and contains the name of the current task on other runs. I tried making my function check it and act only when it is None, but that resulted in errors about basehash value having changed and bitbake thus considering the metadata non-deterministic.

Could BB_CURRENTTASK be somehow utilized to achieve what I am trying?


BR,
Antti Gärding