[Pkg-sugar-commit] [sugar-toolkit] 01/10: Do not fail if activity mime_type was already installed #1394

Jonas Smedegaard dr at jones.dk
Thu Apr 16 18:49:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.84.11-1
in repository sugar-toolkit.

commit 5b6043d46ef8f35d27f42e1a50ccc6b82678a05f
Author: Simon Schampijer <simon at schampijer.de>
Date:   Mon Jun 7 13:35:52 2010 +0200

    Do not fail if activity mime_type was already installed #1394
    
    - backported from 0.88
    - initial patch from Aleksey Lim
---
 src/sugar/bundle/activitybundle.py | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
index 268576e..2bec54f 100644
--- a/src/sugar/bundle/activitybundle.py
+++ b/src/sugar/bundle/activitybundle.py
@@ -323,7 +323,7 @@ class ActivityBundle(Bundle):
                 os.makedirs(mime_pkg_dir)
             installed_mime_path = os.path.join(mime_pkg_dir,
                                                '%s.xml' % self._bundle_id)
-            os.symlink(mime_path, installed_mime_path)
+            self._symlink(mime_path, installed_mime_path)
             os.spawnlp(os.P_WAIT, 'update-mime-database',
                        'update-mime-database', mime_dir)
 
@@ -339,16 +339,27 @@ class ActivityBundle(Bundle):
                                               mime_type.replace('/', '-'))
                 svg_file = mime_icon_base + '.svg'
                 info_file = mime_icon_base + '.icon'
-                if os.path.isfile(svg_file):
-                    os.symlink(svg_file,
-                               os.path.join(installed_icons_dir,
-                                            os.path.basename(svg_file)))
-                if os.path.isfile(info_file):
-                    os.symlink(info_file,
-                               os.path.join(installed_icons_dir,
-                                            os.path.basename(info_file)))
+                self._symlink(svg_file,
+                              os.path.join(installed_icons_dir,
+                                           os.path.basename(svg_file)))
+                self._symlink(info_file,
+                              os.path.join(installed_icons_dir,
+                                           os.path.basename(info_file)))
+
         return install_path
 
+    def _symlink(self, src, dst):
+        if not os.path.isfile(src):
+            return
+        if not os.path.islink(dst) and os.path.exists(dst):
+            raise RuntimeError('Do not remove %s if it was not '
+                               'installed by sugar', dst)
+        logging.debug('Link resource %s to %s', src, dst)
+        if os.path.lexists(dst):
+            logging.debug('Relink %s', dst)
+            os.unlink(dst)
+        os.symlink(src, dst)
+
     def uninstall(self, install_path, force=False):
         if os.path.islink(install_path):
             # Don't remove the actual activity dir if it's a symbolic link

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-toolkit.git



More information about the pkg-sugar-commit mailing list