def _getPathList(repos, cfg, recipePath, relative=False): loader, recipeClass, sourceVersion = cook.getRecipeInfoFromPath(repos, cfg, recipePath) log.info("Getting relevant path information from %s..." % recipeClass.name) recipeDir = os.path.dirname(recipePath) srcdirs = [ recipeDir ] recipeObj = None buildLabel = sourceVersion.trailingLabel() macros = {'buildlabel' : buildLabel.asString(), 'buildbranch' : sourceVersion.branch().asString()} if recipe.isPackageRecipe(recipeClass): recipeObj = recipeClass(cfg, None, srcdirs, macros, lightInstance=True) elif recipe.isGroupRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, None, None, srcdirs=srcdirs, extraMacros=macros) else: # no included files for the rest of the recipe types pathList = [recipePath] recipeObj = None if recipeObj: try: if hasattr(recipeObj, 'loadPolicy'): recipeObj.loadPolicy() cook._callSetup(cfg, recipeObj) except (conaryerrors.ConaryError, conaryerrors.CvcError), msg: raise errors.RmakeError("could not initialize recipe: %s" % (msg)) pathList = recipeObj.fetchLocalSources() + [recipePath ]
def testTwoSuperClasses(self): # You can't commit a recipe with two recipe classes (this would break # loadSuperClass's return value) self.assertRaises(builderrors.LoadRecipeError, self.makeSourceTrove, 'group-base', """ class GroupBase(GroupRecipe): name='group-base' version = '1.0' clearBuildRequires() class GroupDist(GroupBase): name = 'group-dist' version = '1.0' """) #Chained classes (Though probably redundant) self.makeSourceTrove('group-base', """ loadSuperClass('group-appliance') class GroupBase(GroupApplianceRecipe): clearBuildRequires() name='group-base' version = '1.0' """) for r in ( self.importer.loadSuperClass('group-base', str(self.cfg.buildLabel)), self.importer.loadInstalled('group-base', str(self.cfg.buildLabel))): self.assertTrue(recipe.isGroupRecipe(r)) self.assertEqual(r.__name__, 'GroupBase')
def testTwoSuperClasses(self): # You can't commit a recipe with two recipe classes (this would break # loadSuperClass's return value) self.assertRaises( builderrors.LoadRecipeError, self.makeSourceTrove, 'group-base', """ class GroupBase(GroupRecipe): name='group-base' version = '1.0' clearBuildRequires() class GroupDist(GroupBase): name = 'group-dist' version = '1.0' """) #Chained classes (Though probably redundant) self.makeSourceTrove( 'group-base', """ loadSuperClass('group-appliance') class GroupBase(GroupApplianceRecipe): clearBuildRequires() name='group-base' version = '1.0' """) for r in (self.importer.loadSuperClass('group-base', str(self.cfg.buildLabel)), self.importer.loadInstalled('group-base', str(self.cfg.buildLabel))): self.assertTrue(recipe.isGroupRecipe(r)) self.assertEqual(r.__name__, 'GroupBase')
def testLoadSuperClass(self): # This doesn't actually test the functionality of the load* calls, just # the return values. #Take a look at the return value for r in ( self.importer.loadSuperClass('group-appliance', str(self.cfg.buildLabel)), self.importer.loadInstalled('group-appliance', str(self.cfg.buildLabel))): self.assertTrue(recipe.isGroupRecipe(r)) self.assertEqual(r.__name__, 'GroupApplianceRecipe')
def testLoadSuperClass(self): # This doesn't actually test the functionality of the load* calls, just # the return values. #Take a look at the return value for r in (self.importer.loadSuperClass('group-appliance', str(self.cfg.buildLabel)), self.importer.loadInstalled('group-appliance', str(self.cfg.buildLabel))): self.assertTrue(recipe.isGroupRecipe(r)) self.assertEqual(r.__name__, 'GroupApplianceRecipe')
def getRecipeType(recipeClass): if recipe.isPackageRecipe(recipeClass): return RecipeType.PACKAGE if recipe.isGroupRecipe(recipeClass): return RecipeType.GROUP if recipe.isInfoRecipe(recipeClass): return RecipeType.INFO if recipe.isRedirectRecipe(recipeClass): return RecipeType.REDIRECT if recipe.isFileSetRecipe(recipeClass): return RecipeType.FILESET return RecipeType.UNKNOWN
def getRecipeType(recipeClass): if recipe.isPackageRecipe(recipeClass): return RECIPE_TYPE_PACKAGE if recipe.isGroupRecipe(recipeClass): return RECIPE_TYPE_GROUP if recipe.isInfoRecipe(recipeClass): return RECIPE_TYPE_INFO if recipe.isRedirectRecipe(recipeClass): return RECIPE_TYPE_REDIRECT if recipe.isFileSetRecipe(recipeClass): return RECIPE_TYPE_FILESET return RECIPE_TYPE_UNKNOWN
def getRecipeObj(repos, name, version, flavor, trv, loadInstalledSource=None, installLabelPath=None, loadRecipeSpecs=None, buildLabel=None, groupRecipeSource=None, cfg=None): if cfg: cfg = copy.deepcopy(cfg) else: cfg = conarycfg.ConaryConfiguration(False) cfg.initializeFlavors() branch = version.branch() if not buildLabel: buildLabel = version.branch().label() if not installLabelPath: cfg.installLabelPath = [buildLabel] else: cfg.installLabelPath = installLabelPath cfg.buildFlavor = flavor cfg.defaultBasePackages = [] name = name.split(':')[0] use.LocalFlags._clear() assert (flavorutil.getArch(flavor)) use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) ignoreInstalled = not loadInstalledSource macros = { 'buildlabel': buildLabel.asString(), 'buildbranch': version.branch().asString() } cfg.lookaside = tempfile.mkdtemp() try: loader = RecipeLoaderFromSourceTrove(trv, repos, cfg, name + ':source', branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, buildFlavor=flavor) recipeClass = loader.getRecipe() recipeClass._trove = trv if recipe.isGroupRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, None, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.loadPolicy() recipeObj.setup() elif (recipe.isPackageRecipe(recipeClass) or recipe.isFactoryRecipe(recipeClass) or recipe.isCapsuleRecipe(recipeClass)): if recipe.isFactoryRecipe(recipeClass): #This requires a specific capability in conary compat.ConaryVersion().requireFactoryRecipeGeneration() #Load the FactoryRecipe factoryClass = recipeClass loaded = cook.loadFactoryRecipe(factoryClass, cfg, repos, flavor) recipeClass = loaded.getRecipe() lcache = lookaside.RepositoryCache(repos) recipeObj = recipeClass(cfg, lcache, [], macros, lightInstance=True) recipeObj.sourceVersion = version recipeObj.populateLcache() if not recipeObj.needsCrossFlags(): recipeObj.crossRequires = [] recipeObj.loadPolicy() recipeObj.setup() elif recipe.isInfoRecipe(recipeClass): recipeObj = recipeClass(cfg, None, None, macros) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isRedirectRecipe(recipeClass): binaryBranch = version.getBinaryVersion().branch() recipeObj = recipeClass(repos, cfg, binaryBranch, flavor) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isFileSetRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.setup() else: raise RuntimeError, 'Unknown class type %s for recipe %s' % ( recipeClass, name) finally: util.rmtree(cfg.lookaside) return recipeObj, loader
def getRecipeObj( repos, name, version, flavor, trv, loadInstalledSource=None, installLabelPath=None, loadRecipeSpecs=None, buildLabel=None, groupRecipeSource=None, cfg=None, ): if cfg: cfg = copy.deepcopy(cfg) else: cfg = conarycfg.ConaryConfiguration(False) cfg.initializeFlavors() branch = version.branch() if not buildLabel: buildLabel = version.branch().label() if not installLabelPath: cfg.installLabelPath = [buildLabel] else: cfg.installLabelPath = installLabelPath cfg.buildFlavor = flavor cfg.defaultBasePackages = [] name = name.split(":")[0] use.LocalFlags._clear() assert flavorutil.getArch(flavor) use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) ignoreInstalled = not loadInstalledSource macros = {"buildlabel": buildLabel.asString(), "buildbranch": version.branch().asString()} cfg.lookaside = tempfile.mkdtemp() try: loader = RecipeLoaderFromSourceTrove( trv, repos, cfg, name + ":source", branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, buildFlavor=flavor, ) recipeClass = loader.getRecipe() recipeClass._trove = trv if recipe.isGroupRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, None, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.loadPolicy() recipeObj.setup() elif ( recipe.isPackageRecipe(recipeClass) or recipe.isFactoryRecipe(recipeClass) or recipe.isCapsuleRecipe(recipeClass) ): if recipe.isFactoryRecipe(recipeClass): # This requires a specific capability in conary compat.ConaryVersion().requireFactoryRecipeGeneration() # Load the FactoryRecipe factoryClass = recipeClass loaded = cook.loadFactoryRecipe(factoryClass, cfg, repos, flavor) recipeClass = loaded.getRecipe() lcache = lookaside.RepositoryCache(repos) recipeObj = recipeClass(cfg, lcache, [], macros, lightInstance=True) recipeObj.sourceVersion = version recipeObj.populateLcache() if not recipeObj.needsCrossFlags(): recipeObj.crossRequires = [] recipeObj.loadPolicy() recipeObj.setup() elif recipe.isInfoRecipe(recipeClass): recipeObj = recipeClass(cfg, None, None, macros) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isRedirectRecipe(recipeClass): binaryBranch = version.getBinaryVersion().branch() recipeObj = recipeClass(repos, cfg, binaryBranch, flavor) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isFileSetRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.setup() else: raise RuntimeError, "Unknown class type %s for recipe %s" % (recipeClass, name) finally: util.rmtree(cfg.lookaside) return recipeObj, loader