From 911b3a5dc70deaf0378991e600237c87f1e4ce85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 6 Dec 2005 16:55:41 +0000 Subject: [PATCH] * complete the code to index sources * to do this add an optional URI attribute to source spec --- pisi/index.py | 20 +++++++++++--------- pisi/packagedb.py | 4 ++-- pisi/specfile.py | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pisi/index.py b/pisi/index.py index c1101835..ebb83fb6 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -73,8 +73,8 @@ class Index(XmlFile): if fn == 'component.xml': ctx.ui.info(_('Adding %s to component index') % fn) self.add_component(os.path.join(root, fn)) - #if fn == 'pspec.xml': - # self.add_source(os.path.join(root, fn), repo_uri) + if fn == 'pspec.xml': + self.add_source(os.path.join(root, fn), repo_uri) def update_db(self, repo): pkgdb = packagedb.get_db(repo) @@ -93,11 +93,11 @@ class Index(XmlFile): md = metadata.MetaData() md.read(os.path.join(ctx.config.install_dir(), ctx.const.metadata_xml)) if ctx.config.options and ctx.config.options.absolute_uris: + # FIXME: the name "absolute_uris" does not seem to fit below :/ md.package.packageURI = os.path.realpath(path) else: # create relative path by default - # TODO: in the future we'll do all of this with purl/pfile/&helpers - # After that, we'll remove the ugly repo_uri parameter from this - # function. + # TODO: in the future well do all of this with purl/pfile/&helpers + # really? heheh -- future exa md.package.packageURI = util.removepathprefix(repo_uri, path) # check package semantics errs = md.errors() @@ -116,8 +116,8 @@ class Index(XmlFile): ctx.ui.error(_('Component in %s is corrupt') % path) #ctx.ui.error(str(Error(*errs))) - def add_source(self, path): - ctx.ui.info(_('Adding %s to source index') % fn) + def add_source(self, path, repo_uri): + ctx.ui.info(_('Adding %s to source index') % path) sf = specfile.SpecFile() sf.read(path) errs = sf.errors() @@ -125,6 +125,8 @@ class Index(XmlFile): ctx.ui.error(_('SpecFile in %s is corrupt') % path) ctx.ui.error(str(Error(*errs))) else: + if ctx.config.options and ctx.config.options.absolute_uris: + sf.source.sourceURI = os.path.realpath(path) + else: # create relative path by default + sf.source.sourceURI = util.removepathprefix(repo_uri, path) self.sources.append(sf.source) - - #TODO: add source diff --git a/pisi/packagedb.py b/pisi/packagedb.py index 6fc7ce9d..27702eba 100644 --- a/pisi/packagedb.py +++ b/pisi/packagedb.py @@ -36,8 +36,8 @@ class Error(pisi.Error): pass class PackageDB(object): - """PackageDB class provides an interface to the package database with - a delegated dbshelve object""" + """PackageDB class provides an interface to the package database + using shelf objects""" def __init__(self, id): self.d = shelve.LockedDBShelf('package-%s' % id ) self.dr = shelve.LockedDBShelf('revdep-%s' % id ) diff --git a/pisi/specfile.py b/pisi/specfile.py index d46c6531..2b9770ee 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -156,6 +156,7 @@ class Source: t_BuildDependencies = [ [Dependency], autoxml.optional] t_Version = [ autoxml.String, autoxml.optional] t_Release = [ autoxml.String, autoxml.optional] + t_SourceURI = [ autoxml.String, autoxml.optional ] # used in index class Package: