From 134f72f17c6b280839fcfd1b63d2130102f21cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 18 Mar 2010 10:04:09 +0000 Subject: [PATCH] Add ability to rename System.Service scripts System.Service System.Service Will register two separate system services called respectively "iscsi" and "iscsid". This way we don't have to split packages to give them separate names or to provide more than 1 services in a sub-package. --- pisi-spec.rng | 3 +++ pisi/atomicoperations.py | 3 ++- pisi/comariface.py | 18 +++++++++++------- pisi/specfile.py | 3 ++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pisi-spec.rng b/pisi-spec.rng index 6c1e5f51..0fc029c6 100644 --- a/pisi-spec.rng +++ b/pisi-spec.rng @@ -1420,6 +1420,9 @@ + + + diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 7e1f3de2..c40c8da0 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -674,11 +674,12 @@ class Remove(AtomicOperation): self.package_name, os.path.join(self.package.pkg_dir(), ctx.const.metadata_xml), os.path.join(self.package.pkg_dir(), ctx.const.files_xml), + provided_scripts=self.package.providesComar, ) def update_databases(self): self.remove_db() - self.historydb.add_and_update(pkgBefore=self.package, operation="remove") + self.historydb.add_and_update(pkgBefore=self.package, operation="remove") def remove_pisi_files(self): util.clean_dir(self.package.pkg_dir()) diff --git a/pisi/comariface.py b/pisi/comariface.py index 4db9a072..20b1c771 100644 --- a/pisi/comariface.py +++ b/pisi/comariface.py @@ -104,17 +104,18 @@ def post_install(package_name, provided_scripts, scriptpath, metapath, filepath, for script in provided_scripts: ctx.ui.debug(_("Registering %s comar script") % script.om) + script_name = script.name if script.name else package_name if script.om == "System.Package": self_post = True elif script.om == "System.Service": sys_service = True try: - link.register(package_name, script.om, os.path.join(scriptpath, script.script)) + link.register(script_name, script.om, os.path.join(scriptpath, script.script)) except dbus.DBusException, exception: raise Error, _("Script error: %s") % exception if sys_service: try: - link.System.Service[package_name].registerState() + link.System.Service[script_name].registerState() except dbus.DBusException, exception: raise Error, _("Script error: %s") % exception @@ -167,13 +168,15 @@ def pre_remove(package_name, metapath, filepath): if not is_method_missing(exception): raise Error, _("Script error: %s") % exception -def post_remove(package_name, metapath, filepath): +def post_remove(package_name, metapath, filepath, provided_scripts=[]): """Do package's post removal operations""" ctx.ui.info(_("Running post removal operations for %s") % package_name) link = get_link() package_name = safe_package_name(package_name) + scripts = set([s.name for s in provided_scripts if s.name]) + scripts.add(package_name) if package_name in list(link.System.Package): ctx.ui.debug(_("Running package's postremove script")) @@ -194,7 +197,8 @@ def post_remove(package_name, metapath, filepath): raise Error, _("Script error: %s") % exception ctx.ui.debug(_("Unregistering comar scripts")) - try: - link.remove(package_name, timeout=ctx.dbus_timeout) - except dbus.DBusException, exception: - raise Error, _("Script error: %s") % exception + for scr in scripts: + try: + link.remove(scr, timeout=ctx.dbus_timeout) + except dbus.DBusException, exception: + raise Error, _("Script error: %s") % exception diff --git a/pisi/specfile.py b/pisi/specfile.py index 40d440ab..32f0fc7d 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -142,11 +142,12 @@ class ComarProvide: s_om = [autoxml.String, autoxml.mandatory] a_script = [autoxml.String, autoxml.mandatory] + a_name = [autoxml.String, autoxml.optional] def __str__(self): # FIXME: descriptive enough? s = self.script - s += ' (' + self.om + ')' + s += ' (' + self.om + '%s' % (' for %s' % self.name if self.name else '') + ')' return s class Archive: