@@ -56,7 +56,39 @@ def check_network_flag(d):
if network and not is_allowed(bpn, task):
bb.error(f"QA Issue: task {task} has network enabled")
+def check_missing_srcrev(d):
+ import bb.fetch2
+ src_uri = (d.getVar('SRC_URI', False) or '').split()
+ pn = d.getVar('PN')
+ for uri in src_uri:
+ try:
+ (scheme, _, _, _, _, params) = bb.fetch2.decodeurl(uri)
+ except Exception:
+ continue
+ if scheme not in ('git', 'gitsm', 'hg', 'svn'):
+ continue
+ if params.get('rev', ''):
+ continue
+ name = params.get('name', '') or 'default'
+ candidates = [
+ 'SRCREV_%s:pn-%s' % (name, pn),
+ 'SRCREV_%s' % name,
+ 'SRCREV:pn-%s' % pn,
+ 'SRCREV',
+ ]
+ raw = None
+ for candidate in candidates:
+ raw = d.getVar(candidate, False)
+ if raw:
+ break
+ if not raw or raw == 'INVALID':
+ bb.error("QA Issue: %s: %s not set for SCM URI %s [missing-srcrev]" % (
+ d.getVar('PN'), candidates[-1], uri))
+ d.setVar("QA_ERRORS_FOUND", "True")
+
+
python () {
check_insane_skip(d)
check_network_flag(d)
+ check_missing_srcrev(d)
}
Add check_missing_srcrev() to yocto-check-layer.bbclass to enforce the missing-srcrev check as an error during yocto-check-layer runs. This ensures layer maintainers submitting layers to the Yocto ecosystem must fix all missing SRCREVs before their layer passes validation, even if their layer only gets WARN_QA during normal builds. This satisfies the requirement from Bug 16051 Comment 2: 'add a QA check outside of checklayer then add it to checklayer' Fixes: https://bugzilla.yoctoproject.org/show_bug.cgi?id=16051 Signed-off-by: Sai Sneha <saisneha196@gmail.com> --- meta/classes-global/yocto-check-layer.bbclass | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+)