mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76acd9cb5f | ||
|
|
e4b2d96faf | ||
|
|
9229fc57b1 | ||
|
|
c396a53c6f | ||
|
|
2a67e2d732 | ||
|
|
a135f1a1ee | ||
|
|
30361b0128 | ||
|
|
cce5edd78d | ||
|
|
515b8259bc | ||
|
|
edc0fd0e56 | ||
|
|
b4e0dcca6c | ||
|
|
ee679586cf | ||
|
|
c6f1cd4e3c | ||
|
|
306ea26df8 | ||
|
|
d719b92636 | ||
|
|
b43b188c82 | ||
|
|
6b9981f567 | ||
|
|
34fcb8784b | ||
|
|
4f7ed347ab | ||
|
|
9823892062 | ||
|
|
a22562431b | ||
|
|
4db96f6c4f | ||
|
|
385673ff24 | ||
|
|
c3cdbf46cb | ||
|
|
89ab067477 | ||
|
|
29a2fa7974 | ||
|
|
cb9386a4ea | ||
|
|
119766a650 | ||
|
|
9eba644190 | ||
|
|
4a87deeb7f | ||
|
|
a09aad7ca0 | ||
|
|
9c360b465b |
No files matched your search
@@ -0,0 +1,75 @@
|
||||
name: "Create Draft Release"
|
||||
|
||||
env:
|
||||
BUILDDIR: "build"
|
||||
DEVELOPER_DIR: "/Applications/Xcode_12.5.1.app/Contents/Developer"
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
|
||||
concurrency:
|
||||
group: publish-release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: "Publish binaries for release"
|
||||
runs-on: macos-11
|
||||
|
||||
steps:
|
||||
- name: "Checkout sources"
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Extract latest changes from CHANGELOG"
|
||||
run: |
|
||||
./Configurations/generate_latest_changes.py > latest-changes.txt
|
||||
|
||||
- name: "Extract version information from project"
|
||||
run: |
|
||||
MARKETING_VERSION=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep -m 1 '^[[:space:]]*MARKETING_VERSION' | sed -E 's/.+=[[:space:]]+(.*)$/\1/')
|
||||
echo "MARKETING_VERSION=${MARKETING_VERSION}" >> $GITHUB_ENV
|
||||
|
||||
- name: "Determine if this is a pre-release version"
|
||||
run: |
|
||||
SPARKLE_VERSION_SUFFIX=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep -m 1 '^[[:space:]]*SPARKLE_VERSION_SUFFIX' | sed -E 's/.+=[[:space:]]+(.*)$/\1/')
|
||||
if [[ ! -z "$SPARKLE_VERSION_SUFFIX" ]]; then
|
||||
echo "PRERELEASE_VERSION=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "PRERELEASE_VERSION=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: "Set up git and create tag"
|
||||
run: |
|
||||
git config user.name Sparkle-Bot
|
||||
git config user.email sparkle.project.bot@gmail.com
|
||||
git tag "${{ env.MARKETING_VERSION }}"
|
||||
|
||||
- name: "Build release distribution"
|
||||
run: make release
|
||||
env:
|
||||
GITHUB_ACTOR: ${{ github.actor }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
|
||||
- name: "Push the updated Swift package description"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
run: git push
|
||||
|
||||
- name: "Draft a release"
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
prerelease: ${{ env.PRERELEASE_VERSION }}
|
||||
name: "Sparkle ${{ env.MARKETING_VERSION }}"
|
||||
tag_name: ${{ env.MARKETING_VERSION }}
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
body_path: latest-changes.txt
|
||||
files: |
|
||||
build/Build/Products/Release/Sparkle-*.tar.xz
|
||||
build/Build/Products/Release/Sparkle-for-Swift-Package-Manager.zip
|
||||
@@ -35,7 +35,7 @@
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 7ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 5ull
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show display progress UI after a delay from starting the final part of the installation.
|
||||
* This should be long enough so that we don't show progress for very fast installations, but
|
||||
* short enough so that we don't leave the user wondering why nothing is happening.
|
||||
|
||||
@@ -186,6 +186,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
|
||||
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
|
||||
BOOL removedFile = NO;
|
||||
|
||||
// Files that have no property set that we check for will get ignored
|
||||
// This is important because they aren't part of the delta, just part of the directory structure
|
||||
|
||||
const char *value;
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||
|
||||
@@ -61,7 +61,6 @@ typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
|
||||
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
|
||||
|
||||
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
||||
extern NSData *hashOfFileContents(FTSENT *ent);
|
||||
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
|
||||
extern NSString *hashOfTree(NSString *path);
|
||||
extern BOOL removeTree(NSString *path);
|
||||
|
||||
@@ -45,7 +45,7 @@ int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
||||
case SUAzureMajorVersion:
|
||||
return 1;
|
||||
case SUBeigeMajorVersion:
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -137,15 +137,6 @@ static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSData *hashOfFileContents(FTSENT *ent)
|
||||
{
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
if (!_hashOfFileContents(fileHash, ent)) {
|
||||
return nil;
|
||||
}
|
||||
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
|
||||
}
|
||||
|
||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
{
|
||||
char pathBuffer[PATH_MAX] = { 0 };
|
||||
@@ -190,6 +181,11 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
uint16_t mode = ent->fts_statp->st_mode;
|
||||
// permission of symlinks is irrelevant and can't be changed.
|
||||
// hardcoding a value helps avoid differences between filesystems.
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
mode = 0755;
|
||||
}
|
||||
uint16_t type = ent->fts_info;
|
||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||
|
||||
|
||||
@@ -66,25 +66,23 @@ extern int bsdiff(int argc, const char **argv);
|
||||
|
||||
@end
|
||||
|
||||
#define INFO_HASH_KEY @"hash"
|
||||
#define INFO_PATH_KEY @"path"
|
||||
#define INFO_TYPE_KEY @"type"
|
||||
#define INFO_PERMISSIONS_KEY @"permissions"
|
||||
#define INFO_SIZE_KEY @"size"
|
||||
|
||||
static NSDictionary *infoForFile(FTSENT *ent)
|
||||
{
|
||||
NSData *hash = hashOfFileContents(ent);
|
||||
if (!hash) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
|
||||
|
||||
assert(ent->fts_statp != NULL);
|
||||
|
||||
mode_t permissions = ent->fts_statp->st_mode & PERMISSION_FLAGS;
|
||||
|
||||
return @{ INFO_HASH_KEY: hash,
|
||||
NSString *path = @(ent->fts_path);
|
||||
assert(path != nil);
|
||||
|
||||
return @{ INFO_PATH_KEY: path != nil ? path : @"",
|
||||
INFO_TYPE_KEY: @(ent->fts_info),
|
||||
INFO_PERMISSIONS_KEY: @(permissions),
|
||||
INFO_SIZE_KEY: @(size) };
|
||||
@@ -174,12 +172,19 @@ static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
unsigned short originalInfoType = [(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
unsigned short newInfoType = [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
if (originalInfoType != newInfoType) {
|
||||
// File types are different
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([(NSData *)originalInfo[INFO_HASH_KEY] isEqual:(NSData *)newInfo[INFO_HASH_KEY]]) {
|
||||
// this is possible if just the permissions have changed
|
||||
NSString *originalPath = originalInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = newInfo[INFO_PATH_KEY];
|
||||
|
||||
// Skip delta if both entries are directories, or if the files/symlinks are equal in content
|
||||
if (originalInfoType == FTS_D || [[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath]) {
|
||||
// this is possible if just the permissions have changed but contents have not
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -205,11 +210,21 @@ static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newIn
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
unsigned short originalInfoType = [(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
unsigned short newInfoType = [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
|
||||
if (originalInfoType != newInfoType) {
|
||||
// File types are different
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![(NSData *)originalInfo[INFO_HASH_KEY] isEqual:(NSData *)newInfo[INFO_HASH_KEY]]) {
|
||||
|
||||
NSString *originalPath = originalInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = newInfo[INFO_PATH_KEY];
|
||||
|
||||
// Don't skip extract if files/symlinks entries are not equal in content
|
||||
// (note if the entries are directories, they are equal)
|
||||
if (originalInfoType != FTS_D && ![[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -233,6 +248,52 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne
|
||||
return YES;
|
||||
}
|
||||
|
||||
static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTable, xar_t x, NSString *relativePath, NSString *filePath)
|
||||
{
|
||||
NSArray<NSString *> *rootRelativePathComponents = relativePath.pathComponents;
|
||||
// Relative path must at least have starting "/" component and one more path component
|
||||
if (rootRelativePathComponents.count < 2) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSArray<NSString *> *relativePathComponents = [rootRelativePathComponents subarrayWithRange:NSMakeRange(1, rootRelativePathComponents.count - 1)];
|
||||
|
||||
NSUInteger relativePathComponentsCount = relativePathComponents.count;
|
||||
|
||||
// Build parent files as needed until we get to our final file we want to add
|
||||
// So if we get "Contents/Resources/foo.txt", we will first add "Contents" parent,
|
||||
// then "Resources" parent, then "foo.txt" as the final entry we want to add
|
||||
// We store every file we add into a fileTable for easy referencing
|
||||
// Note if a diff has Contents/Resources/foo/ and Contents/Resources/foo/bar.txt,
|
||||
// due to sorting order we will add the foo directory first and won't end up with
|
||||
// mis-ordering bugs
|
||||
xar_file_t lastParent = NULL;
|
||||
for (NSUInteger componentIndex = 0; componentIndex < relativePathComponentsCount; componentIndex++) {
|
||||
NSArray<NSString *> *subpathComponents = [relativePathComponents subarrayWithRange:NSMakeRange(0, componentIndex + 1)];
|
||||
NSString *subpathKey = [subpathComponents componentsJoinedByString:@"/"];
|
||||
|
||||
xar_file_t cachedFile = [fileTable[subpathKey] pointerValue];
|
||||
if (cachedFile != NULL) {
|
||||
lastParent = cachedFile;
|
||||
} else {
|
||||
xar_file_t newParent;
|
||||
|
||||
BOOL atLastIndex = (componentIndex == relativePathComponentsCount - 1);
|
||||
|
||||
NSString *lastPathComponent = subpathComponents.lastObject;
|
||||
if (atLastIndex && filePath != nil) {
|
||||
newParent = xar_add_frompath(x, lastParent, lastPathComponent.fileSystemRepresentation, filePath.fileSystemRepresentation);
|
||||
} else {
|
||||
newParent = xar_add_frombuffer(x, lastParent, lastPathComponent.fileSystemRepresentation, "", 1);
|
||||
}
|
||||
|
||||
lastParent = newParent;
|
||||
fileTable[subpathKey] = [NSValue valueWithPointer:newParent];
|
||||
}
|
||||
}
|
||||
return lastParent;
|
||||
}
|
||||
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError *__autoreleasing *error)
|
||||
{
|
||||
assert(source);
|
||||
@@ -489,11 +550,14 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
|
||||
}];
|
||||
|
||||
NSMutableDictionary<NSString *, NSValue *> *fileTable = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSString *key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
|
||||
if ([(NSObject *)value isEqual:[NSNull null]]) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
xar_file_t newFile = _xarAddFile(fileTable, x, key, NULL);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||
|
||||
@@ -508,7 +572,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (shouldSkipDeltaCompression(originalInfo, newInfo)) {
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && shouldSkipExtracting(originalInfo, newInfo)) {
|
||||
if (shouldChangePermissions(originalInfo, newInfo)) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
xar_file_t newFile = _xarAddFile(fileTable, x, key, NULL);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
|
||||
|
||||
@@ -518,7 +582,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
} else {
|
||||
NSString *path = [destination stringByAppendingPathComponent:key];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
||||
xar_file_t newFile = _xarAddFile(fileTable, x, key, path);
|
||||
assert(newFile);
|
||||
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||
@@ -570,7 +634,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||
xar_file_t newFile = _xarAddFile(fileTable, x, [operation relativePath], resultPath);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
|
||||
unlink([resultPath fileSystemRepresentation]);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Security/SecCode.h>
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -23,24 +24,38 @@
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecStaticCodeRef oldCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Bundle is not code signed: %@", newBundleURL] }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
NSString *message = [NSString stringWithFormat:@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result];
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
NSString *message = [NSString stringWithFormat:@"Failed to get static code %d", result];
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
@@ -51,24 +66,56 @@
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(SULogLevelError, @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
if (result != errSecSuccess) {
|
||||
NSError *underlyingError;
|
||||
if (cfError != NULL) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
underlyingError = tmpError;
|
||||
} else {
|
||||
underlyingError = nil;
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
if (underlyingError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
if (result == errSecCSUnsigned) {
|
||||
NSString *message = @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else if (result == errSecCSReqFailed) {
|
||||
CFStringRef requirementString = nil;
|
||||
NSString *initialMessage;
|
||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
||||
SULog(SULogLevelError, @"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
initialMessage = [NSString stringWithFormat:@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString];
|
||||
|
||||
SULog(SULogLevelError, @"%@", initialMessage);
|
||||
CFRelease(requirementString);
|
||||
} else {
|
||||
initialMessage = @"Code signature of new version doesn't match the old version. Please ensure that old and new app is signed using exactly the same certificate.";
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
NSDictionary *oldInfo = [self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"%@ old info: %@. new info: %@", initialMessage, oldInfo, newInfo];
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = @"Error: Old app bundle code signing signature failed to match new bundle code signature";
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +131,15 @@ finally:
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to get static code for verifying code signature: %d", result] }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
@@ -98,17 +147,47 @@ finally:
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(SULogLevelError, @"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||
if (result != errSecSuccess) {
|
||||
NSError *underlyingError;
|
||||
if (cfError != NULL) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
underlyingError = tmpError;
|
||||
} else {
|
||||
underlyingError = nil;
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
if (underlyingError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
if (result == errSecCSUnsigned) {
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app is not signed using Apple Code Signing. %@", bundleURL];
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else if (result == errSecCSReqFailed) {
|
||||
if (error != NULL) {
|
||||
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@ - new info: %@", bundleURL, newInfo];
|
||||
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@", bundleURL];
|
||||
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,9 +232,10 @@ finally:
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
+ (NSDictionary *)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
|
||||
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
||||
return relevantInfo;
|
||||
}
|
||||
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// 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.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
@interface SUPlainInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
/*!
|
||||
/**
|
||||
@param host The current (old) bundle host
|
||||
@param bundlePath The path to the new bundle that will be installed.
|
||||
@param installationPath The path the new bundlePath will be installed to.
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys;
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error;
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures;
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUErrors.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
|
||||
@@ -30,22 +31,26 @@
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
|
||||
if (!verifier) {
|
||||
if (verifier == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create SUSignatureVerifier instance" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [verifier verifyFileAtPath:path signatures:signatures];
|
||||
return [verifier verifyFileAtPath:path signatures:signatures error:error];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
|
||||
{
|
||||
self = [super init];
|
||||
_pubKeys = pubkeys;
|
||||
|
||||
if (self != nil) {
|
||||
_pubKeys = pubkeys;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -85,14 +90,19 @@
|
||||
return dsaPubKeySecKey;
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (!path || !path.length) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Path passed to verify has zero length and is not valid" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!signatures) {
|
||||
SULog(SULogLevelDefault, @"No signatures given to verifyFileAtPath");
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"No signatures given to verifyFileAtPath" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -104,26 +114,55 @@
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
|
||||
// We will have already logged an error for this failure when the public key was read in, so just do an informational log here.
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but the app has an invalid EdDSA public key, so the update will automatically be rejected.");
|
||||
NSString *message = @"The update has an EdDSA signature, but the app has an invalid EdDSA public key, so the update will automatically be rejected.";
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
SULog(SULogLevelDefault, @"The app has an invalid EdDSA public key, but there is no EdDSA signature in the update. Falling back to DSA.");
|
||||
break;
|
||||
case SUSigningInputStatusPresent:
|
||||
switch (signatures.ed25519SignatureStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
SULog(SULogLevelError, @"The app has an EdDSA public key, but there is no EdDSA signature in the update, so the update will be rejected.");
|
||||
case SUSigningInputStatusAbsent: {
|
||||
NSString *message = @"The app has an EdDSA public key, but there is no EdDSA signature in the update, so the update will be rejected.";
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
case SUSigningInputStatusInvalid:
|
||||
// We will have already logged an error for this failure when the signature was read in, so just do an informational log here.
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it's invalid, so the update will automatically be rejected.");
|
||||
}
|
||||
case SUSigningInputStatusInvalid: {
|
||||
NSString *message = @"The update has an EdDSA signature, but it's invalid, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
case SUSigningInputStatusPresent: {
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&error];
|
||||
NSError *dataError = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&dataError];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, error);
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, dataError);
|
||||
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Failed to load file: %@", path];
|
||||
if (dataError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = dataError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(signatures.ed25519Signature, data.bytes, data.length, self.pubKeys.ed25519PubKey)) {
|
||||
@@ -134,10 +173,18 @@
|
||||
return YES;
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
NSString *message = @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +201,14 @@
|
||||
case SUSigningInputStatusInvalid:
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
// We will have already logged an error for this failure when the public key was read in, so just do an informational log here.
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but the app has an invalid DSA public key, so the update will automatically be rejected.");
|
||||
NSString *message = @"The update has a DSA signature, but the app has an invalid DSA public key, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
SULog(SULogLevelDefault, @"The app has an invalid DSA public key, but there is no DSA signature in the update.");
|
||||
@@ -164,29 +218,50 @@
|
||||
case SUSigningInputStatusAbsent:
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
// We will have already logged an error for this failure when the signature was read in, so just do an informational log here.
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it's invalid, so the update will automatically be rejected.");
|
||||
case SUSigningInputStatusInvalid: {
|
||||
NSString *message = @"The update has a DSA signature, but it's invalid, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
case SUSigningInputStatusPresent: {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:signatures.dsaSignature];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:signatures.dsaSignature error:error];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (error != NULL) {
|
||||
// Use generic failure
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"EdDSA and DSA verification for the update has failed" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature error:(NSError * __autoreleasing *)outError
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Invalid arguments to verifyStream" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
|
||||
if (!dsaPubKeySecKey) {
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create DSA Sec Key Ref" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -208,12 +283,18 @@
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(SULogLevelError, @"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecTransform for input stream)" }];
|
||||
}
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecDigest for input stream)" }];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
@@ -221,31 +302,54 @@
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
if (!dataVerifyTransform) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
if (outError != NULL) {
|
||||
NSError *underlyingError = (__bridge NSError *)error;
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Could not understand format of the signature data %@", dsaSignature];
|
||||
if (underlyingError != NULL) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data read transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data digest transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature verification failed", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(SULogLevelError, @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set"}];
|
||||
}
|
||||
}
|
||||
|
||||
cleanup();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Added command line utility to update Sparkle-based bundles (Zorg)
|
||||
* More modern architecture
|
||||
* Moves extraction, validation, and installation into a submitted launchd agent/daemon with XPC communication (Zorg)
|
||||
* Features faster installs with shorter update/relaunch times (Zorg)
|
||||
* Features faster installs with shorter update/relaunch times (#1802) (Zorg)
|
||||
* Provides more robust installs that need to request user authorization (Zorg)
|
||||
* Adoption of atomic-safe bundle replacing updates leveraging APFS (#1801) (Zorg)
|
||||
* API Changes
|
||||
@@ -14,9 +14,10 @@
|
||||
* Decoupled AppKit and UI logic in the framework from core functionality (Zorg)
|
||||
* Ensure (most) API / ABI compatibility with Sparkle 1.x; you can likely test Sparkle 2 in an existing app without any changes (Zorg)
|
||||
* Deprecated SUUpdater, albeit it is still functional for testing and transitional purposes (Zorg)
|
||||
* `-bestValidUpdateInAppcast:forUpdater:` delegate method behavior has been refined and discouraged for some cases. Please review its updated header documentation in `SPUUpdaterDelegate.h` if you use this method. (#1838, #1862, #1879, #1880) (Zorg)
|
||||
* Delegation methods may have been removed or added to the newer updater API. Please review `SPUUpdaterDelegate` if using `SPUUpdater`. (Zorg)
|
||||
* Updater Changes
|
||||
* Automatic silent and manual update alert prompts are now merged together
|
||||
* Automatic silent and manual update alert prompts are now merged together (Zorg)
|
||||
* Updates will attempt to install even if the user quits the application without relaunching the application update explicitly (Zorg)
|
||||
* Updates can be downloaded in the background automatically but later prompt the user to install them, particularly if Sparkle doesn't have sufficient permission to install them without the user's permission (Zorg)
|
||||
* Authorization now occurs before launching the installer and before terminating the application, which can be canceled by the user cleanly (Zorg)
|
||||
@@ -25,14 +26,25 @@
|
||||
* Policy Changes
|
||||
* Distributing updates without EdDSA signing the archives is now deprecated (Zorg)
|
||||
* Package based updates that are zipped or archived must add sparkle:installationType="package" to the appcast item enclosure (Zorg)
|
||||
* We now recommend using sparkle:version and sparkle:shortVersionString top level elements instead of enclosure attributes (#1878) (Zorg)
|
||||
* The link element in an appcast item is now used for directing users to the product's website if they don't meet minimum system requirements (#1877) (Zorg)
|
||||
* Major/Paid Upgrades Enhancements
|
||||
* Latest minor updates are preferred over major updates (specified by sparkle:minimumAutoupdateVersion) (#1850) Zorg
|
||||
* Major updates can be skipped with a user confirmation (#1853) Zorg
|
||||
* Informational only and critical updates can be specified selectively by app version (#1862)
|
||||
* Expose why a new update is unavailable and direct user to prior release notes or website info (#1877, #1886) (Zorg)
|
||||
* Add support for posting updates only on specific channels (#1879) (Zorg)
|
||||
* System profiler privacy and transparency (#1690) (Martin Pilkington)
|
||||
* Support getting app icon from asset catalog (#1694) (Charles Srstka)
|
||||
* Don't hide update alert window now on deactivation (#1804) (Zorg)
|
||||
* Don't bring up authorization just because group ID doesn't match (#1830) (Zorg)
|
||||
* Raise minimum system version to 10.11 (Zorg)
|
||||
* Special thanks to developers using early builds of this release in production and contributors for keeping this running (Kornel, Jonas Zaugg, Gwynne Raskind, Jordan Rose, Tony Arnold, Bryan Jones, Christian Tietze, Jakob Egger, and many more)
|
||||
|
||||
Please visit [Sparkle's website](http://sparkle-project.org) for more information on documentation and migration.
|
||||
|
||||
If you are migrating from earlier alpha versions of Sparkle 2, please re-familiarize yourself with the [Sandboxing guide](https://sparkle-project.org/documentation/sandboxing/). Some of the XPC Services are now optional and integration with code signing has been simplified. The SPUUserDriver protocol for custom user interfaces has been greatly simplified too.
|
||||
|
||||
# 1.26.0
|
||||
|
||||
* Flat package support from #1745 (Zorg)
|
||||
|
||||
@@ -17,12 +17,16 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_ICON_NAME = AppIcon
|
||||
|
||||
// If you change any of these version details, you must increase CURRENT_PROJECT_VERSION
|
||||
SPARKLE_VERSION_MAJOR = 2
|
||||
SPARKLE_VERSION_MINOR = 0
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
|
||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||
// This should be in SemVer format or empty, ie. "-beta.1"
|
||||
SPARKLE_VERSION_SUFFIX = -beta.2
|
||||
CURRENT_PROJECT_VERSION = 2002
|
||||
|
||||
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||
@@ -38,7 +42,7 @@ INSTALLER_STATUS_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerStatus
|
||||
INSTALLER_LAUNCHER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerLauncher
|
||||
DOWNLOADER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.Downloader
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\"
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" MARKETING_VERSION=\"$(MARKETING_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
SDKROOT = macosx
|
||||
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys
|
||||
|
||||
# Ignore the first version line starting with # x.y.z..
|
||||
# and print everything until the second version line starting with # x.y.z..
|
||||
|
||||
hit_first_changelog_note = False
|
||||
with open("CHANGELOG", "r") as changelog_file:
|
||||
for line in changelog_file:
|
||||
if line.startswith("#"):
|
||||
if hit_first_changelog_note:
|
||||
# We are done with printing changes
|
||||
break
|
||||
else:
|
||||
# We haven't hit an important changelog line yet, so continue
|
||||
continue
|
||||
|
||||
if not hit_first_changelog_note and len(line.strip()) == 0:
|
||||
continue
|
||||
|
||||
hit_first_changelog_note = True
|
||||
sys.stdout.write(line)
|
||||
@@ -1,20 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
# If using cocoapods, sanity check that the Podspec version matches the Sparkle version
|
||||
if [ -x "$(command -v pod)" ]; then
|
||||
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
|
||||
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
||||
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Tests the code signing validity of the extracted products within the provided path.
|
||||
# This guards against our archives being corrupt / created incorrectly.
|
||||
function verify_code_signatures() {
|
||||
verification_directory="$1"
|
||||
|
||||
if [[ -z "$verification_directory" ]]; then
|
||||
echo "Provided verification directory does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Search the current directory for all instances of the framework to verify them (XCFrameworks can have multiple copies of a framework for different platforms).
|
||||
find "${verification_directory}" -name "Sparkle.framework" -type d -exec codesign --verify -vvv --deep {} \;
|
||||
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.Downloader.xpc"
|
||||
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerConnection.xpc"
|
||||
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerLauncher.xpc"
|
||||
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerStatus.xpc"
|
||||
codesign --verify -vvv --deep "${verification_directory}/sparkle.app"
|
||||
codesign --verify -vvv --deep "${verification_directory}/Sparkle Test App.app"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/BinaryDelta"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/generate_appcast"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/sign_update"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/generate_keys"
|
||||
}
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
rm -f "Sparkle-$MARKETING_VERSION.tar.xz"
|
||||
rm -f "Sparkle-$MARKETING_VERSION.tar.bz2"
|
||||
rm -f "Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
@@ -80,72 +95,74 @@ if [ "$ACTION" = "" ] ; then
|
||||
|
||||
# Sorted file list groups similar files together, which improves tar compression
|
||||
if [ "$XZ_EXISTS" -eq 1 ] ; then
|
||||
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
|
||||
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$MARKETING_VERSION.tar.xz"
|
||||
|
||||
# Copy archived distribution for CI
|
||||
cp -f "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz" "../sparkle-dist.tar.xz"
|
||||
cp -f "../Sparkle-$MARKETING_VERSION.tar.xz" "../sparkle-dist.tar.xz"
|
||||
|
||||
# Extract archive for testing binary validity
|
||||
tar -xf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz" -C "/tmp/sparkle-extract"
|
||||
tar -xf "../Sparkle-$MARKETING_VERSION.tar.xz" -C "/tmp/sparkle-extract"
|
||||
else
|
||||
# Fallback to bz2 compression if xz utility is not available
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$MARKETING_VERSION.tar.bz2" --files-from=-
|
||||
|
||||
# Extract archive for testing binary validity
|
||||
tar -xf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" -C "/tmp/sparkle-extract"
|
||||
tar -xf "../Sparkle-$MARKETING_VERSION.tar.bz2" -C "/tmp/sparkle-extract"
|
||||
fi
|
||||
|
||||
# Test code signing validity of the extracted products
|
||||
# This guards against our archives being corrupt / created incorrectly
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/Sparkle.framework"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.Downloader.xpc"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerConnection.xpc"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerLauncher.xpc"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerStatus.xpc"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/sparkle.app"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/Sparkle Test App.app"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/BinaryDelta"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/generate_appcast"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/sign_update"
|
||||
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/generate_keys"
|
||||
verify_code_signatures "/tmp/sparkle-extract"
|
||||
|
||||
rm -rf "/tmp/sparkle-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
# Generate zip containing the xcframework for SPM
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
mkdir -p "/tmp/sparkle-spm-extract"
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
#rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
|
||||
zip -rqyX -9 "../Sparkle-for-Swift-Package-Manager.zip" *
|
||||
# rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
|
||||
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
# Test code signing validity of the extracted Swift package
|
||||
# This guards against our archives being corrupt / created incorrectly
|
||||
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
|
||||
verify_code_signatures "/tmp/sparkle-spm-extract"
|
||||
|
||||
# GitHub actions set the CI environment variable to true
|
||||
if [ "$CI" != true ]; then
|
||||
# Get latest git tag
|
||||
cd "$SRCROOT"
|
||||
latest_git_tag=$(git describe --tags --abbrev=0)
|
||||
# Check semantic versioning
|
||||
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
|
||||
echo "Tag $latest_git_tag follows semantic versioning"
|
||||
else
|
||||
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
# Get latest git tag
|
||||
cd "$SRCROOT"
|
||||
latest_git_tag=$(git describe --tags --abbrev=0)
|
||||
|
||||
# Check semantic versioning
|
||||
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
|
||||
echo "Tag $latest_git_tag follows semantic versioning"
|
||||
else
|
||||
# Dummy placeholder for CI test builds as we don't really need to update Package.swift for building and testing purposes
|
||||
latest_git_tag="CI_BUILD"
|
||||
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Generate new Package manifest
|
||||
|
||||
# Generate new Package manifest and podspec
|
||||
cd "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
|
||||
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
|
||||
# is equivalent to shasum -a 256 FILE
|
||||
spm_checksum=$(swift package compute-checksum "Sparkle-for-Swift-Package-Manager.zip")
|
||||
rm -rf ".build"
|
||||
sed -E -i '' -e "/let tag/ s/\".+\"/\"$latest_git_tag\"/" -e "/let version/ s/\".+\"/\"$CURRENT_PROJECT_VERSION\"/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
|
||||
sed -E -i '' -e "/let tag/ s/\".+\"/\"$latest_git_tag\"/" -e "/let version/ s/\".+\"/\"$MARKETING_VERSION\"/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
|
||||
cp "Package.swift" "$SRCROOT"
|
||||
echo "Package.swift updated with the following values:"
|
||||
echo "Version: $CURRENT_PROJECT_VERSION"
|
||||
echo "Version: $MARKETING_VERSION"
|
||||
echo "Tag: $latest_git_tag"
|
||||
echo "Checksum: $spm_checksum"
|
||||
|
||||
sed -E -i '' -e "/s\.version.+=/ s/\".+\"/\"$MARKETING_VERSION\"/" "Sparkle.podspec"
|
||||
cp "Sparkle.podspec" "$SRCROOT"
|
||||
echo "Sparkle.podspec updated with following values:"
|
||||
echo "Version: $MARKETING_VERSION"
|
||||
else
|
||||
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
|
||||
fi
|
||||
|
||||
@@ -2,25 +2,32 @@
|
||||
set -e
|
||||
|
||||
# Convenience script to automatically commit Package.swift after updating the checksum and move the latest tag
|
||||
latest_git_tag=$(git describe --abbrev=0) # gets the latest tag name
|
||||
latest_git_tag=$(git describe --tags --abbrev=0) # gets the latest tag name
|
||||
commits_since_tag=$(git rev-list ${latest_git_tag}.. --count)
|
||||
|
||||
function move_tag() {
|
||||
long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message
|
||||
long_message=${long_message/$latest_git_tag} # trims tag name
|
||||
long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace
|
||||
git add Package.swift Sparkle.podspec
|
||||
git commit -m "Update Package.swift and Sparkle.podspec for version ${latest_git_tag}"
|
||||
git tag -fa $latest_git_tag -m "${long_message}"
|
||||
echo "Package.swift and Sparkle.podspec committed and tag '$latest_git_tag' moved."
|
||||
}
|
||||
|
||||
if [ "$commits_since_tag" -gt 0 ]; then
|
||||
# If there have been commits since the latest tag, it's highly likely that we did not intend to do a full release
|
||||
echo "WARNING: $commits_since_tag commit(s) since tag '$latest_git_tag'. Did you tag a new version?"
|
||||
echo "Package.swift has not been committed and tag has not been moved."
|
||||
elif [ "$CI" == true ]; then
|
||||
move_tag
|
||||
else
|
||||
# TODO: add sanity check to see if version is actually being updated or not?
|
||||
read -p "Do you want to commit changes to Package.swift and force move tag '$latest_git_tag'? (required for SPM release) [Y/n]" -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
echo "Package.swift has not been committed and tag has not been moved."
|
||||
# TODO: add sanity check to see if version is actually being updated or not?
|
||||
read -p "Do you want to commit changes to Package.swift and Sparkle.podspec, and force move tag '$latest_git_tag'? (required for official release) [Y/n]" -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
move_tag
|
||||
else
|
||||
long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message
|
||||
long_message=${long_message/$latest_git_tag} # trims tag name
|
||||
long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace
|
||||
git add Package.swift
|
||||
git commit -m "Update Package.swift"
|
||||
git tag -fa $latest_git_tag -m "${long_message}"
|
||||
echo "Package.swift committed and tag '$latest_git_tag' moved."
|
||||
echo "Package.swift and Sparkle.podspec have not been committed and tag has not been moved."
|
||||
fi
|
||||
fi
|
||||
@@ -8,12 +8,12 @@ fi
|
||||
if [ -z "$SRCROOT" ] || \
|
||||
[ -z "$BUILT_PRODUCTS_DIR" ] || \
|
||||
[ -z "$INFOPLIST_PATH" ] || \
|
||||
[ -z "$CURRENT_PROJECT_VERSION" ]; then
|
||||
[ -z "$MARKETING_VERSION" ]; then
|
||||
echo "$0: Must be run from Xcode!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="$CURRENT_PROJECT_VERSION"
|
||||
version="$MARKETING_VERSION"
|
||||
|
||||
# Get version in format 1.x.x-commits-hash
|
||||
gitversion=$( cd "$SRCROOT"; git describe --tags --match '[12].*' || true )
|
||||
@@ -22,10 +22,10 @@ if [ -z "$gitversion" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# remove everything before the first "-" to keep the hash part only
|
||||
versionsuffix=${gitversion#*-};
|
||||
# remove everything before the second last "-" to keep the hash part only
|
||||
versionsuffix=$( echo "${gitversion}" | sed -E 's/.+((-[^.]+){2})$/\1/' )
|
||||
if [ "$versionsuffix" != "$gitversion" ]; then
|
||||
version="$version $versionsuffix"
|
||||
version="$version$versionsuffix"
|
||||
fi
|
||||
|
||||
# and use it to set the CFBundleShortVersionString value
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Sparkle 2 API Reference
|
||||
|
||||
These are the primary classes and protocols in Sparkle 2 you may be interested in:
|
||||
|
||||
- `SPUStandardUpdaterController` for creating a standard updater (encapsulates a `SPUUpdater` and `SPUStandardUserDriver`)
|
||||
- `SPUUpdater` for invoking update checks and retrieving updater properties.
|
||||
- `SPUUpdaterDelegate` for delegation methods to control the behavior of `SPUUpdater`.
|
||||
- `SPUUserDriver` for making custom user interfaces.
|
||||
|
||||
If you are migrating from Sparkle 1, please refer to `SPUStandardUpdaterController` and `SPUUpdater`.
|
||||
|
||||
Please also visit the [Basic Setup](https://sparkle-project.org/documentation/) guide which shows how to instantiate an updater in a nib or how to create one programmatically.
|
||||
@@ -1,20 +0,0 @@
|
||||
PROJECT_NAME = Sparkle
|
||||
PROJECT_NUMBER = 1.14.0
|
||||
PROJECT_BRIEF = "A software update framework for macOS"
|
||||
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
|
||||
|
||||
RECURSIVE = YES
|
||||
INPUT = Sparkle
|
||||
OUTPUT_DIRECTORY = Documentation
|
||||
|
||||
GENERATE_HTML = YES
|
||||
GENERATE_LATEX = NO
|
||||
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST = YES
|
||||
GENERATE_TODOLIST = YES
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
|
||||
QT_AUTOBRIEF = YES
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
@@ -13,9 +13,9 @@
|
||||
### Launching the Installer
|
||||
SPUCoreBasedUpdateDriver invokes SPUInstallerDriver's extraction method which invokes SUInstallerLauncher's launch installer method. The launcher can be inside a XPC service or running inside the updater/sparkle framework itself. The launcher XPC bundle includes a copy of the installer and agent application in its bundle so it can compute the path to them itself (instead of relying on the updater to pass the paths), which is for security trust reasons.
|
||||
|
||||
First, the launcher makes sure that if the updater delegate doesn't allow interaction, that installation can be done without interaction. If it can't, then the launcher fails. If the updater driver that invoked the launcher doesn't allow for interaction (in particular, the automatic/silent update driver does not allow interaction), then the launcher fails with a hint to try again with interaction enabled (in particular, with a UI based update driver). If this happens, the updater keeps a reference to the downloaded update and appcast item that is used for resuming with a UI based update driver later. The launcher in this case is telling that authorization can only be done if interaction is allowed from the driver, so the user can enter their password to start up the installer as root to install over a location that requires such privileges.
|
||||
First, if the updater driver that invoked the launcher doesn't allow for interaction (in particular, the automatic/silent update driver does not allow interaction), then the launcher fails with a hint to try again with interaction enabled (in particular, with a UI based update driver). If this happens, the updater keeps a reference to the downloaded update and appcast item that is used for resuming with a UI based update driver later. The launcher in this case is telling that authorization can only be done if interaction is allowed from the driver, so the user can enter their password to start up the installer as root to install over a location that requires such privileges.
|
||||
|
||||
The launcher then looks for the installer and agent application first in its bundle's auxiliary directory path, and then its resources path. If the launcher is running inside a XPC service, the tools will be in the auxiliary path location, which allows the developer using the service to also code sign the tools. Once those paths are found, the launcher copies the progress agent application to a temporary cache location. The installer is not copied because it is a plain single executable that does not rely on external relative depedencies, whereas the agent application relies on bundle resources. This is important to consider because the old application may be moved around and removed when the installation process occurs. Leaving the installer inside its bundle also could leave it in a place the user doesn't necessarily have write privileges to.
|
||||
The launcher then looks for the installer and agent application first in its bundle's auxiliary directory path. Once those paths are found, the launcher copies the progress agent application to a temporary cache location. The installer is not copied because it is a plain single executable that does not rely on external relative dependencies, whereas the agent application relies on bundle resources. This is important to consider because the old application may be moved around and removed when the installation process occurs. Leaving the installer inside its bundle also could leave it in a place the user doesn't necessarily have write privileges to.
|
||||
|
||||
The installer is first submitted. If it requires root privileges, it will ask for an admin user name and password. How it determines if root privileges are necessary is based on:
|
||||
|
||||
@@ -27,7 +27,7 @@ The installer makes sure, after extraction, that the expected installation type
|
||||
|
||||
If the user cancels submitting the installer on authorization (if it's required), the launcher aborts the installation process silently. If everything does alright, the progress agent application is submitted next. If either of the submissions fail, the installation fails and aborts, otherwise the launcher succeeds and its job is done. Note before the submissions are done, the jobs are removed from launchd, and the jobs are submitted in a way that act as "one-time" jobs. If they fail or succeed, the jobs aren't restarted, and the jobs aren't installed in a system location for launchd to attempt launching again.
|
||||
|
||||
The only argument passed to the installer is the host bundle identifier of the bundle to update. This bundle identifier is used so that the installer and updater know what Mach service to connect to for IPC. Everything else to the installer is sent via a XPC connection. The host bundle path is passed to the progress agent, which is just used for obtaining the bundle identifier, and for UI purposes (eg: displaying app icon and name when the app needs to show progress). The type of domain the installer is running in (user vs system) is also passed to the progress agent application so it can know which domain to use to connect to the installer.
|
||||
The most important argument passed to the installer is the host bundle identifier of the bundle to update. This bundle identifier is used so that the installer and updater know what Mach service to connect to for IPC. Mostly everything else to the installer is sent via a XPC connection. The host bundle path is passed to the progress agent, which is just used for obtaining the bundle identifier, and for UI purposes (eg: displaying app icon and name when the app needs to show progress). The type of domain the installer is running in (user vs system) is also passed to the progress agent application so it can know which domain to use to connect to the installer.
|
||||
|
||||
### Timeouts
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
if which -s doxygen ; then
|
||||
doxygen Documentation/Doxyfile
|
||||
else
|
||||
echo "warning: Doxygen not found in PATH"
|
||||
echo "open Terminal and type this command 'brew install doxygen' then click 'enter/return' key. finally build this target again"
|
||||
fi
|
||||
elif [ "$ACTION" = "clean" ] ; then
|
||||
rm -rf "$SRCROOT/Documentation/html"
|
||||
fi
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "SPULocalCacheDirectory.h"
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SPUDownloadDataPrivate.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// SUInstallerLauncher+Private.h
|
||||
// SUInstallerLauncher+Private
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/21/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUInstallerLauncher_Private_h
|
||||
#define SUInstallerLauncher_Private_h
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
// Chances are clients will need this too
|
||||
#import <Sparkle/SPUInstallationType.h>
|
||||
|
||||
@class NSString;
|
||||
|
||||
/**
|
||||
Private API for determining if the system needs authorization access to update a bundle path
|
||||
|
||||
This API is not supported when used directly from a Sandboxed applications and will always return @c YES in that case.
|
||||
|
||||
@param bundlePath The bundle path to test if authorization is needed when performing an update that replaces this bundle.
|
||||
@return @c YES if Sparkle thinks authorization is needed to update the @p bundlePath, otherwise @c NO.
|
||||
*/
|
||||
SU_EXPORT BOOL SPUSystemNeedsAuthorizationAccessForBundlePath(NSString *bundlePath);
|
||||
|
||||
#endif /* SUInstallerLauncher_Private_h */
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SUInstallerLauncher.h"
|
||||
#import "SUInstallerLauncher+Private.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SULog.h"
|
||||
#import "SPUMessageTypes.h"
|
||||
@@ -315,7 +316,44 @@
|
||||
return resolvedAuxiliaryToolURL.path;
|
||||
}
|
||||
|
||||
static BOOL SPUNeedsSystemAuthorizationAccess(NSString *path, NSString *installationType)
|
||||
BOOL SPUSystemNeedsAuthorizationAccessForBundlePath(NSString *bundlePath)
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
BOOL hasWritability = [fileManager isWritableFileAtPath:bundlePath] && [fileManager isWritableFileAtPath:[bundlePath stringByDeletingLastPathComponent]];
|
||||
|
||||
BOOL needsAuthorization;
|
||||
if (!hasWritability) {
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
// Just because we have writability access does not mean we can set the correct owner/group
|
||||
// Test if we can set the owner/group on a temporarily created file
|
||||
// If we can, then we can probably perform an update without authorization
|
||||
|
||||
NSString *tempFilename = @"permission_test" ;
|
||||
|
||||
SUFileManager *suFileManager = [[SUFileManager alloc] init];
|
||||
NSURL *tempDirectoryURL = [suFileManager makeTemporaryDirectoryWithPreferredName:tempFilename appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:NULL];
|
||||
|
||||
if (tempDirectoryURL == nil) {
|
||||
// I don't imagine this ever happening but in case it does, requesting authorization may be the better option
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
NSURL *tempFileURL = [tempDirectoryURL URLByAppendingPathComponent:tempFilename];
|
||||
if (![[NSData data] writeToURL:tempFileURL atomically:NO]) {
|
||||
// Obvious indicator we may need authorization
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
needsAuthorization = ![suFileManager changeOwnerAndGroupOfItemAtRootURL:tempFileURL toMatchURL:[NSURL fileURLWithPath:bundlePath] error:NULL];
|
||||
}
|
||||
|
||||
[suFileManager removeItemAtURL:tempDirectoryURL error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
return needsAuthorization;
|
||||
}
|
||||
|
||||
static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installationType)
|
||||
{
|
||||
BOOL needsAuthorization;
|
||||
if ([installationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
@@ -323,45 +361,17 @@ static BOOL SPUNeedsSystemAuthorizationAccess(NSString *path, NSString *installa
|
||||
} else if ([installationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
needsAuthorization = NO;
|
||||
} else {
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
BOOL hasWritability = [fileManager isWritableFileAtPath:path] && [fileManager isWritableFileAtPath:[path stringByDeletingLastPathComponent]];
|
||||
if (!hasWritability) {
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
// Just because we have writability access does not mean we can set the correct owner/group
|
||||
// Test if we can set the owner/group on a temporarily created file
|
||||
// If we can, then we can probably perform an update without authorization
|
||||
|
||||
NSString *tempFilename = @"permission_test" ;
|
||||
|
||||
SUFileManager *suFileManager = [[SUFileManager alloc] init];
|
||||
NSURL *tempDirectoryURL = [suFileManager makeTemporaryDirectoryWithPreferredName:tempFilename appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:NULL];
|
||||
|
||||
if (tempDirectoryURL == nil) {
|
||||
// I don't imagine this ever happening but in case it does, requesting authorization may be the better option
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
NSURL *tempFileURL = [tempDirectoryURL URLByAppendingPathComponent:tempFilename];
|
||||
if (![[NSData data] writeToURL:tempFileURL atomically:NO]) {
|
||||
// Obvious indicator we may need authorization
|
||||
needsAuthorization = YES;
|
||||
} else {
|
||||
needsAuthorization = ![suFileManager changeOwnerAndGroupOfItemAtRootURL:tempFileURL toMatchURL:[NSURL fileURLWithPath:path] error:NULL];
|
||||
}
|
||||
|
||||
[suFileManager removeItemAtURL:tempDirectoryURL error:NULL];
|
||||
}
|
||||
}
|
||||
needsAuthorization = SPUSystemNeedsAuthorizationAccessForBundlePath(path);
|
||||
}
|
||||
return needsAuthorization;
|
||||
}
|
||||
|
||||
|
||||
// Note: do not pass untrusted information such as paths to the installer and progress agent tools, when we can find them ourselves here
|
||||
- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction allowingUpdaterInteraction:(BOOL)allowingUpdaterInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler
|
||||
- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
BOOL needsSystemAuthorization = SPUNeedsSystemAuthorizationAccess(hostBundlePath, installationType);
|
||||
BOOL needsSystemAuthorization = SPUSystemNeedsAuthorizationAccess(hostBundlePath, installationType);
|
||||
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
if (hostBundle == nil) {
|
||||
@@ -372,18 +382,6 @@ static BOOL SPUNeedsSystemAuthorizationAccess(NSString *path, NSString *installa
|
||||
return;
|
||||
}
|
||||
|
||||
if (needsSystemAuthorization && !allowingUpdaterInteraction) {
|
||||
SULog(SULogLevelError, @"Updater is not allowing interaction to the launcher.");
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowingUpdaterInteraction && [installationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
SULog(SULogLevelError, @"Updater is not allowing interaction to the launcher for performing an interactive type package installation.");
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
return;
|
||||
}
|
||||
|
||||
// if we need to use the system domain and we aren't allowed interaction, then try sometime later when interaction is allowed
|
||||
if (needsSystemAuthorization && !allowingDriverInteraction) {
|
||||
completionHandler(SUInstallerLauncherAuthorizeLater, needsSystemAuthorization);
|
||||
@@ -462,10 +460,4 @@ static BOOL SPUNeedsSystemAuthorizationAccess(NSString *path, NSString *installa
|
||||
});
|
||||
}
|
||||
|
||||
- (void)checkIfApplicationInstallationRequiresAuthorizationWithHostBundlePath:(NSString *)hostBundlePath reply:(void(^)(BOOL))reply
|
||||
{
|
||||
// No need to execute on main queue
|
||||
reply(SPUNeedsSystemAuthorizationAccess(hostBundlePath, SPUInstallationTypeApplication));
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
@protocol SUInstallerLauncherProtocol
|
||||
|
||||
- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterBundleIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction allowingUpdaterInteraction:(BOOL)allowingUpdaterInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler;
|
||||
|
||||
- (void)checkIfApplicationInstallationRequiresAuthorizationWithHostBundlePath:(NSString *)hostBundlePath reply:(void(^)(BOOL requiresAuthorization))reply;
|
||||
- (void)launchInstallerWithHostBundlePath:(NSString *)hostBundlePath updaterIdentifier:(NSString *)updaterBundleIdentifier authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingDriverInteraction:(BOOL)allowingDriverInteraction completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler;
|
||||
|
||||
@end
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -22,26 +22,14 @@ release:
|
||||
|
||||
build:
|
||||
xcodebuild clean build
|
||||
|
||||
test:
|
||||
xcodebuild -scheme Distribution -configuration Debug test
|
||||
./objc_dep/objc_dep.py -t .
|
||||
|
||||
# Need to first gem install jazzy to run this rule
|
||||
docs:
|
||||
jazzy --objc --umbrella-header Sparkle/Sparkle.h --framework-root . --readme Documentation/API_README.markdown --theme jony --output Documentation/html
|
||||
|
||||
uitest:
|
||||
xcodebuild -scheme UITests -configuration Debug test
|
||||
|
||||
ci:
|
||||
for i in {7..9} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
for i in {10..12} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
check-localizations:
|
||||
./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm"
|
||||
open "$(TMPDIR)/LocalizationsReport.htm"
|
||||
+3
-3
@@ -2,10 +2,10 @@
|
||||
import PackageDescription
|
||||
|
||||
// Version is technically not required here, SPM doesn't check
|
||||
let version = "2.0.0"
|
||||
let version = "2.0.0-beta.2"
|
||||
// Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it.
|
||||
let tag = "2.0.0"
|
||||
let checksum = "ef0d0cc46421f8644f455b62537f4e4db2c97bdca5820641219a1836f3782878"
|
||||
let tag = "2.0.0-beta.2"
|
||||
let checksum = "0df58f522a002b6a2d0c02fd2a2828e6c7e1ca387680023e2dffa633c7a3ff61"
|
||||
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
let package = Package(
|
||||
|
||||
@@ -6,39 +6,39 @@
|
||||
<language>en</language>
|
||||
<item>
|
||||
<title>Version 2.0 (2 bugs fixed; 3 new features)</title>
|
||||
<link>http://sparkle-project.org</link>
|
||||
<link>https://sparkle-project.org</link>
|
||||
<sparkle:version>2.0</sparkle:version>
|
||||
<sparkle:releaseNotesLink>
|
||||
http://you.com/app/2.0.html
|
||||
https://you.com/app/2.0.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" length="1623481" type="application/octet-stream" sparkle:edSignature="WVyVJpOx+a5+vNWJVY79TRjFKveNk+VhGJf2iti4CZtJsJewIUGvh/1AKKEAFbH1qUwx+vro1ECuzOsMmumoBA==" />
|
||||
<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>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<title>Version 1.5 (8 bugs fixed; 2 new features)</title>
|
||||
<link>http://sparkle-project.org</link>
|
||||
<link>https://sparkle-project.org</link>
|
||||
<sparkle:version>1.5</sparkle:version>
|
||||
<sparkle:releaseNotesLink>
|
||||
http://you.com/app/1.5.html
|
||||
https://you.com/app/1.5.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" length="1472893" type="application/octet-stream" sparkle:edSignature="pNFd7KbcQSu+Mq7UYrbQXTPq82luht2ACXm/r2utp1u/Uv/5hWqctdT2jwQgMejW7DRoeV/hVr6J4VdZYdwWDw==" />
|
||||
<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>
|
||||
</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. -->
|
||||
<item>
|
||||
<title>Version 1.4 (5 bugs fixed; 2 new features)</title>
|
||||
<link>http://sparkle-project.org</link>
|
||||
<link>https://sparkle-project.org</link>
|
||||
<sparkle:releaseNotesLink>
|
||||
http://you.com/app/1.4.html
|
||||
https://you.com/app/1.4.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<sparkle:version>241</sparkle:version>
|
||||
<sparkle:shortVersionString>1.4</sparkle:shortVersionString>
|
||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:edSignature="Ody3D/ybSMH4T+P/oNj3LN4F0SA8RJGLEr1TI4UemrBAiJ9aEcDnYV3u58P75AbcFjI13jPYmHDUHXMSTFQbDw==" length="1472349" type="application/octet-stream" />
|
||||
<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>
|
||||
</item>
|
||||
</channel>
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "2.0.0"
|
||||
s.version = "2.0.0-beta.2"
|
||||
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"
|
||||
s.documentation_url = "http://sparkle-project.org/documentation/"
|
||||
s.screenshot = "http://sparkle-project.org/images/screenshot-noshadow@2x.png"
|
||||
s.homepage = "https://sparkle-project.org"
|
||||
s.documentation_url = "https://sparkle-project.org/documentation/"
|
||||
s.screenshot = "https://sparkle-project.org/images/screenshot-noshadow@2x.png"
|
||||
s.license = {
|
||||
:type => 'MIT',
|
||||
:file => 'LICENSE'
|
||||
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
|
||||
s.preserve_paths = 'bin/*'
|
||||
s.preserve_paths = ['bin/*', 'XPCServices/*']
|
||||
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
s.vendored_frameworks = 'Sparkle.framework'
|
||||
s.xcconfig = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 47;
|
||||
objectVersion = 52;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXAggregateTarget section */
|
||||
@@ -309,6 +309,9 @@
|
||||
726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; };
|
||||
726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
727DBAE526B5BBFD00111F0C /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 727DBAE426B5BBFD00111F0C /* ArgumentParser */; };
|
||||
727DBAE726B5C47800111F0C /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 727DBAE626B5C47800111F0C /* ArgumentParser */; };
|
||||
727DBAE926B5C48A00111F0C /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 727DBAE826B5C48A00111F0C /* ArgumentParser */; };
|
||||
727F340B2605321D00020E85 /* SULog+NSError.m in Sources */ = {isa = PBXBuildFile; fileRef = 727F340A2605321D00020E85 /* SULog+NSError.m */; };
|
||||
727F340D2605321D00020E85 /* SULog+NSError.m in Sources */ = {isa = PBXBuildFile; fileRef = 727F340A2605321D00020E85 /* SULog+NSError.m */; };
|
||||
727F340E2605321D00020E85 /* SULog+NSError.m in Sources */ = {isa = PBXBuildFile; fileRef = 727F340A2605321D00020E85 /* SULog+NSError.m */; };
|
||||
@@ -367,6 +370,9 @@
|
||||
72EB87EA1CB8798800C37F42 /* ShowInstallerProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */; };
|
||||
72EB87EB1CB8859100C37F42 /* Updater.app in Copy Tools */ = {isa = PBXBuildFile; fileRef = 721C24451CB753E6005440CB /* Updater.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
72EB87EC1CB8887E00C37F42 /* SUStatus.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55C14BD8136EF00C00649790 /* SUStatus.xib */; };
|
||||
72EE17FB26D1CC8800C58B19 /* SUInstallerLauncher+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EE17FA26D1CBC000C58B19 /* SUInstallerLauncher+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
72EE17FC26D1CC9D00C58B19 /* SPUInstallationType.h in Headers */ = {isa = PBXBuildFile; fileRef = 7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
72EE181926DAE70900C58B19 /* SPUUpdateCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EE181826DAE6E100C58B19 /* SPUUpdateCheck.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72EF30BE2675CF38008CE987 /* SPUAppcastItemStateResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72EF30BA2675CF38008CE987 /* SPUAppcastItemStateResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
72EF30BF2675CF38008CE987 /* SPUAppcastItemState.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EF30BB2675CF38008CE987 /* SPUAppcastItemState.m */; };
|
||||
72EF30C02675CF38008CE987 /* SPUAppcastItemStateResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EF30BC2675CF38008CE987 /* SPUAppcastItemStateResolver.m */; };
|
||||
@@ -439,13 +445,6 @@
|
||||
remoteGlobalIDString = 61B5F90109C4CEE200B25A18;
|
||||
remoteInfo = "Sparkle Test App";
|
||||
};
|
||||
1454BA1719637EE900344E57 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 1420DF491962329200203BB0;
|
||||
remoteInfo = Documentation;
|
||||
};
|
||||
14732BCA1960F73500593899 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
@@ -808,8 +807,6 @@
|
||||
0263187214FEBB31005EBF43 /* uk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Sparkle.strings; sourceTree = "<group>"; };
|
||||
0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||
1420DF4D196247B500203BB0 /* build-docs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-docs.sh"; sourceTree = "<group>"; };
|
||||
1420DF4E196247B500203BB0 /* Doxyfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
|
||||
1420DF4F196247F900203BB0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaTest.m; sourceTree = "<group>"; };
|
||||
14652F7919A93E5F00959E44 /* set-git-version-info.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-git-version-info.sh"; sourceTree = "<group>"; };
|
||||
@@ -944,6 +941,7 @@
|
||||
7218EC362623F31C008FECF3 /* org.sparkle-project.InstallerConnection.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerConnection.entitlements"; sourceTree = "<group>"; };
|
||||
7218EC372623F32E008FECF3 /* org.sparkle-project.InstallerStatus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "org.sparkle-project.InstallerStatus.entitlements"; sourceTree = "<group>"; };
|
||||
7218EC4B2623F51C008FECF3 /* codesign_xpc_service.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = codesign_xpc_service.py; sourceTree = "<group>"; };
|
||||
721AB11626C777D900D34A86 /* SPUDownloadDataPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUDownloadDataPrivate.h; sourceTree = "<group>"; };
|
||||
721BC2061D17A532002BC71E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
721BC2081D17A553002BC71E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
|
||||
721BC20A1D17A5AD002BC71E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
|
||||
@@ -1278,6 +1276,8 @@
|
||||
72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SUUpdateSettingsWindowController.xib; sourceTree = "<group>"; };
|
||||
72E45CFB1B641961005C701A /* sparkletestcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = sparkletestcast.xml; sourceTree = "<group>"; };
|
||||
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ShowInstallerProgress.m; path = Sparkle/InstallerProgress/ShowInstallerProgress.m; sourceTree = SOURCE_ROOT; };
|
||||
72EE17FA26D1CBC000C58B19 /* SUInstallerLauncher+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SUInstallerLauncher+Private.h"; sourceTree = "<group>"; };
|
||||
72EE181826DAE6E100C58B19 /* SPUUpdateCheck.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUUpdateCheck.h; sourceTree = "<group>"; };
|
||||
72EF30BA2675CF38008CE987 /* SPUAppcastItemStateResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUAppcastItemStateResolver.h; sourceTree = "<group>"; };
|
||||
72EF30BB2675CF38008CE987 /* SPUAppcastItemState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemState.m; sourceTree = "<group>"; };
|
||||
72EF30BC2675CF38008CE987 /* SPUAppcastItemStateResolver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemStateResolver.m; sourceTree = "<group>"; };
|
||||
@@ -1400,6 +1400,7 @@
|
||||
EA1E285622B6619B004AA304 /* libed25519.a in Frameworks */,
|
||||
EA1E281A22B645F4004AA304 /* libbsdiff.a in Frameworks */,
|
||||
7205C4641E1306BE00E370AE /* libbz2.tbd in Frameworks */,
|
||||
727DBAE526B5BBFD00111F0C /* ArgumentParser in Frameworks */,
|
||||
7205C4631E1306B500E370AE /* libxar.tbd in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1498,6 +1499,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
727DBAE726B5C47800111F0C /* ArgumentParser in Frameworks */,
|
||||
EA1E286A22B6653D004AA304 /* libed25519.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1506,6 +1508,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
727DBAE926B5C48A00111F0C /* ArgumentParser in Frameworks */,
|
||||
EA1E287E22B66705004AA304 /* libed25519.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1600,9 +1603,7 @@
|
||||
1420DE391962322200203BB0 /* Documentation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1420DF4E196247B500203BB0 /* Doxyfile */,
|
||||
721D8A891D4D273E0032E472 /* Internal */,
|
||||
1420DF4D196247B500203BB0 /* build-docs.sh */,
|
||||
);
|
||||
path = Documentation;
|
||||
sourceTree = "<group>";
|
||||
@@ -1783,6 +1784,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72F9EC421D5E9ED8004AC8B6 /* SPUDownloadData.h */,
|
||||
721AB11626C777D900D34A86 /* SPUDownloadDataPrivate.h */,
|
||||
72F9EC431D5E9ED8004AC8B6 /* SPUDownloadData.m */,
|
||||
7214B8851D45AD9A00CB5CED /* SPUInstallationType.h */,
|
||||
7293A1AC1CEE933800B957A7 /* SPUURLRequest.h */,
|
||||
@@ -1958,6 +1960,7 @@
|
||||
720E21791D0D00BF003A311C /* SPUUpdaterCycle.h */,
|
||||
720E217A1D0D00BF003A311C /* SPUUpdaterCycle.m */,
|
||||
72F9EC471D5EA7D3004AC8B6 /* SPUUpdaterDelegate.h */,
|
||||
72EE181826DAE6E100C58B19 /* SPUUpdateCheck.h */,
|
||||
726E078B1CA891E9001A286B /* SPUUpdaterSettings.h */,
|
||||
726E078C1CA891E9001A286B /* SPUUpdaterSettings.m */,
|
||||
72F9EC3D1D5E823F004AC8B6 /* SPUUpdaterTimer.h */,
|
||||
@@ -2092,6 +2095,7 @@
|
||||
726E07B51CAF08D6001A286B /* Info.plist */,
|
||||
726E07B31CAF08D6001A286B /* main.m */,
|
||||
726E07B01CAF08D6001A286B /* SUInstallerLauncher.h */,
|
||||
72EE17FA26D1CBC000C58B19 /* SUInstallerLauncher+Private.h */,
|
||||
726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */,
|
||||
726E07AF1CAF08D6001A286B /* SUInstallerLauncherProtocol.h */,
|
||||
721652671D3C8FED00FD13D8 /* SUInstallerLauncherStatus.h */,
|
||||
@@ -2328,6 +2332,7 @@
|
||||
7229E1BD1C98EFF200CB50D0 /* SPUDownloadDriver.h in Headers */,
|
||||
7267E5FD1D3DD1B700D1BF90 /* SPUResumableUpdate.h in Headers */,
|
||||
7267E5B61D3D8AEE00D1BF90 /* SPUInstallationInfo.h in Headers */,
|
||||
72EE181926DAE70900C58B19 /* SPUUpdateCheck.h in Headers */,
|
||||
72B767CE1C9B924900A07552 /* SPUInstallerDriver.h in Headers */,
|
||||
723ABF30259D062F00BDB4FA /* SULegacyWebView.h in Headers */,
|
||||
721BC20E1D1CDE55002BC71E /* SPULocalCacheDirectory.h in Headers */,
|
||||
@@ -2340,8 +2345,10 @@
|
||||
7246E0A31C83B685003B4E75 /* SPUStandardUpdaterController.h in Headers */,
|
||||
725CB95A1C7121830064365A /* SPUStandardUserDriver.h in Headers */,
|
||||
726E4A371C89116000C57C6A /* SPUStandardUserDriverDelegate.h in Headers */,
|
||||
72EE17FC26D1CC9D00C58B19 /* SPUInstallationType.h in Headers */,
|
||||
72EF30BE2675CF38008CE987 /* SPUAppcastItemStateResolver.h in Headers */,
|
||||
72EF30C7267C716A008CE987 /* SUAppcastItem+Private.h in Headers */,
|
||||
72EE17FB26D1CC8800C58B19 /* SUInstallerLauncher+Private.h in Headers */,
|
||||
61299A5C09CA6D4500B7442F /* SUConstants.h in Headers */,
|
||||
726DF88E1C84277600188804 /* SPUUserUpdateState.h in Headers */,
|
||||
72B767DA1C9CD2E400A07552 /* SPUUIBasedUpdateDriver.h in Headers */,
|
||||
@@ -2395,20 +2402,6 @@
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXLegacyTarget section */
|
||||
1420DF491962329200203BB0 /* Documentation */ = {
|
||||
isa = PBXLegacyTarget;
|
||||
buildArgumentsString = "\"$(SRCROOT)/Documentation/build-docs.sh\" $(ACTION)";
|
||||
buildConfigurationList = 1420DF4A1962329200203BB0 /* Build configuration list for PBXLegacyTarget "Documentation" */;
|
||||
buildPhases = (
|
||||
);
|
||||
buildToolPath = bash;
|
||||
buildWorkingDirectory = "";
|
||||
dependencies = (
|
||||
);
|
||||
name = Documentation;
|
||||
passBuildSettingsInEnvironment = 1;
|
||||
productName = Documentation;
|
||||
};
|
||||
14732BC51960F69300593899 /* Distribution */ = {
|
||||
isa = PBXLegacyTarget;
|
||||
buildArgumentsString = "$(SRCROOT)/Configurations/make-release-package.sh $(ACTION)";
|
||||
@@ -2429,7 +2422,6 @@
|
||||
7205C46B1E13070300E370AE /* PBXTargetDependency */,
|
||||
FA344BA724C869A300B2A401 /* PBXTargetDependency */,
|
||||
FA344BA524C8699E00B2A401 /* PBXTargetDependency */,
|
||||
1454BA1819637EE900344E57 /* PBXTargetDependency */,
|
||||
895C5DC724D78F700058A82D /* PBXTargetDependency */,
|
||||
);
|
||||
name = Distribution;
|
||||
@@ -2511,6 +2503,9 @@
|
||||
dependencies = (
|
||||
);
|
||||
name = generate_appcast;
|
||||
packageProductDependencies = (
|
||||
727DBAE426B5BBFD00111F0C /* ArgumentParser */,
|
||||
);
|
||||
productName = generate_appcast;
|
||||
productReference = 7205C43E1E13049400E370AE /* generate_appcast */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
@@ -2749,6 +2744,9 @@
|
||||
dependencies = (
|
||||
);
|
||||
name = generate_keys;
|
||||
packageProductDependencies = (
|
||||
727DBAE626B5C47800111F0C /* ArgumentParser */,
|
||||
);
|
||||
productName = generate_keys;
|
||||
productReference = EA1E285E22B66487004AA304 /* generate_keys */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
@@ -2766,6 +2764,9 @@
|
||||
dependencies = (
|
||||
);
|
||||
name = sign_update;
|
||||
packageProductDependencies = (
|
||||
727DBAE826B5C48A00111F0C /* ArgumentParser */,
|
||||
);
|
||||
productName = sign_update;
|
||||
productReference = EA1E287622B666EB004AA304 /* sign_update */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
@@ -2905,6 +2906,9 @@
|
||||
fa,
|
||||
);
|
||||
mainGroup = 0867D691FE84028FC02AAC07 /* Sparkle */;
|
||||
packageReferences = (
|
||||
727DBAE326B5BBFD00111F0C /* XCRemoteSwiftPackageReference "swift-argument-parser" */,
|
||||
);
|
||||
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
@@ -2922,7 +2926,6 @@
|
||||
72D9549D1CBB415B006F28BD /* sparkle-cli */,
|
||||
721C24441CB753E6005440CB /* Installer Progress */,
|
||||
14732BC51960F69300593899 /* Distribution */,
|
||||
1420DF491962329200203BB0 /* Documentation */,
|
||||
1495005F195FB89400BC5B5B /* All */,
|
||||
895C5DC024D78E210058A82D /* XCFrameworks */,
|
||||
726B2B5C1C645FC900388755 /* UI Tests */,
|
||||
@@ -3534,11 +3537,6 @@
|
||||
target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */;
|
||||
targetProxy = 1454BA1519637EDB00344E57 /* PBXContainerItemProxy */;
|
||||
};
|
||||
1454BA1819637EE900344E57 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 1420DF491962329200203BB0 /* Documentation */;
|
||||
targetProxy = 1454BA1719637EE900344E57 /* PBXContainerItemProxy */;
|
||||
};
|
||||
14732BCB1960F73500593899 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 8DC2EF4F0486A6940098B216 /* Sparkle */;
|
||||
@@ -3864,18 +3862,6 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1420DF4B1962329200203BB0 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1420DF4C1962329200203BB0 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
14732BC71960F69300593899 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -3941,12 +3927,6 @@
|
||||
};
|
||||
name = Coverage;
|
||||
};
|
||||
149B78611B7D398100D7D62C /* Coverage */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
};
|
||||
name = Coverage;
|
||||
};
|
||||
149B78621B7D398100D7D62C /* Coverage */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -4223,7 +4203,6 @@
|
||||
baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -4232,7 +4211,6 @@
|
||||
baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
};
|
||||
name = Coverage;
|
||||
};
|
||||
@@ -4241,7 +4219,6 @@
|
||||
baseConfigurationReference = 72D954B01CBB41E2006F28BD /* ConfigSparkleTool.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -4350,16 +4327,6 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1420DF4A1962329200203BB0 /* Build configuration list for PBXLegacyTarget "Documentation" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1420DF4B1962329200203BB0 /* Debug */,
|
||||
149B78611B7D398100D7D62C /* Coverage */,
|
||||
1420DF4C1962329200203BB0 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
14732BC61960F69300593899 /* Build configuration list for PBXLegacyTarget "Distribution" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
@@ -4581,6 +4548,35 @@
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
727DBAE326B5BBFD00111F0C /* XCRemoteSwiftPackageReference "swift-argument-parser" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/apple/swift-argument-parser.git";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 0.4.3;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
727DBAE426B5BBFD00111F0C /* ArgumentParser */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 727DBAE326B5BBFD00111F0C /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
|
||||
productName = ArgumentParser;
|
||||
};
|
||||
727DBAE626B5C47800111F0C /* ArgumentParser */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 727DBAE326B5BBFD00111F0C /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
|
||||
productName = ArgumentParser;
|
||||
};
|
||||
727DBAE826B5C48A00111F0C /* ArgumentParser */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 727DBAE326B5BBFD00111F0C /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
|
||||
productName = ArgumentParser;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:Sparkle.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "swift-argument-parser",
|
||||
"repositoryURL": "https://github.com/apple/swift-argument-parser.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "83b23d940471b313427da226196661856f6ba3e0",
|
||||
"version": "0.4.4"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Release"
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#import "SPUSecureCoding.h"
|
||||
#import "SPUInstallationInfo.h"
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
* This delay should be be high enough to increase the likelihood that our updated app will be launched up front,
|
||||
* but should be low enough so that the user doesn't ponder why the updater hasn't finished terminating yet
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@class SUStandardVersionComparator, SPUAppcastItemState;
|
||||
@protocol SUVersionComparison;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Private exposed class used to resolve Appcast Item properties that rely on external factors such as a host.
|
||||
This resolver is used for constructing appcast items.
|
||||
*/
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUAutomaticUpdateDriver : NSObject <SPUUpdateDriver>
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+14
-23
@@ -39,7 +39,7 @@
|
||||
@synthesize updateItem = _updateItem;
|
||||
@synthesize willInstallSilently = _willInstallSilently;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -47,40 +47,31 @@
|
||||
// The user driver is only used for a termination callback
|
||||
_userDriver = userDriver;
|
||||
_updaterDelegate = updaterDelegate;
|
||||
_coreDriver = [[SPUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
_coreDriver = [[SPUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle updateCheck:SPUUpdateCheckUpdatesInBackground updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders preventingInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.coreDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
|
||||
[self.coreDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
[self abortUpdateWithError:error];
|
||||
} else {
|
||||
[self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES requiresSilentInstall:YES];
|
||||
}
|
||||
}];
|
||||
[self.coreDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)__unused completionBlock
|
||||
#pragma clang diagnostic pop
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeInstallingUpdateWithCompletion: called on SPUAutomaticUpdateDriver");
|
||||
[self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES requiresSilentInstall:YES];
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)__unused resumableUpdate completion:(SPUUpdateDriverCompletion)__unused completionBlock
|
||||
#pragma clang diagnostic pop
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeDownloadedUpdate:completion: called on SPUAutomaticUpdateDriver");
|
||||
SULog(SULogLevelError, @"Error: resumeInstallingUpdate: called on SPUAutomaticUpdateDriver");
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)__unused resumableUpdate
|
||||
{
|
||||
// Nothing really to do here.. this shouldn't be called.
|
||||
SULog(SULogLevelError, @"Error: resumeDownloadedUpdate: called on SPUAutomaticUpdateDriver");
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem
|
||||
|
||||
Vendored
+5
-4
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SPUUpdateDriver.h"
|
||||
#import "SPUUpdateCheck.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -28,15 +29,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUBasicUpdateDriver : NSObject
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id <SPUBasicUpdateDriverDelegate>)delegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host updateCheck:(SPUUpdateCheck)updateCheck updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id <SPUBasicUpdateDriverDelegate>)delegate;
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background;
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeInstallingUpdate;
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate;
|
||||
|
||||
- (void)abortUpdateAndShowNextUpdateImmediately:(BOOL)shouldSignalShowingUpdate resumableUpdate:(id<SPUResumableUpdate> _Nullable)resumableUpdate error:(nullable NSError *)error;
|
||||
|
||||
|
||||
Vendored
+25
-33
@@ -10,8 +10,6 @@
|
||||
#import "SUAppcastDriver.h"
|
||||
#import "SPUUpdaterDelegate.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SULog.h"
|
||||
#import "SULog+NSError.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUAppcastItem.h"
|
||||
@@ -31,6 +29,7 @@
|
||||
@property (nonatomic, copy) SPUUpdateDriverCompletion completionBlock;
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) SPUUpdateCheck updateCheck;
|
||||
@property (nonatomic, readonly, weak) id updater; // if we didn't have legacy support, I'd remove this..
|
||||
@property (nullable, nonatomic, readonly, weak) id <SPUUpdaterDelegate>updaterDelegate;
|
||||
|
||||
@@ -41,6 +40,7 @@
|
||||
@implementation SPUBasicUpdateDriver
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize updateCheck = _updateCheck;
|
||||
@synthesize updater = _updater;
|
||||
@synthesize updaterDelegate = _updaterDelegate;
|
||||
@synthesize delegate = _delegate;
|
||||
@@ -48,11 +48,12 @@
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize aborted = _aborted;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(id <SPUUpdaterDelegate>)updaterDelegate delegate:(id <SPUBasicUpdateDriverDelegate>)delegate
|
||||
- (instancetype)initWithHost:(SUHost *)host updateCheck:(SPUUpdateCheck)updateCheck updater:(id)updater updaterDelegate:(id <SPUUpdaterDelegate>)updaterDelegate delegate:(id <SPUBasicUpdateDriverDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_host = host;
|
||||
_updateCheck = updateCheck;
|
||||
_updater = updater;
|
||||
_updaterDelegate = updaterDelegate;
|
||||
_delegate = delegate;
|
||||
@@ -62,7 +63,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
}
|
||||
@@ -90,14 +91,12 @@
|
||||
[self notifyFinishLoadingAppcast];
|
||||
|
||||
SUAppcastItem *nonNullUpdateItem = updateItem;
|
||||
[self notifyFoundValidUpdateWithAppcastItem:nonNullUpdateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain];
|
||||
[self notifyFoundValidUpdateWithAppcastItem:nonNullUpdateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain resuming:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
[SPUProbeInstallStatus probeInstallerUpdateItemForHostBundleIdentifier:hostBundleIdentifier completion:^(SPUInstallationInfo * _Nullable installationInfo) {
|
||||
@@ -107,10 +106,8 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
|
||||
[self notifyResumableUpdateItem:resumableUpdate.updateItem secondaryUpdateItem:resumableUpdate.secondaryUpdateItem systemDomain:nil];
|
||||
}
|
||||
|
||||
@@ -139,24 +136,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)notifyFoundValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem systemDomain:(NSNumber * _Nullable)systemDomain
|
||||
- (void)notifyFoundValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem systemDomain:(NSNumber * _Nullable)systemDomain resuming:(BOOL)resuming
|
||||
{
|
||||
if (!self.aborted) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
||||
object:self.updater
|
||||
userInfo:@{ SUUpdaterAppcastItemNotificationKey: updateItem }];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((updater:didFindValidUpdate:))]) {
|
||||
[self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem];
|
||||
// If the update is not being resumed from a prior session, give the delegate a chance to bail
|
||||
NSError *shouldNotProceedError = nil;
|
||||
if (!resuming && [self.updaterDelegate respondsToSelector:@selector(updater:shouldProceedWithUpdate:updateCheck:error:)] && ![self.updaterDelegate updater:self.updater shouldProceedWithUpdate:updateItem updateCheck:self.updateCheck error:&shouldNotProceedError]) {
|
||||
[self.delegate basicDriverIsRequestingAbortUpdateWithError:shouldNotProceedError];
|
||||
} else {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
||||
object:self.updater
|
||||
userInfo:@{ SUUpdaterAppcastItemNotificationKey: updateItem }];
|
||||
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((updater:didFindValidUpdate:))]) {
|
||||
[self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem];
|
||||
}
|
||||
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain];
|
||||
}
|
||||
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryAppcastItem
|
||||
{
|
||||
[self notifyFoundValidUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryAppcastItem systemDomain:nil];
|
||||
[self notifyFoundValidUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryAppcastItem systemDomain:nil resuming:NO];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdateWithLatestAppcastItem:(nullable SUAppcastItem *)latestAppcastItem hostToLatestAppcastItemComparisonResult:(NSComparisonResult)hostToLatestAppcastItemComparisonResult background:(BOOL)background
|
||||
@@ -258,19 +261,8 @@
|
||||
self.aborted = YES;
|
||||
|
||||
[self.appcastDriver cleanup:^{
|
||||
if (error != nil) {
|
||||
if (error.code != SUNoUpdateError && error.code != SUInstallationCanceledError && error.code != SUInstallationAuthorizeLaterError) { // Let's not bother logging this.
|
||||
SULogError(error);
|
||||
}
|
||||
|
||||
// Notify host app that updater has aborted
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((updater:didAbortWithError:))]) {
|
||||
[self.updaterDelegate updater:self.updater didAbortWithError:(NSError * _Nonnull)error];
|
||||
}
|
||||
}
|
||||
|
||||
if (self.completionBlock != nil) {
|
||||
self.completionBlock(shouldShowUpdateImmediately, resumableUpdate);
|
||||
self.completionBlock(shouldShowUpdateImmediately, resumableUpdate, error);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
}];
|
||||
|
||||
Vendored
+5
-6
@@ -9,6 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SPUUpdateDriver.h"
|
||||
#import "SPUUserUpdateState.h"
|
||||
#import "SPUUpdateCheck.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -49,17 +50,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUCoreBasedUpdateDriver : NSObject
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUCoreBasedUpdateDriverDelegate>)delegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updateCheck:(SPUUpdateCheck)updateCheck updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUCoreBasedUpdateDriverDelegate>)delegate;
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply;
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background requiresSilentInstall:(BOOL)silentInstall;
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeInstallingUpdate;
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate;
|
||||
|
||||
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem inBackground:(BOOL)background;
|
||||
|
||||
|
||||
Vendored
+12
-53
@@ -39,7 +39,6 @@
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic) BOOL resumingInstallingUpdate;
|
||||
@property (nonatomic) BOOL silentInstall;
|
||||
@property (nonatomic) BOOL preventsInstallerInteraction;
|
||||
@property (nonatomic, readonly, weak) id updater; // if we didn't have legacy support, I'd remove this..
|
||||
@property (nullable, nonatomic, readonly, weak) id <SPUUpdaterDelegate>updaterDelegate;
|
||||
@property (nonatomic) NSString *userAgent;
|
||||
@@ -58,7 +57,6 @@
|
||||
@synthesize host = _host;
|
||||
@synthesize resumingInstallingUpdate = _resumingInstallingUpdate;
|
||||
@synthesize silentInstall = _silentInstall;
|
||||
@synthesize preventsInstallerInteraction = _preventsInstallerInteraction;
|
||||
@synthesize updater = _updater;
|
||||
@synthesize updaterDelegate = _updaterDelegate;
|
||||
@synthesize userAgent = _userAgent;
|
||||
@@ -66,7 +64,7 @@
|
||||
@synthesize resumableUpdate = _resumableUpdate;
|
||||
@synthesize downloadedUpdateForRemoval = _downloadedUpdateForRemoval;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUCoreBasedUpdateDriverDelegate>)delegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updateCheck:(SPUUpdateCheck)updateCheck updater:(id)updater updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUCoreBasedUpdateDriverDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -75,8 +73,8 @@
|
||||
NSString *bundleIdentifier = host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
|
||||
_basicDriver = [[SPUBasicUpdateDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
_installerDriver = [[SPUInstallerDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
_basicDriver = [[SPUBasicUpdateDriver alloc] initWithHost:host updateCheck:updateCheck updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
_installerDriver = [[SPUInstallerDriver alloc] initWithHost:host applicationBundle:applicationBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
|
||||
_host = host;
|
||||
_updater = updater;
|
||||
@@ -85,33 +83,9 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.basicDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
}
|
||||
|
||||
- (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply
|
||||
{
|
||||
// Save for later
|
||||
self.preventsInstallerInteraction = preventsInstallerInteraction;
|
||||
|
||||
// If we don't allow interaction, make sure we have sufficient privileges to update
|
||||
// If we don't, then we should abort early before trying to check for updates
|
||||
// Note if we don't have permission to update an application update without interaction,
|
||||
// then we won't have permission for package type of updates either (converse is not true)
|
||||
|
||||
if (!preventsInstallerInteraction) {
|
||||
reply(nil);
|
||||
} else {
|
||||
// Otherwise check if we have sufficient privileges to update without interaction
|
||||
[self.installerDriver checkIfApplicationInstallationRequiresAuthorizationWithReply:^(BOOL requiresAuthorization) {
|
||||
if (requiresAuthorization) {
|
||||
reply([NSError errorWithDomain:SUSparkleErrorDomain code:SUNotAllowedInteractionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"No new update has been checked because the installation will require interaction, which has been prevented."] }]);
|
||||
} else {
|
||||
reply(nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
[self.basicDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background requiresSilentInstall:(BOOL)silentInstall
|
||||
@@ -123,23 +97,20 @@
|
||||
[self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
self.resumingInstallingUpdate = YES;
|
||||
self.silentInstall = NO;
|
||||
|
||||
[self.basicDriver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
[self.basicDriver resumeInstallingUpdate];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
self.resumableUpdate = resumableUpdate;
|
||||
self.silentInstall = NO;
|
||||
|
||||
// Note if installer interaction isn't allowed, we shouldn't have downloaded the update, and shouldn't be able to get here
|
||||
// So no need to do a test if we can perform an update without authorization
|
||||
|
||||
[self.basicDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
[self.basicDriver resumeUpdate:resumableUpdate];
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFinishLoadingAppcast
|
||||
@@ -157,21 +128,9 @@
|
||||
if (self.resumingInstallingUpdate) {
|
||||
assert(systemDomain != nil);
|
||||
[self.installerDriver resumeInstallingUpdateWithUpdateItem:updateItem systemDomain:systemDomain.boolValue];
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
|
||||
} else {
|
||||
if (!self.preventsInstallerInteraction) {
|
||||
// Simple case - delegate allows interaction, so we should continue along
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
|
||||
} else {
|
||||
// Package type installations will always require installer interaction as long as we don't support running as root
|
||||
// If it's not a package type installation, we should be okay since we did an auth check before checking for updates above
|
||||
if (![updateItem.installationType isEqualToString:SPUInstallationTypeApplication]) {
|
||||
[self.delegate coreDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNotAllowedInteractionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A new update is available but cannot be installed because interaction has been prevented."] }]];
|
||||
} else {
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
|
||||
}
|
||||
|
||||
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem inBackground:(BOOL)background
|
||||
@@ -265,7 +224,7 @@
|
||||
[self.delegate coreDriverDidStartExtractingUpdate];
|
||||
}
|
||||
|
||||
[self.installerDriver extractDownloadedUpdate:downloadedUpdate silently:self.silentInstall preventsInstallerInteraction:self.preventsInstallerInteraction completion:^(NSError * _Nullable error) {
|
||||
[self.installerDriver extractDownloadedUpdate:downloadedUpdate silently:self.silentInstall completion:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
if (error.code != SUInstallationAuthorizeLaterError) {
|
||||
[self clearDownloadedUpdate];
|
||||
|
||||
Vendored
+5
-7
@@ -27,31 +27,29 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
/**
|
||||
* A class for containing downloaded data along with some information about it.
|
||||
*/
|
||||
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data URL:(NSURL *)URL textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* The raw data that was downloaded.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* The URL that was fetched from.
|
||||
*
|
||||
* This may be different from the URL in the request if there were redirects involved.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy) NSURL *URL;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* The IANA charset encoding name if available. Eg: "utf-8"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* The MIME type if available. Eg: "text/plain"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SPUDownloadDataPrivate.h
|
||||
// SPUDownloadDataPrivate
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/13/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUDownloadData (Private)
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data URL:(NSURL *)URL textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+2
-4
@@ -30,13 +30,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUInstallerDriver : NSObject
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SPUInstallerDriverDelegate>)delegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater updaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SPUInstallerDriverDelegate>)delegate;
|
||||
|
||||
- (void)resumeInstallingUpdateWithUpdateItem:(SUAppcastItem *)updateItem systemDomain:(BOOL)systemDomain;
|
||||
|
||||
- (void)checkIfApplicationInstallationRequiresAuthorizationWithReply:(void (^)(BOOL requiresAuthorization))reply;
|
||||
|
||||
- (void)extractDownloadedUpdate:(SPUDownloadedUpdate *)downloadedUpdate silently:(BOOL)silently preventsInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(void (^)(NSError * _Nullable))completionHandler;
|
||||
- (void)extractDownloadedUpdate:(SPUDownloadedUpdate *)downloadedUpdate silently:(BOOL)silently completion:(void (^)(NSError * _Nullable))completionHandler;
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
|
||||
|
||||
|
||||
Vendored
+8
-72
@@ -12,7 +12,7 @@
|
||||
#import "SPUXPCServiceInfo.h"
|
||||
#import "SPUUpdaterDelegate.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SULog.h"
|
||||
#import "SUAppcastItem+Private.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUHost.h"
|
||||
@@ -41,7 +41,6 @@
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) NSBundle *applicationBundle;
|
||||
@property (nonatomic, readonly) NSBundle *sparkleBundle;
|
||||
@property (nonatomic, weak, readonly) id<SPUInstallerDriverDelegate> delegate;
|
||||
@property (nonatomic) SPUInstallerMessageType currentStage;
|
||||
@property (nonatomic) BOOL startedInstalling;
|
||||
@@ -69,7 +68,6 @@
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize applicationBundle = _applicationBundle;
|
||||
@synthesize sparkleBundle = _sparkleBundle;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize currentStage = _currentStage;
|
||||
@synthesize startedInstalling = _startedInstalling;
|
||||
@@ -86,13 +84,12 @@
|
||||
@synthesize aborted = _aborted;
|
||||
@synthesize installerError = _installerError;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(id<SPUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SPUInstallerDriverDelegate>)delegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater updaterDelegate:(id<SPUUpdaterDelegate>)updaterDelegate delegate:(nullable id<SPUInstallerDriverDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_host = host;
|
||||
_applicationBundle = applicationBundle;
|
||||
_sparkleBundle = sparkleBundle;
|
||||
_updater = updater;
|
||||
_updaterDelegate = updaterDelegate;
|
||||
_delegate = delegate;
|
||||
@@ -144,7 +141,7 @@
|
||||
}
|
||||
|
||||
// This can be called multiple times (eg: if a delta update fails, this may be called again with a regular update item)
|
||||
- (void)extractDownloadedUpdate:(SPUDownloadedUpdate *)downloadedUpdate silently:(BOOL)silently preventsInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(void (^)(NSError * _Nullable))completionHandler
|
||||
- (void)extractDownloadedUpdate:(SPUDownloadedUpdate *)downloadedUpdate silently:(BOOL)silently completion:(void (^)(NSError * _Nullable))completionHandler
|
||||
{
|
||||
self.updateItem = downloadedUpdate.updateItem;
|
||||
self.temporaryDirectory = downloadedUpdate.temporaryDirectory;
|
||||
@@ -153,7 +150,7 @@
|
||||
self.currentStage = SPUInstallerNotStarted;
|
||||
|
||||
if (self.installerConnection == nil) {
|
||||
[self launchAutoUpdateSilently:silently preventsInstallerInteraction:preventsInstallerInteraction completion:completionHandler];
|
||||
[self launchAutoUpdateSilently:silently completion:completionHandler];
|
||||
} else {
|
||||
// The Install tool is already alive; just send out installation input data again
|
||||
[self sendInstallationData];
|
||||
@@ -320,70 +317,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkIfApplicationInstallationRequiresAuthorizationWithReply:(void (^)(BOOL requiresAuthorization))reply
|
||||
{
|
||||
id<SUInstallerLauncherProtocol> installerLauncher = nil;
|
||||
__block BOOL madeReply = NO;
|
||||
NSXPCConnection *launcherConnection = nil;
|
||||
|
||||
if (!SPUXPCServiceExists(@INSTALLER_LAUNCHER_BUNDLE_ID)) {
|
||||
installerLauncher = [[SUInstallerLauncher alloc] init];
|
||||
} else {
|
||||
launcherConnection = [[NSXPCConnection alloc] initWithServiceName:@INSTALLER_LAUNCHER_BUNDLE_ID];
|
||||
launcherConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerLauncherProtocol)];
|
||||
|
||||
launcherConnection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!madeReply) {
|
||||
// We'll break the retain cycle in the invalidation handler
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
[launcherConnection invalidate];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
launcherConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
if (!madeReply) {
|
||||
#pragma clang diagnostic pop
|
||||
// If something went horribly wrong, just guess that we won't require authorization
|
||||
reply(NO);
|
||||
|
||||
// Break the retain cycle
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
||||
launcherConnection.interruptionHandler = nil;
|
||||
launcherConnection.invalidationHandler = nil;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[launcherConnection resume];
|
||||
|
||||
installerLauncher = launcherConnection.remoteObjectProxy;
|
||||
}
|
||||
|
||||
[installerLauncher checkIfApplicationInstallationRequiresAuthorizationWithHostBundlePath:self.host.bundlePath reply:^(BOOL requiresAuthorization) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
if (!madeReply) {
|
||||
#pragma clang diagnostic pop
|
||||
madeReply = YES;
|
||||
[launcherConnection invalidate];
|
||||
|
||||
reply(requiresAuthorization);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)launchAutoUpdateSilently:(BOOL)silently preventsInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(void (^)(NSError *_Nullable))completionHandler
|
||||
- (void)launchAutoUpdateSilently:(BOOL)silently completion:(void (^)(NSError *_Nullable))completionHandler
|
||||
{
|
||||
id<SUInstallerLauncherProtocol> installerLauncher = nil;
|
||||
__block BOOL retrievedLaunchStatus = NO;
|
||||
@@ -410,7 +344,9 @@
|
||||
launcherConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
if (!retrievedLaunchStatus) {
|
||||
#pragma clang diagnostic pop
|
||||
NSError *error =
|
||||
@@ -470,7 +406,7 @@
|
||||
mainBundleIdentifier = (bundleIdentifier == nil) ? mainBundleName : bundleIdentifier;
|
||||
}
|
||||
|
||||
[installerLauncher launchInstallerWithHostBundlePath:hostBundlePath updaterIdentifier:mainBundleIdentifier authorizationPrompt:authorizationPrompt installationType:installationType allowingDriverInteraction:driverAllowsInteraction allowingUpdaterInteraction:!preventsInstallerInteraction completion:^(SUInstallerLauncherStatus result, BOOL systemDomain) {
|
||||
[installerLauncher launchInstallerWithHostBundlePath:hostBundlePath updaterIdentifier:mainBundleIdentifier authorizationPrompt:authorizationPrompt installationType:installationType allowingDriverInteraction:driverAllowsInteraction completion:^(SUInstallerLauncherStatus result, BOOL systemDomain) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedLaunchStatus = YES;
|
||||
[launcherConnection invalidate];
|
||||
|
||||
Vendored
+12
@@ -39,7 +39,9 @@
|
||||
[installerStatus setInvalidationHandler:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
completionHandler(NO);
|
||||
@@ -54,7 +56,9 @@
|
||||
[installerStatus probeStatusConnectivityWithReply:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
completionHandler(YES);
|
||||
@@ -65,7 +69,9 @@
|
||||
}];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(PROBE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
@@ -96,7 +102,9 @@
|
||||
[installerStatus setInvalidationHandler:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
completionHandler(nil);
|
||||
@@ -116,7 +124,9 @@
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
completionHandler(installationInfo);
|
||||
@@ -128,7 +138,9 @@
|
||||
}];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#if __has_warning("-Wcompletion-handler")
|
||||
#pragma clang diagnostic ignored "-Wcompletion-handler"
|
||||
#endif
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(PROBE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!handledCompletion) {
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
Vendored
+11
-10
@@ -28,30 +28,31 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_basicDriver = [[SPUBasicUpdateDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
_basicDriver = [[SPUBasicUpdateDriver alloc] initWithHost:host updateCheck:SPUUpdateCheckUpdateInformation updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders preventingInstallerInteraction:(BOOL)__unused preventsInstallerInteraction completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.basicDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders
|
||||
{
|
||||
// We don't preflight for update permission in this driver because we are just interested if an update is available
|
||||
|
||||
[self.basicDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
|
||||
[self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
[self.basicDriver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
[self.basicDriver resumeInstallingUpdate];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
self.resumableUpdate = resumableUpdate;
|
||||
|
||||
[self.basicDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
[self.basicDriver resumeUpdate:resumableUpdate];
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)__unused appcastItem secondaryAppcastItem:(SUAppcastItem * _Nullable)__unused secondaryAppcastItem systemDomain:(NSNumber * _Nullable)__unused systemDomain
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUScheduledUpdateDriver : NSObject <SPUUpdateDriver>
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+16
-22
@@ -27,37 +27,33 @@
|
||||
@synthesize uiDriver = _uiDriver;
|
||||
@synthesize showedUpdate = _showedUpdate;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_uiDriver = [[SPUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater userDriver:userDriver userInitiated:NO updaterDelegate:updaterDelegate delegate:self];
|
||||
_uiDriver = [[SPUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle updater:updater userDriver:userDriver userInitiated:NO updaterDelegate:updaterDelegate delegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders preventingInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.uiDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
|
||||
[self.uiDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
// Don't tell the user about the permission error for scheduled update checks
|
||||
[self abortUpdateWithError:nil];
|
||||
} else {
|
||||
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES];
|
||||
}
|
||||
}];
|
||||
[self.uiDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders
|
||||
{
|
||||
[self.uiDriver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
[self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
[self.uiDriver resumeInstallingUpdate];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
[self.uiDriver resumeUpdate:resumableUpdate];
|
||||
}
|
||||
|
||||
- (void)uiDriverDidShowUpdate
|
||||
@@ -72,14 +68,12 @@
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error
|
||||
{
|
||||
// Don't tell the user that no update was found or some appcast fetch error occurred for scheduled update checks if we haven't shown the update
|
||||
[self abortUpdateWithError:self.showedUpdate ? error : nil];
|
||||
[self abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error
|
||||
{
|
||||
// Don't tell the user that an update error occurred for scheduled update checks if we haven't shown the update
|
||||
[self abortUpdateWithError:self.showedUpdate ? error : nil];
|
||||
[self abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
|
||||
@@ -94,7 +88,7 @@
|
||||
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error
|
||||
{
|
||||
[self.uiDriver abortUpdateWithError:error];
|
||||
[self.uiDriver abortUpdateWithError:error showErrorToUser:self.showedUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
+32
-36
@@ -23,101 +23,97 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@class NSMenuItem;
|
||||
@protocol SPUUserDriver, SPUUpdaterDelegate, SPUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
A controller class that instantiates a SPUUpdater and allows binding UI to it.
|
||||
/**
|
||||
A controller class that instantiates a `SPUUpdater` and allows binding UI to its updater settings.
|
||||
|
||||
This class can be instantiated in a nib or created programatically using initWithUpdaterDelegate:userDriverDelegate: or initWithStartingUpdater:updaterDelegate:userDriverDelegate:.
|
||||
This class can be instantiated in a nib or created programatically using `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate:userDriverDelegate:`.
|
||||
|
||||
The controller's updater targets the application's main bundle and uses Sparkle's standard user interface.
|
||||
Typically, this class is used by sticking it as a custom NSObject subclass in an Interface Builder nib (probably in MainMenu) but it works well programatically too.
|
||||
|
||||
The controller creates an SPUUpdater instance and allows hooking up the check for updates action and menu item validation. It also allows hooking
|
||||
up the updater's and user driver's delegates.
|
||||
The controller creates an `SPUUpdater` instance using a `SPUStandardUserDriver` and allows hooking up the check for updates action and handling menu item validation.
|
||||
It also allows hooking up the updater's and user driver's delegates.
|
||||
|
||||
If you need more control over what bundle you want to update or you want to provide a custom user interface (via SPUUserDriver), please use SPUUpdater directly instead.
|
||||
If you need more control over what bundle you want to update, or you want to provide a custom user interface (via `SPUUserDriver`), please use `SPUUpdater` directly instead.
|
||||
*/
|
||||
SU_EXPORT @interface SPUStandardUpdaterController : NSObject
|
||||
|
||||
/*!
|
||||
/**
|
||||
Interface builder outlet for the updater's delegate.
|
||||
|
||||
This property should only be set using Interface Builder by creating a connection using the outlet.
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) IBOutlet id<SPUUpdaterDelegate> updaterDelegate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Interface builder outlet for the user driver's delegate.
|
||||
|
||||
This property should only be set using Interface Builder by creating a connection using the outlet.
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) IBOutlet id<SPUStandardUserDriverDelegate> userDriverDelegate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Accessible property for the updater. Some properties on the updater can be binded via KVO
|
||||
|
||||
When instantiated from a nib, don't perform update checks before the application has finished launching in a MainMenu nib (i.e applicationDidFinishLaunching:) or before the corresponding window/view controller has been loaded (i.e, windowDidLoad or viewDidLoad). The updater is not guaranteed to be started yet before these points.
|
||||
*/
|
||||
@property (nonatomic, readonly) SPUUpdater *updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Accessible property for the updater's user driver.
|
||||
*/
|
||||
@property (nonatomic, readonly) SPUStandardUserDriver *userDriver;
|
||||
|
||||
/*!
|
||||
Create a new SPUStandardUpdaterController from a nib.
|
||||
/**
|
||||
Create a new `SPUStandardUpdaterController` from a nib.
|
||||
|
||||
You cannot call this initializer directly. You must instantiate a SPUStandardUpdaterController inside of a nib (typically the MainMenu nib) to use it.
|
||||
You cannot call this initializer directly. You must instantiate a `SPUStandardUpdaterController` inside of a nib (typically the MainMenu nib) to use it.
|
||||
|
||||
To create a SPUStandardUpdaterController programatically, use initWithUpdaterDelegate:userDriverDelegate: or initWithStartingUpdater:updaterDelegate:userDriverDelegate: instead.
|
||||
To create a `SPUStandardUpdaterController` programatically, use `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate:userDriverDelegate:` instead.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/*!
|
||||
Create a new SPUStandardUpdaterController programmatically.
|
||||
/**
|
||||
Create a new `SPUStandardUpdaterController` programmatically.
|
||||
|
||||
The updater is started automatically. See -[SPUStandardUpdaterController startUpdater] for more information.
|
||||
The updater is started automatically. See `-startUpdater` for more information.
|
||||
*/
|
||||
- (instancetype)initWithUpdaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate userDriverDelegate:(nullable id<SPUStandardUserDriverDelegate>)userDriverDelegate;
|
||||
|
||||
/*!
|
||||
Create a new SPUStandardUpdaterController programmatically allowing you to specify whether or not to start the updater immediately.
|
||||
/**
|
||||
Create a new `SPUStandardUpdaterController` programmatically allowing you to specify whether or not to start the updater immediately.
|
||||
|
||||
You can specify whether or not you want to start the updater immediately. If you do not start the updater, you
|
||||
must invoke -[SPUStandardUpdaterController startUpdater] at a later time to start it.
|
||||
You can specify whether or not you want to start the updater immediately.
|
||||
If you do not start the updater, you must invoke `-startUpdater` at a later time to start it.
|
||||
*/
|
||||
- (instancetype)initWithStartingUpdater:(BOOL)startUpdater updaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate userDriverDelegate:(nullable id<SPUStandardUserDriverDelegate>)userDriverDelegate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Starts the updater if it has not already been started.
|
||||
|
||||
You should only call this method yourself if you opted out of starting the updater on initialization.
|
||||
Hence, do not call this yourself if you are instantiating this controller from a nib.
|
||||
|
||||
This invokes -[SPUUpdater startUpdater:]. If the application is misconfigured with Sparkle, an error is logged and an alert is shown to the user (after a few seconds) to contact the developer.
|
||||
If you want more control over this behavior, you can create your own SPUUpdater instead.
|
||||
This invokes `-[SPUUpdater startUpdater:]`. If the application is misconfigured with Sparkle, an error is logged and an alert is shown to the user (after a few seconds) to contact the developer.
|
||||
If you want more control over this behavior, you can create your own `SPUUpdater` instead of using `SPUStandardUpdaterController`.
|
||||
*/
|
||||
- (void)startUpdater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
This method is meant for a main menu item.
|
||||
Connect any menu item to this action in Interface Builder,
|
||||
and Sparkle will check for updates and report back its findings verbosely
|
||||
when it is invoked.
|
||||
Connect any NSMenuItem to this action in Interface Builder or programmatically,
|
||||
and Sparkle will check for updates and report back its findings verbosely when it is invoked.
|
||||
|
||||
This action checks updates by invoking -[SPUUpdater checkForUpdates]
|
||||
When the target/action of the menu item is set to this controller and this method,
|
||||
this controller also handles enabling/disabling the menu item by checking
|
||||
`-[SPUUpdater canCheckForUpdates]`
|
||||
|
||||
This action checks updates by invoking `-[SPUUpdater checkForUpdates]`
|
||||
*/
|
||||
- (IBAction)checkForUpdates:(nullable id)sender;
|
||||
|
||||
/*!
|
||||
Validates if the menu item for checkForUpdates: can be invoked or not
|
||||
|
||||
This validates the menu item by checking -SPUUpdater.canCheckForUpdates
|
||||
*/
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+4
@@ -17,6 +17,10 @@
|
||||
#import "SULocalizations.h"
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
@interface SPUStandardUpdaterController () <NSMenuItemValidation>
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUStandardUpdaterController
|
||||
|
||||
@synthesize updater = _updater;
|
||||
|
||||
Vendored
+4
-4
@@ -21,20 +21,20 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Sparkle's standard built-in user driver for updater interactions
|
||||
*/
|
||||
SU_EXPORT @interface SPUStandardUserDriver : NSObject <SPUUserDriver>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Initializes a Sparkle's standard user driver for user update interactions
|
||||
|
||||
@param hostBundle The target bundle of the host that is being updated.
|
||||
@param delegate The delegate to this user driver. Pass nil if you don't want to provide one.
|
||||
@param delegate The optional delegate to this user driver.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(nullable id<SPUStandardUserDriverDelegate>)delegate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Use initWithHostBundle:delegate: instead.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
+5
-6
@@ -18,7 +18,7 @@
|
||||
|
||||
@protocol SUVersionDisplay;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A protocol for Sparkle's standard user driver's delegate
|
||||
|
||||
This includes methods related to UI interactions
|
||||
@@ -27,22 +27,21 @@ SU_EXPORT @protocol SPUStandardUserDriverDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called before showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)standardUserDriverWillShowModalAlert;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called after showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)standardUserDriverDidShowModalAlert;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version formatter will be used.
|
||||
If you don't implement this method or return @c nil, the standard version formatter will be used.
|
||||
*/
|
||||
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;
|
||||
|
||||
|
||||
Vendored
+5
-7
@@ -29,19 +29,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUUIBasedUpdateDriver : NSObject
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate;
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply;
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background;
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeInstallingUpdate;
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate;
|
||||
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error;
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error showErrorToUser:(BOOL)showedUserProgress;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+31
-39
@@ -88,8 +88,7 @@
|
||||
@property (nonatomic, readonly) id<SPUUserDriver> userDriver;
|
||||
@property (nonatomic) SPUReleaseNotesDriver *releaseNotesDriver;
|
||||
@property (nonatomic) BOOL resumingInstallingUpdate;
|
||||
@property (nonatomic) BOOL resumingDownloadedUpdate;
|
||||
@property (nonatomic) BOOL preventsInstallerInteraction;
|
||||
@property (nonatomic) BOOL resumingDownloadedInfoOrUpdate;
|
||||
@property (nonatomic, nullable) NSDictionary *httpHeaders;
|
||||
@property (nonatomic, nullable) NSString *userAgent;
|
||||
|
||||
@@ -106,12 +105,11 @@
|
||||
@synthesize releaseNotesDriver = _releaseNotesDriver;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize resumingInstallingUpdate = _resumingInstallingUpdate;
|
||||
@synthesize resumingDownloadedUpdate = _resumingDownloadedUpdate;
|
||||
@synthesize preventsInstallerInteraction = _preventsInstallerInteraction;
|
||||
@synthesize resumingDownloadedInfoOrUpdate = _resumingDownloadedInfoOrUpdate;
|
||||
@synthesize httpHeaders = _httpHeaders;
|
||||
@synthesize userAgent = _userAgent;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver userInitiated:(BOOL)userInitiated updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate delegate:(id<SPUUIBasedUpdateDriverDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -122,21 +120,16 @@
|
||||
_updaterDelegate = updaterDelegate;
|
||||
_host = host;
|
||||
|
||||
_coreDriver = [[SPUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
SPUUpdateCheck updateCheck = userInitiated ? SPUUpdateCheckUpdates : SPUUpdateCheckUpdatesInBackground;
|
||||
|
||||
_coreDriver = [[SPUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle updateCheck:updateCheck updater:updater updaterDelegate:updaterDelegate delegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.coreDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
}
|
||||
|
||||
- (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply
|
||||
{
|
||||
self.preventsInstallerInteraction = preventsInstallerInteraction;
|
||||
|
||||
[self.coreDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:reply];
|
||||
[self.coreDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
- (void)_clearSkippedUpdatesIfUserInitiated
|
||||
@@ -156,24 +149,20 @@
|
||||
[self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background requiresSilentInstall:NO];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
[self _clearSkippedUpdatesIfUserInitiated];
|
||||
|
||||
self.resumingInstallingUpdate = YES;
|
||||
[self.coreDriver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
[self.coreDriver resumeInstallingUpdate];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
[self _clearSkippedUpdatesIfUserInitiated];
|
||||
|
||||
// Informational downloads shouldn't be presented as updates to be downloaded
|
||||
// Neither should items that prevent auto updating
|
||||
if (!resumableUpdate.updateItem.isInformationOnlyUpdate && !resumableUpdate.updateItem.majorUpgrade) {
|
||||
self.resumingDownloadedUpdate = YES;
|
||||
}
|
||||
[self.coreDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
self.resumingDownloadedInfoOrUpdate = YES;
|
||||
[self.coreDriver resumeUpdate:resumableUpdate];
|
||||
}
|
||||
|
||||
- (void)basicDriverDidFinishLoadingAppcast
|
||||
@@ -188,7 +177,8 @@
|
||||
id <SPUUpdaterDelegate> updaterDelegate = self.updaterDelegate;
|
||||
|
||||
SPUUserUpdateStage stage;
|
||||
if (self.resumingDownloadedUpdate) {
|
||||
// Major upgrades and information only updates are not downloaded automatically
|
||||
if (self.resumingDownloadedInfoOrUpdate && !updateItem.majorUpgrade && !updateItem.informationOnlyUpdate) {
|
||||
stage = SPUUserUpdateStageDownloaded;
|
||||
} else if (self.resumingInstallingUpdate) {
|
||||
stage = SPUUserUpdateStageInstalling;
|
||||
@@ -216,7 +206,7 @@
|
||||
[self.coreDriver extractDownloadedUpdate];
|
||||
break;
|
||||
case SPUUserUpdateStageInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:YES];
|
||||
break;
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem inBackground:NO];
|
||||
@@ -234,9 +224,9 @@
|
||||
switch (stage) {
|
||||
case SPUUserUpdateStageDownloaded:
|
||||
case SPUUserUpdateStageNotDownloaded:
|
||||
// Informational updates can be resumed too, so make sure we check
|
||||
// self.resumingDownloadedUpdate instead of the stage we pass to user driver
|
||||
if (self.resumingDownloadedUpdate) {
|
||||
// Informational and major updates can be resumed too, so make sure we check
|
||||
// self.resumingDownloadedInfoOrUpdate instead of the stage we pass to user driver
|
||||
if (self.resumingDownloadedInfoOrUpdate) {
|
||||
[self.coreDriver clearDownloadedUpdate];
|
||||
}
|
||||
|
||||
@@ -244,7 +234,7 @@
|
||||
|
||||
break;
|
||||
case SPUUserUpdateStageInstalling:
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:YES];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -258,7 +248,7 @@
|
||||
break;
|
||||
}
|
||||
case SPUUserUpdateStageInstalling: {
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
[self.coreDriver finishInstallationWithResponse:validatedChoice displayingUserInterface:YES];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +263,7 @@
|
||||
[self.delegate uiDriverDidShowUpdate];
|
||||
}
|
||||
|
||||
if (updateItem.releaseNotesURL != nil && (![updaterDelegate respondsToSelector:@selector(updaterShouldDownloadReleaseNotes:)] || [updaterDelegate updaterShouldDownloadReleaseNotes:self.updater])) {
|
||||
if (updateItem.releaseNotesURL != nil && (![updaterDelegate respondsToSelector:@selector(updater:shouldDownloadReleaseNotesForUpdate:)] || [updaterDelegate updater:self.updater shouldDownloadReleaseNotesForUpdate:updateItem])) {
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
self.releaseNotesDriver = [[SPUReleaseNotesDriver alloc] initWithReleaseNotesURL:updateItem.releaseNotesURL httpHeaders:self.httpHeaders userAgent:self.userAgent host:self.host completionHandler:^(SPUDownloadData * _Nullable downloadData, NSError * _Nullable error) {
|
||||
@@ -335,7 +325,7 @@
|
||||
if (!willInstallImmediately) {
|
||||
[self.userDriver showReadyToInstallAndRelaunch:^(SPUUserUpdateChoice choice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:!self.preventsInstallerInteraction];
|
||||
[self.coreDriver finishInstallationWithResponse:choice displayingUserInterface:YES];
|
||||
});
|
||||
}];
|
||||
}
|
||||
@@ -370,14 +360,16 @@
|
||||
[self.delegate coreDriverIsRequestingAbortUpdateWithError:error];
|
||||
}
|
||||
|
||||
- (void)_abortUpdateWithError:(nullable NSError *)error
|
||||
- (void)_abortUpdateWithError:(nullable NSError *)error showErrorToUser:(BOOL)showErrorToUser
|
||||
{
|
||||
void (^abortUpdate)(void) = ^{
|
||||
[self.userDriver dismissUpdateInstallation];
|
||||
if (showErrorToUser) {
|
||||
[self.userDriver dismissUpdateInstallation];
|
||||
}
|
||||
[self.coreDriver abortUpdateAndShowNextUpdateImmediately:NO error:error];
|
||||
};
|
||||
|
||||
if (error != nil) {
|
||||
if (error != nil && showErrorToUser) {
|
||||
NSError *nonNullError = error;
|
||||
|
||||
if (error.code == SUNoUpdateError) {
|
||||
@@ -412,14 +404,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error
|
||||
- (void)abortUpdateWithError:(nullable NSError *)error showErrorToUser:(BOOL)showErrorToUser
|
||||
{
|
||||
if (self.releaseNotesDriver != nil) {
|
||||
[self.releaseNotesDriver cleanup:^{
|
||||
[self _abortUpdateWithError:error];
|
||||
[self _abortUpdateWithError:error showErrorToUser:showErrorToUser];
|
||||
}];
|
||||
} else {
|
||||
[self _abortUpdateWithError:error];
|
||||
[self _abortUpdateWithError:error showErrorToUser:showErrorToUser];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// SPUUpdateCheck.h
|
||||
// SPUUpdateCheck
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/28/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPUUpdateCheck_h
|
||||
#define SPUUpdateCheck_h
|
||||
|
||||
/**
|
||||
Describes the type of update check being performed.
|
||||
|
||||
Each update check corresponds to an update check method on `SPUUpdater`.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, SPUUpdateCheck)
|
||||
{
|
||||
/**
|
||||
The user-initiated update check corresponding to `-[SPUUpdater checkForUpdates]`.
|
||||
*/
|
||||
SPUUpdateCheckUpdates = 0,
|
||||
/**
|
||||
The background scheduled update check corresponding to `-[SPUUpdater checkForUpdatesInBackground]`.
|
||||
*/
|
||||
SPUUpdateCheckUpdatesInBackground = 1,
|
||||
/**
|
||||
The informational probe update check corresponding to `-[SPUUpdater checkForUpdateInformation]`.
|
||||
*/
|
||||
SPUUpdateCheckUpdateInformation = 2
|
||||
};
|
||||
|
||||
#endif /* SPUUpdateCheck_h */
|
||||
Vendored
+6
-4
@@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUResumableUpdate;
|
||||
|
||||
typedef void (^SPUUpdateDriverCompletion)(BOOL shouldShowUpdateImmediately, id<SPUResumableUpdate> _Nullable resumableUpdate);
|
||||
typedef void (^SPUUpdateDriverCompletion)(BOOL shouldShowUpdateImmediately, id<SPUResumableUpdate> _Nullable resumableUpdate, NSError * _Nullable error);
|
||||
|
||||
// This protocol describes an update driver that drives updates
|
||||
// An update driver may have multiple levels of other controller components (eg: basic update driver, core based update driver, ui based update driver, appcast driver, etc)
|
||||
@@ -19,11 +19,13 @@ typedef void (^SPUUpdateDriverCompletion)(BOOL shouldShowUpdateImmediately, id<S
|
||||
// The newer architecture is still complex but should be more reliable to maintain and extend.
|
||||
@protocol SPUUpdateDriver <NSObject>
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders preventingInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock;
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders;
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock;
|
||||
- (void)resumeInstallingUpdate;
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate;
|
||||
|
||||
@property (nonatomic, readonly) BOOL showingUpdate;
|
||||
|
||||
|
||||
Vendored
+3
-3
@@ -18,19 +18,19 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
/**
|
||||
This class represents information needed to make a permission request for checking updates.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdatePermissionRequest : NSObject<NSSecureCoding>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Initializes a new update permission request instance.
|
||||
|
||||
@param systemProfile The system profile information.
|
||||
*/
|
||||
- (instancetype)initWithSystemProfile:(NSArray<NSDictionary<NSString *, NSString *> *> *)systemProfile;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A read-only property for the user's system profile.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray<NSDictionary<NSString *, NSString *> *> *systemProfile;
|
||||
|
||||
Vendored
+103
-77
@@ -23,50 +23,61 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
/**
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update parameters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
This class is used to configure the update parameters as well as manually and automatically schedule and control checks for updates.
|
||||
|
||||
For convenience, you can create a standard or nib instantiable updater by using `SPUStandardUpdaterController`.
|
||||
|
||||
Prefer to set initial properties in your bundle's Info.plist as described in [Customizing Sparkle](https://sparkle-project.org/documentation/customization/).
|
||||
|
||||
Otherwise only if you need dynamic behavior (eg. for user preferences) should you set properties on the updater such as:
|
||||
- `automaticallyChecksForUpdates`
|
||||
- `updateCheckInterval`
|
||||
- `automaticallyDownloadsUpdates`
|
||||
- `feedURL`
|
||||
|
||||
Please view the documentation on each of these properties for more detail if you are to configure them dynamically.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
/*!
|
||||
Initializes a new SPUUpdater instance
|
||||
/**
|
||||
Initializes a new `SPUUpdater` instance
|
||||
|
||||
This does not start the updater. To start it, see -[SPUUpdater startUpdater:]
|
||||
This creates an updater, but to start it and schedule update checks `-startUpdater:` needs to be invoked first.
|
||||
|
||||
Note that this is a normal initializer and doesn't implement the singleton pattern (i.e, instances aren't cached, so no surprises)
|
||||
This also means that updater instances can be deallocated, and that they will be torn down properly.
|
||||
Related: See `SPUStandardUpdaterController` which wraps a `SPUUpdater` instance and is suitable for instantiating inside of nib files.
|
||||
|
||||
Related: See SPUStandardUpdaterController which wraps a SPUUpdater instance and is suitable for instantiating in nib files
|
||||
|
||||
@param hostBundle The bundle that should be targetted for updating. This must not be nil.
|
||||
@param hostBundle The bundle that should be targetted for updating.
|
||||
@param applicationBundle The application bundle that should be waited for termination and relaunched (unless overridden). Usually this can be the same as hostBundle. This may differ when updating a plug-in or other non-application bundle.
|
||||
@param userDriver The user driver that Sparkle uses for user update interaction
|
||||
@param delegate The delegate for SPUUpdater. This may be nil.
|
||||
@param userDriver The user driver that Sparkle uses for user update interaction.
|
||||
@param delegate The delegate for `SPUUpdater`.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id <SPUUserDriver>)userDriver delegate:(id<SPUUpdaterDelegate> _Nullable)delegate;
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id <SPUUserDriver>)userDriver delegate:(nullable id<SPUUpdaterDelegate>)delegate;
|
||||
|
||||
/*!
|
||||
Use -initWithHostBundle:applicationBundle:userDriver:delegate: or SPUStandardUpdaterController standard adapter instead.
|
||||
/**
|
||||
Use `-initWithHostBundle:applicationBundle:userDriver:delegate:` or `SPUStandardUpdaterController` standard adapter instead.
|
||||
|
||||
If you want to drop an updater into a nib, use SPUStandardUpdaterController.
|
||||
If you want to drop an updater into a nib, use `SPUStandardUpdaterController`.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Starts the updater.
|
||||
|
||||
This method checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
|
||||
Other properties of this SPUUpdater instance can be set before this method is invoked as well, such as automatic update checks.
|
||||
This method first checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
|
||||
|
||||
If the configuration is valid, an update cycle is started in the next main runloop cycle.
|
||||
During this cycle, a permission prompt may be brought up (if needed) for checking if the user wants automatic update checking.
|
||||
Otherwise if automatic update checks are enabled, a scheduled update alert may be brought up if enough time has elapsed since the last check.
|
||||
See `automaticallyChecksForUpdates` for more information.
|
||||
|
||||
After starting the updater and before the next runloop cycle, one of -checkForUpdates, -checkForUpdatesInBackground, or -checkForUpdateInformation can be invoked.
|
||||
This may be useful if you want to check for updates immediately or without showing a permission prompt.
|
||||
After starting the updater and before the next runloop cycle, one of `-checkForUpdates`, `-checkForUpdatesInBackground`, or `-checkForUpdateInformation` can be invoked.
|
||||
This may be useful if you want to check for updates immediately or without showing a potential permission prompt.
|
||||
|
||||
If the updater cannot be started (i.e, due to a configuration issue in the application), you may want to fall back appropriately.
|
||||
For example, the standard updater controller (`SPUStandardUpdaterController`) alerts the user that the app is misconfigured and to contact the developer.
|
||||
|
||||
This must be called on the main thread.
|
||||
|
||||
@@ -75,22 +86,22 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
*/
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Checks for updates, and displays progress while doing so if needed.
|
||||
|
||||
This is meant for users initiating a new update check or checking the current update progress.
|
||||
|
||||
If an update hasn't started, the user may be shown that a new check for updates is occurring.
|
||||
If an update has already been downloaded or begun installing, the user may be presented to install that update.
|
||||
If an update has already been downloaded or begun installing from a previous session, the user may be presented to install that update.
|
||||
If the user is already being presented with an update, that update will be shown to the user in active focus.
|
||||
|
||||
This will find updates that the user has previously opted into skipping.
|
||||
|
||||
See canCheckForUpdates property which can determine if this method may be invoked.
|
||||
See `canCheckForUpdates` property which can determine when this method may be invoked.
|
||||
*/
|
||||
- (void)checkForUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates.
|
||||
@@ -99,80 +110,102 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
Note if there is no resumable update found, and automated updating is turned on,
|
||||
the update will be downloaded in the background without disrupting the user.
|
||||
|
||||
This method does not do anything if there is a `sessionInProgress`.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SPUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SPUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
`-[SPUUpdaterDelegate updater:didFindValidUpdate:]` and
|
||||
`-[SPUUpdaterDelegate updaterDidNotFindUpdate:]` will be called,
|
||||
so you can use that information in your UI.
|
||||
|
||||
`-[SPUUpdaterDelegate updater:didFinishUpdateCycleForUpdateCheck:error:]` will be called when
|
||||
this probing check is completed.
|
||||
|
||||
Updates that have been skipped by the user will not be found.
|
||||
|
||||
This method does not do anything if there is a `sessionInProgress`.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A property indicating whether or not updates can be checked by the user.
|
||||
|
||||
An update check can be made by the user when an update session isn't in progress, or when an update or its progress is being shown to the user.
|
||||
|
||||
This property is suitable to use for menu item validation for seeing if -checkForUpdates can be invoked.
|
||||
This property is suitable to use for menu item validation for seeing if `-checkForUpdates` can be invoked.
|
||||
|
||||
Note this property does not reflect whether or not an update session is in progress. Please see sessionInProgress property instead.
|
||||
Note this property does not reflect whether or not an update session is in progress. Please see `sessionInProgress` property instead.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL canCheckForUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A property indicating whether or not an update session is in progress.
|
||||
|
||||
An update session is in progress when the appcast is being downloaded, an update is being downloaded,
|
||||
an update is being shown, update permission is being requested, or the installer is being started.
|
||||
|
||||
An active session is when Sparkle's fired scheduler is running.
|
||||
|
||||
Note an update session may be inactive even though Sparkle's installer (ran as a separate process) may be running,
|
||||
Note an update session may not be running even though Sparkle's installer (ran as a separate process) may be running,
|
||||
or even though the update has been downloaded but the installation has been deferred. In both of these cases, a new update session
|
||||
may be activated with the update resumed at a later point (automatically or manually).
|
||||
|
||||
See also canCheckForUpdates property which is more suited for menu item validation.
|
||||
See also:
|
||||
- `canCheckForUpdates` property which is more suited for menu item validation.
|
||||
- `-[SPUUpdaterDelegate updater:didFinishUpdateCycleForUpdateCheck:error:]` which lets the updater delegate know when an update cycle and session finishes.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL sessionInProgress;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A property indicating whether or not to check for updates automatically.
|
||||
|
||||
By default, Sparkle asks users on second launch for permission if they want automatic update checks enabled
|
||||
and sets this property based on their response. If SUEnableAutomaticChecks is set in the Info.plist,
|
||||
this permission request is not performed however.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating the current automatic update check interval.
|
||||
/**
|
||||
A property indicating the current automatic update check interval in seconds.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
For this reason, only set this property if you need dynamic behavior (eg user preferences).
|
||||
Otherwise prefer to set SUScheduledCheckInterval directly in your Info.plist.
|
||||
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A property indicating whether or not updates can be automatically downloaded in the background.
|
||||
|
||||
By default, updates are not automatically downloaded.
|
||||
|
||||
Note that the developer can disallow automatic downloading of updates from being enabled.
|
||||
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
|
||||
In this case, this property will return NO regardless of how this property is set.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
For this reason, only set this property if you need dynamic behavior (eg user preferences).
|
||||
Otherwise prefer to set SUAutomaticallyUpdate directly in your Info.plist.
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
The URL of the appcast used to download update information.
|
||||
|
||||
If the updater's delegate implements -[SPUUpdaterDelegate feedURLStringForUpdater:], this will return that feed URL.
|
||||
If the updater's delegate implements `-[SPUUpdaterDelegate feedURLStringForUpdater:]`, this will return that feed URL.
|
||||
Otherwise if the feed URL has been set before, the feed URL returned will be retrieved from the host bundle's user defaults.
|
||||
Otherwise the feed URL in the host bundle's Info.plist will be returned.
|
||||
If no feed URL can be retrieved, returns nil.
|
||||
@@ -181,75 +214,68 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) NSURL *feedURL;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Set the URL of the appcast used to download update information. Using this method is discouraged.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
To avoid this, you should consider instead implementing
|
||||
-[SPUUpdaterDelegate feedURLStringForUpdater:]
|
||||
To avoid this, you should consider implementing
|
||||
`-[SPUUpdaterDelegate feedURLStringForUpdater:]` instead of using this method.
|
||||
|
||||
Passing nil will remove any feed URL that has been set in the host bundle's user defaults.
|
||||
If you do not need to alternate between multiple feeds, set the SUFeedURL in your Info.plist instead of invoking this method.
|
||||
|
||||
For beta updates, you may consider migrating to -[SPUUpdaterDelegate allowedChannelsForUpdater:] in the future.
|
||||
For beta updates, you may consider migrating to `-[SPUUpdaterDelegate allowedChannelsForUpdater:]` in the future.
|
||||
|
||||
This method must be called on the main thread; calls from background threads will have no effect.
|
||||
*/
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL;
|
||||
- (void)setFeedURL:(nullable NSURL *)feedURL;
|
||||
|
||||
/*!
|
||||
/**
|
||||
The host bundle that is being updated.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSBundle *hostBundle;
|
||||
|
||||
/*!
|
||||
The bundle this class (SPUUpdater) is loaded into
|
||||
*/
|
||||
@property (nonatomic, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
/*!
|
||||
* The user agent used when checking for updates.
|
||||
*
|
||||
* The default implementation can be overrided.
|
||||
/**
|
||||
The user agent used when checking for updates.
|
||||
|
||||
By default the user agent string returned is in the format:
|
||||
$(BundleDisplayName)/$(BundleDisplayVersion) Sparkle/$(SparkleDisplayVersion)
|
||||
|
||||
BundleDisplayVersion is derived from the application Info.plist's CFBundleShortVersionString.
|
||||
|
||||
This default implementation can be overrided.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
/*!
|
||||
The HTTP headers used when checking for updates.
|
||||
/**
|
||||
The HTTP headers used when checking for updates, downloading release notes, and downloading updates.
|
||||
|
||||
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
|
||||
The keys of this dictionary are HTTP header fields and values are corresponding values.
|
||||
*/
|
||||
#if __has_feature(objc_generics)
|
||||
@property (nonatomic, copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
#else
|
||||
@property (nonatomic, copy, nullable) NSDictionary *httpHeaders;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
/**
|
||||
A property indicating whether or not the user's system profile information is sent when checking for updates.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property (nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
/**
|
||||
The date of the last update check or nil if no check has been performed yet.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy, nullable) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
/**
|
||||
Appropriately schedules or cancels the update checking timer according to the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal timer.
|
||||
This call does not change the date of the next check, but only the internal timer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
|
||||
/*!
|
||||
The system profile information that is sent when checking for updates
|
||||
/**
|
||||
The system profile information that is sent when checking for updates.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy) NSArray<NSDictionary<NSString *, NSString *> *> *systemProfileArray;
|
||||
|
||||
|
||||
Vendored
+144
-83
@@ -15,6 +15,7 @@
|
||||
#import "SPUUpdateDriver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SULog+NSError.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUSystemProfiler.h"
|
||||
#import "SPUScheduledUpdateDriver.h"
|
||||
@@ -50,6 +51,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (nonatomic) id <SPUUpdateDriver> driver;
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) NSBundle *applicationBundle;
|
||||
@property (nonatomic, readonly) NSBundle *sparkleBundle;
|
||||
@property (nonatomic, readonly) SPUUpdaterSettings *updaterSettings;
|
||||
@property (nonatomic, readonly) SPUUpdaterCycle *updaterCycle;
|
||||
@property (nonatomic, readonly) SPUUpdaterTimer *updaterTimer;
|
||||
@@ -61,7 +63,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
|
||||
|
||||
@property (nonatomic) BOOL loggedATSWarning;
|
||||
@property (nonatomic) BOOL loggedDSAWarning;
|
||||
@property (nonatomic) BOOL loggedNoSecureKeyWarning;
|
||||
|
||||
@end
|
||||
|
||||
@@ -84,7 +86,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@synthesize showingPermissionRequest = _showingPermissionRequest;
|
||||
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
|
||||
@synthesize loggedATSWarning = _loggedATSWarning;
|
||||
@synthesize loggedDSAWarning = _loggedDSAWarning;
|
||||
@synthesize loggedNoSecureKeyWarning = _loggedNoSecureKeyWarning;
|
||||
|
||||
#if DEBUG
|
||||
+ (void)load
|
||||
@@ -215,17 +217,18 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
}
|
||||
}
|
||||
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
|
||||
|
||||
if (feedURL != nil) {
|
||||
servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
if (!servingOverHttps) {
|
||||
BOOL foundXPCPersistentDownloaderService = NO;
|
||||
BOOL foundATSPersistentIssue = [self checkATSIssueForBundle:SPUXPCServiceBundle(@DOWNLOADER_BUNDLE_ID) getBundleExists:&foundXPCPersistentDownloaderService];
|
||||
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
BOOL foundATSMainBundleIssue = NO;
|
||||
if (!foundATSPersistentIssue && !foundXPCPersistentDownloaderService) {
|
||||
BOOL foundATSIssue = ([mainBundle objectForInfoDictionaryKey:@"NSAppTransportSecurity"] == nil);
|
||||
BOOL updatingMainBundle = [self.host.bundle isEqualTo:mainBundle];
|
||||
|
||||
if (updatingMainBundle) {
|
||||
// The only way we'll know for sure if there is an issue is if the main bundle is the same as the one we're updating
|
||||
@@ -245,8 +248,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hasPublicKey = self.host.publicKeys.hasAnyKeys;
|
||||
if (!hasPublicKey) {
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
BOOL hasAnyPublicKey = publicKeys.hasAnyKeys;
|
||||
if (!hasAnyPublicKey) {
|
||||
// If we failed to retrieve a DSA key but the bundle specifies a path to one, we should consider this a configuration failure
|
||||
NSString *publicDSAKeyFileKey = [self.host publicDSAKeyFileKey];
|
||||
if (publicDSAKeyFileKey != nil) {
|
||||
@@ -256,26 +260,40 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow invalid EdDSA public keys
|
||||
if (publicKeys.ed25519PubKeyStatus == SUSigningInputStatusInvalid) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"The EdDSA public key is not valid for %@.", hostName] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!hasPublicKey) {
|
||||
if (!hasAnyPublicKey) {
|
||||
if ((feedURL != nil && !servingOverHttps) || ![SUCodeSigningVerifier bundleAtURLIsCodeSigned:[[self hostBundle] bundleURL]]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUNoPublicDSAFoundError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"For security reasons, updates need to be signed with an EdDSA key for %@. See Sparkle's documentation for more information.", hostName] }];
|
||||
}
|
||||
return NO;
|
||||
} else {
|
||||
if (!self.loggedDSAWarning) {
|
||||
SULog(SULogLevelDefault, @"DEPRECATION: Serving updates without an EdDSA key is now deprecated and may be removed from a future release. See Sparkle's documentation for more information.");
|
||||
if (updatingMainBundle && !self.loggedNoSecureKeyWarning) {
|
||||
SULog(SULogLevelError, @"Error: Serving updates without an EdDSA key and only using Apple Code Signing is deprecated and may be unsupported in a future release. Visit Sparkle's documentation for more information: https://sparkle-project.org/documentation/#3-segue-for-security-concerns");
|
||||
|
||||
self.loggedDSAWarning = YES;
|
||||
self.loggedNoSecureKeyWarning = YES;
|
||||
}
|
||||
}
|
||||
} else if (publicKeys.ed25519PubKey == nil) {
|
||||
// No EdDSA key is available, so app must be using DSA
|
||||
if (updatingMainBundle && !self.loggedNoSecureKeyWarning) {
|
||||
SULog(SULogLevelError, @"Error: Serving updates without an EdDSA key is insecure and deprecated. DSA support may be removed in a future Sparkle release. Please migrate to using EdDSA (ed25519). Visit Sparkle's documentation for migration information: https://sparkle-project.org/documentation/#3-segue-for-security-concerns");
|
||||
|
||||
self.loggedNoSecureKeyWarning = YES;
|
||||
}
|
||||
}
|
||||
|
||||
// Check XPC Services are functional
|
||||
NSBundle *sparkleBundle = [NSBundle bundleForClass:[self class]];
|
||||
for (NSString *xpcServiceID in @[@INSTALLER_LAUNCHER_BUNDLE_ID, @DOWNLOADER_BUNDLE_ID, @INSTALLER_CONNECTION_BUNDLE_ID, @INSTALLER_STATUS_BUNDLE_ID]) {
|
||||
if (!SPUXPCValidateServiceIfBundleExists(xpcServiceID, sparkleBundle, error)) {
|
||||
if (!SPUXPCValidateServiceIfBundleExists(xpcServiceID, self.sparkleBundle, error)) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -386,8 +404,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
[self.updaterTimer invalidate];
|
||||
|
||||
if (![self automaticallyChecksForUpdates]) {
|
||||
if ([self.delegate respondsToSelector:@selector(updaterWillIdleSchedulingUpdates:)]) {
|
||||
[self.delegate updaterWillIdleSchedulingUpdates:self];
|
||||
if ([self.delegate respondsToSelector:@selector(updaterWillNotScheduleUpdateCheck:)]) {
|
||||
[self.delegate updaterWillNotScheduleUpdateCheck:self];
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -458,7 +476,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
[[SPUAutomaticUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
applicationBundle:strongSelf.applicationBundle
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf
|
||||
userDriver:strongSelf.userDriver
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
@@ -467,20 +484,12 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
[[SPUScheduledUpdateDriver alloc]
|
||||
initWithHost:strongSelf.host
|
||||
applicationBundle:strongSelf.applicationBundle
|
||||
sparkleBundle:strongSelf.sparkleBundle
|
||||
updater:strongSelf
|
||||
userDriver:strongSelf.userDriver
|
||||
updaterDelegate:strongSelf.delegate];
|
||||
}
|
||||
|
||||
BOOL preventsInstallerInteraction;
|
||||
if ([strongSelf.delegate respondsToSelector:@selector(updater:shouldAllowInstallerInteractionForUpdateCheck:)]) {
|
||||
preventsInstallerInteraction = ![strongSelf.delegate updater:strongSelf shouldAllowInstallerInteractionForUpdateCheck:SPUUpdateCheckBackgroundScheduled];
|
||||
} else {
|
||||
preventsInstallerInteraction = NO;
|
||||
}
|
||||
|
||||
[strongSelf checkForUpdatesWithDriver:updateDriver installerInProgress:installerIsRunning preventsInstallerInteraction:preventsInstallerInteraction];
|
||||
[strongSelf checkForUpdatesWithDriver:updateDriver updateCheck:SPUUpdateCheckUpdatesInBackground installerInProgress:installerIsRunning];
|
||||
});
|
||||
}];
|
||||
}
|
||||
@@ -510,7 +519,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
self.sessionInProgress = YES;
|
||||
|
||||
id <SPUUpdateDriver> theUpdateDriver = [[SPUUserInitiatedUpdateDriver alloc] initWithHost:self.host applicationBundle:self.applicationBundle sparkleBundle:self.sparkleBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate];
|
||||
id <SPUUpdateDriver> theUpdateDriver = [[SPUUserInitiatedUpdateDriver alloc] initWithHost:self.host applicationBundle:self.applicationBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate];
|
||||
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
@@ -520,14 +529,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
BOOL preventsInstallerInteraction;
|
||||
if ([strongSelf.delegate respondsToSelector:@selector(updater:shouldAllowInstallerInteractionForUpdateCheck:)]) {
|
||||
preventsInstallerInteraction = ![strongSelf.delegate updater:strongSelf shouldAllowInstallerInteractionForUpdateCheck:SPUUpdateCheckUserInitiated];
|
||||
} else {
|
||||
preventsInstallerInteraction = NO;
|
||||
}
|
||||
|
||||
[strongSelf checkForUpdatesWithDriver:theUpdateDriver installerInProgress:installerInProgress preventsInstallerInteraction:preventsInstallerInteraction];
|
||||
[strongSelf checkForUpdatesWithDriver:theUpdateDriver updateCheck:SPUUpdateCheckUpdates installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
@@ -554,13 +556,13 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf checkForUpdatesWithDriver:[[SPUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf updaterDelegate:strongSelf.delegate] installerInProgress:installerInProgress preventsInstallerInteraction:NO];
|
||||
[strongSelf checkForUpdatesWithDriver:[[SPUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf updaterDelegate:strongSelf.delegate] updateCheck:SPUUpdateCheckUpdateInformation installerInProgress:installerInProgress];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesWithDriver:(id <SPUUpdateDriver> )d installerInProgress:(BOOL)installerInProgress preventsInstallerInteraction:(BOOL)preventsInstallerInteraction
|
||||
- (void)checkForUpdatesWithDriver:(id <SPUUpdateDriver> )d updateCheck:(SPUUpdateCheck)updateCheck installerInProgress:(BOOL)installerInProgress
|
||||
{
|
||||
if (self.driver != nil) {
|
||||
return;
|
||||
@@ -570,57 +572,115 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
[self updateLastUpdateCheckDate];
|
||||
|
||||
if( [self.delegate respondsToSelector: @selector((updaterMayCheckForUpdates:))] && ![self.delegate updaterMayCheckForUpdates:self] )
|
||||
{
|
||||
self.sessionInProgress = NO;
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
|
||||
self.driver = d;
|
||||
assert(self.driver != nil);
|
||||
|
||||
// Because an application can change the configuration (eg: the feed url) at any point, we should always check if it's valid
|
||||
NSError *configurationError = nil;
|
||||
if (![self checkIfConfiguredProperlyAndRequireFeedURL:YES error:&configurationError]) {
|
||||
// Don't think we should schedule a next update check if the bundle has been misconfigured once,
|
||||
// which would mean something is really off
|
||||
SULog(SULogLevelError, @"Sparkle configuration error (%ld): %@", (long)configurationError.code, configurationError.localizedDescription);
|
||||
SULog(SULogLevelDefault, @"Disabling scheduled updates..");
|
||||
|
||||
void (^notifyDelegateOfDriverCompletion)(NSError * _Nullable, BOOL) = ^(NSError * _Nullable error, BOOL shouldShowUpdateImmediately) {
|
||||
if (error != nil) {
|
||||
if (error.code != SUNoUpdateError && error.code != SUInstallationCanceledError && error.code != SUInstallationAuthorizeLaterError) { // Let's not bother logging this.
|
||||
SULogError(error);
|
||||
}
|
||||
|
||||
// Notify host app that update driver has aborted if a non-recoverable error occurs
|
||||
if (error.code != SUInstallationAuthorizeLaterError && [self.delegate respondsToSelector:@selector((updater:didAbortWithError:))]) {
|
||||
[self.delegate updater:self didAbortWithError:(NSError * _Nonnull)error];
|
||||
}
|
||||
}
|
||||
|
||||
self.sessionInProgress = NO;
|
||||
[self.driver abortUpdateWithError:configurationError];
|
||||
self.driver = nil;
|
||||
// Notify host app that update driver has finished
|
||||
// As long as we're not going to immmediately kick off a new check
|
||||
if (!shouldShowUpdateImmediately && [self.delegate respondsToSelector:@selector((updater:didFinishUpdateCycleForUpdateCheck:error:))]) {
|
||||
[self.delegate updater:self didFinishUpdateCycleForUpdateCheck:updateCheck error:error];
|
||||
}
|
||||
};
|
||||
|
||||
void (^abortUpdateDriver)(NSError * _Nullable , BOOL) = ^(NSError * _Nullable abortError, BOOL shouldScheduleNextUpdateCheck) {
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
[self.driver setCompletionHandler:^(BOOL __unused shouldShowUpdateImmediately, id<SPUResumableUpdate> _Nullable __unused resumableUpdate, NSError * _Nullable error) {
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.driver = nil;
|
||||
strongSelf.sessionInProgress = NO;
|
||||
|
||||
[strongSelf updateLastUpdateCheckDate];
|
||||
|
||||
notifyDelegateOfDriverCompletion(error, NO);
|
||||
|
||||
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
||||
if (!strongSelf.sessionInProgress) {
|
||||
if (shouldScheduleNextUpdateCheck) {
|
||||
[strongSelf scheduleNextUpdateCheck];
|
||||
} else {
|
||||
SULog(SULogLevelDefault, @"Disabling scheduled updates..");
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
[self.driver abortUpdateWithError:abortError];
|
||||
};
|
||||
|
||||
// Check if the delegate wants to defer checking for updates
|
||||
NSError *mayCheckForUpdatesError = nil;
|
||||
if (
|
||||
([self.delegate respondsToSelector:@selector(updater:mayPerformUpdateCheck:error:)] && ![self.delegate updater:self mayPerformUpdateCheck:updateCheck error:&mayCheckForUpdatesError]) ||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
([self.delegate respondsToSelector:@selector((updaterMayCheckForUpdates:))] && ![self.delegate updaterMayCheckForUpdates:self]))
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
abortUpdateDriver(mayCheckForUpdatesError, YES);
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL *theFeedURL = [self parameterizedFeedURL];
|
||||
if (theFeedURL) {
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
SPUUpdateDriverCompletion completionBlock = ^(BOOL shouldShowUpdateImmediately, id<SPUResumableUpdate> _Nullable resumableUpdate) {
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.resumableUpdate = resumableUpdate;
|
||||
strongSelf.driver = nil;
|
||||
self.sessionInProgress = NO;
|
||||
[strongSelf updateLastUpdateCheckDate];
|
||||
// Because an application can change the configuration (eg: the feed url) at any point, we should always check if it's valid
|
||||
// We will not schedule a next update check if the bundle is misconfigured
|
||||
NSError *configurationError = nil;
|
||||
if (![self checkIfConfiguredProperlyAndRequireFeedURL:YES error:&configurationError]) {
|
||||
SULog(SULogLevelError, @"Sparkle configuration error (%ld): %@", (long)configurationError.code, configurationError.localizedDescription);
|
||||
|
||||
abortUpdateDriver(configurationError, NO);
|
||||
return;
|
||||
}
|
||||
|
||||
// Run our update driver and schedule next update check on its completion
|
||||
__weak SPUUpdater *weakSelf = self;
|
||||
[self.driver setCompletionHandler:^(BOOL shouldShowUpdateImmediately, id<SPUResumableUpdate> _Nullable resumableUpdate, NSError * _Nullable error) {
|
||||
SPUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.resumableUpdate = resumableUpdate;
|
||||
strongSelf.driver = nil;
|
||||
strongSelf.sessionInProgress = NO;
|
||||
[strongSelf updateLastUpdateCheckDate];
|
||||
|
||||
notifyDelegateOfDriverCompletion(error, shouldShowUpdateImmediately);
|
||||
|
||||
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
||||
if (!strongSelf.sessionInProgress) {
|
||||
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately];
|
||||
}
|
||||
};
|
||||
|
||||
if (installerInProgress) {
|
||||
[self.driver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
} else if (self.resumableUpdate != nil) {
|
||||
[self.driver resumeUpdate:(id<SPUResumableUpdate> _Nonnull)self.resumableUpdate completion:completionBlock];
|
||||
} else {
|
||||
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] preventingInstallerInteraction:preventsInstallerInteraction completion:completionBlock];
|
||||
}
|
||||
}];
|
||||
|
||||
if (installerInProgress) {
|
||||
// Resume an update that has already begun installing in the background
|
||||
[self.driver resumeInstallingUpdate];
|
||||
} else if (self.resumableUpdate != nil) {
|
||||
// Resume an update or info that has already been downloaded
|
||||
[self.driver resumeUpdate:(id<SPUResumableUpdate> _Nonnull)self.resumableUpdate];
|
||||
} else {
|
||||
// I think this is really unlikely to occur but better be safe
|
||||
[self.driver abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidFeedURLError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot form a valid feed URL." }]];
|
||||
self.sessionInProgress = NO;
|
||||
self.driver = nil;
|
||||
// Check that the parameterized feed URL is valid
|
||||
NSURL *theFeedURL = [self parameterizedFeedURL];
|
||||
if (theFeedURL == nil) {
|
||||
// I think this is really unlikely to occur but better be safe
|
||||
// We will not schedule a next update check if the feed URL cannot be formed
|
||||
SULog(SULogLevelError, @"Error: failed to retrieve feed URL for bundle");
|
||||
|
||||
abortUpdateDriver([NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidFeedURLError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot form a valid feed URL." }], NO);
|
||||
} else {
|
||||
// Check for new updates
|
||||
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,8 +815,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return customUserAgentString;
|
||||
}
|
||||
|
||||
NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"];
|
||||
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], @""MARKETING_VERSION];
|
||||
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
|
||||
|
||||
NSString *result = @"";
|
||||
@@ -844,14 +903,16 @@ static NSString *escapeURLComponent(NSString *str) {
|
||||
NSArray *systemProfile = [SUSystemProfiler systemProfileArrayForHost:self.host];
|
||||
if ([self.delegate respondsToSelector:@selector(allowedSystemProfileKeysForUpdater:)]) {
|
||||
NSArray * allowedKeys = [self.delegate allowedSystemProfileKeysForUpdater:self];
|
||||
NSMutableArray *filteredProfile = [NSMutableArray array];
|
||||
for (NSDictionary *profileElement in systemProfile) {
|
||||
NSString *key = [profileElement objectForKey:@"key"];
|
||||
if (key && [allowedKeys containsObject:key]) {
|
||||
[filteredProfile addObject:profileElement];
|
||||
if (allowedKeys != nil) {
|
||||
NSMutableArray *filteredProfile = [NSMutableArray array];
|
||||
for (NSDictionary *profileElement in systemProfile) {
|
||||
NSString *key = [profileElement objectForKey:@"key"];
|
||||
if (key && [allowedKeys containsObject:key]) {
|
||||
[filteredProfile addObject:profileElement];
|
||||
}
|
||||
}
|
||||
systemProfile = [filteredProfile copy];
|
||||
}
|
||||
systemProfile = [filteredProfile copy];
|
||||
}
|
||||
return systemProfile;
|
||||
}
|
||||
|
||||
Vendored
+240
-214
@@ -15,6 +15,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SPUUpdateCheck.h>
|
||||
|
||||
@protocol SUVersionComparison;
|
||||
@class SPUUpdater, SUAppcast, SUAppcastItem;
|
||||
@@ -57,269 +58,261 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
|
||||
// SPUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUpdateCheck)
|
||||
{
|
||||
SPUUpdateCheckUserInitiated = 0,
|
||||
SPUUpdateCheckBackgroundScheduled = 1
|
||||
};
|
||||
|
||||
/*!
|
||||
Provides methods to control the behavior of an SPUUpdater object.
|
||||
/**
|
||||
Provides delegation methods to control the behavior of an `SPUUpdater` object.
|
||||
*/
|
||||
@protocol SPUUpdaterDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Called when a background update will be scheduled after a delay.
|
||||
|
||||
Automatic update checks need to be enabled for this to trigger.
|
||||
|
||||
\param delay The delay until the next scheduled update will occur.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willScheduleUpdateCheckAfterDelay:(NSTimeInterval)delay;
|
||||
|
||||
/*!
|
||||
Called when no updates will be scheduled in the future.
|
||||
|
||||
This may later change if automatic update checks become enabled.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillIdleSchedulingUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether to allow Sparkle to pop up.
|
||||
/**
|
||||
Returns whether to allow Sparkle to check for updates.
|
||||
|
||||
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
|
||||
Alternatively, you may want to consider starting the updater after eg: the setup assistant finishes
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)updater;
|
||||
@param updater The updater instance.
|
||||
@param updateCheck The type of update check that will be performed if the updater is allowed to check for updates.
|
||||
@param error The (optionally) populated error object if the updater may not perform a new update check.
|
||||
@return @c YES if the updater is allowed to check for updates, otherwise @c NO
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater mayPerformUpdateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
|
||||
|
||||
/*!
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
*/
|
||||
#if __has_feature(objc_generics)
|
||||
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
#else
|
||||
- (NSArray *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Returns a list of system profile keys to be appended to the appcast URL's query string.
|
||||
|
||||
If this is unimplemented then all keys will be included.
|
||||
|
||||
\param updater The updater instance.
|
||||
|
||||
\return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the SUSystemProfiler*Key constants
|
||||
*/
|
||||
#if __has_feature(objc_generics)
|
||||
- (NSArray<NSString *> *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater;
|
||||
#else
|
||||
- (NSArray *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Returns a custom appcast URL.
|
||||
|
||||
Override this to dynamically specify the entire URL.
|
||||
Alternatively you may want to consider adding a feed parameter using -feedParametersForUpdater:sendingSystemProfile:
|
||||
and having the server which appcast to serve.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (nullable NSString *)feedURLStringForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns the set of Sparkle channels the updater is allowed to find new updates from.
|
||||
|
||||
An appcast item can specify a channel the update is posted to. Without specifying a channel, the appcast item is posted to the default channel.
|
||||
For instance:
|
||||
```
|
||||
<item>
|
||||
<sparkle:version>2.0 Beta 1</sparkle:version>
|
||||
<sparkle:channel>beta</sparkle:channel>
|
||||
</item>
|
||||
```
|
||||
|
||||
This example posts an update to the 'beta' channel, so only updaters that are allowed to use the 'beta' channel can find this update.
|
||||
This example posts an update to the @c beta channel, so only updaters that are allowed to use the @c beta channel can find this update.
|
||||
|
||||
If the <sparkle:channel> is not present, the update item is posted to the default channel and can be found by any updater.
|
||||
If the @c <sparkle:channel> element is not present, the update item is posted to the default channel and can be found by any updater.
|
||||
|
||||
You can pick any name you'd like for the channel. The valid characters for channel names are letters, numbers, dashes, underscores, and periods.
|
||||
|
||||
Note to use this feature, all app versions that your users may update from in your feed must use a version of Sparkle that supports this feature.
|
||||
This feature was added in Sparkle 2.
|
||||
|
||||
\return The set of channel names the updater is allowed to find new updates in. An empty set is the default behavior,
|
||||
@return The set of channel names the updater is allowed to find new updates in. An empty set is the default behavior,
|
||||
which means the updater will only look for updates in the default channel.
|
||||
*/
|
||||
- (NSSet<NSString *> *)allowedChannelsForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns a custom appcast URL used for checking for new updates.
|
||||
|
||||
Override this to dynamically specify the feed URL.
|
||||
|
||||
@param updater The updater instance.
|
||||
@return An appcast feed URL to check for new updates in, or @c nil for the default behavior and if you don't want to be delegated this task.
|
||||
*/
|
||||
- (nullable NSString *)feedURLStringForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/**
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
@return An array of dictionaries with keys: `key`, `value`, `displayKey`, `displayValue`, the latter two being specifically for display to the user.
|
||||
*/
|
||||
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
/**
|
||||
Returns whether Sparkle should prompt the user about checking for new updates automatically.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
@param updater The updater instance.
|
||||
@return @c YES if the updater should prompt for permission to check for new updates automatically, otherwise @c NO
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/**
|
||||
Returns an allowed list of system profile keys to be appended to the appcast URL's query string.
|
||||
|
||||
By default all keys will be included. This method allows overriding which keys should only be allowed.
|
||||
|
||||
@param updater The updater instance.
|
||||
|
||||
@return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the `SUSystemProfiler*Key` constants. Return @c nil for the default behavior and if you don't want to be delegated this task.
|
||||
*/
|
||||
- (nullable NSArray<NSString *> *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/**
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/**
|
||||
Called when a new valid update is found by the update driver.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/**
|
||||
Called when a valid new update is not found.
|
||||
|
||||
There are various reasons a new update is unavailable and can't be installed.
|
||||
|
||||
The userInfo dictionary on the error is populated with three keys:
|
||||
- `SPULatestAppcastItemFoundKey`: if available, this may provide the latest `SUAppcastItem` that was found. This will be @c nil if it's unavailable.
|
||||
- `SPUNoUpdateFoundReasonKey`: This will provide the `SPUNoUpdateFoundReason`.
|
||||
For example the reason could be because the latest version in the feed requires a newer OS version or could be because the user is already on the latest version.
|
||||
- `SPUNoUpdateFoundUserInitiatedKey`: A boolean that indicates if a new update was not found when the user intitiated an update check manually.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param error An error containing information on why a new valid update was not found
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater error:(NSError *)error;
|
||||
|
||||
/**
|
||||
Called when a valid new update is not found.
|
||||
|
||||
If more information is needed on why an update was not found, use `-[SPUUpdaterDelegate updaterDidNotFindUpdate:error:]` instead.
|
||||
|
||||
@param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater;
|
||||
|
||||
/**
|
||||
Returns the item in the appcast corresponding to the update that should be installed.
|
||||
|
||||
Please consider using or migrating to other supported features before adopting this method.
|
||||
Specifically:
|
||||
If you want to filter out certain tagged updates (like beta updates), consider -[SPUUpdaterDelegate allowedChannelsForUpdater:] instead.
|
||||
If you want to treat certain updates as informational-only, consider supplying <sparkle:informationalUpdate> with a set of affected versions users are updating from.
|
||||
- If you want to filter out certain tagged updates (like beta updates), consider `-[SPUUpdaterDelegate allowedChannelsForUpdater:]` instead.
|
||||
- If you want to treat certain updates as informational-only, consider supplying @c <sparkle:informationalUpdate> with a set of affected versions users are updating from.
|
||||
|
||||
If you're using special logic or extensions in your appcast,
|
||||
implement this to use your own logic for finding a valid update, if any,
|
||||
in the given appcast.
|
||||
If you're using special logic or extensions in your appcast, implement this to use your own logic for finding a valid update, if any, in the given appcast.
|
||||
|
||||
Do not base your logic by filtering out items with a minimum or maximum OS version or minimum autoupdate version,
|
||||
Do not base your logic by filtering out items with a minimum or maximum OS version or minimum autoupdate version
|
||||
because Sparkle already has logic for determining whether or not those items should be filtered out.
|
||||
|
||||
Also do not return a non-top level item from the appcast such as a delta item. Delta items will be ignored.
|
||||
Sparkle picks the delta item from your selection if the appropriate one is available.
|
||||
|
||||
This method will not be invoked with an appcast that has zero items. Pick the best item from the appcast.
|
||||
If an item is available that has the same version as the application or bundle to update,
|
||||
do not pick an item that is worse than that version.
|
||||
If an item is available that has the same version as the application or bundle to update, do not pick an item that is worse than that version.
|
||||
|
||||
This method may be called multiple times for different selections and filters. This method should be efficient.
|
||||
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
\param updater The updater instance.
|
||||
\return The best valid appcast item. Return SUAppcastItem.emptyAppcastItem if no appcast item is valid. Return nil if you don't want to be delegated this task and
|
||||
want to let Sparkle handle picking the best valid update.
|
||||
Return `+[SUAppcastItem emptyAppcastItem]` if no appcast item is valid.
|
||||
|
||||
Return @c nil if you don't want to be delegated this task and want to let Sparkle handle picking the best valid update.
|
||||
|
||||
@param appcast The appcast that was downloaded from the remote server.
|
||||
@param updater The updater instance.
|
||||
@return The best valid appcast item.
|
||||
*/
|
||||
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when a valid update is found by the update driver.
|
||||
/**
|
||||
Returns whether or not the updater should proceed with the new chosen update from the appcast.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
By default, the updater will always proceed with the best selected update found in an appcast. Override this to override this behavior.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param error An error containing information on why a new valid update was not found
|
||||
There are various reasons a new update is unavailable and can't be installed.
|
||||
The userInfo dictionary on the error is also populated with three keys:
|
||||
SPULatestAppcastItemFoundKey: if available, this may provide the latest SUAppcastItem that was found. This will be nil if it's unavailable.
|
||||
SPUNoUpdateFoundReasonKey: This will provide the SUNoUpdateFoundReason.
|
||||
For example the reason could be because the latest version in the feed requires a newer OS version or could be because the user is already on the latest version.
|
||||
SPUNoUpdateFoundUserInitiatedKey: A boolean that indicates if a new update was not found when the user intitiated an update check manually.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
If you return @c NO and populate the @c error, the user is not shown this @c updateItem nor is the update downloaded or installed.
|
||||
|
||||
\param updater The updater instance.
|
||||
@param updater The updater instance.
|
||||
@param updateItem The selected update item to proceed with.
|
||||
@param updateCheck The type of update check that would be performed if proceeded.
|
||||
@param error An error object that must be populated by the delegate if the updater should not proceed with the update.
|
||||
@return @c YES if the updater should proceed with @c updateItem, otherwise @c NO if the updater should not proceed with the update with an @c error populated.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater;
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldProceedWithUpdate:(SUAppcastItem *)updateItem updateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called when an update is skipped by the user.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that the user skipped.
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that the user skipped.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater userDidSkipThisVersion:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns whether the release notes (if available) should be downloaded after an update is found and shown.
|
||||
|
||||
This is specifically for the releaseNotesLink element in the appcast.
|
||||
This is specifically for the @c <releaseNotesLink> element in the appcast item.
|
||||
|
||||
\param updater The updater instance.
|
||||
@param updater The updater instance.
|
||||
@param updateItem The update item to download and show release notes from.
|
||||
|
||||
\return \c YES to download and show the release notes if available, otherwise NO. The default behavior is YES.
|
||||
@return @c YES to download and show the release notes if available, otherwise @c NO. The default behavior is @c YES.
|
||||
*/
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(SPUUpdater *)updater;
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldDownloadReleaseNotesForUpdate:(SUAppcastItem *)updateItem;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
\param request The mutable URL request that will be used to download the update.
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
@param request The mutable URL request that will be used to download the update.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately after succesfull download of the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that has been downloaded.
|
||||
@param updater The SUUpdater instance.
|
||||
@param item The appcast item corresponding to the update that has been downloaded.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called after the specified update failed to download.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that failed to download.
|
||||
\param error The error generated by the failed download.
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that failed to download.
|
||||
@param error The error generated by the failed download.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the cancel button while and update is being downloaded.
|
||||
/**
|
||||
Called when the user cancels an update while it is being downloaded.
|
||||
|
||||
\param updater The updater instance.
|
||||
@param updater The updater instance.
|
||||
*/
|
||||
- (void)userDidCancelDownload:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately before extracting the specified downloaded update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be extracted.
|
||||
@param updater The SUUpdater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be extracted.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately after extracting the specified downloaded update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that has been extracted.
|
||||
@param updater The SUUpdater instance.
|
||||
@param item The appcast item corresponding to the update that has been extracted.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately before installing the specified update.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
@@ -327,99 +320,132 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck)
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param installHandler The install handler that must be completed before continuing with the relaunch.
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
@param installHandler The install handler that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p installHandler is invoked.
|
||||
@return @c YES to delay the relaunch until @c installHandler is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
Some apps \b cannot be relaunched under certain circumstances.
|
||||
Some apps **cannot** be relaunched under certain circumstances.
|
||||
This method can be used to explicitly prevent a relaunch.
|
||||
|
||||
\param updater The updater instance.
|
||||
\return YES if the updater should be relaunched, otherwise NO if it shouldn't.
|
||||
@param updater The updater instance.
|
||||
@return @c YES if the updater should be relaunched, otherwise @c NO if it shouldn't.
|
||||
*/
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called immediately before relaunching.
|
||||
|
||||
\param updater The updater instance.
|
||||
@param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillRelaunchApplication:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Returns an object that compares version numbers to determine their arithmetic relation to each other.
|
||||
|
||||
This method allows you to provide a custom version comparator.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version comparator will be used. Note that the
|
||||
standard version comparator may be used during installation for preventing
|
||||
a downgrade, even if you provide a custom comparator here.
|
||||
If you don't implement this method or return @c nil,
|
||||
the standard version comparator will be used.
|
||||
|
||||
\sa SUStandardVersionComparator
|
||||
Note that the standard version comparator may be used during installation for preventing a downgrade,
|
||||
even if you provide a custom comparator here.
|
||||
|
||||
\param updater The updater instance.
|
||||
\return The custom version comparator or nil if you don't want to be delegated this task.
|
||||
@param updater The updater instance.
|
||||
@return The custom version comparator or @c nil if you don't want to be delegated this task.
|
||||
*/
|
||||
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether or not the updater should allow interaction from the installer
|
||||
/**
|
||||
Called when a background update will be scheduled after a delay.
|
||||
|
||||
Use this to override the default behavior which is to allow interaction with the installer.
|
||||
Automatic update checks need to be enabled for this to trigger.
|
||||
|
||||
If interaction is allowed, then an authorization prompt may show up to the user if they do
|
||||
not curently have sufficient privileges to perform the installation of the new update.
|
||||
The installer may also show UI and progress when interaction is allowed.
|
||||
@param delay The delay in seconds until the next scheduled update will occur.
|
||||
|
||||
On the other hand, if interaction is not allowed, then an installation may fail if the user does not
|
||||
have sufficient privileges to perform the installation. In this case, the feed and update may not even be downloaded.
|
||||
|
||||
Note this has no effect if the update has already been downloaded in the background silently and ready to be resumed.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param updateCheck The type of update check being performed.
|
||||
@param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldAllowInstallerInteractionForUpdateCheck:(SPUUpdateCheck)updateCheck;
|
||||
- (void)updater:(SPUUpdater *)updater willScheduleUpdateCheckAfterDelay:(NSTimeInterval)delay;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called when no update checks will be scheduled in the future.
|
||||
|
||||
This may later change if automatic update checks become enabled.
|
||||
|
||||
@param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillNotScheduleUpdateCheck:(SPUUpdater *)updater;
|
||||
|
||||
/**
|
||||
Returns the decryption password (if any) which is used to extract the update archive DMG.
|
||||
|
||||
Return nil if no password should be used.
|
||||
Return @c nil if no password should be used.
|
||||
|
||||
\param updater The updater instance.
|
||||
\return The password used for decrypting the archive, or nil if no password should be used.
|
||||
@param updater The updater instance.
|
||||
@return The password used for decrypting the archive, or @c nil if no password should be used.
|
||||
*/
|
||||
- (nullable NSString *)decryptionPasswordForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
/**
|
||||
Called when an update is scheduled to be silently installed on quit after downloading the update automatically.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation.
|
||||
\return Return YES if the delegate will handle installing the update or NO if the updater should be given responsibility.
|
||||
|
||||
If the updater is given responsibility, it can later remind the user an update is available if they have not terminated the application for a long time.
|
||||
|
||||
Also if the updater is given responsibility and the update item is marked critical, the new update will be presented to the user immediately after.
|
||||
Even if the immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
|
||||
|
||||
Even if the @c immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
@param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation.
|
||||
@return @c YES if the delegate will handle installing the update or @c NO if the updater should be given responsibility.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
|
||||
|
||||
/*!
|
||||
Called after an update is aborted due to an error.
|
||||
/**
|
||||
Called after the update driver aborts due to an error.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param error The error that caused the abort
|
||||
The update driver runs when checking for updates. This delegate method is called an error occurs during this process.
|
||||
|
||||
Some special possible values of `error.code` are:
|
||||
|
||||
- `SUNoUpdateError`: No new update was found.
|
||||
- `SUInstallationCanceledError`: The user canceled installing the update when requested for authorization.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param error The error that caused the update driver to abort.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error;
|
||||
|
||||
/**
|
||||
Called after the update driver finishes.
|
||||
|
||||
The update driver runs when checking for updates. This delegate method is called when that check is finished.
|
||||
|
||||
An update may be scheduled to be installed during the update cycle, or no updates may be found, or an available update may be dismissed or skipped (which is the same as no error).
|
||||
|
||||
If the @c error is @c nil, no error has occurred.
|
||||
|
||||
Some special possible values of `error.code` are:
|
||||
|
||||
- `SUNoUpdateError`: No new update was found.
|
||||
- `SUInstallationCanceledError`: The user canceled installing the update when requested for authorization.
|
||||
|
||||
@param updater The updater instance.
|
||||
@param updateCheck The type of update check was performed.
|
||||
@param error The error that caused the update driver to abort. This is @c nil if the update driver finished normally and there is no error.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFinishUpdateCycleForUpdateCheck:(SPUUpdateCheck)updateCheck error:(nullable NSError *)error;
|
||||
|
||||
/* Deprecated methods */
|
||||
|
||||
- (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)updater __deprecated_msg("Please use -[SPUUpdaterDelegate updater:mayPerformUpdateCheck:error:] instead.");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+6
-6
@@ -18,7 +18,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
/**
|
||||
This class can be used for reading certain updater settings.
|
||||
|
||||
It retrieves the settings by first looking into the host's user defaults.
|
||||
@@ -28,22 +28,22 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Indicates whether or not automatic update checks are enabled.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* The regular update check interval.
|
||||
*/
|
||||
@property (readonly, nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Indicates whether or not automatically downloading updates is allowed to be turned on by the user.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL allowsAutomaticUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Indicates whether or not automatically downloading updates is enabled by the user or developer.
|
||||
*
|
||||
* Note this does not indicate whether or not automatic downloading of updates is allowable.
|
||||
@@ -51,7 +51,7 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Indicates whether or not anonymous system profile information is sent when checking for updates.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
Vendored
+51
-46
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUUpdatePermissionRequest, SUUpdatePermissionResponse, SUAppcastItem, SPUDownloadData;
|
||||
|
||||
/*!
|
||||
/**
|
||||
The API in Sparkle for controlling the user interaction.
|
||||
|
||||
This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell
|
||||
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show an updater permission request to the user
|
||||
*
|
||||
* Ask the user for their permission regarding update checks.
|
||||
@@ -43,7 +43,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)request reply:(void (^)(SUUpdatePermissionResponse *))reply;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user initating an update check
|
||||
*
|
||||
* Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar.
|
||||
@@ -52,42 +52,45 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user a new update is found.
|
||||
*
|
||||
* Let the user know a new update is found and ask them what they want to do.
|
||||
* Before this point, -showUserInitiatedUpdateCheckWithCancellation: may be called.
|
||||
* Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update.
|
||||
*
|
||||
* @param state The current state of the user update.
|
||||
* The state.stage values are:
|
||||
* SPUUpdateStateNotDownloaded - Update has not been downloaded yet.
|
||||
* SPUUpdateStateDownloaded - Update has already been downloaded but not started installing yet.
|
||||
* SPUUpdateStateInstalling - Update has been downloaded and already started installing.
|
||||
* `SPUUpdateStateNotDownloaded` - Update has not been downloaded yet.
|
||||
* `SPUUpdateStateDownloaded` - Update has already been downloaded but not started installing yet.
|
||||
* `SPUUpdateStateInstalling` - Update has been downloaded and already started installing.
|
||||
*
|
||||
* state.userInitiated indicates if the update was initiated by the user or if it was automatically scheduled in the background.
|
||||
*
|
||||
* Additionally, these properties on the appcastItem are of importance:
|
||||
* appcastItem.informationOnlyUpdate indicates if the update is only informational and should not be downloaded. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case.
|
||||
* appcastItem.majorUpgrade indicates if the update is a major or paid upgrade.
|
||||
* appcastItem.criticalUpdate indicates if the update is a critical update.
|
||||
*
|
||||
* @c appcastItem.informationOnlyUpdate indicates if the update is only informational and should not be downloaded. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case.
|
||||
*
|
||||
* @c appcastItem.majorUpgrade indicates if the update is a major or paid upgrade.
|
||||
*
|
||||
* @c appcastItem.criticalUpdate indicates if the update is a critical update.
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUUserUpdateChoiceInstall begins or resumes downloading or installing the update.
|
||||
* If the state.stage is SPUUserUpdateStateInstalling, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch"). Do not use this reply if appcastItem.informationOnlyUpdate is YES.
|
||||
* A reply of `SPUUserUpdateChoiceInstall` begins or resumes downloading or installing the update.
|
||||
* If the state.stage is `SPUUserUpdateStateInstalling`, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch"). Do not use this reply if @c appcastItem.informationOnlyUpdate is YES.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceDismiss dismisses the update for the time being. The user may be reminded of the update at a later point.
|
||||
* If the state.stage is SPUUserUpdateStateDownloaded, the downloaded update is kept after dismissing until the next time an update is shown to the user.
|
||||
* If the state.stage is SPUUserUpdateStateInstalling, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated.
|
||||
* A reply of `SPUUserUpdateChoiceDismiss` dismisses the update for the time being. The user may be reminded of the update at a later point.
|
||||
* If the state.stage is `SPUUserUpdateStateDownloaded`, the downloaded update is kept after dismissing until the next time an update is shown to the user.
|
||||
* If the state.stage is `SPUUserUpdateStateInstalling`, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceSkip skips this particular version and won't notify the user again, unless they initiate an update check themselves.
|
||||
* If appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped.
|
||||
* If the state.stage is SPUUpdateStateInstalling, the installation is also canceled when the update is skipped.
|
||||
* A reply of `SPUUserUpdateChoiceSkip` skips this particular version and won't notify the user again, unless they initiate an update check themselves.
|
||||
* If @c appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped.
|
||||
* If the state.stage is `SPUUpdateStateInstalling`, the installation is also canceled when the update is skipped.
|
||||
*/
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user the release notes for the new update
|
||||
*
|
||||
* Display the release notes to the user. This will be called after showing the new update.
|
||||
@@ -98,7 +101,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the new update's release notes could not be downloaded
|
||||
*
|
||||
* This will be called after showing the new update.
|
||||
@@ -109,26 +112,28 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)error;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user a new update was not found
|
||||
*
|
||||
* Let the user know a new update was not found after they tried initiating an update check.
|
||||
* Before this point, -showUserInitiatedUpdateCheckWithCancellation: may be called.
|
||||
* Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called.
|
||||
*
|
||||
* @param error The error associated with why a new update was not found.
|
||||
* There are various reasons a new update is unavailable and can't be installed.
|
||||
* This error object is populated with recovery and suggestion strings suitable to be shown in an alert.
|
||||
*
|
||||
* The userInfo dictionary is also populated with two keys:
|
||||
* SPULatestAppcastItemFoundKey: if available, this may provide the latest SUAppcastItem that was found.
|
||||
* SPUNoUpdateFoundReasonKey: if available, this will provide the SUNoUpdateFoundReason. For example the reason could be because
|
||||
*
|
||||
* `SPULatestAppcastItemFoundKey`: if available, this may provide the latest SUAppcastItem that was found.
|
||||
*
|
||||
* `SPUNoUpdateFoundReasonKey`: if available, this will provide the `SUNoUpdateFoundReason`. For example the reason could be because
|
||||
* the latest version in the feed requires a newer OS version or could be because the user is already on the latest version.
|
||||
*
|
||||
* @param acknowledgement Acknowledge to the updater that no update found error was shown.
|
||||
*/
|
||||
- (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user an update error occurred
|
||||
*
|
||||
* Let the user know that the updater failed with an error. This will not be invoked without the user having been
|
||||
@@ -136,21 +141,21 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*
|
||||
* Before this point, any of the non-error user driver methods may have been invoked.
|
||||
*
|
||||
* @param error The error associated with what update error occurred..
|
||||
* @param error The error associated with what update error occurred.
|
||||
* @param acknowledgement Acknowledge to the updater that the error was shown.
|
||||
*/
|
||||
- (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that downloading the new update initiated
|
||||
*
|
||||
* Let the user know that downloading the new update started.
|
||||
*
|
||||
* @param cancellation Invoke this cancellation block to cancel the download at any point before -showDownloadDidStartExtractingUpdate is invoked.
|
||||
* @param cancellation Invoke this cancellation block to cancel the download at any point before `-showDownloadDidStartExtractingUpdate` is invoked.
|
||||
*/
|
||||
- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user the content length of the new update that will be downloaded
|
||||
*
|
||||
* @param expectedContentLength The expected content length of the new update being downloaded.
|
||||
@@ -159,7 +164,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update download received more data
|
||||
*
|
||||
* This may be an appropriate time to advance a visible progress indicator of the download
|
||||
@@ -167,7 +172,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showDownloadDidReceiveDataOfLength:(uint64_t)length;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update finished downloading and started extracting
|
||||
*
|
||||
* Sparkle uses this to show an indeterminate progress bar.
|
||||
@@ -177,44 +182,44 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showDownloadDidStartExtractingUpdate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update is extracting with progress
|
||||
*
|
||||
* Let the user know how far along the update extraction is.
|
||||
*
|
||||
* Before this point, -showDownloadDidStartExtractingUpdate is called.
|
||||
* Before this point, `-showDownloadDidStartExtractingUpdate` is called.
|
||||
*
|
||||
* @param progress The progress of the extraction from a 0.0 to 1.0 scale
|
||||
*/
|
||||
- (void)showExtractionReceivedProgress:(double)progress;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update is installing
|
||||
*
|
||||
* Let the user know that the update is currently installing. Sparkle uses this to show an indeterminate progress bar.
|
||||
*
|
||||
* Before this point, -showExtractionReceivedProgress: may be called.
|
||||
* Before this point, `-showExtractionReceivedProgress:` may be called.
|
||||
*/
|
||||
- (void)showInstallingUpdate;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update is ready to install & relaunch
|
||||
*
|
||||
* Let the user know that the update is ready to install and relaunch, and ask them whether they want to proceed.
|
||||
* Note if the target application has already terminated, this method may not be invoked.
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUUserUpdateChoiceInstall installs the update the new update immediately. The application is relaunched only if it is still running by the time this reply is invoked. If the application terminates on its own, Sparkle will attempt to automatically install the update.
|
||||
* A reply of `SPUUserUpdateChoiceInstall` installs the update the new update immediately. The application is relaunched only if it is still running by the time this reply is invoked. If the application terminates on its own, Sparkle will attempt to automatically install the update.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceDismiss dismisses the update installation for the time being. Note the update may still be installed automatically after the application terminates.
|
||||
* A reply of `SPUUserUpdateChoiceDismiss` dismisses the update installation for the time being. Note the update may still be installed automatically after the application terminates.
|
||||
*
|
||||
* A reply of SPUUserUpdateChoiceSkip cancels the current update that has begun installing and dismisses the update. In this circumstance, the update is canceled but this update version is not skipped in the future.
|
||||
* A reply of `SPUUserUpdateChoiceSkip` cancels the current update that has begun installing and dismisses the update. In this circumstance, the update is canceled but this update version is not skipped in the future.
|
||||
*
|
||||
* Before this point, -showInstallingUpdate will be called.
|
||||
* Before this point, `-showInstallingUpdate` will be called.
|
||||
*/
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))reply;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show or dismiss progress while a termination signal is being sent to the application from Sparkle's installer
|
||||
*
|
||||
* Terminating and relaunching the application (if requested to be relaunched) may happen quickly,
|
||||
@@ -227,7 +232,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showSendingTerminationSignal;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user that the update installation finished
|
||||
*
|
||||
* Let the user know that the update finished installing.
|
||||
@@ -236,14 +241,14 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
* the updater's lifetime is tied to the application it is updating. This implementation must not try to reference
|
||||
* the old bundle prior to the installation, which will no longer be around.
|
||||
*
|
||||
* Before this point, -showSendingTerminationSignal or -showReadyToInstallAndRelaunch: may be called.
|
||||
* Before this point, `-showSendingTerminationSignal` or `-showReadyToInstallAndRelaunch:` may be called.
|
||||
*
|
||||
* @param relaunched Indicates if the update was relaunched.
|
||||
* @param acknowledgement Acknowledge to the updater that the finished installation was shown.
|
||||
*/
|
||||
- (void)showUpdateInstalledAndRelaunched:(BOOL)relaunched acknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show the user the current presented update or its progress in utmost focus
|
||||
*
|
||||
* The user wishes to check for updates while the user is being shown update progress.
|
||||
@@ -251,7 +256,7 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*/
|
||||
- (void)showUpdateInFocus;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Dismiss the current update installation
|
||||
*
|
||||
* Stop and tear down everything.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUUserInitiatedUpdateDriver : NSObject <SPUUpdateDriver>
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+22
-27
@@ -31,50 +31,45 @@
|
||||
@synthesize showingUpdate = _showingUpdate;
|
||||
@synthesize aborted = _aborted;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_uiDriver = [[SPUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater userDriver:userDriver userInitiated:YES updaterDelegate:updaterDelegate delegate:self];
|
||||
_uiDriver = [[SPUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle updater:updater userDriver:userDriver userInitiated:YES updaterDelegate:updaterDelegate delegate:self];
|
||||
_userDriver = userDriver;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders preventingInstallerInteraction:(BOOL)preventsInstallerInteraction completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)setCompletionHandler:(SPUUpdateDriverCompletion)completionBlock
|
||||
{
|
||||
[self.uiDriver prepareCheckForUpdatesWithCompletion:completionBlock];
|
||||
[self.uiDriver setCompletionHandler:completionBlock];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders
|
||||
{
|
||||
self.showingUserInitiatedProgress = YES;
|
||||
self.showingUpdate = YES;
|
||||
|
||||
[self.uiDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:^(NSError * _Nullable error) {
|
||||
if (!self.aborted) {
|
||||
if (error != nil) {
|
||||
[self abortUpdateWithError:error];
|
||||
} else {
|
||||
self.showingUserInitiatedProgress = YES;
|
||||
self.showingUpdate = YES;
|
||||
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCancellation:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.showingUserInitiatedProgress) {
|
||||
[self abortUpdate];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO];
|
||||
[self.userDriver showUserInitiatedUpdateCheckWithCancellation:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.showingUserInitiatedProgress) {
|
||||
[self abortUpdate];
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
[self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO];
|
||||
}
|
||||
|
||||
- (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeInstallingUpdate
|
||||
{
|
||||
[self.uiDriver resumeInstallingUpdateWithCompletion:completionBlock];
|
||||
[self.uiDriver resumeInstallingUpdate];
|
||||
}
|
||||
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock
|
||||
- (void)resumeUpdate:(id<SPUResumableUpdate>)resumableUpdate
|
||||
{
|
||||
[self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
[self.uiDriver resumeUpdate:resumableUpdate];
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error
|
||||
@@ -122,7 +117,7 @@
|
||||
self.showingUserInitiatedProgress = NO;
|
||||
}
|
||||
self.aborted = YES;
|
||||
[self.uiDriver abortUpdateWithError:error];
|
||||
[self.uiDriver abortUpdateWithError:error showErrorToUser:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+36
@@ -22,23 +22,59 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
A choice made by the user when prompted with a new update.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) {
|
||||
/**
|
||||
Dismisses the update and skips being notified of it in the future.
|
||||
*/
|
||||
SPUUserUpdateChoiceSkip,
|
||||
/**
|
||||
Downloads (if needed) and installs the update.
|
||||
*/
|
||||
SPUUserUpdateChoiceInstall,
|
||||
/**
|
||||
Dismisses the update until Sparkle reminds the user of it at a later time.
|
||||
*/
|
||||
SPUUserUpdateChoiceDismiss,
|
||||
};
|
||||
|
||||
/**
|
||||
Describes the current stage an update is undergoing.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, SPUUserUpdateStage) {
|
||||
/**
|
||||
The update has not been downloaded.
|
||||
*/
|
||||
SPUUserUpdateStageNotDownloaded,
|
||||
/**
|
||||
The update has already been downloaded but not begun installing.
|
||||
*/
|
||||
SPUUserUpdateStageDownloaded,
|
||||
/**
|
||||
The update has already been downloaded and began installing in the background.
|
||||
*/
|
||||
SPUUserUpdateStageInstalling
|
||||
};
|
||||
|
||||
/**
|
||||
This represents the user's current update state.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUserUpdateState : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
The current update stage.
|
||||
|
||||
This stage indicates if data has been already downloaded or not, or if an update is currently being installed.
|
||||
*/
|
||||
@property (nonatomic, readonly) SPUUserUpdateStage stage;
|
||||
|
||||
/**
|
||||
Indicates whether or not the update check was initiated by the user.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL userInitiated;
|
||||
|
||||
@end
|
||||
|
||||
Vendored
+25
-12
@@ -25,22 +25,35 @@ BOOL SPUXPCValidateServiceIfBundleExists(NSString *bundleName, NSBundle *sparkle
|
||||
if (xpcBundle == nil) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Sometimes in debug the short version where we append a git hash is not available,
|
||||
// so if our CFBundleVersion == CFBundleShortVersionString, we will compare to CURRENT_PROJECT_VERSION,
|
||||
// Otherwise if git hash is correctly appended, we will compare to short version string of Sparkle framework
|
||||
NSString *bundleVersion = [xpcBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *version = [xpcBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
|
||||
NSString *projectVersion = [bundleVersion isEqualToString:version] ? @""CURRENT_PROJECT_VERSION : [sparkleBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
|
||||
if (version == nil || projectVersion == nil || ![version isEqualToString:projectVersion]) {
|
||||
|
||||
#if DEBUG
|
||||
// Post install scripts for appending git hash info to CFBundleShortVersionString are too unreliable to verify for debug/development
|
||||
// Fortunately debug builds of Sparkle are not usable in a production environment
|
||||
(void)sparkleBundle; // Mark parameter as used
|
||||
#else
|
||||
// Make sure the display versions of Sparkle and the XPC bundle match
|
||||
// These versions may contain a git hash identifier if built from the Sparkle repository
|
||||
NSString *sparkleDisplayVersion = [sparkleBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
NSString *xpcDisplayVersion = [xpcBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
|
||||
if (sparkleDisplayVersion == nil || xpcDisplayVersion == nil || ![sparkleDisplayVersion isEqualToString:xpcDisplayVersion]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Version mismatch. Framework display version is %@ but XPC Service (%@) display version is %@. Bundled XPC Service cannot be used.", projectVersion, xpcBundle.bundlePath, version] }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Version mismatch. Framework display version is %@ but XPC Service (%@) display version is %@. Bundled XPC Service cannot be used.", sparkleDisplayVersion, xpcBundle.bundlePath, xpcDisplayVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Make sure the bundle versions of Sparkle and the XPC bundle match
|
||||
NSString *xpcBundleVersion = [xpcBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
|
||||
if (xpcBundleVersion == nil || ![xpcBundleVersion isEqualToString:@""CURRENT_PROJECT_VERSION]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Version mismatch. Framework bundle version is %@ but XPC Service (%@) bundle version is %@. Bundled XPC Service cannot be used.", @""CURRENT_PROJECT_VERSION, xpcBundle.bundlePath, xpcBundleVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+11
@@ -22,8 +22,19 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
|
||||
/**
|
||||
The appcast representing a collection of `SUAppcastItem` items in the feed.
|
||||
*/
|
||||
SU_EXPORT @interface SUAppcast : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
The collection of update items.
|
||||
|
||||
These `SUAppcastItem` items are in the same order as specified in the appcast XML feed and are thus not sorted by version.
|
||||
*/
|
||||
@property (readonly, copy) NSArray<SUAppcastItem *> *items;
|
||||
|
||||
@end
|
||||
|
||||
Vendored
+6
-1
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUAppcastItem (Private) <NSSecureCoding>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Initializes with data from a dictionary provided by the RSS class and state resolver
|
||||
|
||||
This initializer method is intended to be marked "private" and discouraged from public usage.
|
||||
@@ -33,6 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL stateResolver:(SPUAppcastItemStateResolver *)stateResolver failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;
|
||||
|
||||
/**
|
||||
The DSA and EdDSA signatures along with their statuses.
|
||||
*/
|
||||
@property (readonly, nullable) SUSignatures *signatures;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Vendored
+293
-25
@@ -33,41 +33,309 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly, nullable) NSString *title;
|
||||
@property (copy, readonly, nullable) NSString *dateString;
|
||||
@property (copy, readonly, nullable) NSDate *date;
|
||||
@property (copy, readonly, nullable) NSString *itemDescription;
|
||||
@property (strong, readonly, nullable) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly, nullable) SUSignatures *signatures;
|
||||
@property (copy, readonly, nullable) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly, nullable) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly, nullable) NSURL *fileURL;
|
||||
@property (nonatomic, readonly) uint64_t contentLength;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly, nullable) NSString *osString;
|
||||
@property (copy, readonly, nullable) NSString *displayVersionString;
|
||||
@property (copy, readonly, nullable) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly, nullable) NSURL *infoURL;
|
||||
@property (copy, readonly, nullable) NSNumber* phasedRolloutInterval;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (copy, readonly, nullable) NSString *minimumAutoupdateVersion;
|
||||
@property (nonatomic, readonly, nullable) NSString *channel;
|
||||
/**
|
||||
The appcast item describing an update in the application's appcast feed.
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isMajorUpgrade, readonly) BOOL majorUpgrade;
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
An appcast item represents a single update item in the `SUAppcast` contained within the @c <item> element.
|
||||
|
||||
Every appcast item must have a `versionString`, and either a `fileURL` or an `infoURL`.
|
||||
All the remaining properties describing an update to the application are optional.
|
||||
|
||||
Extended documentation and examples on using appcast item features are available at:
|
||||
https://sparkle-project.org/documentation/publishing/
|
||||
*/
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
|
||||
/**
|
||||
The version of the update item.
|
||||
|
||||
Sparkle uses this property to compare update items and determine the best available update item in the `SUAppcast`.
|
||||
|
||||
This corresponds to the application update's @c CFBundleVersion
|
||||
|
||||
This is extracted from the @c <sparkle:version> element, or the @c sparkle:version attribute from the @c <enclosure> element.
|
||||
*/
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
|
||||
/**
|
||||
The human-readable display version of the update item if provided.
|
||||
|
||||
This is the version string shown to the user when they are notified of a new update.
|
||||
|
||||
This corresponds to the application update's @c CFBundleShortVersionString
|
||||
|
||||
This is extracted from the @c <sparkle:shortVersionString> element, or the @c sparkle:shortVersionString attribute from the @c <enclosure> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *displayVersionString;
|
||||
|
||||
/**
|
||||
The file URL to the update item if provided.
|
||||
|
||||
This download contains the actual update Sparkle will attempt to install.
|
||||
In cases where a download cannot be provided, an `infoURL` must be provided instead.
|
||||
|
||||
A file URL should have an accompanying `contentLength` provided.
|
||||
|
||||
This is extracted from the @c url attribute in the @c <enclosure> element.
|
||||
*/
|
||||
@property (readonly, nullable) NSURL *fileURL;
|
||||
|
||||
/**
|
||||
The content length of the download in bytes.
|
||||
|
||||
This property is used as a fallback when the server doesn't report the content length of the download.
|
||||
In that case, it is used to report progress of the downloading update to the user.
|
||||
|
||||
A warning is outputted if this property is not equal the server's expected content length (if provided).
|
||||
|
||||
This is extracted from the @c length attribute in the @c <enclosure> element.
|
||||
It should be specified if a `fileURL` is provided.
|
||||
*/
|
||||
@property (nonatomic, readonly) uint64_t contentLength;
|
||||
|
||||
/**
|
||||
The info URL to the update item if provided.
|
||||
|
||||
This informational link is used to direct the user to learn more about an update they cannot download/install directly from within the application.
|
||||
The link should point to the product's web page.
|
||||
|
||||
The informational link will be used if `informationOnlyUpdate` is @c YES
|
||||
|
||||
This is extracted from the @c <link> element.
|
||||
*/
|
||||
@property (readonly, nullable) NSURL *infoURL;
|
||||
|
||||
/**
|
||||
Indicates whether or not the update item is only informational and has no download.
|
||||
|
||||
If `infoURL` is not present, this is @c NO
|
||||
|
||||
If `fileURL` is not present, this is @c YES
|
||||
|
||||
Otherwise this is determined based on the contents extracted from the @c <sparkle:informationalUpdate> element.
|
||||
*/
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
/**
|
||||
The title of the appcast item if provided.
|
||||
|
||||
This is extracted from the @c <title> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *title;
|
||||
|
||||
/**
|
||||
The date string of the appcast item if provided.
|
||||
|
||||
The `date` property is constructed from this property and expects this string to comply with the following date format:
|
||||
`E, dd MMM yyyy HH:mm:ss Z`
|
||||
|
||||
This is extracted from the @c <pubDate> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *dateString;
|
||||
|
||||
/**
|
||||
The date constructed from the `dateString` property if provided.
|
||||
|
||||
Sparkle by itself only uses this property for phased group rollouts specified via `phasedRolloutInterval`, but clients may query this property too.
|
||||
|
||||
This date is constructed using the @c en_US locale.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSDate *date;
|
||||
|
||||
/**
|
||||
The release notes URL of the appcast item if provided.
|
||||
|
||||
This external link points to an HTML file that Sparkle downloads and renders to show the user a new or old update item's changelog.
|
||||
|
||||
An alternative to using an external release notes link is providing an embedded `itemDescription`.
|
||||
|
||||
This is extracted from the @c <sparkle:releaseNotesLink> element.
|
||||
*/
|
||||
@property (readonly, nullable) NSURL *releaseNotesURL;
|
||||
|
||||
/**
|
||||
The description of the appcast item if provided.
|
||||
|
||||
A description may be provided for inline/embedded release notes for new updates using @c <![CDATA[...]]>
|
||||
This is an alternative to providing a `releaseNotesURL`.
|
||||
|
||||
This is extracted from the @c <description> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *itemDescription;
|
||||
|
||||
/**
|
||||
The required minimum system operating version string for this update if provided.
|
||||
|
||||
This version string should contain three period-separated components.
|
||||
|
||||
Example: @c 10.12.0
|
||||
|
||||
Use `minimumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
|
||||
|
||||
This is extracted from the @c <sparkle:minimumSystemVersion> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *minimumSystemVersion;
|
||||
|
||||
/**
|
||||
Indicates whether or not the current running system passes the `minimumSystemVersion` requirement.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL minimumOperatingSystemVersionIsOK;
|
||||
|
||||
/**
|
||||
The required maximum system operating version string for this update if provided.
|
||||
|
||||
A maximum system operating version requirement should only be made in unusual scenarios.
|
||||
|
||||
This version string should contain three period-separated components.
|
||||
|
||||
Example: @c 10.13.0
|
||||
|
||||
Use `maximumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
|
||||
|
||||
This is extracted from the @c <sparkle:maximumSystemVersion> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *maximumSystemVersion;
|
||||
|
||||
/**
|
||||
Indicates whether or not the current running system passes the `maximumSystemVersion` requirement.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL maximumOperatingSystemVersionIsOK;
|
||||
|
||||
// Returns the dictionary representing the appcast item; this might be useful later for extensions.
|
||||
/**
|
||||
The channel the update item is on if provided.
|
||||
|
||||
An update item may specify a custom channel name (such as @c beta) that can only be found by updaters that filter for that channel.
|
||||
If no channel is provided, the update item is assumed to be on the default channel.
|
||||
|
||||
This is extracted from the @c <sparkle:channel> element.
|
||||
Old applications must be using Sparkle 2 or later to interpret the channel element and to ignore unmatched channels.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) NSString *channel;
|
||||
|
||||
/**
|
||||
The installation type of the update at `fileURL`
|
||||
|
||||
This may be:
|
||||
- @c application - indicates this is a regular application update.
|
||||
- @c package - indicates this is a guided package installer update.
|
||||
- @c interactive-package - indicates this is an interactive package installer update (deprecated; use "package" instead)
|
||||
|
||||
This is extracted from the @c sparkle:installationType attribute in the @c <enclosure> element.
|
||||
|
||||
If no installation type is provided in the enclosure, the installation type is inferred from the `fileURL` file extension instead.
|
||||
|
||||
If the file extension is @c pkg or @c mpkg, the installation type is @c package otherwise it is @c application
|
||||
|
||||
Hence, the installation type in the enclosure element only needs to be specified for package based updates distributed inside of a @c zip or other archive format.
|
||||
|
||||
Old applications must be using Sparkle 1.26 or later to support downloading bare package updates (`pkg` or `mpkg`) that are not additionally archived inside of a @c zip or other archive format.
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
|
||||
/**
|
||||
The phased rollout interval of the update item in seconds if provided.
|
||||
|
||||
This is the interval between when different groups of users are notified of a new update.
|
||||
|
||||
For this property to be used by Sparkle, the published `date` on the update item must be present as well.
|
||||
|
||||
After each interval after the update item's `date`, a new group of users become eligible for being notified of the new update.
|
||||
|
||||
This is extracted from the @c <sparkle:phasedRolloutInterval> element.
|
||||
|
||||
Old applications must be using Sparkle 1.25 or later to support phased rollout intervals, otherwise they may assume updates are immediately available.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSNumber* phasedRolloutInterval;
|
||||
|
||||
/**
|
||||
The minimum bundle version string this update requires for automatically downloading and installing updates if provided.
|
||||
|
||||
If an application's bundle version meets this version requirement, it can install the new update item in the background automatically.
|
||||
|
||||
Otherwise if the requirement is not met, the user is always prompted to install the update. In this case, the update is assumed to be a `majorUpgrade`.
|
||||
|
||||
If the update is a `majorUpgrade` and the update is skipped by the user, other future update alerts with the same `minimumAutoupdateVersion` will also be skipped.
|
||||
|
||||
This version string corresponds to the application's @c CFBundleVersion
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *minimumAutoupdateVersion;
|
||||
|
||||
/**
|
||||
Indicates whether or not the update item is a major upgrade.
|
||||
|
||||
An update is a major upgrade if the application's bundle version doesn't meet the `minimumAutoupdateVersion` requirement.
|
||||
*/
|
||||
@property (getter=isMajorUpgrade, readonly) BOOL majorUpgrade;
|
||||
|
||||
/**
|
||||
Indicates whether or not the update item is critical.
|
||||
|
||||
Critical updates are shown to the user more promptly. Sparkle's standard user interface also does not allow them to be skipped.
|
||||
|
||||
This is determined and extracted from a top-level @c <sparkle:criticalUpdate> element or a @c sparkle:criticalUpdate element inside of a @c sparkle:tags element.
|
||||
|
||||
Old applications must be using Sparkle 2 or later to support the top-level @c <sparkle:criticalUpdate> element.
|
||||
*/
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
|
||||
/**
|
||||
Specifies the operating system the download update is available for if provided.
|
||||
|
||||
If this property is not provided, then the supported operating system is assumed to be macOS.
|
||||
|
||||
Known potential values for this string are @c macos and @c windows
|
||||
|
||||
Sparkle on Mac ignores update items that are for other operating systems.
|
||||
This is only useful for sharing appcasts between Sparkle on Mac and Sparkle on other operating systems.
|
||||
|
||||
Use `macOsUpdate` property to test if this update item is for macOS.
|
||||
|
||||
This is extracted from the @c sparkle:os attribute in the @c <enclosure> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSString *osString;
|
||||
|
||||
/**
|
||||
Indicates whether or not this update item is for macOS.
|
||||
|
||||
This is determined from the `osString` property.
|
||||
*/
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
|
||||
/**
|
||||
The delta updates for this update item.
|
||||
|
||||
Sparkle uses these to download and apply a smaller update based on the version the user is updating from.
|
||||
|
||||
The key is based on the @c sparkle:version of the update.
|
||||
The value is an update item that will have `deltaUpdate` be @c YES
|
||||
|
||||
Clients typically should not need to examine the contents of the delta updates.
|
||||
|
||||
This is extracted from the @c <sparkle:deltas> element.
|
||||
*/
|
||||
@property (copy, readonly, nullable) NSDictionary<NSString *, SUAppcastItem *> *deltaUpdates;
|
||||
|
||||
/**
|
||||
Indicates whether or not the update item is a delta update.
|
||||
|
||||
An update item is a delta update if it is in the `deltaUpdates` of another update item.
|
||||
*/
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
|
||||
/**
|
||||
The dictionary representing the entire appcast item.
|
||||
|
||||
This is useful for querying custom extensions or elements from the appcast item.
|
||||
*/
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
An empty appcast item.
|
||||
|
||||
This may be used as a potential return value in `-[SPUUpdaterDelegate bestValidUpdateInAppcast:forUpdater:]`
|
||||
*/
|
||||
+ (instancetype)emptyAppcastItem;
|
||||
|
||||
// Deprecated initializers
|
||||
|
||||
Vendored
+5
-3
@@ -37,6 +37,8 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState";
|
||||
|
||||
@interface SUAppcastItem ()
|
||||
|
||||
@property (readonly, nullable) SUSignatures *signatures;
|
||||
|
||||
// Auxillary appcast item state that needs to be evaluated based on the host state
|
||||
// This may be nil if the client creates an SUAppcastItem with a deprecated initializer
|
||||
// In that case we will need to fallback to safe behavior
|
||||
@@ -386,14 +388,14 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState";
|
||||
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
if (!enclosure && !theInfoURL) {
|
||||
if (!enclosure && !_infoURL) {
|
||||
if (error) {
|
||||
*error = @"No enclosure in feed item";
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (theInfoURL != nil) {
|
||||
if (_infoURL != nil) {
|
||||
// If enclosure doesn't exist, the update must be an informational update
|
||||
// Otherwise check presence of informational update element
|
||||
_informationalUpdateVersions = (enclosure != nil) ? [dict objectForKey:SUAppcastElementInformationalUpdate] : [NSSet set];
|
||||
@@ -403,7 +405,7 @@ static NSString *SUAppcastItemStateKey = @"SUAppcastItemState";
|
||||
}
|
||||
|
||||
NSString *enclosureURLString = [enclosure objectForKey:SURSSAttributeURL];
|
||||
if (!enclosureURLString && !theInfoURL) {
|
||||
if (!enclosureURLString && !_infoURL) {
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
}
|
||||
|
||||
Vendored
+19
-1
@@ -71,18 +71,36 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCanceledError = 4007,
|
||||
SUInstallationAuthorizeLaterError = 4008,
|
||||
SUNotAllowedInteractionError = 4009,
|
||||
SUNotValidUpdateError = 4009,
|
||||
SUAgentInvalidationError = 4010,
|
||||
|
||||
// API misuse errors.
|
||||
SUIncorrectAPIUsageError = 5000
|
||||
};
|
||||
|
||||
/**
|
||||
The reason why a new update is not available.
|
||||
*/
|
||||
typedef NS_ENUM(OSStatus, SPUNoUpdateFoundReason) {
|
||||
/**
|
||||
A new update is unavailable for an unknown reason.
|
||||
*/
|
||||
SPUNoUpdateFoundReasonUnknown,
|
||||
/**
|
||||
A new update is unavailable because the user is on the latest known version in the appcast feed.
|
||||
*/
|
||||
SPUNoUpdateFoundReasonOnLatestVersion,
|
||||
/**
|
||||
A new update is unavailable because the user is on a version newer than the latest known version in the appcast feed.
|
||||
*/
|
||||
SPUNoUpdateFoundReasonOnNewerThanLatestVersion,
|
||||
/**
|
||||
A new update is unavailable because the user's operating system version is too old for the update.
|
||||
*/
|
||||
SPUNoUpdateFoundReasonSystemIsTooOld,
|
||||
/**
|
||||
A new update is unavailable because the user's operating system version is too new for the update.
|
||||
*/
|
||||
SPUNoUpdateFoundReasonSystemIsTooNew
|
||||
};
|
||||
|
||||
|
||||
+16
-11
@@ -32,7 +32,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
/**
|
||||
Sparkle's default version comparator.
|
||||
|
||||
This comparator is adapted from MacPAD, by Kevin Ballard.
|
||||
@@ -41,24 +41,29 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Initializes a new instance of the standard version comparator.
|
||||
*/
|
||||
- (instancetype)init;
|
||||
|
||||
/*!
|
||||
Returns a singleton instance of the comparator.
|
||||
|
||||
It is usually preferred to alloc/init new a comparator instead.
|
||||
/**
|
||||
A singleton instance of the comparator.
|
||||
*/
|
||||
+ (SUStandardVersionComparator *)defaultComparator;
|
||||
@property (nonatomic, class, readonly) SUStandardVersionComparator *defaultComparator;
|
||||
|
||||
/*!
|
||||
Compares version strings through textual analysis.
|
||||
|
||||
See the implementation for more details.
|
||||
/**
|
||||
Compares two version strings through textual analysis.
|
||||
|
||||
These version strings should be in the format of x, x.y, or x.y.z where each component is a number.
|
||||
For example, valid version strings include "1.5.3", "500", or "4000.1"
|
||||
These versions that are compared correspond to the @c CFBundleVersion values of the updates.
|
||||
|
||||
@param versionA The first version string to compare.
|
||||
@param versionB The second version string to compare.
|
||||
@return A comparison result between @c versionA and @c versionB
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Vendored
+4
-4
@@ -16,12 +16,12 @@
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
/**
|
||||
This class represents a response for permission to check updates.
|
||||
*/
|
||||
SU_EXPORT @interface SUUpdatePermissionResponse : NSObject<NSSecureCoding>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Initializes a new update permission response instance.
|
||||
|
||||
@param automaticUpdateChecks Flag for whether to allow automatic update checks.
|
||||
@@ -34,12 +34,12 @@ SU_EXPORT @interface SUUpdatePermissionResponse : NSObject<NSSecureCoding>
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A read-only property indicating whether automatic update checks are allowed or not.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL automaticUpdateChecks;
|
||||
|
||||
/*!
|
||||
/**
|
||||
A read-only property indicating if system profile should be sent or not.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL sendSystemProfile;
|
||||
|
||||
Vendored
+32
-14
@@ -55,12 +55,13 @@
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to validate update before unarchiving because no (Ed)DSA public key was found in the old app" }];
|
||||
}
|
||||
} else {
|
||||
if ([SUSignatureVerifier validatePath:self.downloadPath withSignatures:signatures withPublicKeys:publicKeys]) {
|
||||
NSError *innerError = nil;
|
||||
if ([SUSignatureVerifier validatePath:self.downloadPath withSignatures:signatures withPublicKeys:publicKeys error:&innerError]) {
|
||||
self.prevalidatedSignature = YES;
|
||||
return YES;
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"(Ed)DSA signature validation before unarchiving failed for update %@", self.downloadPath] }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"(Ed)DSA signature validation before unarchiving failed for update %@", self.downloadPath], NSUnderlyingErrorKey: innerError }];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
@@ -90,23 +91,24 @@
|
||||
// Check to see if we have a package or bundle to validate
|
||||
if (isPackage) {
|
||||
// If we get here, then the appcast installation type was lying to us.. This error will be caught later when starting the installer.
|
||||
// For package type updates, all we do is check if the DSA signature is valid
|
||||
BOOL validationCheckSuccess = [SUSignatureVerifier validatePath:downloadPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
// For package type updates, all we do is check if the EdDSA signature is valid
|
||||
NSError *innerError = nil;
|
||||
BOOL validationCheckSuccess = [SUSignatureVerifier validatePath:downloadPath withSignatures:signatures withPublicKeys:publicKeys error:&innerError];
|
||||
if (!validationCheckSuccess) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead." }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"EdDSA signature validation of the package failed. The update contains an installer package, and valid EdDSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid EdDSA key or use an .app bundle update instead.", NSUnderlyingErrorKey: innerError }];
|
||||
}
|
||||
}
|
||||
return validationCheckSuccess;
|
||||
} else {
|
||||
// For application bundle updates, we check both the DSA and Apple code signing signatures
|
||||
// For application bundle updates, we check both the EdDSA and Apple code signing signatures
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL signatures:signatures error:error];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
// We already prevalidated the package and nothing else needs to be done
|
||||
return YES;
|
||||
} else {
|
||||
// Because we already validated the DSA signature, this is just a consistency check to see
|
||||
// Because we already validated the EdDSA signature, this is just a consistency check to see
|
||||
// if the developer signed their application properly with their Apple ID
|
||||
// Currently, this case only gets hit for binary delta updates
|
||||
NSError *innerError = nil;
|
||||
@@ -166,23 +168,25 @@
|
||||
BOOL passedDSACheck = NO;
|
||||
BOOL passedCodeSigning = NO;
|
||||
|
||||
NSError *dsaError = nil;
|
||||
if (oldHasAnyDSAKey) {
|
||||
// it's critical to check against the old public key, rather than the new key
|
||||
passedDSACheck = [SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
passedDSACheck = [SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:publicKeys error:&dsaError];
|
||||
}
|
||||
|
||||
NSError *codeSignedError = nil;
|
||||
if (hostIsCodeSigned) {
|
||||
NSError *innerError = nil;
|
||||
passedCodeSigning = [SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&innerError];
|
||||
passedCodeSigning = [SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&codeSignedError];
|
||||
}
|
||||
// End of security-critical part
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
if (!passedDSACheck && newHasAnyDSAKey) {
|
||||
if (![SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:newPublicKeys]) {
|
||||
NSError *innerError = nil;
|
||||
if (![SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:newPublicKeys error:&innerError]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"The update has a public (Ed)DSA key, but the public key shipped with the update doesn't match the signature. To prevent future problems, the update will be rejected." }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"The update has a public (Ed)DSA key, but the public key shipped with the update doesn't match the signature. To prevent future problems, the update will be rejected.", NSUnderlyingErrorKey: innerError }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@@ -219,11 +223,25 @@
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus] }];
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus];
|
||||
|
||||
if (dsaError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = dsaError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus] }];
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus];
|
||||
|
||||
if (codeSignedError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = codeSignedError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-5
@@ -26,13 +26,12 @@
|
||||
|
||||
@protocol SUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
/**
|
||||
The legacy API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
This class is now deprecated and acts as a thin wrapper around `SPUUpdater` and `SPUStandardUserDriver`.
|
||||
|
||||
Note: This class is now deprecated and acts as a thin wrapper around SPUUpdater and SPUStandardUserDriver
|
||||
If you are migrating to Sparkle 2, use `SPUStandardUpdaterController` instead, or `SPUUpdater` if you need more control.
|
||||
*/
|
||||
__deprecated_msg("Deprecated in Sparkle 2. Use SPUStandardUpdaterController instead, or SPUUpdater if you need more control.")
|
||||
SU_EXPORT @interface SUUpdater : NSObject
|
||||
|
||||
Vendored
+3
-2
@@ -109,7 +109,8 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
|
||||
- (NSBundle *)sparkleBundle
|
||||
{
|
||||
return self.updater.sparkleBundle;
|
||||
// Use explicit class to use the correct bundle even when subclassed
|
||||
return [NSBundle bundleForClass:[SUUpdater class]];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
@@ -255,7 +256,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
return versionDisplayer;
|
||||
}
|
||||
|
||||
- (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)__unused updater
|
||||
- (BOOL)updater:(SPUUpdater *)__unused updater mayPerformUpdateCheck:(SPUUpdateCheck)__unused updateCheck error:(NSError *__autoreleasing _Nullable *)error
|
||||
{
|
||||
BOOL updaterMayCheck = YES;
|
||||
if ([self.delegate respondsToSelector:@selector(updaterMayCheckForUpdates:)]) {
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
/**
|
||||
Provides version comparison facilities for Sparkle.
|
||||
*/
|
||||
@protocol SUVersionComparison
|
||||
|
||||
/*!
|
||||
/**
|
||||
An abstract method to compare two version strings.
|
||||
|
||||
Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a,
|
||||
|
||||
Vendored
+2
-2
@@ -16,12 +16,12 @@
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
/**
|
||||
Applies special display formatting to version numbers.
|
||||
*/
|
||||
SU_EXPORT @protocol SUVersionDisplay
|
||||
|
||||
/*!
|
||||
/**
|
||||
Formats two version strings.
|
||||
|
||||
Both versions are provided so that important distinguishing information
|
||||
|
||||
Vendored
+3
@@ -68,7 +68,10 @@ static WKUserScript *_userScriptWithInjectedStyleSource(NSString *styleSource)
|
||||
// that involves implementing a delegate method that is only available on macOS 11.. to get it properly working.
|
||||
// To simplify things, just rely on deprecated property for now.
|
||||
// Future reader: if you change how JS is disabled, please be sure to test that JS code is properly disabled in HTML release notes.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
configuration.preferences.javaScriptEnabled = javaScriptEnabled;
|
||||
#pragma clang diagnostic pop
|
||||
configuration.preferences.javaScriptCanOpenWindowsAutomatically = NO;
|
||||
|
||||
NSError *colorStyleContentsError = nil;
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
Vendored
+3
-3
@@ -2,11 +2,11 @@
|
||||
|
||||
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ wurde geladen und steht zur Installation bereit! Möchtest du %1$@ jetzt durch die neue Version ersetzen und neu starten?";
|
||||
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "%1$@ kann nicht aktualisiert werden, da es aus dem Downloads-Order, oder von einer DMG Datei oder Laufwerk ohne Schreibzugriff gestartet wurde.";
|
||||
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "%1$@ kann nicht aktualisiert werden, da es aus dem Downloads-Order, oder von einer DMG-Datei oder einem Laufwerk ohne Schreibzugriff gestartet wurde.";
|
||||
|
||||
"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "Kopiere %1$@ in den Programmeordner, starte es von dort aus und versuche es erneut zu aktualisieren.";
|
||||
|
||||
"Quit %1$@, move it into your Applications folder, relaunch it from there and try again." = "Beenden Sie „%1$@“, bewegen Sie es in den Ordner „Programme“, starten Sie das Programm von dort erneut und versuchen Sie es noch einmal.";
|
||||
"Quit %1$@, move it into your Applications folder, relaunch it from there and try again." = "Beende „%1$@“, bewege es in den Ordner „Programme“, starte das Programm von dort erneut und versuche es noch einmal.";
|
||||
|
||||
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "„%1$@“ kann nicht aktualisiert werden, wenn das Programm von dem Ort ausgeführt wird, an den es heruntergeladen wurde.";
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
"A new version of %@ is ready to install!" = "Eine neue Version von %@ steht zur Installation bereit!";
|
||||
|
||||
"An error occurred in retrieving update information. Please try again later." = "Beim Laden der Updateinformationen trat ein Fehler auf. Bitte versuche es später erneut.";
|
||||
"An error occurred in retrieving update information. Please try again later." = "Beim Laden der Updateinformationen ist ein Fehler aufgetreten. Bitte versuche es später erneut.";
|
||||
|
||||
"An error occurred while downloading the update. Please try again later." = "Beim Laden des Updates ist ein Fehler aufgetreten. Bitte versuche es später erneut.";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<item>
|
||||
<title>Version 2.0</title>
|
||||
<sparkle:version>2.0</sparkle:version>
|
||||
<link>https://sparkle-project.org</link>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<ul>
|
||||
|
||||
@@ -17,7 +17,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator.default()
|
||||
let versionComparator = SUStandardVersionComparator.default
|
||||
let hostVersion = "1.0"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
@@ -86,7 +86,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator.default()
|
||||
let versionComparator = SUStandardVersionComparator.default
|
||||
let hostVersion = "1.0"
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: hostVersion, applicationVersionComparator: versionComparator, standardVersionComparator: versionComparator)
|
||||
|
||||
@@ -144,7 +144,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator.default()
|
||||
let versionComparator = SUStandardVersionComparator.default
|
||||
|
||||
// If critical update version is 1.5 and host version is 1.0, update should be marked critical
|
||||
do {
|
||||
@@ -184,7 +184,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let testData = try Data(contentsOf: testURL)
|
||||
|
||||
let versionComparator = SUStandardVersionComparator.default()
|
||||
let versionComparator = SUStandardVersionComparator.default
|
||||
|
||||
// Test informational updates from version 1.0
|
||||
do {
|
||||
@@ -200,7 +200,7 @@ class SUAppcastTest: XCTestCase {
|
||||
|
||||
// Test delta updates inheriting informational only updates
|
||||
do {
|
||||
let deltaUpdate = appcast.items[2].deltaUpdates!["2.0"] as! SUAppcastItem
|
||||
let deltaUpdate = appcast.items[2].deltaUpdates!["2.0"]!
|
||||
XCTAssertTrue(deltaUpdate.isInformationOnlyUpdate)
|
||||
}
|
||||
}
|
||||
@@ -612,7 +612,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let testFileData = try Data(contentsOf: testFileUrl)
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default(), standardVersionComparator: SUStandardVersionComparator.default())
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default, standardVersionComparator: SUStandardVersionComparator.default)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testFileData, relativeTo: testFileUrl, stateResolver: stateResolver)
|
||||
let items = appcast.items
|
||||
@@ -628,7 +628,7 @@ class SUAppcastTest: XCTestCase {
|
||||
let testData = NSData(contentsOfFile: testFile)!
|
||||
|
||||
do {
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default(), standardVersionComparator: SUStandardVersionComparator.default())
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default, standardVersionComparator: SUStandardVersionComparator.default)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData as Data, relativeTo: nil, stateResolver: stateResolver)
|
||||
let items = appcast.items
|
||||
@@ -652,7 +652,7 @@ class SUAppcastTest: XCTestCase {
|
||||
do {
|
||||
let baseURL = URL(string: "https://fake.sparkle-project.org/updates/index.xml")!
|
||||
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default(), standardVersionComparator: SUStandardVersionComparator.default())
|
||||
let stateResolver = SPUAppcastItemStateResolver(hostVersion: "1.0", applicationVersionComparator: SUStandardVersionComparator.default, standardVersionComparator: SUStandardVersionComparator.default)
|
||||
|
||||
let appcast = try SUAppcast(xmlData: testData as Data, relativeTo: baseURL, stateResolver: stateResolver)
|
||||
let items = appcast.items
|
||||
|
||||
@@ -257,7 +257,7 @@ typedef void (^SUDeltaHandler)(NSFileManager *fileManager, NSString *sourceDirec
|
||||
XCTFail(@"Failed setting file permissions");
|
||||
}
|
||||
|
||||
XCTAssertFalse([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]);
|
||||
XCTAssertTrue([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -34,85 +34,100 @@
|
||||
|
||||
NSString *validSig = @"MCwCFCIHCIYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
|
||||
NSError *error = nil;
|
||||
|
||||
XCTAssertTrue([self checkFile:self.testFile
|
||||
withDSAKey:pubKey
|
||||
signature:validSig],
|
||||
@"Expected valid signature");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Expected valid signature: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withDSAKey:@"lol"
|
||||
signature:validSig],
|
||||
@"Invalid pubkey");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Invalid pubkey: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.pubDSAKeyFile
|
||||
withDSAKey:pubKey
|
||||
signature:validSig],
|
||||
@"Wrong file checked");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Wrong file checked: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withDSAKey:pubKey
|
||||
signature:@"MCwCFCIHCiYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ=="],
|
||||
@"Expected invalid signature");
|
||||
signature:@"MCwCFCIHCiYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ=="
|
||||
error:&error],
|
||||
@"Expected invalid signature: %@", error);
|
||||
|
||||
XCTAssertTrue([self checkFile:self.testFile
|
||||
withDSAKey:pubKey
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8c="],
|
||||
@"Expected valid signature");
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8c="
|
||||
error:&error],
|
||||
@"Expected valid signature: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withDSAKey:pubKey
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8"],
|
||||
@"Expected invalid signature");
|
||||
signature:@"MC0CFAsKO7cq2q7L5/FWe6ybVIQkwAwSAhUA2Q8GKsE309eugi/v3Kh1W3w3N8"
|
||||
error:&error],
|
||||
@"Expected invalid signature: %@", error);
|
||||
}
|
||||
|
||||
- (void)testVerifyFileAtPathUsingED25519
|
||||
{
|
||||
NSString *validSig = @"EIawm2YkDZ2gBfkEMF2+1VuuTeXnCGZOdnMdVgPPvDZioq7bvDayXqKkIIzSjKMmeFdcFJOHdnba5ZV60+gPBw==";
|
||||
|
||||
NSError *error = nil;
|
||||
|
||||
XCTAssertTrue([self checkFile:self.testFile
|
||||
withEdKey:self.pubEdKey
|
||||
signature:validSig],
|
||||
@"Expected valid signature");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Expected valid signature: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withEdKey:@"lol"
|
||||
signature:validSig],
|
||||
@"Invalid pubkey");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Invalid pubkey: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.pubDSAKeyFile
|
||||
withEdKey:self.pubEdKey
|
||||
signature:validSig],
|
||||
@"Wrong file checked");
|
||||
signature:validSig
|
||||
error:&error],
|
||||
@"Wrong file checked: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withEdKey:self.pubEdKey
|
||||
signature:@"wTcpXCgWoa4NrJpsfzS61FXJIbv963//12U2ef9xstzVOLPHYK2N4/ojgpDV5N1/NGG1uWMBgK+kEWp0Z5zMDQ=="],
|
||||
@"Expected wrong signature");
|
||||
signature:@"wTcpXCgWoa4NrJpsfzS61FXJIbv963//12U2ef9xstzVOLPHYK2N4/ojgpDV5N1/NGG1uWMBgK+kEWp0Z5zMDQ=="
|
||||
error:&error],
|
||||
@"Expected wrong signature: %@", error);
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withEdKey:self.pubEdKey
|
||||
signature:@"lol"],
|
||||
@"Invalid signature");
|
||||
signature:@"lol"
|
||||
error:&error],
|
||||
@"Invalid signature: %@", error);
|
||||
}
|
||||
|
||||
- (BOOL)checkFile:(NSString *)aFile withDSAKey:(NSString *)pubKey signature:(NSString *)sigString
|
||||
- (BOOL)checkFile:(NSString *)aFile withDSAKey:(NSString *)pubKey signature:(NSString *)sigString error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
SUPublicKeys *pubKeys = [[SUPublicKeys alloc] initWithDsa:pubKey ed:nil];
|
||||
SUSignatureVerifier *v = [[SUSignatureVerifier alloc] initWithPublicKeys:pubKeys];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:sigString ed:nil];
|
||||
|
||||
return [v verifyFileAtPath:aFile signatures:sig];
|
||||
return [v verifyFileAtPath:aFile signatures:sig error:error];
|
||||
}
|
||||
|
||||
- (BOOL)checkFile:(NSString *)aFile withEdKey:(NSString *)pubKey signature:(NSString *)sigString
|
||||
- (BOOL)checkFile:(NSString *)aFile withEdKey:(NSString *)pubKey signature:(NSString *)sigString error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
SUPublicKeys *pubKeys = [[SUPublicKeys alloc] initWithDsa:nil ed:pubKey];
|
||||
SUSignatureVerifier *v = [[SUSignatureVerifier alloc] initWithPublicKeys:pubKeys];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:nil ed:sigString];
|
||||
|
||||
return [v verifyFileAtPath:aFile signatures:sig];
|
||||
return [v verifyFileAtPath:aFile signatures:sig error:error];
|
||||
}
|
||||
|
||||
- (void)testVerifyFileWithBothKeys
|
||||
@@ -122,13 +137,14 @@
|
||||
|
||||
SUPublicKeys *pubKeys = [[SUPublicKeys alloc] initWithDsa:dsaKey ed:self.pubEdKey];
|
||||
SUSignatureVerifier *v = [[SUSignatureVerifier alloc] initWithPublicKeys:pubKeys];
|
||||
NSError *error = nil;
|
||||
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:nil]],
|
||||
@"Fail if no signatures are provided");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:nil] error:&error],
|
||||
@"Fail if no signatures are provided: %@", error);
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:@"lol" ed:@"lol"]],
|
||||
@"Fail if both signatures are invalid");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:@"lol" ed:@"lol"] error:&error],
|
||||
@"Fail if both signatures are invalid: %@", error);
|
||||
|
||||
NSString *dsaSig = @"MCwCFCIHCIYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
NSString *wrongDSASig = @"MCwCFCIHCiYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
@@ -136,30 +152,30 @@
|
||||
NSString *wrongEdSig = @"wTcpXCgWoa4NrJpsfzS61FXJIbv963//12U2ef9xstzVOLPHYK2N4/ojgpDV5N1/NGG1uWMBgK+kEWp0Z5zMDQ==";
|
||||
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:nil]],
|
||||
@"EdDSA signature must be present if app has EdDSA key");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:nil] error:&error],
|
||||
@"EdDSA signature must be present if app has EdDSA key: %@", error);
|
||||
|
||||
XCTAssertTrue([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:edSig]],
|
||||
@"Allow just an EdDSA signature if that's all that's available");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:edSig] error:&error],
|
||||
@"Allow just an EdDSA signature if that's all that's available: %@", error);
|
||||
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:wrongEdSig]],
|
||||
@"Fail on a bad Ed25519 signature regardless");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:wrongEdSig] error:&error],
|
||||
@"Fail on a bad Ed25519 signature regardless: %@", error);
|
||||
XCTAssertTrue([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:wrongDSASig ed:edSig]],
|
||||
@"Allow bad DSA signature if EdDSA signature is good");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:wrongDSASig ed:edSig] error:&error],
|
||||
@"Allow bad DSA signature if EdDSA signature is good: %@", error);
|
||||
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:@"lol"]],
|
||||
@"Fail if the Ed25519 signature is invalid.");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:@"lol"] error:&error],
|
||||
@"Fail if the Ed25519 signature is invalid: %@", error);
|
||||
XCTAssertFalse([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:@"lol" ed:edSig]],
|
||||
@"Fail if invalid DSA signature is used even if EdDSA signature is good.");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:@"lol" ed:edSig] error:&error],
|
||||
@"Fail if invalid DSA signature is used even if EdDSA signature is good: %@", error);
|
||||
|
||||
XCTAssertTrue([v verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:edSig]],
|
||||
@"Pass if both are valid");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:edSig] error:&error],
|
||||
@"Pass if both are valid: %@", error);
|
||||
}
|
||||
|
||||
- (void)testVerifyFileWithWrongKey
|
||||
@@ -173,16 +189,17 @@
|
||||
SUPublicKeys *dsaOnlyKeys = [[SUPublicKeys alloc] initWithDsa:dsaKey ed:nil];
|
||||
SUSignatureVerifier *dsaOnlyVerifier = [[SUSignatureVerifier alloc] initWithPublicKeys:dsaOnlyKeys];
|
||||
|
||||
NSError *error = nil;
|
||||
XCTAssertFalse([dsaOnlyVerifier verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:edSig]],
|
||||
@"DSA cannot verify an Ed signature");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:nil ed:edSig] error:&error],
|
||||
@"DSA cannot verify an Ed signature: %@", error);
|
||||
|
||||
SUPublicKeys *edOnlyKeys = [[SUPublicKeys alloc] initWithDsa:nil ed:self.pubEdKey];
|
||||
SUSignatureVerifier *edOnlyVerifier = [[SUSignatureVerifier alloc] initWithPublicKeys:edOnlyKeys];
|
||||
|
||||
XCTAssertFalse([edOnlyVerifier verifyFileAtPath:self.testFile
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:nil]],
|
||||
@"Ed cannot verify an DSA signature");
|
||||
signatures:[[SUSignatures alloc] initWithDsa:dsaSig ed:nil] error:&error],
|
||||
@"Ed cannot verify an DSA signature: %@", error);
|
||||
|
||||
}
|
||||
|
||||
@@ -198,7 +215,8 @@
|
||||
XCTAssertNotNil(sig);
|
||||
XCTAssertNotNil(sig.dsaSignature);
|
||||
|
||||
XCTAssertTrue([SUSignatureVerifier validatePath:self.testFile withSignatures:sig withPublicKeys:pubkeys], @"Expected valid signature");
|
||||
NSError *error = nil;
|
||||
XCTAssertTrue([SUSignatureVerifier validatePath:self.testFile withSignatures:sig withPublicKeys:pubkeys error:&error], @"Expected valid signature: %@", error);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
for file in "dsaparam.pem" "dsa_priv.pem" "dsa_pub.pem"; do
|
||||
if [ -e "$file" ]; then
|
||||
echo "There's already a $file here! Move it aside or be more careful!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
openssl="/usr/bin/openssl"
|
||||
$openssl gendsa <($openssl dsaparam 2047) -out dsa_priv.pem
|
||||
chmod 0400 dsa_priv.pem
|
||||
$openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem
|
||||
|
||||
echo "
|
||||
Generated two files:
|
||||
dsa_priv.pem: your private key. Keep it secret and don't share it!
|
||||
dsa_pub.pem: public counterpart to include in the app bundle.
|
||||
|
||||
BACK UP YOUR PRIVATE KEY AND KEEP IT SAFE!
|
||||
If you lose it, your users will be unable to upgrade!
|
||||
"
|
||||
|
||||
open -R dsa_priv.pem
|
||||
@@ -5,17 +5,13 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
// Maximum number of delta updates (per OS).
|
||||
let maxDeltas = 5
|
||||
|
||||
func makeError(code: SUError, _ description: String) -> NSError {
|
||||
return NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(code.rawValue)), userInfo: [
|
||||
NSLocalizedDescriptionKey: description,
|
||||
])
|
||||
}
|
||||
|
||||
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String: [ArchiveItem]] {
|
||||
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast")
|
||||
func makeAppcast(archivesSourceDir: URL, cacheDirectory cacheDir: URL, keys: PrivateKeys, versions: Set<String>?, maximumDeltas: Int, verbose: Bool) throws -> [String: [ArchiveItem]] {
|
||||
let comparator = SUStandardVersionComparator()
|
||||
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose: verbose))
|
||||
@@ -73,6 +69,11 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
var latestUpdatePerOS: [String: ArchiveItem] = [:]
|
||||
|
||||
for update in updates {
|
||||
// If the new versions are specified, ignore everything else
|
||||
if let versions = versions, !versions.contains(update.version) {
|
||||
continue
|
||||
}
|
||||
|
||||
// items are ordered starting latest first
|
||||
let os = update.minimumSystemVersion
|
||||
if latestUpdatePerOS[os] == nil {
|
||||
@@ -84,7 +85,7 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
var numDeltas = 0
|
||||
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent
|
||||
for item in updates {
|
||||
if numDeltas > maxDeltas {
|
||||
if numDeltas >= maximumDeltas {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
// CDATA text must contain less characters than this threshold
|
||||
let CDATA_HTML_FRAGMENT_THRESHOLD = 1000
|
||||
|
||||
class DeltaUpdate {
|
||||
let fromVersion: String
|
||||
let archivePath: URL
|
||||
@@ -141,6 +144,7 @@ class ArchiveItem: CustomStringConvertible {
|
||||
var pubDate: String {
|
||||
let date = self.archiveFileAttributes[.creationDate] as! Date
|
||||
let formatter = DateFormatter()
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZ"
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
@@ -163,7 +167,7 @@ class ArchiveItem: CustomStringConvertible {
|
||||
|
||||
private func getReleaseNotesAsHTMLFragment(_ path: URL) -> String? {
|
||||
if let html = try? String(contentsOf: path) {
|
||||
if html.utf8.count < 1000 &&
|
||||
if html.utf8.count < CDATA_HTML_FRAGMENT_THRESHOLD &&
|
||||
!html.localizedCaseInsensitiveContains("<!DOCTYPE") &&
|
||||
!html.localizedCaseInsensitiveContains("<body") {
|
||||
return html
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
let maxVersionsInFeed = 5
|
||||
|
||||
func findElement(name: String, parent: XMLElement) -> XMLElement? {
|
||||
if let found = try? parent.nodes(forXPath: name) {
|
||||
if found.count > 0 {
|
||||
@@ -31,7 +29,7 @@ func text(_ text: String) -> XMLNode {
|
||||
return XMLNode.text(withStringValue: text) as! XMLNode
|
||||
}
|
||||
|
||||
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set<String>?, maxNewVersionsInFeed: Int, link: String?, newChannel: String?, majorVersion: String?, phasedRolloutInterval: Int?, criticalUpdateVersion: String?, informationalUpdateVersions: [String]?) throws -> (numNewUpdates: Int, numExistingUpdates: Int) {
|
||||
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
|
||||
|
||||
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
|
||||
@@ -67,6 +65,9 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement)
|
||||
root.addChild(channel)
|
||||
}
|
||||
|
||||
var numNewUpdates = 0
|
||||
var numExistingUpdates = 0
|
||||
|
||||
var numItems = 0
|
||||
for update in updates {
|
||||
@@ -78,20 +79,35 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
existingItems = try channel.nodes(forXPath: "item[\(SUAppcastElementVersion)=\"\(update.version)\"]")
|
||||
}
|
||||
|
||||
let createNewItem = existingItems.count == 0
|
||||
let createNewItem = (existingItems.count == 0)
|
||||
|
||||
// Update all old items, but aim for less than 5 in new feeds
|
||||
if createNewItem && numItems >= maxVersionsInFeed {
|
||||
continue
|
||||
// Update all old items, but aim for less than maxNewVersionsInFeed in new feeds,
|
||||
// unless the user specifies which versions they want to generate
|
||||
if createNewItem {
|
||||
if let newVersions = newVersions {
|
||||
if !newVersions.contains(update.version) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if numItems >= maxNewVersionsInFeed {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
numNewUpdates += 1
|
||||
} else {
|
||||
numExistingUpdates += 1
|
||||
}
|
||||
numItems += 1
|
||||
|
||||
if createNewItem {
|
||||
item = XMLElement.element(withName: "item") as! XMLElement
|
||||
channel.addChild(item)
|
||||
} else {
|
||||
item = existingItems[0] as! XMLElement
|
||||
// Remove the existing item to make sure it's inserted in the correct order when we re-add it
|
||||
channel.removeChild(at: item.index)
|
||||
}
|
||||
channel.addChild(item)
|
||||
|
||||
if nil == findElement(name: "title", parent: item) {
|
||||
item.addChild(XMLElement.element(withName: "title", stringValue: update.shortVersion) as! XMLElement)
|
||||
@@ -100,6 +116,58 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement)
|
||||
}
|
||||
|
||||
if createNewItem {
|
||||
// Set link
|
||||
if let link = link,
|
||||
let linkElement = XMLElement.element(withName: SURSSElementLink, uri: sparkleNS) as? XMLElement {
|
||||
linkElement.setChildren([text(link)])
|
||||
item.addChild(linkElement)
|
||||
}
|
||||
|
||||
// Set new channel name
|
||||
if let newChannelName = newChannel,
|
||||
let channelNameElement = XMLElement.element(withName: SUAppcastElementChannel, uri: sparkleNS) as? XMLElement {
|
||||
channelNameElement.setChildren([text(newChannelName)])
|
||||
item.addChild(channelNameElement)
|
||||
}
|
||||
|
||||
// Set last major version
|
||||
if let minimumAutoupdateVersion = majorVersion,
|
||||
let minimumAutoupdateVersionElement = XMLElement.element(withName: SUAppcastElementMinimumAutoupdateVersion, uri: sparkleNS) as? XMLElement {
|
||||
minimumAutoupdateVersionElement.setChildren([text(minimumAutoupdateVersion)])
|
||||
item.addChild(minimumAutoupdateVersionElement)
|
||||
}
|
||||
|
||||
// Set phased rollout interval
|
||||
if let phasedRolloutInterval = phasedRolloutInterval,
|
||||
let phasedRolloutIntervalElement = XMLElement.element(withName: SUAppcastElementPhasedRolloutInterval, uri: sparkleNS) as? XMLElement {
|
||||
phasedRolloutIntervalElement.setChildren([text(String(phasedRolloutInterval))])
|
||||
item.addChild(phasedRolloutIntervalElement)
|
||||
}
|
||||
|
||||
// Set last critical update version
|
||||
if let criticalUpdateVersion = criticalUpdateVersion,
|
||||
let criticalUpdateElement = XMLElement.element(withName: SUAppcastElementCriticalUpdate, uri: sparkleNS) as? XMLElement {
|
||||
if criticalUpdateVersion.count > 0 {
|
||||
criticalUpdateElement.setAttributesWith([SUAppcastAttributeVersion: criticalUpdateVersion])
|
||||
}
|
||||
item.addChild(criticalUpdateElement)
|
||||
}
|
||||
|
||||
// Set informational update versions
|
||||
if let informationalUpdateVersions = informationalUpdateVersions,
|
||||
let informationalUpdateElement = XMLElement.element(withName: SUAppcastElementInformationalUpdate, uri: sparkleNS) as? XMLElement {
|
||||
let versionElements: [XMLElement] = informationalUpdateVersions.compactMap({ informationalUpdateVersion in
|
||||
let element = XMLElement.element(withName: SUAppcastAttributeVersion, uri: sparkleNS) as? XMLElement
|
||||
element?.setChildren([text(informationalUpdateVersion)])
|
||||
return element
|
||||
})
|
||||
|
||||
informationalUpdateElement.setChildren(versionElements)
|
||||
item.addChild(informationalUpdateElement)
|
||||
}
|
||||
}
|
||||
|
||||
var versionElement = findElement(name: SUAppcastElementVersion, parent: item)
|
||||
if nil == versionElement {
|
||||
versionElement = XMLElement.element(withName: SUAppcastElementVersion, uri: sparkleNS) as? XMLElement
|
||||
@@ -120,13 +188,20 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
cdata.stringValue = html
|
||||
descElement.setChildren([cdata])
|
||||
}
|
||||
|
||||
|
||||
// Override the minimum system version with the version from the archive,
|
||||
// only if an existing item doesn't specify one
|
||||
let minimumSystemVersion: String
|
||||
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item)
|
||||
if nil == minVer {
|
||||
if let minVer = minVer {
|
||||
minimumSystemVersion = minVer.stringValue ?? update.minimumSystemVersion
|
||||
} else {
|
||||
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement
|
||||
item.addChild(minVer!)
|
||||
|
||||
minimumSystemVersion = update.minimumSystemVersion
|
||||
}
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)])
|
||||
minVer?.setChildren([text(minimumSystemVersion)])
|
||||
|
||||
// Look for an existing release notes element
|
||||
let releaseNotesXpath = "\(SUAppcastElementReleaseNotesLink)"
|
||||
@@ -218,4 +293,6 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
let docData = doc.xmlData(options: options)
|
||||
_ = try XMLDocument(data: docData, options: XMLNode.Options()); // Verify that it was generated correctly, which does not always happen!
|
||||
try docData.write(to: appcastDestPath)
|
||||
|
||||
return (numNewUpdates, numExistingUpdates)
|
||||
}
|
||||
+179
-245
@@ -7,49 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
var verbose = false
|
||||
|
||||
// Enum that contains keys for command-line arguments
|
||||
struct CommandLineArguments {
|
||||
var privateDSAKey : SecKey?
|
||||
var privateEdString : String?
|
||||
var downloadURLPrefix : URL?
|
||||
var releaseNotesURLPrefix: URL?
|
||||
var outputPathURL: URL?
|
||||
var archivesSourceDir: URL?
|
||||
}
|
||||
|
||||
func printUsage() {
|
||||
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent
|
||||
let usage = """
|
||||
|
||||
Generate appcast from a directory of Sparkle update archives
|
||||
|
||||
Usage: \(command) [OPTIONS] [ARCHIVES_FOLDER]
|
||||
-h: prints this message
|
||||
-f: provide the path to the private DSA key
|
||||
-n: provide the name of the private DSA key. This option must be used with `-k`
|
||||
-k: provide the name of the keychain. This option must be used with `-n`
|
||||
-s: provide the private EdDSA key (128 characters)
|
||||
-o: provide a filename for the generated appcast (allowed when only one will be created)
|
||||
|
||||
--download-url-prefix: provide a prefix used to construct URLs for update downloads
|
||||
--release-notes-url-prefix: provide a prefix used to construct URLs for release notes
|
||||
|
||||
Examples:
|
||||
\(command) ./my-app-release-zipfiles/
|
||||
\(command) -o appcast-name.xml ./my-app-release-zipfiles/
|
||||
|
||||
\(command) dsa_priv.pem ./my-app-release-zipfiles/ [DEPRECATED]
|
||||
|
||||
Appcast files and deltas will be written to the archives directory.
|
||||
Note that pkg-based updates are not supported.
|
||||
|
||||
"""
|
||||
|
||||
print(usage)
|
||||
}
|
||||
import ArgumentParser
|
||||
|
||||
func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> PrivateKeys {
|
||||
var privateEdKey: Data?
|
||||
@@ -88,222 +46,198 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses all possible command line options and returns a struct that contains them
|
||||
*/
|
||||
func parseCommandLineOptions() -> CommandLineArguments {
|
||||
var arguments = CommandLine.arguments
|
||||
struct GenerateAppcast: ParsableCommand {
|
||||
static let programName = "generate_appcast"
|
||||
static let programNamePath: String = CommandLine.arguments.first ?? "./\(programName)"
|
||||
static let cacheDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast")
|
||||
|
||||
// If there are fewer than two arguments (the name of the application +
|
||||
// the required archive directory), or if `-h` is in the argument list,
|
||||
// then show the usage message
|
||||
if arguments.count < 2 || arguments.contains("-h") {
|
||||
printUsage()
|
||||
exit(1)
|
||||
static let DEFAULT_MAX_NEW_VERSIONS_IN_FEED = 5
|
||||
static let DEFAULT_MAXIMUM_DELTAS = 5
|
||||
|
||||
@Option(name: .customShort("s"), help: ArgumentHelp("The private EdDSA string (128 characters). If not specified, the private EdDSA key will be read from the Keychain instead.", valueName: "private-EdDSA-key"))
|
||||
var privateEdString : String?
|
||||
|
||||
@Option(name: .customShort("f"), help: ArgumentHelp("Path to the private DSA key file. Only use this option for transitioning to EdDSA from older updates.", valueName: "private-dsa-key-file"), transform: { URL(fileURLWithPath: $0) })
|
||||
var privateDSAKeyURL: URL?
|
||||
|
||||
@Option(name: .customShort("n"), help: ArgumentHelp("The name of the private DSA key. This option must be used together with `-k`. Only use this option for transitioning to EdDSA from older updates.", valueName: "dsa-key-name"))
|
||||
var privateDSAKeyName: String?
|
||||
|
||||
@Option(name: .customShort("k"), help: ArgumentHelp("The path to the keychain to look up the private DSA key. This option must be used together with `-n`. Only use this option for transitioning to EdDSA from older updates.", valueName: "keychain-for-dsa"), transform: { URL(fileURLWithPath: $0) })
|
||||
var keychainURL: URL?
|
||||
|
||||
@Option(name: .customLong("download-url-prefix"), help: ArgumentHelp("A URL that will be used as prefix for the URL from where updates will be downloaded.", valueName: "url"), transform: { URL(string: $0) })
|
||||
var downloadURLPrefix : URL?
|
||||
|
||||
@Option(name: .customLong("release-notes-url-prefix"), help: ArgumentHelp("A URL that will be used as prefix for constructing URLs for release notes.", valueName: "url"), transform: { URL(string: $0) })
|
||||
var releaseNotesURLPrefix : URL?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("A URL to the application's website which Sparkle may use for directing users to if they cannot download a new update from within the application. This will be used for new generated update items. By default, no product link is used.", valueName: "link"))
|
||||
var link: String?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("An optional comma delimited list of application versions (specified by CFBundleVersion) to generate new update items for. By default, new update items are inferred from the available archives and are only generated if they are in the latest \(DEFAULT_MAX_NEW_VERSIONS_IN_FEED) updates in the appcast.", valueName: "versions"), transform: { Set($0.components(separatedBy: ",")) })
|
||||
var versions: Set<String>?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("The maximum number of delta items to create for the latest update for each minimum required operating system.", valueName: "maximum-deltas"))
|
||||
var maximumDeltas: Int = DEFAULT_MAXIMUM_DELTAS
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("The Sparkle channel name that will be used for generating new updates. By default, no channel is used. Old applications need to be using Sparkle 2 to use this feature.", valueName: "channel-name"))
|
||||
var channel: String?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("The last major or minimum autoupdate sparkle:version that will be used for generating new updates. By default, no last major version is used.", valueName: "major-version"))
|
||||
var majorVersion: String?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("The phased rollout interval in seconds that will be used for generating new updates. By default, no phased rollout interval is used.", valueName: "phased-rollout-interval"), transform: { Int($0) })
|
||||
var phasedRolloutInterval: Int?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("The last critical update sparkle:version that will be used for generating new updates. An empty string argument will treat this update as critical coming from any application version. By default, no last critical update version is used. Old applications need to be using Sparkle 2 to use this feature.", valueName: "critical-update-version"))
|
||||
var criticalUpdateVersion: String?
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp("A comma delimited list of application sparkle:version's that will see newly generated updates as being informational only. An empty string argument will treat this update as informational coming from any application version. By default, updates are not informational only. --link must also be provided. Old applications need to be using Sparkle 2 to use this feature.", valueName: "informational-update-versions"), transform: { $0.components(separatedBy: ",").filter({$0.count > 0}) })
|
||||
var informationalUpdateVersions: [String]?
|
||||
|
||||
@Option(name: .customShort("o"), help: ArgumentHelp("Path to filename for the generated appcast (allowed when only one will be created).", valueName: "output-path"), transform: { URL(fileURLWithPath: $0) })
|
||||
var outputPathURL: URL?
|
||||
|
||||
@Argument(help: "The path to the directory containing the update archives and delta files.", transform: { URL(fileURLWithPath: $0, isDirectory: true) })
|
||||
var archivesSourceDir: URL
|
||||
|
||||
// New update items are only generated if they are in the latest maxNewVersionsInFeed updates in the appcast
|
||||
// If the `versions` to generate is specified however, this counter has no effect.
|
||||
// Keep this option hidden from the user for now
|
||||
@Option(name: .long, help: .hidden)
|
||||
var maxNewVersionsInFeed: Int = DEFAULT_MAX_NEW_VERSIONS_IN_FEED
|
||||
|
||||
@Flag(help: .hidden)
|
||||
var verbose: Bool = false
|
||||
|
||||
static var configuration = CommandConfiguration(
|
||||
abstract: "Generate appcast from a directory of Sparkle update archives.",
|
||||
discussion: """
|
||||
Appcast files and deltas will be written to the archives directory.
|
||||
|
||||
If an appcast file is already present in the archives directory, that file will be re-used and updated with new entries.
|
||||
Old entries in the appcast are kept intact. Otherwise, a new appcast file will be generated and written.
|
||||
|
||||
.html files that have the same filename as an archive (except for the file extension) will be used for release notes for that item.
|
||||
If the contents of these files are short (< \(CDATA_HTML_FRAGMENT_THRESHOLD) characters) and do not include a DOCTYPE or body tags, they will be treated as embedded CDATA release notes.
|
||||
|
||||
For new update entries, Sparkle infers the minimum system OS requirement based on your update's LSMinimumSystemVersion provided
|
||||
by your application's Info.plist. If none is found, \(programName) defaults to Sparkle's own minimum system requirement (macOS 10.11).
|
||||
|
||||
An example of an archives directory may look like:
|
||||
./my-app-release-zipfiles/
|
||||
MyApp 1.0.zip
|
||||
MyApp 1.0.html
|
||||
MyApp 1.1.zip
|
||||
MyApp 1.1.html
|
||||
appcast.xml
|
||||
|
||||
EXAMPLES:
|
||||
\(programNamePath) ./my-app-release-zipfiles/
|
||||
\(programNamePath) -o appcast-name.xml ./my-app-release-zipfiles/
|
||||
|
||||
For more advanced options that can be used for publishing updates, see https://sparkle-project.org/documentation/publishing/ for further documentation.
|
||||
|
||||
Extracted archives are cached in \((cacheDirectory.path as NSString).abbreviatingWithTildeInPath) to avoid re-computation in subsequent runs.
|
||||
|
||||
Note that \(programName) does not support package-based (.pkg) updates.
|
||||
""")
|
||||
|
||||
func validate() throws {
|
||||
guard (keychainURL == nil) == (privateDSAKeyName == nil) else {
|
||||
throw ValidationError("Both -n <dsa-key-name> and -k <keychain> options must be provided together, or neither should be provided.")
|
||||
}
|
||||
|
||||
// Both keychain/dsa key name options, and private dsa key file options cannot coexist
|
||||
guard (keychainURL == nil) || (privateDSAKeyURL == nil) else {
|
||||
throw ValidationError("-f <private-dsa-key-file> cannot be provided if -n <dsa-key-name> and -k <keychain> is provided")
|
||||
}
|
||||
|
||||
if let versions = versions {
|
||||
guard versions.count > 0 else {
|
||||
throw ValidationError("--versions must specify at least one application version.")
|
||||
}
|
||||
}
|
||||
|
||||
guard (informationalUpdateVersions == nil) || (link != nil) else {
|
||||
throw ValidationError("--link must be specified if --informational-update-versions is specified.")
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the first element since this is the path to executable which we don't need
|
||||
arguments.removeFirst()
|
||||
|
||||
// Create the struct that will hold the parsed args
|
||||
var commandLineArguments = CommandLineArguments()
|
||||
|
||||
// check if the private dsa key option is present
|
||||
if let privateDSAKeyOptionIndex = arguments.firstIndex(of: "-f") {
|
||||
// check that when accessing the value of the option we don't get out of bounds
|
||||
if privateDSAKeyOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
func run() throws {
|
||||
// Extract the keys
|
||||
let privateDSAKey : SecKey?
|
||||
if let privateDSAKeyURL = privateDSAKeyURL {
|
||||
do {
|
||||
privateDSAKey = try loadPrivateDSAKey(at: privateDSAKeyURL)
|
||||
} catch {
|
||||
print("Unable to load DSA private key from", privateDSAKeyURL.path, "\n", error)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
} else if let keychainURL = keychainURL, let privateDSAKeyName = privateDSAKeyName {
|
||||
do {
|
||||
privateDSAKey = try loadPrivateDSAKey(named: privateDSAKeyName, fromKeychainAt: keychainURL)
|
||||
} catch {
|
||||
print("Unable to load DSA private key '\(privateDSAKeyName)' from keychain at", keychainURL.path, "\n", error)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
} else {
|
||||
privateDSAKey = nil
|
||||
}
|
||||
|
||||
// get the private DSA key
|
||||
let privateKeyUrl = URL(fileURLWithPath: arguments[privateDSAKeyOptionIndex + 1])
|
||||
|
||||
let keys = loadPrivateKeys(privateDSAKey, privateEdString)
|
||||
|
||||
do {
|
||||
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(at: privateKeyUrl)
|
||||
} catch {
|
||||
print("Unable to load DSA private key from", privateKeyUrl.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// remove the already parsed arguments
|
||||
arguments.remove(at: privateDSAKeyOptionIndex + 1)
|
||||
arguments.remove(at: privateDSAKeyOptionIndex)
|
||||
}
|
||||
|
||||
// check if the private dsa sould be loaded using the keyname and the name of the keychain
|
||||
if let keyNameOptionIndex = arguments.firstIndex(of: "-n"), let keychainNameOptionIndex = arguments.firstIndex(of: "-k") {
|
||||
// check that when accessing one of the values of the options we don't get out of bounds
|
||||
if keyNameOptionIndex + 1 >= arguments.count || keychainNameOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// get the keyname and the keychain url to load the private DSA key
|
||||
let keyName: String = arguments[keyNameOptionIndex + 1]
|
||||
let keychainUrl: URL = URL(fileURLWithPath: arguments[keychainNameOptionIndex + 1])
|
||||
do {
|
||||
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(named: keyName, fromKeychainAt: keychainUrl)
|
||||
} catch {
|
||||
print("Unable to load DSA private key '\(keyName)' from keychain at", keychainUrl.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// remove the already parsed arguments
|
||||
arguments.remove(at: keyNameOptionIndex + 1)
|
||||
arguments.remove(at: keyNameOptionIndex)
|
||||
arguments.remove(at: arguments.firstIndex(of: "-k")! + 1)
|
||||
arguments.remove(at: keychainNameOptionIndex)
|
||||
}
|
||||
|
||||
// check if the private EdDSA key string was given as an argument
|
||||
if let privateEdDSAKeyOptionIndex = arguments.firstIndex(of: "-s") {
|
||||
// check that when accessing the value of the option we don't get out of bounds
|
||||
if privateEdDSAKeyOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// get the private EdDSA key string
|
||||
commandLineArguments.privateEdString = arguments[privateEdDSAKeyOptionIndex + 1]
|
||||
|
||||
// remove the already parsed argument
|
||||
arguments.remove(at: privateEdDSAKeyOptionIndex + 1)
|
||||
arguments.remove(at: privateEdDSAKeyOptionIndex)
|
||||
}
|
||||
|
||||
// check if a prefix for the download url of the archives was given
|
||||
if let downloadUrlPrefixOptionIndex = arguments.firstIndex(of: "--download-url-prefix") {
|
||||
// check that when accessing the value of the option we don't get out of bounds
|
||||
if downloadUrlPrefixOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// get the download url prefix
|
||||
commandLineArguments.downloadURLPrefix = URL(string: arguments[downloadUrlPrefixOptionIndex + 1])
|
||||
|
||||
// remove the parsed argument
|
||||
arguments.remove(at: downloadUrlPrefixOptionIndex + 1)
|
||||
arguments.remove(at: downloadUrlPrefixOptionIndex)
|
||||
}
|
||||
|
||||
// Check if a URL prefix was specified for the release notes
|
||||
if let releaseNotesURLPrefixOptionIndex = arguments.firstIndex(of: "--release-notes-url-prefix") {
|
||||
if releaseNotesURLPrefixOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Get the URL prefix for the release notes
|
||||
commandLineArguments.releaseNotesURLPrefix = URL(string: arguments[releaseNotesURLPrefixOptionIndex + 1])
|
||||
|
||||
// Remove the parsed argument
|
||||
arguments.remove(at: releaseNotesURLPrefixOptionIndex + 1)
|
||||
arguments.remove(at: releaseNotesURLPrefixOptionIndex)
|
||||
}
|
||||
|
||||
// Check if an output filename was specified
|
||||
if let outputFilenameOptionIndex = arguments.firstIndex(of: "-o") {
|
||||
// check that when accessing the value of the option we don't get out of bounds
|
||||
if outputFilenameOptionIndex + 1 >= arguments.count {
|
||||
print("Too few arguments were given")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Get the URL prefix for the release notes
|
||||
commandLineArguments.outputPathURL = URL(fileURLWithPath: arguments[outputFilenameOptionIndex + 1])
|
||||
|
||||
// Remove the parsed argument
|
||||
arguments.remove(at: outputFilenameOptionIndex + 1)
|
||||
arguments.remove(at: outputFilenameOptionIndex)
|
||||
}
|
||||
|
||||
// now that all command line options have been removed from the arguments array
|
||||
// there should only be the path to the private DSA key (if provided) path to the archives dir left
|
||||
if arguments.count == 2 {
|
||||
// if there are two arguments left they are the private DSA key and the path to the archives directory (in this order)
|
||||
// first get the private DSA key
|
||||
let privateKeyURL = URL(fileURLWithPath: arguments[0])
|
||||
do {
|
||||
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(at: privateKeyURL)
|
||||
} catch {
|
||||
print("Unable to load DSA private key from", privateKeyURL.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// remove the parsed path to the DSA key
|
||||
arguments.removeFirst()
|
||||
}
|
||||
|
||||
// now only the archives source dir is left
|
||||
if let archivesSourceDir = arguments.first {
|
||||
commandLineArguments.archivesSourceDir = URL(fileURLWithPath: archivesSourceDir, isDirectory: true)
|
||||
} else {
|
||||
print("Archive folder must be specified")
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return commandLineArguments
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Parse the command line arguments
|
||||
let args = parseCommandLineOptions()
|
||||
|
||||
// If parsing the command line options was successful, then
|
||||
// the archivesSourceDir must exist
|
||||
let archivesSourceDir = args.archivesSourceDir!
|
||||
|
||||
// Extract the keys
|
||||
let keys = loadPrivateKeys(args.privateDSAKey, args.privateEdString)
|
||||
|
||||
do {
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose: verbose)
|
||||
|
||||
// If a URL prefix was provided, set on the archive items
|
||||
if args.downloadURLPrefix != nil || args.releaseNotesURLPrefix != nil {
|
||||
for (_, archiveItems) in allUpdates {
|
||||
for archiveItem in archiveItems {
|
||||
if let downloadURLPrefix = args.downloadURLPrefix {
|
||||
archiveItem.downloadUrlPrefix = downloadURLPrefix
|
||||
}
|
||||
if let releaseNotesURLPrefix = args.releaseNotesURLPrefix {
|
||||
archiveItem.releaseNotesURLPrefix = releaseNotesURLPrefix
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, cacheDirectory: GenerateAppcast.cacheDirectory, keys: keys, versions: versions, maximumDeltas: maximumDeltas, verbose: verbose)
|
||||
|
||||
// If a URL prefix was provided, set on the archive items
|
||||
if downloadURLPrefix != nil || releaseNotesURLPrefix != nil {
|
||||
for (_, archiveItems) in allUpdates {
|
||||
for archiveItem in archiveItems {
|
||||
if let downloadURLPrefix = downloadURLPrefix {
|
||||
archiveItem.downloadUrlPrefix = downloadURLPrefix
|
||||
}
|
||||
if let releaseNotesURLPrefix = releaseNotesURLPrefix {
|
||||
archiveItem.releaseNotesURLPrefix = releaseNotesURLPrefix
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a (single) output filename was specified on the command-line, but more than one
|
||||
// appcast file was found in the archives, then it's an error.
|
||||
if let outputPathURL = outputPathURL,
|
||||
allUpdates.count > 1 {
|
||||
print("Cannot write to \(outputPathURL.path): multiple appcasts found")
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
// If an output filename was specified, use it.
|
||||
// Otherwise, use the name of the appcast file found in the archive.
|
||||
let appcastDestPath = outputPathURL ?? URL(fileURLWithPath: appcastFile,
|
||||
relativeTo: archivesSourceDir)
|
||||
|
||||
// If a (single) output filename was specified on the command-line, but more than one
|
||||
// appcast file was found in the archives, then it's an error.
|
||||
if let outputPathURL = args.outputPathURL,
|
||||
allUpdates.count > 1 {
|
||||
print("Cannot write to \(outputPathURL.path): multiple appcasts found")
|
||||
exit(1);
|
||||
// Write the appcast
|
||||
let (numNewUpdates, numExistingUpdates) = try writeAppcast(appcastDestPath: appcastDestPath, updates: updates, newVersions: versions, maxNewVersionsInFeed: maxNewVersionsInFeed, link: link, newChannel: channel, majorVersion: majorVersion, phasedRolloutInterval: phasedRolloutInterval, criticalUpdateVersion: criticalUpdateVersion, informationalUpdateVersions: informationalUpdateVersions)
|
||||
|
||||
// Inform the user, pluralizing "update" if necessary
|
||||
let pluralizeUpdates = { $0 == 1 ? "update" : "updates" }
|
||||
let newUpdatesString = pluralizeUpdates(numNewUpdates)
|
||||
let existingUpdatesString = pluralizeUpdates(numExistingUpdates)
|
||||
|
||||
print("Wrote \(numNewUpdates) new \(newUpdatesString) and updated \(numExistingUpdates) existing \(existingUpdatesString)")
|
||||
}
|
||||
} catch {
|
||||
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
// If an output filename was specified, use it.
|
||||
// Otherwise, use the name of the appcast file found in the archive.
|
||||
let appcastDestPath = args.outputPathURL ?? URL(fileURLWithPath: appcastFile,
|
||||
relativeTo: archivesSourceDir)
|
||||
|
||||
// Write the appcast
|
||||
try writeAppcast(appcastDestPath: appcastDestPath, updates: updates)
|
||||
|
||||
// Inform the user, pluralizing "update" if necessary
|
||||
let updateString = (updates.count == 1) ? "update" : "updates"
|
||||
print("Wrote \(updates.count) \(updateString) to: \(appcastDestPath.path)")
|
||||
}
|
||||
} catch {
|
||||
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.global().async(execute: {
|
||||
main()
|
||||
GenerateAppcast.main()
|
||||
CFRunLoopStop(CFRunLoopGetMain())
|
||||
})
|
||||
|
||||
CFRunLoopRun()
|
||||
+111
-121
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
import ArgumentParser
|
||||
|
||||
let PRIVATE_KEY_LABEL = "Private key for signing Sparkle updates"
|
||||
|
||||
@@ -155,133 +156,122 @@ func printNewPublicKeyUsage(_ publicKey: Data) {
|
||||
""")
|
||||
}
|
||||
|
||||
/// Once it's safe to require Swift 5.3 and Xcode 12 for this code, rename this file to `generate_keys.swift` and
|
||||
/// replace this function with a class tagged with `@main`.
|
||||
func entryPoint() {
|
||||
let arguments = CommandLine.arguments
|
||||
let programName = arguments.first ?? "generate_keys"
|
||||
struct GenerateKeys: ParsableCommand {
|
||||
@Flag(name: .customShort("p"), help: ArgumentHelp("Looks up and just prints the existing public key stored in the Keychain."))
|
||||
var lookUpPublicKey: Bool = false
|
||||
|
||||
let mode = arguments.count > 1 ? arguments[1] : nil
|
||||
|
||||
/// If not in any mode, give an intro blurb.
|
||||
if mode == nil {
|
||||
print("""
|
||||
Usage: \(programName) [-p] [-x private-key-file] [-f private-key-file]
|
||||
|
||||
This tool generates a public & private keys and uses the macOS Keychain to store
|
||||
the private key for signing app updates which will be distributed via Sparkle.
|
||||
This key will be associated with your user account.
|
||||
|
||||
Note: You only need one signing key, no matter how many apps you embed Sparkle in.
|
||||
|
||||
The keychain may ask permission for this tool to access an existing key, if one
|
||||
exists, or for permission to save the new key. You must allow access in order to
|
||||
successfully proceed.
|
||||
|
||||
Additional Options:
|
||||
-p
|
||||
Looks up and just prints the existing public key stored in the Keychain.
|
||||
|
||||
-x private-key-file
|
||||
Exports your private key from your login keychain and writes it to private-key-file. Note the contents of
|
||||
this sensitive exported file are the same as the password to the \"\(PRIVATE_KEY_LABEL)\" item in
|
||||
your keychain.
|
||||
|
||||
-f private-key-file
|
||||
Imports the private key from private-key-file into your keychain instead of generating a new key.
|
||||
This file has likely been exported via -x option from another machine.
|
||||
Any existing \"\(PRIVATE_KEY_LABEL)\" items listed in Keychain Access may need to be removed manually first before proceeding.
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
""")
|
||||
@Option(name: .customShort("x"), help: ArgumentHelp("Exports your private key from your login keychain and writes it to private-key-file. Note the contents of this sensitive exported file are the same as the password to the \"\(PRIVATE_KEY_LABEL)\" item in your keychain.", valueName: "private-key-file"))
|
||||
var exportedPrivateKeyFile: String?
|
||||
|
||||
@Option(name: .customShort("f"), help: ArgumentHelp("Imports the private key from private-key-file into your keychain instead of generating a new key. This file has likely been exported via -x option from another machine. Any existing \"\(PRIVATE_KEY_LABEL)\" items listed in Keychain Access may need to be removed manually first before proceeding.", valueName: "private-key-file"))
|
||||
var importedPrivateKeyFile: String?
|
||||
|
||||
static var configuration: CommandConfiguration = CommandConfiguration(
|
||||
abstract: "Generate public & private keys for signing Sparkle based app updates.",
|
||||
discussion: """
|
||||
This tool generates a public & private keys and uses the macOS Keychain to store
|
||||
the private key for signing app updates which will be distributed via Sparkle.
|
||||
This key will be associated with your user account.
|
||||
|
||||
Note: You only need one signing key, no matter how many apps you embed Sparkle in.
|
||||
|
||||
The keychain may ask permission for this tool to access an existing key, if one
|
||||
exists, or for permission to save the new key. You must allow access in order to
|
||||
successfully proceed.
|
||||
|
||||
In the default mode ran without any arguments, the public key and how it should be used
|
||||
in your application's Info.plist will be printed. If a private key was already generated in your Keychain,
|
||||
that key will be used and not overridden.
|
||||
|
||||
You may additionally use options to only look up the existing public key for automation (-p),
|
||||
export the private key from your Keychain to a file for transferring the key (-x), or
|
||||
import the private key into your Keychain from a file (-f).
|
||||
""")
|
||||
|
||||
func validate() throws {
|
||||
if lookUpPublicKey {
|
||||
guard exportedPrivateKeyFile == nil && importedPrivateKeyFile == nil else {
|
||||
throw ValidationError("-p option cannot be provided together with -x or -f.")
|
||||
}
|
||||
} else {
|
||||
guard exportedPrivateKeyFile == nil || importedPrivateKeyFile == nil else {
|
||||
throw ValidationError("Both -x and -f options cannot be provided together.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch mode {
|
||||
case .some("-p"):
|
||||
/// Lookup mode - print just the pubkey and exit
|
||||
if let keyPair = findKeyPair() {
|
||||
let pubKey = keyPair[64...]
|
||||
print(pubKey.base64EncodedString())
|
||||
func run() throws {
|
||||
if lookUpPublicKey {
|
||||
/// Lookup mode - print just the pubkey and exit
|
||||
if let keyPair = findKeyPair() {
|
||||
let pubKey = keyPair[64...]
|
||||
print(pubKey.base64EncodedString())
|
||||
} else {
|
||||
failure("No existing signing key found!")
|
||||
}
|
||||
} else if let exportedPrivateKeyFile = exportedPrivateKeyFile {
|
||||
/// Export mode - export the key-pair file from the user's keychain
|
||||
let exportURL = URL(fileURLWithPath: exportedPrivateKeyFile)
|
||||
if let reachable = try? exportURL.checkResourceIsReachable(), reachable {
|
||||
failure("private-key-file already exists: \(exportURL.path)")
|
||||
}
|
||||
|
||||
guard let keyPair = findKeyPair() else {
|
||||
failure("No existing signing key found!")
|
||||
}
|
||||
|
||||
do {
|
||||
try keyPair.base64EncodedString().write(to: exportURL, atomically: true, encoding: .utf8)
|
||||
} catch {
|
||||
failure("Failed to write exported file: \(error)")
|
||||
}
|
||||
} else if let importedPrivateKeyFile = importedPrivateKeyFile {
|
||||
/// Import mode - import the specifed key-pair file
|
||||
let privateAndPublicBase64KeyFile = importedPrivateKeyFile
|
||||
let privateAndPublicBase64Key: String
|
||||
do {
|
||||
privateAndPublicBase64Key = try String(contentsOfFile: privateAndPublicBase64KeyFile)
|
||||
} catch {
|
||||
failure("Failed to read private-key-file: \(error)")
|
||||
}
|
||||
|
||||
guard let privateAndPublicKey = Data(base64Encoded: privateAndPublicBase64Key.trimmingCharacters(in: .whitespacesAndNewlines), options: .init()) else {
|
||||
failure("Failed to decode base64 encoded key data from: \(privateAndPublicBase64Key)")
|
||||
}
|
||||
|
||||
guard privateAndPublicKey.count == 64 + 32 else {
|
||||
failure("Imported key must be 96 bytes decoded. Instead it is \(privateAndPublicKey.count) bytes decoded.")
|
||||
}
|
||||
|
||||
print("Importing signing key..\n")
|
||||
|
||||
let publicKey = privateAndPublicKey[64...]
|
||||
let privateKey = privateAndPublicKey[0..<64]
|
||||
|
||||
storeKeyPair(publicEdKey: publicKey, privateEdKey: privateKey)
|
||||
|
||||
printNewPublicKeyUsage(publicKey)
|
||||
} else {
|
||||
failure("No existing signing key found!")
|
||||
}
|
||||
case .some("-f"):
|
||||
/// Import mode - import the specifed key-pair file
|
||||
guard arguments.count > 2 else {
|
||||
failure("private-key-file was not specified")
|
||||
}
|
||||
|
||||
let privateAndPublicBase64KeyFile = arguments[2]
|
||||
let privateAndPublicBase64Key: String
|
||||
do {
|
||||
privateAndPublicBase64Key = try String(contentsOfFile: privateAndPublicBase64KeyFile)
|
||||
} catch {
|
||||
failure("Failed to read private-key-file: \(error)")
|
||||
}
|
||||
|
||||
guard let privateAndPublicKey = Data(base64Encoded: privateAndPublicBase64Key.trimmingCharacters(in: .whitespacesAndNewlines), options: .init()) else {
|
||||
failure("Failed to decode base64 encoded key data from: \(privateAndPublicBase64Key)")
|
||||
}
|
||||
|
||||
guard privateAndPublicKey.count == 64 + 32 else {
|
||||
failure("Imported key must be 96 bytes decoded. Instead it is \(privateAndPublicKey.count) bytes decoded.")
|
||||
}
|
||||
|
||||
print("Importing signing key..")
|
||||
|
||||
let publicKey = privateAndPublicKey[64...]
|
||||
let privateKey = privateAndPublicKey[0..<64]
|
||||
|
||||
storeKeyPair(publicEdKey: publicKey, privateEdKey: privateKey)
|
||||
|
||||
printNewPublicKeyUsage(publicKey)
|
||||
|
||||
case .some("-x"):
|
||||
/// Export mode - export the key-pair file from the user's keychain
|
||||
guard arguments.count > 2 else {
|
||||
failure("private-key-file was not specified")
|
||||
}
|
||||
|
||||
let exportURL = URL(fileURLWithPath: arguments[2])
|
||||
if let reachable = try? exportURL.checkResourceIsReachable(), reachable {
|
||||
failure("private-key-file already exists: \(exportURL.path)")
|
||||
}
|
||||
|
||||
guard let keyPair = findKeyPair() else {
|
||||
failure("No existing signing key found!")
|
||||
}
|
||||
|
||||
do {
|
||||
try keyPair.base64EncodedString().write(to: exportURL, atomically: true, encoding: .utf8)
|
||||
} catch {
|
||||
failure("Failed to write exported file: \(error)")
|
||||
}
|
||||
|
||||
case .some(let unknownOption):
|
||||
failure("Unknown option: \(unknownOption)")
|
||||
|
||||
case nil:
|
||||
/// Default mode - find an existing public key and print its usage, or generate new keys
|
||||
if let keyPair = findKeyPair() {
|
||||
let pubKey = keyPair[64...]
|
||||
print("""
|
||||
A pre-existing signing key was found. This is how it should appear in your Info.plist:
|
||||
/// Default mode - find an existing public key and print its usage, or generate new keys
|
||||
if let keyPair = findKeyPair() {
|
||||
let pubKey = keyPair[64...]
|
||||
print("""
|
||||
A pre-existing signing key was found. This is how it should appear in your Info.plist:
|
||||
|
||||
<key>SUPublicEDKey</key>
|
||||
<string>\(pubKey.base64EncodedString())</string>
|
||||
|
||||
""")
|
||||
} else {
|
||||
print("Generating a new signing key. This may take a moment, depending on your machine.")
|
||||
|
||||
let (pubKey, privKey) = generateKeyPair()
|
||||
storeKeyPair(publicEdKey: pubKey, privateEdKey: privKey)
|
||||
|
||||
printNewPublicKeyUsage(pubKey)
|
||||
<key>SUPublicEDKey</key>
|
||||
<string>\(pubKey.base64EncodedString())</string>
|
||||
|
||||
""")
|
||||
} else {
|
||||
print("Generating a new signing key. This may take a moment, depending on your machine.")
|
||||
|
||||
let (pubKey, privKey) = generateKeyPair()
|
||||
storeKeyPair(publicEdKey: pubKey, privateEdKey: privKey)
|
||||
|
||||
printNewPublicKeyUsage(pubKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch to a function because `@main` isn't stable yet at the time of this writing and top-level code is finicky.
|
||||
entryPoint()
|
||||
GenerateKeys.main()
|
||||
@@ -1,108 +0,0 @@
|
||||
- 2013-04-17 merged changes from mikkelee who [added](https://github.com/nst/objc_dep/pull/6) to use a single bidirectional arrow for two-way dependencies
|
||||
- 2013-02-21 merged changes from jomnius who [added](https://github.com/nst/objc_dep/pull/4) a parameter to exclude directories names by regex
|
||||
- 2012-05-11 merged changes from jonreid who [added](https://github.com/nst/objc_dep/pull/3) a parameter to exclude class names by regex
|
||||
- 2012-01-11 merged changes from jomnius who [added](https://github.com/nst/objc_dep/pull/1) support for C projects and better handling of categories
|
||||
- read [Object graph dependency analysis](http://samuelgoodwin.tumblr.com/post/18345393597/object-graph-dependency-analysis) by Samuel Goodwin
|
||||
- see also jominus blog post [Dependency Graph Tool for iOS Projects](http://jomnius.blogspot.com/2012/01/dependency-graph-tool-for-ios-projects.html)
|
||||
- yet another use case on vigorouscoding.com [Better get it right the first time](http://www.vigorouscoding.com/2011/12/better-get-it-right-the-first-time/)
|
||||
|
||||
# License
|
||||
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2012-2013, Nicolas Seriot All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
Neither the name of the Nicolas Seriot nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Refactoring by graphing class dependencies
|
||||
|
||||
### Code design and loose coupling
|
||||
|
||||
As developers, we all love clean code, but the fact is that most of the time we're dealing with bad code. It may be recent or legacy code, written by ourselves or by other developers. We can recognize bad code because [code](http://en.wikipedia.org/wiki/Code_smell) [smells](http://www.codinghorror.com/blog/2006/05/code-smells.html). In other words, some heuristics raise questions about code quality. Among thoses we can name dead code, which I already wrote about [here](http://seriot.ch/blog.php?article=20080728) and [here](http://seriot.ch/blog.php?article=20100301), and tight coupling.
|
||||
|
||||
Tight coupling describes a system where many components depend on many other components. A tightly coupled code base stinks, the coupling points out that some classes assume too many responsibilities or that a responsability is spread over several classes, rather than having its own class. The opposite, loose coupling, shows a better design which promotes single-responsibility and separation of concerns. Loose coupling makes the code easier to test and maintain.
|
||||
|
||||
In Objective-C, reducing coupling generally involves [delegates](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html) and [notifications](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html%23//apple_ref/doc/uid/10000043i).
|
||||
|
||||
### Graphing class dependencies
|
||||
|
||||
So how do we achieve loose coupling in our own code? Well, at first, we need to get a better idea on the current coupling. Let us define class dependency: _class A depends on B if class A imports class B header_. With such a definition, we can draw a graph of dependencies between classes by considering the Objective-C `#import` directives in each class. We assume here that the files are named according to the classes they contain.
|
||||
|
||||
I wrote [objc_dep.py](https://github.com/nst/objc_dep), a Python script which extracts imports from Objective-C source code. The output can then be displayed in [GraphViz](http://www.graphviz.org/) or [OmniGraffle](http://www.omnigroup.com/products/omnigraffle/). You can then see an oriented graph of dependencies between classes. Note that we could also compute metrics on coupling, but it's not the point here.
|
||||
|
||||
### Sample usage
|
||||
|
||||
How do we get from the dependencies graph to a better design? There's no determinist algorithm and it depends on your project. Let us apply the script on [FSWalker](http://code.google.com/p/fswalker/), a small iPhone file browser I wrote a long time ago.
|
||||
|
||||
#### 1. Generate the graph
|
||||
|
||||
$ python objc_dep.py /path/to/FSWalker > fswalker.dot
|
||||
|
||||
#### 2. Open it in OmniGraffle
|
||||
|
||||
At this point, we see classes as nodes and dependencies as directed edges.
|
||||
|
||||
<a href="https://github.com/nst/objc_dep/raw/master/pics/fswalker1.png"><img src="https://github.com/nst/objc_dep/raw/master/pics/fswalker1.png" width="600" /></a>
|
||||
|
||||
#### 3. Remove categories
|
||||
|
||||
We can safely remove Objective-C [categories](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCategories.html) from the graph, since referencing categories from many places is not an issue from a design point of view.
|
||||
|
||||
<a href="https://github.com/nst/objc_dep/raw/master/pics/fswalker2.png"><img src="https://github.com/nst/objc_dep/raw/master/pics/fswalker2.png" width="600" /></a>
|
||||
|
||||
#### 4. Group related classes
|
||||
|
||||
Next, we can move the vertices around, try to group classes with a common responsibility into clusters.
|
||||
|
||||
<a href="https://github.com/nst/objc_dep/raw/master/pics/fswalker3.png"><img src="https://github.com/nst/objc_dep/raw/master/pics/fswalker3.png" width="600" /></a>
|
||||
|
||||
#### 5. Study strange dependencies
|
||||
|
||||
The graph now gives a pretty good overview of the overall code structure. The controller objects have been colored in pink, the model objects in yellow and the network part in blue. The graph allows to sport strange dependencies and question the code design. We can see at first glance that FSWalkerAppDelegate has too many dependencies. Specifically we consider:
|
||||
|
||||
a) unreferenced classes or clusters
|
||||
|
||||
This is probably dead code, which can be removed.
|
||||
|
||||
Ok, there are no unreferenced classes here, although you will probably find some in bigger projects.
|
||||
|
||||
b) two-ways references
|
||||
|
||||
Maybe one class should not reference another directly, but reference a protocol implemented by the other class instead.
|
||||
|
||||
We have two examples of two-ways references here, between HTTPServer and HTTPConnection, and also between RootViewController and FSWalkerAppDelegate. The former is part of [CocoaHTTPServer](http://code.google.com/p/cocoahttpserver/) and is not a design issue in our project. However, the latter is an issue. By looking at the code, we will notice that RootViewController doesn't actually use FSWalkerAppDelegate. The import can thus be safely removed.
|
||||
|
||||
c) weird references
|
||||
|
||||
Some of the import directives may simply be unnecessary, or reveal design issues.
|
||||
|
||||
There is no good reason why FSWalkerAppDelegate would reference FSItem, nor InfoPanelController. Code inspection will reveal that DetailViewController and InfoPanelController should not be referenced by FSWalkerAppDelegate but RootViewController instead. So, here is the final graph. The architecture of FSWalker may still be improved, but you get the idea...
|
||||
|
||||
<a href="https://github.com/nst/objc_dep/raw/master/pics/fswalker4.png"><img src="https://github.com/nst/objc_dep/raw/master/pics/fswalker4.png" width="600" /></a>
|
||||
|
||||
### Real world usage
|
||||
|
||||
Here is the kind of chart you can expect with a 100 classes project.
|
||||
|
||||
<a href="https://github.com/nst/objc_dep/raw/master/pics/largerproject.png"><img src="https://github.com/nst/objc_dep/raw/master/pics/largerproject.png" width="600" /></a>
|
||||
|
||||
#### Using options
|
||||
|
||||
`% python objc_dep.py /path/to/repo -x "(^Internal|secret)" -i subdir1 subdir2 > graph.dot`
|
||||
|
||||
Will exclude files with names that begin with "Internal", or contain the word "secret". Additionally all files in folders named subdir1 and subdir2 are ignored.
|
||||
|
||||
### Possible improvements
|
||||
|
||||
The Cocoa framework enforces the [MVC paradigm](http://developer.apple.com/technologies/mac/cocoa.html), which states (to be short) that model objects and graphical objects should be clearly separated by controller objects. The script could probably be improved by drawing classes which depend on Foundation and classes which depend on AppKit/UIKit with different colors.
|
||||
|
||||
### Conclusion
|
||||
|
||||
I have found [objc_dep.py](https://github.com/nst/objc_dep) to be definitely useful on small projects as well as bigger ones. It helped me in getting a clear view of code base structure. Spotting strange dependencies allowed me to ask good questions which led to design simplifications. Such a tool could even be integrated into Apple development tools.
|
||||
|
||||
Interestingly, the last chart is quite close to the mental representation I have of the code architecture. It reminds me a discussion I had 15 years ago with a friend who was a champion chess player who could play several "blind" chess games simultaneously. He explained then that he saw a blurry chessboard in his head and could move around the pieces as with a small 3D camera. Focusing on a specific piece would then raise awareness of opportunities and risks - dependencies - for this piece. As a side effect, writing this script made me realize that software engineering is pretty similar to chess in this way.
|
||||
@@ -1,265 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Nicolas Seriot
|
||||
# 2011-01-06 -> 2011-12-16
|
||||
# https://github.com/nst/objc_dep/
|
||||
|
||||
"""
|
||||
Input: path of an Objective-C project
|
||||
|
||||
Output: import dependencies Graphviz format, unless --test is passed in which case outputs a successful exit status of 0 if no two-way dependencies are found
|
||||
|
||||
Typical usage: $ python objc_dep.py /path/to/project [-x regex] [-i subfolder [subfolder ...]] > graph.dot
|
||||
|
||||
The .dot file can be opened with Graphviz or OmniGraffle.
|
||||
|
||||
- red arrows: .pch imports
|
||||
- blue arrows: two ways imports
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from sets import Set
|
||||
import re
|
||||
from os.path import basename
|
||||
import argparse
|
||||
|
||||
local_regex_import = re.compile("^\s*#(?:import|include)\s+\"(?P<filename>\S*)(?P<extension>\.(?:h|hpp|hh))?\"")
|
||||
system_regex_import = re.compile("^\s*#(?:import|include)\s+[\"<](?P<filename>\S*)(?P<extension>\.(?:h|hpp|hh))?[\">]")
|
||||
objc_extensions = ['.h', '.hh', '.hpp', '.m', '.mm', '.c', '.cc', '.cpp']
|
||||
|
||||
def gen_filenames_imported_in_file(path, regex_exclude, system, extensions):
|
||||
for line in open(path):
|
||||
results = re.search(system_regex_import, line) if system else re.search(local_regex_import, line)
|
||||
if results:
|
||||
filename = results.group('filename')
|
||||
extension = results.group('extension') if results.group('extension') else ""
|
||||
if regex_exclude is not None and regex_exclude.search(filename + extension):
|
||||
continue
|
||||
yield (filename + extension) if extension else filename
|
||||
|
||||
def dependencies_in_project(path, ext, exclude, ignore, system, extensions):
|
||||
d = {}
|
||||
|
||||
regex_exclude = None
|
||||
if exclude:
|
||||
regex_exclude = re.compile(exclude)
|
||||
|
||||
for root, dirs, files in os.walk(path):
|
||||
|
||||
if ignore:
|
||||
for subfolder in ignore:
|
||||
if subfolder in dirs:
|
||||
dirs.remove(subfolder)
|
||||
|
||||
objc_files = (f for f in files if f.endswith(ext))
|
||||
|
||||
for f in objc_files:
|
||||
|
||||
filename = f if extensions else os.path.splitext(f)[0]
|
||||
if regex_exclude is not None and regex_exclude.search(filename):
|
||||
continue
|
||||
|
||||
if filename not in d:
|
||||
d[filename] = Set()
|
||||
|
||||
path = os.path.join(root, f)
|
||||
|
||||
for imported_filename in gen_filenames_imported_in_file(path, regex_exclude, system, extensions):
|
||||
if imported_filename != filename and '+' not in imported_filename and '+' not in filename:
|
||||
imported_filename = imported_filename if extensions else os.path.splitext(imported_filename)[0]
|
||||
d[filename].add(imported_filename)
|
||||
|
||||
return d
|
||||
|
||||
def dependencies_in_project_with_file_extensions(path, exts, exclude, ignore, system, extensions, root_class):
|
||||
|
||||
d = {}
|
||||
|
||||
for ext in exts:
|
||||
d2 = dependencies_in_project(path, ext, exclude, ignore, system, extensions)
|
||||
for (k, v) in d2.iteritems():
|
||||
if not k in d:
|
||||
d[k] = Set()
|
||||
d[k] = d[k].union(v)
|
||||
|
||||
if root_class:
|
||||
def parse_requirements(tree, root, known_deps=[]):
|
||||
next_deps = list(tree[root])
|
||||
new_deps = []
|
||||
|
||||
for dep in next_deps:
|
||||
if dep not in known_deps and dep in tree:
|
||||
new_deps += parse_requirements(tree, dep, known_deps + next_deps)
|
||||
|
||||
return (new_deps + next_deps)
|
||||
|
||||
requirements = set(parse_requirements(d, root_class))
|
||||
|
||||
return { k: d[k] for k in requirements if k in d}
|
||||
|
||||
return d
|
||||
|
||||
def two_ways_dependencies(d):
|
||||
|
||||
two_ways = Set()
|
||||
|
||||
# d is {'a1':[b1, b2], 'a2':[b1, b3, b4], ...}
|
||||
|
||||
for a, l in d.iteritems():
|
||||
for b in l:
|
||||
if b in d and a in d[b]:
|
||||
if (a, b) in two_ways or (b, a) in two_ways:
|
||||
continue
|
||||
if a != b:
|
||||
two_ways.add((a, b))
|
||||
|
||||
return two_ways
|
||||
|
||||
def untraversed_files(d):
|
||||
|
||||
dead_ends = Set()
|
||||
|
||||
for file_a, file_a_dependencies in d.iteritems():
|
||||
for file_b in file_a_dependencies:
|
||||
if not file_b in dead_ends and not file_b in d:
|
||||
dead_ends.add(file_b)
|
||||
|
||||
return dead_ends
|
||||
|
||||
def category_files(d):
|
||||
d2 = {}
|
||||
l = []
|
||||
|
||||
for k, v in d.iteritems():
|
||||
if not v and '+' in k:
|
||||
l.append(k)
|
||||
else:
|
||||
d2[k] = v
|
||||
|
||||
return l, d2
|
||||
|
||||
def referenced_classes_from_dict(d):
|
||||
d2 = {}
|
||||
|
||||
for k, deps in d.iteritems():
|
||||
for x in deps:
|
||||
d2.setdefault(x, Set())
|
||||
d2[x].add(k)
|
||||
|
||||
return d2
|
||||
|
||||
def print_frequencies_chart(d):
|
||||
|
||||
lengths = map(lambda x:len(x), d.itervalues())
|
||||
if not lengths: return
|
||||
max_length = max(lengths)
|
||||
|
||||
for i in range(0, max_length+1):
|
||||
s = "%2d | %s\n" % (i, '*'*lengths.count(i))
|
||||
sys.stderr.write(s)
|
||||
|
||||
sys.stderr.write("\n")
|
||||
|
||||
l = [Set() for i in range(max_length+1)]
|
||||
for k, v in d.iteritems():
|
||||
l[len(v)].add(k)
|
||||
|
||||
for i in range(0, max_length+1):
|
||||
s = "%2d | %s\n" % (i, ", ".join(sorted(list(l[i]))))
|
||||
sys.stderr.write(s)
|
||||
|
||||
def dependencies_in_dot_format(path, exclude, ignore, system, extensions, root_class):
|
||||
|
||||
d = dependencies_in_project_with_file_extensions(path, objc_extensions, exclude, ignore, system, extensions, root_class)
|
||||
|
||||
two_ways_set = two_ways_dependencies(d)
|
||||
untraversed_set = untraversed_files(d)
|
||||
|
||||
category_list, d = category_files(d)
|
||||
|
||||
pch_set = dependencies_in_project(path, '.pch', exclude, ignore, system, extensions)
|
||||
|
||||
#
|
||||
|
||||
sys.stderr.write("# number of imports\n\n")
|
||||
print_frequencies_chart(d)
|
||||
|
||||
sys.stderr.write("\n# times the class is imported\n\n")
|
||||
d2 = referenced_classes_from_dict(d)
|
||||
print_frequencies_chart(d2)
|
||||
|
||||
#
|
||||
|
||||
l = []
|
||||
l.append("digraph G {")
|
||||
l.append("\tnode [shape=box];")
|
||||
|
||||
for k, deps in d.iteritems():
|
||||
if deps:
|
||||
deps.discard(k)
|
||||
|
||||
if len(deps) == 0:
|
||||
l.append("\t\"%s\" -> {};" % (k))
|
||||
|
||||
for k2 in deps:
|
||||
if not ((k, k2) in two_ways_set or (k2, k) in two_ways_set):
|
||||
l.append("\t\"%s\" -> \"%s\";" % (k, k2))
|
||||
|
||||
l.append("\t")
|
||||
for (k, v) in pch_set.iteritems():
|
||||
l.append("\t\"%s\" [color=red];" % k)
|
||||
for x in v:
|
||||
l.append("\t\"%s\" -> \"%s\" [color=red];" % (k, x))
|
||||
|
||||
l.append("\t")
|
||||
l.append("\tedge [color=blue, dir=both];")
|
||||
|
||||
for (k, k2) in two_ways_set:
|
||||
l.append("\t\"%s\" -> \"%s\";" % (k, k2))
|
||||
|
||||
for k in untraversed_set:
|
||||
l.append("\t\"%s\" [color=gray, style=dashed, fontcolor=gray]" % k)
|
||||
|
||||
if category_list:
|
||||
l.append("\t")
|
||||
l.append("\tedge [color=black];")
|
||||
l.append("\tnode [shape=plaintext];")
|
||||
l.append("\t\"Categories\" [label=\"%s\"];" % "\\n".join(category_list))
|
||||
|
||||
if ignore:
|
||||
l.append("\t")
|
||||
l.append("\tnode [shape=box, color=blue];")
|
||||
l.append("\t\"Ignored\" [label=\"%s\"];" % "\\n".join(ignore))
|
||||
|
||||
l.append("}\n")
|
||||
return '\n'.join(l)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-x", "--exclude", nargs='?', default='' ,help="regular expression of substrings to exclude from module names")
|
||||
parser.add_argument("-i", "--ignore", nargs='*', help="list of subfolder names to ignore")
|
||||
parser.add_argument("-s", "--system", action='store_true', default=False, help="include system dependencies")
|
||||
parser.add_argument("-e", "--extensions", action='store_true', default=False, help="print file extensions")
|
||||
parser.add_argument("-r", "--root", default='', help="Class to use as root of dependency graph")
|
||||
parser.add_argument("-t", "--test", action='store_true', default=False, help="Exit with a success status of 0 if no two-way dependencies exist or failure otherwise, instead of outputting a graph")
|
||||
parser.add_argument("project_path", help="path to folder hierarchy containing Objective-C files")
|
||||
args= parser.parse_args()
|
||||
|
||||
if not args.test:
|
||||
print dependencies_in_dot_format(args.project_path, args.exclude, args.ignore, args.system, args.extensions, args.root)
|
||||
else:
|
||||
# Test if two-way dependencies exist. If none do, then exit on success (0), otherwise exit on failure (1)
|
||||
d = dependencies_in_project_with_file_extensions(args.project_path, objc_extensions, args.exclude, args.ignore, args.system, args.extensions, args.root)
|
||||
two_ways_set = two_ways_dependencies(d)
|
||||
|
||||
if len(two_ways_set) == 0:
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.stderr.write("Error: Found two way dependencies:\n")
|
||||
for (k, k2) in two_ways_set:
|
||||
sys.stderr.write("%s <-> %s\n" % (k, k2))
|
||||
sys.exit(1)
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
@@ -1,3 +0,0 @@
|
||||
Source: https://github.com/nst/objc_dep/
|
||||
License: See README.md
|
||||
Commit: c73b097d8de0fbca8b9468cf25aaef398d66c68f
|
||||
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user