Beispiel #1
0
 def formatNVF(self, name, version, flavor):
     if version and (flavor is not None) and not flavor.isEmpty():
         return "'%s=%s[%s]'" % (name, version.asString(), deps.formatFlavor(flavor))
     if (flavor is not None) and not flavor.isEmpty():
         return "'%s[%s]'" % (name, deps.formatFlavor(flavor))
     if version:
         return "%s=%s" % (name, version.asString())
     return name
Beispiel #2
0
    def format(self, val, displayOptions=None):
        val = ', '.join(deps.formatFlavor(val).split(','))

        if displayOptions and displayOptions.get('prettyPrint', False):
            val = ('\n%26s' % '').join(textwrap.wrap(val, 48))

        return val
Beispiel #3
0
    def format(self, val, displayOptions=None):
        val = ', '.join(deps.formatFlavor(val).split(','))

        if displayOptions and displayOptions.get('prettyPrint', False):
            val = ('\n%26s'%'').join(textwrap.wrap(val, 48))

        return val
Beispiel #4
0
def signTroves(cfg, specStrList, recurse=False, callback=None):
    troveStr = ""
    jobList = []
    trv = []
    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if callback is None:
        if cfg.quiet:
            callback = callbacks.SignatureCallback()
        else:
            callback = SignatureCallback()

    for specStr in specStrList:
        name, versionStr, flavor = parseTroveSpec(specStr)

        try:
            trvList = repos.findTrove([cfg.buildLabel],
                                      (name, versionStr, flavor), cfg.flavor)
        except errors.TroveNotFound, e:
            log.error(str(e))
            return

        for trvInfo in trvList:
            troveStr += "%s=%s[%s]\n" % (trvInfo[0], trvInfo[1].asString(),
                                         deps.formatFlavor(trvInfo[2]))

            jobList.append(
                (trvInfo[0], (None, None), (trvInfo[1], trvInfo[2]), True))
Beispiel #5
0
def signTroves(cfg, specStrList, recurse = False, callback = None):
    troveStr = ""
    jobList = []
    trv = []
    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if callback is None:
        if cfg.quiet:
            callback = callbacks.SignatureCallback()
        else:
            callback = SignatureCallback()

    for specStr in specStrList:
        name, versionStr, flavor = parseTroveSpec(specStr)

        try:
            trvList = repos.findTrove([ cfg.buildLabel ],
                                      (name, versionStr, flavor), cfg.flavor)
        except errors.TroveNotFound, e:
            log.error(str(e))
            return

        for trvInfo in trvList:
            troveStr += "%s=%s[%s]\n" % (trvInfo[0], trvInfo[1].asString(),
                                         deps.formatFlavor(trvInfo[2]))

            jobList.append((trvInfo[0], (None, None), (trvInfo[1], trvInfo[2]),
                            True))
Beispiel #6
0
    def _DO_kernel(self, args):
        if not self._kernelTup:
            raise RuntimeError("Encountered 'kernel' manifest command but "
                    "jobslave didn't provide a kernel")
        
        command = args.pop(0)
        if command == 'install':
            self._installContents(self._kernelDir, [self._kernelTup])
            # XXX - SLES 11 needs kernel-base
            kernels = []
            if os.path.exists(os.path.join(self._kernelDir, 'boot')):
                kernels = [ x for x in 
                            os.listdir(os.path.join(self._kernelDir, 'boot')) if
                            x.startswith('vmlinuz') ]               
            if len(kernels) == 0:
                self._installContents(self._kernelDir,
                    [ ('kernel-base', self._kernelTup[1], self._kernelTup[2]) ])
            return
        commandFunc = getattr(self, '_KERNEL_' + command, None)
        if not commandFunc:
            raise RuntimeError("Unknown kernel command %r in MANIFEST"
                    % (command,))

        """
        KERNEL, CONTENTS, and ARCH are treated as macros.
        Extend the list as needed.  This can probably be
        combined into one big RegEx.
        """
        commandArgs = []
        kernelFlavor = deps.formatFlavor(self._kernelTup[2])
        arch = (kernelFlavor.find('x86_64') == -1) and 'i386' or 'x86_64'
        contentsRE = re.compile('(^|/)CONTENTS(/|$)')
        kernelRE = re.compile('(^|/)KERNEL(/|$)')
        archRE = re.compile('(^|/)ARCH(/|$)')
        while len(args) > 0:
            nextArg = archRE.sub(r'\1%s\2' % arch,
                      kernelRE.sub(r'\1%s\2' % self._kernelDir,
                      contentsRE.sub(r'\1%s\2' % self._contentsDir, 
                      args.pop(0))))
            commandArgs.append(nextArg)

        # anaconda scripts may take different args, so just pass them
        if command == 'anacondaScript':
            self._KERNEL_anacondaScript(commandArgs)
            return

        # This is only for "copy" right now
        if len(commandArgs) == 3:
            inputName, outputName, mode = commandArgs
            mode = int(mode, 8)
        elif len(commandArgs) == 2:
            inputName, outputName = commandArgs
            mode = 0644
        else:
            raise RuntimeError("Can't handle kernel command %r" % (command,))
        commandFunc(inputName, outputName, mode)
