source: trunk/Sparkle/SUPackageInstaller.m @ 1046

Revision 630, 1.6 KB checked in by speck, 3 years ago (diff)

Sparkle update with latest bug fixes.

Line 
1//
2//  SUPackageInstaller.m
3//  Sparkle
4//
5//  Created by Andy Matuschak on 4/10/08.
6//  Copyright 2008 Andy Matuschak. All rights reserved.
7//
8
9#import "SUPackageInstaller.h"
10
11
12@implementation SUPackageInstaller
13
14+ (void)performInstallationWithPath:(NSString *)path host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator;
15{
16    NSError *error = nil;
17    BOOL result = YES;
18   
19    NSString* openCommand = @"/usr/bin/open";
20    if ([[NSFileManager defaultManager] fileExistsAtPath:openCommand])
21    {
22        // Using "open" insures that the installer application is brought to the front.
23        // The -W and -n options were added to the 'open' command in 10.5
24        // -W = wait until the app has quit.  -n = Open another instance if already open.
25        // -b = app bundle identifier
26        NSArray *args;
27        if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4)
28            args = [NSArray arrayWithObjects:@"-W", @"-n", @"-b", @"com.apple.installer", path, nil]; // 10.5 and later
29        else
30            args = [NSArray arrayWithObjects:@"-b", @"com.apple.installer", path, nil]; // 10.4
31        NSTask *openTask = [NSTask launchedTaskWithLaunchPath:openCommand arguments:args];
32        [openTask waitUntilExit];
33    }
34    else
35    {
36        error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple's installer tool!" forKey:NSLocalizedDescriptionKey]];
37        result = NO;
38    }
39
40    // Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
41    [self _finishInstallationWithResult:result host:host error:error delegate:delegate];
42}
43
44@end
Note: See TracBrowser for help on using the repository browser.