diff --git a/pisi/api.py b/pisi/api.py index 0f0479d8..9a8484fb 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -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) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 300bdf96..94fa23b6 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -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() diff --git a/pisi/install.py b/pisi/install.py index 4e4d6301..16d329d9 100644 --- a/pisi/install.py +++ b/pisi/install.py @@ -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): diff --git a/pisi/operations.py b/pisi/operations.py index cde7ddda..e0af44c1 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -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