Files
Sparkle/SUPackageInstaller.m
T
andym 0e997002d1 Added fetching of CFBundleName as a fallback for CFBundleDisplayName in -[NSBundle(SUAdditions) name].
Fixed an uninitialized variable.
Fixed autorelease pool errors during installation thread.
Fixed error including SUInstaller.h from host app.
Patch courtesy Ben Kazez.
2008-04-29 05:10:20 +00:00

33 lines
1.2 KiB
Objective-C

//
// SUPackageInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPackageInstaller.h"
@implementation SUPackageInstaller
+ (void)installPath:(NSString *)path overHostBundle:(NSBundle *)bundle delegate:delegate
{
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;
}
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 hostBundle:bundle error:error delegate:delegate];
}
@end