<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 5 Aug 2019 at 18:39, <a href="mailto:chris.laplante@agilent.com">chris.laplante@agilent.com</a> &lt;<a href="mailto:chris.laplante@agilent.com">chris.laplante@agilent.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; But I would like something smarter, e.g. first trying to check if the SRC_URI is available, if not switching on using the prebuilt package if available (e.g.<br>&gt; in a DIR_PREBUILT)...<br>&gt; <br>&gt; Before going further is there already an existing solution for that? do you have any recommendation on the easier/best way to<br>&gt; achieve this?<br>
<br>I don&#39;t have a &quot;best practice&quot; recommendation to offer. But coincidentally I suggested something similar for upstreaming a few weeks ago. It was (rightfully) rejected as too &quot;hacky&quot; for inclusion in core code. Regardless, here&#39;s a bbclass we currently use:<br>
<br>addhandler skip_eventhandler<br>python skip_eventhandler() {<br>    try:<br>        bb.fetch2.Fetch(d.getVar(&quot;SRC_URI&quot;).split(), d)<br>    except bb.fetch2.FetchError:<br>        raise bb.parse.SkipRecipe(&quot;skip-inaccessible: could not access upstream repo; check SRC_URI, access rights, and network availability&quot;)<br>}<br>skip_eventhandler[eventmask] = &quot;bb.event.RecipePreFinalise&quot;<br>
<br>
<br>As was pointed out to me, this is a pretty heavy-handed approach - it can fail for any number of reasons, not just the URI actually being unavailable. So you may consider a more surgical check, e.g. actually trying to fetch the SRC_URI directly using raw GET requests.<br>
<br>To implement the handover, you&#39;d have separate recipes for the build-from-source and the prebuilt case which PROVIDE the same package. You probably also want to set PREFERRED_PROVIDER in your layer conf to prefer the build-from-source recipe. <br>
<br>Alternatively, you can do it all in a single recipe by rewriting the SRC_URI from within the event handler. But I think separate recipes is nicer.<br></blockquote><div><br></div><div>Well, I ended up with the attached class, which generates or install prebuilt tarball. It&#39;s only a draft and I&#39;ll come back with a polished version, but the idea is to look for the related prebuilt package into a &#39;PREBUILT_SRC_DIR&#39; (if defined) and install it instead of fetching and compiling from source. This allows having only one recipe. Then a company just needs to provide closed-source software as a set of prebuilt tarballs and customer need to point to the prebuilt dir (e.g. in local.conf). <br></div><div><br></div><div>Regards,</div><div>Loic<br></div></div></div>