Example #1
0
 def _filterBuildReqsByFlavor(flavor, troves):
     troves.sort(key=lambda x: x.getVersion())
     if flavor is None:
         # get latest
         return troves[-1]
     for trove in troves:
         troveFlavor = trove.getFlavor()
         if troveFlavor.stronglySatisfies(flavor):
             return trove
Example #2
0
 def _filterBuildReqsByFlavor(flavor, troves):
     troves.sort(key=lambda x: x.getVersion())
     if flavor is None:
         # get latest
         return troves[-1]
     for trove in troves:
         troveFlavor = trove.getFlavor()
         if troveFlavor.stronglySatisfies(flavor):
             return trove
Example #3
0
 def _addReq(self, trove, buildReq, isCross=False):
     name, label, flavor = buildReq
     pkg = name.split(':')[0]
     providingTroves = self.trovesByPackage.get(pkg, [])
     for provTrove in providingTroves:
         # this trove must be built after the providing trove,
         # which means that provTrove should be a leaf first.
         if (not isCross and trove.hasTargetArch()
             and provTrove.isCrossCompiled()):
             self.rejectDep(trove, provTrove, isCross)
         elif self._flavorsMatch(trove.getFlavor(), provTrove.getFlavor(),
                               flavor, isCross):
             # only add edges for nodes that are
             # likely to be on a satisfying branch or flavor,
             # otherwise we'll create unnecessary cycles.
             self.dependsOn(trove, provTrove, (isCross, buildReq))
         else:
             self.rejectDep(trove, provTrove, isCross)
Example #4
0
 def _addReq(self, trove, buildReq, isCross=False):
     name, label, flavor = buildReq
     pkg = name.split(':')[0]
     providingTroves = self.trovesByPackage.get(pkg, [])
     for provTrove in providingTroves:
         # this trove must be built after the providing trove,
         # which means that provTrove should be a leaf first.
         if (not isCross and trove.hasTargetArch()
             and provTrove.isCrossCompiled()):
             self.rejectDep(trove, provTrove, isCross)
         elif self._flavorsMatch(trove.getFlavor(), provTrove.getFlavor(),
                               flavor, isCross):
             # only add edges for nodes that are
             # likely to be on a satisfying branch or flavor,
             # otherwise we'll create unnecessary cycles.
             self.dependsOn(trove, provTrove, (isCross, buildReq))
         else:
             self.rejectDep(trove, provTrove, isCross)
