зеркало из https://github.com/mozilla/gecko-dev.git
Mac v2 signing - Temporary workaround for Bug 1070148 - Copy maintenance service binary into its install directory when the installed binary is different. r=bbondy
This commit is contained in:
Родитель
ff50e5f369
Коммит
0690c90f12
|
@ -1237,6 +1237,32 @@ function getTestDirFile(aRelPath) {
|
|||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
function getSpecialFolderDir(aCSIDL) {
|
||||
AUS_Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
let lib = ctypes.open("shell32");
|
||||
let SHGetSpecialFolderPath = lib.declare("SHGetSpecialFolderPathW",
|
||||
ctypes.winapi_abi,
|
||||
ctypes.bool, /* bool(return) */
|
||||
ctypes.int32_t, /* HWND hwndOwner */
|
||||
ctypes.char16_t.ptr, /* LPTSTR lpszPath */
|
||||
ctypes.int32_t, /* int csidl */
|
||||
ctypes.bool /* BOOL fCreate */);
|
||||
|
||||
let aryPath = ctypes.char16_t.array()(260);
|
||||
let rv = SHGetSpecialFolderPath(0, aryPath, aCSIDL, false);
|
||||
lib.close();
|
||||
|
||||
let path = aryPath.readString(); // Convert the c-string to js-string
|
||||
if (!path) {
|
||||
return null;
|
||||
}
|
||||
logTestInfo("SHGetSpecialFolderPath returned path: " + path);
|
||||
let dir = AUS_Cc["@mozilla.org/file/local;1"].
|
||||
createInstance(AUS_Ci.nsILocalFile);
|
||||
dir.initWithPath(path);
|
||||
return dir;
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash",
|
||||
function test_gInstallDirPathHash() {
|
||||
// Figure out where we should check for a cached hash value
|
||||
|
@ -1274,51 +1300,13 @@ XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash",
|
|||
XPCOMUtils.defineLazyGetter(this, "gLocalAppDataDir",
|
||||
function test_gLocalAppDataDir() {
|
||||
const CSIDL_LOCAL_APPDATA = 0x1c;
|
||||
|
||||
AUS_Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
let lib = ctypes.open("shell32");
|
||||
let SHGetSpecialFolderPath = lib.declare("SHGetSpecialFolderPathW",
|
||||
ctypes.winapi_abi,
|
||||
ctypes.bool, /* bool(return) */
|
||||
ctypes.int32_t, /* HWND hwndOwner */
|
||||
ctypes.char16_t.ptr, /* LPTSTR lpszPath */
|
||||
ctypes.int32_t, /* int csidl */
|
||||
ctypes.bool /* BOOL fCreate */);
|
||||
|
||||
let aryPathLocalAppData = ctypes.char16_t.array()(260);
|
||||
let rv = SHGetSpecialFolderPath(0, aryPathLocalAppData, CSIDL_LOCAL_APPDATA, false);
|
||||
lib.close();
|
||||
|
||||
let pathLocalAppData = aryPathLocalAppData.readString(); // Convert the c-string to js-string
|
||||
let updatesDir = AUS_Cc["@mozilla.org/file/local;1"].
|
||||
createInstance(AUS_Ci.nsILocalFile);
|
||||
updatesDir.initWithPath(pathLocalAppData);
|
||||
return updatesDir;
|
||||
return getSpecialFolderDir(CSIDL_LOCAL_APPDATA);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gProgFilesDir",
|
||||
function test_gProgFilesDir() {
|
||||
const CSIDL_PROGRAM_FILES = 0x26;
|
||||
|
||||
AUS_Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
let lib = ctypes.open("shell32");
|
||||
let SHGetSpecialFolderPath = lib.declare("SHGetSpecialFolderPathW",
|
||||
ctypes.winapi_abi,
|
||||
ctypes.bool, /* bool(return) */
|
||||
ctypes.int32_t, /* HWND hwndOwner */
|
||||
ctypes.char16_t.ptr, /* LPTSTR lpszPath */
|
||||
ctypes.int32_t, /* int csidl */
|
||||
ctypes.bool /* BOOL fCreate */);
|
||||
|
||||
let aryPathProgFiles = ctypes.char16_t.array()(260);
|
||||
let rv = SHGetSpecialFolderPath(0, aryPathProgFiles, CSIDL_PROGRAM_FILES, false);
|
||||
lib.close();
|
||||
|
||||
let pathProgFiles = aryPathProgFiles.readString(); // Convert the c-string to js-string
|
||||
let progFilesDir = AUS_Cc["@mozilla.org/file/local;1"].
|
||||
createInstance(AUS_Ci.nsILocalFile);
|
||||
progFilesDir.initWithPath(pathProgFiles);
|
||||
return progFilesDir;
|
||||
return getSpecialFolderDir(CSIDL_PROGRAM_FILES);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -1339,7 +1327,7 @@ function getMockUpdRootD() {
|
|||
"\\" + DIR_UPDATES + "\\" + gInstallDirPathHash;
|
||||
}
|
||||
|
||||
if (!relPathUpdates) {
|
||||
if (!relPathUpdates && progFilesDir) {
|
||||
if (appDirPath.length > progFilesDir.path.length) {
|
||||
if (appDirPath.substr(0, progFilesDir.path.length) == progFilesDir.path) {
|
||||
if (MOZ_APP_VENDOR && MOZ_APP_BASENAME) {
|
||||
|
@ -1591,14 +1579,15 @@ function stageUpdate() {
|
|||
*
|
||||
* @param aFirstTest
|
||||
* Whether this is the first test within the test.
|
||||
* @param aSkipTest
|
||||
* Whether to skip this test if the installed maintenance service
|
||||
* isn't the same as the build's maintenance service. This is a
|
||||
* temporary workaround until all build systems grant write access to
|
||||
* the maintenance service install directory so the tests can copy the
|
||||
* version of the maintenance service that should be tests.
|
||||
* @return true if the test should run and false if it shouldn't.
|
||||
*/
|
||||
function shouldRunServiceTest(aFirstTest) {
|
||||
// In case the machine is running an old maintenance service or if it
|
||||
// is not installed, and permissions exist to install it. Then install
|
||||
// the newer bin that we have.
|
||||
attemptServiceInstall();
|
||||
|
||||
function shouldRunServiceTest(aFirstTest, aSkipTest) {
|
||||
let binDir = getGREDir();
|
||||
let updaterBin = binDir.clone();
|
||||
updaterBin.append(FILE_UPDATER_BIN);
|
||||
|
@ -1664,7 +1653,11 @@ function shouldRunServiceTest(aFirstTest) {
|
|||
do_throw("this test can only run on builds with signed binaries.");
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
|
||||
// In case the machine is running an old maintenance service or if it
|
||||
// is not installed, and permissions exist to install it. Then install
|
||||
// the newer bin that we have since all of the other checks passed.
|
||||
return attemptServiceInstall(aSkipTest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1864,27 +1857,86 @@ function copyFileToTestAppDir(aFileRelPath, aDestFileRelPath) {
|
|||
* This is useful for XP where we have permission to upgrade in case an
|
||||
* older service installer exists. Also if the user manually installed into
|
||||
* a unprivileged location.
|
||||
*
|
||||
* @param aSkipTest
|
||||
* Whether to skip this test if the installed maintenance service
|
||||
* isn't the same as the build's maintenance service. This is a
|
||||
* temporary workaround until all build systems grant write access to
|
||||
* the maintenance service install directory so the tests can copy the
|
||||
* version of the maintenance service that should be tests.
|
||||
*/
|
||||
function attemptServiceInstall() {
|
||||
var version = AUS_Cc["@mozilla.org/system-info;1"]
|
||||
.getService(AUS_Ci.nsIPropertyBag2)
|
||||
.getProperty("version");
|
||||
var isVistaOrHigher = (parseFloat(version) >= 6.0);
|
||||
if (isVistaOrHigher) {
|
||||
return;
|
||||
function attemptServiceInstall(aSkipTest) {
|
||||
const CSIDL_PROGRAM_FILES = 0x26;
|
||||
const CSIDL_PROGRAM_FILESX86 = 0x2A;
|
||||
// This will return an empty string on our Win XP build systems.
|
||||
let maintSvcDir = getSpecialFolderDir(CSIDL_PROGRAM_FILESX86);
|
||||
if (maintSvcDir) {
|
||||
maintSvcDir.append("Mozilla Maintenance Service");
|
||||
logTestInfo("using CSIDL_PROGRAM_FILESX86 - maintenance service install " +
|
||||
"directory path: " + maintSvcDir.path);
|
||||
}
|
||||
if (!maintSvcDir || !maintSvcDir.exists()) {
|
||||
maintSvcDir = getSpecialFolderDir(CSIDL_PROGRAM_FILES);
|
||||
if (maintSvcDir) {
|
||||
maintSvcDir.append("Mozilla Maintenance Service");
|
||||
logTestInfo("using CSIDL_PROGRAM_FILES - maintenance service install " +
|
||||
"directory path: " + maintSvcDir.path);
|
||||
}
|
||||
}
|
||||
if (!maintSvcDir || !maintSvcDir.exists()) {
|
||||
do_throw("maintenance service install directory doesn't exist!");
|
||||
}
|
||||
let oldMaintSvcBin = maintSvcDir.clone();
|
||||
oldMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
|
||||
if (!oldMaintSvcBin.exists()) {
|
||||
do_throw("maintenance service install directory binary doesn't exist! " +
|
||||
"Path: " + oldMaintSvcBin.path);
|
||||
}
|
||||
let buildMaintSvcBin = getGREDir();
|
||||
buildMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
|
||||
if (readFileBytes(oldMaintSvcBin) == readFileBytes(buildMaintSvcBin)) {
|
||||
logTestInfo("installed maintenance service binary is the same as the " +
|
||||
"build's maintenance service binary");
|
||||
return true;
|
||||
}
|
||||
let backupMaintSvcBin = maintSvcDir.clone();
|
||||
backupMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN + ".backup");
|
||||
try {
|
||||
if (backupMaintSvcBin.exists()) {
|
||||
backupMaintSvcBin.remove(false);
|
||||
}
|
||||
oldMaintSvcBin.moveTo(maintSvcDir, FILE_MAINTENANCE_SERVICE_BIN + ".backup");
|
||||
buildMaintSvcBin.copyTo(maintSvcDir, FILE_MAINTENANCE_SERVICE_BIN);
|
||||
backupMaintSvcBin.remove(false);
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Restore the original file in case the moveTo was successful.
|
||||
if (backupMaintSvcBin.exists()) {
|
||||
oldMaintSvcBin = maintSvcDir.clone();
|
||||
oldMaintSvcBin.append(FILE_MAINTENANCE_SERVICE_BIN);
|
||||
if (!oldMaintSvcBin.exists()) {
|
||||
backupMaintSvcBin.moveTo(maintSvcDir, FILE_MAINTENANCE_SERVICE_BIN);
|
||||
}
|
||||
}
|
||||
logTestInfo("unable to copy new maintenance service into the " +
|
||||
"maintenance service directory: " + maintSvcDir.path + ", " +
|
||||
"Exception: " + e);
|
||||
}
|
||||
|
||||
let binDir = getGREDir();
|
||||
let installerFile = binDir.clone();
|
||||
installerFile.append(FILE_MAINTENANCE_SERVICE_INSTALLER_BIN);
|
||||
if (!installerFile.exists()) {
|
||||
do_throw(FILE_MAINTENANCE_SERVICE_INSTALLER_BIN + " not found.");
|
||||
let version = AUS_Cc["@mozilla.org/system-info;1"].
|
||||
getService(AUS_Ci.nsIPropertyBag2).
|
||||
getProperty("version");
|
||||
var isWin7OrBelow = (parseFloat(version) <= 6.1);
|
||||
// The account running the tests on Win XP and Win 7 build systems have write
|
||||
// access to the maintenance service directory so throw if copying the
|
||||
// maintenance service binary fails. This should always throw after write
|
||||
// access is provided on all Windows build slaves in bug 1067756.
|
||||
if (isWin7OrBelow) {
|
||||
do_throw("The account running the tests on Win 7 and below build systems " +
|
||||
"should have write access to the maintenance service directory!");
|
||||
}
|
||||
let installerProcess = AUS_Cc["@mozilla.org/process/util;1"].
|
||||
createInstance(AUS_Ci.nsIProcess);
|
||||
installerProcess.init(installerFile);
|
||||
logTestInfo("starting installer process...");
|
||||
installerProcess.run(true, [], 0);
|
||||
|
||||
return aSkipTest ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* General Complete MAR File Staged Patch Apply Test */
|
||||
|
||||
function run_test() {
|
||||
if (!shouldRunServiceTest()) {
|
||||
if (!shouldRunServiceTest(false, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* General Partial MAR File Staged Patch Apply Test */
|
||||
|
||||
function run_test() {
|
||||
if (!shouldRunServiceTest()) {
|
||||
if (!shouldRunServiceTest(false, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче