def loadRecipe(repos, name, version, flavor, trv, defaultFlavor=None, loadInstalledSource=None, installLabelPath=None, buildLabel=None, groupRecipeSource=None, cfg=None): name = name.split(':')[0] try: if defaultFlavor is not None: fullFlavor = deps.overrideFlavor(defaultFlavor, flavor) else: fullFlavor = flavor # set up necessary flavors and track used flags before # calling loadRecipe, since even loading the class # may check some flags that may never be checked inside # the recipe recipeObj, loader = getRecipeObj(repos, name, version, fullFlavor, trv, loadInstalledSource=loadInstalledSource, installLabelPath=installLabelPath, buildLabel=buildLabel, cfg=cfg) relevantFlavor = use.usedFlagsToFlavor(recipeObj.name) relevantFlavor = flavorutil.removeInstructionSetFlavor(relevantFlavor) # always add in the entire arch flavor. We need to ensure the # relevant flavor is unique per architecture, also, arch flavors # can affect the macros used. if defaultFlavor is not None: relevantFlavor.union(flavor) relevantFlavor.union(flavorutil.getArchFlags(fullFlavor)) relevantFlags = flavorutil.getFlavorUseFlags(relevantFlavor) flags = flavorutil.getFlavorUseFlags(fullFlavor) use.track(False) for flagSet in ('Use',): # allow local flags not to be used -- they are set to their default if flagSet not in relevantFlags: continue for flag in relevantFlags[flagSet]: if flag not in flags[flagSet]: raise (RuntimeError, "Recipe %s uses Flavor %s but value not known" %(name, flag)) if 'Arch' in relevantFlags: for majarch in relevantFlags['Arch'].keys(): for subarch in relevantFlags['Arch'][majarch]: if not use.Arch[majarch][subarch]: #negative values for subarches are assumed continue if subarch not in flags['Arch'][majarch]: log.error("arch %s.%s used but not specified" % ( majarch, subarch)) raise RuntimeError, ( "arch %s.%s used but not specified" % ( majarch, subarch)) use.resetUsed() except: log.error('Error Loading Recipe (%s, %s, %s):\n%s' % (name, version, fullFlavor, ''.join(traceback.format_exc()))) raise return loader, recipeObj, relevantFlavor
def _flavorsMatch(self, troveFlavor, provFlavor, reqFlavor, isCross): if isCross: troveFlavor = flavorutil.getSysRootFlavor(troveFlavor) archFlavor = flavorutil.getBuiltFlavor(flavorutil.getArchFlags( troveFlavor, getTarget=False, withFlags=False)) if reqFlavor is None: reqFlavor = archFlavor else: reqFlavor = deps.overrideFlavor(archFlavor, reqFlavor) if flavorutil.getArchFlags(provFlavor).isEmpty(): provFlavor = deps.overrideFlavor(archFlavor, provFlavor) if flavorutil.getBuiltFlavor(provFlavor).toStrongFlavor().satisfies( reqFlavor.toStrongFlavor()): return True return False
def formatNode(node): name, version, flavor, context = node.getNameVersionFlavor(True) name = name.split(':')[0] versionStr = '%s' % (version.trailingRevision()) archFlavor = flavorutil.getArchFlags(flavor, withFlags=False) restFlavor = flavorutil.removeInstructionSetFlavor(flavor) archFlavor.union(restFlavor) if context: contextStr = '{%s}' % context else: contextStr = '' return '%s=%s[%s]%s' % (name, versionStr, archFlavor, contextStr)
def getFlavorSpecs(job): flavorsByName = {} for nvf in job.iterTroveList(): flavorsByName.setdefault(nvf[0], []).append(nvf[2]) for trove in job.iterTroves(): if not trove: continue for nvf in trove.iterBuiltTroves(): flavorsByName.setdefault(nvf[0], []).append(nvf[2]) for name, flavorList in flavorsByName.items(): allFlavors = [] for flavor in flavorList: archFlags = flavorutil.getArchFlags(flavor, withFlags=False) flavorsByName[name, flavor] = archFlags if len(set(allFlavors)) != len(allFlavors): diffs = deps.flavorDifferences(flavorList) for flavor in flavorList: archFlags = flavorsByName[name, flavor] archFlags.union(diffs[flavor]) return flavorsByName
def getNodeForFlavors(self, flavors, requiresChroot=False): nodes = [] for node in self.getOpenNodes(requiresChroot=requiresChroot): if not flavors: nodes.append(node) continue for flavor in flavors: found = False archFlavor = flavorutil.getArchFlags(flavor, getTarget=False, withFlags=False) for buildFlavor in node.buildFlavors: filteredFlavor = deps.filterFlavor(flavor, [buildFlavor, archFlavor]) if buildFlavor.stronglySatisfies(filteredFlavor): found = True break if not found: break if found: nodes.append(node) if not nodes: return None return self.rankNodes(nodes)[0]
def getNodeForFlavors(self, flavors, requiresChroot=False): nodes = [] for node in self.getOpenNodes(requiresChroot=requiresChroot): if not flavors: nodes.append(node) continue for flavor in flavors: found = False archFlavor = flavorutil.getArchFlags(flavor, getTarget=False, withFlags=False) for buildFlavor in node.buildFlavors: filteredFlavor = deps.filterFlavor( flavor, [buildFlavor, archFlavor]) if buildFlavor.stronglySatisfies(filteredFlavor): found = True break if not found: break if found: nodes.append(node) if not nodes: return None return self.rankNodes(nodes)[0]
def loadRecipe(repos, name, version, flavor, trv, defaultFlavor=None, loadInstalledSource=None, installLabelPath=None, buildLabel=None, groupRecipeSource=None, cfg=None): name = name.split(':')[0] try: if defaultFlavor is not None: fullFlavor = deps.overrideFlavor(defaultFlavor, flavor) else: fullFlavor = flavor # set up necessary flavors and track used flags before # calling loadRecipe, since even loading the class # may check some flags that may never be checked inside # the recipe recipeObj, loader = getRecipeObj( repos, name, version, fullFlavor, trv, loadInstalledSource=loadInstalledSource, installLabelPath=installLabelPath, buildLabel=buildLabel, cfg=cfg) relevantFlavor = use.usedFlagsToFlavor(recipeObj.name) relevantFlavor = flavorutil.removeInstructionSetFlavor(relevantFlavor) # always add in the entire arch flavor. We need to ensure the # relevant flavor is unique per architecture, also, arch flavors # can affect the macros used. if defaultFlavor is not None: relevantFlavor.union(flavor) relevantFlavor.union(flavorutil.getArchFlags(fullFlavor)) relevantFlags = flavorutil.getFlavorUseFlags(relevantFlavor) flags = flavorutil.getFlavorUseFlags(fullFlavor) use.track(False) for flagSet in ('Use', ): # allow local flags not to be used -- they are set to their default if flagSet not in relevantFlags: continue for flag in relevantFlags[flagSet]: if flag not in flags[flagSet]: raise (RuntimeError, "Recipe %s uses Flavor %s but value not known" % (name, flag)) if 'Arch' in relevantFlags: for majarch in relevantFlags['Arch'].keys(): for subarch in relevantFlags['Arch'][majarch]: if not use.Arch[majarch][subarch]: #negative values for subarches are assumed continue if subarch not in flags['Arch'][majarch]: log.error("arch %s.%s used but not specified" % (majarch, subarch)) raise RuntimeError, ( "arch %s.%s used but not specified" % (majarch, subarch)) use.resetUsed() except: log.error('Error Loading Recipe (%s, %s, %s):\n%s' % (name, version, fullFlavor, ''.join(traceback.format_exc()))) raise return loader, recipeObj, relevantFlavor