Mac v2 signing - Bug 1059467 - Move precomplete file from the root of the Mac bundle to Contents/Resources. r=bbondy, r=nthomas
authorRobert Strong <robert.bugzilla@gmail.com>
Mon, 29 Sep 2014 11:51:55 -0700
changeset 207881 d3025e55dfc3ac40fdedd1344799bd55ff8d2806
parent 207880 c6e905b1e209ed4f628bffafc7d0d25dab28c331
child 207882 432ef1ab72b0eab9ea1f2a16daac6c128ebb3323
push id27569
push usercbook@mozilla.com
push dateTue, 30 Sep 2014 13:14:19 +0000
treeherdermozilla-central@2ae57957e4bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy, nthomas
bugs1059467
milestone35.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
Mac v2 signing - Bug 1059467 - Move precomplete file from the root of the Mac bundle to Contents/Resources. r=bbondy, r=nthomas
config/createprecomplete.py
toolkit/mozapps/update/updater/updater.cpp
tools/update-packaging/make_full_update.sh
tools/update-packaging/make_incremental_update.sh
tools/update-packaging/make_incremental_updates.py
tools/update-packaging/test/from-mac/Contents/Resources/precomplete
tools/update-packaging/test/from-mac/precomplete
tools/update-packaging/test/make_full_update.sh
tools/update-packaging/test/to-mac/Contents/MacOS/precomplete
tools/update-packaging/test/to-mac/Contents/Resources/precomplete
tools/update-packaging/test/to-mac/precomplete
--- a/config/createprecomplete.py
+++ b/config/createprecomplete.py
@@ -39,24 +39,27 @@ def get_build_entries(root_path):
 
     return rel_file_path_list, rel_dir_path_list
 
 def generate_precomplete(root_path):
     """ Creates the precomplete file containing the remove and rmdir
         application update instructions. The given directory is used
         for the location to enumerate and to create the precomplete file.
     """
+    rel_path_precomplete = "precomplete"
     # If inside a Mac bundle use the root of the bundle for the path.
     if os.path.basename(root_path) == "Resources":
         root_path = os.path.abspath(os.path.join(root_path, '../../'))
+        rel_path_precomplete = "Contents/Resources/precomplete"
 
+    precomplete_file_path = os.path.join(root_path,rel_path_precomplete)
+    # Open the file so it exists before building the list of files and open it
+    # in binary mode to prevent OS specific line endings.
+    precomplete_file = open(precomplete_file_path, "wb")
     rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
-    precomplete_file_path = os.path.join(root_path,"precomplete")
-    # open in binary mode to prevent OS specific line endings.
-    precomplete_file = open(precomplete_file_path, "wb")
     for rel_file_path in rel_file_path_list:
         precomplete_file.writelines("remove \""+rel_file_path+"\"\n")
 
     for rel_dir_path in rel_dir_path_list:
         precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")
 
     precomplete_file.close()
 
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -2085,53 +2085,18 @@ ProcessReplaceRequest()
       }
     }
 
     NS_tclosedir(dir);
   } else {
     LOG(("Updated.app dir can't be found: " LOG_S ", err: %d",
          updatedAppDir, errno));
   }
+
   ensure_remove_recursive(updatedAppDir);
-
-  LOG(("Moving the precomplete file"));
-
-  // We also need to move the precomplete file too.
-  NS_tchar precompleteSource[MAXPATHLEN];
-  NS_tsnprintf(precompleteSource, sizeof(precompleteSource)/sizeof(precompleteSource[0]),
-               NS_T("%s/precomplete"), installDir);
-
-  NS_tchar precompleteTmp[MAXPATHLEN];
-  NS_tsnprintf(precompleteTmp, sizeof(precompleteTmp)/sizeof(precompleteTmp[0]),
-               NS_T("%s/precomplete.bak"), installDir);
-
-  NS_tchar precompleteNew[MAXPATHLEN];
-  NS_tsnprintf(precompleteNew, sizeof(precompleteNew)/sizeof(precompleteNew[0]),
-               NS_T("%s/Updated.app/precomplete"), installDir);
-
-  ensure_remove(precompleteTmp);
-  LOG(("Begin moving precompleteSrc to precompleteTmp"));
-  rv = rename_file(precompleteSource, precompleteTmp);
-  LOG(("Moved precompleteSrc to precompleteTmp, err: %d", rv));
-  LOG(("Begin moving precompleteNew to precompleteSrc"));
-  int rv2 = rename_file(precompleteNew, precompleteSource);
-  LOG(("Moved precompleteNew to precompleteSrc, err: %d", rv2));
-
-  // If new could not be moved to source, we only want to restore tmp to source
-  // if the first step succeeded.  Note that it is possible for the first
-  // rename to have failed as well, for example if the tmpFile exists and we
-  // race between the ensure_remove call and the first rename call, but there
-  // isn't too much that we can do about that, unfortunately.
-  if (!rv && rv2) {
-    LOG(("Begin trying to recover precompleteSrc"));
-    rv = rename_file(precompleteTmp, precompleteSource);
-    LOG(("Moved precompleteTmp to precompleteSrc, err: %d", rv));
-  }
-
-  LOG(("Finished moving the precomplete file"));
 #endif
 
   gSucceeded = true;
 
   return 0;
 }
 
 #ifdef XP_WIN
