* fix: determine source component when indexing
* fix: add sources to componentdb correctly, enabling emerge <component> :)
This commit is contained in:
+27
-1
@@ -9,7 +9,7 @@
|
||||
#
|
||||
# Please read the COPYING file.
|
||||
#
|
||||
# Author: Eray Ozkural <eray@pardus.org.tr>
|
||||
# Author: Eray Ozkural <eray at pardus.org.tr>
|
||||
|
||||
import gettext
|
||||
__trans = gettext.translation('pisi', fallback=True)
|
||||
@@ -149,6 +149,7 @@ class ComponentDB(object):
|
||||
|
||||
def add_package(self, component_name, package, repo, txn = None):
|
||||
def proc(txn):
|
||||
assert component_name
|
||||
if self.has_component(component_name, repo, txn):
|
||||
component = self.get_component(component_name, repo, txn)
|
||||
else:
|
||||
@@ -171,6 +172,31 @@ class ComponentDB(object):
|
||||
|
||||
ctx.txn_proc(lambda x: proc(txn, repo), txn)
|
||||
|
||||
def add_spec(self, component_name, spec, repo, txn = None):
|
||||
def proc(txn):
|
||||
assert component_name
|
||||
if self.has_component(component_name, repo, txn):
|
||||
component = self.get_component(component_name, repo, txn)
|
||||
else:
|
||||
component = Component( name = component_name )
|
||||
if not spec in component.sources:
|
||||
component.sources.append(spec)
|
||||
self.d.add_item(component_name, component, repo, txn) # update
|
||||
self.d.txn_proc(proc, txn)
|
||||
|
||||
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.packages.remove(spec)
|
||||
self.d.add_item(component_name, component, repo, txn) # update
|
||||
|
||||
ctx.txn_proc(lambda x: proc(txn, repo), txn)
|
||||
|
||||
def clear(self, txn = None):
|
||||
self.d.clear(txn)
|
||||
|
||||
|
||||
+17
-13
@@ -38,7 +38,7 @@ import pisi.specfile as specfile
|
||||
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class Index(XmlFile):
|
||||
__metaclass__ = autoxml.autoxml
|
||||
@@ -156,16 +156,20 @@ class Index(XmlFile):
|
||||
#ctx.ui.error(str(Error(*errs)))
|
||||
|
||||
def add_spec(self, path, repo_uri):
|
||||
import pisi.build
|
||||
ctx.ui.info(_('Adding %s to source index') % path)
|
||||
sf = specfile.SpecFile()
|
||||
sf.read(path)
|
||||
errs = sf.errors()
|
||||
if sf.errors():
|
||||
ctx.ui.error(_('SpecFile in %s is corrupt, skipping...') % 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.specs.append(sf)
|
||||
builder = pisi.build.Builder(path)
|
||||
#sf = specfile.SpecFile()
|
||||
#sf.read(path)
|
||||
#errs = sf.errors()
|
||||
#if sf.errors():
|
||||
#ctx.ui.error(_('SpecFile in %s is corrupt, skipping...') % path)
|
||||
#ctx.ui.error(str(Error(*errs)))
|
||||
builder.fetch_component()
|
||||
sf = builder.spec
|
||||
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)
|
||||
# check component
|
||||
self.specs.append(sf)
|
||||
|
||||
@@ -75,6 +75,7 @@ class SourceDB(object):
|
||||
self.d.add_item(name, spec, repo, txn)
|
||||
for pkg in spec.packages:
|
||||
self.dpkgtosrc.add_item(pkg.name, name, repo, txn)
|
||||
ctx.componentdb.add_spec(spec.source.partOf, spec.source.name, repo, txn)
|
||||
self.d.txn_proc(proc, txn)
|
||||
|
||||
def remove_spec(self, name, repo, txn = None):
|
||||
@@ -85,6 +86,7 @@ class SourceDB(object):
|
||||
self.d.remove_item(name, txn=txn)
|
||||
for pkg in spec.packages:
|
||||
self.dpkgtosrc.remove_item_repo(pkg.name, repo, txn)
|
||||
ctx.componentdb.remove_spec(spec.source.partOf, spec.source.name, repo, txn)
|
||||
|
||||
self.d.txn_proc(proc, txn)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user