def make_BareConfig(self): a = BareConfig() # Test components of the BareConfig class: self.test_url = 'https://api.gentoo.org/overlays/repositories.xml' assertEqual(a['overlay'], self.test_url) self.test_keys = [ 'bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'custom_news_func', 'custom_news_pkg', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_email', 'git_postsync', 'git_syncopts', 'git_user', 'installed', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'news_reporter', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width' ] assertEqual(sorted(a), self.test_keys) assertEqual(a.get_option('nocheck'), True)
def make_BareConfig(self): a = BareConfig() # Test components of the BareConfig class: self.test_url = 'https://api.gentoo.org/overlays/repositories.xml' assertEqual(a['overlay'], self.test_url) self.test_keys = ['bzr_addopts', 'bzr_command', 'bzr_postsync', 'bzr_syncopts', 'cache', 'config', 'configdir', 'custom_news_func', 'custom_news_pkg', 'cvs_addopts', 'cvs_command', 'cvs_postsync', 'cvs_syncopts', 'darcs_addopts', 'darcs_command', 'darcs_postsync', 'darcs_syncopts', 'g-common_command', 'g-common_generateopts', 'g-common_postsync', 'g-common_syncopts', 'git_addopts', 'git_command', 'git_email', 'git_postsync', 'git_syncopts', 'git_user', 'installed', 'local_list', 'make_conf', 'mercurial_addopts', 'mercurial_command', 'mercurial_postsync', 'mercurial_syncopts', 'news_reporter', 'nocheck', 'nocolor', 'output', 'overlay_defs', 'overlays', 'proxy', 'quiet', 'quietness', 'rsync_command', 'rsync_postsync', 'rsync_syncopts', 'stderr', 'stdin', 'stdout', 'storage', 'svn_addopts', 'svn_command', 'svn_postsync', 'svn_syncopts', 't/f_options', 'tar_command', 'tar_postsync', 'umask', 'verbose', 'width'] assertEqual(sorted(a), self.test_keys) assertEqual(a.get_option('nocheck'), True)
def _get_layman_api(self): ''' Initializes layman api. @rtype layman.api.LaymanAPI instance ''' # Make it so that we aren't initializing the # LaymanAPI instance if it already exists and # if the current storage location hasn't been # changed for the new repository. self.storage = self.repo.location.replace(self.repo.name, '') if self._layman and self.storage in self.current_storage: return self._layman config = BareConfig() configdir = {'configdir': config.get_option('configdir')} self.message = Message(out=sys.stdout, err=sys.stderr) self.current_storage = self.storage options = { 'config': config.get_option('config') % (configdir), 'quiet': self.settings.get('PORTAGE_QUIET'), 'quietness': config.get_option('quietness'), 'overlay_defs': config.get_option('overlay_defs') % (configdir), 'output': self.message, 'nocolor': self.settings.get('NOCOLOR'), 'root': self.settings.get('EROOT'), 'storage': self.current_storage, 'verbose': self.settings.get('PORTAGE_VERBOSE'), 'width': self.settings.get('COLUMNWIDTH'), } self.config = OptionConfig(options=options, root=options['root']) # Reloads config to read custom overlay # xml files. reload_config(self.config) layman_api = LaymanAPI(self.config, report_errors=True, output=self.config['output'] ) self._layman = layman_api return layman_api
def _get_layman_api(self): ''' Initializes layman api. @rtype layman.api.LaymanAPI instance ''' # Make it so that we aren't initializing the # LaymanAPI instance if it already exists and # if the current storage location hasn't been # changed for the new repository. self.storage = self.repo.location.replace(self.repo.name, '') if self._layman and self.storage in self.current_storage: return self._layman config = BareConfig() configdir = {'configdir': config.get_option('configdir')} self.message = Message(out=sys.stdout, err=sys.stderr) self.current_storage = self.storage options = { 'config': config.get_option('config') % (configdir), 'quiet': self.settings.get('PORTAGE_QUIET'), 'quietness': config.get_option('quietness'), 'overlay_defs': config.get_option('overlay_defs') % (configdir), 'output': self.message, 'nocolor': self.settings.get('NOCOLOR'), 'root': self.settings.get('EROOT'), 'storage': self.current_storage, 'verbose': self.settings.get('PORTAGE_VERBOSE'), 'width': self.settings.get('COLUMNWIDTH'), } self.config = OptionConfig(options=options, root=options['root']) # Reloads config to read custom overlay # xml files. reload_config(self.config) layman_api = LaymanAPI(self.config, report_errors=True, output=self.config['output']) self._layman = layman_api return layman_api
def install_overlay(module, name, list_url=None): '''Installs the overlay repository. If not on the central overlays list, then :list_url of an alternative list must be provided. The list will be fetched and saved under ``%(overlay_defs)/%(name.xml)`` (location of the ``overlay_defs`` is read from the Layman's configuration). :param name: the overlay id :param list_url: the URL of the remote repositories list to look for the overlay definition (optional, default: None) :returns: True if the overlay was installed, or False if already exists (i.e. nothing has changed) :raises ModuleError ''' # read Layman configuration layman_conf = BareConfig(read_configfile=True) layman = init_layman(layman_conf) if layman.is_installed(name): return False if module.check_mode: mymsg = 'Would add layman repo \'' + name + '\'' module.exit_json(changed=True, msg=mymsg) if not layman.is_repo(name): if not list_url: raise ModuleError( "Overlay '%s' is not on the list of known " "overlays and URL of the remote list was not provided." % name) overlay_defs = layman_conf.get_option('overlay_defs') dest = path.join(overlay_defs, name + '.xml') download_url(module, list_url, dest) # reload config layman = init_layman() if not layman.add_repos(name): raise ModuleError(layman.get_errors()) return True
def install_overlay(module, name, list_url=None): '''Installs the overlay repository. If not on the central overlays list, then :list_url of an alternative list must be provided. The list will be fetched and saved under ``%(overlay_defs)/%(name.xml)`` (location of the ``overlay_defs`` is read from the Layman's configuration). :param name: the overlay id :param list_url: the URL of the remote repositories list to look for the overlay definition (optional, default: None) :returns: True if the overlay was installed, or False if already exists (i.e. nothing has changed) :raises ModuleError ''' # read Layman configuration layman_conf = BareConfig(read_configfile=True) layman = init_layman(layman_conf) if layman.is_installed(name): return False if module.check_mode: mymsg = 'Would add layman repo \'' + name + '\'' module.exit_json(changed=True, msg=mymsg) if not layman.is_repo(name): if not list_url: raise ModuleError("Overlay '%s' is not on the list of known " \ "overlays and URL of the remote list was not provided." % name) overlay_defs = layman_conf.get_option('overlay_defs') dest = path.join(overlay_defs, name + '.xml') download_url(module, list_url, dest) # reload config layman = init_layman() if not layman.add_repos(name): raise ModuleError(layman.get_errors()) return True