Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanish <manish@robbie.oficina.paraguayeduca.org>2011-01-17 18:04:26 (GMT)
committer manish <manish@robbie.oficina.paraguayeduca.org>2011-01-17 18:05:43 (GMT)
commita69619a4da09e35b738d6a03fa4d01c1af082e6d (patch)
tree5a2e925ef394e2acd1c4c8017e2d408d745729ac
parent95f49e4243fb2ee25f50362dc894ed2468fa347a (diff)
Check for activity compatibility before installing
-rw-r--r--rpms/sugar-toolkit/Fix-typo-in-except-block.patch30
-rw-r--r--rpms/sugar-toolkit/Parse-activity-dependencies.patch129
-rw-r--r--rpms/sugar-toolkit/sugar-toolkit.spec12
-rw-r--r--rpms/sugar/Check-for-required-activity-deps-before-installing.patch162
-rw-r--r--rpms/sugar/Let-call-the-frame-from-arbitrary-code-avoiding-curcular-imports.patch35
-rw-r--r--rpms/sugar/sugar.spec34
6 files changed, 389 insertions, 13 deletions
diff --git a/rpms/sugar-toolkit/Fix-typo-in-except-block.patch b/rpms/sugar-toolkit/Fix-typo-in-except-block.patch
new file mode 100644
index 0000000..e0f226a
--- /dev/null
+++ b/rpms/sugar-toolkit/Fix-typo-in-except-block.patch
@@ -0,0 +1,30 @@
+From patchwork Wed Jan 12 14:37:08 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [sugar-toolkit,1/2] Fix typo in except block
+Date: Wed, 12 Jan 2011 19:37:08 -0000
+From: Aleksey Lim <alsroot@member.fsf.org>
+X-Patchwork-Id: 556
+Message-Id: <1294843029-28075-1-git-send-email-alsroot@member.fsf.org>
+To: sugar-devel@lists.sugarlabs.org
+Cc: dextrose@lists.sugarlabs.org
+
+---
+ src/sugar/bundle/bundle.py | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+
+diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py
+index 2c210b3..a402ae9 100644
+--- a/src/sugar/bundle/bundle.py
++++ b/src/sugar/bundle/bundle.py
+@@ -73,7 +73,7 @@ class Bundle(object):
+ if not os.path.isdir(self._path):
+ try:
+ self._zip_file = zipfile.ZipFile(self._path)
+- except (zipfile.error, LargeZipFile), ziperror:
++ except (zipfile.error, zipfile.LargeZipFile), ziperror:
+ raise MalformedBundleException(
+ "Error accessing zip file %s: %s"
+ % (self._path, ziperror))
diff --git a/rpms/sugar-toolkit/Parse-activity-dependencies.patch b/rpms/sugar-toolkit/Parse-activity-dependencies.patch
new file mode 100644
index 0000000..6c9001a
--- /dev/null
+++ b/rpms/sugar-toolkit/Parse-activity-dependencies.patch
@@ -0,0 +1,129 @@
+From patchwork Wed Jan 12 14:37:09 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [sugar-toolkit,2/2] Parse activity dependencies
+Date: Wed, 12 Jan 2011 19:37:09 -0000
+From: Aleksey Lim <alsroot@member.fsf.org>
+X-Patchwork-Id: 558
+Message-Id: <1294843029-28075-2-git-send-email-alsroot@member.fsf.org>
+To: sugar-devel@lists.sugarlabs.org
+Cc: dextrose@lists.sugarlabs.org
+
+It is a mimic of sweets' requires tag that will be used only for sugar
+dependency. Full functional dependency tracking will come with sweets support
+implementation in the shell.
+
+The format for requires optin in activity.info:
+ requires = sugar (=|==|<|<=|>|>=) version [; ...]
+
+---
+src/sugar/bundle/activitybundle.py | 70 ++++++++++++++++++++++++++++++++++++
+ 1 files changed, 70 insertions(+), 0 deletions(-)
+
+diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
+index b2548a4..ac1d558 100644
+--- a/src/sugar/bundle/activitybundle.py
++++ b/src/sugar/bundle/activitybundle.py
+@@ -26,6 +26,8 @@ import os
+ import tempfile
+ import logging
+ import shutil
++import gettext
++import re
+
+ from sugar import env
+ from sugar import util
+@@ -33,6 +35,14 @@ from sugar.bundle.bundle import Bundle, \
+ MalformedBundleException, NotInstalledException
+
+
++_ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
++
++
++class DependencyException(Exception):
++ """Required dependencies were not found."""
++ pass
++
++
+ class ActivityBundle(Bundle):
+ """A Sugar activity bundle
+
+@@ -60,6 +70,7 @@ class ActivityBundle(Bundle):
+ self._tags = None
+ self._activity_version = 0
+ self._installation_time = os.stat(path).st_mtime
++ self._requires = []
+
+ info_file = self.get_file('activity/activity.info')
+ if info_file is None:
+@@ -129,6 +140,11 @@ class ActivityBundle(Bundle):
+ 'Activity bundle %s has invalid version number %s' %
+ (self._path, version))
+
++ if cp.has_option(section, 'requires'):
++ requires = cp.get(section, 'requires')
++ for dep in requires.replace('\n', ';').split(';'):
++ self._requires.extend(_parse_condition(dep))
++
+ def _get_linfo_file(self):
+ lang = locale.getdefaultlocale()[0]
+ if not lang:
+@@ -331,3 +347,57 @@ class ActivityBundle(Bundle):
+
+ def is_user_activity(self):
+ return self.get_path().startswith(env.get_user_activities_path())
++
++ def meets_restriction(self, req_name, req_version):
++ version = _parse_version(req_version)
++
++ for dep, dep_rels, dep_version, error_msg in self._requires:
++ if dep != req_name:
++ continue
++ errors = set()
++ for rel in dep_rels:
++ if cmp(version, dep_version) == rel:
++ errors.clear()
++ break
++ else:
++ errors.add(error_msg)
++ if errors:
++ error = _('Restriction was not met: %s') % ', '.join(errors)
++ raise DependencyException(error)
++
++
++def _format_version(version):
++ return '.'.join([str(i) for i in version])
++
++
++def _parse_version(version):
++ return [int(i) if i.isdigit() else 0 for i in version.strip().split('.')]
++
++
++def _parse_condition(dep):
++ match = re.split('(=|==|<|<=|>|>=|!=)\s*([0-9.]+)', dep)
++ if len(match) == 1:
++ return []
++ if len(match) != 4 or match[-1]:
++ raise MalformedBundleException(_('Malformed requires, "%s"') % dep)
++
++ result = []
++ dep = match[0].strip()
++ arg = _parse_version(match[2])
++ error_msg = '%s %s %s' % (dep, match[1], _format_version(arg))
++
++ if match[1] == '=' or match[1] == '==':
++ result.append((dep, [0, 1], arg, error_msg))
++ result.append((dep, [-1], arg[:-1] + [arg[-1] + 1], error_msg))
++ elif match[1] == '<':
++ result.append((dep, [-1], arg, error_msg))
++ elif match[1] == '<=':
++ result.append((dep, [-1, 0], arg, error_msg))
++ elif match[1] == '>':
++ result.append((dep, [1], arg, error_msg))
++ elif match[1] == '>=':
++ result.append((dep, [1, 0], arg, error_msg))
++ elif match[1] == '!=':
++ result.append((dep, [-1, 1], arg, error_msg))
++
++ return result
diff --git a/rpms/sugar-toolkit/sugar-toolkit.spec b/rpms/sugar-toolkit/sugar-toolkit.spec
index 1f2ed82..341051a 100644
--- a/rpms/sugar-toolkit/sugar-toolkit.spec
+++ b/rpms/sugar-toolkit/sugar-toolkit.spec
@@ -3,7 +3,7 @@
Summary: Sugar toolkit
Name: sugar-toolkit
Version: 0.88.1
-Release: 4.10dxo%{?dist}
+Release: 4.11dxo%{?dist}
URL: http://wiki.laptop.org/go/Sugar
Source0: http://download.sugarlabs.org/sources/sucrose/glucose/%{name}/%{name}-%{version}.tar.bz2
Source1: macros.sugar
@@ -39,6 +39,10 @@ Patch401: accessibility_0001_style-contrast.patch
#NamingAlert being optional
Patch501: namingalert_being_optional.patch
+#Checks to prevent installation of incompatible activities
+Patch601: Fix-typo-in-except-block.patch
+Patch602: Parse-activity-dependencies.patch
+
License: LGPLv2+
Group: System Environment/Libraries
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -96,6 +100,9 @@ to interact with system services like presence and the datastore.
%patch501 -p1
+%patch601 -p1
+%patch602 -p1
+
%build
%configure
make %{?_smp_mflags} V=1
@@ -123,6 +130,9 @@ rm -rf %{buildroot}
%{_sysconfdir}/rpm/macros.sugar
%changelog
+* Mon Jan 14 2011 Anish Mangal <anish@sugarlabs.org> - 0.88.1-4.11
+- Checks to prevent installation of incompatible activities (Patch601, Patch602)
+
* Mon Jan 10 2011 Anish Mangal <anish@sugarlabs.org> - 0.88.1-4.10
- Add 'NamingAlert being optional' (patch501)
diff --git a/rpms/sugar/Check-for-required-activity-deps-before-installing.patch b/rpms/sugar/Check-for-required-activity-deps-before-installing.patch
new file mode 100644
index 0000000..021bff6
--- /dev/null
+++ b/rpms/sugar/Check-for-required-activity-deps-before-installing.patch
@@ -0,0 +1,162 @@
+From patchwork Wed Jan 12 14:32:32 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [sugar,2/2] Check for required activity deps before installing
+Date: Wed, 12 Jan 2011 19:32:32 -0000
+From: Aleksey Lim <alsroot@member.fsf.org>
+X-Patchwork-Id: 554
+Message-Id: <1294842752-27812-3-git-send-email-alsroot@member.fsf.org>
+To: sugar-devel@lists.sugarlabs.org
+Cc: dextrose@lists.sugarlabs.org
+
+The patch moves all bundle install calls to one function and wraps all known
+exceptions to send error notifications.
+
+---
+src/jarabe/journal/journalactivity.py | 11 ++----
+ src/jarabe/journal/misc.py | 53 ++++++++++++++++++++++----------
+ src/jarabe/model/bundleregistry.py | 3 ++
+ 3 files changed, 43 insertions(+), 24 deletions(-)
+
+diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
+index 52a677e..7b04735 100644
+--- a/src/jarabe/journal/journalactivity.py
++++ b/src/jarabe/journal/journalactivity.py
+@@ -305,14 +305,11 @@ class JournalActivity(JournalWindow):
+ bundle.get_path())
+ return
+
+- try:
+- registry.install(bundle)
+- except (ZipExtractException, RegistrationException):
+- logging.exception('Could not install bundle %s', bundle.get_path())
+- return
++ def install_cb():
++ metadata['bundle_id'] = bundle.get_bundle_id()
++ model.write(metadata)
+
+- metadata['bundle_id'] = bundle.get_bundle_id()
+- model.write(metadata)
++ misc.install_activity(bundle, install_cb)
+
+ def search_grab_focus(self):
+ search_toolbar = self._main_toolbox.search_toolbar
+diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
+index 710cb15..28644d6 100644
+--- a/src/jarabe/journal/misc.py
++++ b/src/jarabe/journal/misc.py
+@@ -30,8 +30,9 @@ from sugar.graphics.icon import get_icon_file_name
+ from sugar.graphics.xocolor import XoColor
+ from sugar.graphics.alert import ConfirmationAlert
+ from sugar import mime
+-from sugar.bundle.activitybundle import ActivityBundle
++from sugar.bundle.activitybundle import ActivityBundle, DependencyException
+ from sugar.bundle.bundle import AlreadyInstalledException
++from sugar.bundle.bundle import ZipExtractException, RegistrationException
+ from sugar.bundle.contentbundle import ContentBundle
+ from sugar import util
+
+@@ -40,6 +41,7 @@ from jarabe.model import bundleregistry, shell
+ from jarabe.journal.journalentrybundle import JournalEntryBundle
+ from jarabe.journal import model
+ from jarabe.journal import journalwindow
++from jarabe import frame
+
+ def _get_icon_for_mime(mime_type):
+ generic_types = mime.get_all_generic_types()
+@@ -161,18 +163,7 @@ def resume(metadata, bundle_id=None):
+
+ file_path = model.get_file(metadata['uid'])
+ bundle = ActivityBundle(file_path)
+- if not registry.is_installed(bundle):
+- logging.debug('Installing activity bundle')
+- try:
+- registry.install(bundle)
+- except AlreadyInstalledException:
+- _downgrade_option_alert(bundle)
+- return
+- else:
+- logging.debug('Upgrading activity bundle')
+- registry.upgrade(bundle)
+-
+- _launch_bundle(bundle)
++ install_activity(bundle, lambda: _launch_bundle(bundle))
+
+ elif is_content_bundle(metadata) and bundle_id is None:
+
+@@ -229,6 +220,33 @@ def resume(metadata, bundle_id=None):
+ else:
+ activityfactory.create_with_object_id(bundle, object_id)
+
++
++def install_activity(bundle, finish_cb=None):
++ try:
++ registry = bundleregistry.get_registry()
++
++ if not registry.is_installed(bundle):
++ logging.debug('Installing activity bundle')
++ registry.install(bundle)
++ else:
++ logging.debug('Upgrading activity bundle')
++ registry.upgrade(bundle)
++
++ if finish_cb is not None:
++ finish_cb()
++
++ except AlreadyInstalledException:
++ _downgrade_option_alert(bundle, finish_cb)
++ except DependencyException, error:
++ frame.get_view().add_message(
++ summary=_('Cannot install %s activity') % bundle.get_name(),
++ body=str(error))
++ except (ZipExtractException, RegistrationException):
++ frame.get_view().add_message(
++ summary=_('Cannot install activity %s') % bundle.get_name(),
++ body = _('Malformed activity bundle'))
++
++
+ def _launch_bundle(bundle):
+ registry = bundleregistry.get_registry()
+ logging.debug('activityfactory.creating bundle with id %r',
+@@ -240,21 +258,22 @@ def _launch_bundle(bundle):
+ logging.error('Bundle %r is not installed.',
+ bundle.get_bundle_id())
+
+-def _downgrade_option_alert(bundle):
++def _downgrade_option_alert(bundle, finish_cb):
+ alert = ConfirmationAlert()
+ alert.props.title = _('Older Version Of %s Activity') % (bundle.get_name())
+ alert.props.msg = _('Do you want to downgrade to version %s') % \
+ bundle.get_activity_version()
+- alert.connect('response', _downgrade_alert_response_cb, bundle)
++ alert.connect('response', _downgrade_alert_response_cb, bundle, finish_cb)
+ journalwindow.get_journal_window().add_alert(alert)
+ alert.show()
+
+-def _downgrade_alert_response_cb(alert, response_id, bundle):
++def _downgrade_alert_response_cb(alert, response_id, bundle, finish_cb):
+ if response_id is gtk.RESPONSE_OK:
+ journalwindow.get_journal_window().remove_alert(alert)
+ registry = bundleregistry.get_registry()
+ registry.install(bundle, force_downgrade=True)
+- _launch_bundle(bundle)
++ if finish_cb is not None:
++ finish_cb()
+ elif response_id is gtk.RESPONSE_CANCEL:
+ journalwindow.get_journal_window().remove_alert(alert)
+
+diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
+index f2c2a52..cd82fc9 100644
+--- a/src/jarabe/model/bundleregistry.py
++++ b/src/jarabe/model/bundleregistry.py
+@@ -377,6 +377,9 @@ class BundleRegistry(gobject.GObject):
+ return False
+
+ def install(self, bundle, uid=None, force_downgrade=False):
++ if hasattr(bundle, 'meets_restriction'):
++ bundle.meets_restriction('sugar', config.version)
++
+ activities_path = env.get_user_activities_path()
+
+ for installed_bundle in self._bundles:
diff --git a/rpms/sugar/Let-call-the-frame-from-arbitrary-code-avoiding-curcular-imports.patch b/rpms/sugar/Let-call-the-frame-from-arbitrary-code-avoiding-curcular-imports.patch
new file mode 100644
index 0000000..2acecf2
--- /dev/null
+++ b/rpms/sugar/Let-call-the-frame-from-arbitrary-code-avoiding-curcular-imports.patch
@@ -0,0 +1,35 @@
+From patchwork Wed Jan 12 14:32:31 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [sugar,
+ 1/2] Let call the frame from arbitrary code avoiding curcular imports
+Date: Wed, 12 Jan 2011 19:32:31 -0000
+From: Aleksey Lim <alsroot@member.fsf.org>
+X-Patchwork-Id: 552
+Message-Id: <1294842752-27812-2-git-send-email-alsroot@member.fsf.org>
+To: sugar-devel@lists.sugarlabs.org
+Cc: dextrose@lists.sugarlabs.org
+
+---
+ src/jarabe/frame/__init__.py | 3 +--
+ 1 files changed, 1 insertions(+), 2 deletions(-)
+
+
+diff --git a/src/jarabe/frame/__init__.py b/src/jarabe/frame/__init__.py
+index d7aec3d..3ca156c 100644
+--- a/src/jarabe/frame/__init__.py
++++ b/src/jarabe/frame/__init__.py
+@@ -14,11 +14,10 @@
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+-from jarabe.frame.frame import Frame
+-
+ _view = None
+
+ def get_view():
++ from jarabe.frame.frame import Frame
+ global _view
+ if not _view:
+ _view = Frame()
diff --git a/rpms/sugar/sugar.spec b/rpms/sugar/sugar.spec
index 0dd8168..020b1ae 100644
--- a/rpms/sugar/sugar.spec
+++ b/rpms/sugar/sugar.spec
@@ -3,7 +3,7 @@
Summary: Constructionist learning platform
Name: sugar
Version: 0.88.1
-Release: 5.43dxo%{?dist}
+Release: 5.44dxo%{?dist}
URL: http://sugarlabs.org/
Source0: http://download.sugarlabs.org/sources/sucrose/glucose/%{name}/%{name}-%{version}.tar.bz2
@@ -87,24 +87,28 @@ patch707: accessibility_0008_cp_show-virtualkeyboard-for-accessibility.patch
# Translations
patch801: accessibility_0007_cp_translations.patch
patch802: backup-translations.patch
-Patch803: journal-0003-reindex-translations.patch
-Patch804: accessibility_0009_cp_show-virtualkeyboard-for-accessibility-traslate.patch
+patch803: journal-0003-reindex-translations.patch
+patch804: accessibility_0009_cp_show-virtualkeyboard-for-accessibility-traslate.patch
-Patch901: add-button-frame.patch
+patch901: add-button-frame.patch
#Notifications
-Patch1001: 0001-Simple-messages-notification-extension.patch
-Patch1002: 0002-Improve-message-notification-behaviour.patch
-Patch1003: 0003-Yum-updater-notifications-integration.patch
+patch1001: 0001-Simple-messages-notification-extension.patch
+patch1002: 0002-Improve-message-notification-behaviour.patch
+patch1003: 0003-Yum-updater-notifications-integration.patch
#NamingAlert being optional
-Patch1101: add__show_naming_alert__gconf_key.patch
+patch1101: add__show_naming_alert__gconf_key.patch
#Downgrading activities not allowed (#2164)
-Patch1201: downgrading_activities_not_allowed_2164.patch
+patch1201: downgrading_activities_not_allowed_2164.patch
#Globalkey for touchpad device icon
-Patch1301: globalkey_for_touchpad_device_icon.patch
+patch1301: globalkey_for_touchpad_device_icon.patch
+
+#Checks to prevent installation of incompatible activities
+patch1401: Let-call-the-frame-from-arbitrary-code-avoiding-curcular-imports.patch
+patch1402: Check-for-required-activity-deps-before-installing.patch
License: GPLv2+
Group: User Interface/Desktops
@@ -259,6 +263,9 @@ multiple instances of sugar.
%patch1301 -p1
+%patch1401 -p1
+%patch1402 -p1
+
%build
autoreconf
%configure
@@ -335,11 +342,14 @@ rm -rf %{buildroot}
%{_datadir}/icons/hicolor/scalable/apps/sugar-xo.svg
%changelog
+* Thu Jan 14 2011 Anish Mangal <anish@sugarlabs.org> - 0.88.1-5.44
+- Checks to prevent installation of incompatible activities
+
* Mon Jan 10 2011 Anish Mangal <anish@sugarlabs.org> - 0.88.1-5.43
- Add 'NamingAlert being optional' (patch1101)
-- Add 'Downgrading activities not allowed' (Patch1201)
+- Add 'Downgrading activities not allowed' (patch1201)
- Add 'Globalkey for touchpad device icon' (patch1301)
-- Replace updater with OLPC Microformat compatible one (Patch508)
+- Replace updater with OLPC Microformat compatible one (patch508)
* Sun Jan 9 2011 Bernie Innocenti <bernie@codewiz.org> - 0.88.1-5.42
- Add yum updater, and notification system.