Example #5
0
    def formatInfo(self, trove):
        """ returns iterator of format lines about this local trove """
        # TODO: it'd be nice if this were set up to do arbitrary
        # formats...

        n, v, f = trove.getName(), trove.getVersion(), trove.getFlavor()
        dcfg = self.dcfg
        troveSource = dcfg.getTroveSource()

        sourceName = trove.getSourceName()
        sourceTrove = None

        if sourceName:
            try:
                sourceVer = v.getSourceVersion()
                if sourceVer.isOnLocalHost():
                    sourceVer = sourceVer.parentVersion()

                sourceTrove = troveSource.getTrove(
                    sourceName, sourceVer, deps.Flavor(), withFiles = False)
                # FIXME: all trove sources should return TroveMissing
                # on failed getTrove calls
            except errors.TroveMissing:
                pass
            except errors.InsufficientPermission:
                pass

        elif n.endswith(':source'):
            sourceTrove = trove

        if trove.getBuildTime():
            buildTime = time.strftime("%c",
                                time.localtime(trove.getBuildTime()))
        else:
            buildTime = "(unknown)"

        if trove.getSize() is not None:
            size = "%s" % trove.getSize()
        else:
            size = "(unknown)"

        yield "%-30s %s" % \
            (("Name      : %s" % trove.getName(),
             ("Build time: %s" % buildTime)))

        if dcfg.fullVersions:
            yield "Version   : %s" %v
            yield "Label     : %s" % v.branch().label().asString()
        else:
            yield "%-30s %s" % \
                (("Version   : %s" %
                            v.trailingRevision().asString()),
                 ("Label     : %s" %
                            v.branch().label().asString()))

        yield '%-30s' % ("Size      : %s" % size)
        if hasattr(troveSource, 'trovesArePinned'):
            yield "Pinned    : %s" % troveSource.trovesArePinned(
                                                            [ (n, v, f) ])[0]

        commitTime = v.trailingRevision().timeStamp
        if commitTime:
            commitTime = time.strftime("%c", time.localtime(commitTime))
        else:
            commitTime = '(unknown)'
        if not trove.getBuildTime() or log.getVerbosity() <= log.DEBUG:
            yield "Committed : " + commitTime
        yield "%-30s" % ("Flavor    : %s" % deps.formatFlavor(f))
        if trove.getInstallTime():
            yield 'Installed : %s' % (time.strftime("%c",
                time.localtime(trove.getInstallTime())))

        imageGroup = trove.troveInfo.imageGroup()
        if imageGroup is not None:
            yield 'Image Group: %s' % bool(imageGroup)

        for ln in self.formatMetadata(trove):
            yield ln
        if sourceTrove:
            if not n.endswith(':source'):
                yield 'Source    : %s' % trove.getSourceName()
            cl = sourceTrove.getChangeLog()
            if cl:
                yield "Change log: %s (%s)" % (cl.getName(), cl.getContact())
                lines = cl.getMessage().split("\n")[:-1]
                for l in lines:
                    yield "    " + l
        if log.getVerbosity() <= log.DEBUG:
            yield "%-30s %s" % (("Incomp.   : %s" %
                                 bool(trove.troveInfo.incomplete())),
                                ("TroveVer  : %s" %
                                            trove.troveInfo.troveVersion()))
            yield "%-30s" % (("Clone of  : %s" % trove.troveInfo.clonedFrom()))
            subPackages = set(trove.troveInfo.subPackages())
            subPackages.discard(trove.getName())
            if subPackages:
                yield "%-30s" % (("Siblings  : %s" % (' '.join(sorted(subPackages)))))
            yield "%-30s" % (("Conary version : %s" % trove.troveInfo.conaryVersion()))
Example #6
0
    def formatInfo(self, trove):
        """ returns iterator of format lines about this local trove """
        # TODO: it'd be nice if this were set up to do arbitrary
        # formats...

        n, v, f = trove.getName(), trove.getVersion(), trove.getFlavor()
        dcfg = self.dcfg
        troveSource = dcfg.getTroveSource()

        sourceName = trove.getSourceName()
        sourceTrove = None

        if sourceName:
            try:
                sourceVer = v.getSourceVersion()
                if sourceVer.isOnLocalHost():
                    sourceVer = sourceVer.parentVersion()

                sourceTrove = troveSource.getTrove(sourceName,
                                                   sourceVer,
                                                   deps.Flavor(),
                                                   withFiles=False)
                # FIXME: all trove sources should return TroveMissing
                # on failed getTrove calls
            except errors.TroveMissing:
                pass
            except errors.InsufficientPermission:
                pass

        elif n.endswith(':source'):
            sourceTrove = trove

        if trove.getBuildTime():
            buildTime = time.strftime("%c",
                                      time.localtime(trove.getBuildTime()))
        else:
            buildTime = "(unknown)"

        if trove.getSize() is not None:
            size = "%s" % trove.getSize()
        else:
            size = "(unknown)"

        yield "%-30s %s" % \
            (("Name      : %s" % trove.getName(),
             ("Build time: %s" % buildTime)))

        if dcfg.fullVersions:
            yield "Version   : %s" % v
            yield "Label     : %s" % v.branch().label().asString()
        else:
            yield "%-30s %s" % \
                (("Version   : %s" %
                            v.trailingRevision().asString()),
                 ("Label     : %s" %
                            v.branch().label().asString()))

        yield '%-30s' % ("Size      : %s" % size)
        if hasattr(troveSource, 'trovesArePinned'):
            yield "Pinned    : %s" % troveSource.trovesArePinned([(n, v, f)
                                                                  ])[0]

        yield "%-30s" % ("Flavor    : %s" % deps.formatFlavor(f))
        if trove.getInstallTime():
            yield 'Installed : %s' % (time.strftime(
                "%c", time.localtime(trove.getInstallTime())))

        imageGroup = trove.troveInfo.imageGroup()
        if imageGroup is not None:
            yield 'Image Group: %s' % bool(imageGroup)

        for ln in self.formatMetadata(trove):
            yield ln
        if sourceTrove:
            if not n.endswith(':source'):
                yield 'Source    : %s' % trove.getSourceName()
            cl = sourceTrove.getChangeLog()
            if cl:
                yield "Change log: %s (%s)" % (cl.getName(), cl.getContact())
                lines = cl.getMessage().split("\n")[:-1]
                for l in lines:
                    yield "    " + l

        if log.getVerbosity() <= log.DEBUG:
            yield "%-30s %s" % (
                ("Incomp.   : %s" % bool(trove.troveInfo.incomplete())),
                ("TroveVer  : %s" % trove.troveInfo.troveVersion()))
            yield "%-30s" % (("Clone of  : %s" % trove.troveInfo.clonedFrom()))
            yield "%-30s" % (
                ("Conary version : %s" % trove.troveInfo.conaryVersion()))
