Bug 1551455 - Reinstall distribution language packs. r=kmag
authorMichael Kaply <mozilla@kaply.com>
Thu, 16 May 2019 18:19:14 +0000
changeset 536111 296ca33d9a0e4bd501df7db94fac65961c7acec5
parent 536110 67eb2cac32c2db9e105ef3b38480c8de56f0ddfe
child 536112 a012ed03628d6192c71ab1561e8dc978c81e9136
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1551455
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551455 - Reinstall distribution language packs. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D31456
toolkit/mozapps/extensions/internal/XPIInstall.jsm
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
@@ -3306,20 +3306,23 @@ var XPIInstall = {
 
   /**
    * @param {string} id
    *        The expected ID of the add-on.
    * @param {nsIFile} file
    *        The XPI file to install the add-on from.
    * @param {XPIStateLocation} location
    *        The install location to install the add-on to.
+   * @param {string?} [oldAppVersion]
+   *        The version of the application last run with this profile or null
+   *        if it is a new profile or the version is unknown
    * @returns {AddonInternal}
    *        The installed Addon object, upon success.
    */
-  async installDistributionAddon(id, file, location) {
+  async installDistributionAddon(id, file, location, oldAppVersion) {
     let addon = await loadManifestFromFile(file, location);
     addon.installTelemetryInfo = {source: "distribution"};
 
     if (addon.id != id) {
       throw new Error(`File file ${file.path} contains an add-on with an incorrect ID`);
     }
 
     let state = location.get(id);
@@ -3330,16 +3333,20 @@ var XPIInstall = {
 
         if (Services.vc.compare(addon.version, existingAddon.version) <= 0)
           return null;
       } catch (e) {
         // Bad add-on in the profile so just proceed and install over the top
         logger.warn("Profile contains an add-on with a bad or missing install " +
                     `manifest at ${state.path}, overwriting`, e);
       }
+    } else if (addon.type === "locale" && oldAppVersion && Services.vc.compare(oldAppVersion, "67") < 0) {
+        /* Distribution language packs didn't get installed due to the signing
+           issues so we need to force them to be reinstalled. */
+      Services.prefs.clearUserPref(PREF_BRANCH_INSTALLED_ADDON + id);
     } else if (Services.prefs.getBoolPref(PREF_BRANCH_INSTALLED_ADDON + id, false)) {
       return null;
     }
 
     // Install the add-on
     addon.sourceBundle = location.installer.installAddon({ id, source: file, action: "copy" });
 
     XPIStates.addAddon(addon);
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2569,20 +2569,23 @@ var XPIProvider = {
    * newer version already exists or the user has previously uninstalled the
    * distributed add-on.
    *
    * @param {Object} aManifests
    *        A dictionary to add new install manifests to to save having to
    *        reload them later
    * @param {string} [aAppChanged]
    *        See checkForChanges
+   * @param {string?} [aOldAppVersion]
+   *        The version of the application last run with this profile or null
+   *        if it is a new profile or the version is unknown
    * @returns {boolean}
    *        True if any new add-ons were installed
    */
-  installDistributionAddons(aManifests, aAppChanged) {
+  installDistributionAddons(aManifests, aAppChanged, aOldAppVersion) {
     let distroDir;
     try {
       distroDir = FileUtils.getDir(KEY_APP_DISTRIBUTION, [DIR_EXTENSIONS]);
     } catch (e) {
       return false;
     }
 
     let changed = false;
@@ -2601,17 +2604,17 @@ var XPIProvider = {
       /* If this is not an upgrade and we've already handled this extension
        * just continue */
       if (!aAppChanged && Services.prefs.prefHasUserValue(PREF_BRANCH_INSTALLED_ADDON + id)) {
         continue;
       }
 
       try {
         let loc = XPIStates.getLocation(KEY_APP_PROFILE);
-        let addon = awaitPromise(XPIInstall.installDistributionAddon(id, file, loc));
+        let addon = awaitPromise(XPIInstall.installDistributionAddon(id, file, loc, aOldAppVersion));
 
         if (addon) {
           // aManifests may contain a copy of a newly installed add-on's manifest
           // and we'll have overwritten that so instead cache our install manifest
           // which will later be put into the database in processFileChanges
           if (!(loc.name in aManifests))
             aManifests[loc.name] = {};
           aManifests[loc.name][id] = addon;
@@ -2687,17 +2690,17 @@ var XPIProvider = {
     // to the application crashing)
     let hasPendingChanges = Services.prefs.getBoolPref(PREF_PENDING_OPERATIONS, false);
     if (hasPendingChanges) {
       updateReasons.push("hasPendingChanges");
     }
 
     // If the application has changed then check for new distribution add-ons
     if (Services.prefs.getBoolPref(PREF_INSTALL_DISTRO_ADDONS, true)) {
-      updated = this.installDistributionAddons(manifests, aAppChanged);
+      updated = this.installDistributionAddons(manifests, aAppChanged, aOldAppVersion);
       if (updated) {
         updateReasons.push("installDistributionAddons");
       }
     }
 
     // If the schema appears to have changed then we should update the database
     if (DB_SCHEMA != Services.prefs.getIntPref(PREF_DB_SCHEMA, 0)) {
       // If we don't have any add-ons, just update the pref, since we don't need to