Merge from pisi-devel... trunk is for 2008 development.
This commit is contained in:
@@ -1,289 +0,0 @@
|
|||||||
Index: pisi/comariface.py
|
|
||||||
===================================================================
|
|
||||||
--- pisi/comariface.py (revision 17555)
|
|
||||||
+++ pisi/comariface.py (working copy)
|
|
||||||
@@ -13,6 +13,7 @@
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import select
|
|
||||||
+import string
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
|
||||||
@@ -25,117 +26,147 @@
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
- import comar
|
|
||||||
+ import dbus
|
|
||||||
except ImportError:
|
|
||||||
- raise Error(_("comar package is not fully installed"))
|
|
||||||
+ raise Error(_("dbus-python package is not fully installed"))
|
|
||||||
|
|
||||||
-def get_comar():
|
|
||||||
- """Connect to the comar daemon and return the handle"""
|
|
||||||
+def is_char_valid(char):
|
|
||||||
+ """Test if char is valid object path character."""
|
|
||||||
+ return char in string.ascii_letters + string.digits + "_"
|
|
||||||
+
|
|
||||||
+def make_object_path(package):
|
|
||||||
+ """Generates DBus object name from package name."""
|
|
||||||
+ object = package
|
|
||||||
+ for char in package:
|
|
||||||
+ if not is_char_valid(char):
|
|
||||||
+ object = object.replace(char, '_')
|
|
||||||
+ if object[0].isdigit():
|
|
||||||
+ object = '_%s' % object
|
|
||||||
+ return object
|
|
||||||
+
|
|
||||||
+def get_iface(package="", model=""):
|
|
||||||
+ """Connect to the DBus daemon and return the system interface."""
|
|
||||||
|
|
||||||
- sockname = "/var/run/comar.socket"
|
|
||||||
+ sockname = "unix:path=/var/run/dbus/system_bus_socket"
|
|
||||||
# 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:
|
|
||||||
- sockname = ctx.comar_sockname
|
|
||||||
+ # able to connect true dbus (and comar).
|
|
||||||
+ # (usually unix:path=/var/run/dbus/system_bus_socket)
|
|
||||||
+ if ctx.dbus_sockname:
|
|
||||||
+ sockname = ctx.dbus_sockname
|
|
||||||
|
|
||||||
+ if package:
|
|
||||||
+ obj_path = "/package/%s" % package
|
|
||||||
+ else:
|
|
||||||
+ obj_path = "/"
|
|
||||||
+ if model:
|
|
||||||
+ obj_interface = "tr.org.pardus.comar.%s" % model
|
|
||||||
+ else:
|
|
||||||
+ obj_interface = "tr.org.pardus.comar"
|
|
||||||
+
|
|
||||||
# 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
|
|
||||||
while timeout > 0:
|
|
||||||
try:
|
|
||||||
- com = comar.Link(sockname)
|
|
||||||
- return com
|
|
||||||
- except comar.CannotConnect:
|
|
||||||
+ bus = dbus.bus.BusConnection(address_or_type=sockname)
|
|
||||||
+ obj = bus.get_object(ctx.comar_destination, obj_path, introspect=False)
|
|
||||||
+ iface = dbus.Interface(obj, dbus_interface=obj_interface)
|
|
||||||
+ return iface
|
|
||||||
+ except dbus.DBusException:
|
|
||||||
pass
|
|
||||||
time.sleep(0.2)
|
|
||||||
timeout -= 0.2
|
|
||||||
- raise Error(_("cannot connect to comar"))
|
|
||||||
+ raise Error(_("cannot connect to dbus"))
|
|
||||||
|
|
||||||
-def wait_for_result(com, package_name=None):
|
|
||||||
- multiple = False
|
|
||||||
- while True:
|
|
||||||
- try:
|
|
||||||
- reply = com.read_cmd()
|
|
||||||
- except select.error:
|
|
||||||
- if ctx.keyboard_interrupt_pending():
|
|
||||||
- return
|
|
||||||
- raise
|
|
||||||
- except comar.LinkClosed:
|
|
||||||
- # Comar postInstall does a "service comar restart" which cuts
|
|
||||||
- # our precious communication link, so we waitsss
|
|
||||||
- if package_name == "comar":
|
|
||||||
- try:
|
|
||||||
- get_comar()
|
|
||||||
- except Error:
|
|
||||||
- raise Error, _("Could not restart comar")
|
|
||||||
- return
|
|
||||||
- else:
|
|
||||||
- if ctx.keyboard_interrupt_pending():
|
|
||||||
- return
|
|
||||||
- raise Error, _("connection with comar unexpectedly closed")
|
|
||||||
-
|
|
||||||
- cmd = reply[0]
|
|
||||||
- if cmd == com.RESULT and not multiple:
|
|
||||||
- return
|
|
||||||
- elif cmd == com.NONE and not multiple:
|
|
||||||
- # no post/pre function, that is ok
|
|
||||||
- return
|
|
||||||
- elif cmd == com.RESULT_START:
|
|
||||||
- multiple = True
|
|
||||||
- elif cmd == com.RESULT_END:
|
|
||||||
- return
|
|
||||||
- elif cmd == com.FAIL:
|
|
||||||
- raise Error, _("Configuration error: %s") % reply[2]
|
|
||||||
- elif cmd == com.ERROR:
|
|
||||||
- raise Error, _("Script error: %s") % reply[2]
|
|
||||||
- elif cmd == com.DENIED:
|
|
||||||
- raise Error, _("comar denied our access")
|
|
||||||
-
|
|
||||||
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath, fromVersion, fromRelease, toVersion, toRelease):
|
|
||||||
"""Do package's post install operations"""
|
|
||||||
|
|
||||||
ctx.ui.info(_("Configuring %s package") % package_name)
|
|
||||||
self_post = False
|
|
||||||
- com = get_comar()
|
|
||||||
+ sys_service = False
|
|
||||||
+ sys_iface = get_iface()
|
|
||||||
+ object_name = make_object_path(package_name)
|
|
||||||
|
|
||||||
for script in provided_scripts:
|
|
||||||
ctx.ui.debug(_("Registering %s comar script") % script.om)
|
|
||||||
if script.om == "System.Package":
|
|
||||||
self_post = True
|
|
||||||
- com.register(script.om, package_name, os.path.join(scriptpath, script.script))
|
|
||||||
- wait_for_result(com)
|
|
||||||
+ elif script.om == "System.Service":
|
|
||||||
+ sys_service = True
|
|
||||||
+ try:
|
|
||||||
+ sys_iface.register(object_name, script.om, os.path.join(scriptpath, script.script))
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
+ if sys_service:
|
|
||||||
+ try:
|
|
||||||
+ iface = get_iface(object_name, "System.Service")
|
|
||||||
+ iface.registerState()
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
|
|
||||||
ctx.ui.debug(_("Calling post install handlers"))
|
|
||||||
- com.call("System.PackageHandler.setupPackage", [ "metapath", metapath, "filepath", filepath ])
|
|
||||||
- wait_for_result(com)
|
|
||||||
+ for handler in sys_iface.listModelApplications("System.PackageHandler"):
|
|
||||||
+ iface = get_iface(handler, "System.PackageHandler")
|
|
||||||
+ try:
|
|
||||||
+ iface.setupPackage(metapath, filepath, timeout=300)
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ # Do nothing if setupPackage method is not defined in package script
|
|
||||||
+ if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
|
||||||
+ exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
|
|
||||||
if self_post:
|
|
||||||
- args = {
|
|
||||||
- "fromVersion": fromVersion,
|
|
||||||
- "fromRelease": fromRelease,
|
|
||||||
- "toVersion": toVersion,
|
|
||||||
- "toRelease": toRelease,
|
|
||||||
- }
|
|
||||||
+ if not fromVersion:
|
|
||||||
+ fromVersion = ""
|
|
||||||
+ if not fromRelease:
|
|
||||||
+ fromRelease = ""
|
|
||||||
+
|
|
||||||
ctx.ui.debug(_("Running package's post install script"))
|
|
||||||
- com.call_package("System.Package.postInstall", package_name, args)
|
|
||||||
- wait_for_result(com, package_name)
|
|
||||||
+ try:
|
|
||||||
+ iface = get_iface(object_name, "System.Package")
|
|
||||||
+ iface.postInstall(fromVersion, fromRelease, toVersion, toRelease, timeout=300)
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ # Do nothing if postInstall method is not defined in package script
|
|
||||||
+ if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
|
||||||
+ exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
+
|
|
||||||
+ if package_name == 'comar':
|
|
||||||
+ pisi.api.set_comar_destination('tr.org.pardus.comar.new')
|
|
||||||
|
|
||||||
def pre_remove(package_name, metapath, filepath):
|
|
||||||
"""Do package's pre removal operations"""
|
|
||||||
|
|
||||||
ctx.ui.info(_("Configuring %s package for removal") % package_name)
|
|
||||||
- com = get_comar()
|
|
||||||
+ sys_iface = get_iface()
|
|
||||||
+ object_name = make_object_path(package_name)
|
|
||||||
|
|
||||||
- ctx.ui.debug(_("Running package's pre remove script"))
|
|
||||||
- com.call_package("System.Package.preRemove", package_name)
|
|
||||||
- wait_for_result(com)
|
|
||||||
+ if "System.Package" in sys_iface.listApplicationModels(object_name):
|
|
||||||
+ ctx.ui.debug(_("Running package's pre remove script"))
|
|
||||||
+ iface = get_iface(object_name, "System.Package")
|
|
||||||
+ try:
|
|
||||||
+ iface.preRemove(timeout=300)
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ # Do nothing if preRemove method is not defined in package script
|
|
||||||
+ if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
|
||||||
+ exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
|
|
||||||
ctx.ui.debug(_("Calling pre remove handlers"))
|
|
||||||
- com.call("System.PackageHandler.cleanupPackage", [ "metapath", metapath, "filepath", filepath ])
|
|
||||||
- wait_for_result(com)
|
|
||||||
+ for handler in sys_iface.listModelApplications("System.PackageHandler"):
|
|
||||||
+ iface = get_iface(handler, "System.PackageHandler")
|
|
||||||
+ try:
|
|
||||||
+ iface.cleanupPackage(metapath, filepath, timeout=300)
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ # Do nothing if cleanupPackage method is not defined in package script
|
|
||||||
+ if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
|
||||||
+ exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
|
|
||||||
ctx.ui.debug(_("Unregistering comar scripts"))
|
|
||||||
- com.remove(package_name)
|
|
||||||
- wait_for_result(com)
|
|
||||||
+ try:
|
|
||||||
+ sys_iface.remove(object_name)
|
|
||||||
+ except dbus.DBusException, exception:
|
|
||||||
+ raise Error, _("Script error: %s") % exception
|
|
||||||
Index: pisi/api.py
|
|
||||||
===================================================================
|
|
||||||
--- pisi/api.py (revision 17555)
|
|
||||||
+++ pisi/api.py (working copy)
|
|
||||||
@@ -73,13 +73,20 @@
|
|
||||||
"""
|
|
||||||
ctx.comar = enable
|
|
||||||
|
|
||||||
-def set_comar_sockname(sockname):
|
|
||||||
+def set_comar_destination(destination):
|
|
||||||
"""
|
|
||||||
- Set comar socket file
|
|
||||||
+ Set comar bus destination
|
|
||||||
+ @param destination: Path to bus destination of COMAR
|
|
||||||
+ """
|
|
||||||
+ ctx.comar_destination = destination
|
|
||||||
+
|
|
||||||
+def set_dbus_sockname(sockname):
|
|
||||||
+ """
|
|
||||||
+ Set dbus socket file
|
|
||||||
Used by YALI
|
|
||||||
- @param sockname: Path to comar socket file
|
|
||||||
+ @param sockname: Path to dbus socket file
|
|
||||||
"""
|
|
||||||
- ctx.comar_sockname = sockname
|
|
||||||
+ ctx.dbus_sockname = sockname
|
|
||||||
|
|
||||||
def set_signal_handling(enable):
|
|
||||||
"""
|
|
||||||
Index: pisi/atomicoperations.py
|
|
||||||
===================================================================
|
|
||||||
--- pisi/atomicoperations.py (revision 17555)
|
|
||||||
+++ pisi/atomicoperations.py (working copy)
|
|
||||||
@@ -152,7 +152,7 @@
|
|
||||||
# check comar
|
|
||||||
if self.metadata.package.providesComar and ctx.comar:
|
|
||||||
import pisi.comariface as comariface
|
|
||||||
- comariface.get_comar()
|
|
||||||
+ comariface.get_iface()
|
|
||||||
|
|
||||||
def check_relations(self):
|
|
||||||
# check dependencies
|
|
||||||
Index: pisi/context.py
|
|
||||||
===================================================================
|
|
||||||
--- pisi/context.py (revision 17555)
|
|
||||||
+++ pisi/context.py (working copy)
|
|
||||||
@@ -38,7 +38,8 @@
|
|
||||||
stderr = None
|
|
||||||
|
|
||||||
comar = True
|
|
||||||
-comar_sockname = None
|
|
||||||
+comar_destination = "tr.org.pardus.comar"
|
|
||||||
+dbus_sockname = None
|
|
||||||
|
|
||||||
# Bug #2879
|
|
||||||
# FIXME: Maybe we can create a simple rollback mechanism. There are other
|
|
||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/python2.5
|
|
||||||
#
|
|
||||||
# Copyright (C) 2005 - 2007, TUBITAK/UEKAE
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
|
||||||
# the terms of the GNU General Public License as published by the Free
|
|
||||||
# Software Foundation; either version 2 of the License, or (at your option)
|
|
||||||
# any later version.
|
|
||||||
#
|
|
||||||
# Please read the COPYING file.
|
|
||||||
#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import locale
|
|
||||||
import traceback
|
|
||||||
import exceptions
|
|
||||||
import signal
|
|
||||||
|
|
||||||
import pisi.ui
|
|
||||||
import pisi.context as ctx
|
|
||||||
import pisi.cli.pisicli as pisicli
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
|
||||||
_ = __trans.ugettext
|
|
||||||
|
|
||||||
def exit():
|
|
||||||
pisi.api.finalize()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def handle_exception(exception, value, tb):
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
|
|
||||||
ui = pisi.cli.CLI() # make a temporary UI
|
|
||||||
show_traceback = False
|
|
||||||
if exception == exceptions.KeyboardInterrupt:
|
|
||||||
ui.error(_("Keyboard Interrupt: Exiting..."))
|
|
||||||
exit()
|
|
||||||
elif isinstance(value, pisi.Error):
|
|
||||||
ui.error(_("Program Terminated."))
|
|
||||||
show_traceback = ctx.get_option('debug')
|
|
||||||
elif isinstance(value, pisi.Exception):
|
|
||||||
show_traceback = True
|
|
||||||
ui.error(_("""Unhandled internal exception.
|
|
||||||
Please file a bug report. (http://bugs.uludag.org.tr)"""))
|
|
||||||
else:
|
|
||||||
# For any other exception (possibly Python exceptions) show
|
|
||||||
# the traceback!
|
|
||||||
show_traceback = ctx.get_option('debug')
|
|
||||||
ui.error(_("System Error. Program Terminated."))
|
|
||||||
|
|
||||||
if ctx.get_option('debug'):
|
|
||||||
ui.error(u"%s: %s" % (exception, value))
|
|
||||||
else:
|
|
||||||
ui.error(unicode(value))
|
|
||||||
|
|
||||||
ui.info(_("Please use 'pisi help' for general help."))
|
|
||||||
|
|
||||||
if show_traceback:
|
|
||||||
ui.info(_("Traceback:"))
|
|
||||||
traceback.print_tb(tb)
|
|
||||||
else:
|
|
||||||
if not exception is pisicli.Error:
|
|
||||||
ui.info(_("Use --debug to see a traceback."))
|
|
||||||
|
|
||||||
exit()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
sys.excepthook = handle_exception
|
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
|
||||||
cli = pisicli.PisiCLI()
|
|
||||||
cli.run_command()
|
|
||||||
@@ -26,6 +26,7 @@ from pisi.actionsapi.shelltools import system
|
|||||||
from pisi.actionsapi.shelltools import can_access_file
|
from pisi.actionsapi.shelltools import can_access_file
|
||||||
from pisi.actionsapi.shelltools import unlink
|
from pisi.actionsapi.shelltools import unlink
|
||||||
from pisi.actionsapi.libtools import gnuconfig_update
|
from pisi.actionsapi.libtools import gnuconfig_update
|
||||||
|
from pisi.actionsapi.libtools import libtoolize
|
||||||
|
|
||||||
class ConfigureError(pisi.actionsapi.Error):
|
class ConfigureError(pisi.actionsapi.Error):
|
||||||
def __init__(self, value=''):
|
def __init__(self, value=''):
|
||||||
@@ -55,6 +56,7 @@ class RunTimeError(pisi.actionsapi.Error):
|
|||||||
|
|
||||||
def configure(parameters = ''):
|
def configure(parameters = ''):
|
||||||
'''configure source with given parameters = "--with-nls --with-libusb --with-something-usefull"'''
|
'''configure source with given parameters = "--with-nls --with-libusb --with-something-usefull"'''
|
||||||
|
|
||||||
if can_access_file('configure'):
|
if can_access_file('configure'):
|
||||||
gnuconfig_update()
|
gnuconfig_update()
|
||||||
|
|
||||||
|
|||||||
+19
-4
@@ -73,13 +73,28 @@ def set_comar(enable):
|
|||||||
"""
|
"""
|
||||||
ctx.comar = enable
|
ctx.comar = enable
|
||||||
|
|
||||||
def set_comar_sockname(sockname):
|
def set_comar_destination(destination):
|
||||||
"""
|
"""
|
||||||
Set comar socket file
|
Set comar bus destination
|
||||||
|
@param destination: Path to bus destination of COMAR
|
||||||
|
"""
|
||||||
|
ctx.comar_destination = destination
|
||||||
|
|
||||||
|
def set_dbus_sockname(sockname):
|
||||||
|
"""
|
||||||
|
Set dbus socket file
|
||||||
Used by YALI
|
Used by YALI
|
||||||
@param sockname: Path to comar socket file
|
@param sockname: Path to dbus socket file
|
||||||
"""
|
"""
|
||||||
ctx.comar_sockname = sockname
|
ctx.dbus_sockname = sockname
|
||||||
|
|
||||||
|
def set_dbus_timeout(timeout):
|
||||||
|
"""
|
||||||
|
Set dbus timeout
|
||||||
|
Used by YALI
|
||||||
|
@param timeout: Timeout in seconds
|
||||||
|
"""
|
||||||
|
ctx.dbus_timeout = timeout
|
||||||
|
|
||||||
def set_signal_handling(enable):
|
def set_signal_handling(enable):
|
||||||
"""
|
"""
|
||||||
|
|||||||
+21
-5
@@ -19,6 +19,7 @@ import shutil
|
|||||||
import tarfile
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
import gzip
|
import gzip
|
||||||
|
import struct
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -114,8 +115,7 @@ class ArchiveTar(ArchiveBase):
|
|||||||
elif self.type == 'tarlzma':
|
elif self.type == 'tarlzma':
|
||||||
rmode = 'r:'
|
rmode = 'r:'
|
||||||
self.file_path = self.file_path.rstrip(ctx.const.lzma_suffix)
|
self.file_path = self.file_path.rstrip(ctx.const.lzma_suffix)
|
||||||
ret, out, err = util.run_batch("lzma d %s %s" % (self.file_path + ctx.const.lzma_suffix,
|
ret, out, err = util.run_batch("lzma -k -f -d %s%s" % (self.file_path,ctx.const.lzma_suffix))
|
||||||
self.file_path))
|
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
raise LzmaRuntimeError(err)
|
raise LzmaRuntimeError(err)
|
||||||
else:
|
else:
|
||||||
@@ -190,9 +190,9 @@ class ArchiveTar(ArchiveBase):
|
|||||||
if self.tar.mode == 'wb' and self.type == 'tarlzma':
|
if self.tar.mode == 'wb' and self.type == 'tarlzma':
|
||||||
batch = None
|
batch = None
|
||||||
if ctx.config.values.build.compressionlevel:
|
if ctx.config.values.build.compressionlevel:
|
||||||
batch = "lzmash -%s %s" % (ctx.config.values.build.compressionlevel, self.file_path)
|
batch = "lzma -%s -z %s" % (ctx.config.values.build.compressionlevel, self.file_path)
|
||||||
else:
|
else:
|
||||||
batch = "lzmash %s" % self.file_path
|
batch = "lzma -z %s" % self.file_path
|
||||||
|
|
||||||
ret, out, err = util.run_batch(batch)
|
ret, out, err = util.run_batch(batch)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
@@ -213,7 +213,23 @@ class MyZipFile(zipfile.ZipFile):
|
|||||||
"Attempt to read ZIP archive that was already closed"
|
"Attempt to read ZIP archive that was already closed"
|
||||||
zinfo = self.getinfo(name)
|
zinfo = self.getinfo(name)
|
||||||
filepos = self.fp.tell()
|
filepos = self.fp.tell()
|
||||||
self.fp.seek(zinfo.file_offset, 0)
|
|
||||||
|
self.fp.seek(zinfo.header_offset, 0)
|
||||||
|
|
||||||
|
# Skip the file header:
|
||||||
|
fheader = self.fp.read(30)
|
||||||
|
if fheader[0:4] != zipfile.stringFileHeader:
|
||||||
|
raise BadZipfile, "Bad magic number for file header"
|
||||||
|
|
||||||
|
fheader = struct.unpack(zipfile.structFileHeader, fheader)
|
||||||
|
fname = self.fp.read(fheader[zipfile._FH_FILENAME_LENGTH])
|
||||||
|
if fheader[zipfile._FH_EXTRA_FIELD_LENGTH]:
|
||||||
|
self.fp.read(fheader[zipfile._FH_EXTRA_FIELD_LENGTH])
|
||||||
|
|
||||||
|
if fname != zinfo.orig_filename:
|
||||||
|
raise zipfile.BadZipfile, \
|
||||||
|
'File name in directory "%s" and header "%s" differ.' % (
|
||||||
|
zinfo.orig_filename, fname)
|
||||||
|
|
||||||
destfile = file(outname, 'wb')
|
destfile = file(outname, 'wb')
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,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
|
||||||
comariface.get_comar()
|
comariface.get_iface()
|
||||||
|
|
||||||
def check_relations(self):
|
def check_relations(self):
|
||||||
# check dependencies
|
# check dependencies
|
||||||
|
|||||||
+103
-72
@@ -13,6 +13,7 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import select
|
import select
|
||||||
|
import string
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -25,19 +26,43 @@ class Error(pisi.Error):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import comar
|
import dbus
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise Error(_("comar package is not fully installed"))
|
raise Error(_("dbus-python package is not fully installed"))
|
||||||
|
|
||||||
def get_comar():
|
def is_char_valid(char):
|
||||||
"""Connect to the comar daemon and return the handle"""
|
"""Test if char is valid object path character."""
|
||||||
|
return char in string.ascii_letters + string.digits + "_"
|
||||||
|
|
||||||
sockname = "/var/run/comar.socket"
|
def make_object_path(package):
|
||||||
|
"""Generates DBus object name from package name."""
|
||||||
|
object = package
|
||||||
|
for char in package:
|
||||||
|
if not is_char_valid(char):
|
||||||
|
object = object.replace(char, '_')
|
||||||
|
if object[0].isdigit():
|
||||||
|
object = '_%s' % object
|
||||||
|
return object
|
||||||
|
|
||||||
|
def get_iface(package="", model=""):
|
||||||
|
"""Connect to the DBus daemon and return the system interface."""
|
||||||
|
|
||||||
|
sockname = "/var/run/dbus/system_bus_socket"
|
||||||
# YALI starts comar chrooted in the install target, but uses PiSi outside of
|
# 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
|
# 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).
|
# able to connect true dbus (and comar).
|
||||||
if ctx.comar_sockname:
|
# (usually /var/run/dbus/system_bus_socket)
|
||||||
sockname = ctx.comar_sockname
|
if ctx.dbus_sockname:
|
||||||
|
sockname = ctx.dbus_sockname
|
||||||
|
|
||||||
|
if package:
|
||||||
|
obj_path = "/package/%s" % package
|
||||||
|
else:
|
||||||
|
obj_path = "/"
|
||||||
|
if model:
|
||||||
|
obj_interface = "tr.org.pardus.comar.%s" % model
|
||||||
|
else:
|
||||||
|
obj_interface = "tr.org.pardus.comar"
|
||||||
|
|
||||||
# This function is sometimes called when comar has recently started
|
# This function is sometimes called when comar has recently started
|
||||||
# or restarting after an update. So we give comar a chance to become
|
# or restarting after an update. So we give comar a chance to become
|
||||||
@@ -45,97 +70,103 @@ def get_comar():
|
|||||||
timeout = 7
|
timeout = 7
|
||||||
while timeout > 0:
|
while timeout > 0:
|
||||||
try:
|
try:
|
||||||
com = comar.Link(sockname)
|
bus = dbus.bus.BusConnection(address_or_type="unix:path=%s" % sockname)
|
||||||
return com
|
obj = bus.get_object(ctx.comar_destination, obj_path, introspect=False)
|
||||||
except comar.CannotConnect:
|
iface = dbus.Interface(obj, dbus_interface=obj_interface)
|
||||||
|
return iface
|
||||||
|
except dbus.DBusException:
|
||||||
pass
|
pass
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
timeout -= 0.2
|
timeout -= 0.2
|
||||||
raise Error(_("cannot connect to comar"))
|
raise Error(_("cannot connect to dbus"))
|
||||||
|
|
||||||
def wait_for_result(com, package_name=None):
|
|
||||||
multiple = False
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
reply = com.read_cmd()
|
|
||||||
except select.error:
|
|
||||||
if ctx.keyboard_interrupt_pending():
|
|
||||||
return
|
|
||||||
raise
|
|
||||||
except comar.LinkClosed:
|
|
||||||
# Comar postInstall does a "service comar restart" which cuts
|
|
||||||
# our precious communication link, so we waitsss
|
|
||||||
if package_name == "comar":
|
|
||||||
try:
|
|
||||||
get_comar()
|
|
||||||
except Error:
|
|
||||||
raise Error, _("Could not restart comar")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if ctx.keyboard_interrupt_pending():
|
|
||||||
return
|
|
||||||
raise Error, _("connection with comar unexpectedly closed")
|
|
||||||
|
|
||||||
cmd = reply[0]
|
|
||||||
if cmd == com.RESULT and not multiple:
|
|
||||||
return
|
|
||||||
elif cmd == com.NONE and not multiple:
|
|
||||||
# no post/pre function, that is ok
|
|
||||||
return
|
|
||||||
elif cmd == com.RESULT_START:
|
|
||||||
multiple = True
|
|
||||||
elif cmd == com.RESULT_END:
|
|
||||||
return
|
|
||||||
elif cmd == com.FAIL:
|
|
||||||
raise Error, _("Configuration error: %s") % reply[2]
|
|
||||||
elif cmd == com.ERROR:
|
|
||||||
raise Error, _("Script error: %s") % reply[2]
|
|
||||||
elif cmd == com.DENIED:
|
|
||||||
raise Error, _("comar denied our access")
|
|
||||||
|
|
||||||
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath, fromVersion, fromRelease, toVersion, toRelease):
|
def post_install(package_name, provided_scripts, scriptpath, metapath, filepath, fromVersion, fromRelease, toVersion, toRelease):
|
||||||
"""Do package's post install operations"""
|
"""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 = get_comar()
|
sys_service = False
|
||||||
|
sys_iface = get_iface()
|
||||||
|
object_name = make_object_path(package_name)
|
||||||
|
|
||||||
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)
|
||||||
if script.om == "System.Package":
|
if script.om == "System.Package":
|
||||||
self_post = True
|
self_post = True
|
||||||
com.register(script.om, package_name, os.path.join(scriptpath, script.script))
|
elif script.om == "System.Service":
|
||||||
wait_for_result(com)
|
sys_service = True
|
||||||
|
try:
|
||||||
|
sys_iface.register(object_name, script.om, os.path.join(scriptpath, script.script))
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
if sys_service:
|
||||||
|
try:
|
||||||
|
iface = get_iface(object_name, "System.Service")
|
||||||
|
iface.registerState()
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|
||||||
ctx.ui.debug(_("Calling post install handlers"))
|
ctx.ui.debug(_("Calling post install handlers"))
|
||||||
com.call("System.PackageHandler.setupPackage", [ "metapath", metapath, "filepath", filepath ])
|
for handler in sys_iface.listModelApplications("System.PackageHandler"):
|
||||||
wait_for_result(com)
|
iface = get_iface(handler, "System.PackageHandler")
|
||||||
|
try:
|
||||||
|
iface.setupPackage(metapath, filepath, timeout=ctx.dbus_timeout)
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
# Do nothing if setupPackage method is not defined in package script
|
||||||
|
if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
||||||
|
exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|
||||||
if self_post:
|
if self_post:
|
||||||
args = {
|
if not fromVersion:
|
||||||
"fromVersion": fromVersion,
|
fromVersion = ""
|
||||||
"fromRelease": fromRelease,
|
if not fromRelease:
|
||||||
"toVersion": toVersion,
|
fromRelease = ""
|
||||||
"toRelease": toRelease,
|
|
||||||
}
|
|
||||||
ctx.ui.debug(_("Running package's post install script"))
|
ctx.ui.debug(_("Running package's post install script"))
|
||||||
com.call_package("System.Package.postInstall", package_name, args)
|
try:
|
||||||
wait_for_result(com, package_name)
|
iface = get_iface(object_name, "System.Package")
|
||||||
|
iface.postInstall(fromVersion, fromRelease, toVersion, toRelease, timeout=ctx.dbus_timeout)
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
# Do nothing if postInstall method is not defined in package script
|
||||||
|
if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
||||||
|
exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|
||||||
|
if package_name == 'comar':
|
||||||
|
pisi.api.set_comar_destination('tr.org.pardus.comar.new')
|
||||||
|
|
||||||
def pre_remove(package_name, metapath, filepath):
|
def pre_remove(package_name, metapath, filepath):
|
||||||
"""Do package's pre removal operations"""
|
"""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 = get_comar()
|
sys_iface = get_iface()
|
||||||
|
object_name = make_object_path(package_name)
|
||||||
|
|
||||||
|
if "System.Package" in sys_iface.listApplicationModels(object_name):
|
||||||
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)
|
iface = get_iface(object_name, "System.Package")
|
||||||
wait_for_result(com)
|
try:
|
||||||
|
iface.preRemove(timeout=ctx.dbus_timeout)
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
# Do nothing if preRemove method is not defined in package script
|
||||||
|
if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
||||||
|
exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|
||||||
ctx.ui.debug(_("Calling pre remove handlers"))
|
ctx.ui.debug(_("Calling pre remove handlers"))
|
||||||
com.call("System.PackageHandler.cleanupPackage", [ "metapath", metapath, "filepath", filepath ])
|
for handler in sys_iface.listModelApplications("System.PackageHandler"):
|
||||||
wait_for_result(com)
|
iface = get_iface(handler, "System.PackageHandler")
|
||||||
|
try:
|
||||||
|
iface.cleanupPackage(metapath, filepath, timeout=ctx.dbus_timeout)
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
# Do nothing if cleanupPackage method is not defined in package script
|
||||||
|
if not (exception._dbus_error_name.startswith("tr.org.pardus.comar") and
|
||||||
|
exception._dbus_error_name.split('tr.org.pardus.comar.')[1] == 'python.missing'):
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|
||||||
ctx.ui.debug(_("Unregistering comar scripts"))
|
ctx.ui.debug(_("Unregistering comar scripts"))
|
||||||
com.remove(package_name)
|
try:
|
||||||
wait_for_result(com)
|
sys_iface.remove(object_name)
|
||||||
|
except dbus.DBusException, exception:
|
||||||
|
raise Error, _("Script error: %s") % exception
|
||||||
|
|||||||
+8
-8
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005 - 2007, TUBITAK/UEKAE
|
# Copyright (C) 2005 - 2008, TUBITAK/UEKAE
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
# the terms of the GNU General Public License as published by the Free
|
# the terms of the GNU General Public License as published by the Free
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
#host = i686-pc-linux-gnu
|
#host = i686-pc-linux-gnu
|
||||||
#generateDebug = False
|
#generateDebug = False
|
||||||
#jobs = "-j1"
|
#jobs = "-j1"
|
||||||
#CFLAGS= -mtune=generic -mcpu=generic -march=i686 -O2 -pipe -fomit-frame-pointer -Wstrict-overflow -g -ggdb
|
#CFLAGS= -mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2
|
||||||
#CXXFLAGS= -mtune=generic -mcpu=generic -march=i686 -O2 -pipe -fomit-frame-pointer -Wstrict-overflow -g -ggdb
|
#CXXFLAGS= -mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2
|
||||||
#LDFLAGS=
|
#LDFLAGS= -Wl,-O1 -Wl,-z,relro -Wl,--hash-style=gnu
|
||||||
#buildno=True # necessary for generating build nos
|
#buildno=True # necessary for generating build nos
|
||||||
#buildhelper = None / ccache / icecream
|
#buildhelper = None / ccache / icecream
|
||||||
#compressionlevel = 7
|
#compressionlevel = 7
|
||||||
@@ -65,7 +65,7 @@ class GeneralDefaults:
|
|||||||
destinationdirectory = "/"
|
destinationdirectory = "/"
|
||||||
autoclean = False
|
autoclean = False
|
||||||
distribution = "Pardus"
|
distribution = "Pardus"
|
||||||
distribution_release = "2007"
|
distribution_release = "2008"
|
||||||
architecture = "i686"
|
architecture = "i686"
|
||||||
http_proxy = os.getenv("HTTP_PROXY") or None
|
http_proxy = os.getenv("HTTP_PROXY") or None
|
||||||
https_proxy = os.getenv("HTTPS_PROXY") or None
|
https_proxy = os.getenv("HTTPS_PROXY") or None
|
||||||
@@ -78,9 +78,9 @@ class BuildDefaults:
|
|||||||
host = "i686-pc-linux-gnu"
|
host = "i686-pc-linux-gnu"
|
||||||
jobs = "-j1"
|
jobs = "-j1"
|
||||||
generateDebug = False
|
generateDebug = False
|
||||||
cflags = "-mtune=i686 -O2 -pipe -fomit-frame-pointer"
|
cflags = "-mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2"
|
||||||
cxxflags = "-mtune=i686 -O2 -pipe -fomit-frame-pointer"
|
cxxflags = "-mtune=generic -march=i686 -O2 -pipe -fomit-frame-pointer -fstack-protector -D_FORTIFY_SOURCE=2"
|
||||||
ldflags = ""
|
ldflags = "-Wl,-O1 -Wl,-z,relro -Wl,--hash-style=gnu"
|
||||||
buildno = False
|
buildno = False
|
||||||
buildhelper = None
|
buildhelper = None
|
||||||
compressionlevel = 7
|
compressionlevel = 7
|
||||||
|
|||||||
+3
-1
@@ -38,7 +38,9 @@ stdout = None
|
|||||||
stderr = None
|
stderr = None
|
||||||
|
|
||||||
comar = True
|
comar = True
|
||||||
comar_sockname = None
|
comar_destination = "tr.org.pardus.comar"
|
||||||
|
dbus_sockname = None
|
||||||
|
dbus_timeout = 300
|
||||||
|
|
||||||
# Bug #2879
|
# Bug #2879
|
||||||
# FIXME: Maybe we can create a simple rollback mechanism. There are other
|
# FIXME: Maybe we can create a simple rollback mechanism. There are other
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
Index: pisi/archive.py
|
|
||||||
===================================================================
|
|
||||||
--- pisi/archive.py (revision 16476)
|
|
||||||
+++ pisi/archive.py (working copy)
|
|
||||||
@@ -19,6 +19,7 @@
|
|
||||||
import tarfile
|
|
||||||
import zipfile
|
|
||||||
import gzip
|
|
||||||
+import struct
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
|
||||||
@@ -212,8 +213,24 @@
|
|
||||||
"Attempt to read ZIP archive that was already closed"
|
|
||||||
zinfo = self.getinfo(name)
|
|
||||||
filepos = self.fp.tell()
|
|
||||||
- self.fp.seek(zinfo.file_offset, 0)
|
|
||||||
|
|
||||||
+ self.fp.seek(zinfo.header_offset, 0)
|
|
||||||
+
|
|
||||||
+ # Skip the file header:
|
|
||||||
+ fheader = self.fp.read(30)
|
|
||||||
+ if fheader[0:4] != zipfile.stringFileHeader:
|
|
||||||
+ raise BadZipfile, "Bad magic number for file header"
|
|
||||||
+
|
|
||||||
+ fheader = struct.unpack(zipfile.structFileHeader, fheader)
|
|
||||||
+ fname = self.fp.read(fheader[zipfile._FH_FILENAME_LENGTH])
|
|
||||||
+ if fheader[zipfile._FH_EXTRA_FIELD_LENGTH]:
|
|
||||||
+ self.fp.read(fheader[zipfile._FH_EXTRA_FIELD_LENGTH])
|
|
||||||
+
|
|
||||||
+ if fname != zinfo.orig_filename:
|
|
||||||
+ raise zipfile.BadZipfile, \
|
|
||||||
+ 'File name in directory "%s" and header "%s" differ.' % (
|
|
||||||
+ zinfo.orig_filename, fname)
|
|
||||||
+
|
|
||||||
destfile = file(outname, 'wb')
|
|
||||||
|
|
||||||
if zinfo.compress_type == zipfile.ZIP_STORED:
|
|
||||||
Reference in New Issue
Block a user