示例#1
0
    def add_package(self, package_info, repo, txn = None):
        name = str(package_info.name)
        
        def proc(txn):
            self.d.add_item(name, package_info, repo, txn)
            for dep in package_info.runtimeDependencies():
                dep_name = str(dep.package)
                if self.dr.has_key(dep_name, repo, txn):
                    revdep = self.dr.get_item(dep_name, repo, txn)
                    revdep = filter(lambda (n,d):n!=name, revdep)
                    revdep.append( (name, dep) )
                    self.dr.add_item(dep_name, revdep, repo, txn)
                else:
                    self.dr.add_item(dep_name, [ (name, dep) ], repo, txn)
            # add component
            ctx.componentdb.add_package(package_info.partOf, package_info.name, repo, txn)
            # index summary and description
            for (lang, doc) in package_info.summary.iteritems():
                if lang in ['en', 'tr']:
                    pisi.search.add_doc('summary', lang, package_info.name, doc, txn)
            for (lang, doc) in package_info.description.iteritems():
                if lang in ['en', 'tr']:
                    pisi.search.add_doc('description', lang, package_info.name, doc, txn)

        ctx.txn_proc(proc, txn)
示例#2
0
    def add_package(self, package_info, repo, txn = None):
        name = str(package_info.name)

        def proc(txn):
            self.d.add_item(name, package_info, repo, txn)
            for dep in package_info.runtimeDependencies():
                dep_name = str(dep.package)
                if self.dr.has_key(dep_name, repo, txn):
                    revdep = self.dr.get_item(dep_name, repo, txn)
                    revdep = filter(lambda (n,d):n!=name, revdep)
                    revdep.append( (name, dep) )
                    self.dr.add_item(dep_name, revdep, repo, txn)
                else:
                    self.dr.add_item(dep_name, [ (name, dep) ], repo, txn)
            # add component
            ctx.componentdb.add_package(package_info.partOf, package_info.name, repo, txn)
            # index summary and description
            search_keys = {}
            for (lang, doc) in package_info.summary.iteritems():
                text = search_keys.get(lang, "")
                text += " %s" % doc
                search_keys[lang] = text
            for (lang, doc) in package_info.description.iteritems():
                text = search_keys.get(lang, "")
                text += " %s" % doc
                search_keys[lang] = text
            for lang in search_keys:
                text = search_keys[lang]
                # FIXME: other languages should be searchable too
                if lang in ('en', 'tr'):
                    pisi.search.add_doc('terms', lang, package_info.name, doc, repo=repo, txn=txn)
        ctx.txn_proc(proc, txn)
示例#3
0
 def remove_package(self, component_name, package, repo = None, txn = None):
     def proc(txn, repo):
         if not self.has_component(component_name, repo, txn):
             raise Error(_('Information for component %s not available') % component_name)
         if not repo:
             repo = self.d.which_repo(component_name, txn=txn) # get default repo then
         component = self.get_component(component_name, repo, txn)
         if package in component.packages:
             component.packages.remove(package)
         self.d.add_item(component_name, component, repo, txn) # update
         
     ctx.txn_proc(lambda x: proc(txn, repo), txn)
示例#4
0
    def remove_spec(self, component_name, spec, repo=None, txn=None):
        def proc(txn, repo):
            if not self.has_component(component_name, repo, txn):
                raise Error(_("Information for component %s not available") % component_name)
            if not repo:
                repo = self.d.which_repo(component_name, txn=txn)  # get default repo then
            component = self.get_component(component_name, repo, txn)
            if spec in component.sources:
                component.sources.remove(spec)
            self.d.add_item(component_name, component, repo, txn)  # update

        ctx.txn_proc(lambda x: proc(txn, repo), txn)
示例#5
0
    def remove_spec(self, component_name, spec, repo=None, txn=None):
        def proc(txn, repo):
            if not self.has_component(component_name, repo, txn):
                raise Error(
                    _('Information for component %s not available') %
                    component_name)
            if not repo:
                repo = self.d.which_repo(component_name,
                                         txn=txn)  # get default repo then
            component = self.get_component(component_name, repo, txn)
            if spec in component.sources:
                component.sources.remove(spec)
            self.d.add_item(component_name, component, repo, txn)  # update

        ctx.txn_proc(lambda x: proc(txn, repo), txn)
示例#6
0
def has_package(name, txn = None):
    def proc(txn):
        repo = which_repo(name)
        if repo or thirdparty_packagedb.has_package(name, txn) or inst_packagedb.has_package(name, txn):
            return True
        return False
    return ctx.txn_proc(proc, txn)
示例#7
0
def resurrect_package(package_fn):
    """Resurrect the package in the PiSi databases"""

    from os.path import exists

    metadata_xml = util.join_path(ctx.config.lib_dir(), 'package', 
                                  package_fn, ctx.const.metadata_xml)
    if not exists(metadata_xml):
       raise Error, _("Metadata XML '%s' cannot be found") % metadata_xml

    metadata = MetaData()
    metadata.read(metadata_xml)

    errs = metadata.errors()
    if errs:   
       util.Checks.print_errors(errs)
       raise Error, _("MetaData format wrong (%s)") % package_fn

    # FIXME: there won't be any previous versions of the same package under /var/lib/pisi
    # therefore there won't be any need for this check and __is_virtual_upgrade function
    # this is just for backward compatibility for sometime

    # yes, this is an ugly hack
    passed = False
    if ctx.installdb.is_installed(metadata.package.name):
        passed = True
    
    if not passed:
        ctx.ui.info(_('* Adding \'%s\' to db... ') % (metadata.package.name), noln=True)
    
    files_xml = util.join_path(ctx.config.lib_dir(), 'package',
                               package_fn, ctx.const.files_xml)
    if not exists(files_xml):
       raise Error, _("Files XML '%s' cannot be found") % files_xml

    files = Files()
    files.read(files_xml)

    if files.errors():
       raise Error, _("Invalid %s") % ctx.const.files_xml

    import pisi.atomicoperations
    def f(txn):
        pisi.atomicoperations.virtual_install(metadata, files, txn)
    ctx.txn_proc(f)
    if not passed:
        ctx.ui.info(_('OK.'))
