diff --git a/Autoupdate/AppInstaller.m b/Autoupdate/AppInstaller.m index 5cb67d57..38710b2b 100644 --- a/Autoupdate/AppInstaller.m +++ b/Autoupdate/AppInstaller.m @@ -599,7 +599,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; } else if (identifier == SPUSentUpdateAppcastItemData) { SUAppcastItem *updateItem = (data != nil) ? (SUAppcastItem *)SPUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]) : nil; if (updateItem != nil) { - SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[_installer canInstallSilently]]; + SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem]; NSData *archivedData = SPUArchiveRootObjectSecurely(installationInfo); if (archivedData != nil) { @@ -612,7 +612,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; uint8_t showsUI = *((const uint8_t *)data.bytes + 1); dispatch_async(dispatch_get_main_queue(), ^{ - // This flag has an impact on interactive type installations and showing UI progress during non-interactive installations + // This flag has an impact on showing UI progress during installations self->_shouldShowUI = (BOOL)showsUI; // Don't test if the application was alive initially, leave that to the progress agent if we decide to relaunch self->_shouldRelaunch = (BOOL)relaunch; @@ -679,8 +679,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; return; } - uint8_t canPerformSilentInstall = (uint8_t)[installer canInstallSilently]; - dispatch_async(dispatch_get_main_queue(), ^{ self->_installer = installer; @@ -688,9 +686,9 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; self->_performedStage1Installation = YES; os_unfair_lock_unlock(&self->_newConnectionLock); - uint8_t sendInformation[] = {canPerformSilentInstall, (uint8_t)self->_targetTerminated}; + uint8_t targetTerminated = (uint8_t)self->_targetTerminated; - NSData *sendData = [NSData dataWithBytes:sendInformation length:sizeof(sendInformation)]; + NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)]; [self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData]; @@ -705,37 +703,27 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; - (void)performStage2Installation SPU_OBJC_DIRECT { - BOOL canPerformSecondStage = _shouldShowUI || [_installer canInstallSilently]; - if (canPerformSecondStage) { - _performedStage2Installation = YES; + _performedStage2Installation = YES; + + dispatch_async(dispatch_get_main_queue(), ^{ + uint8_t targetTerminated = (uint8_t)self->_targetTerminated; - dispatch_async(dispatch_get_main_queue(), ^{ - uint8_t targetTerminated = (uint8_t)self->_targetTerminated; - - NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)]; - [self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData]; - - // Don't check if the target is already terminated, leave that to the progress agent - // We could be slightly off if there were multiple instances running - [self->_agentConnection.agent sendTerminationSignal]; - }); - } else { - _installer = nil; + NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)]; + [self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to resume installer on stage 2 because installation cannot be installed silently" }]]; - }); - } + // Don't check if the target is already terminated, leave that to the progress agent + // We could be slightly off if there were multiple instances running + [self->_agentConnection.agent sendTerminationSignal]; + }); } - (void)finishInstallationAfterHostTermination SPU_OBJC_DIRECT { assert(self->_targetTerminated); - // Show our installer progress UI tool if only after a certain amount of time passes, - // and if our installer is silent (i.e, doesn't show progress on its own) + // Show our installer progress UI tool if only after a certain amount of time passes __block BOOL shouldShowUIProgress = YES; - if (self->_shouldShowUI && [self->_installer canInstallSilently]) { + if (self->_shouldShowUI) { // Ask the updater if it is still alive // If they are, we will receive a pong response back // Reset if we received a pong just to be on the safe side diff --git a/Autoupdate/SPUInstallationInfo.h b/Autoupdate/SPUInstallationInfo.h index 98132068..e7961acc 100644 --- a/Autoupdate/SPUInstallationInfo.h +++ b/Autoupdate/SPUInstallationInfo.h @@ -14,10 +14,9 @@ NS_ASSUME_NONNULL_BEGIN SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInfo : NSObject -- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall; +- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem; @property (nonatomic, readonly) SUAppcastItem *appcastItem; -@property (nonatomic, readonly) BOOL canSilentlyInstall; @property (nonatomic) BOOL systemDomain; diff --git a/Autoupdate/SPUInstallationInfo.m b/Autoupdate/SPUInstallationInfo.m index b7aa8989..8010143a 100644 --- a/Autoupdate/SPUInstallationInfo.m +++ b/Autoupdate/SPUInstallationInfo.m @@ -19,23 +19,21 @@ static NSString *SUSystemDomainKey = @"SUSystemDomain"; @implementation SPUInstallationInfo @synthesize appcastItem = _appcastItem; -@synthesize canSilentlyInstall = _canSilentlyInstall; @synthesize systemDomain = _systemDomain; -- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall systemDomain:(BOOL)systemDomain +- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem systemDomain:(BOOL)systemDomain { self = [super init]; if (self != nil) { _appcastItem = appcastItem; - _canSilentlyInstall = canSilentlyInstall; _systemDomain = systemDomain; } return self; } -- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall +- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem { - return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:NO]; + return [self initWithAppcastItem:appcastItem systemDomain:NO]; } - (nullable instancetype)initWithCoder:(NSCoder *)decoder @@ -45,16 +43,18 @@ static NSString *SUSystemDomainKey = @"SUSystemDomain"; return nil; } - BOOL canSilentlyInstall = [decoder decodeBoolForKey:SUCanSilentlyInstallKey]; BOOL systemDomain = [decoder decodeBoolForKey:SUSystemDomainKey]; - return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:systemDomain]; + return [self initWithAppcastItem:appcastItem systemDomain:systemDomain]; } - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject:_appcastItem forKey:SUAppcastItemKey]; - [coder encodeBool:_canSilentlyInstall forKey:SUCanSilentlyInstallKey]; [coder encodeBool:_systemDomain forKey:SUSystemDomainKey]; + + // Installation types can always be silently installed for newer versions of Sparkle + // Still encode this key to maintain backwards compatibility with older Sparkle clients + [coder encodeBool:YES forKey:SUCanSilentlyInstallKey]; } + (BOOL)supportsSecureCoding diff --git a/Autoupdate/SUGuidedPackageInstaller.m b/Autoupdate/SUGuidedPackageInstaller.m index 88dd540b..edada19b 100644 --- a/Autoupdate/SUGuidedPackageInstaller.m +++ b/Autoupdate/SUGuidedPackageInstaller.m @@ -82,11 +82,6 @@ { } -- (BOOL)canInstallSilently -{ - return YES; -} - @end #endif diff --git a/Autoupdate/SUInstallerProtocol.h b/Autoupdate/SUInstallerProtocol.h index c574bf41..74f05936 100644 --- a/Autoupdate/SUInstallerProtocol.h +++ b/Autoupdate/SUInstallerProtocol.h @@ -28,11 +28,6 @@ NS_ASSUME_NONNULL_BEGIN // Should be able to be called from any thread - (void)performCleanup; -// Indicates whether or not this installer can install the update silently in the background, without hindering the user -// If this returns NO, then the installation can fail if the user did not directly request for the install to occur. -// Should be thread safe -- (BOOL)canInstallSilently; - @end NS_ASSUME_NONNULL_END diff --git a/Autoupdate/SUPlainInstaller.m b/Autoupdate/SUPlainInstaller.m index 6b93fb07..7db6c722 100644 --- a/Autoupdate/SUPlainInstaller.m +++ b/Autoupdate/SUPlainInstaller.m @@ -406,9 +406,4 @@ } } -- (BOOL)canInstallSilently -{ - return YES; -} - @end diff --git a/Sparkle/SPUAutomaticUpdateDriver.m b/Sparkle/SPUAutomaticUpdateDriver.m index 087b44d4..920b20d1 100644 --- a/Sparkle/SPUAutomaticUpdateDriver.m +++ b/Sparkle/SPUAutomaticUpdateDriver.m @@ -31,7 +31,7 @@ __weak id _userDriver; __weak id _updaterDelegate; - BOOL _willInstallSilently; + BOOL _installerDidFinishPreparation; } - (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate @@ -95,14 +95,14 @@ return NO; } -- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently +- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately { - _willInstallSilently = willInstallSilently; + _installerDidFinishPreparation = YES; if (!willInstallImmediately) { BOOL installationHandledByDelegate = NO; id updaterDelegate = _updaterDelegate; - if (_willInstallSilently && [updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)]) { + if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)]) { __weak __typeof__(self) weakSelf = self; installationHandledByDelegate = [updaterDelegate updater:_updater willInstallUpdateOnQuit:_updateItem immediateInstallationBlock:^{ dispatch_async(dispatch_get_main_queue(), ^{ @@ -139,7 +139,7 @@ - (void)abortUpdateWithError:(NSError *)error { - BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!_willInstallSilently || _updateItem.criticalUpdate || _updateItem.isInformationOnlyUpdate); + BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!_installerDidFinishPreparation || _updateItem.criticalUpdate || _updateItem.isInformationOnlyUpdate); [_coreDriver abortUpdateAndShowNextUpdateImmediately:showNextUpdateImmediately error:error]; } diff --git a/Sparkle/SPUCoreBasedUpdateDriver.h b/Sparkle/SPUCoreBasedUpdateDriver.h index 4c1f2a99..b608d23d 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.h +++ b/Sparkle/SPUCoreBasedUpdateDriver.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryAppcastItem; -- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently; +- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately; - (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error; diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index fbbde4c3..34c6f06a 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -295,9 +295,9 @@ } } -- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently +- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately { - [_delegate installerDidFinishPreparationAndWillInstallImmediately:willInstallImmediately silently:willInstallSilently]; + [_delegate installerDidFinishPreparationAndWillInstallImmediately:willInstallImmediately]; } - (void)finishInstallationWithResponse:(SPUUserUpdateChoice)response displayingUserInterface:(BOOL)displayingUserInterface diff --git a/Sparkle/SPUInstallationType.h b/Sparkle/SPUInstallationType.h index f06aa339..dd6999e9 100644 --- a/Sparkle/SPUInstallationType.h +++ b/Sparkle/SPUInstallationType.h @@ -11,7 +11,7 @@ #define SPUInstallationTypeApplication @"application" // the default installation type for ordinary application updates #define SPUInstallationTypeGuidedPackage @"package" // the preferred installation type for package installations -#define SPUInstallationTypeInteractivePackage @"interactive-package" // the deprecated installation type; use guided package instead +#define SPUInstallationTypeInteractivePackage @"interactive-package" // removed installation type; use guided package instead #define SPUInstallationTypesArray (@[SPUInstallationTypeApplication, SPUInstallationTypeGuidedPackage]) #define SPUValidInstallationType(x) ((x != nil) && [SPUInstallationTypesArray containsObject:(NSString * _Nonnull)x]) diff --git a/Sparkle/SPUInstallerDriver.h b/Sparkle/SPUInstallerDriver.h index f77bf3a8..522d9bf9 100644 --- a/Sparkle/SPUInstallerDriver.h +++ b/Sparkle/SPUInstallerDriver.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)installerDidStartInstallingWithApplicationTerminated:(BOOL)applicationTerminated; - (void)installerDidStartExtracting; - (void)installerDidExtractUpdateWithProgress:(double)progress; -- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently; +- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately; - (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch; - (void)installerDidFinishInstallationAndRelaunched:(BOOL)relaunch acknowledgement:(void(^)(void))acknowledgement; diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index f18cb4d8..cdc0e9a4 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -342,17 +342,12 @@ SULog(SULogLevelError, @"Error: Archived data to send for appcast item is nil"); } - BOOL canInstallSilently = NO; - if (data.length >= sizeof(uint8_t)) { - canInstallSilently = (BOOL)*(const uint8_t *)data.bytes; - } - BOOL hasTargetTerminated = NO; - if (data.length >= sizeof(uint8_t) * 2) { - hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes + 1); + if (data.length >= sizeof(uint8_t)) { + hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes); } - [delegate installerDidFinishPreparationAndWillInstallImmediately:hasTargetTerminated silently:canInstallSilently]; + [delegate installerDidFinishPreparationAndWillInstallImmediately:hasTargetTerminated]; } else if (identifier == SPUInstallationFinishedStage2) { _currentStage = identifier; diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index e6f5b0ae..596deba6 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -355,7 +355,7 @@ [_userDriver showExtractionReceivedProgress:progress]; } -- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)__unused willInstallSilently +- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately { if (!willInstallImmediately) { [_userDriver showReadyToInstallAndRelaunch:^(SPUUserUpdateChoice choice) { diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 959afd69..54c50a42 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -524,7 +524,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification // Proceed as normal if there's no resumable updates completionHandler(regularCheckInterval); } else { - if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate] || [installationInfo.appcastItem isInformationOnlyUpdate]) { + if ([installationInfo.appcastItem isCriticalUpdate] || [installationInfo.appcastItem isInformationOnlyUpdate]) { completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval)); } else { completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval)); diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 19bdd96a..1791dfa5 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -648,8 +648,7 @@ static NSString *SUAppcastItemDeltaFromSparkleLocalesKey = @"SUAppcastItemDeltaF #if SPARKLE_BUILD_PACKAGE_SUPPORT NSString *attributeInstallationType = [enclosure objectForKey:SUAppcastAttributeInstallationType]; if (attributeInstallationType == nil) { - // If we have a flat package, assume installation type is guided - // (flat / non-archived interactive packages are not supported anymore) + // If we have a bare package, assume installation type is guided package // Otherwise assume we have a normal application inside an archive if ([_fileURL.pathExtension isEqualToString:@"pkg"] || [_fileURL.pathExtension isEqualToString:@"mpkg"]) { chosenInstallationType = SPUInstallationTypeGuidedPackage; diff --git a/sparkle-cli/main.m b/sparkle-cli/main.m index 75fa352e..1c1452bf 100644 --- a/sparkle-cli/main.m +++ b/sparkle-cli/main.m @@ -45,7 +45,7 @@ static void printUsage(char **argv) fprintf(stderr, " --%s\n List of allowed Sparkle channels to look for updates in. By default,\n only the default channel is used.\n", CHANNELS_FLAG); fprintf(stderr, " --%s\n URL for appcast feed. This URL will be used for the feed instead of the one\n in the bundle's Info.plist or in the bundle's user defaults.\n", FEED_URL_FLAG); fprintf(stderr, " --%s\n Display name that will be included as a part of the User-Agent string.\n We encourage setting this so developers know what is querying their feed.\n Otherwise, this value may be set and inferred automatically.\n", USER_AGENT_NAME); - fprintf(stderr, " --%s\n Allows prompting the user for an authorization dialog prompt if the\n installer needs elevated privileges, or allows performing an interactive\n installer package. Without passing this, an exit status of 3 is returned\n if an update requires user interaction. An exit status of 5 is returned\n if the user cancels the authorization prompt.\n", INTERACTIVE_FLAG); + fprintf(stderr, " --%s\n Allows prompting the user for an authorization dialog prompt if the\n installer needs elevated privileges.\n Without passing this, an exit status of 3 is returned if an update\n requires user interaction. An exit status of 5 is returned\n if the user cancels the authorization prompt.\n", INTERACTIVE_FLAG); fprintf(stderr, " --%s\n If update permission is requested, this enables automatic update checks.\n Note that this behavior may overwrite the user's defaults for the bundle.\n This option has no effect if --%s is passed, or if the\n user has replied to this request already, or if the developer configured\n to skip it. Without passing this, an exit status of 6 is returned\n if permission is needed.\n", GRANT_AUTOMATIC_CHECKING_FLAG, CHECK_NOW_FLAG); fprintf(stderr, " --%s\n Choose to send system profile information if update permission is requested.\n This option can only take effect if --%s is passed.\n", SEND_PROFILE_FLAG, GRANT_AUTOMATIC_CHECKING_FLAG); fprintf(stderr, " --%s\n Defer installation until after the application terminates on its own. The\n application will not be relaunched unless the installation is resumed later.\n", DEFER_FLAG);