Beispiel #7
0
def doShow(dbfile, commitId):
    db = getDB(dbfile)
    cu = db.cursor()
    cu.execute("""
    select item, version, flavor from CommitList
    join Items on CommitList.itemId = Items.itemId
    join Versions on CommitList.versionId = Versions.versionId
    join Flavors on CommitList.flavorId = Flavors.flavorId
    where commitId = ? """, commitId)
    for n, vStr, fStr in cu:
        if fStr:
            f = deps.ThawFlavor(fStr)
            print "%s=%s[%s]" % (n, vStr, deps.formatFlavor(f))
        else:
            print "%s=%s" % (n, vStr)
    db.close()
Beispiel #8
0
def doShow(dbfile, commitId):
    db = getDB(dbfile)
    cu = db.cursor()
    cu.execute(
        """
    select item, version, flavor from CommitList
    join Items on CommitList.itemId = Items.itemId
    join Versions on CommitList.versionId = Versions.versionId
    join Flavors on CommitList.flavorId = Flavors.flavorId
    where commitId = ? """, commitId)
    for n, vStr, fStr in cu:
        if fStr:
            f = deps.ThawFlavor(fStr)
            print "%s=%s[%s]" % (n, vStr, deps.formatFlavor(f))
        else:
            print "%s=%s" % (n, vStr)
    db.close()
Beispiel #9
0
def toTroveSpec(name, versionStr, flavor):
    """
    Construct a TroveSpec string from name + version + flavor

    @param name: trove name
    @type name: string

    @param versionStr: trove version string
    @type versionStr: string

    @param flavor: trove flavor
    @type flavor: L{deps.deps.Flavor}

    @rtype: string
    @return: a TroveSpec of the form name=version[flavor]
    """

    disp = [name]
    if versionStr:
        disp.extend(('=', versionStr))
    if flavor is not None and not flavor.isEmpty():
        disp.extend(('[', deps.formatFlavor(flavor), ']'))
    return ''.join(disp)
