> 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.
> in a DIR_PREBUILT)...
>
> Before going further is there already an existing solution for that? do you
> have any recommendation on the easier/best way to
> achieve this?
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:
addhandler skip_eventhandler
python skip_eventhandler() {
try:
bb.fetch2.Fetch(d.getVar("SRC_URI").split(), d)
except bb.fetch2.FetchError:
raise bb.parse.SkipRecipe("skip-inaccessible: could not access upstream
repo; check SRC_URI, access rights, and network availability")
}
skip_eventhandler[eventmask] = "bb.event.RecipePreFinalise"
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.
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.
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.
Chris
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core