Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mac v2 signing - Bug 1059467 - Move precomplete file from the root of…
… the Mac bundle to Contents/Resources. r=bbondy, r=nthomas

--HG--
rename : tools/update-packaging/test/from-mac/precomplete => tools/update-packaging/test/from-mac/Contents/Resources/precomplete
rename : tools/update-packaging/test/to-mac/precomplete => tools/update-packaging/test/to-mac/Contents/Resources/precomplete
  • Loading branch information
Robert Strong committed Sep 29, 2014
1 parent 81d559a commit 2230b39
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 80 deletions.
9 changes: 6 additions & 3 deletions config/createprecomplete.py
Expand Up @@ -44,14 +44,17 @@ def generate_precomplete(root_path):
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"

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_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)
for rel_file_path in rel_file_path_list:
precomplete_file.writelines("remove \""+rel_file_path+"\"\n")

Expand Down
41 changes: 5 additions & 36 deletions toolkit/mozapps/update/updater/updater.cpp
Expand Up @@ -2090,43 +2090,8 @@ ProcessReplaceRequest()
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"));
ensure_remove_recursive(updatedAppDir);
#endif

gSucceeded = true;
Expand Down Expand Up @@ -3639,7 +3604,11 @@ int AddPreCompleteActions(ActionList *list)
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"));
Expand Down
9 changes: 4 additions & 5 deletions tools/update-packaging/make_full_update.sh
Expand Up @@ -49,18 +49,17 @@ 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
Expand Down
14 changes: 9 additions & 5 deletions tools/update-packaging/make_incremental_update.sh
Expand Up @@ -35,6 +35,11 @@ check_for_forced_update() {
return 0;
fi

if [ "$forced_file_chk" = "Contents/Resources/precomplete" ]; then
## "true" *giggle*
return 0;
fi

if [ "${forced_file_chk##*.}" = "chk" ]
then
## "true" *giggle*
Expand Down Expand Up @@ -92,9 +97,6 @@ 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
Expand All @@ -112,8 +114,10 @@ if test $? -ne 0 ; then
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
Expand Down
16 changes: 12 additions & 4 deletions tools/update-packaging/make_incremental_updates.py
Expand Up @@ -336,12 +336,20 @@ def create_partial_patch(from_dir_path, to_dir_path, patch_filename, shas, patch
# 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)
# 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")
# Require that the precomplete file is included in the complete update
if "precomplete" not in to_file_set:
# 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))
Expand Down
@@ -1,4 +1,3 @@
remove "precomplete"
remove "Contents/MacOS/{foodir/update.manifest"
remove "Contents/MacOS/{foodir/same.txt"
remove "Contents/MacOS/{foodir/same.bin"
Expand All @@ -16,10 +15,12 @@ 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/"
9 changes: 4 additions & 5 deletions tools/update-packaging/test/make_full_update.sh
Expand Up @@ -50,18 +50,17 @@ 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
Expand Down
19 changes: 0 additions & 19 deletions tools/update-packaging/test/to-mac/Contents/MacOS/precomplete

This file was deleted.

@@ -1,4 +1,3 @@
remove "precomplete"
remove "Contents/MacOS/{foodir/update.manifest"
remove "Contents/MacOS/{foodir/same.txt"
remove "Contents/MacOS/{foodir/same.bin"
Expand All @@ -13,7 +12,6 @@ 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"
Expand All @@ -22,6 +20,7 @@ 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/"
Expand All @@ -30,4 +29,5 @@ rmdir "Contents/MacOS/extensions/diff/"
rmdir "Contents/MacOS/extensions/added/"
rmdir "Contents/MacOS/extensions/"
rmdir "Contents/MacOS/"
rmdir "Contents/Resources/"
rmdir "Contents/"

0 comments on commit 2230b39

Please sign in to comment.