Bug 1009668: Make retrieval of updater.ini more robust and predictable on OSX. r=smichaud,rstrong

This commit is contained in:
Stephen Pohl 2014-05-23 10:42:52 -04:00
parent 3d1a60d674
commit c267206a18
2 changed files with 14 additions and 20 deletions

View File

@ -75,27 +75,18 @@ void LaunchChild(int argc, char **argv)
} }
void void
LaunchMacPostProcess(const char* aAppExe) LaunchMacPostProcess(const char* aAppBundle)
{ {
// Launch helper to perform post processing for the update; this is the Mac // Launch helper to perform post processing for the update; this is the Mac
// analogue of LaunchWinPostProcess (PostUpdateWin). // analogue of LaunchWinPostProcess (PostUpdateWin).
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Find the app bundle containing the executable path given NSString* iniPath = [NSString stringWithUTF8String:aAppBundle];
NSString *path = [NSString stringWithUTF8String:aAppExe]; iniPath =
NSBundle *bundle; [iniPath stringByAppendingPathComponent:@"Contents/MacOS/updater.ini"];
do {
path = [path stringByDeletingLastPathComponent];
bundle = [NSBundle bundleWithPath:path];
} while ((!bundle || ![bundle bundleIdentifier]) && [path length] > 1);
if (!bundle) {
// No bundle found for the app being launched
[pool release];
return;
}
NSString *iniPath = [bundle pathForResource:@"updater" ofType:@"ini"]; NSFileManager* fileManager = [NSFileManager defaultManager];
if (!iniPath) { if (![fileManager fileExistsAtPath:iniPath]) {
// the file does not exist; there is nothing to run // the file does not exist; there is nothing to run
[pool release]; [pool release];
return; return;
@ -119,9 +110,9 @@ LaunchMacPostProcess(const char* aAppExe)
[pool release]; [pool release];
return; return;
} }
NSString *resourcePath = [bundle resourcePath]; NSString* exeFullPath = [NSString stringWithUTF8String:aAppBundle];
NSString *exeFullPath = [resourcePath stringByAppendingPathComponent:exeRelPath]; exeFullPath = [exeFullPath stringByAppendingPathComponent:exeRelPath];
NSTask *task = [[NSTask alloc] init]; NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:exeFullPath]; [task setLaunchPath:exeFullPath];
@ -131,6 +122,6 @@ LaunchMacPostProcess(const char* aAppExe)
// ignore the return value of the task, there's nothing we can do with it // ignore the return value of the task, there's nothing we can do with it
[task release]; [task release];
[pool release]; [pool release];
} }

View File

@ -3173,7 +3173,10 @@ int NS_main(int argc, NS_tchar **argv)
#endif /* XP_WIN */ #endif /* XP_WIN */
#ifdef XP_MACOSX #ifdef XP_MACOSX
if (gSucceeded) { if (gSucceeded) {
LaunchMacPostProcess(argv[callbackIndex]); char installDir[MAXPATHLEN];
if (GetInstallationDir(installDir)) {
LaunchMacPostProcess(installDir);
}
} }
#endif /* XP_MACOSX */ #endif /* XP_MACOSX */