예제 #1
0
 def filterResolutionsPostUpdate(self, db, jobSet, troveSource):
     # Now that we know how conary would line up these dependencies
     # to installed troves.
     # We can't resolve deps in a way that would cause conary to
     # switch the branch of a trove.
     badJobs = [ x for x in jobSet
                         if (x[1][0] and
                             x[1][0].trailingLabel() != x[2][0].trailingLabel()) ]
     badJobs += [ x for x in jobSet \
                  if (x[1][0] and \
                      deps.getInstructionSetFlavor(x[1][1]) \
                      != deps.getInstructionSetFlavor(x[2][1])) ]
     if badJobs:
         jobSet.difference_update(badJobs)
         oldTroves = db.getTroves(
               [ (x[0], x[1][0], x[1][1]) for x in badJobs ],
               withFiles = False)
         newTroves = troveSource.getTroves(
               [ (x[0], x[2][0], x[2][1]) for x in badJobs ],
               withFiles = False)
         for job, oldTrv, newTrv in itertools.izip(badJobs,
                                                   oldTroves,
                                                   newTroves):
             if oldTrv.compatibleWith(newTrv):
                 jobSet.add((job[0], (None, None), job[2], False))
     return jobSet
예제 #2
0
 def filterResolutionsPostUpdate(self, db, jobSet, troveSource):
     # Now that we know how conary would line up these dependencies
     # to installed troves.
     # We can't resolve deps in a way that would cause conary to
     # switch the branch of a trove.
     badJobs = [
         x for x in jobSet
         if (x[1][0] and x[1][0].trailingLabel() != x[2][0].trailingLabel())
     ]
     badJobs += [ x for x in jobSet \
                  if (x[1][0] and \
                      deps.getInstructionSetFlavor(x[1][1]) \
                      != deps.getInstructionSetFlavor(x[2][1])) ]
     if badJobs:
         jobSet.difference_update(badJobs)
         oldTroves = db.getTroves([(x[0], x[1][0], x[1][1])
                                   for x in badJobs],
                                  withFiles=False)
         newTroves = troveSource.getTroves([(x[0], x[2][0], x[2][1])
                                            for x in badJobs],
                                           withFiles=False)
         for job, oldTrv, newTrv in itertools.izip(badJobs, oldTroves,
                                                   newTroves):
             if oldTrv.compatibleWith(newTrv):
                 jobSet.add((job[0], (None, None), job[2], False))
     return jobSet
예제 #3
0
    def selectResolutionTrove(self, requiredBy, dep, depClass,
                              troveTups, installFlavor, affFlavorDict):
        """
            determine which of the given set of troveTups is the 
            best choice for installing on this system.  Because the
            repository didn't try to determine which flavors are best for 
            our system, we have to filter the troves locally.  
        """
        #NOTE: this method should be a match exactly for the one in 
        # conary.repository.resolvemethod for conary 1.2 and later.
        # when we drop support for earlier conary's we can drop this method.
        # we filter the troves in the following ways:
        # 1. prefer troves that match affinity flavor + are on the affinity
        # label. (And don't drop an arch)
        # 2. fall back to troves that match the install flavor.

        # If we don't match an affinity flavor + label, then use flavor
        # preferences and flavor scoring to select the best flavor.
        # We'll have to check 

        # Within these two categories:
        # 1. filter via flavor preferences for each trove (this may result
        # in an older version for some troves)
        # 2. only leave the latest version for each trove
        # 3. pick the best flavor out of the remaining
        affinityMatches = []
        affinityFlavors = []
        otherMatches = []
        otherFlavors = []

        if installFlavor is not None and not installFlavor.isEmpty():
            flavoredList = []
            for troveTup in troveTups:
                label = troveTup[1].trailingLabel()
                affTroves = affFlavorDict[troveTup[0]]
                found = False
                if affTroves:
                    for affName, affVersion, affFlavor in affTroves:
                        if affVersion.trailingLabel() != label:
                            continue
                        newFlavor = deps.overrideFlavor(installFlavor,
                                                        affFlavor,
                                            mergeType=deps.DEP_MERGE_TYPE_PREFS)
                        # implement never drop an arch for dep resolution
                        currentArch = deps.getInstructionSetFlavor(affFlavor)
                        if not troveTup[2].stronglySatisfies(currentArch):
                            continue
                        if newFlavor.satisfies(troveTup[2]):
                            affinityMatches.append((newFlavor, troveTup))
                            affinityFlavors.append(troveTup[2])
                            found = True
                if not found and not affinityMatches:
                    if installFlavor.satisfies(troveTup[2]):
                        otherMatches.append((installFlavor, troveTup))
                        otherFlavors.append(troveTup[2])
        else:
            otherMatches = [ (None, x) for x in troveTups ]
            otherFlavors = [x[2] for x in troveTups]
        if affinityMatches:
            allFlavors = affinityFlavors
            flavoredList = affinityMatches
        else:
            allFlavors = otherFlavors
            flavoredList = otherMatches

        # Now filter by flavor preferences.
        newFlavors = []
        if self.flavorPreferences:
            for flavor in self.flavorPreferences:
                for trvFlavor in allFlavors:
                    if trvFlavor.stronglySatisfies(flavor):
                       newFlavors.append(trvFlavor)
                if newFlavors:
                    break
        if newFlavors:
            flavoredList = [ x for x in flavoredList if x[1][2] in newFlavors ]

        return self._selectMatchingResolutionTrove(requiredBy, dep,
                                                   depClass, flavoredList)
