* fix: make join_path smarter (now it's really better than os.path.xx)
* fix: #507 call comar dynamically. wow.
This commit is contained in:
+2
-10
@@ -46,16 +46,8 @@ def init(database = True, options = None, ui = None, comar = True):
|
||||
import pisi.config
|
||||
ctx.config = pisi.config.Config(options)
|
||||
|
||||
if comar and not ctx.config.get_option('ignore_comar'):
|
||||
# FIXME: just try for others (that don't use comar)
|
||||
try:
|
||||
import comar
|
||||
ctx.comard = comar.Link()
|
||||
except ImportError:
|
||||
raise Error(_("COMAR: comard not fully installed"))
|
||||
#print _("skipping COMAR connection for now...")
|
||||
except comar.Error:
|
||||
raise Error(_("COMAR: comard not running or defunct"))
|
||||
# TODO: this is definitely not dynamic beyond this point!
|
||||
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
|
||||
|
||||
if ui is None:
|
||||
if options:
|
||||
|
||||
+29
-4
@@ -24,10 +24,35 @@ import pisi.context as ctx
|
||||
class Error(pisi.Error):
|
||||
pass
|
||||
|
||||
def make_com():
|
||||
# FIXME: just try for others (that don't use comar)
|
||||
try:
|
||||
import comar
|
||||
comard = comar.Link()
|
||||
return comard
|
||||
except ImportError:
|
||||
raise Error(_("COMAR: comard not fully installed"))
|
||||
except comar.Error:
|
||||
raise Error(_("COMAR: comard not running or defunct"))
|
||||
|
||||
def register(pcomar, name, path):
|
||||
ctx.ui.info(_("Registering COMAR script %s") % pcomar.script)
|
||||
com = make_com()
|
||||
assert(com)
|
||||
com.register(pcomar.om, name, path)
|
||||
|
||||
while 1:
|
||||
reply = com.read_cmd()
|
||||
if reply[0] == com.RESULT:
|
||||
break
|
||||
else:
|
||||
raise Error, _("COMAR.register ERROR!")
|
||||
|
||||
|
||||
def run_postinstall(package_name):
|
||||
"run postinstall scripts trough COMAR"
|
||||
|
||||
com = ctx.comard
|
||||
com = make_com()
|
||||
assert(com)
|
||||
ctx.ui.info(_("Running post-install script for %s") % package_name)
|
||||
com.call_package("System.Package.postInstall", package_name)
|
||||
@@ -45,7 +70,8 @@ def run_postinstall(package_name):
|
||||
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
||||
|
||||
def run_preremove(package_name):
|
||||
com = ctx.comard
|
||||
|
||||
com = make_com()
|
||||
assert(com)
|
||||
|
||||
# First, call preRemove script!
|
||||
@@ -64,7 +90,7 @@ def run_preremove(package_name):
|
||||
else:
|
||||
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
||||
|
||||
# and than, remove package's Comar Scripts...
|
||||
# and then, remove package's Comar Scripts...
|
||||
ctx.ui.info(_("Unregistering COMAR scripts for %s") % package_name)
|
||||
com.remove(package_name)
|
||||
while 1:
|
||||
@@ -73,4 +99,3 @@ def run_preremove(package_name):
|
||||
break
|
||||
elif reply[1] == com.ERROR:
|
||||
raise Error, "COMAR.remove failed!"
|
||||
|
||||
|
||||
+4
-13
@@ -63,7 +63,7 @@ class Installer:
|
||||
self.check_reinstall()
|
||||
self.extract_install()
|
||||
self.store_pisi_files()
|
||||
if ctx.comard:
|
||||
if ctx.comar:
|
||||
self.register_comar_scripts()
|
||||
import pisi.comariface as comariface
|
||||
comariface.run_postinstall(self.pkginfo.name)
|
||||
@@ -190,18 +190,9 @@ class Installer:
|
||||
|
||||
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)
|
||||
|
||||
com.register(pcomar.om,
|
||||
self.metadata.package.name,
|
||||
scriptPath)
|
||||
while 1:
|
||||
reply = com.read_cmd()
|
||||
if reply[0] == com.RESULT:
|
||||
break
|
||||
else:
|
||||
raise Error, _("COMAR.register ERROR!")
|
||||
|
||||
import pisi.comariface
|
||||
pisi.comariface.register(pcomar, self.metadata.package.name,
|
||||
scriptPath)
|
||||
|
||||
def update_databases(self):
|
||||
"update databases"
|
||||
|
||||
@@ -196,6 +196,7 @@ def join_path(a, *p):
|
||||
"""The python original version has a silly logic"""
|
||||
path = a
|
||||
for b in p:
|
||||
b = b.lstrip('/')
|
||||
if path == '' or path.endswith('/'):
|
||||
path += b
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user