From 15c5850df5b129a9205c96bf8ad2fc91de9d9074 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 12 Nov 2010 10:58:38 +0000 Subject: Adapt bundleregistry to use the new activity version scheme #10379 backported changes from SL #2425 --- diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py index af410a8..1060aff 100644 --- a/src/jarabe/model/bundleregistry.py +++ b/src/jarabe/model/bundleregistry.py @@ -27,6 +27,7 @@ import simplejson from sugar.bundle.activitybundle import ActivityBundle from sugar.bundle.contentbundle import ContentBundle from jarabe.journal.journalentrybundle import JournalEntryBundle +from sugar.bundle.bundleversion import NormalizedVersion from sugar.bundle.bundle import MalformedBundleException, \ AlreadyInstalledException, RegistrationException from sugar import env @@ -141,14 +142,16 @@ class BundleRegistry(gobject.GObject): return for bundle_id in default_activities: - max_version = -1 + max_version = '0' for bundle in self._bundles: if bundle.get_bundle_id() == bundle_id and \ - max_version < bundle.get_activity_version(): + NormalizedVersion(max_version) < \ + NormalizedVersion(bundle.get_activity_version()): max_version = bundle.get_activity_version() key = self._get_favorite_key(bundle_id, max_version) - if max_version > -1 and key not in self._favorite_bundles: + if NormalizedVersion(max_version) > NormalizedVersion('0') and \ + key not in self._favorite_bundles: self._favorite_bundles[key] = None logging.debug('After merging: %r' % self._favorite_bundles) @@ -334,8 +337,8 @@ class BundleRegistry(gobject.GObject): for installed_bundle in self._bundles: if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \ - bundle.get_activity_version() == \ - installed_bundle.get_activity_version(): + NormalizedVersion(bundle.get_activity_version()) == \ + NormalizedVersion(installed_bundle.get_activity_version()): return True return False @@ -348,8 +351,8 @@ class BundleRegistry(gobject.GObject): for installed_bundle in self._bundles: if bundle.get_bundle_id() == installed_bundle.get_bundle_id() and \ - bundle.get_activity_version() == \ - installed_bundle.get_activity_version(): + NormalizedVersion(bundle.get_activity_version()) <= \ + NormalizedVersion(installed_bundle.get_activity_version()): raise AlreadyInstalledException elif bundle.get_bundle_id() == installed_bundle.get_bundle_id(): self.uninstall(installed_bundle, force=True) @@ -381,7 +384,8 @@ class BundleRegistry(gobject.GObject): act = self.get_bundle(bundle.get_bundle_id()) if not force and \ - act.get_activity_version() != bundle.get_activity_version(): + NormalizedVersion(act.get_activity_version()) != \ + NormalizedVersion(bundle.get_activity_version()): logging.warning('Not uninstalling, different bundle present') return elif not act.get_path().startswith(env.get_user_activities_path()): -- cgit v0.9.1