* 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.
|
# Please read the COPYING file.
|
||||||
#
|
#
|
||||||
# Author: Eray Ozkural <eray@pardus.org.tr>
|
# Author: Eray Ozkural <eray at pardus.org.tr>
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -149,6 +149,7 @@ class ComponentDB(object):
|
|||||||
|
|
||||||
def add_package(self, component_name, package, repo, txn = None):
|
def add_package(self, component_name, package, repo, txn = None):
|
||||||
def proc(txn):
|
def proc(txn):
|
||||||
|
assert component_name
|
||||||
if self.has_component(component_name, repo, txn):
|
if self.has_component(component_name, repo, txn):
|
||||||
component = self.get_component(component_name, repo, txn)
|
component = self.get_component(component_name, repo, txn)
|
||||||
else:
|
else:
|
||||||
@@ -171,6 +172,31 @@ class ComponentDB(object):
|
|||||||
|
|
||||||
ctx.txn_proc(lambda x: proc(txn, repo), txn)
|
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):
|
def clear(self, txn = None):
|
||||||
self.d.clear(txn)
|
self.d.clear(txn)
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -38,7 +38,7 @@ import pisi.specfile as specfile
|
|||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Index(XmlFile):
|
class Index(XmlFile):
|
||||||
__metaclass__ = autoxml.autoxml
|
__metaclass__ = autoxml.autoxml
|
||||||
@@ -156,16 +156,20 @@ class Index(XmlFile):
|
|||||||
#ctx.ui.error(str(Error(*errs)))
|
#ctx.ui.error(str(Error(*errs)))
|
||||||
|
|
||||||
def add_spec(self, path, repo_uri):
|
def add_spec(self, path, repo_uri):
|
||||||
|
import pisi.build
|
||||||
ctx.ui.info(_('Adding %s to source index') % path)
|
ctx.ui.info(_('Adding %s to source index') % path)
|
||||||
sf = specfile.SpecFile()
|
builder = pisi.build.Builder(path)
|
||||||
sf.read(path)
|
#sf = specfile.SpecFile()
|
||||||
errs = sf.errors()
|
#sf.read(path)
|
||||||
if sf.errors():
|
#errs = sf.errors()
|
||||||
ctx.ui.error(_('SpecFile in %s is corrupt, skipping...') % path)
|
#if sf.errors():
|
||||||
ctx.ui.error(str(Error(*errs)))
|
#ctx.ui.error(_('SpecFile in %s is corrupt, skipping...') % path)
|
||||||
else:
|
#ctx.ui.error(str(Error(*errs)))
|
||||||
if ctx.config.options and ctx.config.options.absolute_uris:
|
builder.fetch_component()
|
||||||
sf.source.sourceURI = os.path.realpath(path)
|
sf = builder.spec
|
||||||
else: # create relative path by default
|
if ctx.config.options and ctx.config.options.absolute_uris:
|
||||||
sf.source.sourceURI = util.removepathprefix(repo_uri, path)
|
sf.source.sourceURI = os.path.realpath(path)
|
||||||
self.specs.append(sf)
|
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)
|
self.d.add_item(name, spec, repo, txn)
|
||||||
for pkg in spec.packages:
|
for pkg in spec.packages:
|
||||||
self.dpkgtosrc.add_item(pkg.name, name, repo, txn)
|
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)
|
self.d.txn_proc(proc, txn)
|
||||||
|
|
||||||
def remove_spec(self, name, repo, txn = None):
|
def remove_spec(self, name, repo, txn = None):
|
||||||
@@ -85,6 +86,7 @@ class SourceDB(object):
|
|||||||
self.d.remove_item(name, txn=txn)
|
self.d.remove_item(name, txn=txn)
|
||||||
for pkg in spec.packages:
|
for pkg in spec.packages:
|
||||||
self.dpkgtosrc.remove_item_repo(pkg.name, repo, txn)
|
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)
|
self.d.txn_proc(proc, txn)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user