Bug 1551455 - Reinstall distribution language packs. r=kmag a=pascalc FIREFOX_67_0_BUILD2 FIREFOX_67_0_RELEASE
authorMichael Kaply <mozilla@kaply.com>
Fri, 17 May 2019 00:46:16 +0300
changeset 526555 2a7896ba9aa5d982abe01f859d771d411fda8101
parent 526554 5a2f875d59dfec879c080fd7f1e7d1151b8fc086
child 526556 ed997d399d3b9f82ab11ca69d7848ea861516687
push id2043
push userncsoregi@mozilla.com
push dateThu, 16 May 2019 21:52:25 +0000
treeherdermozilla-release@2a7896ba9aa5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, pascalc
bugs1551455
milestone67.0
Bug 1551455 - Reinstall distribution language packs. r=kmag a=pascalc Reviewers: kmag Reviewed By: kmag Subscribers: mossop Bug #: 1551455 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
@@ -3223,20 +3223,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);
@@ -3247,16 +3250,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" });
     addon.rootURI = XPIInternal.getURIForResourceInFile(addon._sourceBundle, "").spec;
 
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -2519,20 +2519,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;
@@ -2551,17 +2554,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;
@@ -2626,17 +2629,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