Beispiel #10
0
    def testFlavorQueries(self):
        def _build(v, f):
            self.addComponent('manyflavors:runtime', str(v), flavor = f)
            self.addCollection('manyflavors', str(v), [ ':runtime' ],
                               defaultFlavor = f)

        v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1-1')
        v2 = versions.VersionFromString('/localhost@rpl:linux/1.0-1-2')
        defFlavor = deps.parseFlavor('readline,ssl')
        noReadLine = deps.parseFlavor('~!readline,ssl')

        for version, flavor in [ (v1, defFlavor), (v1, noReadLine) ]:
            _build(version, flavor)

        # put it back
        self.overrideBuildFlavor('~readline')

        buildBranch = versions.VersionFromString("/%s" %
                            self.cfg.buildLabel.asString())

        repos = self.openRepository()
        d = repos.getTroveVersionList('localhost', { None : None })
        full = { 'manyflavors': { v1 : [ defFlavor, noReadLine ] },
                 'manyflavors:runtime': { v1 : [ defFlavor, noReadLine ] } }
        self.cmpQueryResult(d, full)

        d = repos.getTroveVersionList('localhost', { None : [ defFlavor ]})
        full = { 'manyflavors': { v1 : [ defFlavor ] },
                 'manyflavors:runtime': { v1 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        # both flavors are compatible here, so both are returned
        d = repos.getTroveVersionList('localhost', { None : [ noReadLine ] })
        full = { 'manyflavors': { v1 : [ defFlavor, noReadLine ] },
                 'manyflavors:runtime': { v1 : [ defFlavor, noReadLine ] } }
        self.cmpQueryResult(d, full)

    # this should return all of the flavors
        d = repos.getTroveLeavesByBranch(
                    { 'manyflavors' : { buildBranch : None } },
                    bestFlavor = False)
        self.cmpQueryResult(d, { 'manyflavors': 
                                    { v1 : [ defFlavor, noReadLine ] } })

    # this chooses the best flavor
        d = repos.getTroveLeavesByLabel(
                            { None : { self.cfg.buildLabel : [ defFlavor ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v1 : [ defFlavor ] },
                 'manyflavors:runtime': { v1 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
                            { None : { self.cfg.buildLabel : [ defFlavor ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v1 : [ defFlavor ] },
                 'manyflavors:runtime': { v1 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLeavesByLabel(
                            { None : { self.cfg.buildLabel : [ noReadLine ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v1 : [ noReadLine ] },
                 'manyflavors:runtime': { v1 : [ noReadLine ] } }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
                            { None : { self.cfg.buildLabel : [ noReadLine ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v1 : [ noReadLine ] },
                 'manyflavors:runtime': { v1 : [ noReadLine ] } }
        self.cmpQueryResult(d, full)

    # now make the two branches of different lengths
        _build(v2, defFlavor)

        d = repos.getTroveLeavesByLabel(
                            { None : { self.cfg.buildLabel : [ defFlavor ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v2 : [ defFlavor ] },
                 'manyflavors:runtime': { v2 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        # v2 is still the best match since it's not actually incompatible
        # with the noReadLine flavor
        d = repos.getTroveLeavesByLabel(
                            { None : { self.cfg.buildLabel : [ noReadLine ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v2 : [ defFlavor ] },
                 'manyflavors:runtime': { v2 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
                            { None : { self.cfg.buildLabel : [ noReadLine ] } },
                            bestFlavor = True)
        full = { 'manyflavors': { v2 : [ defFlavor ] },
                 'manyflavors:runtime': { v2 : [ defFlavor ] } }
        self.cmpQueryResult(d, full)

        disallowReadLine = deps.parseFlavor(
            deps.formatFlavor(noReadLine).replace('~!readline','!readline'))

        # now that we explicitly disallow troves which use readline, we
        # should get the old version
        d = repos.getTroveLeavesByLabel(
                    { None : { self.cfg.buildLabel : [ disallowReadLine ] } },
                    bestFlavor = True)
        self.cmpQueryResult(d, 
                    { 'manyflavors': { v1 : [ noReadLine ] },
                      'manyflavors:runtime': { v1 : [ noReadLine ] } })

        d = repos.getTroveLatestByLabel(
                    { None : { self.cfg.buildLabel : [ disallowReadLine ] } },
                    bestFlavor = True)
        self.cmpQueryResult(d, 
                    { 'manyflavors': { v1 : [ noReadLine ] },
                      'manyflavors:runtime': { v1 : [ noReadLine ] } })
Beispiel #11
0
 def __str__(self):
     return "%s conflicts with a file owned by %s=%s[%s]" % \
                      (self.path, self.name, str(self.version),
                       deps.formatFlavor(self.flavor))
Beispiel #12
0
 def __str__(self):
     return "%s is in the way of a newly created file in %s=%s[%s]" % \
                      (self.path, self.name, str(self.version),
                       deps.formatFlavor(self.flavor))
Beispiel #13
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()))
Beispiel #14
0
    def generateChangeSet(self, troveNameList, all=False):
        if self.display != DISPLAY_NONE:
            # save memory by not keeping the changeset around; this is
            # particularly useful when all=True
            self.finalCs = None
        else:
            self.finalCs = changeset.ReadOnlyChangeSet()

        troveNames = [ cmdline.parseTroveSpec(x) for x in troveNameList ]
        if all:
            assert(not troveNameList)
            client = conaryclient.ConaryClient(self.cfg)
            troveInfo = client.getUpdateItemList()
            troveInfo.sort()
        else:
            troveInfo = []

            for (troveName, versionStr, flavor) in troveNames:
                try:
                    troveInfo += self.db.findTrove(None,
                                    (troveName, versionStr, flavor))
                except errors.TroveNotFound:
                    if versionStr:
                        if flavor is not None and not flavor.isEmpty():
                            flavorStr = deps.formatFlavor(flavor)
                            log.error("version %s with flavor '%s' of "
                                      "trove %s is not installed",
                                      versionStr, flavorStr, troveName)
                        else:
                            log.error("version %s of trove %s is not installed",
                                      versionStr, troveName)
                    elif flavor is not None and not flavor.isEmpty():
                        flavorStr = deps.formatFlavor(flavor)
                        log.error("flavor '%s' of trove %s is not installed",
                                  flavorStr, troveName)
                    else:
                        log.error("trove %s is not installed", troveName)

        # we need the recursive closure of the set; self.db.walkTroveSet(trv)
        # is surely not the most efficient thing to do, but it's easy. remember
        # it's depth first; keeping the order depth first helps keep the
        # output sane

        troves = self.db.getTroves(troveInfo, withDeps = False,
                                   withFileObjects = True, pristine = False)
        seen = set()
        fullTroveList = []
        for topTrv in troves:
            for nvf in self.db.walkTroveSet(topTrv, withFiles = False,
                                                asTuple = True):
                seen.add(nvf)
                fullTroveList.append(nvf)

        if self.newFiles:
            newFilesByTrove = self._scanFilesystem(fullTroveList,
                                                   dirType = self.newFiles)
        else:
            newFilesByTrove = {}

        self._verifyTroves(fullTroveList, newFilesByTrove)

        if None in newFilesByTrove:
            self._addUnownedNewFiles(newFilesByTrove[None])

        if self.finalCs:
            for trv in troves:
                self.finalCs.addPrimaryTrove(
                         trv.getName(),
                         trv.getVersion().createShadow(versions.LocalLabel()),
                         trv.getFlavor())

        return self.finalCs
Beispiel #15
0
    def testParseFlavor(self):
        def _test(first, second, testFormat = True):
            flavor = parseFlavor(first)
            assert(str(flavor) == second)
            if testFormat:
                assert(str(parseFlavor(formatFlavor(flavor))) == second)

        _test('','')
        _test('is: mips', 'is: mips')
        _test('is: x86(sse)', 'is: x86(sse)')
        _test('is: x86(!sse)', 'is: x86(!sse)')
        _test('is: x86(sse,mmx)', 'is: x86(mmx,sse)')
        _test('is: x86(~sse,~!mmx)', 'is: x86(~!mmx,~sse)')
        _test('is: x86(~sse,~!mmx) x86_64', 'is: x86(~!mmx,~sse) x86_64')
        _test('is: x86(~sse,~!mmx) x86_64(3dnow)', 'is: x86(~!mmx,~sse) x86_64(3dnow)')
        _test('ssl', 'ssl')
        _test('~ssl', '~ssl')
        _test('gtk,ssl', 'gtk,ssl')
        _test('!gtk,~!ssl', '!gtk,~!ssl')

        full = 'gtk,ssl is: x86(mmx,sse)'
        _test('use: gtk,ssl is: x86(sse,mmx)', full)
        _test('  gtk,ssl is: x86(sse, mmx)  ', full)
        _test('use: gtk,ssl is:x86(  sse,mmx)', full)
        _test('use:    gtk  ,ssl   is:    x86(sse,mmx)', full)
        _test('gtk,ssl is: x86(sse , mmx)', full)
        _test('foo.bar,ssl is: x86', 'foo.bar,ssl is: x86')
        _test('foo-valid.bar,ssl is: x86', 'foo-valid.bar,ssl is: x86')

        _test('is: x86 x86_64(cmov) ppc(cmov)',
              'is: ppc(cmov) x86 x86_64(cmov)')
        _test('is: x86 x86_64 ppc(cmov)',
              'is: ppc(cmov) x86 x86_64')
        _test('is: x86(cmov) x86_64(cmov) ppc(cmov)',
              'is: ppc(cmov) x86(cmov) x86_64(cmov)')
        _test('is: x86 x86_64 ppc',
              'is: ppc x86 x86_64')
        _test('target: x86(cmov)',
              'target: x86(cmov)')
        _test('target: x86', 'target: x86')
        _test('target: x86 x86_64', 'target: x86 x86_64', testFormat=False)
        _test('is: x86 x86_64(cmov) ppc(cmov) target: x86(cmov)',
              'is: ppc(cmov) x86 x86_64(cmov) target: x86(cmov)')
        _test('is: x86 x86_64 ppc(cmov) target: x86(cmov)',
              'is: ppc(cmov) x86 x86_64 target: x86(cmov)')
        _test('is: x86(cmov) x86_64(cmov) ppc(cmov) target: x86(cmov)',
              'is: ppc(cmov) x86(cmov) x86_64(cmov) target: x86(cmov)')
        _test('is: x86 x86_64 ppc target: x86(cmov)',
              'is: ppc x86 x86_64 target: x86(cmov)')
        _test('is: x86 x86_64 ppc target: x86(cmov) x86_64',
              'is: ppc x86 x86_64 target: x86(cmov) x86_64')

        # quick tests to make sure mergeBase behaves itself
        assert(formatFlavor(parseFlavor('is: x86(sse)',
                            mergeBase = parseFlavor('use: gtk')))
                    == 'gtk is: x86(sse)')

        assert(formatFlavor(parseFlavor('gnome is: x86(sse)',
                            mergeBase = parseFlavor('use: gtk')))
                    == 'gnome is: x86(sse)')
        assert(formatFlavor(parseFlavor('use: gnome',
                            mergeBase = parseFlavor('is: x86(mmx)')))
                    == 'gnome is: x86(mmx)')
        assert(formatFlavor(parseFlavor('use: gnome is:',
                            mergeBase = parseFlavor('is: x86(mmx)')))
                    == 'gnome')
        assert(formatFlavor(parseFlavor('use: is: ',
                            mergeBase = parseFlavor('x86(mmx)')))
                    == '')
        assert(formatFlavor(parseFlavor('use: ssl is: x86',
                            mergeBase = parseFlavor('use: gtk is: x86(mmx)')))
                    == 'ssl is: x86')
        assert(formatFlavor(parseFlavor('is: x86(sse)',
                            mergeBase = parseFlavor('use: gtk')))
                    == 'gtk is: x86(sse)')

        # mergeFlavor is separated now
        assert(formatFlavor(mergeFlavor(parseFlavor('gnome is: x86(sse)'),
                            parseFlavor('use: gtk')))
                    == 'gnome is: x86(sse)')
        assert(formatFlavor(mergeFlavor(parseFlavor('use: gnome'),
                            mergeBase = parseFlavor('is: x86(mmx)')))
                    == 'gnome is: x86(mmx)')
        assert(formatFlavor(mergeFlavor(parseFlavor('use: gnome is:'),
                            mergeBase = parseFlavor('is: x86(mmx)')))
                    == 'gnome')
        assert(formatFlavor(mergeFlavor(parseFlavor('use: is: '),
                            mergeBase = parseFlavor('x86(mmx)')))
                    == '')
        assert(formatFlavor(mergeFlavor(parseFlavor('use: ssl is: x86'),
                            mergeBase = parseFlavor('use: gtk is: x86(mmx)')))
                    == 'ssl is: x86')

        assert(formatFlavor(mergeFlavor(parseFlavor('use: ssl is: x86'),
                            mergeBase = parseFlavor('use: gtk is: x86(mmx)')))
                    == 'ssl is: x86')
        assert(formatFlavor(mergeFlavor(parseFlavor('use: ssl'),
                            mergeBase = parseFlavor('is: x86(mmx) x86_64')))
                    == 'ssl is: x86(mmx) x86_64')
Beispiel #16
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()))
Beispiel #17
0
                print "\nNo key is defined for label %s" % label
                return

            continue

        # Look for a public key for this key; don't catch the exception
        keyCache = trove.openpgpkey.getKeyCache()
        key = keyCache.getPublicKey(signatureKey)
        signatureKey = key.getFingerprint()

        try:
            trv.getDigitalSignature(signatureKey)
            if not cfg.quiet:
                print "\nTrove: %s=%s[%s] is already signed by key: %s" \
                    % (trv.getName(), trv.getVersion(),
                       deps.formatFlavor(trv.getFlavor()),
                       cfg.signatureKey)
                continue
        except KeyNotFound:
            pass

        try:
            trv.addDigitalSignature(signatureKey)
        except KeyNotFound:
            print "\nKey:", signatureKey, "is not in your keyring."
            return

        try:
            repos.addDigitalSignature(trv.getName(), trv.getVersion(),
                                      trv.getFlavor(),
                                      trv.getDigitalSignature(signatureKey))
Beispiel #18
0
 def _test(first, second, testFormat = True):
     flavor = parseFlavor(first)
     assert(str(flavor) == second)
     if testFormat:
         assert(str(parseFlavor(formatFlavor(flavor))) == second)
Beispiel #19
0
                print "\nNo key is defined for label %s" % label
                return

            continue

        # Look for a public key for this key; don't catch the exception
        keyCache = trove.openpgpkey.getKeyCache()
        key = keyCache.getPublicKey(signatureKey)
        signatureKey = key.getFingerprint()

        try:
            trv.getDigitalSignature(signatureKey)
            if not cfg.quiet:
                print "\nTrove: %s=%s[%s] is already signed by key: %s" \
                    % (trv.getName(), trv.getVersion(),
                       deps.formatFlavor(trv.getFlavor()),
                       cfg.signatureKey)
                continue
        except KeyNotFound:
            pass

        try:
            trv.addDigitalSignature(signatureKey)
        except KeyNotFound:
            print "\nKey:", signatureKey, "is not in your keyring."
            return

        try:
            repos.addDigitalSignature(trv.getName(), trv.getVersion(),
                                      trv.getFlavor(),
                                      trv.getDigitalSignature(signatureKey))
Beispiel #20
0
 def __str__(self):
     return "%s conflicts with a file owned by %s=%s[%s]" % \
                      (self.path, self.name, str(self.version),
                       deps.formatFlavor(self.flavor))
Beispiel #21
0
 def __str__(self):
     return "%s is in the way of a newly created file in %s=%s[%s]" % \
                      (self.path, self.name, str(self.version),
                       deps.formatFlavor(self.flavor))
Beispiel #22
0
    def testFlavorQueries(self):
        def _build(v, f):
            self.addComponent('manyflavors:runtime', str(v), flavor=f)
            self.addCollection('manyflavors',
                               str(v), [':runtime'],
                               defaultFlavor=f)

        v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1-1')
        v2 = versions.VersionFromString('/localhost@rpl:linux/1.0-1-2')
        defFlavor = deps.parseFlavor('readline,ssl')
        noReadLine = deps.parseFlavor('~!readline,ssl')

        for version, flavor in [(v1, defFlavor), (v1, noReadLine)]:
            _build(version, flavor)

        # put it back
        self.overrideBuildFlavor('~readline')

        buildBranch = versions.VersionFromString(
            "/%s" % self.cfg.buildLabel.asString())

        repos = self.openRepository()
        d = repos.getTroveVersionList('localhost', {None: None})
        full = {
            'manyflavors': {
                v1: [defFlavor, noReadLine]
            },
            'manyflavors:runtime': {
                v1: [defFlavor, noReadLine]
            }
        }
        self.cmpQueryResult(d, full)

        d = repos.getTroveVersionList('localhost', {None: [defFlavor]})
        full = {
            'manyflavors': {
                v1: [defFlavor]
            },
            'manyflavors:runtime': {
                v1: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        # both flavors are compatible here, so both are returned
        d = repos.getTroveVersionList('localhost', {None: [noReadLine]})
        full = {
            'manyflavors': {
                v1: [defFlavor, noReadLine]
            },
            'manyflavors:runtime': {
                v1: [defFlavor, noReadLine]
            }
        }
        self.cmpQueryResult(d, full)

        # this should return all of the flavors
        d = repos.getTroveLeavesByBranch({'manyflavors': {
            buildBranch: None
        }},
                                         bestFlavor=False)
        self.cmpQueryResult(d, {'manyflavors': {v1: [defFlavor, noReadLine]}})

        # this chooses the best flavor
        d = repos.getTroveLeavesByLabel(
            {None: {
                self.cfg.buildLabel: [defFlavor]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v1: [defFlavor]
            },
            'manyflavors:runtime': {
                v1: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
            {None: {
                self.cfg.buildLabel: [defFlavor]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v1: [defFlavor]
            },
            'manyflavors:runtime': {
                v1: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLeavesByLabel(
            {None: {
                self.cfg.buildLabel: [noReadLine]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v1: [noReadLine]
            },
            'manyflavors:runtime': {
                v1: [noReadLine]
            }
        }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
            {None: {
                self.cfg.buildLabel: [noReadLine]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v1: [noReadLine]
            },
            'manyflavors:runtime': {
                v1: [noReadLine]
            }
        }
        self.cmpQueryResult(d, full)

        # now make the two branches of different lengths
        _build(v2, defFlavor)

        d = repos.getTroveLeavesByLabel(
            {None: {
                self.cfg.buildLabel: [defFlavor]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v2: [defFlavor]
            },
            'manyflavors:runtime': {
                v2: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        # v2 is still the best match since it's not actually incompatible
        # with the noReadLine flavor
        d = repos.getTroveLeavesByLabel(
            {None: {
                self.cfg.buildLabel: [noReadLine]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v2: [defFlavor]
            },
            'manyflavors:runtime': {
                v2: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        d = repos.getTroveLatestByLabel(
            {None: {
                self.cfg.buildLabel: [noReadLine]
            }}, bestFlavor=True)
        full = {
            'manyflavors': {
                v2: [defFlavor]
            },
            'manyflavors:runtime': {
                v2: [defFlavor]
            }
        }
        self.cmpQueryResult(d, full)

        disallowReadLine = deps.parseFlavor(
            deps.formatFlavor(noReadLine).replace('~!readline', '!readline'))

        # now that we explicitly disallow troves which use readline, we
        # should get the old version
        d = repos.getTroveLeavesByLabel(
            {None: {
                self.cfg.buildLabel: [disallowReadLine]
            }}, bestFlavor=True)
        self.cmpQueryResult(
            d, {
                'manyflavors': {
                    v1: [noReadLine]
                },
                'manyflavors:runtime': {
                    v1: [noReadLine]
                }
            })

        d = repos.getTroveLatestByLabel(
            {None: {
                self.cfg.buildLabel: [disallowReadLine]
            }}, bestFlavor=True)
        self.cmpQueryResult(
            d, {
                'manyflavors': {
                    v1: [noReadLine]
                },
                'manyflavors:runtime': {
                    v1: [noReadLine]
                }
            })
Beispiel #23
0
    def generateChangeSet(self, troveNameList, all=False):
        if self.display != DISPLAY_NONE:
            # save memory by not keeping the changeset around; this is
            # particularly useful when all=True
            self.finalCs = None
        else:
            self.finalCs = changeset.ReadOnlyChangeSet()

        troveNames = [cmdline.parseTroveSpec(x) for x in troveNameList]
        if all:
            assert (not troveNameList)
            client = conaryclient.ConaryClient(self.cfg)
            troveInfo = client.getUpdateItemList()
            troveInfo.sort()
        else:
            troveInfo = []

            for (troveName, versionStr, flavor) in troveNames:
                try:
                    troveInfo += self.db.findTrove(
                        None, (troveName, versionStr, flavor))
                except errors.TroveNotFound:
                    if versionStr:
                        if flavor is not None and not flavor.isEmpty():
                            flavorStr = deps.formatFlavor(flavor)
                            log.error(
                                "version %s with flavor '%s' of "
                                "trove %s is not installed", versionStr,
                                flavorStr, troveName)
                        else:
                            log.error(
                                "version %s of trove %s is not installed",
                                versionStr, troveName)
                    elif flavor is not None and not flavor.isEmpty():
                        flavorStr = deps.formatFlavor(flavor)
                        log.error("flavor '%s' of trove %s is not installed",
                                  flavorStr, troveName)
                    else:
                        log.error("trove %s is not installed", troveName)

        # we need the recursive closure of the set; self.db.walkTroveSet(trv)
        # is surely not the most efficient thing to do, but it's easy. remember
        # it's depth first; keeping the order depth first helps keep the
        # output sane

        troves = self.db.getTroves(troveInfo,
                                   withDeps=False,
                                   withFileObjects=True,
                                   pristine=False)
        seen = set()
        fullTroveList = []
        for topTrv in troves:
            for nvf in self.db.walkTroveSet(topTrv,
                                            withFiles=False,
                                            asTuple=True):
                seen.add(nvf)
                fullTroveList.append(nvf)

        if self.newFiles:
            newFilesByTrove = self._scanFilesystem(fullTroveList,
                                                   dirType=self.newFiles)
        else:
            newFilesByTrove = {}

        self._verifyTroves(fullTroveList, newFilesByTrove)

        if None in newFilesByTrove:
            self._addUnownedNewFiles(newFilesByTrove[None])

        if self.finalCs:
            for trv in troves:
                self.finalCs.addPrimaryTrove(
                    trv.getName(),
                    trv.getVersion().createShadow(versions.LocalLabel()),
                    trv.getFlavor())

        return self.finalCs