$OpenBSD$ index 5e25bd9..7e099fd 100644 --- toolkit/mozapps/update/nsUpdateService.js.orig Fri Feb 20 15:40:39 2015 +++ toolkit/mozapps/update/nsUpdateService.js Fri Feb 20 15:40:39 2015 @@ -11,7 +11,11 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/AddonManager.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); +#ifdef BUILD_CTYPES +#ifdef XP_WIN Components.utils.import("resource://gre/modules/ctypes.jsm"); +#endif +#endif const Cc = Components.classes; const Ci = Components.interfaces; @@ -75,6 +79,10 @@ const KEY_GRED = "GreD"; const KEY_UPDROOT = "UpdRootD"; const KEY_EXECUTABLE = "XREExeF"; +#ifdef TOR_BROWSER_VERSION +#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__; +#endif + #ifdef MOZ_WIDGET_GONK #define USE_UPDATE_ARCHIVE_DIR #endif @@ -330,6 +338,7 @@ XPCOMUtils.defineLazyGetter(this, "gOSVersion", function aus_gOSVersion() { } if (osVersion) { +#ifdef BUILD_CTYPES #ifdef XP_WIN const BYTE = ctypes.uint8_t; const WORD = ctypes.uint16_t; @@ -436,6 +445,7 @@ XPCOMUtils.defineLazyGetter(this, "gOSVersion", function aus_gOSVersion() { } } #endif +#endif try { osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")"; @@ -1675,7 +1685,17 @@ function Update(update) { this._patches.push(patch); } - if (this._patches.length == 0 && !update.hasAttribute("unsupported")) + if (update.hasAttribute("unsupported")) + this.unsupported = ("true" == update.getAttribute("unsupported")); + else if (update.hasAttribute("minSupportedOSVersion")) { + let minOSVersion = update.getAttribute("minSupportedOSVersion"); + try { + let osVersion = Services.sysinfo.getProperty("version"); + this.unsupported = (Services.vc.compare(osVersion, minOSVersion) < 0); + } catch (e) {} + } + + if (this._patches.length == 0 && !this.unsupported) throw Cr.NS_ERROR_ILLEGAL_VALUE; // Fallback to the behavior prior to bug 530872 if the update does not have an @@ -1720,15 +1740,13 @@ function Update(update) { if(!isNaN(attr.value)) this.promptWaitTime = parseInt(attr.value); } - else if (attr.name == "unsupported") - this.unsupported = attr.value == "true"; else if (attr.name == "version") { // Prevent version from replacing displayVersion if displayVersion is // present in the update xml. if (!this.displayVersion) this.displayVersion = attr.value; } - else { + else if (attr.name != "unsupported") { this[attr.name] = attr.value; switch (attr.name) { @@ -2643,9 +2661,14 @@ UpdateService.prototype = { updates.forEach(function(aUpdate) { // Ignore updates for older versions of the application and updates for // the same version of the application with the same build ID. - if (vc.compare(aUpdate.appVersion, Services.appinfo.version) < 0 || - vc.compare(aUpdate.appVersion, Services.appinfo.version) == 0 && - aUpdate.buildID == Services.appinfo.appBuildID) { +#ifdef TOR_BROWSER_UPDATE + var compatVersion = TOR_BROWSER_VERSION; +#else + var compatVersion = Services.appinfo.version; +#endif + var rc = vc.compare(aUpdate.appVersion, compatVersion); + if (rc < 0 || ((rc == 0) && + (aUpdate.buildID == Services.appinfo.appBuildID))) { LOG("UpdateService:selectUpdate - skipping update because the " + "update's application version is less than the current " + "application version"); @@ -2816,8 +2839,13 @@ UpdateService.prototype = { } // Only check add-on compatibility when the version changes. +#ifdef TOR_BROWSER_UPDATE + var compatVersion = TOR_BROWSER_VERSION; +#else + var compatVersion = Services.appinfo.version; +#endif if (update.appVersion && - Services.vc.compare(update.appVersion, Services.appinfo.version) != 0) { + Services.vc.compare(update.appVersion, compatVersion) != 0) { this._update = update; this._checkAddonCompatibility(); } @@ -2847,6 +2875,11 @@ UpdateService.prototype = { // Get all the installed add-ons var self = this; AddonManager.getAllAddons(function(addons) { +#ifdef TOR_BROWSER_UPDATE + let compatVersion = self._update.platformVersion; +#else + let compatVersion = self._update.appVersion; +#endif self._incompatibleAddons = []; addons.forEach(function(addon) { // Protect against code that overrides the add-ons manager and doesn't @@ -2875,7 +2908,7 @@ UpdateService.prototype = { !addon.appDisabled && !addon.userDisabled && addon.scope != AddonManager.SCOPE_APPLICATION && addon.isCompatible && - !addon.isCompatibleWith(self._update.appVersion, + !addon.isCompatibleWith(compatVersion, self._update.platformVersion)) self._incompatibleAddons.push(addon); } @@ -2911,7 +2944,7 @@ UpdateService.prototype = { self._incompatibleAddons.forEach(function(addon) { addon.findUpdates(this, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, - this._update.appVersion, this._update.platformVersion); + compatVersion, this._update.platformVersion); }, self); } else { @@ -2948,8 +2981,13 @@ UpdateService.prototype = { // the add-on will become incompatible. let bs = Cc["@mozilla.org/extensions/blocklist;1"]. getService(Ci.nsIBlocklistService); +#ifdef TOR_BROWSER_UPDATE + let compatVersion = gUpdates.update.platformVersion; +#else + let compatVersion = gUpdates.update.appVersion; +#endif if (bs.isAddonBlocklisted(addon, - gUpdates.update.appVersion, + compatVersion, gUpdates.update.platformVersion)) return; @@ -3055,14 +3093,24 @@ UpdateService.prototype = { // current application's version or the update's version is the same as the // application's version and the build ID is the same as the application's // build ID. +#ifdef TOR_BROWSER_UPDATE + var compatVersion = TOR_BROWSER_VERSION; +#else + var compatVersion = Services.appinfo.version; +#endif if (update.appVersion && - (Services.vc.compare(update.appVersion, Services.appinfo.version) < 0 || + (Services.vc.compare(update.appVersion, compatVersion) < 0 || update.buildID && update.buildID == Services.appinfo.appBuildID && - update.appVersion == Services.appinfo.version)) { + update.appVersion == compatVersion)) { LOG("UpdateService:downloadUpdate - canceling download of update since " + "it is for an earlier or same application version and build ID.\n" + - "current application version: " + Services.appinfo.version + "\n" + +#ifdef TOR_BROWSER_UPDATE + "current Tor Browser version: " + compatVersion + "\n" + + "update Tor Browser version : " + update.appVersion + "\n" + +#else + "current application version: " + compatVersion + "\n" + "update application version : " + update.appVersion + "\n" + +#endif "current build ID: " + Services.appinfo.appBuildID + "\n" + "update build ID : " + update.buildID); cleanupActiveUpdate(); @@ -3095,7 +3143,7 @@ UpdateService.prototype = { } #endif // Set the previous application version prior to downloading the update. - update.previousAppVersion = Services.appinfo.version; + update.previousAppVersion = compatVersion; this._downloader = new Downloader(background, this); return this._downloader.downloadUpdate(update); }, @@ -3559,7 +3607,11 @@ Checker.prototype = { } url = url.replace(/%PRODUCT%/g, Services.appinfo.name); +#ifdef TOR_BROWSER_UPDATE + url = url.replace(/%VERSION%/g, TOR_BROWSER_VERSION); +#else url = url.replace(/%VERSION%/g, Services.appinfo.version); +#endif url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID); url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + gABI); url = url.replace(/%OS_VERSION%/g, gOSVersion);