All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] insane.bbclass: check revision for every git URI
@ 2025-11-17 17:12 Corentin Guillevic
  2025-11-17 17:12 ` [PATCH v2 2/2] layer.conf: enable test for revision alongside a " Corentin Guillevic
  2025-11-18 16:20 ` [OE-core] [PATCH v2 1/2] insane.bbclass: check revision for every " Mathieu Dubois-Briand
  0 siblings, 2 replies; 3+ messages in thread
From: Corentin Guillevic @ 2025-11-17 17:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Corentin Guillevic

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(+)

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)
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-18 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 17:12 [PATCH v2 1/2] insane.bbclass: check revision for every git URI Corentin Guillevic
2025-11-17 17:12 ` [PATCH v2 2/2] layer.conf: enable test for revision alongside a " Corentin Guillevic
2025-11-18 16:20 ` [OE-core] [PATCH v2 1/2] insane.bbclass: check revision for every " Mathieu Dubois-Briand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.