* 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
|
import pisi.config
|
||||||
ctx.config = pisi.config.Config(options)
|
ctx.config = pisi.config.Config(options)
|
||||||
|
|
||||||
if comar and not ctx.config.get_option('ignore_comar'):
|
# TODO: this is definitely not dynamic beyond this point!
|
||||||
# FIXME: just try for others (that don't use comar)
|
ctx.comar = comar and not ctx.config.get_option('ignore_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"))
|
|
||||||
|
|
||||||
if ui is None:
|
if ui is None:
|
||||||
if options:
|
if options:
|
||||||
|
|||||||
+29
-4
@@ -24,10 +24,35 @@ import pisi.context as ctx
|
|||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
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):
|
def run_postinstall(package_name):
|
||||||
"run postinstall scripts trough COMAR"
|
"run postinstall scripts trough COMAR"
|
||||||
|
|
||||||
com = ctx.comard
|
com = make_com()
|
||||||
assert(com)
|
assert(com)
|
||||||
ctx.ui.info(_("Running post-install script for %s") % package_name)
|
ctx.ui.info(_("Running post-install script for %s") % package_name)
|
||||||
com.call_package("System.Package.postInstall", 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]
|
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
||||||
|
|
||||||
def run_preremove(package_name):
|
def run_preremove(package_name):
|
||||||
com = ctx.comard
|
|
||||||
|
com = make_com()
|
||||||
assert(com)
|
assert(com)
|
||||||
|
|
||||||
# First, call preRemove script!
|
# First, call preRemove script!
|
||||||
@@ -64,7 +90,7 @@ def run_preremove(package_name):
|
|||||||
else:
|
else:
|
||||||
raise Error, _("COMAR.call_package ERROR: %d") % reply[0]
|
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)
|
ctx.ui.info(_("Unregistering COMAR scripts for %s") % package_name)
|
||||||
com.remove(package_name)
|
com.remove(package_name)
|
||||||
while 1:
|
while 1:
|
||||||
@@ -73,4 +99,3 @@ def run_preremove(package_name):
|
|||||||
break
|
break
|
||||||
elif reply[1] == com.ERROR:
|
elif reply[1] == com.ERROR:
|
||||||
raise Error, "COMAR.remove failed!"
|
raise Error, "COMAR.remove failed!"
|
||||||
|
|
||||||
|
|||||||
+4
-13
@@ -63,7 +63,7 @@ class Installer:
|
|||||||
self.check_reinstall()
|
self.check_reinstall()
|
||||||
self.extract_install()
|
self.extract_install()
|
||||||
self.store_pisi_files()
|
self.store_pisi_files()
|
||||||
if ctx.comard:
|
if ctx.comar:
|
||||||
self.register_comar_scripts()
|
self.register_comar_scripts()
|
||||||
import pisi.comariface as comariface
|
import pisi.comariface as comariface
|
||||||
comariface.run_postinstall(self.pkginfo.name)
|
comariface.run_postinstall(self.pkginfo.name)
|
||||||
@@ -190,18 +190,9 @@ class Installer:
|
|||||||
|
|
||||||
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)
|
import pisi.comariface
|
||||||
|
pisi.comariface.register(pcomar, self.metadata.package.name,
|
||||||
com.register(pcomar.om,
|
scriptPath)
|
||||||
self.metadata.package.name,
|
|
||||||
scriptPath)
|
|
||||||
while 1:
|
|
||||||
reply = com.read_cmd()
|
|
||||||
if reply[0] == com.RESULT:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
raise Error, _("COMAR.register ERROR!")
|
|
||||||
|
|
||||||
|
|
||||||
def update_databases(self):
|
def update_databases(self):
|
||||||
"update databases"
|
"update databases"
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ def join_path(a, *p):
|
|||||||
"""The python original version has a silly logic"""
|
"""The python original version has a silly logic"""
|
||||||
path = a
|
path = a
|
||||||
for b in p:
|
for b in p:
|
||||||
|
b = b.lstrip('/')
|
||||||
if path == '' or path.endswith('/'):
|
if path == '' or path.endswith('/'):
|
||||||
path += b
|
path += b
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user