From c267206a18c48925511bd11c46c570d03d0fcd14 Mon Sep 17 00:00:00 2001 From: Stephen Pohl Date: Fri, 23 May 2014 10:42:52 -0400 Subject: [PATCH] Bug 1009668: Make retrieval of updater.ini more robust and predictable on OSX. r=smichaud,rstrong --- .../mozapps/update/updater/launchchild_osx.mm | 29 +++++++------------ toolkit/mozapps/update/updater/updater.cpp | 5 +++- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/toolkit/mozapps/update/updater/launchchild_osx.mm b/toolkit/mozapps/update/updater/launchchild_osx.mm index 78418717103..b4f2374e48c 100644 --- a/toolkit/mozapps/update/updater/launchchild_osx.mm +++ b/toolkit/mozapps/update/updater/launchchild_osx.mm @@ -75,27 +75,18 @@ void LaunchChild(int argc, char **argv) } void -LaunchMacPostProcess(const char* aAppExe) +LaunchMacPostProcess(const char* aAppBundle) { // Launch helper to perform post processing for the update; this is the Mac // analogue of LaunchWinPostProcess (PostUpdateWin). NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // Find the app bundle containing the executable path given - NSString *path = [NSString stringWithUTF8String:aAppExe]; - NSBundle *bundle; - 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 = [NSString stringWithUTF8String:aAppBundle]; + iniPath = + [iniPath stringByAppendingPathComponent:@"Contents/MacOS/updater.ini"]; - NSString *iniPath = [bundle pathForResource:@"updater" ofType:@"ini"]; - if (!iniPath) { + NSFileManager* fileManager = [NSFileManager defaultManager]; + if (![fileManager fileExistsAtPath:iniPath]) { // the file does not exist; there is nothing to run [pool release]; return; @@ -119,9 +110,9 @@ LaunchMacPostProcess(const char* aAppExe) [pool release]; return; } - - NSString *resourcePath = [bundle resourcePath]; - NSString *exeFullPath = [resourcePath stringByAppendingPathComponent:exeRelPath]; + + NSString* exeFullPath = [NSString stringWithUTF8String:aAppBundle]; + exeFullPath = [exeFullPath stringByAppendingPathComponent:exeRelPath]; NSTask *task = [[NSTask alloc] init]; [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 [task release]; - [pool release]; + [pool release]; } diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index 6a77ae9463c..3988cb5f631 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -3173,7 +3173,10 @@ int NS_main(int argc, NS_tchar **argv) #endif /* XP_WIN */ #ifdef XP_MACOSX if (gSucceeded) { - LaunchMacPostProcess(argv[callbackIndex]); + char installDir[MAXPATHLEN]; + if (GetInstallationDir(installDir)) { + LaunchMacPostProcess(installDir); + } } #endif /* XP_MACOSX */