def _getRmakeConfig(self, rmakeCfgFn=None): # Get default pluginDirs from the rmake cfg object, setup the plugin # manager, then create a new rmake config object so that rmakeUser # will be parsed correctly. rmakeCfg = buildcfg.BuildConfiguration(readConfigFiles=False) disabledPlugins = [ x[0] for x in rmakeCfg.usePlugin.items() if not x[1] ] disabledPlugins.append('monitor') pluginMgr = plugins.PluginManager(rmakeCfg.pluginDirs, disabledPlugins) pluginMgr.loadPlugins() pluginMgr.callClientHook('client_preInit', self, []) rmakerc = 'rmakerc' if rmakeCfgFn: rmakeCfgPath = util.join(self._cfg.configPath, rmakeCfgFn) if os.path.exists(rmakeCfgPath): rmakerc = rmakeCfgFn # FIXME: This is a hack to work around having two conaryrc # files, one for building groups and one for building # packages. self._ccfg.autoLoadRecipes = [] else: log.warn('%s not found, falling back to rmakerc' % rmakeCfgFn) rmakeCfg = buildcfg.BuildConfiguration(readConfigFiles=False) rmakeCfg.read(util.join(self._cfg.configPath, rmakerc)) rmakeCfg.useConaryConfig(self._ccfg) rmakeCfg.copyInConfig = False rmakeCfg.strictMode = True # Use default tmpDir when building with rMake since the specified # tmpDir may not exist in the build root. rmakeCfg.resetToDefault('tmpDir') return rmakeCfg
def setModel(self, pkgName, groups, version=None): """ Freeze group model and save to the repository. """ log.info('saving model for %s' % pkgName) recipeDir = self._edit(pkgName, version=version) groupFileName = util.join(recipeDir, 'groups.xml') groupModel = GroupModel() for name, model in groups.iteritems(): groupfn = util.join(recipeDir, model.fileName) model.freeze(groupfn) groupModel.add( name=name, filename=model.fileName, byDefault=model.byDefault, depCheck=model.depCheck, checkPathConflicts=model.checkPathConflicts, ) self._addFile(recipeDir, model.fileName) groupModel.freeze(groupFileName) self._addFile(recipeDir, 'groups.xml')
def getModel(self, pkgName, version=None): """ Get a thawed data representation of the group xml data from the repository. """ log.info('loading model for %s' % pkgName) recipeDir = self._edit(pkgName, version=version) groupFileName = util.join(recipeDir, 'groups.xml') # load group model groups = {} if os.path.exists(groupFileName): model = GroupModel.thaw(groupFileName) for name, groupObj in model.iteritems(): contentFileName = util.join(recipeDir, groupObj.filename) contentsModel = GroupContentsModel.thaw(contentFileName, (name, groupObj.byDefault, groupObj.depCheck, groupObj.checkPathConflicts)) contentsModel.fileName = groupObj.filename groups[groupObj.name] = contentsModel return groups
def setModel(self, pkgName, groups, version=None): """ Freeze group model and save to the repository. """ log.info('saving model for %s' % pkgName) recipeDir = self._edit(pkgName, version=version) groupFileName = util.join(recipeDir, 'groups.xml') groupModel = GroupModel() for name, model in groups.iteritems(): groupfn = util.join(recipeDir, model.fileName) model.freeze(groupfn) groupModel.add(name=name, filename=model.fileName, byDefault=model.byDefault, depCheck=model.depCheck, checkPathConflicts=model.checkPathConflicts,) self._addFile(recipeDir, model.fileName) groupModel.freeze(groupFileName) self._addFile(recipeDir, 'groups.xml')
def getModel(self, pkgName, version=None): """ Get a thawed data representation of the group xml data from the repository. """ log.info('loading model for %s' % pkgName) recipeDir = self._edit(pkgName, version=version) groupFileName = util.join(recipeDir, 'groups.xml') # load group model groups = {} if os.path.exists(groupFileName): model = GroupModel.thaw(groupFileName) for name, groupObj in model.iteritems(): contentFileName = util.join(recipeDir, groupObj.filename) contentsModel = GroupContentsModel.thaw( contentFileName, (name, groupObj.byDefault, groupObj.depCheck, groupObj.checkPathConflicts)) contentsModel.fileName = groupObj.filename groups[groupObj.name] = contentsModel return groups
def getErrataState(self, pkgname, version=None): """ Get the contents of the errata state file from the specified package, if file does not exist, return None. """ log.info('getting errata state information from %s' % pkgname) recipeDir = self._edit(pkgname, version=version) stateFileName = util.join(recipeDir, 'erratastate') if not os.path.exists(stateFileName): return None state = open(stateFileName).read().strip() if state.isdigit(): state = int(state) return state
def read(self, *args, **kwargs): """ Read specified file. """ # If there is a global config, load it first. cfgDir = os.path.dirname(args[0]) cfgFile = util.join(cfgDir, '../', 'updatebotrc') if os.path.exists(cfgFile): cfg.SectionedConfigFile.read(self, cfgFile, **kwargs) # Find configPath. ret = cfg.SectionedConfigFile.read(self, *args, **kwargs) if (not self.configPath.startswith(os.sep) and args[0].endswith('updatebotrc')): # configPath is relative dirname = os.path.dirname(args[0]) self.configPath = os.path.normpath( os.path.join(dirname, self.configPath)) return ret
def read(self, *args, **kwargs): """ Read specified file. """ # If there is a global config, load it first. cfgDir = os.path.dirname(args[0]) cfgFile = util.join(cfgDir, '../', 'updatebotrc') if os.path.exists(cfgFile): cfg.SectionedConfigFile.read(self, cfgFile, **kwargs) # Find configPath. ret = cfg.SectionedConfigFile.read(self, *args, **kwargs) if (not self.configPath.startswith(os.sep) and args[0].endswith('updatebotrc')): # configPath is relative dirname = os.path.dirname(args[0]) self.configPath = os.path.normpath(os.path.join(dirname, self.configPath)) return ret
def setErrataState(self, pkgname, state, version=None): """ Set the current errata state for the given package. """ log.info('storing errata state information in %s' % pkgname) recipeDir = self._edit(pkgname, version=version) stateFileName = util.join(recipeDir, 'erratastate') # write state info statefh = open(stateFileName, 'w') statefh.write(str(state)) # source files must end in a trailing newline statefh.write('\n') statefh.close() # make sure state file is part of source trove self._addFile(recipeDir, 'erratastate')
def __init__(self, cfg, ui, rmakeCfgFn=None, conaryCfg=None, rmakeCfg=None): self._cfg = cfg self._ui = ui if conaryCfg: self._ccfg = conaryCfg else: self._ccfg = conarycfg.ConaryConfiguration(readConfigFiles=False) self._ccfg.read(util.join(self._cfg.configPath, 'conaryrc')) self._ccfg.dbPath = ':memory:' self._ccfg.initializeFlavors() self._client = conaryclient.ConaryClient(self._ccfg) if self._cfg.saveChangeSets or self._cfg.sanityCheckChangesets: self._saveChangeSets = tempfile.mkdtemp( prefix=self._cfg.platformName, suffix='-import-changesets') else: self._saveChangeSets = False self._sanityCheckChangesets = self._cfg.sanityCheckChangesets self._sanityCheckCommits = self._cfg.sanityCheckCommits if rmakeCfg: self._rmakeCfg = rmakeCfg else: self._rmakeCfg = self._getRmakeConfig(rmakeCfgFn=rmakeCfgFn) self._helper = helper.rMakeHelper(buildConfig=self._rmakeCfg) self.cvc = Cvc(self._cfg, self._ccfg, self._formatInput, LocalDispatcher(self, 12)) self._asyncDispatcher = OrderedCommitDispatcher(self, 30) self._conaryhelper = ConaryHelper(self._cfg)