Example #7
0
    def addSourceTrovesToGraph(self, sourceTroves):
        sourceTroves = [ x for x in sourceTroves if not x.isFailed() ]
        [ self.depGraph.addNode(trove) for trove in sourceTroves ]
        for trove in sourceTroves:
            if trove.isPrepOnly():
                continue
            for package in trove.getDerivedPackages():
                self.trovesByPackage.setdefault(package, []).append(trove)

        for trove in sourceTroves:
            try:
                if trove.isPrimaryTrove():
                    self.hasPrimaryTroves = True
                trove.addBuildRequirements(trove.cfg.defaultBuildReqs)
                if trove.isPrepOnly():
                    continue
                for buildReq in trove.getBuildRequirementSpecs():
                    self._addReq(trove, buildReq, False)

                for crossReq in trove.getCrossRequirementSpecs():
                    self._addReq(trove, crossReq, True)
            except Exception, err:
                errMsg =  'Error adding buildreqs to %s: %s: %s' % (trove.getName(), err.__class__.__name__, err)
                failureReason = failure.LoadFailed(errMsg,
                                                   traceback.format_exc())
                trove.troveFailed(failureReason)
                # We can't continue the build now
                raise errors.RmakeError, errMsg, sys.exc_info()[2]

            # if're loading something that we're also building
            # then we should make sure that we build the thing with the 
            # loadInstalled line secondly
            for loadSpec, sourceTup in trove.iterAllLoadedSpecs():
                name, label, flavor = loadSpec
                providingTroves = self.trovesByPackage.get(name, [])
                for provTrove in providingTroves:
                    if provTrove.getVersion() != sourceTup[1]:
                        continue
                    elif self._flavorsMatch(trove.getFlavor(),
                                            provTrove.getFlavor(),
                                            flavor, False):
                        # FIXME: we really shouldn't allow loadInstalled
                        # loops to occur.  It means that we're building
                        # two recipes that loadInstall each other which
                        # means that we can't even trust the buildReqs
                        # specified for each.
                        self.dependsOn(trove, provTrove, (False, loadSpec))
                    else:
                        self.rejectDep(trove, provTrove, False)

            # If we have multiple groups that are building w/ the same
            # name and version, we send them to be built together.
            if trove.isGroupRecipe():
                name, version = trove.getName(), trove.getVersion()
                if (name, version) not in self.groupsByNameVersion:
                    self.groupsByNameVersion[name, version] = []
                self.groupsByNameVersion[name, version].append(trove)

            # Troves like groups, redirects, etc, have requirements
            # that control when they can be built.
            for sourceTup in trove.getDelayedRequirements():
                name, version, flavor = sourceTup
                package = name.split(':')[0]
                providingTroves = self.trovesByPackage.get(package, [])
                for provTrove in providingTroves:
                    if provTrove.getVersion() != sourceTup[1]:
                        continue
                    if (flavor is None or
                        provTrove.getFlavor().toStrongFlavor().satisfies(
                                                flavor.toStrongFlavor())):
                        self.dependsOn(trove, provTrove,
                                        (False, (name, version, flavor)))
