Mac v2 signing - Bug 1075169: Disable update staging on OSX when Firefox isn't installed on the primary Volume. r=rstrong
☠☠ backed out by 4097945f9f96 ☠ ☠
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Tue, 30 Sep 2014 15:10:20 -0700
changeset 491298 79f6dc04c45a4491b09d0b1a15660def6b162ffd
parent 491297 a99dd012283f80d5840ec5ac0a11e1fc63124474
child 491299 4097945f9f96ec2948a766bf32dee0d8e4d1a314
push id47343
push userbmo:dothayer@mozilla.com
push dateWed, 01 Mar 2017 22:58:58 +0000
reviewersrstrong
bugs1075169
milestone35.0a1
Mac v2 signing - Bug 1075169: Disable update staging on OSX when Firefox isn't installed on the primary Volume. r=rstrong
toolkit/mozapps/update/nsUpdateService.js
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -745,17 +745,29 @@ function getCanStageUpdates() {
    */
   XPCOMUtils.defineLazyGetter(this, "canStageUpdatesSession", function canStageUpdatesSession() {
     try {
       var updateTestFile = getInstallDirRoot();
       updateTestFile.append(FILE_PERMS_TEST);
       LOG("canStageUpdatesSession - testing write access " +
           updateTestFile.path);
       testWriteAccess(updateTestFile, true);
-#ifndef XP_MACOSX
+#ifdef XP_MACOSX
+      var rootParent;
+      var tmpParent = updateTestFile.parent;
+      while (tmpParent && tmpParent.parent) {
+        rootParent = tmpParent;
+        tmpParent = tmpParent.parent;
+      }
+      let volumesPath = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+      volumesPath.initWithPath("/Volumes");
+      if (rootParent.equals(volumesPath)) {
+        return false;
+      }
+#else
       // On all platforms except Mac, we need to test the parent directory as
       // well, as we need to be able to move files in that directory during the
       // replacing step.
       updateTestFile = getInstallDirRoot().parent;
       updateTestFile.append(FILE_PERMS_TEST);
       LOG("canStageUpdatesSession - testing write access " +
           updateTestFile.path);
       updateTestFile.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE,
@@ -911,17 +923,16 @@ function getAppBaseDir() {
  * bundle directory on Mac OS X and the location of the application binary
  * on all other platforms.
  *
  * @return nsIFile object for the directory
  */
 function getInstallDirRoot() {
   var dir = getAppBaseDir();
 #ifdef XP_MACOSX
-  // On Mac, we store the Updated.app directory inside the bundle directory.
   dir = dir.parent.parent;
 #endif
   return dir;
 }
 
 /**
  * Gets the file at the specified hierarchy under the update root directory.
  * @param   pathArray
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -2172,18 +2172,17 @@ UpdateThreadFunc(void *param)
     // updater application again in order to apply the update without
     // staging.
     // The MOZ_NO_REPLACE_FALLBACK environment variable is used to
     // bypass this fallback, and is used in the updater tests.
     // The only special thing which we should do here is to remove the
     // staged directory as it won't be useful any more.
     ensure_remove_recursive(gWorkingDirPath);
     WriteStatusFile(sUsingService ? "pending-service" : "pending");
-    char processUpdates[] = "MOZ_PROCESS_UPDATES=";
-    putenv(processUpdates); // We need to use -process-updates again in the tests
+    putenv(const_cast<char*>("MOZ_PROCESS_UPDATES=")); // We need to use -process-updates again in the tests
     reportRealResults = false; // pretend success
   }
 
   if (reportRealResults) {
     if (rv) {
       LOG(("failed: %d", rv));
     }
     else {