Exemple #1
0
    def getSearchSource(self, flavor=0, troveSource=None, installLabelPath=0):
        """
        @return: a searchSourceStack
        @rtype: conary.repository.searchsource.NetworkSearchSource
        @raises ConaryError: raised if SearchSourceStack creation fails
        @raises ParseError: raised if an element in the search path is malformed.
        """
        # a flavor of None is common in some cases so we use 0
        # as our "unset" case.
        if flavor is 0:
            flavor = self.cfg.flavor
        if installLabelPath is 0:
            installLabelPath = self.cfg.installLabelPath

        searchMethod = resolvemethod.RESOLVE_LEAVES_FIRST
        if troveSource is None:
            troveSource = self.getRepos()
            if troveSource is None:
                return None
        searchSource = searchsource.NetworkSearchSource(troveSource,
                            installLabelPath,
                            flavor, self.db,
                            resolveSearchMethod=searchMethod)
        if self.cfg.searchPath:
            return searchsource.createSearchSourceStackFromStrings(
                                                         searchSource,
                                                         self.cfg.searchPath,
                                                         flavor,
                                                         db=self.db)
        else:
            return searchSource
Exemple #2
0
    def testNetworkSearchSource(self):
        repos = self.openRepository()
        trv1 = self.addComponent('foo:runtime', '1', 'ssl')
        trv2 = self.addComponent('foo:runtime', '2', '!ssl')

        s = searchsource.NetworkSearchSource(repos, self.cfg.installLabelPath,
                                             parseFlavor('ssl'))
        tup = s.findTrove(('foo:runtime', None, None))[0]
        assert(tup == trv1.getNameVersionFlavor())
        tup = s.findTrove(('foo:runtime', None, parseFlavor('!ssl')))[0]
        assert(tup == trv2.getNameVersionFlavor())
        trv = s.getTrove(*tup)
        assert(trv == trv2)
        cs = s.createChangeSet([(tup[0], (None, None), (tup[1], tup[2]), True)])
        trvCs = cs.getNewTroveVersion(*trv.getNameVersionFlavor())
        trv = trove.Trove(trvCs)
        assert(trv == trv2)
        assert(list(s.iterFilesInTrove(*trv.getNameVersionFlavor()))
               == list(repos.iterFilesInTrove(*trv.getNameVersionFlavor())))

        # test dep resolution - the resolve source for this should check
        # the right branch.
        self.cfg.installLabelPath = [versions.Label('localhost@rpl:branch')]
        self.addComponent('bar:runtime', ':branch/1', filePrimer=1, 
                          requires='trove:foo:runtime')
        self.checkUpdate('bar:runtime', ['bar:runtime', 'foo:runtime=1'],
                          resolveSource=s.getResolveMethod(), resolve=True)
Exemple #3
0
    def _createRepositoryTroveSet(self, repos, g, csTroveSet=None):
        if csTroveSet is None:
            path = []
        else:
            path = [csTroveSet]

        repos = troveset.SearchSourceTroveSet(searchsource.NetworkSearchSource(
            repos, [], self.cfg.flavor),
                                              graph=g)
        path.append(repos)

        return CMLSearchPath(path, graph=g)
