mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Mac v2 signing - Bug 1068439 - Move the distribution directory from Content/MacOS to Contents/Resources on app update due to v2 signing requirements. r=spohl
This commit is contained in:
parent
898c627c71
commit
1b2658d18f
@ -654,61 +654,6 @@ var gTestFilesPartialSuccess = [
|
||||
// Concatenate the common files to the end of the array.
|
||||
gTestFilesPartialSuccess = gTestFilesPartialSuccess.concat(gTestFilesCommon);
|
||||
|
||||
/**
|
||||
* The mar files used for the updater tests contain the following remove
|
||||
* operations.
|
||||
*
|
||||
* partial and complete test mar remove operations
|
||||
* -----------------------------------------------
|
||||
* remove "text1"
|
||||
* remove "text0"
|
||||
* rmrfdir "9/99/"
|
||||
* rmdir "9/99/"
|
||||
* rmrfdir "9/98/"
|
||||
* rmrfdir "9/97/"
|
||||
* rmrfdir "9/96/"
|
||||
* rmrfdir "9/95/"
|
||||
* rmrfdir "9/95/"
|
||||
* rmrfdir "9/94/"
|
||||
* rmdir "9/94/"
|
||||
* rmdir "9/93/"
|
||||
* rmdir "9/92/"
|
||||
* rmdir "9/91/"
|
||||
* rmdir "9/90/"
|
||||
* rmdir "9/90/"
|
||||
* rmrfdir "8/89/"
|
||||
* rmdir "8/89/"
|
||||
* rmrfdir "8/88/"
|
||||
* rmrfdir "8/87/"
|
||||
* rmrfdir "8/86/"
|
||||
* rmrfdir "8/85/"
|
||||
* rmrfdir "8/85/"
|
||||
* rmrfdir "8/84/"
|
||||
* rmdir "8/84/"
|
||||
* rmdir "8/83/"
|
||||
* rmdir "8/82/"
|
||||
* rmdir "8/81/"
|
||||
* rmdir "8/80/"
|
||||
* rmdir "8/80/"
|
||||
* rmrfdir "7/"
|
||||
* rmdir "6/"
|
||||
* remove "5/text1"
|
||||
* remove "5/text0"
|
||||
* rmrfdir "5/"
|
||||
* remove "4/text1"
|
||||
* remove "4/text0"
|
||||
* remove "4/exe0.exe"
|
||||
* rmdir "4/"
|
||||
* remove "3/text1"
|
||||
* remove "3/text0"
|
||||
*
|
||||
* partial test mar additional remove operations
|
||||
* ---------------------------------------------
|
||||
* remove "0/00/00text1"
|
||||
* remove "1/10/10text0"
|
||||
* rmdir "1/10/"
|
||||
* rmdir "1/"
|
||||
*/
|
||||
var gTestDirsCommon = [
|
||||
{
|
||||
relPathDir : DIR_RESOURCES + "3/",
|
||||
@ -1112,6 +1057,21 @@ function setTestFilesAndDirsForFailure() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for updater binary tests that prevents the distribution
|
||||
* directory files from being created.
|
||||
*/
|
||||
function preventDistributionFiles() {
|
||||
gTestFiles = gTestFiles.filter(function(aTestFile) {
|
||||
return aTestFile.relPathDir.indexOf("distribution/") == -1;
|
||||
});
|
||||
|
||||
gTestDirs = gTestDirs.filter(function(aTestDir) {
|
||||
return aTestDir.relPathDir.indexOf("distribution/") == -1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the most commonly used settings and creates an instance of the
|
||||
* update service stub.
|
||||
@ -2386,8 +2346,11 @@ function createUpdaterINI(aIsExeAsync) {
|
||||
*
|
||||
* @param aCompareLogFile
|
||||
* The log file to compare the update log with.
|
||||
* @param aExcludeDistributionDir
|
||||
* Removes lines containing the distribution directory from the log
|
||||
* file to compare the update log with.
|
||||
*/
|
||||
function checkUpdateLogContents(aCompareLogFile) {
|
||||
function checkUpdateLogContents(aCompareLogFile, aExcludeDistributionDir) {
|
||||
if (IS_UNIX && !IS_MACOSX) {
|
||||
// Sorting on Linux is different so skip checking the logs for now.
|
||||
return;
|
||||
@ -2422,16 +2385,14 @@ function checkUpdateLogContents(aCompareLogFile) {
|
||||
updateLogContents = updateLogContents.replace(/WORKING DIRECTORY.*/g, "");
|
||||
// Skip lines that log failed attempts to open the callback executable.
|
||||
updateLogContents = updateLogContents.replace(/NS_main: callback app file .*/g, "");
|
||||
if (IS_MACOSX) {
|
||||
// Skip lines that log moving the distribution directory for Mac v2 signing.
|
||||
updateLogContents = updateLogContents.replace(/Moving old [^\n]*\nrename_file: .*/g, "");
|
||||
updateLogContents = updateLogContents.replace(/New distribution directory .*/g, "");
|
||||
}
|
||||
if (gSwitchApp) {
|
||||
// Remove the lines which contain absolute paths
|
||||
updateLogContents = updateLogContents.replace(/^Begin moving.*$/mg, "");
|
||||
if (IS_MACOSX) {
|
||||
// Remove the entire section about moving the precomplete file as it contains
|
||||
// absolute paths.
|
||||
updateLogContents = updateLogContents.replace(/\n/g, "%%%EOL%%%");
|
||||
updateLogContents = updateLogContents.replace(/Moving the precomplete file.*Finished moving the precomplete file/, "");
|
||||
updateLogContents = updateLogContents.replace(/%%%EOL%%%/g, "\n");
|
||||
}
|
||||
}
|
||||
updateLogContents = updateLogContents.replace(/\r/g, "");
|
||||
// Replace error codes since they are different on each platform.
|
||||
@ -2468,6 +2429,9 @@ function checkUpdateLogContents(aCompareLogFile) {
|
||||
!gTestFiles[gTestFiles.length - 2].originalContents) {
|
||||
compareLogContents = compareLogContents.replace(/.*update-settings.ini.*/g, "");
|
||||
}
|
||||
if (aExcludeDistributionDir) {
|
||||
compareLogContents = compareLogContents.replace(/.*distribution\/.*/g, "");
|
||||
}
|
||||
// Remove leading and trailing newlines
|
||||
compareLogContents = compareLogContents.replace(/\n+/g, "\n");
|
||||
// Remove leading and trailing newlines
|
||||
|
@ -14,6 +14,15 @@ function run_test() {
|
||||
gTestFiles[gTestFiles.length - 1].comparePerms = 0o644;
|
||||
gTestDirs = gTestDirsCompleteSuccess;
|
||||
setupUpdaterTest(FILE_COMPLETE_MAR);
|
||||
if (IS_MACOSX) {
|
||||
// Create files in the old distribution directory location to verify that
|
||||
// the directory and its contents are removed when there is a distribution
|
||||
// directory in the new location.
|
||||
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
testFile = getApplyDirFile(DIR_MACOS + "distribution/test1/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
}
|
||||
|
||||
createUpdaterINI(false);
|
||||
|
||||
@ -93,6 +102,17 @@ function finishCheckUpdateApplied() {
|
||||
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
|
||||
}
|
||||
|
||||
if (IS_MACOSX) {
|
||||
logTestInfo("testing that the distribution directory is removed from the " +
|
||||
"old location when there is a distribution directory in the " +
|
||||
"new location");
|
||||
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
|
||||
checkUpdateLogContains("removing old distribution directory");
|
||||
}
|
||||
|
||||
if (IS_UNIX && !IS_MACOSX) {
|
||||
checkSymlink();
|
||||
}
|
||||
|
@ -13,7 +13,16 @@ function run_test() {
|
||||
gTestFiles[gTestFiles.length - 2].compareContents = "FromPartial\n";
|
||||
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
|
||||
gTestDirs = gTestDirsPartialSuccess;
|
||||
preventDistributionFiles();
|
||||
setupUpdaterTest(FILE_PARTIAL_MAR);
|
||||
if (IS_MACOSX) {
|
||||
// Create files in the old distribution directory location to verify that
|
||||
// the directory and its contents are moved to the new location on update.
|
||||
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
}
|
||||
|
||||
createUpdaterINI(false);
|
||||
|
||||
@ -30,7 +39,7 @@ function run_test() {
|
||||
runUpdate(0, STATE_APPLIED, null);
|
||||
|
||||
checkFilesAfterUpdateSuccess(getStageDirFile, true, false);
|
||||
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
|
||||
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
|
||||
|
||||
if (IS_WIN || IS_MACOSX) {
|
||||
// Check that the post update process was not launched when staging an
|
||||
@ -73,7 +82,34 @@ function finishCheckUpdateApplied() {
|
||||
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
|
||||
}
|
||||
|
||||
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
|
||||
if (IS_MACOSX) {
|
||||
logTestInfo("testing that the distribution directory is moved from the " +
|
||||
"old location to the new location");
|
||||
logTestInfo("testing " + distributionDir.path + " should exist");
|
||||
do_check_true(distributionDir.exists());
|
||||
|
||||
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
|
||||
logTestInfo("testing " + testFile.path + " should exist");
|
||||
do_check_true(testFile.exists());
|
||||
|
||||
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
|
||||
logTestInfo("testing " + testFile.path + " should exist");
|
||||
do_check_true(testFile.exists());
|
||||
|
||||
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
|
||||
checkUpdateLogContains("Moving old distribution directory to new location");
|
||||
} else {
|
||||
logTestInfo("testing that files aren't added with an add-if instruction " +
|
||||
"when the file's destination directory doesn't exist");
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
}
|
||||
|
||||
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
|
||||
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
|
||||
checkUpdateLogContents(LOG_PARTIAL_SUCCESS, true);
|
||||
checkCallbackAppLog();
|
||||
}
|
||||
|
@ -9,7 +9,16 @@ function run_test() {
|
||||
setupTestCommon();
|
||||
gTestFiles = gTestFilesCompleteSuccess;
|
||||
gTestDirs = gTestDirsCompleteSuccess;
|
||||
preventDistributionFiles();
|
||||
setupUpdaterTest(FILE_COMPLETE_MAR);
|
||||
if (IS_MACOSX) {
|
||||
// Create files in the old distribution directory location to verify that
|
||||
// the directory and its contents are moved to the new location on update.
|
||||
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
}
|
||||
|
||||
createUpdaterINI();
|
||||
|
||||
@ -53,7 +62,34 @@ function finishCheckUpdateApplied() {
|
||||
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
|
||||
}
|
||||
|
||||
let distributionDir = getApplyDirFile(DIR_RESOURCES + "distribution", true);
|
||||
if (IS_MACOSX) {
|
||||
logTestInfo("testing that the distribution directory is moved from the " +
|
||||
"old location to the new location");
|
||||
logTestInfo("testing " + distributionDir.path + " should exist");
|
||||
do_check_true(distributionDir.exists());
|
||||
|
||||
let testFile = getApplyDirFile(DIR_RESOURCES + "distribution/testFile", true);
|
||||
logTestInfo("testing " + testFile.path + " should exist");
|
||||
do_check_true(testFile.exists());
|
||||
|
||||
testFile = getApplyDirFile(DIR_RESOURCES + "distribution/test/testFile", true);
|
||||
logTestInfo("testing " + testFile.path + " should exist");
|
||||
do_check_true(testFile.exists());
|
||||
|
||||
distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
|
||||
checkUpdateLogContains("Moving old distribution directory to new location");
|
||||
} else {
|
||||
logTestInfo("testing that files aren't added with an add-if instruction " +
|
||||
"when the file's destination directory doesn't exist");
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
}
|
||||
|
||||
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
|
||||
checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
|
||||
checkUpdateLogContents(LOG_COMPLETE_SUCCESS, true);
|
||||
checkCallbackAppLog();
|
||||
}
|
||||
|
@ -16,6 +16,15 @@ function run_test() {
|
||||
gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
|
||||
gTestDirs = gTestDirsPartialSuccess;
|
||||
setupUpdaterTest(FILE_PARTIAL_MAR);
|
||||
if (IS_MACOSX) {
|
||||
// Create files in the old distribution directory location to verify that
|
||||
// the directory and its contents are removed when there is a distribution
|
||||
// directory in the new location.
|
||||
let testFile = getApplyDirFile(DIR_MACOS + "distribution/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
testFile = getApplyDirFile(DIR_MACOS + "distribution/test/testFile", true);
|
||||
writeFile(testFile, "test\n");
|
||||
}
|
||||
|
||||
createUpdaterINI(true);
|
||||
|
||||
@ -59,6 +68,17 @@ function finishCheckUpdateApplied() {
|
||||
do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
|
||||
}
|
||||
|
||||
if (IS_MACOSX) {
|
||||
logTestInfo("testing that the distribution directory is removed from the " +
|
||||
"old location when there is a distribution directory in the " +
|
||||
"new location");
|
||||
let distributionDir = getApplyDirFile(DIR_MACOS + "distribution", true);
|
||||
logTestInfo("testing " + distributionDir.path + " shouldn't exist");
|
||||
do_check_false(distributionDir.exists());
|
||||
|
||||
checkUpdateLogContains("removing old distribution directory");
|
||||
}
|
||||
|
||||
checkFilesAfterUpdateSuccess(getApplyDirFile, false, false);
|
||||
checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
|
||||
checkCallbackAppLog();
|
||||
|
@ -2678,12 +2678,12 @@ int NS_main(int argc, NS_tchar **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't want to use the service at all, or if an update was
|
||||
// already happening, or launching the service command failed, then
|
||||
// If we didn't want to use the service at all, or if an update was
|
||||
// already happening, or launching the service command failed, then
|
||||
// launch the elevated updater.exe as we do without the service.
|
||||
// We don't launch the elevated updater in the case that we did have
|
||||
// write access all along because in that case the only reason we're
|
||||
// using the service is because we are testing.
|
||||
// using the service is because we are testing.
|
||||
if (!useService && !noServiceFallback &&
|
||||
updateLockFileHandle == INVALID_HANDLE_VALUE) {
|
||||
SHELLEXECUTEINFO sinfo;
|
||||
@ -3020,6 +3020,40 @@ int NS_main(int argc, NS_tchar **argv)
|
||||
} // end the extra level of scope for the GonkAutoMounter
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// When the update is successful move the distribution directory from
|
||||
// Contents/MacOS to Contents/Resources and if both exist delete the
|
||||
// directory under Contents/MacOS (see Bug 1068439).
|
||||
if (gSucceeded) {
|
||||
NS_tchar oldDistDir[MAXPATHLEN];
|
||||
NS_tsnprintf(oldDistDir, sizeof(oldDistDir)/sizeof(oldDistDir[0]),
|
||||
NS_T("%s/Contents/MacOS/distribution"), gInstallDirPath);
|
||||
int rv = NS_taccess(oldDistDir, F_OK);
|
||||
if (!rv) {
|
||||
NS_tchar newDistDir[MAXPATHLEN];
|
||||
NS_tsnprintf(newDistDir, sizeof(newDistDir)/sizeof(newDistDir[0]),
|
||||
NS_T("%s/Contents/Resources/distribution"), gInstallDirPath);
|
||||
rv = NS_taccess(newDistDir, F_OK);
|
||||
if (!rv) {
|
||||
LOG(("New distribution directory already exists... removing old " \
|
||||
"distribution directory: " LOG_S, oldDistDir));
|
||||
rv = ensure_remove_recursive(oldDistDir);
|
||||
if (rv) {
|
||||
LOG(("Removing old distribution directory failed - err: %d", rv));
|
||||
}
|
||||
} else {
|
||||
LOG(("Moving old distribution directory to new location. src: " LOG_S \
|
||||
", dst:" LOG_S, oldDistDir, newDistDir));
|
||||
rv = rename_file(oldDistDir, newDistDir, true);
|
||||
if (rv) {
|
||||
LOG(("Moving old distribution directory to new location failed - " \
|
||||
"err: %d", rv));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
LogFinish();
|
||||
|
||||
if (argc > callbackIndex) {
|
||||
|
Loading…
Reference in New Issue
Block a user