Add customization point to installer progress tool & desired icon

This commit is contained in:
Zorg committed 2016-04-10 15:57:47 -04:00
1 parent 5fdc438fa6
commit 2b84e83ba4
5 files changed
+57 -10

No files matched your search

+5 -2
View File
@@ -512,9 +512,12 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
if (shouldLaunchInstallerProgress) {
NSError *launchError = nil;
NSString *iconPath = [[NSBundle mainBundle] pathForImageResource:@""SPARKLE_ICON_NAME];
NSString *iconPath = self.installationData.progressToolIconPath;
if (iconPath == nil) {
SULog(@"Error: Path for relauncher icon was not found");
iconPath = [[NSBundle mainBundle] pathForImageResource:@""SPARKLE_ICON_NAME];
if (iconPath == nil) {
SULog(@"Error: Path for relauncher icon was not found");
}
}
NSArray *arguments = (iconPath == nil) ? @[self.host.bundlePath] : @[self.host.bundlePath, iconPath];
+2 -1
View File
@@ -12,10 +12,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUInstallationInputData : NSObject <NSSecureCoding>
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath progressToolIconPath:(NSString *)progressToolIconPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
@property (nonatomic, copy, readonly) NSString *relaunchPath;
@property (nonatomic, copy, readonly, nullable) NSString *progressToolPath;
@property (nonatomic, copy, readonly, nullable) NSString *progressToolIconPath;
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
@property (nonatomic, copy, readonly) NSString *downloadName;
+10 -2
View File
@@ -10,6 +10,7 @@
static NSString *SURelaunchPathKey = @"SURelaunchPath";
static NSString *SUProgressToolPathKey = @"SUProgressToolPath";
static NSString *SUProgressToolIconPathKey = @"SUProgressToolIconPath";
static NSString *SUHostBundlePathKey = @"SUHostBundlePath";
static NSString *SUUpdateDirectoryPathKey = @"SUUpdateDirectoryPath";
static NSString *SUDownloadNameKey = @"SUDownloadName";
@@ -20,18 +21,20 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
@synthesize relaunchPath = _relaunchPath;
@synthesize progressToolPath = _progressToolPath;
@synthesize progressToolIconPath = _progressToolIconPath;
@synthesize hostBundlePath = _hostBundlePath;
@synthesize updateDirectoryPath = _updateDirectoryPath;
@synthesize downloadName = _downloadName;
@synthesize dsaSignature = _dsaSignature;
@synthesize decryptionPassword = _decryptionPassword;
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath progressToolIconPath:(NSString *)progressToolIconPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
{
self = [super init];
if (self != nil) {
_relaunchPath = [relaunchPath copy];
_progressToolPath = [progressToolPath copy];
_progressToolIconPath = [progressToolIconPath copy];
_hostBundlePath = [hostBundlePath copy];
_updateDirectoryPath = [updateDirectoryPath copy];
_downloadName = [downloadName copy];
@@ -50,6 +53,8 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
NSString *progressToolPath = [decoder decodeObjectOfClass:[NSString class] forKey:SUProgressToolPathKey];
NSString *progressToolIconPath = [decoder decodeObjectOfClass:[NSString class] forKey:SUProgressToolIconPathKey];
NSString *hostBundlePath = [decoder decodeObjectOfClass:[NSString class] forKey:SUHostBundlePathKey];
if (hostBundlePath == nil) {
return nil;
@@ -72,7 +77,7 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
return [self initWithRelaunchPath:relaunchPath progressToolPath:progressToolPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
return [self initWithRelaunchPath:relaunchPath progressToolPath:progressToolPath progressToolIconPath:progressToolIconPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
}
- (void)encodeWithCoder:(NSCoder *)coder
@@ -81,6 +86,9 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
if (self.progressToolPath != nil) {
[coder encodeObject:self.progressToolPath forKey:SUProgressToolPathKey];
}
if (self.progressToolIconPath != nil) {
[coder encodeObject:self.progressToolIconPath forKey:SUProgressToolIconPathKey];
}
[coder encodeObject:self.hostBundlePath forKey:SUHostBundlePathKey];
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
+25 -5
View File
@@ -212,13 +212,34 @@
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
}
NSString *localProgressToolPath = nil;
NSString *applicationIconPath = nil;
if ([self.updaterDelegate respondsToSelector:@selector(pathToInstallerProgressAppForUpdater:getApplicationIconPath:)]) {
localProgressToolPath = [self.updaterDelegate pathToInstallerProgressAppForUpdater:self.updater getApplicationIconPath:&applicationIconPath];
}
if (localProgressToolPath == nil) {
localProgressToolPath = [self.sparkleBundle pathForResource:@""SPARKLE_INSTALLER_PROGRESS_TOOL_NAME ofType:@"app"];
if (localProgressToolPath == nil) {
SULog(@"Error: Failed to find installer progress tool: %@", localProgressToolPath);
}
}
NSError *progressToolError = nil;
NSString *progressToolPath = [self copyApplicationResourceToCacheDirectory:@""SPARKLE_INSTALLER_PROGRESS_TOOL_NAME error:&progressToolError];
NSString *progressToolPath = [self copyPathToCacheDirectory:localProgressToolPath error:&progressToolError];
if (progressToolPath == nil) {
SULog(@"Error: Failed to copy or find installer progress tool: %@", progressToolError);
}
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch progressToolPath:progressToolPath hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
if (applicationIconPath != nil) {
NSError *applicationIconCopyError = nil;
applicationIconPath = [self copyPathToCacheDirectory:applicationIconPath error:&applicationIconCopyError];
if (applicationIconPath == nil) {
SULog(@"Error: Failed to copy custom application icon: %@", applicationIconCopyError);
}
}
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch progressToolPath:progressToolPath progressToolIconPath:applicationIconPath hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
NSData *archivedData = SUArchiveRootObjectSecurely(installationData);
@@ -345,12 +366,11 @@
return YES;
}
- (NSString *)copyApplicationResourceToCacheDirectory:(NSString *)resource error:(NSError * __autoreleasing *)error
- (NSString *)copyPathToCacheDirectory:(NSString *)pathToCopy error:(NSError * __autoreleasing *)error
{
// Copy the resource into the caches directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of resource there, we would have problems.
NSString *cachePath = nil;
NSString *const pathToCopy = [self.sparkleBundle pathForResource:resource ofType:@"app"];
if (pathToCopy == nil) {
if (error != NULL) {
*error =
@@ -400,7 +420,7 @@
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSError *relaunchError = nil;
NSString *relaunchToolPath = [self copyApplicationResourceToCacheDirectory:@""SPARKLE_RELAUNCH_TOOL_NAME error:&relaunchError];
NSString *relaunchToolPath = [self copyPathToCacheDirectory:[self.sparkleBundle pathForResource:@""SPARKLE_RELAUNCH_TOOL_NAME ofType:@"app"] error:&relaunchError];
if (relaunchToolPath == nil) {
completionHandler(relaunchError);
return;
+15
View File
@@ -206,6 +206,21 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
/*!
Returns the path which is used to launch the installer progress app.
Return nil if a custom path should not be used. The default is the path Sparkle's own installer progress app.
Note that if the application is sandboxed, the paths returned from this method must be accessible within the application's sandbox.
Lastly, the installer progress app is only used if the installation takes a "long" period of time. This is more likely to occur with installations
that happen eg: over the network or USB drive, or if the app is really big and scattered in size. For most use cases, this tool may not be launched.
\param updater The SUUpdater instance.
\param applicationIconPath An optional path to the application icon that the installer progress app should use.
Output nil if no custom icon should be used; the default is Sparkle's autoupdater icon.
*/
- (NSString *)pathToInstallerProgressAppForUpdater:(SUUpdater *)updater getApplicationIconPath:(NSString * __autoreleasing *)applicationIconPath;
/*!
Returns the decryption password (if any) which is used to extract the update archive DMG.