- 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!
This commit is contained in:
+12
@@ -43,6 +43,18 @@ def init(database = True, options = None, ui = None ):
|
|||||||
import pisi.config
|
import pisi.config
|
||||||
ctx.config = pisi.config.Config(options)
|
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 ui is None:
|
||||||
if options:
|
if options:
|
||||||
pisi.context.ui = pisi.cli.CLI(options.debug)
|
pisi.context.ui = pisi.cli.CLI(options.debug)
|
||||||
|
|||||||
+14
-10
@@ -68,6 +68,8 @@ class Command(object):
|
|||||||
p.add_option("-D", "--destdir", action="store")
|
p.add_option("-D", "--destdir", action="store")
|
||||||
p.add_option("", "--yes-all", action="store_true",
|
p.add_option("", "--yes-all", action="store_true",
|
||||||
default=False, help = "assume yes in all yes/no queries")
|
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("-u", "--username", action="store")
|
||||||
p.add_option("-p", "--password", action="store")
|
p.add_option("-p", "--password", action="store")
|
||||||
p.add_option("-P", action="store_true", dest="getpass", default=False,
|
p.add_option("-P", action="store_true", dest="getpass", default=False,
|
||||||
@@ -276,22 +278,24 @@ class PackageOp(Command):
|
|||||||
super(PackageOp, self).__init__()
|
super(PackageOp, self).__init__()
|
||||||
|
|
||||||
def options(self):
|
def options(self):
|
||||||
self.parser.add_option("", "--ignore-comar", action="store_true",
|
pass
|
||||||
default=False, help="bypass comar configuration agent")
|
|
||||||
## self.parser.add_option("", "--ignore-dependency",
|
## self.parser.add_option("", "--ignore-dependency",
|
||||||
## action="store_true",
|
## action="store_true",
|
||||||
## default=False, help="death")
|
## default=False, help="death")
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
super(PackageOp, self).init(True)
|
super(PackageOp, self).init(True)
|
||||||
import pisi
|
pass
|
||||||
if not self.options.ignore_comar:
|
# ctx.comard should be initialized in pisi.api for other interfaces to
|
||||||
import comar
|
# use it!
|
||||||
try:
|
# import pisi
|
||||||
ctx.comard = comar.Link() # context
|
# if not self.options.ignore_comar:
|
||||||
except comar.Error:
|
# import comar
|
||||||
ctx.ui.error('Comar error encountered\n')
|
# try:
|
||||||
self.die()
|
# ctx.comard = comar.Link() # context
|
||||||
|
# except comar.Error:
|
||||||
|
# ctx.ui.error('Comar error encountered\n')
|
||||||
|
# self.die()
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
#self.finalize_db()
|
#self.finalize_db()
|
||||||
|
|||||||
+14
-7
@@ -52,7 +52,8 @@ class Installer:
|
|||||||
self.reinstall()
|
self.reinstall()
|
||||||
self.extract_install()
|
self.extract_install()
|
||||||
self.store_pisi_files()
|
self.store_pisi_files()
|
||||||
self.register_comar_scripts()
|
if ctx.comard:
|
||||||
|
self.register_comar_scripts()
|
||||||
self.update_databases()
|
self.update_databases()
|
||||||
|
|
||||||
def check_requirements(self):
|
def check_requirements(self):
|
||||||
@@ -157,15 +158,21 @@ class Installer:
|
|||||||
def register_comar_scripts(self):
|
def register_comar_scripts(self):
|
||||||
"register COMAR scripts"
|
"register COMAR scripts"
|
||||||
|
|
||||||
|
com = ctx.comard
|
||||||
|
|
||||||
for pcomar in self.metadata.package.providesComar:
|
for pcomar in self.metadata.package.providesComar:
|
||||||
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
|
scriptPath = os.path.join(self.package.comar_dir(),pcomar.script)
|
||||||
ctx.ui.info("Registering COMAR script %s" % pcomar.script)
|
ctx.ui.info("Registering COMAR script %s" % pcomar.script)
|
||||||
# FIXME: We must check the result of the command (possibly
|
|
||||||
# with id?)
|
com.register(pcomar.om,
|
||||||
if comard:
|
self.metadata.package.name,
|
||||||
comard.register(pcomar.om,
|
scriptPath)
|
||||||
self.metadata.package.name,
|
while 1:
|
||||||
scriptPath)
|
reply = com.read_cmd()
|
||||||
|
if reply[0] == com.RESULT:
|
||||||
|
break
|
||||||
|
elif reply[1] == com.ERROR:
|
||||||
|
raise InstallError, "COMAR.register failed!"
|
||||||
|
|
||||||
|
|
||||||
def update_databases(self):
|
def update_databases(self):
|
||||||
|
|||||||
+12
-2
@@ -32,8 +32,18 @@ def remove_single(package_name):
|
|||||||
raise Exception('Trying to remove nonexistent package '
|
raise Exception('Trying to remove nonexistent package '
|
||||||
+ package_name)
|
+ package_name)
|
||||||
if ctx.comard:
|
if ctx.comard:
|
||||||
ctx.comard.remove(package_name)
|
com = ctx.comard
|
||||||
ctx.comard.call("System.Package", "preremove")
|
|
||||||
|
# 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:
|
for fileinfo in ctx.installdb.files(package_name).list:
|
||||||
fpath = os.path.join(ctx.config.destdir, fileinfo.path)
|
fpath = os.path.join(ctx.config.destdir, fileinfo.path)
|
||||||
# TODO: We have to store configuration files for futher
|
# TODO: We have to store configuration files for futher
|
||||||
|
|||||||
Reference in New Issue
Block a user