aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-14 14:30:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-15 06:59:44 +0100
commit9f374c4e8523430ef2fc5cb492c3ece9786623d2 (patch)
tree325323dce354e1b5a0b0f82df56573752aac2938
parent4b8b1105a59f5d5849a9a40c190e45e882571995 (diff)
downloadopenembedded-core-contrib-9f374c4e8523430ef2fc5cb492c3ece9786623d2.tar.gz
openembedded-core-contrib-9f374c4e8523430ef2fc5cb492c3ece9786623d2.tar.bz2
openembedded-core-contrib-9f374c4e8523430ef2fc5cb492c3ece9786623d2.zip
bitbake: providers: Add PREFERRED_RPROVIDER support
Sometimes you can end up in a situation where you need to specify that a specific runtime entity should be provided by a specific entry. An example of this is bluez where you could end up in a situation where for example: NOTE: multiple providers are available for runtime libasound-module-bluez (bluez4, bluez5) NOTE: consider defining a PREFERRED_PROVIDER entry to match libasound-module-bluez NOTE: multiple providers are available for runtime bluez-hcidump (bluez-hcidump, bluez5) NOTE: consider defining a PREFERRED_PROVIDER entry to match bluez-hcidump The only option here is to set something like PREFERRED_PROVIDER_bluez4 = "bluez4" which is clearly not very informative. I've actually held off adding RPROVIDER support for a long while as this does have sigificant potential for misuse. It doesn't for example allow multiple runtime providers of the same name to coexist, that simply isn't supported. It therefore doesn't replace some of the name mappings such as busybox verses coreutils that OE-Core faces as that is a different problem with different constraints. This mechanism is simply to provide bitbake with a hint to decide what the dependency tree should look like. Also, this allows us to stop printing a confusing message telling the user to set PREFERRED_PROVIDER when the setting needed would be rather ambiguous. [YOCTO #5044] (Bitbake rev: 62eb39d1474d024b204634689071700605c6095c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/providers.py62
-rw-r--r--bitbake/lib/bb/ui/knotty.py5
2 files changed, 44 insertions, 23 deletions
diff --git a/bitbake/lib/bb/providers.py b/bitbake/lib/bb/providers.py
index 8195d62a11c..563a091fda7 100644
--- a/bitbake/lib/bb/providers.py
+++ b/bitbake/lib/bb/providers.py
@@ -317,32 +317,50 @@ def filterProvidersRunTime(providers, item, cfgData, dataCache):
eligible = _filterProviders(providers, item, cfgData, dataCache)
- # Should use dataCache.preferred here?
- preferred = []
- preferred_vars = []
- pns = {}
- for p in eligible:
- pns[dataCache.pkg_fn[p]] = p
- for p in eligible:
- pn = dataCache.pkg_fn[p]
- provides = dataCache.pn_provides[pn]
- for provide in provides:
- prefervar = cfgData.getVar('PREFERRED_PROVIDER_%s' % provide, True)
- #logger.debug(1, "checking PREFERRED_PROVIDER_%s (value %s) against %s", provide, prefervar, pns.keys())
- if prefervar in pns and pns[prefervar] not in preferred:
- var = "PREFERRED_PROVIDER_%s = %s" % (provide, prefervar)
- logger.verbose("selecting %s to satisfy runtime %s due to %s", prefervar, item, var)
- preferred_vars.append(var)
- pref = pns[prefervar]
- eligible.remove(pref)
- eligible = [pref] + eligible
- preferred.append(pref)
+ # First try and match any PREFERRED_RPROVIDER entry
+ prefervar = cfgData.getVar('PREFERRED_RPROVIDER_%s' % item, True)
+ foundUnique = False
+ if prefervar:
+ for p in eligible:
+ pn = dataCache.pkg_fn[p]
+ if prefervar == pn:
+ logger.verbose("selecting %s to satisfy %s due to PREFERRED_RPROVIDER", pn, item)
+ eligible.remove(p)
+ eligible = [p] + eligible
+ foundUnique = True
+ numberPreferred = 1
break
- numberPreferred = len(preferred)
+ # If we didn't find an RPROVIDER entry, try and infer the provider from PREFERRED_PROVIDER entries
+ # by looking through the provides of each eligible recipe and seeing if a PREFERRED_PROVIDER was set.
+ # This is most useful for virtual/ entries rather than having a RPROVIDER per entry.
+ if not foundUnique:
+ # Should use dataCache.preferred here?
+ preferred = []
+ preferred_vars = []
+ pns = {}
+ for p in eligible:
+ pns[dataCache.pkg_fn[p]] = p
+ for p in eligible:
+ pn = dataCache.pkg_fn[p]
+ provides = dataCache.pn_provides[pn]
+ for provide in provides:
+ prefervar = cfgData.getVar('PREFERRED_PROVIDER_%s' % provide, True)
+ #logger.debug(1, "checking PREFERRED_PROVIDER_%s (value %s) against %s", provide, prefervar, pns.keys())
+ if prefervar in pns and pns[prefervar] not in preferred:
+ var = "PREFERRED_PROVIDER_%s = %s" % (provide, prefervar)
+ logger.verbose("selecting %s to satisfy runtime %s due to %s", prefervar, item, var)
+ preferred_vars.append(var)
+ pref = pns[prefervar]
+ eligible.remove(pref)
+ eligible = [pref] + eligible
+ preferred.append(pref)
+ break
+
+ numberPreferred = len(preferred)
if numberPreferred > 1:
- logger.error("Trying to resolve runtime dependency %s resulted in conflicting PREFERRED_PROVIDER entries being found.\nThe providers found were: %s\nThe PREFERRED_PROVIDER entries resulting in this conflict were: %s", item, preferred, preferred_vars)
+ logger.error("Trying to resolve runtime dependency %s resulted in conflicting PREFERRED_PROVIDER entries being found.\nThe providers found were: %s\nThe PREFERRED_PROVIDER entries resulting in this conflict were: %s. You could set PREFERRED_RPROVIDER_%s" % (item, preferred, preferred_vars, item))
logger.debug(1, "sorted runtime providers for %s are: %s", item, eligible)
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 2fc20cfb532..268562770a2 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -453,7 +453,10 @@ def main(server, eventHandler, params, tf = TerminalFilter):
logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "",
event._item,
", ".join(event._candidates))
- logger.info("consider defining a PREFERRED_PROVIDER entry to match %s", event._item)
+ rtime = ""
+ if event._is_runtime:
+ rtime = "R"
+ logger.info("consider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, event._item))
continue
if isinstance(event, bb.event.NoProvider):
if event._runtime: