Kaydet (Commit) 5538e0ae authored tarafından Barış Metin's avatar Barış Metin

- make comar connection work.
- move comard initialization code to pisi.api from pisi.cli.commands (comard
  connection is not specialized for the command line interface).
  pisi.cli.commands.PackageOp needs a attention!
üst c00a3c6c
......@@ -43,6 +43,18 @@ def init(database = True, options = None, ui = None ):
import pisi.config
ctx.config = pisi.config.Config(options)
if ctx.config.options and not ctx.config.options.ignore_comar:
# FIXME: just try for others (that don't use comar)
try:
import comar
ctx.comard = comar.Link()
except ImportError:
print "INSTALL COMARD!"
print "skipping COMAR connection for now..."
except comar.Error:
print "NEXT TIME RUN COMARD FIRST!"
print "skipping COMAR connection for now..."
if ui is None:
if options:
pisi.context.ui = pisi.cli.CLI(options.debug)
......
......@@ -68,6 +68,8 @@ class Command(object):
p.add_option("-D", "--destdir", action="store")
p.add_option("", "--yes-all", action="store_true",
default=False, help = "assume yes in all yes/no queries")
p.add_option("", "--ignore-comar", action="store_true",
default=False, help="bypass comar configuration agent")
p.add_option("-u", "--username", action="store")
p.add_option("-p", "--password", action="store")
p.add_option("-P", action="store_true", dest="getpass", default=False,
......@@ -276,22 +278,24 @@ class PackageOp(Command):
super(PackageOp, self).__init__()
def options(self):
self.parser.add_option("", "--ignore-comar", action="store_true",
default=False, help="bypass comar configuration agent")
pass
## self.parser.add_option("", "--ignore-dependency",
## action="store_true",
## default=False, help="death")
def init(self):
super(PackageOp, self).init(True)
import pisi
if not self.options.ignore_comar:
import comar
try:
ctx.comard = comar.Link() # context
except comar.Error:
ctx.ui.error('Comar error encountered\n')
self.die()
pass
# ctx.comard should be initialized in pisi.api for other interfaces to
# use it!
# import pisi
# if not self.options.ignore_comar:
# import comar
# try:
# ctx.comard = comar.Link() # context
# except comar.Error:
# ctx.ui.error('Comar error encountered\n')
# self.die()
def finalize(self):
#self.finalize_db()
......
......@@ -52,7 +52,8 @@ class Installer:
self.reinstall()
self.extract_install()
self.store_pisi_files()
self.register_comar_scripts()
if ctx.comard:
self.register_comar_scripts()
self.update_databases()
def check_requirements(self):
......@@ -157,15 +158,21 @@ class Installer:
def register_comar_scripts(self):
"register COMAR scripts"
com = ctx.comard
for pcomar in self.metadata.package.providesComar:
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
ctx.ui.info("Registering COMAR script %s" % pcomar.script)
# FIXME: We must check the result of the command (possibly
# with id?)
if comard:
comard.register(pcomar.om,
self.metadata.package.name,
scriptPath)
com.register(pcomar.om,
self.metadata.package.name,
scriptPath)
while 1:
reply = com.read_cmd()
if reply[0] == com.RESULT:
break
elif reply[1] == com.ERROR:
raise InstallError, "COMAR.register failed!"
def update_databases(self):
......
......@@ -32,8 +32,18 @@ def remove_single(package_name):
raise Exception('Trying to remove nonexistent package '
+ package_name)
if ctx.comard:
ctx.comard.remove(package_name)
ctx.comard.call("System.Package", "preremove")
com = ctx.comard
# TODO: run preremove scripts...
# com.call("System.Package", "preremove")
com.remove(package_name)
while 1:
reply = com.read_cmd()
if reply[0] == com.RESULT:
break
elif reply[1] == com.ERROR:
raise Error, "COMAR.remove failed!"
for fileinfo in ctx.installdb.files(package_name).list:
fpath = os.path.join(ctx.config.destdir, fileinfo.path)
# TODO: We have to store configuration files for futher
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment