* complete the code to index sources
* to do this add an optional URI attribute to source spec
This commit is contained in:
+11
-9
@@ -73,8 +73,8 @@ class Index(XmlFile):
|
|||||||
if fn == 'component.xml':
|
if fn == 'component.xml':
|
||||||
ctx.ui.info(_('Adding %s to component index') % fn)
|
ctx.ui.info(_('Adding %s to component index') % fn)
|
||||||
self.add_component(os.path.join(root, fn))
|
self.add_component(os.path.join(root, fn))
|
||||||
#if fn == 'pspec.xml':
|
if fn == 'pspec.xml':
|
||||||
# self.add_source(os.path.join(root, fn), repo_uri)
|
self.add_source(os.path.join(root, fn), repo_uri)
|
||||||
|
|
||||||
def update_db(self, repo):
|
def update_db(self, repo):
|
||||||
pkgdb = packagedb.get_db(repo)
|
pkgdb = packagedb.get_db(repo)
|
||||||
@@ -93,11 +93,11 @@ class Index(XmlFile):
|
|||||||
md = metadata.MetaData()
|
md = metadata.MetaData()
|
||||||
md.read(os.path.join(ctx.config.install_dir(), ctx.const.metadata_xml))
|
md.read(os.path.join(ctx.config.install_dir(), ctx.const.metadata_xml))
|
||||||
if ctx.config.options and ctx.config.options.absolute_uris:
|
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)
|
md.package.packageURI = os.path.realpath(path)
|
||||||
else: # create relative path by default
|
else: # create relative path by default
|
||||||
# TODO: in the future we'll do all of this with purl/pfile/&helpers
|
# TODO: in the future well do all of this with purl/pfile/&helpers
|
||||||
# After that, we'll remove the ugly repo_uri parameter from this
|
# really? heheh -- future exa
|
||||||
# function.
|
|
||||||
md.package.packageURI = util.removepathprefix(repo_uri, path)
|
md.package.packageURI = util.removepathprefix(repo_uri, path)
|
||||||
# check package semantics
|
# check package semantics
|
||||||
errs = md.errors()
|
errs = md.errors()
|
||||||
@@ -116,8 +116,8 @@ class Index(XmlFile):
|
|||||||
ctx.ui.error(_('Component in %s is corrupt') % path)
|
ctx.ui.error(_('Component in %s is corrupt') % path)
|
||||||
#ctx.ui.error(str(Error(*errs)))
|
#ctx.ui.error(str(Error(*errs)))
|
||||||
|
|
||||||
def add_source(self, path):
|
def add_source(self, path, repo_uri):
|
||||||
ctx.ui.info(_('Adding %s to source index') % fn)
|
ctx.ui.info(_('Adding %s to source index') % path)
|
||||||
sf = specfile.SpecFile()
|
sf = specfile.SpecFile()
|
||||||
sf.read(path)
|
sf.read(path)
|
||||||
errs = sf.errors()
|
errs = sf.errors()
|
||||||
@@ -125,6 +125,8 @@ class Index(XmlFile):
|
|||||||
ctx.ui.error(_('SpecFile in %s is corrupt') % path)
|
ctx.ui.error(_('SpecFile in %s is corrupt') % path)
|
||||||
ctx.ui.error(str(Error(*errs)))
|
ctx.ui.error(str(Error(*errs)))
|
||||||
else:
|
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)
|
self.sources.append(sf.source)
|
||||||
|
|
||||||
#TODO: add source
|
|
||||||
|
|||||||
+2
-2
@@ -36,8 +36,8 @@ class Error(pisi.Error):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class PackageDB(object):
|
class PackageDB(object):
|
||||||
"""PackageDB class provides an interface to the package database with
|
"""PackageDB class provides an interface to the package database
|
||||||
a delegated dbshelve object"""
|
using shelf objects"""
|
||||||
def __init__(self, id):
|
def __init__(self, id):
|
||||||
self.d = shelve.LockedDBShelf('package-%s' % id )
|
self.d = shelve.LockedDBShelf('package-%s' % id )
|
||||||
self.dr = shelve.LockedDBShelf('revdep-%s' % id )
|
self.dr = shelve.LockedDBShelf('revdep-%s' % id )
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ class Source:
|
|||||||
t_BuildDependencies = [ [Dependency], autoxml.optional]
|
t_BuildDependencies = [ [Dependency], autoxml.optional]
|
||||||
t_Version = [ autoxml.String, autoxml.optional]
|
t_Version = [ autoxml.String, autoxml.optional]
|
||||||
t_Release = [ autoxml.String, autoxml.optional]
|
t_Release = [ autoxml.String, autoxml.optional]
|
||||||
|
t_SourceURI = [ autoxml.String, autoxml.optional ] # used in index
|
||||||
|
|
||||||
|
|
||||||
class Package:
|
class Package:
|
||||||
|
|||||||
Reference in New Issue
Block a user