def findLatestProvider(pn, cfgData, dataCache, file_set): """ Return the highest version of the providers in file_set. Take default preferences into account. """ latest = None latest_p = 0 latest_f = None for file_name in file_set: pe, pv, pr = dataCache.pkg_pepvpr[file_name] dp = dataCache.pkg_dp[file_name] if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pe, pv, pr)) < 0)) or (dp > latest_p): latest = (pe, pv, pr) latest_f = file_name latest_p = dp return (latest, latest_f)
def findLatestProvider(pn, cfgData, dataCache, file_set): """ Return the highest version of the providers in file_set. Take default preferences into account. """ latest = None latest_p = 0 latest_f = None for file_name in file_set: pe,pv,pr = dataCache.pkg_pepvpr[file_name] dp = dataCache.pkg_dp[file_name] if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pe, pv, pr)) < 0)) or (dp > latest_p): latest = (pe, pv, pr) latest_f = file_name latest_p = dp return (latest, latest_f)
def findBestProvider(pn, cfgData, dataCache, pkg_pn = None, item = None): """ If there is a PREFERRED_VERSION, find the highest-priority bbfile providing that version. If not, find the latest version provided by an bbfile in the highest-priority set. """ if not pkg_pn: pkg_pn = dataCache.pkg_pn files = pkg_pn[pn] priorities = {} for f in files: priority = dataCache.bbfile_priority[f] if priority not in priorities: priorities[priority] = [] priorities[priority].append(f) p_list = priorities.keys() p_list.sort(lambda a, b: a - b) tmp_pn = [] for p in p_list: tmp_pn = [priorities[p]] + tmp_pn preferred_file = None localdata = data.createCopy(cfgData) bb.data.setVar('OVERRIDES', "%s:%s" % (pn, data.getVar('OVERRIDES', localdata)), localdata) bb.data.update_data(localdata) preferred_v = bb.data.getVar('PREFERRED_VERSION_%s' % pn, localdata, True) if preferred_v: m = re.match('(.*)_(.*)', preferred_v) if m: preferred_v = m.group(1) preferred_r = m.group(2) else: preferred_r = None for file_set in tmp_pn: for f in file_set: pv,pr = dataCache.pkg_pvpr[f] if preferred_v == pv and (preferred_r == pr or preferred_r == None): preferred_file = f preferred_ver = (pv, pr) break if preferred_file: break; if preferred_r: pv_str = '%s-%s' % (preferred_v, preferred_r) else: pv_str = preferred_v itemstr = "" if item: itemstr = " (for item %s)" % item if preferred_file is None: bb.msg.note(1, bb.msg.domain.Provider, "preferred version %s of %s not available%s" % (pv_str, pn, itemstr)) else: bb.msg.debug(1, bb.msg.domain.Provider, "selecting %s as PREFERRED_VERSION %s of package %s%s" % (preferred_file, pv_str, pn, itemstr)) del localdata # get highest priority file set files = tmp_pn[0] latest = None latest_p = 0 latest_f = None for file_name in files: pv,pr = dataCache.pkg_pvpr[file_name] dp = dataCache.pkg_dp[file_name] if (latest is None) or ((latest_p == dp) and (utils.vercmp(latest, (pv, pr)) < 0)) or (dp > latest_p): latest = (pv, pr) latest_f = file_name latest_p = dp if preferred_file is None: preferred_file = latest_f preferred_ver = latest return (latest,latest_f,preferred_ver, preferred_file)