예제 #4
0
    def selectResolutionTrove(self, requiredBy, dep, depClass, troveTups,
                              installFlavor, affFlavorDict):
        """
            determine which of the given set of troveTups is the 
            best choice for installing on this system.  Because the
            repository didn't try to determine which flavors are best for 
            our system, we have to filter the troves locally.  
        """
        #NOTE: this method should be a match exactly for the one in
        # conary.repository.resolvemethod for conary 1.2 and later.
        # when we drop support for earlier conary's we can drop this method.
        # we filter the troves in the following ways:
        # 1. prefer troves that match affinity flavor + are on the affinity
        # label. (And don't drop an arch)
        # 2. fall back to troves that match the install flavor.

        # If we don't match an affinity flavor + label, then use flavor
        # preferences and flavor scoring to select the best flavor.
        # We'll have to check

        # Within these two categories:
        # 1. filter via flavor preferences for each trove (this may result
        # in an older version for some troves)
        # 2. only leave the latest version for each trove
        # 3. pick the best flavor out of the remaining
        affinityMatches = []
        affinityFlavors = []
        otherMatches = []
        otherFlavors = []

        if installFlavor is not None and not installFlavor.isEmpty():
            flavoredList = []
            for troveTup in troveTups:
                label = troveTup[1].trailingLabel()
                affTroves = affFlavorDict[troveTup[0]]
                found = False
                if affTroves:
                    for affName, affVersion, affFlavor in affTroves:
                        if affVersion.trailingLabel() != label:
                            continue
                        newFlavor = deps.overrideFlavor(
                            installFlavor,
                            affFlavor,
                            mergeType=deps.DEP_MERGE_TYPE_PREFS)
                        # implement never drop an arch for dep resolution
                        currentArch = deps.getInstructionSetFlavor(affFlavor)
                        if not troveTup[2].stronglySatisfies(currentArch):
                            continue
                        if newFlavor.satisfies(troveTup[2]):
                            affinityMatches.append((newFlavor, troveTup))
                            affinityFlavors.append(troveTup[2])
                            found = True
                if not found and not affinityMatches:
                    if installFlavor.satisfies(troveTup[2]):
                        otherMatches.append((installFlavor, troveTup))
                        otherFlavors.append(troveTup[2])
        else:
            otherMatches = [(None, x) for x in troveTups]
            otherFlavors = [x[2] for x in troveTups]
        if affinityMatches:
            allFlavors = affinityFlavors
            flavoredList = affinityMatches
        else:
            allFlavors = otherFlavors
            flavoredList = otherMatches

        # Now filter by flavor preferences.
        newFlavors = []
        if self.flavorPreferences:
            for flavor in self.flavorPreferences:
                for trvFlavor in allFlavors:
                    if trvFlavor.stronglySatisfies(flavor):
                        newFlavors.append(trvFlavor)
                if newFlavors:
                    break
        if newFlavors:
            flavoredList = [x for x in flavoredList if x[1][2] in newFlavors]

        return self._selectMatchingResolutionTrove(requiredBy, dep, depClass,
                                                   flavoredList)