fazlalık fonksiyonu attım, biraz temizlik ve açıklamalar
This commit is contained in:
+1
-1
@@ -95,7 +95,7 @@ def init(database = True, write = True,
|
|||||||
|
|
||||||
# TODO: this is definitely not dynamic beyond this point!
|
# TODO: this is definitely not dynamic beyond this point!
|
||||||
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
|
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
|
||||||
# This is for YALI, used in comariface.py:make_com()
|
# This is for YALI, used in comariface.py
|
||||||
ctx.comar_sockname = comar_sockname
|
ctx.comar_sockname = comar_sockname
|
||||||
|
|
||||||
# initialize repository databases
|
# initialize repository databases
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class Install(AtomicOperation):
|
|||||||
# check comar
|
# check comar
|
||||||
if self.metadata.package.providesComar and ctx.comar:
|
if self.metadata.package.providesComar and ctx.comar:
|
||||||
import pisi.comariface as comariface
|
import pisi.comariface as comariface
|
||||||
com = comariface.make_com()
|
com = comariface.get_comar()
|
||||||
|
|
||||||
def check_relations(self):
|
def check_relations(self):
|
||||||
# check dependencies
|
# check dependencies
|
||||||
|
|||||||
+21
-27
@@ -29,12 +29,19 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
raise Error(_("comar package is not fully installed"))
|
raise Error(_("comar package is not fully installed"))
|
||||||
|
|
||||||
def make_com():
|
def get_comar():
|
||||||
|
"""Connect to the comar daemon and return the handle"""
|
||||||
|
|
||||||
sockname = "/var/run/comar.socket"
|
sockname = "/var/run/comar.socket"
|
||||||
# This is used by YALI
|
# YALI starts comar chrooted in the install target, but uses PiSi outside of
|
||||||
|
# the chroot environment, so PiSi needs to use a different socket path to be
|
||||||
|
# able to connect true comar (usually /mnt/target/var/run/comar.socket).
|
||||||
if ctx.comar_sockname:
|
if ctx.comar_sockname:
|
||||||
sockname = ctx.comar_sockname
|
sockname = ctx.comar_sockname
|
||||||
|
|
||||||
|
# This function is sometimes called when comar has recently started
|
||||||
|
# or restarting after an update. So we give comar a chance to become
|
||||||
|
# active in a reasonable time.
|
||||||
timeout = 7
|
timeout = 7
|
||||||
while timeout > 0:
|
while timeout > 0:
|
||||||
try:
|
try:
|
||||||
@@ -46,26 +53,9 @@ def make_com():
|
|||||||
timeout -= 0.2
|
timeout -= 0.2
|
||||||
raise Error(_("cannot connect to comar"))
|
raise Error(_("cannot connect to comar"))
|
||||||
|
|
||||||
def wait_comar():
|
|
||||||
# FIXME: this function is redundant, use make_com in wait_for_result
|
|
||||||
import socket
|
|
||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
||||||
timeout = 5
|
|
||||||
sockname = "/var/run/comar.socket"
|
|
||||||
if ctx.comar_sockname:
|
|
||||||
sockname = ctx.comar_sockname
|
|
||||||
while timeout > 0:
|
|
||||||
try:
|
|
||||||
sock.connect(sockname)
|
|
||||||
return True
|
|
||||||
except socket.error:
|
|
||||||
timeout -= 0.2
|
|
||||||
time.sleep(0.2)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def wait_for_result(com, package_name=None):
|
def wait_for_result(com, package_name=None):
|
||||||
multiple = False
|
multiple = False
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
reply = com.read_cmd()
|
reply = com.read_cmd()
|
||||||
except select.error:
|
except select.error:
|
||||||
@@ -76,7 +66,9 @@ def wait_for_result(com, package_name=None):
|
|||||||
# Comar postInstall does a "service comar restart" which cuts
|
# Comar postInstall does a "service comar restart" which cuts
|
||||||
# our precious communication link, so we waitsss
|
# our precious communication link, so we waitsss
|
||||||
if package_name == "comar":
|
if package_name == "comar":
|
||||||
if not wait_comar():
|
try:
|
||||||
|
get_comar()
|
||||||
|
except Error:
|
||||||
raise Error, _("Could not restart comar")
|
raise Error, _("Could not restart comar")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -95,18 +87,18 @@ def wait_for_result(com, package_name=None):
|
|||||||
elif cmd == com.RESULT_END:
|
elif cmd == com.RESULT_END:
|
||||||
return
|
return
|
||||||
elif cmd == com.FAIL:
|
elif cmd == com.FAIL:
|
||||||
e = _("Configuration error: %s") % reply[2]
|
raise Error, _("Configuration error: %s") % reply[2]
|
||||||
raise Error, e
|
|
||||||
elif cmd == com.ERROR:
|
elif cmd == com.ERROR:
|
||||||
e = _("Script error: %s") % reply[2]
|
raise Error, _("Script error: %s") % reply[2]
|
||||||
raise Error, e
|
|
||||||
elif cmd == com.DENIED:
|
elif cmd == com.DENIED:
|
||||||
raise Error, _("comar denied our access")
|
raise Error, _("comar denied our access")
|
||||||
|
|
||||||
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath):
|
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath):
|
||||||
|
"""Do package's post install operations"""
|
||||||
|
|
||||||
ctx.ui.info(_("Configuring %s package") % package_name)
|
ctx.ui.info(_("Configuring %s package") % package_name)
|
||||||
self_post = False
|
self_post = False
|
||||||
com = make_com()
|
com = get_comar()
|
||||||
|
|
||||||
for script in provided_scripts:
|
for script in provided_scripts:
|
||||||
ctx.ui.debug(_("Registering %s comar script") % script.om)
|
ctx.ui.debug(_("Registering %s comar script") % script.om)
|
||||||
@@ -125,8 +117,10 @@ def post_install(package_name, provided_scripts, scriptpath, metapath, filepath)
|
|||||||
wait_for_result(com, package_name)
|
wait_for_result(com, package_name)
|
||||||
|
|
||||||
def pre_remove(package_name, metapath, filepath):
|
def pre_remove(package_name, metapath, filepath):
|
||||||
|
"""Do package's pre removal operations"""
|
||||||
|
|
||||||
ctx.ui.info(_("Configuring %s package for removal") % package_name)
|
ctx.ui.info(_("Configuring %s package for removal") % package_name)
|
||||||
com = make_com()
|
com = get_comar()
|
||||||
|
|
||||||
ctx.ui.debug(_("Running package's pre remove script"))
|
ctx.ui.debug(_("Running package's pre remove script"))
|
||||||
com.call_package("System.Package.preRemove", package_name)
|
com.call_package("System.Package.preRemove", package_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user