def runCommand(self, cfg, argSet, args, profile=False, callback=None, repos=None): args = args[1:] dir = argSet.pop('dir', None) template = argSet.pop('template', None) # check to see if the user specified --factory= (with an empty # argument). This is a shortcut for "--factory=factory" # that is not quite so cumbersome factory = argSet.pop('factory', None) if factory is True: factory = 'factory' if len(args) != 2 or argSet: return self.usage() checkin.newTrove(repos, cfg, args[1], dir=dir, template=template, factory=factory)
def createNewPackage(self, package, label, targetDir=None, template=None, factory=None): """ Create a subdirectory containing files to initialize a new conary source package. Similar to the C{cvc newpkg} command. @param package: name of package @type package: string @param label: label to create package on @type label: string @param targetDir: directory to create new package in (default is current working directory) @type targetDir: string @param template: name of Conary template to use @type template: string @param factory: name of Conary factory to use, or True to create a factory @type factory: string, NoneType, or bool """ # Normalize factory settings if factory is True: factory = 'factory' if factory is False: factory = None checkin.newTrove(self._getRepositoryClient(), self.getConaryConfig(), '%s=%s' % (package, label), dir=targetDir, template=template, factory=factory)
def runCommand(self, cfg, argSet, args, profile = False, callback = None, repos = None): args = args[1:] dir = argSet.pop('dir', None) template = argSet.pop('template', None) # check to see if the user specified --factory= (with an empty # argument). This is a shortcut for "--factory=factory" # that is not quite so cumbersome factory = argSet.pop('factory', None) if factory is True: factory = 'factory' if len(args) != 2 or argSet: return self.usage() checkin.newTrove(repos, cfg, args[1], dir = dir, template = template, factory = factory)
def _commitRecipe(conaryclient, cfg, recipePath, message, branch=None): repos = conaryclient.getRepos() conaryCompat = compat.ConaryVersion() recipeClass, pathList = _getPathList(repos, cfg, recipePath) sourceName = recipeClass.name + ':source' log.info("Creating a copy of %s in the rMake internal repository..." % recipeClass.name) cwd = os.getcwd() recipeDir = tempfile.mkdtemp() log.resetErrorOccurred() try: fileNames = [] # Create a source trove that matches the recipe we're trying to cook if not branch: branch = versions.Branch([cfg.buildLabel]) targetLabel = cfg.getTargetLabel(branch) if compat.ConaryVersion().supportsNewPkgBranch(): buildBranch = branch.createShadow(targetLabel) kw = dict(buildBranch=buildBranch) else: buildBranch = versions.Branch([targetLabel]) kw={} cfg.buildLabel = targetLabel if not repos.getTroveLeavesByBranch( { sourceName : { buildBranch : None } }).get(sourceName, None): # we pass it None for repos to avoid the label-based check for # existing packages. checkin.newTrove(None, cfg, recipeClass.name, dir=recipeDir, **kw) else: # see if this package exists on our build branch checkin.checkout(repos, cfg, recipeDir, ['%s=%s' % (sourceName, buildBranch)]) os.chdir(recipeDir) sourceState = state.ConaryStateFromFile(recipeDir + '/CONARY').getSourceState() fileNames = dict((os.path.basename(x), x) for x in pathList) for (pathId, baseName, fileId, version) in list(sourceState.iterFileList()): # update or remove any currently existing files if baseName not in fileNames: sourceState.removeFilePath(baseName) else: shutil.copyfile(fileNames[baseName], os.path.join(recipeDir, baseName)) del fileNames[baseName] for baseName, path in fileNames.iteritems(): shutil.copyfile(path, os.path.join(recipeDir, baseName)) if conaryCompat.stateFileVersion() > 0: # mark all the files as binary - this this version can # never be checked in, it doesn't really matter, but # conary likes us to give a value. for fileName in fileNames: isConfig = _getConfigInfo(fileName) checkin.addFiles([fileName], binary=not isConfig, text=isConfig) else: checkin.addFiles(fileNames) _doCommit(recipePath, repos, cfg, 'Temporary recipe build for rmake') newState = conaryCompat.ConaryStateFromFile(recipeDir + '/CONARY', repos=repos) return newState.getSourceState().getNameVersionFlavor() finally: os.chdir(cwd) shutil.rmtree(recipeDir)