@@ -3634,17 +3599,21 @@ GetManifestContents(const NS_tchar *mani
 }
 
 int AddPreCompleteActions(ActionList *list)
 {
   if (sIsOSUpdate) {
     return OK;
   }
 
+#ifdef XP_MACOSX
+  NS_tchar *rb = GetManifestContents(NS_T("Contents/Resources/precomplete"));
+#else
   NS_tchar *rb = GetManifestContents(NS_T("precomplete"));
+#endif
   if (rb == nullptr) {
     LOG(("AddPreCompleteActions: error getting contents of precomplete " \
          "manifest"));
     // Applications aren't required to have a precomplete manifest. The mar
     // generation scripts enforce the presence of a precomplete manifest.
     return OK;
   }
 
--- a/tools/update-packaging/make_full_update.sh
+++ b/tools/update-packaging/make_full_update.sh
@@ -44,28 +44,27 @@ if [ $(echo "$targetdir" | grep -c '\/$'
 fi
 workdir="$targetdir.work"
 updatemanifestv2="$workdir/updatev2.manifest"
 updatemanifestv3="$workdir/updatev3.manifest"
 targetfiles="updatev2.manifest updatev3.manifest"
 
 mkdir -p "$workdir"
 
-# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
-# Info.plist so it launches the right architecture, bug 600098
-
 # Generate a list of all files in the target directory.
 pushd "$targetdir"
 if test $? -ne 0 ; then
   exit 1
 fi
 
 if [ ! -f "precomplete" ]; then
-  notice "precomplete file is missing!"
-  exit 1
+  if [ ! -f "Contents/Resources/precomplete" ]; then
+    notice "precomplete file is missing!"
+    exit 1
+  fi
 fi
 
 list_files files
 
 popd
 
 # Add the type of update to the beginning of the update manifests.
 > $updatemanifestv2
--- a/tools/update-packaging/make_incremental_update.sh
+++ b/tools/update-packaging/make_incremental_update.sh
@@ -30,16 +30,21 @@ check_for_forced_update() {
 
   local f
 
   if [ "$forced_file_chk" = "precomplete" ]; then
     ## "true" *giggle*
     return 0;
   fi
 
+  if [ "$forced_file_chk" = "Contents/Resources/precomplete" ]; then
+    ## "true" *giggle*
+    return 0;
+  fi
+
   if [ "${forced_file_chk##*.}" = "chk" ]
   then
     ## "true" *giggle*
     return 0;
   fi
 
   for f in $force_list; do
     #echo comparing $forced_file_chk to $f
@@ -87,19 +92,16 @@ if [ $(echo "$newdir" | grep -c '\/$') =
 fi
 workdir="$newdir.work"
 updatemanifestv2="$workdir/updatev2.manifest"
 updatemanifestv3="$workdir/updatev3.manifest"
 archivefiles="updatev2.manifest updatev3.manifest"
 
 mkdir -p "$workdir"
 
-# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
-# Info.plist so it launches the right architecture, bug 600098
-
 # Generate a list of all files in the target directory.
 pushd "$olddir"
 if test $? -ne 0 ; then
   exit 1
 fi
 
 list_files oldfiles
 list_dirs olddirs
@@ -107,18 +109,20 @@ list_dirs olddirs
 popd
 
 pushd "$newdir"
 if test $? -ne 0 ; then
   exit 1
 fi
 
 if [ ! -f "precomplete" ]; then
-  notice "precomplete file is missing!"
-  exit 1
+  if [ ! -f "Contents/Resources/precomplete" ]; then
+    notice "precomplete file is missing!"
+    exit 1
+  fi
 fi
 
 list_dirs newdirs
 list_files newfiles
 
 popd
 
 # Add the type of update to the beginning of the update manifests.
--- a/tools/update-packaging/make_incremental_updates.py
+++ b/tools/update-packaging/make_incremental_updates.py
@@ -331,22 +331,30 @@ def process_explicit_remove_files(dir_pa
 def create_partial_patch(from_dir_path, to_dir_path, patch_filename, shas, patch_info, forced_updates, add_if_not_list):
     """ Builds a partial patch by comparing the files in from_dir_path to those of to_dir_path"""
     # Cannocolize the paths for safey
     from_dir_path = os.path.abspath(from_dir_path)
     to_dir_path = os.path.abspath(to_dir_path)
     # Create a hashtable of the from  and to directories
     from_dir_hash,from_file_set,from_dir_set = patch_info.build_marfile_entry_hash(from_dir_path)
     to_dir_hash,to_file_set,to_dir_set = patch_info.build_marfile_entry_hash(to_dir_path)
+    # Create a list of the forced updates 
+    forced_list = forced_updates.strip().split('|')
     # Require that the precomplete file is included in the complete update
     if "precomplete" not in to_file_set:
-        raise Exception, "missing precomplete file in: "+to_dir_path
-    # Create a list of the forced updates 
-    forced_list = forced_updates.strip().split('|')
-    forced_list.append("precomplete")
+        # The check with \ file separators allows tests for Mac to run on Windows
+        if "Contents/Resources/precomplete" not in to_file_set and "Contents\Resources\precomplete" not in to_file_set:
+            raise Exception, "missing precomplete file in: "+to_dir_path
+        else:
+            if "Contents/Resources/precomplete" in to_file_set:
+                forced_list.append("Contents/Resources/precomplete")
+            else:
+                forced_list.append("Contents\Resources\precomplete")
+    else:
+        forced_list.append("precomplete")
 
     # Files which exist in both sets need to be patched
     patch_filenames = list(from_file_set.intersection(to_file_set))
     patch_filenames.sort(reverse=True)
     for filename in patch_filenames:
         from_marfile_entry = from_dir_hash[filename]
         to_marfile_entry = to_dir_hash[filename]
         if os.path.basename(filename) in add_if_not_list:
rename from tools/update-packaging/test/from-mac/precomplete
rename to tools/update-packaging/test/from-mac/Contents/Resources/precomplete
--- a/tools/update-packaging/test/from-mac/precomplete
+++ b/tools/update-packaging/test/from-mac/Contents/Resources/precomplete
@@ -1,9 +1,8 @@
-remove "precomplete"
 remove "Contents/MacOS/{foodir/update.manifest"
 remove "Contents/MacOS/{foodir/same.txt"
 remove "Contents/MacOS/{foodir/same.bin"
 remove "Contents/MacOS/{foodir/removed.txt"
 remove "Contents/MacOS/{foodir/readme.txt"
 remove "Contents/MacOS/{foodir/force.txt"
 remove "Contents/MacOS/{foodir/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/update.manifest"
@@ -11,15 +10,17 @@ remove "Contents/MacOS/searchplugins/dif
 remove "Contents/MacOS/same.txt"
 remove "Contents/MacOS/same.bin"
 remove "Contents/MacOS/removed.txt"
 remove "Contents/MacOS/readme.txt"
 remove "Contents/MacOS/force.txt"
 remove "Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/application.ini"
+remove "Contents/Resources/precomplete"
 rmdir "Contents/MacOS/{foodir/"
 rmdir "Contents/MacOS/searchplugins/diff/"
 rmdir "Contents/MacOS/searchplugins/"
 rmdir "Contents/MacOS/extensions/diff/"
 rmdir "Contents/MacOS/extensions/"
 rmdir "Contents/MacOS/"
+rmdir "Contents/Resources/"
 rmdir "Contents/"
--- a/tools/update-packaging/test/make_full_update.sh
+++ b/tools/update-packaging/test/make_full_update.sh
@@ -45,28 +45,27 @@ if [ $(echo "$targetdir" | grep -c '\/$'
 fi
 workdir="$targetdir.work"
 updatemanifestv2="$workdir/updatev2.manifest"
 updatemanifestv3="$workdir/updatev3.manifest"
 targetfiles="updatev2.manifest updatev3.manifest"
 
 mkdir -p "$workdir"
 
-# On Mac, the precomplete file added by Bug 386760 will cause OS X to reload the
-# Info.plist so it launches the right architecture, bug 600098
-
 # Generate a list of all files in the target directory.
 pushd "$targetdir"
 if test $? -ne 0 ; then
   exit 1
 fi
 
 if [ ! -f "precomplete" ]; then
-  notice "precomplete file is missing!"
-  exit 1
+  if [ ! -f "Contents/Resources/precomplete" ]; then
+    notice "precomplete file is missing!"
+    exit 1
+  fi
 fi
 
 list_files files
 
 popd
 
 # Add the type of update to the beginning of the update manifests.
 > $updatemanifestv2
deleted file mode 100644
--- a/tools/update-packaging/test/to-mac/Contents/MacOS/precomplete
+++ /dev/null
@@ -1,19 +0,0 @@
-remove "Contents/MacOS/{foodir/update.manifest"
-remove "Contents/MacOS/{foodir/same.txt"
-remove "Contents/MacOS/{foodir/same.bin"
-remove "Contents/MacOS/{foodir/readme.txt"
-remove "Contents/MacOS/{foodir/force.txt"
-remove "Contents/MacOS/{foodir/diff-patch-larger-than-file.txt"
-remove "Contents/MacOS/update.manifest"
-remove "Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt"
-remove "Contents/MacOS/same.txt"
-remove "Contents/MacOS/same.bin"
-remove "Contents/MacOS/removed-files"
-remove "Contents/MacOS/readme.txt"
-remove "Contents/MacOS/precomplete"
-remove "Contents/MacOS/force.txt"
-remove "Contents/MacOS/diff-patch-larger-than-file.txt"
-rmdir "Contents/MacOS/{foodir/"
-rmdir "Contents/MacOS/searchplugins/diff/"
-rmdir "Contents/MacOS/searchplugins/added/"
-rmdir "Contents/MacOS/searchplugins/"
rename from tools/update-packaging/test/to-mac/precomplete
rename to tools/update-packaging/test/to-mac/Contents/Resources/precomplete
--- a/tools/update-packaging/test/to-mac/precomplete
+++ b/tools/update-packaging/test/to-mac/Contents/Resources/precomplete
@@ -1,33 +1,33 @@
-remove "precomplete"
 remove "Contents/MacOS/{foodir/update.manifest"
 remove "Contents/MacOS/{foodir/same.txt"
 remove "Contents/MacOS/{foodir/same.bin"
 remove "Contents/MacOS/{foodir/readme.txt"
 remove "Contents/MacOS/{foodir/force.txt"
 remove "Contents/MacOS/{foodir/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/{foodir/added.txt"
 remove "Contents/MacOS/update.manifest"
 remove "Contents/MacOS/searchplugins/diff/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/searchplugins/added/file.txt"
 remove "Contents/MacOS/same.txt"
 remove "Contents/MacOS/same.bin"
 remove "Contents/MacOS/removed-files"
 remove "Contents/MacOS/readme.txt"
-remove "Contents/MacOS/precomplete"
 remove "Contents/MacOS/force.txt"
 remove "Contents/MacOS/extensions/diff/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/extensions/added/file.txt"
 remove "Contents/MacOS/diff-patch-larger-than-file.txt"
 remove "Contents/MacOS/diff-patch-larger-than-file.bin"
 remove "Contents/MacOS/application.ini"
 remove "Contents/MacOS/added.txt"
 remove "Contents/MacOS/addFeedPrefs.js"
+remove "Contents/Resources/precomplete"
 rmdir "Contents/MacOS/{foodir/"
 rmdir "Contents/MacOS/searchplugins/diff/"
 rmdir "Contents/MacOS/searchplugins/added/"
 rmdir "Contents/MacOS/searchplugins/"
 rmdir "Contents/MacOS/extensions/diff/"
 rmdir "Contents/MacOS/extensions/added/"
 rmdir "Contents/MacOS/extensions/"
 rmdir "Contents/MacOS/"
+rmdir "Contents/Resources/"
 rmdir "Contents/"