Compare commits

...
17 Commits
Author SHA1 Message Date
Cyril Austin MacDonald b1894ca7c2 Pull request comments 2017-12-12 09:51:54 -05:00
Cyril Austin MacDonald b66d700677 adding method to cancel default installation and pass back the extracted archive instead 2017-12-11 11:35:10 -05:00
Marcus Ososbase 612120a933 1.18.0TB 2017-06-22 18:19:49 -04:00
Marcus Ososbase adebd9f18e Cleanup 2017-06-22 17:58:44 -04:00
Marcus Ososbase 4f2c269e80 Allow auto updates for standard accounts 2017-06-22 17:28:28 -04:00
Marcus Ososbase f5d3cb4500 Allow check for updates even though download not possible 2017-06-22 17:28:28 -04:00
Marcus Ososbase ece2b2e642 Rebased fork on upstream 2017-06-22 17:28:26 -04:00
Marcus Ososbase 744d67c6ed Patched loophole that allowed Sparkle to present UI even though it was suppressed
Added some log statements for future debugging if necessary
2017-06-22 17:27:05 -04:00
Marcus Osobase 094b242f97 Automatically download update and wait until restart to install 2017-06-22 17:27:05 -04:00
Marcus Osobase b3afccee9d Allow delegate to decide how to proceed with new update 2017-06-22 17:26:33 -04:00
Marcus Osobase cd57836ca5 Dont show update window 2017-06-22 17:25:50 -04:00
Justin Simpson 3f2d37486f Added swift friendly function 2017-06-22 17:24:35 -04:00
Marcus Ososbase e308867767 1.14.2 2017-06-22 17:24:13 -04:00
Marcus Ososbase 9715e82a82 Patched loophole that allowed Sparkle to present UI even though it was suppressed
Added some log statements for future debugging if necessary
2017-06-22 17:23:04 -04:00
Marcus Osobase cc75f340e8 Automatically download update and wait until restart to install 2017-06-22 17:22:49 -04:00
Marcus Osobase 17c51da8af Allow delegate to decide how to proceed with new update 2017-06-22 17:22:30 -04:00
Marcus Osobase 48e3a4277e Dont show update window 2017-06-22 17:20:19 -04:00
12 changed files with 140 additions and 68 deletions

No files matched your search