Example #8
0
    def addSourceTrovesToGraph(self, sourceTroves):
        sourceTroves = [ x for x in sourceTroves if not x.isFailed() ]
        [ self.depGraph.addNode(trove) for trove in sourceTroves ]
        for trove in sourceTroves:
            if trove.isPrepOnly():
                continue
            for package in trove.getDerivedPackages():
                self.trovesByPackage.setdefault(package, []).append(trove)

        for trove in sourceTroves:
            try:
                if trove.isPrimaryTrove():
                    self.hasPrimaryTroves = True
                trove.addBuildRequirements(trove.cfg.defaultBuildReqs)
                if trove.isPrepOnly():
                    continue
                for buildReq in trove.getBuildRequirementSpecs():
                    self._addReq(trove, buildReq, False)

                for crossReq in trove.getCrossRequirementSpecs():
                    self._addReq(trove, crossReq, True)
            except Exception, err:
                errMsg =  'Error adding buildreqs to %s: %s: %s' % (trove.getName(), err.__class__.__name__, err)
                failureReason = failure.LoadFailed(errMsg,
                                                   traceback.format_exc())
                trove.troveFailed(failureReason)
                # We can't continue the build now
                raise errors.RmakeError, errMsg, sys.exc_info()[2]

            # if're loading something that we're also building
            # then we should make sure that we build the thing with the 
            # loadInstalled line secondly
            for loadSpec, sourceTup in trove.iterAllLoadedSpecs():
                name, label, flavor = loadSpec
                providingTroves = self.trovesByPackage.get(name, [])
                for provTrove in providingTroves:
                    if provTrove.getVersion() != sourceTup[1]:
                        continue
                    elif self._flavorsMatch(trove.getFlavor(),
                                            provTrove.getFlavor(),
                                            flavor, False):
                        # FIXME: we really shouldn't allow loadInstalled
                        # loops to occur.  It means that we're building
                        # two recipes that loadInstall each other which
                        # means that we can't even trust the buildReqs
                        # specified for each.
                        self.dependsOn(trove, provTrove, (False, loadSpec))
                    else:
                        self.rejectDep(trove, provTrove, False)

            # If we have multiple groups that are building w/ the same
            # name and version, we send them to be built together.
            if trove.isGroupRecipe():
                name, version = trove.getName(), trove.getVersion()
                if (name, version) not in self.groupsByNameVersion:
                    self.groupsByNameVersion[name, version] = []
                self.groupsByNameVersion[name, version].append(trove)

            # Troves like groups, redirects, etc, have requirements
            # that control when they can be built.
            for sourceTup in trove.getDelayedRequirements():
                name, version, flavor = sourceTup
                package = name.split(':')[0]
                providingTroves = self.trovesByPackage.get(package, [])
                for provTrove in providingTroves:
                    if provTrove.getVersion() != sourceTup[1]:
                        continue
                    if (flavor is None or
                        provTrove.getFlavor().toStrongFlavor().satisfies(
                                                flavor.toStrongFlavor())):
                        self.dependsOn(trove, provTrove,
                                        (False, (name, version, flavor)))