Exemple #1
0
        def testOne(dir, flagList, emptyPreferred=True):
            files = os.listdir(dir)
            for fileName in files:
                os.unlink(os.path.join(dir, fileName))

            for (flag, sense) in flagList:
                f = open(os.path.join(dir, flag), "w")
                if sense == deps.FLAG_SENSE_PREFERRED:
                    if not emptyPreferred:
                        f.write('sense preferred\n')
                elif sense == deps.FLAG_SENSE_PREFERNOT:
                    f.write('sense prefernot\n')
                elif sense == deps.FLAG_SENSE_DISALLOWED:
                    f.write('sense disallowed\n')
                elif sense == deps.FLAG_SENSE_REQUIRED:
                    f.write('sense required\n')
                else:
                    assert (0)

                f.close()

            use = flavorcfg.FlavorConfig(dir, '')
            cmp = deps.Flavor()
            cmp.addDep(deps.UseDependency, deps.Dependency('use', flagList))
            assert (use.toDependency() == cmp)
Exemple #2
0
    def initializeFlavors(self):
        """
        Initialize flavor preferences based on files typically
        found in /etc/conary/arch (archDirs) and /etc/conary/use

        @raises RuntimeError: Raised if use flags conflict in
        a way which cannot be reconciled
        (see L{deps.DependencyClass.MergeFlags})

        """
        self.flavorConfig = flavorcfg.FlavorConfig(self.useDirs, self.archDirs)
        if self.flavor == []:
            self.flavor = [deps.Flavor()]

        self.flavor = self.flavorConfig.toDependency(override=self.flavor)

        newFlavors = []
        hasIns = False

        # if any flavor has an instruction set, don't merge
        for flavor in self.flavor:
            if deps.DEP_CLASS_IS in flavor.getDepClasses():
                hasIns = True
                break

        if not hasIns:
            # use all the flavors for the main arch first
            for depList in arch.currentArch:
                for flavor in self.flavor:
                    insSet = deps.Flavor()
                    for dep in depList:
                        insSet.addDep(deps.InstructionSetDependency, dep)
                    newFlavor = flavor.copy()
                    newFlavor.union(insSet)
                    newFlavors.append(newFlavor)
            self.flavor = newFlavors

        # buildFlavor is installFlavor + overrides
        self.buildFlavor = deps.overrideFlavor(self.flavor[0],
                                               self.buildFlavor)
        if self.isDefault('flavorPreferences'):
            self.flavorPreferences = arch.getFlavorPreferencesFromFlavor(
                self.flavor[0])
        self.flavorConfig.populateBuildFlags()