Skip to content

Commit

Permalink
Bump minimum deployment target to macOS 10.13 (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgiepoo authored Jul 17, 2022
1 parent 470296a commit 372f050
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 286 deletions.
27 changes: 6 additions & 21 deletions Autoupdate/SUBinaryDeltaApply.m
Original file line number Diff line number Diff line change
Expand Up @@ -398,32 +398,17 @@ BOOL applyBinaryDelta(NSString *source, NSString *finalDestination, NSString *pa

NSTask *dittoTask = [[NSTask alloc] init];

if (@available(macOS 10.13, *)) {
dittoTask.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto" isDirectory:NO];
} else {
dittoTask.launchPath = @"/usr/bin/ditto";
}

dittoTask.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto" isDirectory:NO];
dittoTask.arguments = @[@"--hfsCompression", destination, finalDestination];

// If we fail to apply file system compression, we will try falling back to not doing this
BOOL failedToApplyFileSystemCompression = NO;

if (@available(macOS 10.13, *)) {
NSError *launchError = nil;
if (![dittoTask launchAndReturnError:&launchError]) {
failedToApplyFileSystemCompression = YES;

fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", launchError.localizedDescription.UTF8String);
}
} else {
@try {
[dittoTask launch];
} @catch (NSException *exception) {
failedToApplyFileSystemCompression = YES;

fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", exception.reason.UTF8String);
}
NSError *launchError = nil;
if (![dittoTask launchAndReturnError:&launchError]) {
failedToApplyFileSystemCompression = YES;

fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", launchError.localizedDescription.UTF8String);
}

if (!failedToApplyFileSystemCompression) {
Expand Down
30 changes: 6 additions & 24 deletions Autoupdate/SUDiskImageUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,8 @@ - (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
dispatch_semaphore_signal(terminationSemaphore);
};

if (@available(macOS 10.13, *)) {
if (![task launchAndReturnError:&error]) {
goto reportError;
}
} else {
@try {
[task launch];
} @catch (NSException *) {
goto reportError;
}
if (![task launchAndReturnError:&error]) {
goto reportError;
}

[notifier notifyProgress:0.125];
Expand Down Expand Up @@ -221,20 +213,10 @@ - (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
task.standardOutput = [NSPipe pipe];
task.standardError = [NSPipe pipe];


if (@available(macOS 10.13, *)) {
NSError *launchCleanupError = nil;
if (![task launchAndReturnError:&launchCleanupError]) {
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
SULog(SULogLevelError, @"Error: %@", launchCleanupError);
}
} else {
@try {
[task launch];
} @catch (NSException *exception) {
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
SULog(SULogLevelError, @"Exception: %@", exception);
}
NSError *launchCleanupError = nil;
if (![task launchAndReturnError:&launchCleanupError]) {
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
SULog(SULogLevelError, @"Error: %@", launchCleanupError);
}
} else {
SULog(SULogLevelError, @"Can't mount DMG %@", self.archivePath);
Expand Down
30 changes: 9 additions & 21 deletions Autoupdate/SUGuidedPackageInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,18 @@ - (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))__unused
task.standardError = nil;
task.standardOutput = nil;

if (@available(macOS 10.13, *)) {
NSError *launchError = nil;
if (![task launchAndReturnError:&launchError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];

if (launchError != nil) {
userInfo[NSUnderlyingErrorKey] = launchError;
}

*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}
} else {
@try {
[task launch];
} @catch (NSException *) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Guided package installer task threw an exception" }];
NSError *launchError = nil;
if (![task launchAndReturnError:&launchError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];

if (launchError != nil) {
userInfo[NSUnderlyingErrorKey] = launchError;
}

return NO;
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}

[task waitUntilExit];
Expand Down
16 changes: 3 additions & 13 deletions Autoupdate/SUPipedUnarchiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,9 @@ - (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray
[task setArguments:[args arrayByAddingObject:destination]];

NSError *launchError = nil;
if (@available(macOS 10.13, *)) {
if (![task launchAndReturnError:&launchError]) {
[notifier notifyFailureWithError:launchError];
return;
}
} else {
@try {
[task launch];
} @catch (NSException *e) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, -[NSTask launch] threw exception '%@'", e.description]}];
[notifier notifyFailureWithError:error];
return;
}
if (![task launchAndReturnError:&launchError]) {
[notifier notifyFailureWithError:launchError];
return;
}

NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
Expand Down
16 changes: 6 additions & 10 deletions Autoupdate/SUPlainInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,13 @@ - (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *
// First try swapping the application atomically
NSError *swapError = nil;
BOOL swappedApp;
if (@available(macOS 10.13, *)) {
// If the app is normalized and the installation path differs, go through the old swap path
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
swappedApp = NO;
} else {
// We will be cleaning up the temporary directory later in -performCleanup:
// We don't want to clean it up now because it can take some time
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newTempURL error:&swapError];
}
} else {
// If the app is normalized and the installation path differs, go through the old swap path
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
swappedApp = NO;
} else {
// We will be cleaning up the temporary directory later in -performCleanup:
// We don't want to clean it up now because it can take some time
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newTempURL error:&swapError];
}

if (!swappedApp) {
Expand Down
2 changes: 1 addition & 1 deletion Configurations/ConfigCommon.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 10.11
MACOSX_DEPLOYMENT_TARGET = 10.13
PRODUCT_NAME = ${TARGET_NAME}
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}

Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Please visit [Sparkle's website](http://sparkle-project.org) for up to date docu

## Requirements

* Runtime: macOS 10.11 or greater
* Runtime: macOS 10.13 or greater for 2.3, macOS 10.11 or greater for 2.2.x
* Build: Latest major Xcode (stable or beta, whichever is latest) and one major version less.
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))

Expand Down
6 changes: 3 additions & 3 deletions Resources/SampleAppcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</sparkle:fullReleaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="https://you.com/app/Your%20Great%20App%202.0.zip" length="1623481" type="application/octet-stream" sparkle:edSignature="WVyVJpOx+a5+vNWJVY79TRjFKveNk+VhGJf2iti4CZtJsJewIUGvh/1AKKEAFbH1qUwx+vro1ECuzOsMmumoBA==" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
</item>

<item>
Expand All @@ -31,7 +31,7 @@
</sparkle:fullReleaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<enclosure url="https://you.com/app/Your%20Great%20App%201.5.zip" length="1472893" type="application/octet-stream" sparkle:edSignature="pNFd7KbcQSu+Mq7UYrbQXTPq82luht2ACXm/r2utp1u/Uv/5hWqctdT2jwQgMejW7DRoeV/hVr6J4VdZYdwWDw==" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
</item>

<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
Expand All @@ -48,7 +48,7 @@
<sparkle:shortVersionString>1.4</sparkle:shortVersionString>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
<enclosure url="https://you.com/app/Your%20Great%20App%201.4.zip" sparkle:edSignature="Ody3D/ybSMH4T+P/oNj3LN4F0SA8RJGLEr1TI4UemrBAiJ9aEcDnYV3u58P75AbcFjI13jPYmHDUHXMSTFQbDw==" length="1472349" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
</item>
</channel>
</rss>
2 changes: 1 addition & 1 deletion Sparkle.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
'Andy Matuschak' => 'andy@andymatuschak.org',
}

s.platform = :osx, '10.11'
s.platform = :osx, '10.13'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.xz" }
s.source_files = 'Sparkle.framework/Versions/B/Headers/*.h'

Expand Down
58 changes: 10 additions & 48 deletions Sparkle/SPUSecureCoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,20 @@

NSData * _Nullable SPUArchiveRootObjectSecurely(id<NSSecureCoding> rootObject)
{
if (@available(macOS 10.13, *)) {
NSError *error = nil;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rootObject requiringSecureCoding:YES error:&error];
if (data == nil) {
SULog(SULogLevelError, @"Error while securely archiving object: %@", error);
}
return data;
} else {
NSMutableData *data = [NSMutableData data];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSKeyedArchiver *keyedArchiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
#pragma clang diagnostic pop
keyedArchiver.requiresSecureCoding = YES;

@try {
[keyedArchiver encodeObject:rootObject forKey:SURootObjectArchiveKey];
[keyedArchiver finishEncoding];
return [data copy];
} @catch (NSException *exception) {
SULog(SULogLevelError, @"Exception while securely archiving object: %@", exception);
[keyedArchiver finishEncoding];
return nil;
}
NSError *error = nil;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rootObject requiringSecureCoding:YES error:&error];
if (data == nil) {
SULog(SULogLevelError, @"Error while securely archiving object: %@", error);
}
return data;
}

id<NSSecureCoding> _Nullable SPUUnarchiveRootObjectSecurely(NSData *data, Class klass)
{
if (@available(macOS 10.13, *)) {
NSError *error = nil;
id<NSSecureCoding> rootObject = [NSKeyedUnarchiver unarchivedObjectOfClass:klass fromData:data error:&error];
if (rootObject == nil) {
SULog(SULogLevelError, @"Error while securely unarchiving object: %@", error);
}
return rootObject;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
#pragma clang diagnostic pop
unarchiver.requiresSecureCoding = YES;

@try {
id<NSSecureCoding> rootObject = [unarchiver decodeObjectOfClass:klass forKey:SURootObjectArchiveKey];
[unarchiver finishDecoding];
return rootObject;
} @catch (NSException *exception) {
SULog(SULogLevelError, @"Exception while securely unarchiving object: %@", exception);
[unarchiver finishDecoding];
return nil;
}
NSError *error = nil;
id<NSSecureCoding> rootObject = [NSKeyedUnarchiver unarchivedObjectOfClass:klass fromData:data error:&error];
if (rootObject == nil) {
SULog(SULogLevelError, @"Error while securely unarchiving object: %@", error);
}
return rootObject;
}
4 changes: 2 additions & 2 deletions Sparkle/SUAppcastItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
This version string should contain three period-separated components.
Example: @c 10.12.0
Example: @c 10.13.0
Use `minimumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
Expand All @@ -201,7 +201,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
This version string should contain three period-separated components.
Example: @c 10.13.0
Example: @c 10.14.0
Use `maximumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
Expand Down
2 changes: 1 addition & 1 deletion Sparkle/SUFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
* Otherwise on failure you may need to re-try using move operations. This operation will fail on non-apfs volumes or volumes that don't support rename swapping.
* Both originalItemURL and newItemURL must exist.
*/
- (BOOL)swapItemAtURL:(NSURL *)originalItemURL withItemAtURL:(NSURL *)newItemURL error:(NSError **)error API_AVAILABLE(macos(10.13));
- (BOOL)swapItemAtURL:(NSURL *)originalItemURL withItemAtURL:(NSURL *)newItemURL error:(NSError **)error;

/**
* Copies an item from a source to a destination
Expand Down
4 changes: 1 addition & 3 deletions Sparkle/SULog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ typedef NS_ENUM(uint8_t, SULogLevel) {
SULogLevelError
};

// Logging utlity function that is thread-safe
// On 10.12 or later this uses os_log
// Otherwise on older systems this uses ASL
// Logging utlity function that is thread-safe and uses os_log
// For debugging command line tools, you may have to use Console.app or log(1) to view log messages
// Try to keep log messages as compact/short as possible
void SULog(SULogLevel level, NSString *format, ...) NS_FORMAT_FUNCTION(2, 3);
Expand Down
Loading

0 comments on commit 372f050

Please sign in to comment.