def __update_repo(repo, force=False): ctx.ui.action(_('Updating repository: %s') % repo) ctx.ui.notify(pisilinux.ui.updatingrepo, name = repo) repodb = pisilinux.db.repodb.RepoDB() index = pisilinux.index.Index() if repodb.has_repo(repo): repouri = repodb.get_repo(repo).indexuri.get_uri() try: index.read_uri_of_repo(repouri, repo) except pisilinux.file.AlreadyHaveException as e: ctx.ui.info(_('%s repository information is up-to-date.') % repo) if force: ctx.ui.info(_('Updating database at any rate as requested')) index.read_uri_of_repo(repouri, repo, force = force) else: return False pisilinux.db.historydb.HistoryDB().update_repo(repo, repouri, "update") repodb.check_distribution(repo) try: index.check_signature(repouri, repo) except pisilinux.file.NoSignatureFound as e: ctx.ui.warning(e) ctx.ui.info(_('Package database updated.')) else: raise pisilinux.Error(_('No repository named %s found.') % repo) return True
def remove_repo(name): repodb = pisilinux.db.repodb.RepoDB() if repodb.has_repo(name): repodb.remove_repo(name) pisilinux.db.flush_caches() ctx.ui.info(_('Repo %s removed from system.') % name) else: raise pisilinux.Error(_('Repository %s does not exist. Cannot remove.') % name)
def add_repo(name, indexuri, at = None): if not re.match("^[0-9%s\-\\_\\.\s]*$" % str(pisilinux.util.letters()), name): raise pisilinux.Error(_('Not a valid repo name.')) repodb = pisilinux.db.repodb.RepoDB() if repodb.has_repo(name): raise pisilinux.Error(_('Repo %s already present.') % name) elif repodb.has_repo_url(indexuri, only_active = False): repo = repodb.get_repo_by_url(indexuri) raise pisilinux.Error(_('Repo already present with name %s.') % repo) else: repo = pisilinux.db.repodb.Repo(pisilinux.uri.URI(indexuri)) repodb.add_repo(name, repo, at = at) pisilinux.db.flush_caches() ctx.ui.info(_('Repo %s added to system.') % name)