<div dir="ltr">I think it's better to rearrange the layer itself, and split it into a privileged and a non-privileged one. <div><br></div><div>This patch seems to enable skipping the recipe, regardless of what the actual issue with fetching was (which may or may not be 'access denied'). Skipping on any error doesn't seem right to me as it may mask other types of problems.<br><div><br></div><div>Alex</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 26 Jul 2019 at 16:55, Chris Laplante via bitbake-devel <<a href="mailto:bitbake-devel@lists.openembedded.org">bitbake-devel@lists.openembedded.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Sometimes it is desirable to just skip a recipe if the upstream(s) can't be<br>
accessed by the user, rather than fail the whole build outright.<br>
<br>
For example, in a corporate environment, sometimes certain git repositories<br>
are access controlled. If privileged and non-privileged users share<br>
the same Yocto layers, it would be nice for the non-privileged users to<br>
be able to build the recipes they need, without tripping over parse<br>
failures on the non-accessible recipes.<br>
<br>
Signed-off-by: Chris Laplante <<a href="mailto:chris.laplante@agilent.com" target="_blank">chris.laplante@agilent.com</a>><br>
---<br>
lib/bb/fetch2/__init__.py | 99 +++++++++++++++++++++++++----------------------<br>
1 file changed, 52 insertions(+), 47 deletions(-)<br>
<br>
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py<br>
index f6b5529..a165a77 100644<br>
--- a/lib/bb/fetch2/__init__.py<br>
+++ b/lib/bb/fetch2/__init__.py<br>
@@ -741,55 +741,60 @@ def get_srcrev(d, method_name='sortable_revision'):<br>
that fetcher provides a method with the given name and the same signature as sortable_revision.<br>
"""<br>
<br>
- scms = []<br>
- fetcher = Fetch(d.getVar('SRC_URI').split(), d)<br>
- urldata = fetcher.ud<br>
- for u in urldata:<br>
- if urldata[u].method.supports_srcrev():<br>
- scms.append(u)<br>
-<br>
- if len(scms) == 0:<br>
- raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")<br>
-<br>
- if len(scms) == 1 and len(urldata[scms[0]].names) == 1:<br>
- autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0])<br>
- if len(rev) > 10:<br>
- rev = rev[:10]<br>
- if autoinc:<br>
- return "AUTOINC+" + rev<br>
- return rev<br>
-<br>
- #<br>
- # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT<br>
- #<br>
- format = d.getVar('SRCREV_FORMAT')<br>
- if not format:<br>
- raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.\n"\<br>
- "The SCMs are:\n%s" % '\n'.join(scms))<br>
-<br>
- name_to_rev = {}<br>
- seenautoinc = False<br>
- for scm in scms:<br>
- ud = urldata[scm]<br>
- for name in ud.names:<br>
- autoinc, rev = getattr(ud.method, method_name)(ud, d, name)<br>
- seenautoinc = seenautoinc or autoinc<br>
+ try:<br>
+ scms = []<br>
+ fetcher = Fetch(d.getVar('SRC_URI').split(), d)<br>
+ urldata = fetcher.ud<br>
+ for u in urldata:<br>
+ if urldata[u].method.supports_srcrev():<br>
+ scms.append(u)<br>
+<br>
+ if len(scms) == 0:<br>
+ raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")<br>
+<br>
+ if len(scms) == 1 and len(urldata[scms[0]].names) == 1:<br>
+ autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0])<br>
if len(rev) > 10:<br>
rev = rev[:10]<br>
- name_to_rev[name] = rev<br>
- # Replace names by revisions in the SRCREV_FORMAT string. The approach used<br>
- # here can handle names being prefixes of other names and names appearing<br>
- # as substrings in revisions (in which case the name should not be<br>
- # expanded). The '|' regular expression operator tries matches from left to<br>
- # right, so we need to sort the names with the longest ones first.<br>
- names_descending_len = sorted(name_to_rev, key=len, reverse=True)<br>
- name_to_rev_re = "|".join(re.escape(name) for name in names_descending_len)<br>
- format = re.sub(name_to_rev_re, lambda match: name_to_rev[match.group(0)], format)<br>
-<br>
- if seenautoinc:<br>
- format = "AUTOINC+" + format<br>
-<br>
- return format<br>
+ if autoinc:<br>
+ return "AUTOINC+" + rev<br>
+ return rev<br>
+<br>
+ #<br>
+ # Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT<br>
+ #<br>
+ format = d.getVar('SRCREV_FORMAT')<br>
+ if not format:<br>
+ raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.\n"\<br>
+ "The SCMs are:\n%s" % '\n'.join(scms))<br>
+<br>
+ name_to_rev = {}<br>
+ seenautoinc = False<br>
+ for scm in scms:<br>
+ ud = urldata[scm]<br>
+ for name in ud.names:<br>
+ autoinc, rev = getattr(ud.method, method_name)(ud, d, name)<br>
+ seenautoinc = seenautoinc or autoinc<br>
+ if len(rev) > 10:<br>
+ rev = rev[:10]<br>
+ name_to_rev[name] = rev<br>
+ # Replace names by revisions in the SRCREV_FORMAT string. The approach used<br>
+ # here can handle names being prefixes of other names and names appearing<br>
+ # as substrings in revisions (in which case the name should not be<br>
+ # expanded). The '|' regular expression operator tries matches from left to<br>
+ # right, so we need to sort the names with the longest ones first.<br>
+ names_descending_len = sorted(name_to_rev, key=len, reverse=True)<br>
+ name_to_rev_re = "|".join(re.escape(name) for name in names_descending_len)<br>
+ format = re.sub(name_to_rev_re, lambda match: name_to_rev[match.group(0)], format)<br>
+<br>
+ if seenautoinc:<br>
+ format = "AUTOINC+" + format<br>
+<br>
+ return format<br>
+ except FetchError as e:<br>
+ if d.getVar('BB_WORKERCONTEXT') != '1' and bb.utils.to_boolean(d.getVar("BB_FETCH_SKIP_ON_SRCREV_ERROR")):<br>
+ raise bb.parse.SkipRecipe(e)<br>
+ raise<br>
<br>
def localpath(url, d):<br>
fetcher = bb.fetch2.Fetch([url], d)<br>
-- <br>
2.7.4<br>
<br>
-- <br>
_______________________________________________<br>
bitbake-devel mailing list<br>
<a href="mailto:bitbake-devel@lists.openembedded.org" target="_blank">bitbake-devel@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/bitbake-devel" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/bitbake-devel</a><br>
</blockquote></div>