Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-03-22 19:34:07 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-03-22 19:34:07 (GMT)
commit9af06c0b265ed6fb41b64afa8c186c4a617fa771 (patch)
tree2fe8a5deb30e28696a0e50d52734e2027b5e2302 /bin
parent01056ee8236ee68a73ca86dc1e801f4bd937089e (diff)
Add a script to start sugar. Move the gtkrc to avoid conflicts when
installing on a complete system.
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile.am7
-rwxr-xr-xbin/sugar-install-bundle58
-rw-r--r--bin/sugar.in2
3 files changed, 67 insertions, 0 deletions
diff --git a/bin/Makefile.am b/bin/Makefile.am
new file mode 100644
index 0000000..31f8a3b
--- /dev/null
+++ b/bin/Makefile.am
@@ -0,0 +1,7 @@
+bin_SCRIPTS = \
+ sugar \
+ sugar-install-bundle
+
+EXTRA_DIST = \
+ $(bin_SCRIPTS) \
+ sugar.in
diff --git a/bin/sugar-install-bundle b/bin/sugar-install-bundle
new file mode 100755
index 0000000..359c1c0
--- /dev/null
+++ b/bin/sugar-install-bundle
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+import sys
+import os
+import zipfile
+import dbus
+
+from sugar import env
+
+DBUS_SERVICE = "org.laptop.Shell"
+DBUS_PATH = "/org/laptop/Shell"
+
+# We check here that all the files in the .xo are inside one only dir (bundle_root_dir).
+def get_bundle_root_dir(file_names):
+ bundle_root_dir = None
+ for file_name in file_names:
+ if not bundle_root_dir:
+ bundle_root_dir = file_name.split('/')[0]
+ if not bundle_root_dir.endswith('.activity'):
+ raise 'Incorrect bundle.'
+ else:
+ if not file_name.startswith(bundle_root_dir):
+ raise 'Incorrect bundle.'
+
+ return bundle_root_dir
+
+bus = dbus.SessionBus()
+proxy_obj = bus.get_object(DBUS_SERVICE, DBUS_PATH)
+dbus_service = dbus.Interface(proxy_obj, DBUS_SERVICE)
+
+bundle_dir = env.get_user_activities_path()
+if not os.path.isdir(bundle_dir):
+ os.mkdir(bundle_dir)
+
+zip_file = zipfile.ZipFile(sys.argv[1])
+file_names = zip_file.namelist()
+bundle_root_dir = get_bundle_root_dir(file_names)
+bundle_path = os.path.join(bundle_dir, bundle_root_dir)
+
+# FIXME: we need to support installing different versions of the same bundle.
+if os.path.exists(bundle_path):
+ raise IOError, 'This bundle is already installed as ' + bundle_path
+
+if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', sys.argv[1], '-d', bundle_dir):
+ raise RuntimeError, 'An error occurred while extracting the .xo contents.'
+
+# notify shell of new bundle
+if not dbus_service.add_bundle(bundle_path):
+ # error, let's delete the just expanded bundle.
+ for root, dirs, files in os.walk(bundle_path, topdown=False):
+ for name in files:
+ os.remove(os.path.join(root, name))
+ for name in dirs:
+ os.rmdir(os.path.join(root, name))
+ os.rmdir(bundle_path)
+
+ raise RuntimeError, 'Bundle is not well-formed.'
+
+print "%s: '%s' installed." % (sys.argv[0], sys.argv[1])
diff --git a/bin/sugar.in b/bin/sugar.in
new file mode 100644
index 0000000..2fec22a
--- /dev/null
+++ b/bin/sugar.in
@@ -0,0 +1,2 @@
+export GTK2_RC_FILES=@prefix@/gtkrc
+dbus-launch --exit-with-session sugar-shell