Exemple #1
0
def update_repo(repo):

    ctx.ui.info('* Updating repository: %s' % repo)
    index = Index()
    index.read(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
    index.update_db(repo)
    ctx.ui.info('* Package database updated.')
Exemple #2
0
def update_repo(repo):

    ctx.ui.info(_("* Updating repository: %s") % repo)
    index = Index()
    index.read_uri(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
    index.update_db(repo)
    ctx.ui.info(_("\n* Package database updated."))
Exemple #3
0
def index(repo_dir = '.'):

    ctx.ui.info('* Building index of PISI files under %s' % repo_dir)
    index = Index()
    index.index(repo_dir)
    index.write(ctx.const.pisi_index)
    ctx.ui.info('* Index file written')
Exemple #4
0
def index(repo_dir="."):

    ctx.ui.info(_("* Building index of PISI files under %s") % repo_dir)
    index = Index()
    index.index(repo_dir)
    index.write(ctx.const.pisi_index)
    ctx.ui.info(_("* Index file written"))
Exemple #5
0
def update_repo(repo):
    ctx.ui.info(_('* Updating repository: %s') % repo)
    index = Index()
    if ctx.repodb.has_repo(repo):
        index.read_uri(ctx.repodb.get_repo(repo).indexuri.get_uri(), repo)
    else:
        raise Error(_('No repository named %s found.') % repo)
    index.update_db(repo)
    ctx.ui.info(_('\n* Package database updated.'))
Exemple #6
0
def index(dirs, output = 'pisi-index.xml'):
    index = Index()
    if not dirs:
        dirs = ['.']
    for repo_dir in dirs:
        ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir)
        index.index(repo_dir)
    index.write(output)
    ctx.ui.info(_('* Index file written'))
Exemple #7
0
    def readRepo(self, repo_url, dest_dir="./"):
        """Reads repo and fetches index files"""
        ### Imports ###
        from pisi.index import Index
        from os import mkdir

        ### Check if address got a trailing slash ###
        if repo_url.split("/")[-1]:  # If not, add a trailing slash.
            self.repo_url = repo_url + "/"
        else:  #  Else, use it.
            self.repo_url = repo_url

        ### Check dest_dir ###
        if dest_dir.split("/")[-1]:
            dest_dir = dest_dir + "/"

        self.dest_dir = dest_dir + self.repo_url.split("/")[-2]
        self.index_url = self.repo_url + "pisi-index.xml.bz2"

        ### Create Pisi-Index instance ###
        self.pi = Index()
        try:
            self.pi.read_uri(self.index_url, self.dest_dir)
        except:
            pass
        self.pi.read((self.dest_dir + "/pisi-index.xml"))
Exemple #8
0
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo)
    
    if ctx.repodb.has_repo(repo):
        repouri = URI(ctx.repodb.get_repo(repo).indexuri.get_uri())
        indexname = repouri.filename()
        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
        ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
Exemple #9
0
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo, noln=True)
    
    index = Index()
    if ctx.repodb.has_repo(repo):
        repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        indexname = os.path.basename(repouri)
        indexpath = pisi.util.join_path(ctx.config.lib_dir(), 'index', repo, indexname)

        if os.path.exists(indexpath):
            repouri = indexpath

        try:
            index.read_uri(repouri, repo, force = True)
        except IOError:
            ctx.ui.warning(_("Repo index file \'%s\' not found.") % repouri)
            return
    else:
        raise Error(_('No repository named %s found.') % repo)

    ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
    ctx.ui.info(_('OK.'))
Exemple #10
0
def rebuild_repo(repo):
    ctx.ui.info(_('* Rebuilding \'%s\' named repo... ') % repo, noln=True)

    if ctx.repodb.has_repo(repo):
        repouri = URI(ctx.repodb.get_repo(repo).indexuri.get_uri())
        indexname = repouri.filename()
        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
        ctx.txn_proc(lambda txn: index.update_db(repo, txn=txn))
        ctx.ui.info(_('OK.'))
Exemple #11
0
def index(dirs=None, output='pisi-index.xml', skip_sources=False, skip_signing=False):
    """accumulate PiSi XML files in a directory"""
    index = Index()
    index.distribution = None
    if not dirs:
        dirs = ['.']
    for repo_dir in dirs:
        repo_dir = str(repo_dir)
        ctx.ui.info(_('* Building index of PiSi files under %s') % repo_dir)
        index.index(repo_dir, skip_sources)

    if skip_signing:
        index.write(output, sha1sum=True, compress=File.bz2, sign=None)
    else:
        index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached)
    ctx.ui.info(_('* Index file written'))
