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))
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))
if len(sys.argv) == 4: cacheDir = sys.argv[3] util.mkdirChain(csdir) util.mkdirChain(baseDir) util.mkdirChain(cacheDir) cfg = conarycfg.ConaryConfiguration(True) cfg.setContext(cfg.context) cfg.dbPath = ':memory:' cfg.root = ':memory:' cfg.initializeFlavors() client = conaryclient.ConaryClient(cfg) name, ver, flv = updatecmd.parseTroveSpec(topGroup) trvList = client.repos.findTrove(cfg.installLabelPath[0], (name, ver, flv), defaultFlavor = cfg.flavor) # Set flavor to match what anaconda uses. cfg.flavor = deps.parseFlavor('') if not trvList: print >> sys.stderr, "no match for", topGroup raise RuntimeError elif len(trvList) > 1: print >> sys.stderr, "multiple matches for", topGroup raise RuntimeError tg = TreeGenerator(cfg, client, trvList[0], cacheDir=cacheDir)
def branch(repos, cfg, newLabel, troveSpecs, makeShadow=False, sourceOnly=False, binaryOnly=False, allowEmptyShadow=False, info=False, forceBinary=False, ignoreConflicts=False, targetFile=None): branchType = _getBranchType(binaryOnly, sourceOnly) client = conaryclient.ConaryClient(cfg) troveSpecs = [ updatecmd.parseTroveSpec(x) for x in troveSpecs ] componentSpecs = [ x[0] for x in troveSpecs if (':' in x[0] and x[0].split(':')[1] != 'source')] if componentSpecs: raise errors.ParseError('Cannot branch or shadow individual components: %s' % ', '.join(componentSpecs)) result = repos.findTroves(cfg.buildLabel, troveSpecs, cfg.buildFlavor) troveList = [ x for x in itertools.chain(*result.itervalues())] sigKey = selectSignatureKey(cfg, newLabel) if makeShadow: dups, cs = client.createShadowChangeSet(newLabel, troveList, allowEmptyShadow=\ allowEmptyShadow, branchType=branchType, sigKeyId=sigKey) else: dups, cs = client.createBranchChangeSet(newLabel, troveList, branchType=branchType, sigKeyId = sigKey) for (name, branch) in dups: log.warning("%s already has branch %s", name, branch.asString()) if not cs: return if makeShadow: branchOps = 'shadows' else: branchOps = 'branches' hasBinary = False for trvCs in cs.iterNewTroveList(): if not trvCs.getName().endswith(':source'): hasBinary = True break if cfg.interactive or info: print 'The following %s will be created:' % branchOps displayBranchJob(cs, shadow=makeShadow) if cfg.interactive: print if hasBinary and branchType & client.BRANCH_BINARY: print 'WARNING: You have chosen to create binary %s. ' \ 'This is not recommended\nwith this version of cvc.' \ % branchOps print okay = cmdline.askYn('Continue with %s? [y/N]' % branchOps.lower(), default=False) if not okay: return elif (not forceBinary) and hasBinary and branchType & client.BRANCH_BINARY: print 'Creating binary %s is only allowed in interactive mode. ' \ 'Rerun cvc\nwith --interactive.' % branchOps return 1 if not info: if targetFile: cs.writeToFile(targetFile) else: client.repos.commitChangeSet(cs)
def branch(repos, cfg, newLabel, troveSpecs, makeShadow=False, sourceOnly=False, binaryOnly=False, allowEmptyShadow=False, info=False, forceBinary=False, ignoreConflicts=False, targetFile=None): branchType = _getBranchType(binaryOnly, sourceOnly) client = conaryclient.ConaryClient(cfg) troveSpecs = [updatecmd.parseTroveSpec(x) for x in troveSpecs] componentSpecs = [ x[0] for x in troveSpecs if (':' in x[0] and x[0].split(':')[1] != 'source') ] if componentSpecs: raise errors.ParseError( 'Cannot branch or shadow individual components: %s' % ', '.join(componentSpecs)) result = repos.findTroves(cfg.buildLabel, troveSpecs, cfg.buildFlavor) troveList = [x for x in itertools.chain(*result.itervalues())] sigKey = selectSignatureKey(cfg, newLabel) if makeShadow: dups, cs = client.createShadowChangeSet(newLabel, troveList, allowEmptyShadow=\ allowEmptyShadow, branchType=branchType, sigKeyId=sigKey) else: dups, cs = client.createBranchChangeSet(newLabel, troveList, branchType=branchType, sigKeyId=sigKey) for (name, branch) in dups: log.warning("%s already has branch %s", name, branch.asString()) if not cs: return if makeShadow: branchOps = 'shadows' else: branchOps = 'branches' hasBinary = False for trvCs in cs.iterNewTroveList(): if not trvCs.getName().endswith(':source'): hasBinary = True break if cfg.interactive or info: print 'The following %s will be created:' % branchOps displayBranchJob(cs, shadow=makeShadow) if cfg.interactive: print if hasBinary and branchType & client.BRANCH_BINARY: print 'WARNING: You have chosen to create binary %s. ' \ 'This is not recommended\nwith this version of cvc.' \ % branchOps print okay = cmdline.askYn('Continue with %s? [y/N]' % branchOps.lower(), default=False) if not okay: return elif (not forceBinary) and hasBinary and branchType & client.BRANCH_BINARY: print 'Creating binary %s is only allowed in interactive mode. ' \ 'Rerun cvc\nwith --interactive.' % branchOps return 1 if not info: if targetFile: cs.writeToFile(targetFile) else: client.repos.commitChangeSet(cs)