Ejemplo n.º 1
0
def __update_repo(repo, force=False):
    ctx.ui.action(_('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 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

        pisi.db.historydb.HistoryDB().update_repo(repo, repouri, "update")
        repodb.check_distribution(repo)

        try:
            index.check_signature(repouri, repo)
        except pisi.file.NoSignatureFound as e:
            ctx.ui.warning(e)

        ctx.ui.info(_('Package database updated.'))
    else:
        raise pisi.Error(_('No repository named %s found.') % repo)

    return True
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def add_repo(name, indexuri, at = None):
    repodb = pisi.db.repodb.RepoDB()
    if repodb.has_repo(name):
        raise pisi.Error(_('Repo %s already present.') % name)
    else:
        repo = pisi.db.repodb.Repo(pisi.uri.URI(indexuri))
        repodb.add_repo(name, repo, at = at)
        ctx.ui.info(_('Repo %s added to system.') % name)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
Archivo: api.py Proyecto: Tayyib/uludag
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()
    if repodb.has_repo(name):
        raise pisi.Error(_('Repo %s already present.') % name)
    elif repodb.has_repo_url(indexuri):
        repo = repodb.get_repo_by_url(indexuri)
        raise pisi.Error(_('Repo already present with name %s.') % repo)
    else:
        repo = pisi.db.repodb.Repo(pisi.uri.URI(indexuri))
        repodb.add_repo(name, repo, at = at)
        ctx.ui.info(_('Repo %s added to system.') % name)
Ejemplo n.º 7
0
def add_repo(name, indexuri, at = None):
    if not re.match("^[a-zA-Z0-9\\-\\_]*$", name):
        raise pisi.Error(_('Not a valid repo name.'))
    repodb = pisi.db.repodb.RepoDB()
    if repodb.has_repo(name):
        raise pisi.Error(_('Repo %s already present.') % name)
    elif repodb.has_repo_url(indexuri):
        repo = repodb.get_repo_by_url(indexuri)
        raise pisi.Error(_('Repo already present with name %s.') % repo)
    else:
        repo = pisi.db.repodb.Repo(pisi.uri.URI(indexuri))
        repodb.add_repo(name, repo, at = at)
        ctx.ui.info(_('Repo %s added to system.') % name)
Ejemplo n.º 8
0
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()
    if repodb.has_repo(name):
        raise pisi.Error(_('Repo %s already present.') % name)
    elif repodb.has_repo_url(indexuri, only_active=False):
        repo = repodb.get_repo_by_url(indexuri)
        raise pisi.Error(_('Repo already present with name %s.') % repo)
    else:
        repo = pisi.db.repodb.Repo(pisi.uri.URI(indexuri))
        repodb.add_repo(name, repo, at=at)
        pisi.db.flush_caches()
        ctx.ui.info(_('Repo %s added to system.') % name)
Ejemplo n.º 9
0
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo)

    repodb = pisi.db.repodb.RepoDB()
    if repodb.has_repo(repo):
        repouri = pisi.uri.URI(repodb.get_repo(repo).indexuri.get_uri())
        indexname = repouri.filename()
        index = pisi.index.Index()
        indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname)
        tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
        pisi.util.clean_dir(tmpdir)
        pisi.util.check_dir(tmpdir)
        try:
            index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there
        except IOError, e:
            ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e)))
            return
Ejemplo n.º 10
0
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo)

    repodb = pisi.db.repodb.RepoDB()
    if repodb.has_repo(repo):
        repouri = pisi.uri.URI(repodb.get_repo(repo).indexuri.get_uri())
        indexname = repouri.filename()
        index = pisi.index.Index()
        indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname)
        tmpdir = os.path.join(ctx.config.tmp_dir(), 'index')
        pisi.util.clean_dir(tmpdir)
        pisi.util.check_dir(tmpdir)
        try:
            index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there
        except IOError, e:
            ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e)))
            return
Ejemplo n.º 11
0
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)
            pisi.db.historydb.HistoryDB().update_repo(repo, repouri, "update")
        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
        except pisi.index.DistributionMismatchException:
            remove_repo(repo)
            return
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
def __update_repo(repo, force=False):
    ctx.ui.action(_('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)
            pisi.db.historydb.HistoryDB().update_repo(repo, repouri, "update")
        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)
        except pisi.file.NoSignatureFound, e:
            ctx.ui.warning(e)
Ejemplo n.º 14
0
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)
            pisi.db.historydb.HistoryDB().update_repo(repo, repouri, "update")
        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)
        except pisi.file.NoSignatureFound, e:
            ctx.ui.warning(e)