diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 9a1dc66b..56317c48 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -227,7 +227,7 @@ if ([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil]) relaunchPath = [targetPath retain]; - [SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously] versionComparator:[self _versionComparator]]; + [SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHost:host delegate:self synchronously:[self shouldInstallSynchronously] versionComparator:[self _versionComparator] updater:updater]; } - (void)installerFinishedForHost:(SUHost *)aHost diff --git a/SUPackageInstaller.m b/SUPackageInstaller.m index 0cdf6542..e007e6bc 100644 --- a/SUPackageInstaller.m +++ b/SUPackageInstaller.m @@ -16,15 +16,29 @@ NSError *error = nil; BOOL result = YES; - NSString *installerPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.installer"]; - installerPath = [installerPath stringByAppendingString:@"/Contents/MacOS/Installer"]; - if (![[NSFileManager defaultManager] fileExistsAtPath:installerPath]) - { - error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple's installer tool!" forKey:NSLocalizedDescriptionKey]]; - result = NO; + NSString* openCommand = @"/usr/bin/open"; + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4 && [[NSFileManager defaultManager] fileExistsAtPath:openCommand]) { + // Using "open" insures that the installer application is brought to the front. + // The -W and -n options were added to the 'open' command in 10.5 + // -W = wait until the app has quit. -n = Open another instance if already open. + // -b = app bundle identifier + NSArray *args = [NSArray arrayWithObjects:@"-W", @"-n", @"-b", @"com.apple.installer", path, nil]; +#ifdef DEBUG + NSLog(@"Runs installer using: %@ %@", openCommand, args); +#endif + NSTask *openTask = [NSTask launchedTaskWithLaunchPath:openCommand arguments:args]; + [openTask waitUntilExit]; + } else { + NSString *installerPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.installer"]; + installerPath = [installerPath stringByAppendingString:@"/Contents/MacOS/Installer"]; + if (![[NSFileManager defaultManager] fileExistsAtPath:installerPath]) + { + error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple's installer tool!" forKey:NSLocalizedDescriptionKey]]; + result = NO; + } + NSTask *installer = [NSTask launchedTaskWithLaunchPath:installerPath arguments:[NSArray arrayWithObjects:path, nil]]; + [installer waitUntilExit]; } - NSTask *installer = [NSTask launchedTaskWithLaunchPath:installerPath arguments:[NSArray arrayWithObjects:path, nil]]; - [installer waitUntilExit]; // Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine. [self _finishInstallationWithResult:result host:host error:error delegate:delegate]; }