* implement a database of components
* extend index commands: allow for multiple dirs to be indexed at once NB: unfortunately, this exposes a bug in autoxml XmlFile support that I knew but had forgotten...
This commit is contained in:
@@ -94,10 +94,11 @@ Legend:
|
|||||||
+ requirements
|
+ requirements
|
||||||
+ xml format, add to PSPEC
|
+ xml format, add to PSPEC
|
||||||
+ index component.xml's and make use of them in build
|
+ index component.xml's and make use of them in build
|
||||||
- a database of components:
|
/ a database of components:
|
||||||
- query components by name
|
+ query components by name
|
||||||
- query list of packages in a component
|
+ query list of packages in a component
|
||||||
- index: update component database(s)
|
+ index: update component database(s)
|
||||||
|
/ bug fixing
|
||||||
- install/remove components
|
- install/remove components
|
||||||
- safety switch: preserve system.base, install system.devel for build, etc.
|
- safety switch: preserve system.base, install system.devel for build, etc.
|
||||||
+ multiple package repository (eray)
|
+ multiple package repository (eray)
|
||||||
|
|||||||
+11
-5
@@ -38,6 +38,7 @@ import pisi.packagedb as packagedb
|
|||||||
import pisi.repodb
|
import pisi.repodb
|
||||||
import pisi.installdb
|
import pisi.installdb
|
||||||
import pisi.sourcedb
|
import pisi.sourcedb
|
||||||
|
import pisi.component as component
|
||||||
from pisi.index import Index
|
from pisi.index import Index
|
||||||
import pisi.cli
|
import pisi.cli
|
||||||
from pisi.operations import install, remove, upgrade
|
from pisi.operations import install, remove, upgrade
|
||||||
@@ -70,12 +71,14 @@ def init(database = True, options = None, ui = None, comar = True):
|
|||||||
ctx.repodb = pisi.repodb.init()
|
ctx.repodb = pisi.repodb.init()
|
||||||
ctx.installdb = pisi.installdb.init()
|
ctx.installdb = pisi.installdb.init()
|
||||||
ctx.filesdb = pisi.files.FilesDB()
|
ctx.filesdb = pisi.files.FilesDB()
|
||||||
|
ctx.componentdb = pisi.component.ComponentDB()
|
||||||
packagedb.init_db()
|
packagedb.init_db()
|
||||||
pisi.sourcedb.init()
|
pisi.sourcedb.init()
|
||||||
else:
|
else:
|
||||||
ctx.repodb = None
|
ctx.repodb = None
|
||||||
ctx.installdb = None
|
ctx.installdb = None
|
||||||
ctx.filesdb = None
|
ctx.filesdb = None
|
||||||
|
ctx.componentdb = None
|
||||||
ctx.ui.debug('PISI API initialized')
|
ctx.ui.debug('PISI API initialized')
|
||||||
ctx.initialized = True
|
ctx.initialized = True
|
||||||
|
|
||||||
@@ -84,7 +87,8 @@ def finalize():
|
|||||||
pisi.installdb.finalize()
|
pisi.installdb.finalize()
|
||||||
if ctx.filesdb != None:
|
if ctx.filesdb != None:
|
||||||
ctx.filesdb.close()
|
ctx.filesdb.close()
|
||||||
|
if ctx.componentdb != None:
|
||||||
|
ctx.componentdb.close()
|
||||||
packagedb.finalize_db()
|
packagedb.finalize_db()
|
||||||
pisi.sourcedb.finalize()
|
pisi.sourcedb.finalize()
|
||||||
ctx.ui.debug('PISI API finalized')
|
ctx.ui.debug('PISI API finalized')
|
||||||
@@ -223,11 +227,13 @@ def info_name(package_name):
|
|||||||
else:
|
else:
|
||||||
raise Error(_('Package %s not found') % package_name)
|
raise Error(_('Package %s not found') % package_name)
|
||||||
|
|
||||||
def index(repo_dir = '.', output = 'pisi-index.xml'):
|
def index(dirs, output = 'pisi-index.xml'):
|
||||||
|
|
||||||
ctx.ui.info(_('* Building index of PISI files under %s') % repo_dir)
|
|
||||||
index = Index()
|
index = Index()
|
||||||
index.index(repo_dir)
|
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)
|
index.write(output)
|
||||||
ctx.ui.info(_('* Index file written'))
|
ctx.ui.info(_('* Index file written'))
|
||||||
|
|
||||||
|
|||||||
@@ -565,14 +565,11 @@ source and binary packages.
|
|||||||
|
|
||||||
self.init()
|
self.init()
|
||||||
from pisi.api import index
|
from pisi.api import index
|
||||||
if len(self.args)==1:
|
if len(self.args)>0:
|
||||||
index(self.args[0], ctx.get_option('output'))
|
index(self.args, ctx.get_option('output'))
|
||||||
elif len(self.args)==0:
|
elif len(self.args)==0:
|
||||||
ctx.ui.info( _('Indexing current directory.'))
|
ctx.ui.info( _('Indexing current directory.'))
|
||||||
index('.', ctx.get_option('output'))
|
index('.', ctx.get_option('output'))
|
||||||
else:
|
|
||||||
ctx.ui.info( _('Indexing only a single directory supported.'))
|
|
||||||
return
|
|
||||||
self.finalize()
|
self.finalize()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+51
-3
@@ -9,9 +9,7 @@
|
|||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
# Authors: Eray Ozkural <eray@uludag.org.tr>
|
# Author: Eray Ozkural <eray@uludag.org.tr>
|
||||||
|
|
||||||
"""a placeholder for data types, might factor elsewhere later"""
|
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -20,6 +18,7 @@ _ = __trans.ugettext
|
|||||||
import pisi
|
import pisi
|
||||||
import pisi.pxml.xmlfile as xmlfile
|
import pisi.pxml.xmlfile as xmlfile
|
||||||
import pisi.pxml.autoxml as autoxml
|
import pisi.pxml.autoxml as autoxml
|
||||||
|
import pisi.lockeddbshelve as shelve
|
||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
@@ -57,6 +56,10 @@ class Component(xmlfile.XmlFile):
|
|||||||
# Dependencies to other components
|
# Dependencies to other components
|
||||||
t_Dependencies = [ [autoxml.String], autoxml.optional, "Dependencies/Component"]
|
t_Dependencies = [ [autoxml.String], autoxml.optional, "Dependencies/Component"]
|
||||||
|
|
||||||
|
# the components contained by this guy.
|
||||||
|
# to be filled by the component database, thus it is optional.
|
||||||
|
t_Components = [ [autoxml.String], autoxml.optional, "Components/Component"]
|
||||||
|
|
||||||
# TODO: this is probably not necessary since we use fully qualified
|
# TODO: this is probably not necessary since we use fully qualified
|
||||||
# module names (like in Java)
|
# module names (like in Java)
|
||||||
#t_PartOf = [autoxml.Text, autoxml.mandatory]
|
#t_PartOf = [autoxml.Text, autoxml.mandatory]
|
||||||
@@ -74,3 +77,48 @@ class Component(xmlfile.XmlFile):
|
|||||||
# t_Dependencies = [ [autoxml.Text], autoxml.optional, "Component"]
|
# t_Dependencies = [ [autoxml.Text], autoxml.optional, "Component"]
|
||||||
# #t_Parts = [ [pisi.component.ComponentTree], autoxml.optional, "Component"]
|
# #t_Parts = [ [pisi.component.ComponentTree], autoxml.optional, "Component"]
|
||||||
|
|
||||||
|
class ComponentDB(object):
|
||||||
|
"""a database of components"""
|
||||||
|
|
||||||
|
#FIXME: we might need a database per repo in the future
|
||||||
|
def __init__(self):
|
||||||
|
self.d = shelve.LockedDBShelf('components')
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.d.close()
|
||||||
|
|
||||||
|
def has_component(self, name):
|
||||||
|
return self.d.has_key(name)
|
||||||
|
|
||||||
|
def get_component(self, name):
|
||||||
|
return self.d[name]
|
||||||
|
|
||||||
|
def list_components(self):
|
||||||
|
list = []
|
||||||
|
for (pkg, x) in self.d.iteritems():
|
||||||
|
list.append(pkg)
|
||||||
|
return list
|
||||||
|
|
||||||
|
def add_component(self, component):
|
||||||
|
self.d[name] = component.name
|
||||||
|
|
||||||
|
def add_package(self, component_name, package):
|
||||||
|
if not self.has_component(component_name):
|
||||||
|
raise Error(_('Information for component %s not available') % component_name)
|
||||||
|
component = self.get_component(component_name)
|
||||||
|
component.components.append(package)
|
||||||
|
self.d[component_name] = component # update
|
||||||
|
|
||||||
|
def remove_package(self, component_name, package):
|
||||||
|
if not self.has_component(component_name):
|
||||||
|
raise Error(_('Information for component %s not available') % component_name)
|
||||||
|
component = self.get_component(component_name)
|
||||||
|
component.components.remove(package)
|
||||||
|
self.d[component_name] = component # update
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self.d.clear()
|
||||||
|
|
||||||
|
def remove_component(self, name):
|
||||||
|
name = str(name)
|
||||||
|
del self.d[name]
|
||||||
|
|||||||
+2
-2
@@ -79,10 +79,10 @@ class Index(XmlFile):
|
|||||||
def update_db(self, repo):
|
def update_db(self, repo):
|
||||||
pkgdb = packagedb.get_db(repo)
|
pkgdb = packagedb.get_db(repo)
|
||||||
pkgdb.clear()
|
pkgdb.clear()
|
||||||
|
for comp in self.components:
|
||||||
|
compdb.add_component(pkg)
|
||||||
for pkg in self.packages:
|
for pkg in self.packages:
|
||||||
pkgdb.add_package(pkg)
|
pkgdb.add_package(pkg)
|
||||||
#for comp in self.components:
|
|
||||||
# compdb.add_component(pkg)
|
|
||||||
|
|
||||||
def add_package(self, path, repo_uri):
|
def add_package(self, path, repo_uri):
|
||||||
package = Package(path, 'r')
|
package = Package(path, 'r')
|
||||||
|
|||||||
+4
-1
@@ -78,6 +78,8 @@ class PackageDB(object):
|
|||||||
self.dr[dep_name].append( (name, dep) )
|
self.dr[dep_name].append( (name, dep) )
|
||||||
else:
|
else:
|
||||||
self.dr[dep_name] = [ (name, dep) ]
|
self.dr[dep_name] = [ (name, dep) ]
|
||||||
|
# add component
|
||||||
|
ctx.componentdb.add_package(package_info.partOf, package_info.name)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.d.clear()
|
self.d.clear()
|
||||||
@@ -85,7 +87,8 @@ class PackageDB(object):
|
|||||||
def remove_package(self, name):
|
def remove_package(self, name):
|
||||||
name = str(name)
|
name = str(name)
|
||||||
del self.d[name]
|
del self.d[name]
|
||||||
|
#FIXME: what's happening to dr?
|
||||||
|
ctx.componentdb.remove_package(package_info.partOf, package_info.name)
|
||||||
|
|
||||||
packagedbs = {}
|
packagedbs = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user