[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-102.9.0esr-12.5-1] 4 commits: fixup! Bug 4234: Use the Firefox Update Process for Tor Browser.

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Mon Mar 20 13:41:13 UTC 2023



Pier Angelo Vendrame pushed to branch tor-browser-102.9.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
9eac9235 by Pier Angelo Vendrame at 2023-03-20T14:38:14+01:00
fixup! Bug 4234: Use the Firefox Update Process for Tor Browser.

Bug 41668: Port some updater patches to Base Browser

Changes that will need to remain when actually cherry-picking to
base-browser, because they contain name fixes, for example.
Or, for UpdateService.jsm, they need to stay because they make the patch
more understandable.

- - - - -
cfc8f07d by Pier Angelo Vendrame at 2023-03-20T14:38:23+01:00
fixup! Bug 4234: Use the Firefox Update Process for Tor Browser.

Bug 41668: Port some updater patches to Base Browser

Remove Tor Browser-only additions to make the updater patches usable
with Base Browser.
This commit should be reverted, and become a commit on its own, to
further adapt the updater to Tor Browser needs.

- - - - -
648dd29f by Pier Angelo Vendrame at 2023-03-20T14:38:24+01:00
Bug 41668: Tweaks to the Base Browser updater for Tor Browser

This commit was once part of "Bug 4234: Use the Firefox Update Process
for Tor Browser.".
However, some parts of it were not needed for Base Browser and some
derivative browsers.
Therefore, we extracted from that commit the parts for Tor Browser
legacy, and we add them back to the patch set with this commit.

- - - - -
e5e872d6 by Kathy Brade at 2023-03-20T14:38:24+01:00
Bug 12647: Support symlinks in the updater.

- - - - -


11 changed files:

- browser/components/BrowserContentHandler.jsm
- build/moz.configure/init.configure
- toolkit/modules/UpdateUtils.jsm
- toolkit/mozapps/extensions/AddonManager.jsm
- toolkit/mozapps/update/UpdateService.jsm
- toolkit/mozapps/update/UpdateServiceStub.jsm
- toolkit/mozapps/update/common/updatehelper.cpp
- toolkit/xre/nsAppRunner.cpp
- toolkit/xre/nsUpdateDriver.cpp
- toolkit/xre/nsXREDirProvider.cpp
- tools/update-packaging/make_incremental_update.sh


Changes:

=====================================
browser/components/BrowserContentHandler.jsm
=====================================
@@ -37,7 +37,7 @@ XPCOMUtils.defineLazyGetter(this, "gSystemPrincipal", () =>
 );
 XPCOMUtils.defineLazyGlobalGetters(this, [URL]);
 
-const kTBSavedVersionPref =
+const FORK_VERSION_PREF =
   "browser.startup.homepage_override.torbrowser.version";
 
 // One-time startup homepage override configurations
@@ -103,8 +103,8 @@ const OVERRIDE_NEW_BUILD_ID = 3;
  * Returns:
  *  OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
  *  OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
- *                      Gecko milestone or Tor Browser version (i.e. right
- *                      after an upgrade).
+ *                      Gecko milestone or fork version (i.e. right after an
+ *                      upgrade).
  *  OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
  *                        same Gecko milestone (i.e. after a nightly upgrade).
  *  OVERRIDE_NONE otherwise.
