Ejemplo n.º 1
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
Ejemplo n.º 2
0
def loadRecipeClass(
    repos,
    name,
    version,
    flavor,
    trv=None,
    ignoreInstalled=True,
    root=None,
    loadInstalledSource=None,
    overrides=None,
    buildLabel=None,
    cfg=None,
):
    if trv is None:
        trv = repos.getTrove(name, version, deps.parseFlavor(""), withFiles=True)

    if cfg is None:
        cfg = conarycfg.ConaryConfiguration(False)
    else:
        cfg = copy.deepcopy(cfg)
    cfg.initializeFlavors()
    if root:
        cfg.root = root
    branch = version.branch()
    label = version.branch().label()
    cfg.buildLabel = label
    cfg.buildFlavor = flavor
    name = name.split(":")[0]

    use.LocalFlags._clear()
    use.setBuildFlagsFromFlavor(name, flavor, error=False)
    use.resetUsed()
    use.track(True)

    loader = RecipeLoaderFromSourceTrove(
        trv,
        repos,
        cfg,
        name + ":source",
        branch,
        ignoreInstalled=ignoreInstalled,
        db=loadInstalledSource,
        overrides=overrides,
        buildFlavor=flavor,
    )
    recipeClass = loader.getRecipe()
    recipeClass._trove = trv

    use.track(False)
    localFlags = flavorutil.getLocalFlags()
    usedFlags = use.getUsed()
    use.LocalFlags._clear()
    return loader, recipeClass, localFlags, usedFlags
Ejemplo n.º 3
0
def loadRecipeClass(repos,
                    name,
                    version,
                    flavor,
                    trv=None,
                    ignoreInstalled=True,
                    root=None,
                    loadInstalledSource=None,
                    overrides=None,
                    buildLabel=None,
                    cfg=None):
    if trv is None:
        trv = repos.getTrove(name,
                             version,
                             deps.parseFlavor(''),
                             withFiles=True)

    if cfg is None:
        cfg = conarycfg.ConaryConfiguration(False)
    else:
        cfg = copy.deepcopy(cfg)
    cfg.initializeFlavors()
    if root:
        cfg.root = root
    branch = version.branch()
    label = version.branch().label()
    cfg.buildLabel = label
    cfg.buildFlavor = flavor
    name = name.split(':')[0]

    use.LocalFlags._clear()
    use.setBuildFlagsFromFlavor(name, flavor, error=False)
    use.resetUsed()
    use.track(True)

    loader = RecipeLoaderFromSourceTrove(trv,
                                         repos,
                                         cfg,
                                         name + ':source',
                                         branch,
                                         ignoreInstalled=ignoreInstalled,
                                         db=loadInstalledSource,
                                         overrides=overrides,
                                         buildFlavor=flavor)
    recipeClass = loader.getRecipe()
    recipeClass._trove = trv

    use.track(False)
    localFlags = flavorutil.getLocalFlags()
    usedFlags = use.getUsed()
    use.LocalFlags._clear()
    return loader, recipeClass, localFlags, usedFlags
Ejemplo n.º 4
0
        # get the correct environment variables from this root
        # some packages depend on environment variables e.g. $QTDIR that
        # are set by other packages.
        setupEnvironment()

        # now override flags set in flavor
        # don't need to reset this flavor ever, because
        # we are in a fork
        flavorutil.setLocalFlags(localFlags)
        packageName = name.split(':')[0]
        # this shouldn't matter for group recipes as it will get overridden
        # by the behavior in cookGroupObject.  But it matters for some other
        # recipe types.  That should be fixed and all that code should be
        # moved inside cookObject so I could get rid of this.
        use.setBuildFlagsFromFlavor(packageName, cfg.buildFlavor, error=False)
        use.resetUsed()
        use.setUsed(usedFlags)

        # we don't want to sign packages here, if necessary, we can sign
        # them at a higher level.
        cfg.signatureKeyMap = {}
        cfg.signatureKey = None
        crossCompile = flavorutil.getCrossCompile(cfg.buildFlavor)

        # add extra buildreqs manually added for this trove
        # by the builder.  Only add them if the recipe is of the
        # right type, and the cfg file we're passed in understands them
        # (it might be a simple conary cfg file).
        if (hasattr(recipeClasses[0], 'buildRequires')
                and hasattr(cfg, 'defaultBuildReqs')):
            for recipeClass in recipeClasses:
Ejemplo n.º 5
0
        # get the correct environment variables from this root
        # some packages depend on environment variables e.g. $QTDIR that 
        # are set by other packages.  
        setupEnvironment()

        # now override flags set in flavor
        # don't need to reset this flavor ever, because
        # we are in a fork
        flavorutil.setLocalFlags(localFlags)
        packageName = name.split(':')[0]
        # this shouldn't matter for group recipes as it will get overridden
        # by the behavior in cookGroupObject.  But it matters for some other
        # recipe types.  That should be fixed and all that code should be
        # moved inside cookObject so I could get rid of this.
        use.setBuildFlagsFromFlavor(packageName, cfg.buildFlavor, error=False)
        use.resetUsed()
        use.setUsed(usedFlags)


        # we don't want to sign packages here, if necessary, we can sign
        # them at a higher level.
        cfg.signatureKeyMap = {}
        cfg.signatureKey = None
        crossCompile = flavorutil.getCrossCompile(cfg.buildFlavor)

        # add extra buildreqs manually added for this trove
        # by the builder.  Only add them if the recipe is of the
        # right type, and the cfg file we're passed in understands them
        # (it might be a simple conary cfg file).
        if (hasattr(recipeClasses[0], 'buildRequires')
            and hasattr(cfg, 'defaultBuildReqs')):