Exemple #4
0
    def augment(self, model, totalSearchSet, finalTroveSet):
        collections = set()
        for op in model.modelOps:
            if isinstance(op, model.SearchOperation):
                continue

            for troveTup in op:
                name = troveTup[0]
                if (isinstance(op, model.OfferTroveOperation)
                        or trove.troveIsComponent(name)):
                    collections.add(name.split(':')[0])
                elif trove.troveIsGroup(name):
                    collections.add(name)

        # this represents the path from "search" lines
        newSearchPath = []
        rebuildTotalSearchSet = False
        # the "total search" searches the current troveset first, then the
        # search path. we only reset this when an operation changed the
        # working troveset in a way which would affect later operations,
        # after searchTroveSet chagnes
        # changed the current troveset in a way which a

        # finalTroveSet is the current working set of what's been selected
        # so far

        for op in model.modelOps:
            if isinstance(op, model.SearchOperation):
                partialTup = op.item
                if isinstance(partialTup, versions.Label):
                    newSearchTroveSet = troveset.SearchSourceTroveSet(
                        searchsource.NetworkSearchSource(
                            self.repos, [partialTup], self.flavor),
                        graph=self.g)
                    newSearchSet = newSearchTroveSet
                elif partialTup[0] is not None:
                    newSearchSet = self.reposTroveSet.find(partialTup)
                else:
                    assert (0)

                newSearchPath.insert(0, newSearchSet)
                rebuildTotalSearchSet = True
                continue

            searchSpecs = []
            localSpecs = []
            for troveSpec in op:
                if (troveSpec.version is not None
                        and troveSpec.version[0] == '/'):
                    try:
                        verObj = versions.VersionFromString(troveSpec.version)
                        if verObj.isInLocalNamespace():
                            localSpecs.append(troveSpec)
                            continue

                    except (errors.VersionStringError, errors.ParseError):
                        pass

                searchSpecs.append(troveSpec)

            if isinstance(op, model.EraseTroveOperation):
                eraseMatches = self._splitFind(self.EraseFindAction,
                                               finalTroveSet, searchSpecs, op)

                finalTroveSet = finalTroveSet._action(
                    eraseMatches,
                    ActionClass=self.RemoveAction,
                    index=op.getLocation())
                continue

            if isinstance(op, model.IncludeOperation):
                # we need a complete total search set to pass into the sub
                # ops, since they have their compilation deferred
                rebuildTotalSearchSet = True

            if rebuildTotalSearchSet:
                totalSearchSet = self.SearchPathTroveSet(newSearchPath +
                                                         [totalSearchSet],
                                                         graph=self.g)
                newSearchPath = []
                rebuildTotalSearchSet = False

            searchMatches = self._splitFind(self.FindAction, totalSearchSet,
                                            searchSpecs, op)
            localMatches = self._splitFind(self.FindAction, self.dbTroveSet,
                                           localSpecs, op)

            if searchMatches and localMatches:
                matches = searchMatches._action(localMatches,
                                                ActionClass=self.UnionAction,
                                                index=op.getLocation())
            elif searchMatches:
                matches = searchMatches
            else:
                matches = localMatches

            if isinstance(op, model.IncludeOperation):
                assert (not localMatches)
                finalTroveSet = finalTroveSet._action(
                    matches,
                    totalSearchSet,
                    compiler=self,
                    ActionClass=self.IncludeAction,
                    SearchPathClass=self.SearchPathTroveSet)
                totalSearchSet = finalTroveSet.finalSearchSet
                continue
            elif isinstance(op, model.InstallTroveOperation):
                finalTroveSet = finalTroveSet._action(
                    matches,
                    ActionClass=self.UnionAction,
                    index=op.getLocation())
            elif isinstance(op, model.PatchTroveOperation):
                finalTroveSet = finalTroveSet._action(
                    matches,
                    ActionClass=self.PatchAction,
                    index=op.getLocation())
            elif isinstance(op, model.UpdateTroveOperation):
                finalTroveSet = finalTroveSet._action(
                    matches,
                    ActionClass=self.UpdateAction,
                    index=op.getLocation())
            elif isinstance(op, model.OfferTroveOperation):
                finalTroveSet = finalTroveSet._action(
                    matches,
                    ActionClass=self.OptionalAction,
                    index=op.getLocation())
            else:
                assert (0)

            newSearchPath.insert(0, matches)

            for troveSpec in op:
                if troveSpec.name in collections:
                    rebuildTotalSearchSet = True
                    break

        if newSearchPath:
            totalSearchSet = self.SearchPathTroveSet(newSearchPath +
                                                     [totalSearchSet],
                                                     graph=self.g)

        finalTroveSet.searchPath = totalSearchSet

        return finalTroveSet