@@ -121,7 +121,7 @@ function needHomepageOverride(prefb) {
 
   var mstone = Services.appinfo.platformVersion;
 
-  var savedTBVersion = prefb.getCharPref(kTBSavedVersionPref, null);
+  var savedForkVersion = prefb.getCharPref(FORK_VERSION_PREF, null);
 
   var savedBuildID = prefb.getCharPref(
     "browser.startup.homepage_override.buildID",
@@ -144,20 +144,13 @@ function needHomepageOverride(prefb) {
 
     prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
-    prefb.setCharPref(kTBSavedVersionPref, AppConstants.BASE_BROWSER_VERSION);
-
-    // After an upgrade from an older release of Tor Browser (<= 5.5a1), the
-    // savedmstone will be undefined because those releases included the
-    // value "ignore" for the browser.startup.homepage_override.mstone pref.
-    // To correctly detect an upgrade vs. a new profile, we check for the
-    // presence of the "app.update.postupdate" pref.
-    let updated = prefb.prefHasUserValue("app.update.postupdate");
-    return savedmstone || updated ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
+    prefb.setCharPref(FORK_VERSION_PREF, AppConstants.BASE_BROWSER_VERSION);
+    return savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
   }
 
-  if (AppConstants.BASE_BROWSER_VERSION != savedTBVersion) {
+  if (AppConstants.BASE_BROWSER_VERSION != savedForkVersion) {
     prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
-    prefb.setCharPref(kTBSavedVersionPref, AppConstants.BASE_BROWSER_VERSION);
+    prefb.setCharPref(FORK_VERSION_PREF, AppConstants.BASE_BROWSER_VERSION);
     return OVERRIDE_NEW_MSTONE;
   }
 
@@ -689,8 +682,8 @@ nsBrowserContentHandler.prototype = {
         "unknown"
       );
 
-      // We do the same for the Tor Browser version.
-      let old_tbversion = prefb.getCharPref(kTBSavedVersionPref, null);
+      // We do the same for the fork version.
+      let old_forkVersion = prefb.getCharPref(FORK_VERSION_PREF, null);
 
       override = needHomepageOverride(prefb);
       if (override != OVERRIDE_NONE) {
@@ -728,7 +721,7 @@ nsBrowserContentHandler.prototype = {
               "startup.homepage_override_url"
             );
             let update = UpdateManager.readyUpdate;
-            let old_version = old_tbversion ? old_tbversion : old_mstone;
+            let old_version = old_forkVersion ? old_forkVersion : old_mstone;
             if (
               update &&
               Services.vc.compare(update.appVersion, old_version) > 0
@@ -740,8 +733,8 @@ nsBrowserContentHandler.prototype = {
 
             overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
             overridePage = overridePage.replace(
-              "%OLD_TOR_BROWSER_VERSION%",
-              old_tbversion
+              "%OLD_BASE_BROWSER_VERSION%",
+              old_forkVersion
             );
             if (overridePage && AppConstants.BASE_BROWSER_UPDATE) {
               prefb.setCharPref("torbrowser.post_update.url", overridePage);


=====================================
build/moz.configure/init.configure
=====================================
@@ -954,10 +954,10 @@ def version_path(path):
     return path
 
 
-# set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
-# The logic works like this:
-# - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
-# - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
+# Firefox looks for "a" or "a1" in the milestone to detect whether nightly
+# features should be enabled. We do not want them, because we want our nightly
+# builds to be as close as possible to actual releases.
+# So we set always is_release_or_beta to True.
 @depends(build_environment, build_project, version_path, "--help")
 @imports(_from="__builtin__", _import="open")
 @imports("os")
@@ -1001,10 +1001,8 @@ def milestone(build_env, build_project, version_path, _):
 
     is_nightly = is_release_or_beta = is_early_beta_or_earlier = None
 
-    if "a1" in milestone:
-        is_nightly = True
-    else:
-        is_release_or_beta = True
+    # Do not enable extra nightly features
+    is_release_or_beta = True
 
     major_version = milestone.split(".")[0]
     m = re.search(r"([ab]\d+)", milestone)


=====================================
toolkit/modules/UpdateUtils.jsm
=====================================
@@ -167,8 +167,8 @@ var UpdateUtils = {
    * downloads and installs updates. This corresponds to whether or not the user
    * has selected "Automatically install updates" in about:preferences.
    *
-   * On Windows (except in Tor Browser), this setting is shared across all profiles
-   * for the installation
+   * On Windows (except in Base Browser and derivatives), this setting is shared
+   * across all profiles for the installation
    * and is read asynchronously from the file. On other operating systems, this
    * setting is stored in a pref and is thus a per-profile setting.
    *
@@ -184,8 +184,8 @@ var UpdateUtils = {
    * updates" and "Check for updates but let you choose to install them" options
    * in about:preferences.
    *
-   * On Windows (except in Tor Browser), this setting is shared across all profiles
-   * for the installation
+   * On Windows (except in Base Browser and derivatives), this setting is shared
+   * across all profiles for the installation
    * and is written asynchronously to the file. On other operating systems, this
    * setting is stored in a pref and is thus a per-profile setting.
    *


=====================================
toolkit/mozapps/extensions/AddonManager.jsm
=====================================
@@ -40,7 +40,7 @@ const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
 const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
 const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
 const PREF_REMOTESETTINGS_DISABLED = "extensions.remoteSettings.disabled";
-const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
+const PREF_EM_LAST_FORK_VERSION = "extensions.lastTorBrowserVersion";
 
 const PREF_MIN_WEBEXT_PLATFORM_VERSION =
   "extensions.webExtensionsMinPlatformVersion";
@@ -645,26 +645,19 @@ var AddonManagerInternal = {
         );
       }
 
-      // To ensure that extension and plugin code gets a chance to run
-      // after each browser update, set appChanged = true when the
-      // Tor Browser version has changed even if the Mozilla app
-      // version has not changed.
-      let tbChanged = undefined;
-      try {
-        tbChanged =
-          AppConstants.BASE_BROWSER_VERSION !==
-          Services.prefs.getCharPref(PREF_EM_LAST_TORBROWSER_VERSION);
-      } catch (e) {}
-      if (tbChanged !== false) {
-        // Because PREF_EM_LAST_TORBROWSER_VERSION was not present in older
-        // versions of Tor Browser, an app change is indicated when tbChanged
-        // is undefined or true.
+      // To ensure that extension and plugin code gets a chance to run after
+      // each browser update, set appChanged = true when BASE_BROWSER_VERSION
+      // has changed even if the Mozilla app version has not changed.
+      const forkChanged = AppConstants.BASE_BROWSER_VERSION !==
+        Services.prefs.getCharPref(PREF_EM_LAST_FORK_VERSION, "");
+      if (forkChanged) {
+        // appChanged could be undefined (in case of a new profile)
         if (appChanged === false) {
           appChanged = true;
         }
 
         Services.prefs.setCharPref(
-          PREF_EM_LAST_TORBROWSER_VERSION,
+          PREF_EM_LAST_FORK_VERSION,
           AppConstants.BASE_BROWSER_VERSION
         );
       }


=====================================
toolkit/mozapps/update/UpdateService.jsm
=====================================
@@ -1587,33 +1587,32 @@ function handleUpdateFailure(update, errorCode) {
     );
     cancelations++;
     Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations);
-    if (AppConstants.platform == "macosx") {
-      if (AppConstants.BASE_BROWSER_UPDATE) {
-        cleanupActiveUpdates();
+    if (AppConstants.platform == "macosx" && AppConstants.BASE_BROWSER_UPDATE) {
+      cleanupActiveUpdates();
+      update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
+    } else if (AppConstants.platform == "macosx") {
+      let osxCancelations = Services.prefs.getIntPref(
+        PREF_APP_UPDATE_CANCELATIONS_OSX,
+        0
+      );
+      osxCancelations++;
+      Services.prefs.setIntPref(
+        PREF_APP_UPDATE_CANCELATIONS_OSX,
+        osxCancelations
+      );
+      let maxCancels = Services.prefs.getIntPref(
+        PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
+        DEFAULT_CANCELATIONS_OSX_MAX
+      );
+      // Prevent the preference from setting a value greater than 5.
+      maxCancels = Math.min(maxCancels, 5);
+      if (osxCancelations >= maxCancels) {
+        cleanupReadyUpdate();
       } else {
-        let osxCancelations = Services.prefs.getIntPref(
-          PREF_APP_UPDATE_CANCELATIONS_OSX,
-          0
-        );
-        osxCancelations++;
-        Services.prefs.setIntPref(
-          PREF_APP_UPDATE_CANCELATIONS_OSX,
-          osxCancelations
+        writeStatusFile(
+          getReadyUpdateDir(),
+          (update.state = STATE_PENDING_ELEVATE)
         );
-        let maxCancels = Services.prefs.getIntPref(
-          PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
-          DEFAULT_CANCELATIONS_OSX_MAX
-        );
-        // Prevent the preference from setting a value greater than 5.
-        maxCancels = Math.min(maxCancels, 5);
-        if (osxCancelations >= maxCancels) {
-          cleanupReadyUpdate();
-        } else {
-          writeStatusFile(
-            getReadyUpdateDir(),
-            (update.state = STATE_PENDING_ELEVATE)
-          );
-        }
       }
       update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
     } else {


=====================================
toolkit/mozapps/update/UpdateServiceStub.jsm
=====================================
@@ -80,8 +80,9 @@ function UpdateServiceStub() {
   // contains the status file's path
 
   // We may need to migrate update data
-  // In Tor Browser we skip this because we do not use an update agent and we
-  // do not want to store any data outside of the browser installation directory.
+  // In Base Browser and derivatives, we skip this because we do not use an
+  // update agent and we do not want to store any data outside of the browser
+  // installation directory.
   // For more info, see https://bugzilla.mozilla.org/show_bug.cgi?id=1458314
   if (
     AppConstants.platform == "win" &&


=====================================
toolkit/mozapps/update/common/updatehelper.cpp
=====================================
@@ -68,8 +68,8 @@ BOOL PathGetSiblingFilePath(LPWSTR destinationBuffer, LPCWSTR siblingFilePath,
 BOOL GetSecureOutputDirectoryPath(LPWSTR outBuf) {
 #ifdef BASE_BROWSER_UPDATE
   // This function is used to support the maintenance service and elevated
-  // updates and is therefore not called by Tor Browser's updater. We stub
-  // it out to avoid any chance that the Tor Browser updater will create
+  // updates and is therefore not called by Base Browser's updater. We stub
+  // it out to avoid any chance that the Base Browser updater will create
   // files under C:\Program Files (x86)\ or a similar location.
   return FALSE;
 #else


=====================================
toolkit/xre/nsAppRunner.cpp
=====================================
@@ -3657,9 +3657,9 @@ static bool CheckCompatibility(nsIFile* aProfileDir, const nsCString& aVersion,
 
   nsAutoCString buf;
 
-  nsAutoCString tbVersion(BASE_BROWSER_VERSION_QUOTED);
+  nsAutoCString forkVersion(BASE_BROWSER_VERSION_QUOTED);
   rv = parser.GetString("Compatibility", "LastTorBrowserVersion", buf);
-  if (NS_FAILED(rv) || !tbVersion.Equals(buf)) return false;
+  if (NS_FAILED(rv) || !forkVersion.Equals(buf)) return false;
 
   rv = parser.GetString("Compatibility", "LastOSABI", buf);
   if (NS_FAILED(rv) || !aOSABI.Equals(buf)) return false;
@@ -3746,11 +3746,11 @@ static void WriteVersion(nsIFile* aProfileDir, const nsCString& aVersion,
   PR_Write(fd, kHeader, sizeof(kHeader) - 1);
   PR_Write(fd, aVersion.get(), aVersion.Length());
 
-  nsAutoCString tbVersion(BASE_BROWSER_VERSION_QUOTED);
-  static const char kTorBrowserVersionHeader[] =
+  nsAutoCString forkVersion(BASE_BROWSER_VERSION_QUOTED);
+  static const char kForkVersionHeader[] =
       NS_LINEBREAK "LastTorBrowserVersion=";
-  PR_Write(fd, kTorBrowserVersionHeader, sizeof(kTorBrowserVersionHeader) - 1);
-  PR_Write(fd, tbVersion.get(), tbVersion.Length());
+  PR_Write(fd, kForkVersionHeader, sizeof(kForkVersionHeader) - 1);
+  PR_Write(fd, forkVersion.get(), forkVersion.Length());
 
   static const char kOSABIHeader[] = NS_LINEBREAK "LastOSABI=";
   PR_Write(fd, kOSABIHeader, sizeof(kOSABIHeader) - 1);


=====================================
toolkit/xre/nsUpdateDriver.cpp
=====================================
@@ -87,7 +87,7 @@ static void UpdateDriverSetupMacCommandLine(int& argc, char**& argv,
   // result from it, so we can't just dispatch and return, we have to wait
   // until the dispatched operation actually completes. So we also set up a
   // monitor to signal us when that happens, and block until then.
-  Monitor monitor("nsUpdateDriver SetupMacCommandLine");
+  Monitor monitor MOZ_UNANNOTATED("nsUpdateDriver SetupMacCommandLine");
 
   nsresult rv = NS_DispatchToMainThread(NS_NewRunnableFunction(
       "UpdateDriverSetupMacCommandLine",


=====================================
toolkit/xre/nsXREDirProvider.cpp
=====================================
@@ -1213,20 +1213,27 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult,
   NS_ENSURE_SUCCESS(rv, rv);
 
 #if defined(BASE_BROWSER_UPDATE)
-  // For Tor Browser, we store update history, etc. within the UpdateInfo
-  // directory under the user data directory.
-  rv = GetTorBrowserUserDataDir(getter_AddRefs(updRoot));
+  nsCOMPtr<nsIFile> dataDir;
+  // For Base Browser and derivatives, we store update history, etc. within the
+  // UpdateInfo directory under the user data directory.
+#  if defined(ANDROID)
+#    error "The Base Browser updater is not supported on Android."
+#  else
+  rv = GetUserDataDirectoryHome(getter_AddRefs(dataDir), false);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = dataDir->GetParent(getter_AddRefs(updRoot));
   NS_ENSURE_SUCCESS(rv, rv);
+#  endif
   rv = updRoot->AppendNative("UpdateInfo"_ns);
   NS_ENSURE_SUCCESS(rv, rv);
+
 #  if defined(XP_MACOSX)
-  // Since the TorBrowser-Data directory may be shared among different
-  // installations of the application, embed the app path in the update dir
-  // so that the update history is partitioned. This is much less likely to
-  // be an issue on Linux or Windows because the Tor Browser packages for
-  // those platforms include a "container" folder that provides partitioning
-  // by default, and we do not support use of a shared, OS-recommended area
-  // for user data on those platforms.
+  // Since the data directory may be shared among different installations of the
+  // application, embed the app path in the update dir so that the update
+  // history is partitioned. This is much less likely to be an issue on Linux or
+  // Windows, because our packages for those platforms include a "container"
+  // folder that provides partitioning by default, and we do not support use of
+  // a shared, OS-recommended area for user data on those platforms.
   nsAutoString appPath;
   rv = appFile->GetPath(appPath);
   NS_ENSURE_SUCCESS(rv, rv);


=====================================
tools/update-packaging/make_incremental_update.sh
=====================================
@@ -79,7 +79,7 @@ if [ $# = 0 ]; then
 fi
 
 # Firefox uses requested_forced_updates='Contents/MacOS/firefox Contents/Resources/defaults/pref/channel-prefs.js'
-# - 'Contents/MacOS/firefox' is required for Bugzilla 770996 but in Tor Browser we do not need that fix.
+# - 'Contents/MacOS/firefox' is required for Bugzilla 770996 but Base Browser and derivatives do not need that fix.
 # - 'Contents/Resources/defaults/pref/channel-prefs.js' is required for 1804303 to avoid a failed code signing signature
 #   check on macOS aarch64; it is unlikely that users will run into this issue but there's no harm in including it
 requested_forced_updates="Contents/Resources/defaults/pref/channel-prefs.js"



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d41e60a210e81539032f13833fc2efbc54943ae7...e5e872d60887666c9deaaf3d20cb261936861796

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d41e60a210e81539032f13833fc2efbc54943ae7...e5e872d60887666c9deaaf3d20cb261936861796
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20230320/a559b851/attachment-0001.htm>


More information about the tbb-commits mailing list