def update_repo(repo, force=False): ctx.ui.info(_('* Updating repository: %s') % repo) ctx.ui.notify(pisi.ui.updatingrepo, name = repo) repodb = pisi.db.repodb.RepoDB() index = pisi.index.Index() if repodb.has_repo(repo): repouri = repodb.get_repo(repo).indexuri.get_uri() try: index.read_uri_of_repo(repouri, repo) except pisi.file.AlreadyHaveException, 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 try: index.check_signature(repouri, repo) ctx.ui.info(_('* Package database updated.')) except pisi.file.NoSignatureFound, e: ctx.ui.warning(e) if ctx.ui.confirm(_('Adding this repository may harm your system. Do you want to continue?')): ctx.ui.info(_('* Package database updated.')) else: repodb.remove_repo(repo)
def remove_repo(name): repodb = pisi.db.repodb.RepoDB() if repodb.has_repo(name): repodb.remove_repo(name) ctx.ui.info(_('Repo %s removed from system.') % name) else: raise pisi.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(pisi.util.letters()), name): raise pisi.Error(_('Not a valid repo name.')) repodb = pisi.db.repodb.RepoDB() new_indexuri = pisi.urlcheck.switch_from_legacy(indexuri) if repodb.has_repo_url(new_indexuri, only_active = False): repo = repodb.get_repo_by_url(new_indexuri) ctx.ui.warning(_('Repo already present with name %s and same URL. Removing first.') % repo) repodb.remove_repo(repo) if repodb.has_repo(name): repodb.remove_repo(name) if new_indexuri != indexuri: ctx.ui.warning("Legacy repo found. Attempting rewrite.") repo = pisi.db.repodb.Repo(pisi.uri.URI(new_indexuri)) repodb.add_repo(name, repo, at = at) pisi.db.flush_caches() ctx.ui.info(_('Repo %s added to system.') % name)