Exemple #12
0
def index(dirs=None, output="pisi-index.xml", skip_sources=False, skip_signing=False, non_recursive=False):
    """accumulate PISI XML files in a directory"""
    index = Index()
    if not dirs:
        dirs = ["."]
    for repo_dir in dirs:
        repo_dir = str(repo_dir)
        ctx.ui.info(_("* Building index of PISI files under %s") % repo_dir)
        index.index(repo_dir, skip_sources, non_recursive)

    if skip_signing:
        index.write(output, sha1sum=True, compress=File.bz2, sign=None)
    else:
        index.write(output, sha1sum=True, compress=File.bz2, sign=File.detached)
    ctx.ui.info(_("* Index file written"))
Exemple #13
0
def update_repo(repo, force=False):
    ctx.ui.info(_('* Updating repository: %s') % repo)
    index = Index()
    if ctx.repodb.has_repo(repo):
        repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        try:
            index.read_uri_of_repo(repouri, repo)
        except pisi.file.AlreadyHaveException, e:
            ctx.ui.info(_('No updates available for repository %s.') % 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)
Exemple #14
0
def index(dirs=None,
          output='pisi-index.xml',
          skip_sources=False,
          skip_signing=False,
          non_recursive=False):
    """accumulate PISI XML files in a directory"""
    index = Index()
    index.distribution = None
    if not dirs:
        dirs = ['.']
    for repo_dir in dirs:
        repo_dir = str(repo_dir)
        ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir)
        index.index(repo_dir, skip_sources, non_recursive)

    if skip_signing:
        index.write(output, sha1sum=True, compress=File.bz2, sign=None)
    else:
        index.write(output,
                    sha1sum=True,
                    compress=File.bz2,
                    sign=File.detached)
    ctx.ui.info(_('* Index file written'))
Exemple #15
0
def update_repo(repo, force=False):
    ctx.ui.info(_('* Updating repository: %s') % repo)
    index = Index()
    if ctx.repodb.has_repo(repo):
        repouri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        try:
            index.read_uri(repouri, repo)
        except pisi.file.AlreadyHaveException, e:
            ctx.ui.info(_('No updates available for repository %s.') % repo)
            if force:
                ctx.ui.info(_('Updating database at any rate as requested'))
                index.read_uri(repouri, repo, force = force)
            else:
                return
        try:
            index.check_signature(repouri, repo)
        except pisi.file.NoSignatureFound, e:
            ctx.ui.warning(e)
Exemple #16
0
class PisiCrawler:
    """ Lists and downloads pisi packages in a given repository """

    def __init__(self):
        """Constructor"""

    # -------------------------------------------------------------------
    def readRepo(self, repo_url, dest_dir="./"):
        """Reads repo and fetches index files"""
        ### Imports ###
        from pisi.index import Index
        from os import mkdir

        ### Check if address got a trailing slash ###
        if repo_url.split("/")[-1]:  # If not, add a trailing slash.
            self.repo_url = repo_url + "/"
        else:  #  Else, use it.
            self.repo_url = repo_url

        ### Check dest_dir ###
        if dest_dir.split("/")[-1]:
            dest_dir = dest_dir + "/"

        self.dest_dir = dest_dir + self.repo_url.split("/")[-2]
        self.index_url = self.repo_url + "pisi-index.xml.bz2"

        ### Create Pisi-Index instance ###
        self.pi = Index()
        try:
            self.pi.read_uri(self.index_url, self.dest_dir)
        except:
            pass
        self.pi.read((self.dest_dir + "/pisi-index.xml"))

    # -------------------------------------------------------------------
    def listPackages(self, fullURI=True):
        """Lists packages for given repo address.
        
        listPackages(fullURI=True)
            
        Set fullURI to False to get just package names.
        """
        ### Iterate over packages ###
        i = 1
        for p in self.pi.packages:
            if fullURI:
                print i, "--", self.repo_url + p.packageURI
            else:
                print i, "--", p.packageURI
            i += 1

    # -------------------------------------------------------------------
    def getPackageList(self):
        """Returns a list of package uri's"""
        liste = []
        for p in self.pi.packages:
            p_uri = self.repo_url + p.packageURI
            liste.append(p_uri)
        return liste

    # ----------------------------------------------------------------------
    def fetchPackages(self, destination=None):
        """Downloads packages to destination directory """
        from urlgrabber.grabber import URLGrabber
        from urlgrabber.progress import TextMeter
        from os import path, chdir

        if destination:
            chdir(destination)
        else:
            chdir(self.dest_dir)

        ### URLGrabber objects ###
        t = TextMeter()
        g = URLGrabber(progress_obj=t)

        ### Start Iteration over list of packages' URIs ###
        for uri in self.getPackageList():
            pisifile = uri.split("/")[-1]
            if path.exists(pisifile):
                print pisifile, "--- No Update! Skipping..."
                continue
            try:
                g.urlgrab(uri)
            except:
                print "Error while downloading file %s" % pisifile
                break
        print "Finished."

    # ----------------------------------------------------------------------
    def generatePackageContents(to="cpickle"):
        """Generates lspisi outputs of pisi packages.
        Filetypes; cpickle, pickle, text"""
        pass