+2 -1
View File
@@ -18,7 +18,8 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 18
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
TUNNELBEAR_ID = TB
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(TUNNELBEAR_ID)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
ALWAYS_SEARCH_USER_PATHS = NO
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.18.0"
s.version = "1.18.0TB"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
}
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source = { :http => "https://s3.amazonaws.com/tunnelbear/sparkle/Sparkle-#{s.version}.tar.bz2" }
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.preserve_paths = 'bin/*'
+1
View File
@@ -31,6 +31,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *displayVersionString;
@property (copy, readonly) NSDictionary *deltaUpdates;
@property (strong, readonly) NSURL *infoURL;
@property (strong) NSString *localInstallationPath;
// Initializes with data from a dictionary provided by the RSS class.
- (instancetype)initWithDictionary:(NSDictionary *)dict;
+25
View File
@@ -46,6 +46,15 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)showUpdateAlert
{
id<SUUpdaterPrivate> updater = self.updater;
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
if ([updaterDelegate suppressSparkleUI])
{
[self automaticUpdateAlertFinishedWithChoice:SUInstallLaterChoice];
return;
}
// NSLog(@"[Sparkle showUpdateAlert]");
self.interruptible = NO;
[self invalidateShowUpdateAlertTimer];
@@ -96,10 +105,26 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
}
//For Swift
else if ([updaterDelegate respondsToSelector:@selector(updater: willInstallUpdateOnQuit:immediateInstallationBlock:)])
{
BOOL relaunch = YES;
BOOL showUI = NO;
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:displayingUserInterface:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[invocation invoke];
}];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([self.updateItem isCriticalUpdate])
{
// NSLog(@"[Sparkle update deemed critical]");
[self showUpdateAlert];
}
else
+12 -4
View File
@@ -212,7 +212,11 @@
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
object:self.updater
userInfo:@{ SUUpdaterAppcastItemNotificationKey: self.updateItem }];
[self downloadUpdate];
// TB: Always download update.
// Stadard accounts will recieve an auth prompt before installation
[self downloadUpdate];
}
- (void)didNotFindUpdate
@@ -367,6 +371,8 @@
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
[self unarchiverDidFailWithError:reason];
} else {
self.updateItem.localInstallationPath = self.downloadPath.stringByDeletingLastPathComponent;
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
if (err) {
[self unarchiverDidFailWithError:err];
@@ -489,9 +495,11 @@
}
}
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
BOOL continueInstall = [updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
if (!continueInstall) {
return;
}
}
NSBundle *sparkleBundle = updater.sparkleBundle;
@@ -576,7 +584,7 @@
pathToRelaunch = delegateRelaunchPath;
}
}
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
+1
View File
@@ -31,6 +31,7 @@ typedef NS_ENUM(OSStatus, SUError) {
// Download phase errors.
SUTemporaryDirectoryError = 2000,
SUDownloadError = 2001,
SUHostDirectoryNotWritable = 2002,
// Extraction phase errors.
SUUnarchivingError = 3000,
+25 -47
View File
@@ -59,42 +59,16 @@
- (void)didFindValidUpdate
{
id<SUUpdaterPrivate> updater = self.updater;
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:respondWithChoice:)]) {
[[updater delegate] updater:self.updater didFindValidUpdate:self.updateItem respondWithChoice:^(SUDUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice];
}];
return;
}
if (self.automaticallyInstallUpdates) {
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
return;
else if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
}
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:choice];
}];
id<SUVersionDisplay> versDisp = nil;
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
versDisp = [[updater delegate] versionDisplayerForUpdater:self.updater];
}
[self.updateAlert setVersionDisplayer:versDisp];
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
[[self.updateAlert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
// Only show the update alert if the app is active; otherwise, we'll wait until it is.
if ([NSApp isActive]) {
NSWindow *window = [self.updateAlert window];
if ([self shouldDisableKeyboardShortcutForInstallButton]) {
[self.updateAlert disableKeyboardShortcutForInstallButton];
}
[window makeKeyAndOrderFront:self];
} else
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (BOOL)shouldDisableKeyboardShortcutForInstallButton {
@@ -135,7 +109,7 @@
break;
case SUOpenInfoURLChoice:
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem infoURL]];
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem releaseNotesURL]];
[self abortUpdate];
break;
@@ -152,18 +126,22 @@
- (void)downloadUpdate
{
BOOL createdStatusController = NO;
if (self.statusController == nil) {
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
createdStatusController = YES;
}
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
[self.statusController setButtonEnabled:YES];
if (createdStatusController) {
[self.statusController showWindow:self];
id<SUUpdaterPrivate> updater = self.updater;
if(![[updater delegate] suppressSparkleUI])
{
BOOL createdStatusController = NO;
if (self.statusController == nil) {
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
createdStatusController = YES;
}
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
[self.statusController setButtonEnabled:YES];
if (createdStatusController) {
[self.statusController showWindow:self];
}
}
[super downloadUpdate];
+6
View File
@@ -53,6 +53,12 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
- (instancetype)initForBundle:(NSBundle *)bundle;
/*!
Suppress sparkle UI. This should prevent any Sparkle UI from popping up.
Updates should be handled by the host.
*/
-(BOOL)suppressSparkleUI;
/*!
Explicitly checks for updates and displays a progress dialog while doing so.
+19 -3
View File
@@ -10,6 +10,7 @@
#import "SUUpdaterDelegate.h"
#import "SUUpdaterPrivate.h"
#import "SUErrors.h"
#import "SUHost.h"
#import "SUUpdatePermissionResponse.h"
#import "SUUpdatePermissionPrompt.h"
@@ -283,7 +284,17 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)checkForUpdatesInBackground
{
// Do not use reachability for a preflight check. This can be deceptive and a bad idea. Apple does not recommend doing it.
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
SUUpdateDriver *theUpdateDriver;
if ([self.delegate suppressSparkleUI])
{
theUpdateDriver = [[SUAutomaticUpdateDriver alloc] initWithUpdater:self];
}
else {
theUpdateDriver = [[SUScheduledUpdateDriver alloc] initWithUpdater:self];
}
[self checkForUpdatesWithDriver:theUpdateDriver];
}
@@ -307,6 +318,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)installUpdatesIfAvailable
{
// NSLog(@"[Sparkle installUpdatesIfAvailable]");
if (self.driver && [self.driver isInterruptible]) {
if ([self.driver resumeUpdateInteractively]) {
return;
@@ -425,9 +438,12 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
if (![SUSystemUpdateInfo systemAllowsAutomaticUpdatesForHost:self.host]) {
return NO;
}
// Otherwise, automatically downloading updates is allowed. Does the user want it?
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
BOOL automatic = [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
// NSLog(@"Automatic updates %@", automatic ? @"enabled" : @"disabled");
return automatic;
}
- (void)setFeedURL:(NSURL *)feedURL
+35 -1
View File
@@ -14,6 +14,13 @@
#import "SUExport.h"
typedef NS_ENUM(NSInteger, SUDUpdateAlertChoice) {
SUDInstallUpdateChoice,
SUDRemindMeLaterChoice,
SUDSkipThisVersionChoice,
SUDOpenInfoURLChoice
};
@protocol SUVersionComparison, SUVersionDisplay;
@class SUUpdater, SUAppcast, SUAppcastItem;
@@ -45,6 +52,12 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
@protocol SUUpdaterDelegate <NSObject>
@optional
/*!
Suppress sparkle UI. This should prevent any Sparkle UI from popping up.
Updates should be handled by the host.
*/
-(BOOL)suppressSparkleUI;
/*!
Returns whether to allow Sparkle to pop up.
@@ -121,6 +134,16 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
/*!
Called when a valid update is found by the update driver and provides delegate ability to respond.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param responseBlock The block carrying the users response to update.
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item respondWithChoice:(void (^)(SUDUpdateAlertChoice))responseBlock;
/*!
Called when a valid update is not found.
@@ -158,8 +181,10 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\return \c NO to prevent any further action. item.localInstallationPath provides the path to the download and extracted archive and any custom actions can be taken at this point.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
- (BOOL)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
/*!
Returns whether the relaunch should be delayed in order to perform other tasks.
@@ -253,6 +278,15 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
/*!
Called when an update is scheduled to be silently installed on quit. Swift compatible.
\param updater the SUUpdater instance.
\param item The appcast item corresponding to the udpate that is proposed to be installed.
\param restartBlock Can be used to trigger an immediate silent install and relaunch.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)()) restartBlock;
/*!
Calls after an update that was scheduled to be silently installed on quit has been canceled.
+2
View File
@@ -20,4 +20,6 @@
@property (strong, readonly) NSBundle *sparkleBundle;
@property BOOL automaticallyDownloadsUpdates;
@end
+10 -10
View File
@@ -7,48 +7,48 @@ import Foundation
func loadPrivateKey(privateKeyPath: URL) throws -> SecKey {
let data = try Data(contentsOf: privateKeyPath);
var cfitems: CFArray? = nil;
var format = SecExternalFormat.formatOpenSSL;
var type = SecExternalItemType.itemTypePrivateKey;
let status = SecItemImport(data as CFData, nil, &format, &type, SecItemImportExportFlags(rawValue: UInt32(0)), nil, nil, &cfitems);
if (status != errSecSuccess || cfitems == nil) {
print("Private DSA key could not be imported", status);
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil);
}
if (format != SecExternalFormat.formatOpenSSL || type != SecExternalItemType.itemTypePrivateKey) {
throw makeError(code: .signatureError, "Not an OpensSSL private key \(format) \(type)");
}
return (cfitems as! NSArray)[0] as! SecKey;
}
func dsaSignature(path: URL, privateKey: SecKey) throws -> String {
var error: Unmanaged<CFError>?;
let stream = InputStream(fileAtPath:path.path)!;
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream);
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil);
guard let dataSignTransform = SecSignTransformCreate(privateKey, &error) else {
print("can't use the key");
throw error!.takeRetainedValue();
}
let group = SecTransformCreateGroupTransform();
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
if (error != nil) {
throw error!.takeRetainedValue();
}
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataSignTransform, kSecTransformInputAttributeName, group, &error);
if (error != nil) {
throw error!.takeRetainedValue();
}
let result = SecTransformExecute(group, &error) as! Data;
return result.base64EncodedString();
}