<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> <<a href="mailto:chris.laplante@agilent.com">chris.laplante@agilent.com</a>> 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">> 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>> in a DIR_PREBUILT)...<br>> <br>> Before going further is there already an existing solution for that? do you have any recommendation on the easier/best way to<br>> achieve this?<br>
<br>I don't have a "best practice" recommendation to offer. But coincidentally I suggested something similar for upstreaming a few weeks ago. It was (rightfully) rejected as too "hacky" for inclusion in core code. Regardless, here's a bbclass we currently use:<br>
<br>addhandler skip_eventhandler<br>python skip_eventhandler() {<br> try:<br> bb.fetch2.Fetch(d.getVar("SRC_URI").split(), d)<br> except bb.fetch2.FetchError:<br> raise bb.parse.SkipRecipe("skip-inaccessible: could not access upstream repo; check SRC_URI, access rights, and network availability")<br>}<br>skip_eventhandler[eventmask] = "bb.event.RecipePreFinalise"<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'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's only a draft and I'll come back with a polished version, but the idea is to look for the related prebuilt package into a 'PREBUILT_SRC_DIR' (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>