示例#8
0
def which_repo(name, txn = None):
    import pisi.repodb
    def proc(txn):
        for repo in pisi.repodb.db.list():
            if get_db(repo).has_package(name, txn):
                return repo
        return None
    return ctx.txn_proc(proc, txn)
示例#9
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))
示例#10
0
    def add_package(self, package_info, repo, txn = None):
        name = str(package_info.name)

        def proc(txn):
            self.d.add_item(name, package_info, repo, txn)
            for dep in package_info.runtimeDependencies():
                dep_name = str(dep.package)
                if self.dr.has_key(dep_name, repo, txn):
                    revdep = self.dr.get_item(dep_name, repo, txn)
                    revdep = filter(lambda (n,d):n!=name, revdep)
                    revdep.append( (name, dep) )
                    self.dr.add_item(dep_name, revdep, repo, txn)
                else:
                    self.dr.add_item(dep_name, [ (name, dep) ], repo, txn)
            # add component
            ctx.componentdb.add_package(package_info.partOf, package_info.name, repo, txn)

        ctx.txn_proc(proc, txn)
示例#11
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.'))
示例#12
0
文件: repo.py 项目: zaxebo1/pisi-1
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.'))
示例#13
0
def resurrect_package(package_fn, write_files, txn = None):
    """Resurrect the package from xml files"""

    from os.path import exists

    metadata_xml = util.join_path(ctx.config.lib_dir(), 'package', 
                                  package_fn, ctx.const.metadata_xml)
    if not exists(metadata_xml):
        raise Error, _("Metadata XML '%s' cannot be found") % metadata_xml
    
    metadata = MetaData()
    metadata.read(metadata_xml)
    
    errs = metadata.errors()
    if errs:   
        util.Checks.print_errors(errs)
        raise Error, _("MetaData format wrong (%s)") % package_fn
    
    ctx.ui.info(_('* Adding \'%s\' to db... ') % (metadata.package.name), noln=True)

    if write_files:
        files_xml = util.join_path(ctx.config.lib_dir(), 'package',
                                package_fn, ctx.const.files_xml)
        if not exists(files_xml):
            raise Error, _("Files XML '%s' cannot be found") % files_xml
    
        files = Files()
        files.read(files_xml)
        if files.errors():
            raise Error, _("Invalid %s") % ctx.const.files_xml
    else:
        files = None

    #import pisi.atomicoperations
    def f(t):
        pisi.atomicoperations.virtual_install(metadata, files, t)
    ctx.txn_proc(f, txn)

    ctx.ui.info(_('OK.'))
示例#14
0
    def add_package(self, package_info, repo, txn=None):
        name = str(package_info.name)

        def proc(txn):
            self.d.add_item(name, package_info, repo, txn)
            for dep in package_info.runtimeDependencies():
                dep_name = str(dep.package)
                if self.dr.has_key(dep_name, repo, txn):
                    revdep = self.dr.get_item(dep_name, repo, txn)
                    revdep = filter(lambda (n, d): n != name, revdep)
                    revdep.append((name, dep))
                    self.dr.add_item(dep_name, revdep, repo, txn)
                else:
                    self.dr.add_item(dep_name, [(name, dep)], repo, txn)
            # add component
            ctx.componentdb.add_package(package_info.partOf, package_info.name,
                                        repo, txn)
            # index summary and description
            for (lang, doc) in package_info.summary.iteritems():
                if lang in ['en', 'tr']:
                    pisi.search.add_doc('summary',
                                        lang,
                                        package_info.name,
                                        doc,
                                        repo=repo,
                                        txn=txn)
            for (lang, doc) in package_info.description.iteritems():
                if lang in ['en', 'tr']:
                    pisi.search.add_doc('description',
                                        lang,
                                        package_info.name,
                                        doc,
                                        repo=repo,
                                        txn=txn)

        ctx.txn_proc(proc, txn)
示例#15
0
        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)

        ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn))
        ctx.ui.info(_('* Package database updated.'))            
    else:
        raise Error(_('No repository named %s found.') % repo)

def delete_cache():
    util.clean_dir(ctx.config.packages_dir())
    util.clean_dir(ctx.config.archives_dir())
    util.clean_dir(ctx.config.tmp_dir())

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()
示例#16
0
文件: repo.py 项目: zaxebo1/pisi-1
        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)

        ctx.txn_proc(lambda txn: index.update_db(repo, txn=txn))
        ctx.ui.info(_('* Package database updated.'))
    else:
        raise Error(_('No repository named %s found.') % repo)


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')
示例#17
0
 def add_obsoletes(self, obsoletes, repo, txn = None):
     def proc(txn):
         self.do.add_item(repo, obsoletes, repo, txn)
     ctx.txn_proc(proc, txn)