From 433cff7297cc60528f003add2b495e218b2d392c Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 10 Sep 2021 15:04:43 +0100 Subject: bitbake: fetch2: Add recursion guard Users sometimes put ${S} references in ${SRC_URI} without realising this can be problematic. Improve the error messages if they accidentally do. [YOCTO #11593] (Bitbake rev: 89e0b19ec0b245a6cd414088904c91808e8814ab) Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bitbake') diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 47a4943369..d9e1599a05 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -754,6 +754,11 @@ def get_srcrev(d, method_name='sortable_revision'): that fetcher provides a method with the given name and the same signature as sortable_revision. """ + recursion = d.getVar("__BBINSRCREV") + if recursion: + raise FetchError("There are recursive references in fetcher variables, likely through SRC_URI") + d.setVar("__BBINSRCREV", True) + scms = [] fetcher = Fetch(d.getVar('SRC_URI').split(), d) urldata = fetcher.ud @@ -768,6 +773,7 @@ def get_srcrev(d, method_name='sortable_revision'): autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) if len(rev) > 10: rev = rev[:10] + d.delVar("__BBINSRCREV") if autoinc: return "AUTOINC+" + rev return rev @@ -802,6 +808,7 @@ def get_srcrev(d, method_name='sortable_revision'): if seenautoinc: format = "AUTOINC+" + format + d.delVar("__BBINSRCREV") return format def localpath(url, d): -- cgit v1.2.3-54-g00ecf