Ejemplo n.º 6
0
 def testTrack(self):
     Use = use.UseCollection()
     Use._addFlag('foo', value=True) 
     Use._addFlag('bar', value=False) 
     Use._addFlag('bam', value=False) 
     assert(Use._getUsed() == [])
     Use._trackUsed(True)
     assert(bool(Use.foo))
     assert(str(Use._getUsed()) == '[foo: True]')
     Use._trackUsed(False)
     bool(Use.bar)
     assert(str(Use._getUsed()) == '[foo: True]')
     Use._resetUsed()
     assert(Use._getUsed() == [])
     Use.foo._set(False)
     Use._trackUsed(True)
     assert(not bool(Use.foo))
     Use._getUsed()
     assert(str(Use._getUsed()) == '[foo: False]')
     Use._trackUsed(False)
     use.setUsed([Use.bar])
     Use._getUsed()
     assert(str(Use._getUsed()) == '[foo: False, bar: False]')
     Use._resetUsed()
     Use._trackUsed(True)
     Use.bar._set()
     assert(bool(Use.bar))
     Use._getUsed()
     assert(str(Use._getUsed()) == '[bar: True]')
     Use._resetUsed()
     Use.bar._set()
     Use.foo._set(False)
     Use._trackUsed(True)
     assert(Use.bar | Use.foo)
     assert(set(x._name for x in Use._iterUsed())  == set(['bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert(not Use.foo & Use.bar)
     assert(set(x._name for x in Use._iterUsed())  == set(['bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert(not (Use.foo & Use.bar & Use.bam))
     sorted(x._name for x in Use._iterUsed())
     assert(set(x._name for x in Use._iterUsed()) == \
             set(['bam', 'bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert(Use.foo | Use.bar | Use.bam)
     assert(set(x._name for x in Use._iterUsed()) == \
             set(['bam', 'bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert(not (Use.foo == True))
     assert([x._name for x in Use._iterUsed()] == ['foo'])
     Use._resetUsed()
     Use._trackUsed(True)
     assert(True != Use.foo)
     assert([x._name for x in Use._iterUsed()] == ['foo'])
     Arch = use.Arch
     use.resetUsed()
     use.track(True)
     assert(not bool(Arch.ppc.ppc64))
     use.track(False)
     assert(use.getUsed() == [Arch.getCurrentArch()])
Ejemplo n.º 7
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
 def testTrack(self):
     Use = use.UseCollection()
     Use._addFlag('foo', value=True)
     Use._addFlag('bar', value=False)
     Use._addFlag('bam', value=False)
     assert (Use._getUsed() == [])
     Use._trackUsed(True)
     assert (bool(Use.foo))
     assert (str(Use._getUsed()) == '[foo: True]')
     Use._trackUsed(False)
     bool(Use.bar)
     assert (str(Use._getUsed()) == '[foo: True]')
     Use._resetUsed()
     assert (Use._getUsed() == [])
     Use.foo._set(False)
     Use._trackUsed(True)
     assert (not bool(Use.foo))
     Use._getUsed()
     assert (str(Use._getUsed()) == '[foo: False]')
     Use._trackUsed(False)
     use.setUsed([Use.bar])
     Use._getUsed()
     assert (str(Use._getUsed()) == '[foo: False, bar: False]')
     Use._resetUsed()
     Use._trackUsed(True)
     Use.bar._set()
     assert (bool(Use.bar))
     Use._getUsed()
     assert (str(Use._getUsed()) == '[bar: True]')
     Use._resetUsed()
     Use.bar._set()
     Use.foo._set(False)
     Use._trackUsed(True)
     assert (Use.bar | Use.foo)
     assert (set(x._name for x in Use._iterUsed()) == set(['bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert (not Use.foo & Use.bar)
     assert (set(x._name for x in Use._iterUsed()) == set(['bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert (not (Use.foo & Use.bar & Use.bam))
     sorted(x._name for x in Use._iterUsed())
     assert(set(x._name for x in Use._iterUsed()) == \
             set(['bam', 'bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert (Use.foo | Use.bar | Use.bam)
     assert(set(x._name for x in Use._iterUsed()) == \
             set(['bam', 'bar', 'foo']))
     Use._resetUsed()
     Use._trackUsed(True)
     assert (not (Use.foo == True))
     assert ([x._name for x in Use._iterUsed()] == ['foo'])
     Use._resetUsed()
     Use._trackUsed(True)
     assert (True != Use.foo)
     assert ([x._name for x in Use._iterUsed()] == ['foo'])
     Arch = use.Arch
     use.resetUsed()
     use.track(True)
     assert (not bool(Arch.ppc.ppc64))
     use.track(False)
     assert (use.getUsed() == [Arch.getCurrentArch()])