* fix: store full specfile in sourcedb

* implement emerge command
This commit is contained in:
Eray Özkural
2006-03-08 15:17:38 +00:00
parent 3c7581f5cb
commit 3c98fd0e27
6 changed files with 57 additions and 21 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ def handle_exception(exception, value, tb):
elif isinstance(value, db.DBRunRecoveryError): elif isinstance(value, db.DBRunRecoveryError):
ui.error(_("""A database operation has been aborted. You should run pisi ui.error(_("""A database operation has been aborted. You should run pisi
again for normal DB recovery procedure. Make sure you have free disk space. again for normal DB recovery procedure. Make sure you have free disk space.
You only have to run rebuild-db if there is file corruption.""")) You have to run rebuild-db only when there is file corruption."""))
elif isinstance(value, pisi.Exception): elif isinstance(value, pisi.Exception):
show_traceback = True show_traceback = True
ui.error(_("""Unhandled internal exception. ui.error(_("""Unhandled internal exception.
+2 -2
View File
@@ -12,9 +12,9 @@
# PiSi version # PiSi version
__version__ = "1.0.4" __version__ = "1.0.5"
__dbversion__ = "1.0.4" __dbversion__ = "1.0.5"
__all__ = [ 'api', 'config', 'packagedb', 'installdb', 'search' ] __all__ = [ 'api', 'config', 'packagedb', 'installdb', 'search' ]
+39 -2
View File
@@ -339,7 +339,7 @@ to be downloaded from a repository containing sources.
def options(self): def options(self):
buildno_opts(self) buildno_opts(self)
ignoredep_opt(self) ignoredep_opt(self)
self.parser.add_option("-O", "--output-dir", action="store", default=".", self.parser.add_option("-O", "--output-dir", action="store", default=None,
help=_("output directory for produced packages")) help=_("output directory for produced packages"))
self.parser.add_option("-A", "--ignore-action-errors", self.parser.add_option("-A", "--ignore-action-errors",
action="store_true", default=False, action="store_true", default=False,
@@ -353,12 +353,49 @@ to be downloaded from a repository containing sources.
return return
self.init(database = True) self.init(database = True)
ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir) if ctx.get_option('output_dir'):
ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir)
else:
ctx.ui.info(_('Outputting packages in the working directory.'))
ctx.config.options.output_dir = '.'
for x in self.args: for x in self.args:
pisi.api.build(x, self.authInfo) pisi.api.build(x, self.authInfo)
self.finalize() self.finalize()
class Emerge(Build):
"""Build and install a PISI source package from repository
Usage: build <sourcename> ...
You should give the name of a source package to be
downloaded from a repository containing sources.
"""
__metaclass__ = autocommand
def __init__(self):
super(Emerge, self).__init__()
name = ("Emerge", "em")
def run(self):
if not self.args:
self.help()
return
self.init(database = True)
if ctx.get_option('output_dir'):
ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir)
else:
ctx.ui.info(_('Outputting binary packages in the package cache.'))
ctx.config.options.output_dir = ctx.config.packages_dir()
pisi.api.emerge(self.args)
self.finalize()
class PackageOp(Command): class PackageOp(Command):
"""Abstract package operation command""" """Abstract package operation command"""
+6 -6
View File
@@ -45,7 +45,7 @@ class Index(XmlFile):
tag = "PISI" tag = "PISI"
t_Sources = [ [specfile.Source], autoxml.optional, "Source"] t_Specs = [ [specfile.SpecFile], autoxml.optional, "SpecFile"]
t_Packages = [ [metadata.Package], autoxml.optional, "Package"] t_Packages = [ [metadata.Package], autoxml.optional, "Package"]
t_Components = [ [component.Component], autoxml.optional, "Component"] t_Components = [ [component.Component], autoxml.optional, "Component"]
@@ -77,7 +77,7 @@ class Index(XmlFile):
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_spec(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)
@@ -86,8 +86,8 @@ class Index(XmlFile):
ctx.componentdb.update_component(comp) ctx.componentdb.update_component(comp)
for pkg in self.packages: for pkg in self.packages:
pkgdb.add_package(pkg) pkgdb.add_package(pkg)
for src in self.sources: for sf in self.specs:
ctx.sourcedb.add_source(src, repo) ctx.sourcedb.add_spec(sf, repo)
def add_package(self, path, repo_uri): def add_package(self, path, repo_uri):
package = Package(path, 'r') package = Package(path, 'r')
@@ -121,7 +121,7 @@ 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, repo_uri): def add_spec(self, path, repo_uri):
ctx.ui.info(_('Adding %s to source index') % path) ctx.ui.info(_('Adding %s to source index') % path)
sf = specfile.SpecFile() sf = specfile.SpecFile()
sf.read(path) sf.read(path)
@@ -134,4 +134,4 @@ class Index(XmlFile):
sf.source.sourceURI = os.path.realpath(path) sf.source.sourceURI = os.path.realpath(path)
else: # create relative path by default else: # create relative path by default
sf.source.sourceURI = util.removepathprefix(repo_uri, path) sf.source.sourceURI = util.removepathprefix(repo_uri, path)
self.sources.append(sf.source) self.specs.append(sf)
+1 -2
View File
@@ -607,10 +607,9 @@ installed in the respective order to satisfy dependencies:
ctx.ui.notify(ui.packagestogo, order = order) ctx.ui.notify(ui.packagestogo, order = order)
ctx.config.output_dir = ctx.config.packages_dir()
for x in order: for x in order:
package_names, blah = atomicoperations.build(x) package_names, blah = atomicoperations.build(x)
install(package_names) # handle inter-package deps here install_pkg_files(package_names) # handle inter-package deps here
def plan_emerge(A): def plan_emerge(A):
+8 -8
View File
@@ -48,11 +48,11 @@ class SourceDB(object):
list.append(pkg) # for some reason we couldn't return self.d.items()!! --exa list.append(pkg) # for some reason we couldn't return self.d.items()!! --exa
return list return list
def has_source(self, name): def has_spec(self, name):
name = str(name) name = str(name)
return self.d.has_key(name) return self.d.has_key(name)
def get_source(self, name): def get_spec(self, name):
name = str(name) name = str(name)
s = self.d[name] s = self.d[name]
order = ctx.repodb.list() order = ctx.repodb.list()
@@ -65,22 +65,22 @@ class SourceDB(object):
name = str(name) name = str(name)
return self.dpkgtosrc[name] return self.dpkgtosrc[name]
def add_source(self, source_info, repo, txn = None): def add_spec(self, spec, repo, txn = None):
assert not source_info.errors() assert not spec.errors()
name = str(source_info.name) name = str(spec.source.name)
repo = str(repo) repo = str(repo)
def proc(txn): def proc(txn):
if not self.d.has_key(name): if not self.d.has_key(name):
s = dict() s = dict()
else: else:
s = self.d.get(name, txn) s = self.d.get(name, txn)
s[repo] = source_info s[repo] = spec
self.d.put(name, s, txn) self.d.put(name, s, txn)
for pkg in source_info.packages: for pkg in spec.packages:
self.dpkgtosrc.put(pkg.name, name, txn) self.dpkgtosrc.put(pkg.name, name, txn)
self.d.txn_proc(proc, txn) self.d.txn_proc(proc, txn)
def remove_source(self, name, repo): def remove_specfile(self, name, repo):
name = str(name) name = str(name)
repo = str(repo) repo = str(repo)
def proc(txn): def proc(txn):