mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge pull request #377 from grahammiln/guided-pkg-install
Added headless guided package installation
This commit is contained in:
commit
4d6d766a21
4 files changed
+364
-10
No files matched your search
@@ -167,6 +167,9 @@
|
||||
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
|
||||
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
|
||||
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
|
||||
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; };
|
||||
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
|
||||
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -531,6 +534,8 @@
|
||||
61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
|
||||
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
|
||||
767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGuidedPackageInstaller.h; sourceTree = "<group>"; };
|
||||
767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = "<group>"; };
|
||||
8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = "<group>"; };
|
||||
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkDebug.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -859,6 +864,8 @@
|
||||
618FA5040DAE8AB80026945C /* SUPlainInstaller.m */,
|
||||
6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */,
|
||||
61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */,
|
||||
767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */,
|
||||
767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */,
|
||||
);
|
||||
name = Installation;
|
||||
sourceTree = "<group>";
|
||||
@@ -1002,6 +1009,7 @@
|
||||
6196CFF909C72148000DC222 /* SUStatusController.h in Headers */,
|
||||
61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */,
|
||||
61B93A3C0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.h in Headers */,
|
||||
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */,
|
||||
61299A8D09CA790200B7442F /* SUUnarchiver.h in Headers */,
|
||||
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */,
|
||||
61B5FCDF09C52A9F00B25A18 /* SUUpdateAlert.h in Headers */,
|
||||
@@ -1375,6 +1383,7 @@
|
||||
55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */,
|
||||
55C14F20136EF84300649790 /* SUStatusController.m in Sources */,
|
||||
55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */,
|
||||
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */,
|
||||
55C14F2A136EF9A900649790 /* SUWindowController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1435,6 +1444,7 @@
|
||||
618FA5020DAE88B40026945C /* SUInstaller.m in Sources */,
|
||||
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
|
||||
618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */,
|
||||
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */,
|
||||
61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */,
|
||||
618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */,
|
||||
61B5F8EF09C4CE3C00B25A18 /* SUPlainInstallerInternals.m in Sources */,
|
||||
|
||||
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// SUGuidedPackageInstaller.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Graham Miln on 14/05/2010.
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
/*!
|
||||
# Sparkle Guided Installations
|
||||
|
||||
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
|
||||
|
||||
A guided installation occurs when Sparkle finds a `.sparkle_guide.plist` in the root of the download; the file contains the relative path of the installer package to install.
|
||||
|
||||
The file must be a property list and have a dictionary root. The only required key pair value is `package`.
|
||||
|
||||
The `package` key value pair must be set to a relative path to the package or multi-package to install. The path is relative to the guide file.
|
||||
|
||||
Example Contents of Sparkle Guide file:
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>package</key>
|
||||
<string>My Package.pkg</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Example Path of Sparkle Guide file:
|
||||
|
||||
/Volumes/MyUpdateDiskImage/.sparkle_guide.plist
|
||||
|
||||
The installer package is installed using Mac OS X's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
||||
|
||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
||||
|
||||
## Notes
|
||||
This method has been tested and successfully deployed on Mac OS X 10.4 - 10.8.
|
||||
|
||||
## To Do
|
||||
- Replace the use of `AuthorizationExecuteWithPrivilegesAndWait`. This method remains because it is well supported and tested. Ideally a helper tool or XPC would be used.
|
||||
*/
|
||||
|
||||
#ifndef SUGUIDEDPACKAGEINSTALLER_H
|
||||
#define SUGUIDEDPACKAGEINSTALLER_H
|
||||
|
||||
#import "Sparkle.h"
|
||||
#import "SUInstaller.h"
|
||||
|
||||
extern NSString* SUInstallerGuidedInstallerFilename; // default filename for guided installer property list
|
||||
|
||||
@interface SUGuidedPackageInstaller : SUInstaller { }
|
||||
/*! Search for and return any installer guide */
|
||||
+ (NSString *)installerGuideWithinUpdateFolder:(NSString *)updateFolder;
|
||||
|
||||
/*! Perform the guided installation */
|
||||
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>)comparator;
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
+272
@@ -0,0 +1,272 @@
|
||||
//
|
||||
// SUGuidedPackageInstaller.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Graham Miln on 14/05/2010.
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
#import <sys/stat.h>
|
||||
#import <Security/Security.h>
|
||||
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
|
||||
NSString* SUInstallerGuidedInstallerFilename = @".sparkle_guide.plist"; // top level file to search for within update folder
|
||||
|
||||
// Constants
|
||||
static NSString* SUGuidedPackageInstallerKeyGuidePath = @"SUGuidedPackageInstallerKeyGuidePath"; // NSString*
|
||||
static NSString* SUGuidedPackageInstallerKeyGuide = @"SUGuidedPackageInstallerKeyGuide"; // NSDictionary*
|
||||
static NSString* SUGuidedPackageInstallerKeyHost = @"SUGuidedPackageInstallerKeyHost"; // SUHost*
|
||||
static NSString* SUGuidedPackageInstallerKeyDelegate = @"SUGuidedPackageInstallerKeyDelegate"; // id
|
||||
static NSString* SUGuidedPackageInstallerKeyResult = @"SUGuidedPackageInstallerKeyResult"; // NSNumber[bool]
|
||||
static NSString* SUGuidedPackageInstallerKeyError = @"SUGuidedPackageInstallerKeyError"; // NSError*
|
||||
|
||||
static NSString* SUGuidedPackageInstallerGuideKeyPackage = @"package"; // NSString*
|
||||
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
|
||||
{
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
|
||||
/* AuthorizationExecuteWithPrivileges used to support 10.4+; should be replaced with XPC or external process */
|
||||
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess)
|
||||
{
|
||||
int status = 0;
|
||||
pid_t pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
returnValue = NO;
|
||||
}
|
||||
else
|
||||
returnValue = NO;
|
||||
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@interface SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
|
||||
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath;
|
||||
@end
|
||||
|
||||
@interface SUGuidedPackageInstaller (SUGuidedPackageInstallerThreads)
|
||||
// Perform the installation script
|
||||
+ (void)performInstallationWithInfo:(NSDictionary *)theInfo;
|
||||
// Complete the installation process
|
||||
+ (void)finishInstallationWithInfo:(NSDictionary *)theInfo;
|
||||
@end
|
||||
|
||||
@implementation SUGuidedPackageInstaller
|
||||
|
||||
// Search for and return any installer guide
|
||||
+ (NSString *)installerGuideWithinUpdateFolder:(NSString *)updateFolder
|
||||
{
|
||||
NSParameterAssert(updateFolder);
|
||||
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:updateFolder];
|
||||
NSString *currentFile;
|
||||
while ((currentFile = [dirEnum nextObject]))
|
||||
{
|
||||
if ([[currentFile lastPathComponent] isEqualToString:SUInstallerGuidedInstallerFilename])
|
||||
{
|
||||
// Found an installer guide
|
||||
return [updateFolder stringByAppendingPathComponent:currentFile];
|
||||
}
|
||||
}
|
||||
|
||||
// No guide found
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *) __unused path fromPath:(NSString *)installerGuide host:(SUHost *)host delegate:delegate synchronously:(BOOL)synchronously versionComparator:(id <SUVersionComparison>) __unused comparator
|
||||
{
|
||||
NSParameterAssert(installerGuide);
|
||||
NSParameterAssert(host);
|
||||
|
||||
// Fetch the contents of the guide
|
||||
NSDictionary* guide = [NSDictionary dictionaryWithContentsOfFile:installerGuide];
|
||||
if (guide == nil)
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Installer guide contents are malformed '%@'.",installerGuide];
|
||||
NSError* error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
[self finishInstallationToPath:installerGuide withResult:NO host:host error:error delegate:delegate];
|
||||
return;
|
||||
}
|
||||
|
||||
// Sanity check the contents of the guide
|
||||
if ([guide objectForKey:SUGuidedPackageInstallerGuideKeyPackage] == NO)
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Installer guide is missing '%@' entry.",SUGuidedPackageInstallerGuideKeyPackage];
|
||||
NSError* error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
[self finishInstallationToPath:installerGuide withResult:NO host:host error:error delegate:delegate];
|
||||
return;
|
||||
}
|
||||
|
||||
// Package up installation details to allow for synchronous installation
|
||||
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
installerGuide,SUGuidedPackageInstallerKeyGuidePath,
|
||||
guide,SUGuidedPackageInstallerKeyGuide,
|
||||
host,SUGuidedPackageInstallerKeyHost,
|
||||
delegate,SUGuidedPackageInstallerKeyDelegate,
|
||||
nil];
|
||||
|
||||
if (synchronously)
|
||||
{
|
||||
[self performInstallationWithInfo:info];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSThread detachNewThreadSelector:@selector(performInstallationWithInfo:) toTarget:self withObject:info];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
|
||||
|
||||
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
|
||||
{
|
||||
NSParameterAssert(executablePath);
|
||||
|
||||
// Get authorization using advice in Apple's Technical Q&A1172
|
||||
|
||||
// ...create authorization without specific rights
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus validAuth = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
// ...then extend authorization with desired rights
|
||||
if ((validAuth == errAuthorizationSuccess) &&
|
||||
(auth != NULL))
|
||||
{
|
||||
const char* executableFileSystemRepresentation = [executablePath fileSystemRepresentation];
|
||||
|
||||
// Prepare a right allowing script to execute with privileges
|
||||
AuthorizationItem right;
|
||||
memset(&right,0,sizeof(right));
|
||||
right.name = kAuthorizationRightExecute;
|
||||
right.value = (void*) executableFileSystemRepresentation;
|
||||
right.valueLength = strlen(executableFileSystemRepresentation);
|
||||
|
||||
// Package up the single right
|
||||
AuthorizationRights rights;
|
||||
memset(&rights,0,sizeof(rights));
|
||||
rights.count = 1;
|
||||
rights.items = &right;
|
||||
|
||||
// Extend rights to run script
|
||||
validAuth = AuthorizationCopyRights(auth,
|
||||
&rights,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagPreAuthorize |
|
||||
kAuthorizationFlagExtendRights |
|
||||
kAuthorizationFlagInteractionAllowed,
|
||||
NULL);
|
||||
if (validAuth != errAuthorizationSuccess)
|
||||
{
|
||||
// Error, clean up authorization
|
||||
(void) AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
||||
auth = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerThreads)
|
||||
|
||||
// Perform the installation script
|
||||
+ (void)performInstallationWithInfo:(NSDictionary *)theInfo
|
||||
{
|
||||
NSParameterAssert(theInfo);
|
||||
|
||||
// Preflight
|
||||
NSString* installerPath = @"/usr/sbin/installer"; // Mac OS X 10.2+ command line installer tool
|
||||
NSError* error = nil;
|
||||
|
||||
// Check installer executable exists
|
||||
if ([[NSFileManager defaultManager] isExecutableFileAtPath:installerPath] == NO)
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Guide installer tool is missing."];
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
|
||||
// Package is relative to installer guide file
|
||||
NSString* absolutePackagePath = nil;
|
||||
if (error == nil)
|
||||
{
|
||||
NSString* installerGuideParentFolderPath = [[theInfo objectForKey:SUGuidedPackageInstallerKeyGuidePath] stringByDeletingLastPathComponent];
|
||||
NSString* packagePath = [(NSDictionary*)[theInfo objectForKey:SUGuidedPackageInstallerKeyGuide] objectForKey:SUGuidedPackageInstallerGuideKeyPackage];
|
||||
NSAssert(packagePath,@"package entry is missing from guide");
|
||||
absolutePackagePath = [installerGuideParentFolderPath stringByAppendingPathComponent:packagePath];
|
||||
|
||||
// Sanity check absolute package path exists
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:absolutePackagePath] == NO)
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Guide installer tool is missing."];
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
}
|
||||
|
||||
// Create authorization for installer executable
|
||||
AuthorizationRef auth = nil;
|
||||
BOOL validInstallation = NO;
|
||||
if (error == nil)
|
||||
{
|
||||
auth = [self authorizationForExecutable:installerPath];
|
||||
if (auth != NULL)
|
||||
{
|
||||
// Permission was granted to execute the installer with privileges
|
||||
const char* const arguments[] = {
|
||||
// [installerPath fileSystemRepresentation],
|
||||
"-pkg",
|
||||
[absolutePackagePath fileSystemRepresentation],
|
||||
"-target",
|
||||
"/",
|
||||
NULL
|
||||
};
|
||||
validInstallation = AuthorizationExecuteWithPrivilegesAndWait(auth,
|
||||
[installerPath fileSystemRepresentation],
|
||||
kAuthorizationFlagDefaults,
|
||||
arguments);
|
||||
// TODO: wait for communications pipe to close via fileno & CFSocketCreateWithNative
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Script authorization denied."];
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
}
|
||||
|
||||
// Release any authorization
|
||||
if (auth)
|
||||
{
|
||||
AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
||||
}
|
||||
|
||||
// Modify info to include the installation script's outcome
|
||||
NSMutableDictionary* resultInfo = [theInfo mutableCopy];
|
||||
[resultInfo setObject:[NSNumber numberWithBool:validInstallation] forKey:SUGuidedPackageInstallerKeyResult];
|
||||
if ((validInstallation == NO) &&
|
||||
(error))
|
||||
{
|
||||
[resultInfo setObject:error forKey:SUGuidedPackageInstallerKeyError];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(finishInstallationWithInfo:) withObject:resultInfo waitUntilDone:NO];
|
||||
}
|
||||
|
||||
// Complete the installation process
|
||||
+ (void)finishInstallationWithInfo:(NSDictionary *)theInfo
|
||||
{
|
||||
NSParameterAssert(theInfo);
|
||||
|
||||
[self finishInstallationToPath:[theInfo objectForKey:SUGuidedPackageInstallerKeyGuidePath]
|
||||
withResult:[[theInfo objectForKey:SUGuidedPackageInstallerKeyResult] boolValue]
|
||||
host:[theInfo objectForKey:SUGuidedPackageInstallerKeyHost]
|
||||
error:[theInfo objectForKey:SUGuidedPackageInstallerKeyError]
|
||||
delegate:[theInfo objectForKey:SUGuidedPackageInstallerKeyDelegate]];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+20
-10
@@ -9,6 +9,7 @@
|
||||
#import "SUInstaller.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPackageInstaller.h"
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
@@ -118,17 +119,26 @@ static NSString *sUpdateFolder = nil;
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
|
||||
// Look for installer guide
|
||||
NSString* installerGuide = [SUGuidedPackageInstaller installerGuideWithinUpdateFolder:inUpdateFolder];
|
||||
if (installerGuide)
|
||||
{
|
||||
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:installerGuide host:host delegate:delegate synchronously:NO versionComparator:comparator];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
|
||||
|
||||
if (newAppDownloadPath == nil)
|
||||
{
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] delegate:delegate];
|
||||
}
|
||||
else
|
||||
{
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class])performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate versionComparator:comparator];
|
||||
}
|
||||
if (newAppDownloadPath == nil)
|
||||
{
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] delegate:delegate];
|
||||
}
|
||||
else
|
||||
{
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class])performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate versionComparator:comparator];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
|
||||
Reference in new issue
Block a user