| Message ID | 20251117171223.919666-1-corentin.guillevic@smile.fr |
|---|---|
| State | New |
| Headers | show |
| Series | [v2,1/2] insane.bbclass: check revision for every git URI | expand |
On Mon Nov 17, 2025 at 6:12 PM CET, Corentin Guillevic via lists.openembedded.org wrote: > Every git URI into SRC_URI variable should have a revision. However, if > the revision is missing (SRCREV), BitBake will perform a query on the > remote repository every time it parses a recipe. > > This check will raise an error if a git URI is not provided alongside a revision. > > Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr> > --- Hi Corentin, Thanks for your patch. It looks like this is braking a lot of seltests, with errors such as: 2025-11-18 10:16:22,997 - oe-selftest - INFO - devtool.DevtoolAddTests.test_devtool_add_binary (subunit.RemotedTestCase) 2025-11-18 10:16:22,998 - oe-selftest - INFO - ... FAIL ... Parsing recipes...ERROR: /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-38423/workspace/recipes/recipetool/tmp-recipetool-oalz2197.bb: AUTOREV/SRCPV set too late for the fetcher to work properly, please set the variables earlier in parsing. Erroring instead of later obtuse build failures. ERROR: Parsing halted due to errors, see error messages above Summary: There were 2 ERROR messages, returning a non-zero exit code. Traceback (most recent call last): File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/scripts/recipetool", line 111, in <module> ret = main() ^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/scripts/recipetool", line 100, in main ret = args.func(args) ^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/scripts/lib/recipetool/create.py", line 525, in create_recipe checksums, ftmpdir = scriptutils.fetch_url(tinfoil, fetchuri, srcrev, srctree, logger, preserve_tmp=args.keep_temp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/scripts/lib/scriptutils.py", line 202, in fetch_url tinfoil.parse_recipes() File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/bitbake/lib/bb/tinfoil.py", line 585, in parse_recipes self.run_actions(config_params) File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/bitbake/lib/bb/tinfoil.py", line 568, in run_actions raise TinfoilUIException(ret) bb.tinfoil.TinfoilUIException: 1 ERROR: Command 'recipetool --color=auto create --devtool -o /tmp/devtoolordsanap 'file:///tmp/devtoolqa1ao0e11u/tst-bin.tar.gz' -x /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-38423/workspace/sources/devtoolsrcka3994q2 -N tst-bin -b' failed This is just one error, there is about 24 of them on each builds: 2025-11-18 16:02:59,746 - oe-selftest - INFO - oe-selftest - FAIL - Required tests failed (successes=609, skipped=12, failures=24, errors=0) https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/2713 https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/2849 https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/2607 Can you have a look at these? Thanks, Mathieu
diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index fed8163c3e..63490ecf25 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -1495,7 +1495,33 @@ python do_recipe_qa() { error_msg = "%s: invalid PACKAGECONFIG(s): %s" % (pn, " ".join(sorted(invalid_pkgconfigs))) oe.qa.handle_error("invalid-packageconfig", error_msg, d) + def test_git_missing_srcrev(pn, d): + sha1_re = re.compile(r'^[0-9a-f]{40}$') + for uri in d.getVar('SRC_URI').split(): + if not uri.startswith('git://'): + continue + + # Get parameters for the current URI + params = bb.fetch2.decodeurl(uri)[5] + name = params.get('name', '') + rev = params.get('rev', '') + + # Revision is provided as a 'rev' parameter + if rev: + # Prevent any revision that doesn't look like a SHA-1 + if not sha1_re.match(rev or ''): + oe.qa.handle_error("missing-srcrev", "%s: ;rev=%s URL parameter doesn't look like a SHA-1" % (pn, rev), d) + # git URI has a "name" parameter + elif name: + rev = d.getVar('SRCREV_' + name) + if not rev: + oe.qa.handle_error("missing-srcrev", "%s: no revision (%s) defined for URI %s" % (pn, 'SRCREV_' + name, uri), d) + else: + if d.getVar('SRCREV') == "INVALID": + oe.qa.handle_error("missing-srcrev", "%s: no revision (SRCREV) defined for URI %s" % (pn, uri), d) + pn = d.getVar('PN') + test_git_missing_srcrev(pn, d) test_naming(pn, d) test_missing_metadata(pn, d) test_missing_maintainer(pn, d)
Every git URI into SRC_URI variable should have a revision. However, if the revision is missing (SRCREV), BitBake will perform a query on the remote repository every time it parses a recipe. This check will raise an error if a git URI is not provided alongside a revision. Signed-off-by: Corentin Guillevic <corentin.guillevic@smile.fr> --- v2: add support of rev= parameter meta/classes-global/insane.bbclass | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)