mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Compare commits
154
Commits
2.1.0-beta.1
...
no-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c790ae0880 | ||
|
|
b7b858dbf3 | ||
|
|
8e2107a57d | ||
|
|
631846cc82 | ||
|
|
3a99b31f37 | ||
|
|
151c256721 | ||
|
|
82b94a131d | ||
|
|
4ac6ea827a | ||
|
|
b5199e7a05 | ||
|
|
39495fd562 | ||
|
|
60568b82ba | ||
|
|
9ab2c0d58c | ||
|
|
665bba36cc | ||
|
|
1e8308116e | ||
|
|
245c6821aa | ||
|
|
ad936155fa | ||
|
|
d220346206 | ||
|
|
95f8e7e0cf | ||
|
|
362f50a8a1 | ||
|
|
87697ce10f | ||
|
|
da75bb432e | ||
|
|
fde8f0a35e | ||
|
|
06edf5695d | ||
|
|
ffc203b89a | ||
|
|
348c3a9658 | ||
|
|
077d7228ba | ||
|
|
be7f6952c2 | ||
|
|
91b8f4eaa0 | ||
|
|
cc90026ade | ||
|
|
68d539ce83 | ||
|
|
8154b1eab3 | ||
|
|
14e4a98b69 | ||
|
|
f36c34f2f4 | ||
|
|
bdc095bf3a | ||
|
|
8cd13b0cfd | ||
|
|
89e2f94872 | ||
|
|
a6536ea8f1 | ||
|
|
df313f7f59 | ||
|
|
f06ccf2711 | ||
|
|
ef9398ab32 | ||
|
|
8ac92e3ffa | ||
|
|
2a98381dfe | ||
|
|
9b4c91bc58 | ||
|
|
a7855eabe6 | ||
|
|
f86907c13c | ||
|
|
028e4c2bec | ||
|
|
891cd38eba | ||
|
|
a208bd5cf9 | ||
|
|
005392963f | ||
|
|
83cc66b988 | ||
|
|
a93317fb08 | ||
|
|
1b1a7db1ac | ||
|
|
d9c0cc7f53 | ||
|
|
7d68f8f7ae | ||
|
|
03f2452379 | ||
|
|
fc8000471b | ||
|
|
6c0e685063 | ||
|
|
c7c8b719cb | ||
|
|
4fa7b23f09 | ||
|
|
f1fe9e45f6 | ||
|
|
679cbc8652 | ||
|
|
6ef1f7fc7f | ||
|
|
6831a35e28 | ||
|
|
1c560652e7 | ||
|
|
863f85b5f5 | ||
|
|
f46ea87380 | ||
|
|
f5d4ad52ca | ||
|
|
926c47d48e | ||
|
|
fbfcec3453 | ||
|
|
8f77f066c1 | ||
|
|
47f335614a | ||
|
|
80a5b80ade | ||
|
|
e81ccbd891 | ||
|
|
dc2e1ff534 | ||
|
|
37ef179284 | ||
|
|
6a69f26dcc | ||
|
|
4cb6719c6b | ||
|
|
2c81393ec2 | ||
|
|
983d19580b | ||
|
|
6cbe8444a0 | ||
|
|
45a9099082 | ||
|
|
aa72b3f639 | ||
|
|
372f0504a5 | ||
|
|
470296a90e | ||
|
|
242ae2c392 | ||
|
|
059ce91287 | ||
|
|
cc0007de3a | ||
|
|
fe69cab530 | ||
|
|
14e511f901 | ||
|
|
80e60279ee | ||
|
|
c1bf68f91f | ||
|
|
4622061d8f | ||
|
|
a7e5320d6a | ||
|
|
90221e7a0f | ||
|
|
7c1cc5627b | ||
|
|
bececc3738 | ||
|
|
a6984d3c02 | ||
|
|
102c4a4009 | ||
|
|
d2fd9a50e0 | ||
|
|
d544d456e0 | ||
|
|
b1f6c161d1 | ||
|
|
06daa03196 | ||
|
|
e64b7649f2 | ||
|
|
220c1edac1 | ||
|
|
e866f8d786 | ||
|
|
2b6664cd8a | ||
|
|
a913fe1355 | ||
|
|
24b072c661 | ||
|
|
2ddef5179e | ||
|
|
308ba94373 | ||
|
|
9a1142a5b1 | ||
|
|
4cb4974107 | ||
|
|
5343305e3f | ||
|
|
72c866f964 | ||
|
|
6808a94dbb | ||
|
|
38ed86dad0 | ||
|
|
15e8270291 | ||
|
|
d7942768b8 | ||
|
|
f126876d35 | ||
|
|
9080bebc88 | ||
|
|
bf6dc6210f | ||
|
|
04d3c13043 | ||
|
|
a33bae7bad | ||
|
|
b3d31d254e | ||
|
|
024eec0b09 | ||
|
|
9ba73525b0 | ||
|
|
7ced6efba0 | ||
|
|
fabd3e6c7b | ||
|
|
58fa11ce04 | ||
|
|
503830bf24 | ||
|
|
2bc9471ed1 | ||
|
|
339e26984e | ||
|
|
9042c8dbd9 | ||
|
|
180f8975cf | ||
|
|
d5b650bae7 | ||
|
|
94719edeb3 | ||
|
|
c33a416b53 | ||
|
|
b0116ef31b | ||
|
|
c0cf32c2b7 | ||
|
|
f250bead4b | ||
|
|
640e988a39 | ||
|
|
183a930797 | ||
|
|
2f86c4f5fe | ||
|
|
286edd1fa2 | ||
|
|
242ba4e5c4 | ||
|
|
8edc77fdb2 | ||
|
|
eb938ad15a | ||
|
|
18c751eaf9 | ||
|
|
94b48c45e7 | ||
|
|
e8fea3481a | ||
|
|
8ea4d705f5 | ||
|
|
ac2ef612bc | ||
|
|
84252a64f8 | ||
|
|
930ea303fd |
No files matched your search
@@ -1,11 +1,24 @@
|
||||
---
|
||||
name: Enhancements and Bug Fixes
|
||||
about: Found a bug? Want to implement a new feature?
|
||||
about: Found a bug? Want to implement a new feature? Something else?
|
||||
title: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
If this is a question or an idea, please consider posting in Discussions first:
|
||||
https://github.com/sparkle-project/Sparkle/discussions
|
||||
|
||||
Otherwise the answer to your issue may already be in Console.app on your computer.
|
||||
Please use Console.app and search for Sparkle.
|
||||
|
||||
Please try troubleshooting steps:
|
||||
https://github.com/sparkle-project/Sparkle#troubleshooting
|
||||
|
||||
-->
|
||||
|
||||
## Summary
|
||||
|
||||
[provide general summary to the issue or enhancement and its rationale]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Sparkle 2.x doesn't work in my app
|
||||
about: Problems with using the beta version of Sparkle 2
|
||||
about: Problems with integration, unexpected errors using Sparkle 2
|
||||
title: ''
|
||||
labels: '2.x'
|
||||
assignees: ''
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Sparkle 1.x doesn't work in my app
|
||||
about: Problems with integration, unexpected errors
|
||||
about: Problems with integration, unexpected errors using Sparkle 1
|
||||
title: ''
|
||||
labels: '1.x'
|
||||
assignees: ''
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
## Misc Checklist:
|
||||
## Misc Checklist
|
||||
|
||||
- [ ] My change requires a documentation update on [Sparkle's website repository](https://github.com/sparkle-project/sparkle-project.github.io)
|
||||
- [ ] My change requires changes to generate_appcast, generate_keys, or sign_update
|
||||
|
||||
@@ -10,19 +10,21 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['xcode12.5.1', 'xcode13.2.1']
|
||||
xcode: ['xcode14.2', 'xcode13.4.1']
|
||||
include:
|
||||
- xcode: 'xcode12.5.1'
|
||||
xcode-path: '/Applications/Xcode_12.5.1.app/Contents/Developer'
|
||||
- xcode: 'xcode13.4.1'
|
||||
xcode-path: '/Applications/Xcode_13.4.1.app/Contents/Developer'
|
||||
upload-dist: false
|
||||
run-analyzer: false
|
||||
- xcode: 'xcode13.2.1'
|
||||
xcode-path: '/Applications/Xcode_13.2.1.app/Contents/Developer'
|
||||
upload-dist: true
|
||||
run-analyzer: true
|
||||
macos: 'macos-12'
|
||||
- xcode: 'xcode14.2'
|
||||
xcode-path: '/Applications/Xcode_14.2.app/Contents/Developer'
|
||||
upload-dist: true
|
||||
run-analyzer: false
|
||||
macos: 'macos-12'
|
||||
|
||||
name: Build and Test Sparkle
|
||||
runs-on: macos-11
|
||||
runs-on: ${{ matrix.macos }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -2,7 +2,7 @@ name: "Create Draft Release"
|
||||
|
||||
env:
|
||||
BUILDDIR: "build"
|
||||
DEVELOPER_DIR: "/Applications/Xcode_13.2.1.app/Contents/Developer"
|
||||
DEVELOPER_DIR: "/Applications/Xcode_14.2.app/Contents/Developer"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -29,11 +29,11 @@ concurrency:
|
||||
jobs:
|
||||
release:
|
||||
name: "Publish binaries for release"
|
||||
runs-on: macos-11
|
||||
runs-on: macos-12
|
||||
|
||||
steps:
|
||||
- name: "Checkout sources"
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
@@ -90,7 +90,8 @@ jobs:
|
||||
with:
|
||||
draft: true
|
||||
prerelease: ${{ env.PRERELEASE_VERSION }}
|
||||
name: "Sparkle ${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
target_commitish: ${{ github.ref_name }}
|
||||
name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "Vendor/ed25519"]
|
||||
path = Vendor/ed25519
|
||||
url = https://github.com/orlp/ed25519
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUInstallerAgentProtocol;
|
||||
|
||||
@interface AgentConnection : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface AgentConnection : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate;
|
||||
|
||||
|
||||
@@ -16,20 +16,16 @@
|
||||
|
||||
@interface AgentConnection () <NSXPCListenerDelegate, SUInstallerAgentInitiationProtocol>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
@property (nonatomic, nullable) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic, nullable) id<SPUInstallerAgentProtocol> agent;
|
||||
@property (nonatomic, weak) id<AgentConnectionDelegate> delegate;
|
||||
@property (nonatomic) BOOL connected;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AgentConnection
|
||||
{
|
||||
NSXPCListener *_xpcListener;
|
||||
NSXPCConnection *_activeConnection;
|
||||
__weak id<AgentConnectionDelegate> _delegate;
|
||||
}
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize agent = _agent;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize connected = _connected;
|
||||
@synthesize invalidationError = _invalidationError;
|
||||
|
||||
@@ -48,23 +44,23 @@
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[_xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
self.delegate = nil;
|
||||
_delegate = nil;
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
self.activeConnection = nil;
|
||||
[_activeConnection invalidate];
|
||||
_activeConnection = nil;
|
||||
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
if (_activeConnection != nil) {
|
||||
[newConnection invalidate];
|
||||
return NO;
|
||||
}
|
||||
@@ -74,22 +70,30 @@
|
||||
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SPUInstallerAgentProtocol)];
|
||||
|
||||
self.activeConnection = newConnection;
|
||||
_activeConnection = newConnection;
|
||||
|
||||
__weak AgentConnection *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
newConnection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_activeConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.delegate agentConnectionDidInvalidate];
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_delegate agentConnectionDidInvalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[newConnection resume];
|
||||
|
||||
self.agent = newConnection.remoteObjectProxy;
|
||||
_agent = newConnection.remoteObjectProxy;
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -97,10 +101,10 @@
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.connected = YES;
|
||||
self->_connected = YES;
|
||||
|
||||
[self.delegate agentConnectionDidInitiate];
|
||||
self.delegate = nil;
|
||||
[self->_delegate agentConnectionDidInitiate];
|
||||
self->_delegate = nil;
|
||||
});
|
||||
|
||||
acknowledgement();
|
||||
@@ -109,7 +113,7 @@
|
||||
- (void)connectionWillInvalidateWithError:(NSError *)error
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.invalidationError = error;
|
||||
self->_invalidationError = error;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AppInstaller : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface AppInstaller : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName;
|
||||
|
||||
|
||||
+165
-178
@@ -32,8 +32,8 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 7ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 5ull
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 18ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 8ull
|
||||
|
||||
/**
|
||||
* Show display progress UI after a delay from starting the final part of the installation.
|
||||
@@ -43,73 +43,48 @@
|
||||
static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
@interface AppInstaller () <NSXPCListenerDelegate, SUInstallerCommunicationProtocol, AgentConnectionDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener* xpcListener;
|
||||
@property (nonatomic) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> communicator;
|
||||
@property (nonatomic) AgentConnection *agentConnection;
|
||||
@property (nonatomic) BOOL receivedUpdaterPong;
|
||||
|
||||
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||
|
||||
@property (nonatomic) SUUpdateValidator *updateValidator;
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *hostBundleIdentifier;
|
||||
@property (nonatomic, readonly) NSString *homeDirectory;
|
||||
@property (nonatomic, readonly) NSString *userName;
|
||||
@property (nonatomic) SUHost *host;
|
||||
@property (nonatomic, copy) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy) NSString *downloadName;
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
@property (nonatomic, strong) SUSignatures *signatures;
|
||||
@property (nonatomic, copy) NSString *relaunchPath;
|
||||
@property (nonatomic, copy) NSString *installationType;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||
|
||||
@property (nonatomic) id<SUInstallerProtocol> installer;
|
||||
@property (nonatomic) BOOL willCompleteInstallation;
|
||||
@property (nonatomic) BOOL receivedInstallationData;
|
||||
@property (nonatomic) BOOL finishedValidation;
|
||||
@property (nonatomic) BOOL agentInitiatedConnection;
|
||||
|
||||
@property (nonatomic) dispatch_queue_t installerQueue;
|
||||
@property (nonatomic) BOOL performedStage1Installation;
|
||||
@property (nonatomic) BOOL performedStage2Installation;
|
||||
@property (nonatomic) BOOL performedStage3Installation;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInstaller
|
||||
{
|
||||
NSXPCListener* _xpcListener;
|
||||
NSXPCConnection *_activeConnection;
|
||||
id<SUInstallerCommunicationProtocol> _communicator;
|
||||
AgentConnection *_agentConnection;
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize communicator = _communicator;
|
||||
@synthesize agentConnection = _agentConnection;
|
||||
@synthesize receivedUpdaterPong = _receivedUpdaterPong;
|
||||
@synthesize hostBundleIdentifier = _hostBundleIdentifier;
|
||||
@synthesize homeDirectory = _homeDirectory;
|
||||
@synthesize userName = _userName;
|
||||
@synthesize terminationListener = _terminationListener;
|
||||
@synthesize updateValidator = _updateValidator;
|
||||
@synthesize host = _host;
|
||||
@synthesize updateDirectoryPath = _updateDirectoryPath;
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize installationType = _installationType;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@synthesize shouldShowUI = _shouldShowUI;
|
||||
@synthesize installer = _installer;
|
||||
@synthesize willCompleteInstallation = _willCompleteInstallation;
|
||||
@synthesize receivedInstallationData = _receivedInstallationData;
|
||||
@synthesize installerQueue = _installerQueue;
|
||||
@synthesize performedStage1Installation = _performedStage1Installation;
|
||||
@synthesize performedStage2Installation = _performedStage2Installation;
|
||||
@synthesize performedStage3Installation = _performedStage3Installation;
|
||||
@synthesize finishedValidation = _finishedValidation;
|
||||
@synthesize agentInitiatedConnection = _agentInitiatedConnection;
|
||||
TerminationListener *_terminationListener;
|
||||
|
||||
SUUpdateValidator *_updateValidator;
|
||||
|
||||
NSString *_hostBundleIdentifier;
|
||||
NSString *_homeDirectory;
|
||||
NSString *_userName;
|
||||
SUHost *_host;
|
||||
NSString *_updateDirectoryPath;
|
||||
NSString *_downloadName;
|
||||
NSString *_decryptionPassword;
|
||||
SUSignatures *_signatures;
|
||||
NSString *_relaunchPath;
|
||||
NSString *_installationType;
|
||||
|
||||
id<SUInstallerProtocol> _installer;
|
||||
|
||||
dispatch_queue_t _installerQueue;
|
||||
|
||||
BOOL _shouldRelaunch;
|
||||
BOOL _shouldShowUI;
|
||||
|
||||
BOOL _receivedUpdaterPong;
|
||||
|
||||
BOOL _willCompleteInstallation;
|
||||
BOOL _receivedInstallationData;
|
||||
BOOL _finishedValidation;
|
||||
BOOL _agentInitiatedConnection;
|
||||
|
||||
BOOL _performedStage1Installation;
|
||||
BOOL _performedStage2Installation;
|
||||
BOOL _performedStage3Installation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
|
||||
{
|
||||
@@ -132,66 +107,71 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
if (_activeConnection != nil) {
|
||||
SULog(SULogLevelDefault, @"Rejecting multiple connections...");
|
||||
[newConnection invalidate];
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.activeConnection = newConnection;
|
||||
_activeConnection = newConnection;
|
||||
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
newConnection.exportedObject = self;
|
||||
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
|
||||
__weak AppInstaller *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
newConnection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_activeConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
AppInstaller *strongSelf = weakSelf;
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
if (strongSelf.activeConnection != nil && !strongSelf.willCompleteInstallation) {
|
||||
if (strongSelf->_activeConnection != nil && !strongSelf->_willCompleteInstallation) {
|
||||
[strongSelf cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Invalidation on remote port being called, and installation is not close enough to completion!" }]];
|
||||
}
|
||||
strongSelf.communicator = nil;
|
||||
strongSelf.activeConnection = nil;
|
||||
strongSelf->_communicator = nil;
|
||||
strongSelf->_activeConnection = nil;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[newConnection resume];
|
||||
|
||||
self.communicator = newConnection.remoteObjectProxy;
|
||||
_communicator = newConnection.remoteObjectProxy;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[self.agentConnection startListener];
|
||||
[_xpcListener resume];
|
||||
[_agentConnection startListener];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FIRST_UPDATER_MESSAGE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.receivedInstallationData) {
|
||||
if (!self->_receivedInstallationData) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: installation data was never received" }]];
|
||||
}
|
||||
|
||||
if (!self.agentConnection.connected) {
|
||||
if (!self->_agentConnection.connected) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: agent connection was never initiated" }]];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)extractAndInstallUpdate
|
||||
- (void)extractAndInstallUpdate SPU_OBJC_DIRECT
|
||||
{
|
||||
[self.communicator handleMessageWithIdentifier:SPUExtractionStarted data:[NSData data]];
|
||||
[_communicator handleMessageWithIdentifier:SPUExtractionStarted data:[NSData data]];
|
||||
|
||||
NSString *archivePath = [self.updateDirectoryPath stringByAppendingPathComponent:self.downloadName];
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:self.host.bundlePath decryptionPassword:self.decryptionPassword expectingInstallationType:self.installationType];
|
||||
NSString *archivePath = [_updateDirectoryPath stringByAppendingPathComponent:_downloadName];
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:_host.bundlePath decryptionPassword:_decryptionPassword expectingInstallationType:_installationType];
|
||||
|
||||
NSError *unarchiverError = nil;
|
||||
BOOL success = NO;
|
||||
@@ -200,14 +180,14 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:self.signatures host:self.host];
|
||||
_updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:_signatures host:_host];
|
||||
|
||||
// Delta & package updates will require validation before extraction
|
||||
// Normal application updates are a bit more lenient allowing developers to change one of apple dev ID or EdDSA keys
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![self.installationType isEqualToString:SPUInstallationTypeApplication];
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![_installationType isEqualToString:SPUInstallationTypeApplication];
|
||||
|
||||
if (needsPrevalidation) {
|
||||
success = [self.updateValidator validateDownloadPathWithError:&unarchiverError];
|
||||
success = [_updateValidator validateDownloadPathWithError:&unarchiverError];
|
||||
} else {
|
||||
success = YES;
|
||||
}
|
||||
@@ -221,18 +201,18 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
if (error != nil) {
|
||||
[self unarchiverDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to unarchive %@", archivePath], NSUnderlyingErrorKey: (NSError * _Nonnull)error }]];
|
||||
} else {
|
||||
[self.communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
|
||||
|
||||
NSError *validationError = nil;
|
||||
BOOL validationSuccess = [self.updateValidator validateWithUpdateDirectory:self.updateDirectoryPath error:&validationError];
|
||||
BOOL validationSuccess = [self->_updateValidator validateWithUpdateDirectory:self->_updateDirectoryPath error:&validationError];
|
||||
|
||||
if (!validationSuccess) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Update validation was a failure", NSUnderlyingErrorKey: validationError }]];
|
||||
} else {
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationStartedStage1 data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationStartedStage1 data:[NSData data]];
|
||||
|
||||
self.finishedValidation = YES;
|
||||
if (self.agentInitiatedConnection) {
|
||||
self->_finishedValidation = YES;
|
||||
if (self->_agentInitiatedConnection) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
@@ -243,60 +223,60 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
uint64_t progressValue = CFSwapInt64HostToLittle(*(uint64_t *)&progress);
|
||||
NSData *data = [NSData dataWithBytes:&progressValue length:sizeof(progressValue)];
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUExtractedArchiveWithProgress data:data];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUExtractedArchiveWithProgress data:data];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearUpdateDirectory
|
||||
- (void)clearUpdateDirectory SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.updateDirectoryPath != nil) {
|
||||
if (_updateDirectoryPath != nil) {
|
||||
NSError *theError = nil;
|
||||
if (![[[SUFileManager alloc] init] removeItemAtURL:[NSURL fileURLWithPath:self.updateDirectoryPath] error:&theError]) {
|
||||
if (![[[SUFileManager alloc] init] removeItemAtURL:[NSURL fileURLWithPath:_updateDirectoryPath] error:&theError]) {
|
||||
SULog(SULogLevelError, @"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
self.updateDirectoryPath = nil;
|
||||
_updateDirectoryPath = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFailWithError:(NSError *)error
|
||||
- (void)unarchiverDidFailWithError:(NSError *)error SPU_OBJC_DIRECT
|
||||
{
|
||||
SULog(SULogLevelError, @"Failed to unarchive file");
|
||||
SULogError(error);
|
||||
|
||||
// No longer need update validator until next possible extraction (eg: if initial delta update fails)
|
||||
self.updateValidator = nil;
|
||||
_updateValidator = nil;
|
||||
|
||||
// Client could try update again with different inputs
|
||||
// Eg: one common case is if a delta update fails, client may want to fall back to regular update
|
||||
// We really only need to set updateDirectoryPath to nil since that's the field we check if we've received installation data,
|
||||
// but may as well set other fields to nil too
|
||||
[self clearUpdateDirectory];
|
||||
self.downloadName = nil;
|
||||
self.decryptionPassword = nil;
|
||||
self.signatures = nil;
|
||||
self.relaunchPath = nil;
|
||||
self.host = nil;
|
||||
_downloadName = nil;
|
||||
_decryptionPassword = nil;
|
||||
_signatures = nil;
|
||||
_relaunchPath = nil;
|
||||
_host = nil;
|
||||
|
||||
NSData *archivedError = SPUArchiveRootObjectSecurely(error);
|
||||
[self.communicator handleMessageWithIdentifier:SPUArchiveExtractionFailed data:archivedError != nil ? archivedError : [NSData data]];
|
||||
[_communicator handleMessageWithIdentifier:SPUArchiveExtractionFailed data:archivedError != nil ? archivedError : [NSData data]];
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInitiate
|
||||
{
|
||||
self.agentInitiatedConnection = YES;
|
||||
if (self.finishedValidation) {
|
||||
_agentInitiatedConnection = YES;
|
||||
if (_finishedValidation) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInvalidate
|
||||
{
|
||||
if (!self.finishedValidation || !self.agentInitiatedConnection) {
|
||||
if (!_finishedValidation || !_agentInitiatedConnection) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Error: Agent connection invalidated before installation began" }];
|
||||
|
||||
NSError *agentError = self.agentConnection.invalidationError;
|
||||
NSError *agentError = _agentConnection.invalidationError;
|
||||
if (agentError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = agentError;
|
||||
}
|
||||
@@ -305,21 +285,21 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)retrieveProcessIdentifierAndStartInstallation
|
||||
- (void)retrieveProcessIdentifierAndStartInstallation SPU_OBJC_DIRECT
|
||||
{
|
||||
// We use the relaunch path for the bundle to listen for termination instead of the host path
|
||||
// For a plug-in this makes a big difference; we want to wait until the app hosting the plug-in terminates
|
||||
// Otherwise for an app, the relaunch path and host path should be identical
|
||||
|
||||
[self.agentConnection.agent registerApplicationBundlePath:self.relaunchPath reply:^(NSNumber * _Nullable processIdentifier) {
|
||||
[_agentConnection.agent registerApplicationBundlePath:_relaunchPath reply:^(NSNumber * _Nullable processIdentifier) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
self->_terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
[self startInstallation];
|
||||
});
|
||||
}];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (self.terminationListener == nil) {
|
||||
if (self->_terminationListener == nil) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout error: failed to retreive process identifier from agent" }]];
|
||||
}
|
||||
});
|
||||
@@ -327,11 +307,11 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
{
|
||||
if (identifier == SPUInstallationData && self.updateDirectoryPath == nil) {
|
||||
if (identifier == SPUInstallationData && _updateDirectoryPath == nil) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Mark that we have received the installation data
|
||||
// Do not rely on eg: self.updateDirectoryPath != nil because we may set it to nil again if an early stage fails (i.e, archive extraction)
|
||||
self.receivedInstallationData = YES;
|
||||
// Do not rely on eg: self->_updateDirectoryPath != nil because we may set it to nil again if an early stage fails (i.e, archive extraction)
|
||||
self->_receivedInstallationData = YES;
|
||||
|
||||
SPUInstallationInputData *installationData = (SPUInstallationInputData *)SPUUnarchiveRootObjectSecurely(data, [SPUInstallationInputData class]);
|
||||
if (installationData == nil) {
|
||||
@@ -348,8 +328,8 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:installationData.hostBundlePath];
|
||||
|
||||
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self.hostBundleIdentifier]) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to match host bundle identifiers %@ and %@", self.hostBundleIdentifier, bundleIdentifier] }]];
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self->_hostBundleIdentifier]) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to match host bundle identifiers %@ and %@", self->_hostBundleIdentifier, bundleIdentifier] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -407,23 +387,23 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
// Carry these properities separately rather than using the SUInstallationInputData object
|
||||
// Some of our properties may slightly differ than our input and we don't want to make the mistake of using one of those
|
||||
self.installationType = installationType;
|
||||
self.relaunchPath = installationData.relaunchPath;
|
||||
self.downloadName = installationData.downloadName;
|
||||
self.signatures = installationData.signatures;
|
||||
self.updateDirectoryPath = cacheInstallationPath;
|
||||
self.host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
self->_installationType = installationType;
|
||||
self->_relaunchPath = installationData.relaunchPath;
|
||||
self->_downloadName = installationData.downloadName;
|
||||
self->_signatures = installationData.signatures;
|
||||
self->_updateDirectoryPath = cacheInstallationPath;
|
||||
self->_host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
|
||||
[self extractAndInstallUpdate];
|
||||
});
|
||||
} else if (identifier == SPUSentUpdateAppcastItemData) {
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SPUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
|
||||
if (updateItem != nil) {
|
||||
SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[self.installer canInstallSilently]];
|
||||
SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[_installer canInstallSilently]];
|
||||
|
||||
NSData *archivedData = SPUArchiveRootObjectSecurely(installationInfo);
|
||||
if (archivedData != nil) {
|
||||
[self.agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
[_agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
}
|
||||
}
|
||||
} else if (identifier == SPUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
|
||||
@@ -433,14 +413,23 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// This flag has an impact on interactive type installations and showing UI progress during non-interactive installations
|
||||
self.shouldShowUI = (BOOL)showsUI;
|
||||
self->_shouldShowUI = (BOOL)showsUI;
|
||||
// Don't test if the application was alive initially, leave that to the progress agent if we decide to relaunch
|
||||
self.shouldRelaunch = (BOOL)relaunch;
|
||||
self->_shouldRelaunch = (BOOL)relaunch;
|
||||
|
||||
if (self.performedStage1Installation) {
|
||||
if (self->_performedStage1Installation) {
|
||||
// Resume the installation if we aren't done with stage 2 yet, and remind the client we are prepared to relaunch
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
[self performStage2InstallationIfNeeded];
|
||||
dispatch_async(self->_installerQueue, ^{
|
||||
if (!self->_performedStage2Installation) {
|
||||
[self performStage2Installation];
|
||||
} else if (!self->_performedStage3Installation) {
|
||||
// If we already performed the 2nd stage, re-purpose this request to re-try sending another termination signal
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Don't check if the target is already terminated, leave that to the progress agent
|
||||
// We could be slightly off if there were multiple instances running
|
||||
[self->_agentConnection.agent sendTerminationSignal];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -449,19 +438,19 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
[self cleanupAndExitWithStatus:0 error:nil];
|
||||
});
|
||||
} else if (identifier == SPUUpdaterAlivePong) {
|
||||
self.receivedUpdaterPong = YES;
|
||||
_receivedUpdaterPong = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startInstallation
|
||||
- (void)startInstallation SPU_OBJC_DIRECT
|
||||
{
|
||||
self.willCompleteInstallation = YES;
|
||||
_willCompleteInstallation = YES;
|
||||
|
||||
self.installerQueue = dispatch_queue_create("org.sparkle-project.sparkle.installer", DISPATCH_QUEUE_SERIAL);
|
||||
_installerQueue = dispatch_queue_create("org.sparkle-project.sparkle.installer", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
dispatch_async(_installerQueue, ^{
|
||||
NSError *installerError = nil;
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self.host expectedInstallationType:self.installationType updateDirectory:self.updateDirectoryPath homeDirectory:self.homeDirectory userName:self.userName error:&installerError];
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self->_host expectedInstallationType:self->_installationType updateDirectory:self->_updateDirectoryPath homeDirectory:self->_homeDirectory userName:self->_userName error:&installerError];
|
||||
|
||||
if (installer == nil) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -472,7 +461,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
NSError *firstStageError = nil;
|
||||
if (![installer performInitialInstallation:&firstStageError]) {
|
||||
self.installer = nil;
|
||||
self->_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to start installer", NSUnderlyingErrorKey: firstStageError }]];
|
||||
@@ -483,17 +472,17 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
uint8_t canPerformSilentInstall = (uint8_t)[installer canInstallSilently];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.installer = installer;
|
||||
self->_installer = installer;
|
||||
|
||||
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
|
||||
uint8_t targetTerminated = (uint8_t)self->_terminationListener.terminated;
|
||||
|
||||
uint8_t sendInformation[] = {canPerformSilentInstall, targetTerminated};
|
||||
|
||||
NSData *sendData = [NSData dataWithBytes:sendInformation length:sizeof(sendInformation)];
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData];
|
||||
|
||||
self.performedStage1Installation = YES;
|
||||
self->_performedStage1Installation = YES;
|
||||
|
||||
// Stage 2 can still be run before we finish installation
|
||||
// if the updater requests for it before the app is terminated
|
||||
@@ -502,28 +491,24 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)performStage2InstallationIfNeeded
|
||||
- (void)performStage2Installation SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.performedStage2Installation) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL performedSecondStage = self.shouldShowUI || [self.installer canInstallSilently];
|
||||
if (performedSecondStage) {
|
||||
self.performedStage2Installation = YES;
|
||||
BOOL canPerformSecondStage = _shouldShowUI || [_installer canInstallSilently];
|
||||
if (canPerformSecondStage) {
|
||||
_performedStage2Installation = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
|
||||
uint8_t targetTerminated = (uint8_t)self->_terminationListener.terminated;
|
||||
|
||||
NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)];
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData];
|
||||
|
||||
// Don't check if the target is already terminated, leave that to the progress agent
|
||||
// We could be slightly off if there were multiple instances running
|
||||
[self.agentConnection.agent sendTerminationSignal];
|
||||
[self->_agentConnection.agent sendTerminationSignal];
|
||||
});
|
||||
} else {
|
||||
self.installer = nil;
|
||||
_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to resume installer on stage 2 because installation cannot be installed silently" }]];
|
||||
@@ -531,9 +516,9 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)finishInstallationAfterHostTermination
|
||||
- (void)finishInstallationAfterHostTermination SPU_OBJC_DIRECT
|
||||
{
|
||||
[self.terminationListener startListeningWithCompletion:^(BOOL success) {
|
||||
[_terminationListener startListeningWithCompletion:^(BOOL success) {
|
||||
if (!success) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to listen for application termination" }]];
|
||||
return;
|
||||
@@ -542,36 +527,38 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
// Show our installer progress UI tool if only after a certain amount of time passes,
|
||||
// and if our installer is silent (i.e, doesn't show progress on its own)
|
||||
__block BOOL shouldShowUIProgress = YES;
|
||||
if (self.shouldShowUI && [self.installer canInstallSilently]) {
|
||||
if (self->_shouldShowUI && [self->_installer canInstallSilently]) {
|
||||
// Ask the updater if it is still alive
|
||||
// If they are, we will receive a pong response back
|
||||
// Reset if we received a pong just to be on the safe side
|
||||
self.receivedUpdaterPong = NO;
|
||||
[self.communicator handleMessageWithIdentifier:SPUUpdaterAlivePing data:[NSData data]];
|
||||
self->_receivedUpdaterPong = NO;
|
||||
[self->_communicator handleMessageWithIdentifier:SPUUpdaterAlivePing data:[NSData data]];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUDisplayProgressTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// Make sure we're still eligible for showing the installer progress
|
||||
// Also if the updater process is still alive, showing the progress should not be our duty
|
||||
// if the communicator object is nil, the updater definitely isn't alive. However, if it is not nil,
|
||||
// this does not necessarily mean the updater is alive, so we should also check if we got a recent response back from the updater
|
||||
if (shouldShowUIProgress && (!self.receivedUpdaterPong || self.communicator == nil)) {
|
||||
[self.agentConnection.agent showProgress];
|
||||
if (shouldShowUIProgress && (!self->_receivedUpdaterPong || self->_communicator == nil)) {
|
||||
[self->_agentConnection.agent showProgress];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
[self performStage2InstallationIfNeeded];
|
||||
dispatch_async(self->_installerQueue, ^{
|
||||
if (!self->_performedStage2Installation) {
|
||||
[self performStage2Installation];
|
||||
}
|
||||
|
||||
if (!self.performedStage2Installation) {
|
||||
if (!self->_performedStage2Installation) {
|
||||
// We failed and we're going to exit shortly
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *thirdStageError = nil;
|
||||
if (![self.installer performFinalInstallationProgressBlock:nil error:&thirdStageError]) {
|
||||
[self.installer performCleanup];
|
||||
self.installer = nil;
|
||||
if (![self->_installer performFinalInstallationProgressBlock:nil error:&thirdStageError]) {
|
||||
[self->_installer performCleanup];
|
||||
self->_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to finalize installation", NSUnderlyingErrorKey: thirdStageError }]];
|
||||
@@ -579,23 +566,23 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
return;
|
||||
}
|
||||
|
||||
self.performedStage3Installation = YES;
|
||||
self->_performedStage3Installation = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Make sure to stop our displayed progress before we move onto cleanup & relaunch
|
||||
// This will also stop the agent from broadcasting the status info service, which we want to do before
|
||||
// we relaunch the app because the relaunched app could check the service upon launch..
|
||||
[self.agentConnection.agent stopProgress];
|
||||
[self->_agentConnection.agent stopProgress];
|
||||
shouldShowUIProgress = NO;
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage3 data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage3 data:[NSData data]];
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
if (self->_shouldRelaunch) {
|
||||
// This will also signal to the agent that it will terminate soon
|
||||
[self.agentConnection.agent relaunchApplication];
|
||||
[self->_agentConnection.agent relaunchApplication];
|
||||
}
|
||||
|
||||
[self.installer performCleanup];
|
||||
[self->_installer performCleanup];
|
||||
|
||||
[self cleanupAndExitWithStatus:EXIT_SUCCESS error:nil];
|
||||
});
|
||||
@@ -610,20 +597,20 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
NSData *errorData = SPUArchiveRootObjectSecurely((NSError * _Nonnull)error);
|
||||
if (errorData != nil) {
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallerError data:errorData];
|
||||
[_communicator handleMessageWithIdentifier:SPUInstallerError data:errorData];
|
||||
}
|
||||
}
|
||||
|
||||
// It's nice to tell the other end we're invalidating
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
self.activeConnection = nil;
|
||||
[_activeConnection invalidate];
|
||||
_activeConnection = nil;
|
||||
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
|
||||
[self.agentConnection invalidate];
|
||||
self.agentConnection = nil;
|
||||
[_agentConnection invalidate];
|
||||
_agentConnection = nil;
|
||||
|
||||
[self clearUpdateDirectory];
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
|
||||
SPUDeltaArchiveHeader *header = [sparkleArchive readHeader];
|
||||
if (header == nil) {
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
NSError *archiveError = sparkleArchive.error;
|
||||
if (archiveError != nil && [archiveError.domain isEqualToString:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN] && archiveError.code == SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC) {
|
||||
// Retry with XAR archive if the magic value is unexpected
|
||||
@@ -35,7 +36,9 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
*outHeader = xarHeader;
|
||||
}
|
||||
return xarArchive;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (outHeader != NULL) {
|
||||
*outHeader = nil;
|
||||
}
|
||||
@@ -56,7 +59,9 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
@synthesize clonedRelativePath = _clonedRelativePath;
|
||||
@synthesize sourcePath = _sourcePath;
|
||||
@synthesize commands = _commands;
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
@synthesize xarContext = _xarContext;
|
||||
#endif
|
||||
@synthesize mode = _mode;
|
||||
@synthesize codedDataLength = _codedDataLength;
|
||||
|
||||
@@ -81,16 +86,18 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
|
||||
@synthesize compression = _compression;
|
||||
@synthesize compressionLevel = _compressionLevel;
|
||||
@synthesize fileSystemCompression = _fileSystemCompression;
|
||||
@synthesize majorVersion = _majorVersion;
|
||||
@synthesize minorVersion = _minorVersion;
|
||||
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_compression = compression;
|
||||
_compressionLevel = compressionLevel;
|
||||
_fileSystemCompression = fileSystemCompression;
|
||||
|
||||
_majorVersion = majorVersion;
|
||||
_minorVersion = minorVersion;
|
||||
@@ -101,9 +108,6 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
- (unsigned char *)beforeTreeHash
|
||||
{
|
||||
return _beforeTreeHash;
|
||||
@@ -114,6 +118,4 @@ id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFil
|
||||
return _afterTreeHash;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
@@ -24,12 +24,13 @@ typedef NS_ENUM(uint8_t, SPUDeltaItemCommands) {
|
||||
};
|
||||
|
||||
// Represents header for our archive
|
||||
@interface SPUDeltaArchiveHeader : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveHeader : NSObject
|
||||
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash;
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash;
|
||||
|
||||
@property (nonatomic, readonly) SPUDeltaCompressionMode compression;
|
||||
@property (nonatomic, readonly) uint8_t compressionLevel;
|
||||
@property (nonatomic, readonly) bool fileSystemCompression;
|
||||
@property (nonatomic, readonly) uint16_t majorVersion;
|
||||
@property (nonatomic, readonly) uint16_t minorVersion;
|
||||
@property (nonatomic, readonly) unsigned char *beforeTreeHash;
|
||||
@@ -38,7 +39,7 @@ typedef NS_ENUM(uint8_t, SPUDeltaItemCommands) {
|
||||
@end
|
||||
|
||||
// Represents an item we read or write to in our delta archive
|
||||
@interface SPUDeltaArchiveItem : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveItem : NSObject
|
||||
|
||||
- (instancetype)initWithRelativeFilePath:(NSString *)relativeFilePath commands:(SPUDeltaItemCommands)commands mode:(uint16_t)mode;
|
||||
|
||||
@@ -57,8 +58,10 @@ typedef NS_ENUM(uint8_t, SPUDeltaItemCommands) {
|
||||
@property (nonatomic) uint16_t mode;
|
||||
|
||||
// Private properties
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
// xar_file context for Xar delta archiver
|
||||
@property (nonatomic, nullable) const void *xarContext;
|
||||
#endif
|
||||
// Tracking length of item's data in data section, when encoding items and when extracting items
|
||||
@property (nonatomic) uint64_t codedDataLength;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
|
||||
@interface SPUInstallationInfo : NSObject <NSSecureCoding>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInfo : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentyInstall;
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ static NSString *SUSystemDomainKey = @"SUSystemDomain";
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.appcastItem forKey:SUAppcastItemKey];
|
||||
[coder encodeBool:self.canSilentlyInstall forKey:SUCanSilentlyInstallKey];
|
||||
[coder encodeBool:self.systemDomain forKey:SUSystemDomainKey];
|
||||
[coder encodeObject:_appcastItem forKey:SUAppcastItemKey];
|
||||
[coder encodeBool:_canSilentlyInstall forKey:SUCanSilentlyInstallKey];
|
||||
[coder encodeBool:_systemDomain forKey:SUSystemDomainKey];
|
||||
}
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUInstallationInputData : NSObject <NSSecureCoding>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInputData : NSObject <NSSecureCoding>
|
||||
|
||||
/*
|
||||
* relaunchPath - path to application bundle to relaunch and listen for termination
|
||||
|
||||
@@ -87,14 +87,14 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.relaunchPath forKey:SURelaunchPathKey];
|
||||
[coder encodeObject:self.hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:self.installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:self.signatures forKey:SUSignaturesKey];
|
||||
if (self.decryptionPassword != nil) {
|
||||
[coder encodeObject:self.decryptionPassword forKey:SUDecryptionPasswordKey];
|
||||
[coder encodeObject:_relaunchPath forKey:SURelaunchPathKey];
|
||||
[coder encodeObject:_hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:_updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:_installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:_downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:_signatures forKey:SUSignaturesKey];
|
||||
if (_decryptionPassword != nil) {
|
||||
[coder encodeObject:_decryptionPassword forKey:SUDecryptionPasswordKey];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[ HEADER (part 1) ]
|
||||
magic (length: 4)
|
||||
compression (length: 1)
|
||||
compressionLevel (length: 1)
|
||||
metadata (See format below. length: 1)
|
||||
|
||||
-- METADATA --
|
||||
compressionLevel (bits [0, 4])
|
||||
(bits [5, 6] reserved)
|
||||
fileSystemCompression (bit 7)
|
||||
|
||||
-- COMPRESSED --
|
||||
|
||||
@@ -92,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
(P number of blobs where P <= M commands)
|
||||
(Indexes for data blobs correspond to indexes for a filtered list of applicable commands (EXTRACT_FILE, BINARY_DIFF_FILE) that have data content)
|
||||
*/
|
||||
@interface SPUSparkleDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUSparkleDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile;
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile;
|
||||
|
||||
+196
-168
@@ -7,12 +7,15 @@
|
||||
//
|
||||
|
||||
#import "SPUSparkleDeltaArchive.h"
|
||||
#import <bzlib.h>
|
||||
#import <sys/stat.h>
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import <compression.h>
|
||||
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
#import <bzlib.h>
|
||||
#endif
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#define SPARKLE_DELTA_FORMAT_MAGIC "spk!"
|
||||
@@ -21,39 +24,33 @@
|
||||
#define SPARKLE_BZIP2_ERROR_DOMAIN @"Sparkle BZIP2"
|
||||
#define SPARKLE_COMPRESSION_ERROR_DOMAIN @"Sparkle Compression"
|
||||
|
||||
@interface SPUSparkleDeltaArchive ()
|
||||
|
||||
@property (nonatomic) FILE *file;
|
||||
@property (nonatomic) BZFILE *bzipFile;
|
||||
@property (nonatomic) compression_stream compressionStream;
|
||||
@property (nonatomic) BOOL initializedCompressionStream;
|
||||
@property (nonatomic, readonly) NSString *patchFile;
|
||||
@property (nonatomic) SPUDeltaCompressionMode compression;
|
||||
@property (nonatomic, readonly) BOOL writeMode;
|
||||
@property (nonatomic) NSError *error;
|
||||
@property (nonatomic) void *partialChunkBuffer;
|
||||
@property (nonatomic) void *compressionBuffer;
|
||||
|
||||
@property (nonatomic) NSMutableArray<SPUDeltaArchiveItem *> *writableItems;
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
typedef struct
|
||||
{
|
||||
uint8_t compressionLevel : 4;
|
||||
uint8_t reserved : 3;
|
||||
bool fileSystemCompression : 1;
|
||||
} SparkleDeltaArchiveMetadata;
|
||||
|
||||
@implementation SPUSparkleDeltaArchive
|
||||
{
|
||||
FILE *_file;
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
BZFILE *_bzipFile;
|
||||
#endif
|
||||
NSString *_patchFile;
|
||||
NSError *_error;
|
||||
void *_partialChunkBuffer;
|
||||
void *_compressionBuffer;
|
||||
NSMutableArray<SPUDeltaArchiveItem *> *_writableItems;
|
||||
|
||||
compression_stream _compressionStream;
|
||||
SPUDeltaCompressionMode _compression;
|
||||
|
||||
BOOL _initializedCompressionStream;
|
||||
BOOL _writeMode;
|
||||
}
|
||||
|
||||
@synthesize file = _file;
|
||||
@synthesize bzipFile = _bzipFile;
|
||||
@synthesize compressionStream = _compressionStream;
|
||||
@synthesize initializedCompressionStream = _initializedCompressionStream;
|
||||
@synthesize patchFile = _patchFile;
|
||||
@synthesize compression = _compression;
|
||||
@synthesize writeMode = _writeMode;
|
||||
@synthesize writableItems = _writableItems;
|
||||
@synthesize error = _error;
|
||||
@synthesize partialChunkBuffer = _partialChunkBuffer;
|
||||
@synthesize compressionBuffer = _compressionBuffer;
|
||||
|
||||
+ (BOOL)maySupportSafeExtraction
|
||||
{
|
||||
@@ -87,42 +84,45 @@
|
||||
|
||||
- (void)close
|
||||
{
|
||||
if (self.bzipFile != NULL) {
|
||||
if (!self.writeMode) {
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
if (_bzipFile != NULL) {
|
||||
if (!_writeMode) {
|
||||
int bzerror = 0;
|
||||
BZ2_bzReadClose(&bzerror, self.bzipFile);
|
||||
BZ2_bzReadClose(&bzerror, _bzipFile);
|
||||
}
|
||||
|
||||
self.bzipFile = NULL;
|
||||
} else if (self.initializedCompressionStream) {
|
||||
_bzipFile = NULL;
|
||||
} else
|
||||
#endif
|
||||
if (_initializedCompressionStream) {
|
||||
compression_stream_destroy(&_compressionStream);
|
||||
self.initializedCompressionStream = NO;
|
||||
_initializedCompressionStream = NO;
|
||||
}
|
||||
|
||||
if (self.file != NULL) {
|
||||
fclose(self.file);
|
||||
self.file = NULL;
|
||||
if (_file != NULL) {
|
||||
fclose(_file);
|
||||
_file = NULL;
|
||||
}
|
||||
|
||||
free(self.partialChunkBuffer);
|
||||
self.partialChunkBuffer = NULL;
|
||||
free(_partialChunkBuffer);
|
||||
_partialChunkBuffer = NULL;
|
||||
|
||||
free(self.compressionBuffer);
|
||||
self.compressionBuffer = NULL;
|
||||
free(_compressionBuffer);
|
||||
_compressionBuffer = NULL;
|
||||
}
|
||||
|
||||
- (BOOL)createBuffers
|
||||
- (BOOL)createBuffers SPU_OBJC_DIRECT
|
||||
{
|
||||
self.partialChunkBuffer = calloc(1, PARTIAL_IO_CHUNK_SIZE);
|
||||
if (self.partialChunkBuffer == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %d bytes for partial chunk buffer.", PARTIAL_IO_CHUNK_SIZE] }];
|
||||
_partialChunkBuffer = calloc(1, PARTIAL_IO_CHUNK_SIZE);
|
||||
if (_partialChunkBuffer == NULL) {
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %d bytes for partial chunk buffer.", PARTIAL_IO_CHUNK_SIZE] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (self.initializedCompressionStream) {
|
||||
self.compressionBuffer = calloc(1, COMPRESSION_BUFFER_SIZE);
|
||||
if (self.compressionBuffer == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %d bytes for compression buffer.", COMPRESSION_BUFFER_SIZE] }];
|
||||
if (_initializedCompressionStream) {
|
||||
_compressionBuffer = calloc(1, COMPRESSION_BUFFER_SIZE);
|
||||
if (_compressionBuffer == NULL) {
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %d bytes for compression buffer.", COMPRESSION_BUFFER_SIZE] }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -130,48 +130,53 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_readBuffer:(void *)buffer length:(int32_t)length
|
||||
- (BOOL)_readBuffer:(void *)buffer length:(int32_t)length SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
switch (self.compression) {
|
||||
switch (_compression) {
|
||||
case SPUDeltaCompressionModeNone: {
|
||||
if (fread(buffer, (size_t)length, 1, self.file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d uncompressed bytes from archive.", length] }];
|
||||
if (fread(buffer, (size_t)length, 1, _file) < 1) {
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d uncompressed bytes from archive.", length] }];
|
||||
return NO;
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
case SPUDeltaCompressionModeBzip2: {
|
||||
case SPUDeltaCompressionModeBzip2:
|
||||
{
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
int bzerror = 0;
|
||||
int bytesRead = BZ2_bzRead(&bzerror, self.bzipFile, buffer, length);
|
||||
int bytesRead = BZ2_bzRead(&bzerror, _bzipFile, buffer, length);
|
||||
|
||||
switch (bzerror) {
|
||||
case BZ_OK:
|
||||
case BZ_STREAM_END:
|
||||
if (bytesRead < length) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:0 userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Only %d out of %d expected bytes were read from the bz2 archive.", bytesRead, length] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:0 userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Only %d out of %d expected bytes were read from the bz2 archive.", bytesRead, length] }];
|
||||
return NO;
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
case BZ_IO_ERROR:
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Encountered unexpected IO error when reading compressed bytes from bz2 archive." }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Encountered unexpected IO error when reading compressed bytes from bz2 archive." }];
|
||||
return NO;
|
||||
default:
|
||||
self.error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: @"Encountered unexpected error when reading compressed bytes from bz2 archive." }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: @"Encountered unexpected error when reading compressed bytes from bz2 archive." }];
|
||||
return NO;
|
||||
}
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
case SPUDeltaCompressionModeZLIB: {
|
||||
FILE *file = self.file;
|
||||
void *compressionBuffer = self.compressionBuffer;
|
||||
FILE *file = _file;
|
||||
void *compressionBuffer = _compressionBuffer;
|
||||
|
||||
_compressionStream.dst_ptr = buffer;
|
||||
_compressionStream.dst_size = (size_t)length;
|
||||
@@ -183,7 +188,7 @@
|
||||
size_t bytesRead = fread(compressionBuffer, 1, COMPRESSION_BUFFER_SIZE, file);
|
||||
if (bytesRead < COMPRESSION_BUFFER_SIZE) {
|
||||
if (feof(file) == 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d compressed raw bytes from archive.", length] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d compressed raw bytes from archive.", length] }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -195,13 +200,13 @@
|
||||
|
||||
compression_status status = compression_stream_process(&_compressionStream, feof(file) != 0 ? COMPRESSION_STREAM_FINALIZE : 0);
|
||||
if (status == COMPRESSION_STATUS_ERROR) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d compressed bytes.", length] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %d compressed bytes.", length] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (status == COMPRESSION_STATUS_END && _compressionStream.dst_size > 0) {
|
||||
// We're expecting more bytes but we can't read any more bytes
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"Failed to decompress and read bytes because we reached EOF" }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"Failed to decompress and read bytes because we reached EOF" }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -232,44 +237,44 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
- (nullable SPUDeltaArchiveHeader *)readHeader
|
||||
{
|
||||
NSString *patchFile = self.patchFile;
|
||||
NSString *patchFile = _patchFile;
|
||||
|
||||
char patchFilePath[PATH_MAX + 1] = {0};
|
||||
if (![patchFile getFileSystemRepresentation:patchFilePath maxLength:sizeof(patchFilePath) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open and represent as a file system representation: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open and represent as a file system representation: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
FILE *file = fopen(patchFilePath, "rb");
|
||||
if (file == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch file for writing value due to io error: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch file for writing value due to io error: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.file = file;
|
||||
_file = file;
|
||||
|
||||
char magic[5] = {0};
|
||||
if (fread(magic, sizeof(magic) - 1, 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read magic value from patch file: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read magic value from patch file: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (strncmp(magic, SPARKLE_DELTA_FORMAT_MAGIC, sizeof(magic) - 1) != 0) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Patch file does not have '%@' magic value", @SPARKLE_DELTA_FORMAT_MAGIC] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Patch file does not have '%@' magic value", @SPARKLE_DELTA_FORMAT_MAGIC] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
SPUDeltaCompressionMode compression = 0;
|
||||
if (fread(&compression, sizeof(compression), 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read compression value from patch file: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read compression value from patch file: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.compression = compression;
|
||||
_compression = compression;
|
||||
|
||||
uint8_t compressionLevel = 0;
|
||||
if (fread(&compressionLevel, sizeof(compressionLevel), 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read compression level value from patch file: %@", patchFile] }];
|
||||
SparkleDeltaArchiveMetadata metadata = {0};
|
||||
if (fread(&metadata, sizeof(metadata), 1, file) < 1) {
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read compression level value from patch file: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -277,40 +282,45 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
case SPUDeltaCompressionModeNone:
|
||||
break;
|
||||
case SPUDeltaCompressionModeBzip2: {
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
int bzerror = 0;
|
||||
|
||||
BZFILE *bzipFile = BZ2_bzReadOpen(&bzerror, file, 0, 0, NULL, 0);
|
||||
if (bzipFile == NULL) {
|
||||
switch (bzerror) {
|
||||
case BZ_IO_ERROR:
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch as bz2 file due to io error: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch as bz2 file due to io error: %@", patchFile] }];
|
||||
break;
|
||||
default:
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:bzerror userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch as bz2 file: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:bzerror userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch as bz2 file: %@", patchFile] }];
|
||||
break;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.bzipFile = bzipFile;
|
||||
_bzipFile = bzipFile;
|
||||
|
||||
break;
|
||||
#else
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open patch as bz2 file because bzip2 support is disabled" }];
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
case SPUDeltaCompressionModeZLIB: {
|
||||
if (compression_stream_init(&_compressionStream, COMPRESSION_STREAM_DECODE, _compressionAlgorithmForMode(compression)) != COMPRESSION_STATUS_OK) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open compression stream for reading" }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open compression stream for reading" }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.initializedCompressionStream = YES;
|
||||
_initializedCompressionStream = YES;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_COMPRESSION_VALUE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Compression value read %d is not recognized.", compression] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_COMPRESSION_VALUE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Compression value read %d is not recognized.", compression] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -338,12 +348,12 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [[SPUDeltaArchiveHeader alloc] initWithCompression:compression compressionLevel:compressionLevel majorVersion:majorVersion minorVersion:minorVersion beforeTreeHash:beforeTreeHash afterTreeHash:afterTreeHash];
|
||||
return [[SPUDeltaArchiveHeader alloc] initWithCompression:compression compressionLevel:metadata.compressionLevel fileSystemCompression:metadata.fileSystemCompression majorVersion:majorVersion minorVersion:minorVersion beforeTreeHash:beforeTreeHash afterTreeHash:afterTreeHash];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)_readRelativeFilePaths
|
||||
- (NSArray<NSString *> *)_readRelativeFilePaths SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -359,7 +369,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char *fileTableData = calloc(1, filePathSectionSize);
|
||||
if (fileTableData == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %llu bytes for relative file paths.", filePathSectionSize] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to calloc() %llu bytes for relative file paths.", filePathSectionSize] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -386,7 +396,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if (fileTableData[index] == '\0') {
|
||||
NSString *relativePath = [fileManager stringWithFileSystemRepresentation:&fileTableData[currentStartIndex] length:index - currentStartIndex];
|
||||
if (relativePath == nil) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be decoded as a file system representation: %@", relativePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be decoded as a file system representation: %@", relativePath] }];
|
||||
|
||||
free(fileTableData);
|
||||
return nil;
|
||||
@@ -418,7 +428,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if (relativeFilePaths.count > UINT32_MAX) {
|
||||
// Very unlikely but we should guard against this
|
||||
// Clones rely on 32-bit indexes
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"There are too many file entries to apply a patch for (more than %u)", UINT32_MAX] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"There are too many file entries to apply a patch for (more than %u)", UINT32_MAX] }];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,7 +467,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
|
||||
if ((NSUInteger)cloneRelativePathIndex >= relativeFilePaths.count) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Index %u is past relative path table bounds of length %lu", cloneRelativePathIndex, (unsigned long)relativeFilePaths.count] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Index %u is past relative path table bounds of length %lu", cloneRelativePathIndex, (unsigned long)relativeFilePaths.count] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -518,7 +528,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
}
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -552,15 +562,17 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if ((commands & SPUDeltaItemCommandBinaryDiff) != 0 || S_ISREG(mode)) {
|
||||
// Regular files
|
||||
|
||||
[fileManager removeItemAtPath:itemFilePath error:NULL];
|
||||
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemFilePath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path to extract cannot be decoded and expressed as a file system representation: %@", itemFilePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path to extract cannot be decoded and expressed as a file system representation: %@", itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
FILE *outputFile = fopen(itemFilePathString, "wb");
|
||||
if (outputFile == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to fopen() %@", itemFilePath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to fopen() %@", itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -571,14 +583,14 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
while (bytesLeftoverToCopy > 0) {
|
||||
uint64_t currentBlockSize = (bytesLeftoverToCopy >= PARTIAL_IO_CHUNK_SIZE) ? PARTIAL_IO_CHUNK_SIZE : bytesLeftoverToCopy;
|
||||
|
||||
void *tempBuffer = self.partialChunkBuffer;
|
||||
void *tempBuffer = _partialChunkBuffer;
|
||||
|
||||
if (![self _readBuffer:tempBuffer length:(int32_t)currentBlockSize]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (fwrite(tempBuffer, currentBlockSize, 1, outputFile) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to fwrite() %llu bytes during extraction.", currentBlockSize] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to fwrite() %llu bytes during extraction.", currentBlockSize] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -588,12 +600,12 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
fclose(outputFile);
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ((commands & SPUDeltaItemCommandExtract) != 0 && chmod(itemFilePathString, mode) != 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to chmod() mode %d on %@", mode, itemFilePath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to chmod() mode %d on %@", mode, itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
@@ -601,13 +613,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
if (PARTIAL_IO_CHUNK_SIZE < decodedLength) {
|
||||
// Something is seriously wrong
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CHUNK_SIZE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"PARTIAL_IO_CHUNK_SIZE (%d) < decodedLength (%llu)", PARTIAL_IO_CHUNK_SIZE, decodedLength] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CHUNK_SIZE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"PARTIAL_IO_CHUNK_SIZE (%d) < decodedLength (%llu)", PARTIAL_IO_CHUNK_SIZE, decodedLength] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (decodedLength > PATH_MAX) {
|
||||
// Link is too long
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Decoded length for link (%llu) is too long.", decodedLength] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Decoded length for link (%llu) is too long.", decodedLength] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -619,7 +631,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
NSString *destinationPath = [fileManager stringWithFileSystemRepresentation:buffer length:decodedLength];
|
||||
|
||||
if (destinationPath == nil) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination path for link %@ cannot be created in a file system representation: %@",itemFilePath, destinationPath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination path for link %@ cannot be created in a file system representation: %@",itemFilePath, destinationPath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -627,13 +639,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
NSError *createLinkError = nil;
|
||||
if (![fileManager createSymbolicLinkAtPath:itemFilePath withDestinationPath:destinationPath error:&createLinkError]) {
|
||||
self.error = createLinkError;
|
||||
_error = createLinkError;
|
||||
return NO;
|
||||
}
|
||||
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemFilePath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path to extract cannot be decoded and expressed as a file system representation: %@", itemFilePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path to extract cannot be decoded and expressed as a file system representation: %@", itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -645,7 +657,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
} else if (S_ISDIR(mode)) {
|
||||
NSError *createDirectoryError = nil;
|
||||
if (![fileManager createDirectoryAtPath:itemFilePath withIntermediateDirectories:NO attributes:@{NSFilePosixPermissions: @(mode)} error:&createDirectoryError]) {
|
||||
self.error = createDirectoryError;
|
||||
_error = createDirectoryError;
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -653,34 +665,39 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_writeBuffer:(void *)buffer length:(int32_t)length
|
||||
- (BOOL)_writeBuffer:(void *)buffer length:(int32_t)length SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
switch (self.compression) {
|
||||
switch (_compression) {
|
||||
case SPUDeltaCompressionModeNone: {
|
||||
BOOL success = (fwrite(buffer, (size_t)length, 1, self.file) == 1);
|
||||
BOOL success = (fwrite(buffer, (size_t)length, 1, _file) == 1);
|
||||
if (!success) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d uncompressed bytes.", length] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d uncompressed bytes.", length] }];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
case SPUDeltaCompressionModeBzip2: {
|
||||
case SPUDeltaCompressionModeBzip2:
|
||||
{
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
int bzerror = 0;
|
||||
BZ2_bzWrite(&bzerror, self.bzipFile, buffer, length);
|
||||
BZ2_bzWrite(&bzerror, _bzipFile, buffer, length);
|
||||
switch (bzerror) {
|
||||
case BZ_OK:
|
||||
return YES;
|
||||
case BZ_IO_ERROR:
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bz2 bytes due to io error.", length] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bz2 bytes due to io error.", length] }];
|
||||
return NO;
|
||||
default:
|
||||
self.error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bz2 bytes.", length] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bz2 bytes.", length] }];
|
||||
return NO;
|
||||
}
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
@@ -689,21 +706,21 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
_compressionStream.src_ptr = buffer;
|
||||
_compressionStream.src_size = (size_t)length;
|
||||
|
||||
FILE *file = self.file;
|
||||
void *compressionBuffer = self.compressionBuffer;
|
||||
FILE *file = _file;
|
||||
void *compressionBuffer = _compressionBuffer;
|
||||
while (_compressionStream.src_size > 0) {
|
||||
// Reset destination buffer
|
||||
_compressionStream.dst_ptr = compressionBuffer;
|
||||
_compressionStream.dst_size = COMPRESSION_BUFFER_SIZE;
|
||||
|
||||
if (compression_stream_process(&_compressionStream, 0) == COMPRESSION_STATUS_ERROR) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bytes.", length] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %d compressed bytes.", length] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
size_t compressedBytesWritten = (size_t)(_compressionStream.dst_ptr - (uint8_t *)compressionBuffer);
|
||||
if (compressedBytesWritten > 0 && fwrite(compressionBuffer, compressedBytesWritten, 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %zu compressed bytes.", compressedBytesWritten] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write %zu compressed bytes.", compressedBytesWritten] }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
@@ -716,31 +733,31 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
- (void)writeHeader:(SPUDeltaArchiveHeader *)header
|
||||
{
|
||||
char patchFilePath[PATH_MAX + 1] = {0};
|
||||
if (![self.patchFile getFileSystemRepresentation:patchFilePath maxLength:sizeof(patchFilePath) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open header and represent as a file system representation: %@", self.patchFile] }];
|
||||
if (![_patchFile getFileSystemRepresentation:patchFilePath maxLength:sizeof(patchFilePath) - 1]) {
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open header and represent as a file system representation: %@", _patchFile] }];
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *file = fopen(patchFilePath, "wb");
|
||||
if (file == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch file for writing: %@", self.patchFile] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open patch file for writing: %@", _patchFile] }];
|
||||
return;
|
||||
}
|
||||
|
||||
self.file = file;
|
||||
_file = file;
|
||||
|
||||
char magic[] = SPARKLE_DELTA_FORMAT_MAGIC;
|
||||
if (fwrite(magic, sizeof(magic) - 1, 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write magic value due to io error" }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write magic value due to io error" }];
|
||||
return;
|
||||
}
|
||||
|
||||
SPUDeltaCompressionMode compression = (header.compression == SPUDeltaCompressionModeDefault) ? SPUDeltaCompressionModeLZMA : header.compression;
|
||||
|
||||
self.compression = compression;
|
||||
_compression = compression;
|
||||
|
||||
if (fwrite(&compression, sizeof(compression), 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write compression value due to io error" }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write compression value due to io error" }];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -748,13 +765,19 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
uint8_t compressionLevel = 0;
|
||||
switch (compression) {
|
||||
case SPUDeltaCompressionModeBzip2:
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
// Only 1 - 9 are valid, 0 is a special case for using default 9
|
||||
if (header.compressionLevel <= 0 || header.compressionLevel > 9) {
|
||||
compressionLevel = 9;
|
||||
} else {
|
||||
compressionLevel = header.compressionLevel;
|
||||
}
|
||||
|
||||
break;
|
||||
#else
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:-1 userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write bzip2 patch because bzip2 support is disabled" }];
|
||||
return;
|
||||
#endif
|
||||
// Some supported formats below have a documented level even though it's not customizable
|
||||
// Let's record them in the archive
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
@@ -770,8 +793,10 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
compressionLevel = 0;
|
||||
}
|
||||
|
||||
if (fwrite(&compressionLevel, sizeof(compressionLevel), 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write compression level value due to io error" }];
|
||||
SparkleDeltaArchiveMetadata metadata = {.compressionLevel = compressionLevel, .fileSystemCompression = header.fileSystemCompression};
|
||||
|
||||
if (fwrite(&metadata, sizeof(metadata), 1, file) < 1) {
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write metadata value due to io error" }];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -779,6 +804,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
case SPUDeltaCompressionModeNone:
|
||||
break;
|
||||
case SPUDeltaCompressionModeBzip2: {
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
int bzerror = 0;
|
||||
// Compression level can be 1 - 9
|
||||
int blockSize100k = (int)compressionLevel;
|
||||
@@ -787,17 +813,18 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if (bzipFile == NULL) {
|
||||
switch (bzerror) {
|
||||
case BZ_IO_ERROR:
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open bz2 stream for writing due to io error" }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open bz2 stream for writing due to io error" }];
|
||||
break;
|
||||
default:
|
||||
self.error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open bz2 stream for writing" }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_BZIP2_ERROR_DOMAIN code:bzerror userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open bz2 stream for writing" }];
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.bzipFile = bzipFile;
|
||||
_bzipFile = bzipFile;
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -806,12 +833,12 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
case SPUDeltaCompressionModeZLIB: {
|
||||
if (compression_stream_init(&_compressionStream, COMPRESSION_STREAM_ENCODE, _compressionAlgorithmForMode(compression)) != COMPRESSION_STATUS_OK) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open compression stream for writing" }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to open compression stream for writing" }];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.initializedCompressionStream = YES;
|
||||
_initializedCompressionStream = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -832,16 +859,16 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
- (void)addItem:(SPUDeltaArchiveItem *)item
|
||||
{
|
||||
[self.writableItems addObject:item];
|
||||
[_writableItems addObject:item];
|
||||
}
|
||||
|
||||
- (void)finishEncodingItems
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray<SPUDeltaArchiveItem *> *writableItems = self.writableItems;
|
||||
NSMutableArray<SPUDeltaArchiveItem *> *writableItems = _writableItems;
|
||||
|
||||
// Build relative path table for tracking file clones
|
||||
NSMutableDictionary<NSString *, NSNumber *> *relativePathToIndexTable = [NSMutableDictionary dictionary];
|
||||
@@ -873,7 +900,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if (relativePathToIndexTable.count > UINT32_MAX) {
|
||||
// Very unlikely but we should guard against this
|
||||
// Clones rely on 32-bit indexes
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"There are too many file entries to create a patch for (more than %u)", UINT32_MAX] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"There are too many file entries to create a patch for (more than %u)", UINT32_MAX] }];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -884,7 +911,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char relativePathString[PATH_MAX + 1] = {0};
|
||||
if (![relativePath getFileSystemRepresentation:relativePathString maxLength:sizeof(relativePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be retrieved and expressed as a file system representation: %@", relativePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be retrieved and expressed as a file system representation: %@", relativePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -893,14 +920,14 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
for (NSString *clonedPathEntry in newClonedPathEntries) {
|
||||
char relativePathString[PATH_MAX + 1] = {0};
|
||||
if (![clonedPathEntry getFileSystemRepresentation:relativePathString maxLength:sizeof(relativePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone cannot be retrieved and expressed as a file system representation: %@", clonedPathEntry] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone cannot be retrieved and expressed as a file system representation: %@", clonedPathEntry] }];
|
||||
break;
|
||||
}
|
||||
|
||||
totalPathLength += strlen(relativePathString) + 1;
|
||||
}
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -915,7 +942,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char pathBuffer[PATH_MAX + 1] = {0};
|
||||
if (![relativePath getFileSystemRepresentation:pathBuffer maxLength:PATH_MAX]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be encoded and expressed as a file system representation: %@", relativePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path cannot be encoded and expressed as a file system representation: %@", relativePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -926,7 +953,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
for (NSString *clonedPathEntry in newClonedPathEntries) {
|
||||
char pathBuffer[PATH_MAX + 1] = {0};
|
||||
if (![clonedPathEntry getFileSystemRepresentation:pathBuffer maxLength:PATH_MAX]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone cannot be encoded and expressed as a file system representation: %@", clonedPathEntry] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone cannot be encoded and expressed as a file system representation: %@", clonedPathEntry] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -935,7 +962,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
}
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -958,13 +985,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char sourcePathString[PATH_MAX + 1] = {0};
|
||||
if (![sourcePath getFileSystemRepresentation:sourcePathString maxLength:sizeof(sourcePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding cloned binary diff item: %@", sourcePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding cloned binary diff item: %@", sourcePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
struct stat fileInfo = {0};
|
||||
if (lstat(sourcePathString, &fileInfo) != 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", sourcePath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", sourcePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -991,7 +1018,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
NSNumber *relativePathIndex = relativePathToIndexTable[clonedRelativePath];
|
||||
if (relativePathIndex == nil) {
|
||||
// We have quite a problem here
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative file path index for %@ could not be located", clonedRelativePath] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative file path index for %@ could not be located", clonedRelativePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1006,13 +1033,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemPath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding cloned binary diff item: %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding cloned binary diff item: %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
struct stat fileInfo = {0};
|
||||
if (lstat(itemFilePathString, &fileInfo) != 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1032,13 +1059,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char sourceFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![sourcePath getFileSystemRepresentation:sourceFilePathString maxLength:sizeof(sourceFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding items: %@", sourcePath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding items: %@", sourcePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
struct stat sourceFileInfo = {0};
|
||||
if (lstat(sourceFilePathString, &sourceFileInfo) != 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", sourcePath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", sourcePath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1074,13 +1101,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemPath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding items: %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path cannot be decoded and expressed as a file system representation while encoding items: %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
struct stat itemFileInfo = {0};
|
||||
if (lstat(itemFilePathString, &itemFileInfo) != 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to lstat() on %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1094,7 +1121,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
} else if (S_ISLNK(extractMode)) {
|
||||
off_t fileSize = itemFileInfo.st_size;
|
||||
if (fileSize > UINT16_MAX) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path has a destination that is too long: %llu bytes", fileSize] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path has a destination that is too long: %llu bytes", fileSize] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1114,7 +1141,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
}
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1125,7 +1152,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
|
||||
// Encode all of our file contents
|
||||
void *tempBuffer = self.partialChunkBuffer;
|
||||
void *tempBuffer = _partialChunkBuffer;
|
||||
for (SPUDeltaArchiveItem *item in writableItems) {
|
||||
SPUDeltaItemCommands commands = item.commands;
|
||||
if ((commands & SPUDeltaItemCommandExtract) != 0 || (commands & SPUDeltaItemCommandBinaryDiff) != 0) {
|
||||
@@ -1140,13 +1167,13 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
if (totalItemSize > 0) {
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemPath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path to finish encoding cannot be decoded and expressed as a file system representation: %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Path to finish encoding cannot be decoded and expressed as a file system representation: %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
FILE *inputFile = fopen(itemFilePathString, "rb");
|
||||
if (inputFile == NULL) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open file for reading while encoding items: %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open file for reading while encoding items: %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1155,7 +1182,7 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
uint64_t currentBlockSize = (bytesLeftoverToCopy >= PARTIAL_IO_CHUNK_SIZE) ? PARTIAL_IO_CHUNK_SIZE : bytesLeftoverToCopy;
|
||||
|
||||
if (fread(tempBuffer, currentBlockSize, 1, inputFile) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %llu chunk bytes while encoding items", currentBlockSize] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read %llu chunk bytes while encoding items", currentBlockSize] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1168,21 +1195,21 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
fclose(inputFile);
|
||||
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (S_ISLNK(extractMode)) {
|
||||
char itemFilePathString[PATH_MAX + 1] = {0};
|
||||
if (![itemPath getFileSystemRepresentation:itemFilePathString maxLength:sizeof(itemFilePathString) - 1]) {
|
||||
self.error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path to finish encoding cannot be decoded and expressed as a file system representation: %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Link path to finish encoding cannot be decoded and expressed as a file system representation: %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
char linkDestination[PATH_MAX + 1] = {0};
|
||||
ssize_t linkDestinationLength = readlink(itemFilePathString, linkDestination, PATH_MAX);
|
||||
if (linkDestinationLength < 0) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to readlink() file at %@", itemPath] }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to readlink() file at %@", itemPath] }];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1195,16 +1222,19 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
// Close up and write final data to compressed streams
|
||||
|
||||
if (self.bzipFile != NULL) {
|
||||
#if SPARKLE_BUILD_BZIP2_DELTA_SUPPORT
|
||||
if (_bzipFile != NULL) {
|
||||
int bzerror = 0;
|
||||
BZ2_bzWriteClose64(&bzerror, self.bzipFile, 0, NULL, NULL, NULL, NULL);
|
||||
BZ2_bzWriteClose64(&bzerror, _bzipFile, 0, NULL, NULL, NULL, NULL);
|
||||
if (bzerror == BZ_IO_ERROR) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write and close bzip2 file due to IO error" }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write and close bzip2 file due to IO error" }];
|
||||
return;
|
||||
}
|
||||
} else if (self.initializedCompressionStream) {
|
||||
void *compressionBuffer = self.compressionBuffer;
|
||||
FILE *file = self.file;
|
||||
} else
|
||||
#endif
|
||||
if (_initializedCompressionStream) {
|
||||
void *compressionBuffer = _compressionBuffer;
|
||||
FILE *file = _file;
|
||||
|
||||
_compressionStream.src_size = 0;
|
||||
|
||||
@@ -1214,14 +1244,14 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
|
||||
compression_status status = compression_stream_process(&_compressionStream, COMPRESSION_STREAM_FINALIZE);
|
||||
if (status == COMPRESSION_STATUS_ERROR) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write final bits of Compression based file" }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_COMPRESSION_ERROR_DOMAIN code:COMPRESSION_STATUS_ERROR userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write final bits of Compression based file" }];
|
||||
return;
|
||||
}
|
||||
|
||||
size_t compressedBytesToWrite = (size_t)(_compressionStream.dst_ptr - (uint8_t *)compressionBuffer);
|
||||
if (compressedBytesToWrite > 0) {
|
||||
if (fwrite(compressionBuffer, compressedBytesToWrite, 1, file) < 1) {
|
||||
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write and close Compression based file due to io error" }];
|
||||
_error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: @"Failed to write and close Compression based file due to io error" }];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1235,5 +1265,3 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
@@ -14,11 +16,13 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Legacy container format for binary delta archives
|
||||
@interface SPUXarDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUXarDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile;
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile;
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile SPU_OBJC_DIRECT;
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile SPU_OBJC_DIRECT;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
|
||||
#import "SPUXarDeltaArchive.h"
|
||||
#include <xar/xar.h>
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
@@ -45,22 +47,15 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE 3
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE 4
|
||||
|
||||
@interface SPUXarDeltaArchive ()
|
||||
|
||||
@property (nonatomic) xar_t x;
|
||||
@property (nonatomic, readonly) int32_t xarMode;
|
||||
@property (nonatomic, readonly) NSMutableDictionary<NSString *, NSValue *> *fileTable;
|
||||
@property (nonatomic, readonly) NSString *patchFile;
|
||||
@property (nonatomic) NSError *error;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUXarDeltaArchive
|
||||
{
|
||||
NSMutableDictionary<NSString *, NSValue *> *_fileTable;
|
||||
NSString *_patchFile;
|
||||
|
||||
xar_t _x;
|
||||
int32_t _xarMode;
|
||||
}
|
||||
|
||||
@synthesize x = _x;
|
||||
@synthesize xarMode = _xarMode;
|
||||
@synthesize patchFile = _patchFile;
|
||||
@synthesize fileTable = _fileTable;
|
||||
@synthesize error = _error;
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile
|
||||
@@ -91,9 +86,9 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
|
||||
- (void)close
|
||||
{
|
||||
if (self.x != NULL) {
|
||||
xar_close(self.x);
|
||||
self.x = NULL;
|
||||
if (_x != NULL) {
|
||||
xar_close(_x);
|
||||
_x = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,18 +100,18 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
|
||||
- (nullable SPUDeltaArchiveHeader *)readHeader
|
||||
{
|
||||
NSString *patchFile = self.patchFile;
|
||||
NSString *patchFile = _patchFile;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Sparkle's XAR delta archives have been superceded by Sparkle's own format
|
||||
xar_t x = xar_open(patchFile.fileSystemRepresentation, READ);
|
||||
#pragma clang diagnostic pop
|
||||
if (x == NULL) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for reading: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for reading: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.x = x;
|
||||
_x = x;
|
||||
|
||||
uint16_t majorDiffVersion = SUBinaryDeltaMajorVersionFirst;
|
||||
uint16_t minorDiffVersion = 0;
|
||||
@@ -124,7 +119,7 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
NSString *expectedAfterHash = nil;
|
||||
|
||||
xar_subdoc_t subdoc;
|
||||
for (subdoc = xar_subdoc_first(self.x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
for (subdoc = xar_subdoc_first(_x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
if (strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY) == 0) {
|
||||
{
|
||||
// available in version 2.0 or later
|
||||
@@ -172,12 +167,12 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
|
||||
// I wasn't able to figure out how to retrieve the compression options from xar,
|
||||
// so we will use default flags to indicate the info isn't available
|
||||
return [[SPUDeltaArchiveHeader alloc] initWithCompression:SPUDeltaCompressionModeDefault compressionLevel:0 majorVersion:majorDiffVersion minorVersion:minorDiffVersion beforeTreeHash:rawExpectedBeforeHash afterTreeHash:rawExpectedAfterHash];
|
||||
return [[SPUDeltaArchiveHeader alloc] initWithCompression:SPUDeltaCompressionModeDefault compressionLevel:0 fileSystemCompression:false majorVersion:majorDiffVersion minorVersion:minorDiffVersion beforeTreeHash:rawExpectedBeforeHash afterTreeHash:rawExpectedAfterHash];
|
||||
}
|
||||
|
||||
- (void)writeHeader:(SPUDeltaArchiveHeader *)header
|
||||
{
|
||||
NSString *patchFile = self.patchFile;
|
||||
NSString *patchFile = _patchFile;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
@@ -185,11 +180,11 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
xar_t x = xar_open(patchFile.fileSystemRepresentation, WRITE);
|
||||
#pragma clang diagnostic pop
|
||||
if (x == NULL) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for writing: %@", patchFile] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for writing: %@", patchFile] }];
|
||||
return;
|
||||
}
|
||||
|
||||
self.x = x;
|
||||
_x = x;
|
||||
|
||||
SPUDeltaCompressionMode compression = (header.compression == SPUDeltaCompressionModeDefault ? SPUDeltaCompressionModeBzip2 : header.compression);
|
||||
|
||||
@@ -218,7 +213,7 @@ extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
case SPUDeltaCompressionModeZLIB: {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Version 2 patches only support bzip2 compression."] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Version 2 patches only support bzip2 compression."] }];
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -281,7 +276,7 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
|
||||
- (void)addItem:(SPUDeltaArchiveItem *)item
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,9 +285,9 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
SPUDeltaItemCommands commands = item.commands;
|
||||
uint16_t mode = item.mode;
|
||||
|
||||
xar_file_t newFile = _xarAddFile(self.fileTable, self.x, relativeFilePath, filePath);
|
||||
xar_file_t newFile = _xarAddFile(_fileTable, _x, relativeFilePath, filePath);
|
||||
if (newFile == NULL) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to add xar file entry: %@", relativeFilePath] }];
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to add xar file entry: %@", relativeFilePath] }];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,13 +315,13 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
|
||||
- (void)enumerateItems:(void (^)(SPUDeltaArchiveItem *, BOOL *))itemHandler
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL exitedEarly = NO;
|
||||
xar_iter_t iter = xar_iter_new();
|
||||
for (xar_file_t file = xar_file_first(self.x, iter); file; file = xar_file_next(iter)) {
|
||||
for (xar_file_t file = xar_file_first(_x, iter); file; file = xar_file_next(iter)) {
|
||||
char *pathCString;
|
||||
#if HAS_XAR_GET_SAFE_PATH
|
||||
#pragma clang diagnostic push
|
||||
@@ -348,7 +343,11 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *relativePath = @(pathCString);
|
||||
NSString *relativePath = [[NSString alloc] initWithBytesNoCopy:pathCString length:strlen(pathCString) encoding:NSUTF8StringEncoding freeWhenDone:YES];
|
||||
if (relativePath == nil) {
|
||||
free(pathCString);
|
||||
continue;
|
||||
}
|
||||
|
||||
SPUDeltaItemCommands commands = 0;
|
||||
{
|
||||
@@ -393,7 +392,7 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
|
||||
- (BOOL)extractItem:(SPUDeltaArchiveItem *)item
|
||||
{
|
||||
if (self.error != nil) {
|
||||
if (_error != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -401,8 +400,8 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
assert(item.xarContext != NULL);
|
||||
|
||||
xar_file_t file = item.xarContext;
|
||||
if (xar_extract_tofile(self.x, file, item.itemFilePath.fileSystemRepresentation) != 0) {
|
||||
self.error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to extract xar file entry to %@", item.itemFilePath] }];
|
||||
if (xar_extract_tofile(_x, file, item.itemFilePath.fileSystemRepresentation) != 0) {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to extract xar file entry to %@", item.itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -410,3 +409,5 @@ static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTa
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@ static BOOL applyBinaryDeltaToFile(NSString *patchFile, NSString *sourceFilePath
|
||||
return success;
|
||||
}
|
||||
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *finalDestination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
|
||||
{
|
||||
SPUDeltaArchiveHeader *header = nil;
|
||||
id<SPUDeltaArchiveProtocol> archive = SPUDeltaArchiveReadPatchAndHeader(patchFile, &header);
|
||||
@@ -39,7 +39,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(0/6.0);
|
||||
progressCallback(0/7.0);
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = header.majorVersion;
|
||||
uint16_t minorDiffVersion = header.minorVersion;
|
||||
@@ -90,7 +90,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
fprintf(stderr, "Verifying source...");
|
||||
}
|
||||
|
||||
progressCallback(1/6.0);
|
||||
progressCallback(1/7.0);
|
||||
|
||||
unsigned char beforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeWithVersion(beforeHash, source, majorDiffVersion)) {
|
||||
@@ -117,7 +117,17 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
fprintf(stderr, "\nCopying files...");
|
||||
}
|
||||
|
||||
progressCallback(2/6.0);
|
||||
progressCallback(2/7.0);
|
||||
|
||||
// Make a temporary destination path if necessary
|
||||
// If we want to apply file system compression after we're done applying, we'll need to use a different
|
||||
// temporary path
|
||||
NSString *destination;
|
||||
if (header.fileSystemCompression) {
|
||||
destination = [finalDestination.stringByDeletingLastPathComponent stringByAppendingPathComponent:[NSString stringWithFormat:@".tmp.%@", finalDestination.lastPathComponent]];
|
||||
} else {
|
||||
destination = finalDestination;
|
||||
}
|
||||
|
||||
if (!removeTree(destination)) {
|
||||
if (verbose) {
|
||||
@@ -129,7 +139,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(3/6.0);
|
||||
progressCallback(3/7.0);
|
||||
|
||||
if (!copyTree(source, destination)) {
|
||||
if (verbose) {
|
||||
@@ -141,7 +151,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(4/6.0);
|
||||
progressCallback(4/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nPatching...");
|
||||
@@ -272,6 +282,21 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
clonedRelativePath = nil;
|
||||
}
|
||||
|
||||
// Decide if we need to preserve original file permissions from the original file
|
||||
// applyBinaryDeltaToFile() normally preserves file permissions on the file it's replacing.
|
||||
// However this is not possible if the destination file we're patching is not writable.
|
||||
// We also need to preserve permissions for clones except when we'll be changing permissions later anyway.
|
||||
BOOL needsToCopyFilePermissions;
|
||||
if (![fileManager isWritableFileAtPath:destinationFilePath]) {
|
||||
// Remove the file non-writable we're patching that may cause issues
|
||||
[fileManager removeItemAtPath:destinationFilePath error:NULL];
|
||||
|
||||
// We will need to preserve permissons if there is no need to make permission changes later on
|
||||
needsToCopyFilePermissions = (commands & SPUDeltaItemCommandModifyPermissions) == 0;
|
||||
} else {
|
||||
needsToCopyFilePermissions = ((commands & SPUDeltaItemCommandClone) != 0) && ((commands & SPUDeltaItemCommandModifyPermissions) == 0);
|
||||
}
|
||||
|
||||
if (!applyBinaryDeltaToFile(tempDiffFile, sourceDiffFilePath, destinationFilePath)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -283,12 +308,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return;
|
||||
}
|
||||
|
||||
// Preserve original file permissions from the original file
|
||||
// Only necessary for clones because applyBinaryDeltaToFile() otherwise preserves
|
||||
// file permissions on the file it's replacing. Also not necessary if we're going to
|
||||
// change permissions later
|
||||
if ((commands & SPUDeltaItemCommandClone) != 0 && (commands & SPUDeltaItemCommandModifyPermissions) == 0) {
|
||||
|
||||
if (needsToCopyFilePermissions) {
|
||||
struct stat sourceFileInfo = {0};
|
||||
if (lstat(sourceDiffFilePath.fileSystemRepresentation, &sourceFileInfo) != 0) {
|
||||
if (verbose) {
|
||||
@@ -374,23 +394,70 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
if (error != NULL && *error == nil) {
|
||||
*error = archiveError;
|
||||
}
|
||||
removeTree(destination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(5/6.0);
|
||||
|
||||
progressCallback(5/7.0);
|
||||
|
||||
// Re-apply file system compression is requested
|
||||
if (header.fileSystemCompression) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nApplying file system compression...");
|
||||
}
|
||||
|
||||
NSTask *dittoTask = [[NSTask alloc] init];
|
||||
|
||||
dittoTask.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto" isDirectory:NO];
|
||||
dittoTask.arguments = @[@"--hfsCompression", destination, finalDestination];
|
||||
|
||||
// If we fail to apply file system compression, we will try falling back to not doing this
|
||||
BOOL failedToApplyFileSystemCompression = NO;
|
||||
|
||||
NSError *launchError = nil;
|
||||
if (![dittoTask launchAndReturnError:&launchError]) {
|
||||
failedToApplyFileSystemCompression = YES;
|
||||
|
||||
fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", launchError.localizedDescription.UTF8String);
|
||||
}
|
||||
|
||||
if (!failedToApplyFileSystemCompression) {
|
||||
[dittoTask waitUntilExit];
|
||||
|
||||
if (dittoTask.terminationStatus != 0) {
|
||||
failedToApplyFileSystemCompression = YES;
|
||||
|
||||
fprintf(stderr, "\nWarning: ditto task for file compression returned exit status %d", dittoTask.terminationStatus);
|
||||
}
|
||||
}
|
||||
|
||||
if (failedToApplyFileSystemCompression) {
|
||||
// Try to replace bundle normally
|
||||
if (![fileManager replaceItemAtURL:[NSURL fileURLWithPath:finalDestination] withItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] backupItemName:nil options:0 resultingItemURL:NULL error:error]) {
|
||||
removeTree(destination);
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
// Remove original copy
|
||||
[fileManager removeItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
progressCallback(6/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nVerifying destination...");
|
||||
}
|
||||
|
||||
unsigned char afterHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeWithVersion(afterHash, destination, majorDiffVersion)) {
|
||||
if (!getRawHashOfTreeWithVersion(afterHash, finalDestination, majorDiffVersion)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", destination] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", finalDestination] }];
|
||||
}
|
||||
removeTree(finalDestination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -401,11 +468,11 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", displayHashFromRawHash(expectedAfterHash), displayHashFromRawHash(afterHash)] }];
|
||||
}
|
||||
removeTree(destination);
|
||||
removeTree(finalDestination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(6/6.0);
|
||||
progressCallback(7/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
#define PERMISSION_FLAGS (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)
|
||||
#define VALID_SYMBOLIC_LINK_PERMISSIONS 0755
|
||||
// Enforcing Sparkle's executable permissions to be valid allows us to perform a preflight test before
|
||||
// downloading delta items
|
||||
#define VALID_SPARKLE_EXECUTABLE_PERMISSIONS 0755
|
||||
|
||||
#define APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY "com.apple.cs.CodeDirectory"
|
||||
#define APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY "com.apple.cs.CodeRequirements"
|
||||
@@ -31,6 +34,9 @@
|
||||
|
||||
#define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
|
||||
|
||||
// Relative path of custom icon data that may be set on a bundle via a resource fork
|
||||
#define CUSTOM_ICON_PATH @"/Icon\r"
|
||||
|
||||
// Changes that break backwards compatibility will have different major versions
|
||||
// Changes that affect creating but not applying patches will have different minor versions
|
||||
typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
|
||||
@@ -46,9 +52,10 @@ extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported;
|
||||
|
||||
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma', 'bzip2', 'zlib', 'lzfse', 'lz4', 'none', and 'default'. Note that version 2 delta files only support 'bzip2', 'none', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 delta files is currently lzma."
|
||||
// Additional compression methods for version 3 patches that we have for debugging are zlib, bzip2, none
|
||||
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma' (best compression, slowest), 'lzfse' (good compression, fast), 'lz4' (worse compression, fastest), and 'default'. Note that version 2 delta files only support 'bzip2', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 delta files is currently lzma."
|
||||
|
||||
#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
|
||||
//#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
|
||||
|
||||
SPUDeltaCompressionMode deltaCompressionModeFromDescription(NSString *description, BOOL *requestValid);
|
||||
NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <xlocale.h>
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -89,7 +90,7 @@ NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode)
|
||||
|
||||
int compareFiles(const FTSENT **a, const FTSENT **b)
|
||||
{
|
||||
return strcoll((*a)->fts_name, (*b)->fts_name);
|
||||
return strcoll_l((*a)->fts_name, (*b)->fts_name, _c_locale);
|
||||
}
|
||||
|
||||
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
|
||||
@@ -112,9 +113,9 @@ uint16_t latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersio
|
||||
case SUBinaryDeltaMajorVersion1:
|
||||
return 2;
|
||||
case SUBinaryDeltaMajorVersion2:
|
||||
return 3;
|
||||
return 4;
|
||||
case SUBinaryDeltaMajorVersion3:
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -255,8 +256,11 @@ BOOL getRawHashOfTreeAndFileTablesWithVersion(unsigned char *hashBuffer, NSStrin
|
||||
continue;
|
||||
|
||||
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (relativePath.length == 0)
|
||||
|
||||
// Ignore icon resource fork data
|
||||
if (relativePath.length == 0 || [relativePath isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
if (!_hashOfFileContents(fileHash, ent, tempBuffer, tempBufferSize)) {
|
||||
@@ -325,7 +329,7 @@ NSString *displayHashFromRawHash(const unsigned char *hash)
|
||||
{
|
||||
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1] = {0};
|
||||
for (size_t i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
|
||||
sprintf(hexHash + i * 2, "%02x", hash[i]);
|
||||
snprintf(hexHash + i * 2, 3, "%02x", hash[i]);
|
||||
}
|
||||
return @(hexHash);
|
||||
}
|
||||
|
||||
@@ -29,42 +29,47 @@
|
||||
extern int bsdiff(int argc, const char **argv);
|
||||
|
||||
@interface CreateBinaryDeltaOperation : NSOperation
|
||||
@property (copy) NSString *relativePath;
|
||||
@property (copy) NSString *clonedRelativePath;
|
||||
@property (strong) NSString *resultPath;
|
||||
@property (strong) NSNumber *oldPermissions;
|
||||
@property (strong) NSNumber *permissions;
|
||||
@property (nonatomic) BOOL changingPermissions;
|
||||
@property (strong) NSString *_fromPath;
|
||||
@property (strong) NSString *_toPath;
|
||||
- (id)initWithRelativePath:(NSString *)relativePath clonedRelativePath:(NSString *)clonedRelativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions changingPermissions:(BOOL)changingPermissions;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relativePath;
|
||||
@property (nonatomic, copy, readonly) NSString *clonedRelativePath;
|
||||
@property (nonatomic, readonly) NSString *resultPath;
|
||||
@property (nonatomic, readonly) NSNumber *oldPermissions;
|
||||
@property (nonatomic, readonly) NSNumber *permissions;
|
||||
@property (nonatomic, readonly) NSString *fromPath;
|
||||
@property (nonatomic, readonly) BOOL changingPermissions;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath clonedRelativePath:(NSString *)clonedRelativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions changingPermissions:(BOOL)changingPermissions SPU_OBJC_DIRECT;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CreateBinaryDeltaOperation
|
||||
{
|
||||
NSString *_toPath;
|
||||
}
|
||||
|
||||
@synthesize relativePath = _relativePath;
|
||||
@synthesize clonedRelativePath = _clonedRelativePath;
|
||||
@synthesize resultPath = _resultPath;
|
||||
@synthesize oldPermissions = _oldPermissions;
|
||||
@synthesize permissions = _permissions;
|
||||
@synthesize fromPath = _fromPath;
|
||||
@synthesize changingPermissions = _changingPermissions;
|
||||
@synthesize _fromPath = _fromPath;
|
||||
@synthesize _toPath = _toPath;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath clonedRelativePath:(NSString *)clonedRelativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions changingPermissions:(BOOL)changingPermissions
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.relativePath = relativePath;
|
||||
self.clonedRelativePath = clonedRelativePath;
|
||||
self.oldPermissions = oldPermissions;
|
||||
self.permissions = permissions;
|
||||
self.changingPermissions = changingPermissions;
|
||||
_relativePath = [relativePath copy];
|
||||
_clonedRelativePath = [clonedRelativePath copy];
|
||||
_oldPermissions = oldPermissions;
|
||||
_permissions = permissions;
|
||||
_changingPermissions = changingPermissions;
|
||||
|
||||
if (clonedRelativePath == nil) {
|
||||
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
_fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
} else {
|
||||
self._fromPath = [oldTree stringByAppendingPathComponent:clonedRelativePath];
|
||||
_fromPath = [oldTree stringByAppendingPathComponent:clonedRelativePath];
|
||||
}
|
||||
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
_toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -72,10 +77,11 @@ extern int bsdiff(int argc, const char **argv);
|
||||
- (void)main
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = { "/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
|
||||
const char *argv[] = { "/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
self.resultPath = temporaryFile;
|
||||
if (result == 0) {
|
||||
_resultPath = temporaryFile;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -440,6 +446,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([key isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing bundles with a custom icon set via a resource fork is not supported. Detected presence of %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
@@ -453,6 +469,20 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
originalTreeState[key] = info;
|
||||
|
||||
// Ensure Sparkle executable permissions are valid
|
||||
if (ent->fts_info == FTS_F && [key.lastPathComponent isEqualToString:@"Sparkle"] && [key.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"Sparkle.framework"]) {
|
||||
mode_t permissions = (mode_t)[(NSNumber *)info[INFO_PERMISSIONS_KEY] shortValue];
|
||||
if (permissions != VALID_SPARKLE_EXECUTABLE_PERMISSIONS) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Permissions for Sparkle executable must be 0%o (found 0%o) on file %@", VALID_SPARKLE_EXECUTABLE_PERMISSIONS, permissions, @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (aclExists(ent)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -517,6 +547,8 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
bool foundFilesystemCompression = false;
|
||||
|
||||
uint32_t warningsCount = 0;
|
||||
const uint32_t maxWarningsToPrint = 16;
|
||||
@@ -529,6 +561,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([key isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing bundles with a custom icon set via a resource fork is not supported. Detected presence of %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
@@ -541,6 +583,20 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Ensure Sparkle executable permissions are valid
|
||||
if (ent->fts_info == FTS_F && [key.lastPathComponent isEqualToString:@"Sparkle"] && [key.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"Sparkle.framework"]) {
|
||||
mode_t permissions = (mode_t)[(NSNumber *)info[INFO_PERMISSIONS_KEY] shortValue];
|
||||
if (permissions != VALID_SPARKLE_EXECUTABLE_PERMISSIONS) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Permissions for Sparkle executable must be 0%o (found 0%o) on file %@", VALID_SPARKLE_EXECUTABLE_PERMISSIONS, permissions, @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// We should validate ACLs even if we don't store the info in the diff in the case of ACLs
|
||||
// We should also not allow files with code signed extended attributes since Apple doesn't recommend inserting these
|
||||
// inside an application, and since we don't preserve extended attribitutes anyway
|
||||
@@ -584,6 +640,17 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
fprintf(stderr, "\nWarning: encountered too many warnings.. Ignoring the rest..");
|
||||
}
|
||||
}
|
||||
|
||||
// If we find any executable files that are using file system compression, that is sufficient
|
||||
// for recording that the applier should re-apply file system compression.
|
||||
// We check for executable files because they are likely candidates to be compressed.
|
||||
if (!foundFilesystemCompression && MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) && ent->fts_info == FTS_F && (ent->fts_statp->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0 && (ent->fts_statp->st_flags & UF_COMPRESSED) != 0) {
|
||||
foundFilesystemCompression = true;
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, " File system compression detected.");
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
|
||||
@@ -643,10 +710,20 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (majorVersion >= SUBinaryDeltaMajorVersion3) {
|
||||
archive = [[SPUSparkleDeltaArchive alloc] initWithPatchFileForWriting:temporaryFile];
|
||||
} else {
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
archive = [[SPUXarDeltaArchive alloc] initWithPatchFileForWriting:temporaryFile];
|
||||
#else
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: @"Support for creating legacy delta updates is disabled" }];
|
||||
}
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
SPUDeltaArchiveHeader *header = [[SPUDeltaArchiveHeader alloc] initWithCompression:compression compressionLevel:compressionLevel majorVersion:majorVersion minorVersion:minorVersion beforeTreeHash:beforeHash afterTreeHash:afterHash];
|
||||
SPUDeltaArchiveHeader *header = [[SPUDeltaArchiveHeader alloc] initWithCompression:compression compressionLevel:compressionLevel fileSystemCompression:foundFilesystemCompression majorVersion:majorVersion minorVersion:minorVersion beforeTreeHash:beforeHash afterTreeHash:afterHash];
|
||||
|
||||
[archive writeHeader:header];
|
||||
if (archive.error != nil) {
|
||||
@@ -857,7 +934,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
BOOL deltaOperationsFailed = NO;
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
NSString *resultPath = operation.resultPath;
|
||||
if (resultPath == nil) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -891,7 +968,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:relativePath commands:commands mode:mode.unsignedShortValue];
|
||||
item.itemFilePath = resultPath;
|
||||
item.sourcePath = operation._fromPath;
|
||||
item.sourcePath = operation.fromPath;
|
||||
item.clonedRelativePath = clonedRelativePath;
|
||||
|
||||
[archive addItem:item];
|
||||
@@ -911,7 +988,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
// Clean up operations after the archive has finished encoding
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
NSString *resultPath = operation.resultPath;
|
||||
if (resultPath != nil) {
|
||||
unlink(resultPath.fileSystemRepresentation);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,15 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT_MEMBERS
|
||||
#endif
|
||||
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -16,17 +16,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUBinaryDeltaUnarchiver
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize updateHostBundlePath = _updateHostBundlePath;
|
||||
{
|
||||
NSString *_archivePath;
|
||||
NSString *_updateHostBundlePath;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -43,7 +37,11 @@
|
||||
// We used to invoke mdimport on the bundle but this is not a very good approach.
|
||||
// There's no need to do that for non-delta updates and for updates that contain no mdimporters.
|
||||
// Moreover, updating the timestamp on the mdimporter bundles is what developers have to do anyway when shipping their new update outside of Sparkle
|
||||
// Note: this is used from unit tests
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT
|
||||
#endif
|
||||
{
|
||||
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
@@ -95,17 +93,17 @@
|
||||
|
||||
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
{
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
NSString *sourcePath = _updateHostBundlePath;
|
||||
NSString *targetPath = [[_archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, _archivePath, NO, ^(double progress){
|
||||
[notifier notifyProgress:progress];
|
||||
|
||||
}, &applyDiffError);
|
||||
|
||||
if (success) {
|
||||
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||
[SUBinaryDeltaUnarchiver updateSpotlightImportersAtBundlePath:targetPath];
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
else {
|
||||
@@ -113,6 +111,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
@@ -11,9 +11,12 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT_MEMBERS
|
||||
#endif
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError **)error;
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL checkNestedCode:(BOOL)checkNestedCode error:(NSError **)error;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError * __autoreleasing *)error
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
@@ -148,7 +148,7 @@ finally:
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not always passed
|
||||
// See in -codeSignatureIsValidAtBundleURL:andMatchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not always passed
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
if (checkNestedCode) {
|
||||
flags |= kSecCSCheckNestedCode;
|
||||
@@ -209,22 +209,8 @@ static id valueOrNSNull(id value) {
|
||||
return value ? value : [NSNull null];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath {
|
||||
NSDictionary *info = nil;
|
||||
SecStaticCodeRef code = NULL;
|
||||
OSStatus result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundlePath, kSecCSDefaultFlags, &code);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
info = [self codeSignatureInfoForCode:code];
|
||||
|
||||
finally:
|
||||
if (code) CFRelease(code);
|
||||
return info;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code {
|
||||
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code SPU_OBJC_DIRECT
|
||||
{
|
||||
CFDictionaryRef signingInfo = nil;
|
||||
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||
@@ -241,7 +227,8 @@ finally:
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
+ (NSDictionary *)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label SPU_OBJC_DIRECT
|
||||
{
|
||||
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
|
||||
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
||||
return relevantInfo;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
#ifndef SUDISKIMAGEUNARCHIVER_H
|
||||
#define SUDISKIMAGEUNARCHIVER_H
|
||||
|
||||
@@ -14,12 +16,16 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SULog.h"
|
||||
@@ -13,17 +15,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUDiskImageUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUDiskImageUnarchiver
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
{
|
||||
NSString *_archivePath;
|
||||
NSString *_decryptionPassword;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -54,7 +50,7 @@
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT
|
||||
{
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
@@ -84,10 +80,10 @@
|
||||
|
||||
NSData *promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
NSMutableArray *arguments = [@[@"attach", _archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
|
||||
if (self.decryptionPassword) {
|
||||
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
if (_decryptionPassword) {
|
||||
NSMutableData *passwordData = [[_decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
// From the hdiutil docs:
|
||||
// read a null-terminated passphrase from standard input
|
||||
//
|
||||
@@ -128,16 +124,8 @@
|
||||
dispatch_semaphore_signal(terminationSemaphore);
|
||||
};
|
||||
|
||||
if (@available(macOS 10.13, *)) {
|
||||
if (![task launchAndReturnError:&error]) {
|
||||
goto reportError;
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *) {
|
||||
goto reportError;
|
||||
}
|
||||
if (![task launchAndReturnError:&error]) {
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
[notifier notifyProgress:0.125];
|
||||
@@ -148,13 +136,17 @@
|
||||
if (![inputPipe.fileHandleForWriting writeData:promptData error:&error]) {
|
||||
goto reportError;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
@try {
|
||||
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||
} @catch (NSException *) {
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[inputPipe.fileHandleForWriting closeFile];
|
||||
|
||||
@@ -189,7 +181,7 @@
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[_archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
itemsCopied += 1.0;
|
||||
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||
@@ -221,27 +213,19 @@
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
task.standardError = [NSPipe pipe];
|
||||
|
||||
|
||||
if (@available(macOS 10.13, *)) {
|
||||
NSError *launchCleanupError = nil;
|
||||
if (![task launchAndReturnError:&launchCleanupError]) {
|
||||
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
|
||||
SULog(SULogLevelError, @"Error: %@", launchCleanupError);
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
|
||||
SULog(SULogLevelError, @"Exception: %@", exception);
|
||||
}
|
||||
NSError *launchCleanupError = nil;
|
||||
if (![task launchAndReturnError:&launchCleanupError]) {
|
||||
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
|
||||
SULog(SULogLevelError, @"Error: %@", launchCleanupError);
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"Can't mount DMG %@", self.archivePath);
|
||||
SULog(SULogLevelError, @"Can't mount DMG %@", _archivePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,16 +6,22 @@
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUnarchiverProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// An unarchiver for flat packages that doesn't really do any unarchiving
|
||||
@interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath expectingInstallationType:(NSString *)installationType;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import "SUFlatPackageUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SPUInstallationType.h"
|
||||
@@ -14,17 +16,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUFlatPackageUnarchiver ()
|
||||
|
||||
@property (nonatomic, readonly) NSString *flatPackagePath;
|
||||
@property (nonatomic, readonly) NSString *expectedInstallationType;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUFlatPackageUnarchiver
|
||||
|
||||
@synthesize flatPackagePath = _flatPackagePath;
|
||||
@synthesize expectedInstallationType = _expectedInstallationType;
|
||||
{
|
||||
NSString *_flatPackagePath;
|
||||
NSString *_expectedInstallationType;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -52,16 +48,18 @@
|
||||
|
||||
// Flat packages must use guided package installs, not interactive
|
||||
BOOL isDirectory = NO;
|
||||
if (![self.expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not have guided installation type but %@ instead", self.expectedInstallationType]}]];
|
||||
} else if (![[NSFileManager defaultManager] fileExistsAtPath:self.flatPackagePath isDirectory:&isDirectory] || isDirectory) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", self.flatPackagePath]}]];
|
||||
if (![_expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not have guided installation type but %@ instead", _expectedInstallationType]}]];
|
||||
} else if (![[NSFileManager defaultManager] fileExistsAtPath:_flatPackagePath isDirectory:&isDirectory] || isDirectory) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", _flatPackagePath]}]];
|
||||
} else {
|
||||
[notifier notifyProgress:1.0];
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.flatPackagePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _flatPackagePath]; }
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -16,11 +16,15 @@ The installer package is installed using macOS's built-in command line installer
|
||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
||||
*/
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerProtocol.h"
|
||||
|
||||
@interface SUGuidedPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUGuidedPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <sys/stat.h>
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
#import "SUErrors.h"
|
||||
@@ -13,19 +15,12 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUGuidedPackageInstaller ()
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *packagePath;
|
||||
@property (nonatomic, readonly, copy) NSString *homeDirectory;
|
||||
@property (nonatomic, readonly, copy) NSString *userName;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUGuidedPackageInstaller
|
||||
|
||||
@synthesize packagePath = _packagePath;
|
||||
@synthesize homeDirectory = _homeDirectory;
|
||||
@synthesize userName = _userName;
|
||||
{
|
||||
NSString *_packagePath;
|
||||
NSString *_homeDirectory;
|
||||
NSString *_userName;
|
||||
}
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
|
||||
{
|
||||
@@ -50,36 +45,24 @@
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = installerPath;
|
||||
task.arguments = @[@"-pkg", self.packagePath, @"-target", @"/"];
|
||||
task.arguments = @[@"-pkg", _packagePath, @"-target", @"/"];
|
||||
// Set the $HOME and $USER variables so pre/post install scripts reference the correct user environment
|
||||
task.environment = @{@"HOME": self.homeDirectory, @"USER": self.userName};
|
||||
task.environment = @{@"HOME": _homeDirectory, @"USER": _userName};
|
||||
task.standardError = nil;
|
||||
task.standardOutput = nil;
|
||||
|
||||
if (@available(macOS 10.13, *)) {
|
||||
NSError *launchError = nil;
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];
|
||||
|
||||
if (launchError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = launchError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Guided package installer task threw an exception" }];
|
||||
NSError *launchError = nil;
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];
|
||||
|
||||
if (launchError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = launchError;
|
||||
}
|
||||
|
||||
return NO;
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
[task waitUntilExit];
|
||||
@@ -105,3 +88,5 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -13,11 +13,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUHost;
|
||||
|
||||
@interface SUInstaller : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUInstaller : NSObject
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError **)error;
|
||||
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr;
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr
|
||||
#endif
|
||||
;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path SPU_OBJC_DIRECT
|
||||
{
|
||||
NSNumber *aliasFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
|
||||
@@ -31,7 +31,10 @@
|
||||
return aliasFlag.boolValue && directoryFlag.boolValue;
|
||||
}
|
||||
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
#endif
|
||||
{
|
||||
NSParameterAssert(inUpdateFolder);
|
||||
NSParameterAssert(host);
|
||||
@@ -41,23 +44,31 @@
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
NSString *fallbackPackagePath = nil;
|
||||
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = YES;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
#endif
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
||||
|
||||
while ((currentFile = [dirEnum nextObject])) {
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
NSString *currentFilename = [currentFile lastPathComponent];
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
NSString *currentExtension = [currentFile pathExtension];
|
||||
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
|
||||
#endif
|
||||
if ([currentFilename isEqualToString:bundleFileName] ||
|
||||
[currentFilename isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage = NO;
|
||||
#endif
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
} else if ([currentExtension isEqualToString:@"pkg"] ||
|
||||
[currentExtension isEqualToString:@"mpkg"]) {
|
||||
if ([currentFilenameNoExtension isEqualToString:bundleFileNameNoExtension]) {
|
||||
@@ -68,12 +79,15 @@
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
|
||||
if (incomingBundle && [incomingBundle.bundleIdentifier isEqualToString:hostBundleIdentifier]) {
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage = NO;
|
||||
#endif
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
@@ -84,6 +98,7 @@
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil) {
|
||||
@@ -105,18 +120,33 @@
|
||||
*isPackagePtr = isPackage;
|
||||
if (isGuidedPtr)
|
||||
*isGuidedPtr = isGuided;
|
||||
|
||||
#endif
|
||||
|
||||
if (!newAppDownloadPath) {
|
||||
SULog(SULogLevelError, @"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
|
||||
SULog(SULogLevelError, @"Searched %@ for %@.(app%@)", inUpdateFolder, bundleFileNameNoExtension,
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
@"|pkg"
|
||||
#else
|
||||
@""
|
||||
#endif
|
||||
);
|
||||
}
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host isPackage:&isPackage isGuided:&isGuided];
|
||||
#endif
|
||||
|
||||
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:&isPackage isGuided:&isGuided
|
||||
#endif
|
||||
];
|
||||
|
||||
if (newDownloadPath == nil) {
|
||||
if (error != NULL) {
|
||||
@@ -129,6 +159,7 @@
|
||||
// We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine
|
||||
// ahead of time whether or not this installer tool should be ran as root or not
|
||||
id <SUInstallerProtocol> installer = nil;
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
if (isPackage && isGuided) {
|
||||
if (![expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
if (error != NULL) {
|
||||
@@ -145,7 +176,9 @@
|
||||
} else {
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (![expectedInstallationType isEqualToString:SPUInstallationTypeApplication]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found regular application update but expected '%@=%@' from the appcast item enclosure instead", SUAppcastAttributeInstallationType, expectedInstallationType] }];
|
||||
|
||||
@@ -6,14 +6,18 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerProtocol.h"
|
||||
|
||||
// This is the deprecated package installation type, aka the "interactive" package installer
|
||||
// For a more supported package installation, see SUGuidedPackageInstaller
|
||||
|
||||
@interface SUPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import "SUPackageInstaller.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUErrors.h"
|
||||
@@ -14,18 +16,13 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPackageInstaller ()
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *packagePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPackageInstaller
|
||||
{
|
||||
NSString *_packagePath;
|
||||
}
|
||||
|
||||
static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
|
||||
@synthesize packagePath = _packagePath;
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath
|
||||
{
|
||||
self = [super init];
|
||||
@@ -52,7 +49,7 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
// -W = wait until the app has quit.
|
||||
// -n = Open another instance if already open.
|
||||
// -b = app bundle identifier
|
||||
NSArray *args = @[@"-W", @"-n", @"-b", @"com.apple.installer", self.packagePath];
|
||||
NSArray *args = @[@"-W", @"-n", @"-b", @"com.apple.installer", _packagePath];
|
||||
|
||||
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||
@try {
|
||||
@@ -80,3 +77,5 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -14,10 +14,12 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -14,17 +14,12 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPipedUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPipedUnarchiver
|
||||
{
|
||||
NSString *_archivePath;
|
||||
}
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
|
||||
+ (nullable NSArray <NSString *> *)commandAndArgumentsConformingToTypeOfPath:(NSString *)path
|
||||
static NSArray <NSString *> * _Nullable _commandAndArgumentsConformingToTypeOfPath(NSString *path)
|
||||
{
|
||||
NSArray <NSString *> *extractTGZ = @[@"/usr/bin/tar", @"-zxC"];
|
||||
NSArray <NSString *> *extractTBZ = @[@"/usr/bin/tar", @"-jxC"];
|
||||
@@ -55,7 +50,7 @@
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
|
||||
return _commandAndArgumentsConformingToTypeOfPath(path) != nil;
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
@@ -74,7 +69,7 @@
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
NSArray <NSString *> *commandAndArguments = [[self class] commandAndArgumentsConformingToTypeOfPath:self.archivePath];
|
||||
NSArray <NSString *> *commandAndArguments = _commandAndArgumentsConformingToTypeOfPath(_archivePath);
|
||||
assert(commandAndArguments != nil);
|
||||
|
||||
NSString *command = commandAndArguments.firstObject;
|
||||
@@ -89,26 +84,26 @@
|
||||
}
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
@autoreleasepool {
|
||||
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
|
||||
NSString *destination = [_archivePath stringByDeletingLastPathComponent];
|
||||
|
||||
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
|
||||
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], _archivePath, destination);
|
||||
|
||||
// Get the file size.
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil];
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:_archivePath error:nil];
|
||||
NSUInteger expectedLength = [(NSNumber *)[attributes objectForKey:NSFileSize] unsignedIntegerValue];
|
||||
|
||||
if (expectedLength == 0) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", self.archivePath]}];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", _archivePath]}];
|
||||
|
||||
[notifier notifyFailureWithError:error];
|
||||
return;
|
||||
}
|
||||
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:self.archivePath];
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:_archivePath];
|
||||
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
@@ -119,34 +114,37 @@
|
||||
[task setArguments:[args arrayByAddingObject:destination]];
|
||||
|
||||
NSError *launchError = nil;
|
||||
if (@available(macOS 10.13, *)) {
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
[notifier notifyFailureWithError:launchError];
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *e) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, -[NSTask launch] threw exception '%@'", e.description]}];
|
||||
[notifier notifyFailureWithError:error];
|
||||
return;
|
||||
}
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
[notifier notifyFailureWithError:launchError];
|
||||
return;
|
||||
}
|
||||
|
||||
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
|
||||
NSUInteger bytesWritten = 0;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
BOOL hasIOErrorMethods;
|
||||
if (@available(macOS 10.15, *)) {
|
||||
hasIOErrorMethods = YES;
|
||||
} else {
|
||||
hasIOErrorMethods = NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
do {
|
||||
NSData *data;
|
||||
if (hasIOErrorMethods) {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
if (!hasIOErrorMethods) {
|
||||
@try {
|
||||
data = [archiveInput readDataOfLength:256*1024];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to read data from archive with exception reason %@", exception.reason);
|
||||
data = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NSError *readError = nil;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
@@ -155,13 +153,6 @@
|
||||
if (data == nil) {
|
||||
SULog(SULogLevelError, @"Failed to read data from archive with error %@", readError);
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
data = [archiveInput readDataOfLength:256*1024];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to read data from archive with exception reason %@", exception.reason);
|
||||
data = nil;
|
||||
}
|
||||
}
|
||||
|
||||
NSUInteger len = [data length];
|
||||
@@ -170,7 +161,18 @@
|
||||
}
|
||||
|
||||
NSError *writeError = nil;
|
||||
if (hasIOErrorMethods) {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
if (!hasIOErrorMethods) {
|
||||
@try {
|
||||
[archiveOutput writeData:data];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to write data to pipe with exception reason %@", exception.reason);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
if (![archiveOutput writeData:data error:&writeError]) {
|
||||
@@ -178,13 +180,6 @@
|
||||
SULog(SULogLevelError, @"Failed to write data to pipe with error %@", writeError);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@try {
|
||||
[archiveOutput writeData:data];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to write data to pipe with exception reason %@", exception.reason);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bytesWritten += len;
|
||||
@@ -198,18 +193,26 @@
|
||||
if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) {
|
||||
SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
[archiveOutput closeFile];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (@available(macOS 10.15, *)) {
|
||||
NSError *archiveInputCloseError = nil;
|
||||
if (![archiveInput closeAndReturnError:&archiveInputCloseError]) {
|
||||
SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
[archiveInput closeFile];
|
||||
}
|
||||
#endif
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
@@ -231,6 +234,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,7 @@
|
||||
@class SUHost;
|
||||
@protocol SUVersionComparison;
|
||||
|
||||
@interface SUPlainInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPlainInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
/**
|
||||
@param host The current (old) bundle host
|
||||
|
||||
@@ -18,25 +18,15 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPlainInstaller ()
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, copy, readonly) NSString *bundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *installationPath;
|
||||
|
||||
@property (nonatomic) NSURL *temporaryOldDirectory;
|
||||
// We get an obj-c warning if we use 'newTemporaryDirectory' name about new + ownership stuff, so use 'temporaryNewDirectory' instead
|
||||
@property (nonatomic) NSURL *temporaryNewDirectory;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPlainInstaller
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize bundlePath = _bundlePath;
|
||||
@synthesize installationPath = _installationPath;
|
||||
@synthesize temporaryOldDirectory = _temporaryOldDirectory;
|
||||
@synthesize temporaryNewDirectory = _temporaryNewDirectory;
|
||||
{
|
||||
SUHost *_host;
|
||||
NSString *_bundlePath;
|
||||
NSString *_installationPath;
|
||||
NSURL *_temporaryOldDirectory;
|
||||
// We get an obj-c warning if we use 'newTemporaryDirectory' name about new + ownership stuff, so use 'temporaryNewDirectory' instead
|
||||
NSURL *_temporaryNewDirectory;
|
||||
}
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath
|
||||
{
|
||||
@@ -49,23 +39,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one
|
||||
- (NSString *)bundleVersionAppropriateForFilenameFromHost:(SUHost *)host
|
||||
{
|
||||
NSString *bundleVersion = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *trimmedVersion = @"";
|
||||
|
||||
if (bundleVersion != nil) {
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
|
||||
trimmedVersion = [bundleVersion stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
|
||||
return trimmedVersion.length > 0 ? trimmedVersion : nil;
|
||||
}
|
||||
|
||||
- (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host progressBlock:(nullable void(^)(double))progress error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host progressBlock:(nullable void(^)(double))progress error:(NSError * __autoreleasing *)error SPU_OBJC_DIRECT
|
||||
{
|
||||
if (installationURL == nil || newURL == nil) {
|
||||
// this really shouldn't happen but just in case
|
||||
@@ -123,7 +97,7 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.temporaryNewDirectory = tempNewDirectoryURL;
|
||||
_temporaryNewDirectory = tempNewDirectoryURL;
|
||||
|
||||
if (progress) {
|
||||
progress(3/10.0);
|
||||
@@ -200,17 +174,13 @@
|
||||
// First try swapping the application atomically
|
||||
NSError *swapError = nil;
|
||||
BOOL swappedApp;
|
||||
if (@available(macOS 10.13, *)) {
|
||||
// If the app is normalized and the installation path differs, go through the old swap path
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
|
||||
swappedApp = NO;
|
||||
} else {
|
||||
// We will be cleaning up the temporary directory later in -performCleanup:
|
||||
// We don't want to clean it up now because it can take some time
|
||||
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newTempURL error:&swapError];
|
||||
}
|
||||
} else {
|
||||
// If the app is normalized and the installation path differs, go through the old swap path
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
|
||||
swappedApp = NO;
|
||||
} else {
|
||||
// We will be cleaning up the temporary directory later in -performCleanup:
|
||||
// We don't want to clean it up now because it can take some time
|
||||
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newTempURL error:&swapError];
|
||||
}
|
||||
|
||||
if (!swappedApp) {
|
||||
@@ -226,7 +196,7 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.temporaryOldDirectory = tempOldDirectoryURL;
|
||||
_temporaryOldDirectory = tempOldDirectoryURL;
|
||||
|
||||
if (progress) {
|
||||
progress(9/10.0);
|
||||
@@ -293,9 +263,9 @@
|
||||
{
|
||||
// Prevent malicious downgrades
|
||||
// Note that we may not be able to do this for package installations, hence this code being done here
|
||||
NSString *hostVersion = [self.host version];
|
||||
NSString *hostVersion = [_host version];
|
||||
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:self.bundlePath];
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:_bundlePath];
|
||||
SUHost *updateHost = [[SUHost alloc] initWithBundle:bundle];
|
||||
NSString *updateVersion = [updateHost objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
|
||||
@@ -318,19 +288,19 @@
|
||||
{
|
||||
// Note: we must do most installation work in the third stage due to relying on our application sitting in temporary directories.
|
||||
// It must not be possible for our update to sit in temporary directories for a very long time.
|
||||
return [self startInstallationToURL:[NSURL fileURLWithPath:self.installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:self.bundlePath] withHost:self.host progressBlock:cb error:error];
|
||||
return [self startInstallationToURL:[NSURL fileURLWithPath:_installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:_bundlePath] withHost:_host progressBlock:cb error:error];
|
||||
}
|
||||
|
||||
- (void)performCleanup
|
||||
{
|
||||
SUFileManager *fileManager = [[SUFileManager alloc] init];
|
||||
|
||||
if (self.temporaryNewDirectory != nil) {
|
||||
[fileManager removeItemAtURL:self.temporaryNewDirectory error:NULL];
|
||||
if (_temporaryNewDirectory != nil) {
|
||||
[fileManager removeItemAtURL:_temporaryNewDirectory error:NULL];
|
||||
}
|
||||
|
||||
if (self.temporaryOldDirectory != nil) {
|
||||
[fileManager removeItemAtURL:self.temporaryOldDirectory error:NULL];
|
||||
if (_temporaryOldDirectory != nil) {
|
||||
[fileManager removeItemAtURL:_temporaryOldDirectory error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
@class SUSignatures;
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error;
|
||||
|
||||
|
||||
@@ -16,21 +16,19 @@
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUErrors.h"
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
#endif
|
||||
#import "ed25519.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUSignatureVerifier ()
|
||||
@property (readonly) SUPublicKeys *pubKeys;
|
||||
@end
|
||||
|
||||
@implementation SUSignatureVerifier {
|
||||
@implementation SUSignatureVerifier
|
||||
{
|
||||
SUPublicKeys *_pubKeys;
|
||||
}
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
@@ -54,9 +52,10 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SecKeyRef)dsaSecKeyRef {
|
||||
|
||||
NSData *data = [self.pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
- (SecKeyRef)dsaSecKeyRef SPU_OBJC_DIRECT
|
||||
{
|
||||
NSData *data = [_pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
@@ -89,6 +88,7 @@
|
||||
CFRelease(items);
|
||||
return dsaPubKeySecKey;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
@@ -106,7 +106,7 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
switch (self.pubKeys.ed25519PubKeyStatus) {
|
||||
switch (_pubKeys.ed25519PubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it won't be used, because the old app doesn't have an EdDSA public key");
|
||||
@@ -165,11 +165,14 @@
|
||||
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(signatures.ed25519Signature, data.bytes, data.length, self.pubKeys.ed25519PubKey)) {
|
||||
if (ed25519_verify(signatures.ed25519Signature, data.bytes, data.length, _pubKeys.ed25519PubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
// No need to check DSA when EdDSA verification succeeded, unless a DSA signature is provided and it's
|
||||
// erroneously invalid
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusInvalid) {
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusInvalid)
|
||||
#endif
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
} else {
|
||||
@@ -177,9 +180,11 @@
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
@@ -192,7 +197,8 @@
|
||||
break;
|
||||
}
|
||||
|
||||
switch (self.pubKeys.dsaPubKeyStatus) {
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
switch (_pubKeys.dsaPubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
|
||||
@@ -235,6 +241,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
switch (_pubKeys.dsaPubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
// We don't keep track of DSA signatures, so we will ignore this mistake and treat it as if it were absent
|
||||
break;
|
||||
case SUSigningInputStatusPresent:
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"The old app has a DSA public key but DSA support is disabled, and the old app does not have an EdDSA public key." }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error != NULL) {
|
||||
// Use generic failure
|
||||
@@ -244,7 +265,8 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature error:(NSError * __autoreleasing *)outError
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature error:(NSError * __autoreleasing *)outError SPU_OBJC_DIRECT
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
@@ -269,7 +291,6 @@
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
#pragma clang diagnostic pop
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
__block SecTransformRef dataVerifyTransform = NULL;
|
||||
@@ -301,11 +322,8 @@
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
if (outError != NULL) {
|
||||
@@ -321,6 +339,7 @@
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
@@ -368,5 +387,6 @@
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUUnarchiverProtocol;
|
||||
|
||||
@interface SUUnarchiver : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUUnarchiver : NSObject
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword expectingInstallationType:(NSString *)installationType;
|
||||
|
||||
|
||||
@@ -23,17 +23,24 @@
|
||||
if ([SUPipedUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUPipedUnarchiver alloc] initWithArchivePath:path];
|
||||
|
||||
} else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
|
||||
}
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path decryptionPassword:decryptionPassword];
|
||||
|
||||
} else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
|
||||
}
|
||||
#endif
|
||||
else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
|
||||
assert(hostPath != nil);
|
||||
NSString *nonNullHostPath = hostPath;
|
||||
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath];
|
||||
} else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
|
||||
}
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
|
||||
// Flat packages are only supported for guided packaage installs
|
||||
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path expectingInstallationType:installationType];
|
||||
}
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUUnarchiverNotifier : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUUnarchiverNotifier : NSObject
|
||||
|
||||
- (instancetype)initWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
|
||||
@@ -13,17 +13,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUUnarchiverNotifier ()
|
||||
|
||||
@property (nonatomic, readonly, copy) void (^completionBlock)(NSError * _Nullable);
|
||||
@property (nonatomic, readonly, copy) void (^ _Nullable progressBlock)(double);
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUnarchiverNotifier
|
||||
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize progressBlock = _progressBlock;
|
||||
{
|
||||
void (^_completionBlock)(NSError * _Nullable);
|
||||
void (^ _Nullable _progressBlock)(double);
|
||||
}
|
||||
|
||||
- (instancetype)initWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
@@ -40,13 +34,13 @@
|
||||
- (void)notifySuccess
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.completionBlock(nil);
|
||||
self->_completionBlock(nil);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)notifyFailureWithError:(NSError * _Nullable)reason
|
||||
{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) forKey:NSLocalizedDescriptionKey];
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:@"An error occurred while extracting the archive. Please try again later." forKey:NSLocalizedDescriptionKey];
|
||||
if (reason) {
|
||||
[userInfo setObject:(NSError * _Nonnull)reason forKey:NSUnderlyingErrorKey];
|
||||
}
|
||||
@@ -54,15 +48,15 @@
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:userInfo];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.completionBlock(error);
|
||||
self->_completionBlock(error);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)notifyProgress:(double)progress
|
||||
{
|
||||
if (self.progressBlock != nil) {
|
||||
if (_progressBlock != nil) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.progressBlock(progress);
|
||||
self->_progressBlock(progress);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUUnarchiverProtocol <NSObject>
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction;
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface StatusInfo : NSObject <SUStatusInfoProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface StatusInfo : NSObject <SUStatusInfoProtocol>
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier;
|
||||
|
||||
|
||||
+44
-8
@@ -12,15 +12,19 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#define REPLY_STATUS_INFO_TIMEOUT 2
|
||||
|
||||
@interface StatusInfo () <NSXPCListenerDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
|
||||
@end
|
||||
|
||||
@implementation StatusInfo
|
||||
{
|
||||
NSXPCListener *_xpcListener;
|
||||
NSMutableDictionary *_pendingReplies;
|
||||
|
||||
NSUInteger _pendingReplyCounter;
|
||||
}
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize installationInfoData = _installationInfoData;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier
|
||||
@@ -29,19 +33,20 @@
|
||||
if (self != nil) {
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUStatusInfoServiceNameForBundleIdentifier(bundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
_pendingReplies = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[_xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
@@ -54,10 +59,41 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setInstallationInfoData:(NSData *)installationInfoData
|
||||
{
|
||||
_installationInfoData = installationInfoData;
|
||||
|
||||
// Respond to all of our pending replies
|
||||
for (NSNumber *replyKey in _pendingReplies) {
|
||||
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[replyKey];
|
||||
replyBlock(_installationInfoData);
|
||||
}
|
||||
|
||||
[_pendingReplies removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
reply(self.installationInfoData);
|
||||
if (self->_installationInfoData != nil) {
|
||||
reply(self->_installationInfoData);
|
||||
} else {
|
||||
// If we don't have the installation info data currently, we may receive it in a very short window afterwards
|
||||
// In this case wait a bit for the reply. If we receive the data it will be in -setInstallationInfoData:
|
||||
NSUInteger currentReplyCounter = self->_pendingReplyCounter;
|
||||
self->_pendingReplyCounter++;
|
||||
|
||||
NSNumber *currentReplyCounterKey = @(currentReplyCounter);
|
||||
self->_pendingReplies[currentReplyCounterKey] = [reply copy];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(REPLY_STATUS_INFO_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[currentReplyCounterKey];
|
||||
if (replyBlock != nil) {
|
||||
replyBlock(self->_installationInfoData);
|
||||
[self->_pendingReplies removeObjectForKey:currentReplyCounterKey];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TerminationListener : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface TerminationListener : NSObject
|
||||
|
||||
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier;
|
||||
|
||||
|
||||
@@ -16,19 +16,14 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface TerminationListener ()
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *processIdentifier;
|
||||
@property (nonatomic) BOOL watchedTermination;
|
||||
@property (nonatomic, copy) void (^completionBlock)(BOOL);
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize processIdentifier = _processIdentifier;
|
||||
@synthesize watchedTermination = _watchedTermination;
|
||||
{
|
||||
NSNumber *_processIdentifier;
|
||||
|
||||
void (^_completionBlock)(BOOL);
|
||||
|
||||
BOOL _watchedTermination;
|
||||
}
|
||||
|
||||
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier
|
||||
{
|
||||
@@ -42,22 +37,22 @@
|
||||
|
||||
- (BOOL)terminated
|
||||
{
|
||||
return (self.watchedTermination || self.processIdentifier == nil) ? YES : (kill(self.processIdentifier.intValue, 0) != 0);
|
||||
return (_watchedTermination || _processIdentifier == nil) ? YES : (kill(_processIdentifier.intValue, 0) != 0);
|
||||
}
|
||||
|
||||
- (void)invokeCompletionWithSuccess:(BOOL)success
|
||||
- (void)invokeCompletionWithSuccess:(BOOL)success SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.completionBlock != nil) {
|
||||
self.completionBlock(success);
|
||||
self.completionBlock = nil;
|
||||
if (_completionBlock != nil) {
|
||||
_completionBlock(success);
|
||||
_completionBlock = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startListeningWithCompletion:(void (^)(BOOL))completionBlock
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
_completionBlock = [completionBlock copy];
|
||||
|
||||
if (self.processIdentifier == nil) {
|
||||
if (_processIdentifier == nil) {
|
||||
[self invokeCompletionWithSuccess:YES];
|
||||
return;
|
||||
}
|
||||
@@ -66,7 +61,7 @@
|
||||
// As described in https://developer.apple.com/library/mac/technotes/tn2050/_index.html#//apple_ref/doc/uid/DTS10003081-CH1-SUBSECTION10
|
||||
// By using kqueues, we can stay away from using AppKit in case we ever decide to abandon it
|
||||
|
||||
pid_t processIdentifier = self.processIdentifier.intValue;
|
||||
pid_t processIdentifier = _processIdentifier.intValue;
|
||||
int queue = kqueue();
|
||||
if (queue == -1) {
|
||||
SULog(SULogLevelError, @"Failed to create kqueue() due to error %d: %@", errno, @(strerror(errno)));
|
||||
@@ -124,7 +119,7 @@ static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unu
|
||||
kevent(CFFileDescriptorGetNativeDescriptor(file), NULL, 0, &event, 1, NULL);
|
||||
|
||||
TerminationListener *self = CFBridgingRelease(info);
|
||||
self.watchedTermination = YES;
|
||||
self->_watchedTermination = YES;
|
||||
[self invokeCompletionWithSuccess:YES];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ struct Create: ParsableCommand {
|
||||
@Option(name: .long, help: ArgumentHelp(COMPRESSION_METHOD_ARGUMENT_DESCRIPTION, valueName: "compression"))
|
||||
var compression: String = "default"
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp(COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION, valueName: "compression-level"))
|
||||
@Option(name: .long, help: .hidden)
|
||||
var compressionLevel: UInt8 = 0
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to original bundle to create a patch from."))
|
||||
|
||||
@@ -1,14 +1,135 @@
|
||||
# 2.4.0
|
||||
|
||||
* Reduce code size
|
||||
* Enable deployment postprocessing in Release to properly strip debug symbols and strip all non-global symbols (#2286, #2305) (Zorg)
|
||||
* Remove duplicate Sparkle localization strings in Updater app (#2288) (Zorg)
|
||||
* Optimize codebase for generated code size (less properties, direct methods, etc) (#2305) (Zorg)
|
||||
* Add additional settings to `ConfigCommon.xcconfig` for disabling features
|
||||
* Ask permission for automatically downloading and installing new updates (#2285) (Zorg)
|
||||
* Add support for plain text release notes view that does not use web view (#2315) (Zorg)
|
||||
* Update `SUVersionDisplay` to better customize and display how versions are shown (#2321) (Zorg)
|
||||
* Add deprecations/warnings for incorrect background update checking usage (#2295) (Zorg)
|
||||
* Deprecate `-[SPUUpdater setFeedURL:]` API and add `-[SPUUpdater clearFeedURLFromUserDefaults]` for migrating away from `-[SPUUpdater setFeedURL:]` (#2295)
|
||||
* Trigger a new update check in `-[SPUUpdater resetUpdateCycle]` if the updater's feed or allowed channels have changed (#2324) (Zorg)
|
||||
* Exit with an error if generate_appcast cannot sign an update that must be signed (#2322) (Zorg)
|
||||
* Remove a redundant Apple code signing check when verifying new updates (#2341) (Zorg)
|
||||
* Turn off auto-linking for XPC targets to alleviate circular dependency issues (#2332) (Daniel Jalkut)
|
||||
|
||||
# 2.3.2
|
||||
|
||||
* Fix potential crash during download if appcast item includes invalid enclosure URL (#2317) (Zorg)
|
||||
* Add delegate method to hide showing version history option (#2303) (Zorg)
|
||||
* Finnish localization grammar fixes (#2311) (Lauri-Matti Parppei)
|
||||
|
||||
# 2.3.1
|
||||
|
||||
* Fix update permission alert title text overlapping with question text in some languages (#2284) (Zorg)
|
||||
* Log the URL that failed to download correctly (#2296) (Zorg)
|
||||
* Update Czech translation (#2275) (Sam)
|
||||
* Add zh_HK (Chinese, Hong Kong) localization (#2273) (Bing Zheung)
|
||||
|
||||
# 2.3.0
|
||||
|
||||
* Bump minimum deployment target to macOS 10.13 (#2196) (Zorg)
|
||||
* Remove and preserve necessary updates in generate_appcast (#2218) (Zorg)
|
||||
* Move old update files no longer needed to old_updates/ in archive directory in generate_appcast (#2228) (Zorg)
|
||||
* Expose maximum-versions option (per branch) in generate_appcast to preserve in the feed (#2259) (Zorg)
|
||||
* Add -p option to sign_update to only print the signed signature (#2268) (Zorg)
|
||||
* Hide automatic install check box when allowsAutomaticUpdates is disabled (#2202) (Jie)
|
||||
* Allow developer to always force allowing automatic updates (#2266) (Zorg)
|
||||
* Fix update window going haywire during resize when release notes are hidden by disabling resizing (#2200) (Zorg)
|
||||
* Allow user to re-try installing/relaunching application when quit is delayed/cancelled (#2234) (Zorg)
|
||||
* Add delta update attributes for validating an app hasn't been stripped from removed localizations or architectures (#2219) (Zorg)
|
||||
* Fix delta patches not applying edge case if files from source that need to be diffed are not writeable (#2211) (Zorg)
|
||||
* Add delegate callback when user makes choice to install, dismiss, or skip an update (#2250) (Zorg)
|
||||
* Reject serving updates with DSA only and no EdDSA (#2167) (Zorg)
|
||||
* Find potential matching running apps that are translocated in the updater agent (#2233) (Zorg)
|
||||
* Expose -[SPUStandardUserDriver activeUpdateAlert] as private API (#2255) (Zorg)
|
||||
* Add zh_CN l10n for "Version History" (#2247) (kakaiikaka)
|
||||
* Update zh_TW localization (#2271) (Chiahong)
|
||||
* Remove ed25519 git submodule in favor of including the dependency directly (#2244) (Zorg)
|
||||
* Clean up left-over code (#2243) (Eitot)
|
||||
* Update Package.resolved (#2245) (Zorg)
|
||||
* Remove model translation table for system profiling (#2188) (Zorg)
|
||||
* Improve documentation usage for SPUUpdater properties (#2256) (Zorg)
|
||||
|
||||
This release improves generate_appcast by automatically removing updates that are no longer needed in the generated appcast, and moving old update files to old_updates/ in the archives directory. New delta update attributes are also added to let Sparkle know when to skip downloading delta updates if the application has been stripped.
|
||||
|
||||
macOS 10.13 or later is now required (due to Xcode 14 dropping support for deploying to older OS versions).
|
||||
|
||||
If you're not generating appcasts automatically, remember to add `<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>` element to `<item>`s in your appcast.
|
||||
|
||||
# 2.2.2
|
||||
|
||||
* Critical update alerts may not show up as promptly as they should when they are being automatically installed (#2230) (Zorg)
|
||||
* Remove module imports from framework headers (#2217) (Zorg)
|
||||
* Update Portuguese localization (#2224) (Kent Sutherland)
|
||||
* Update zh_TW localization (#2246) (Chiahong)
|
||||
|
||||
# 2.2.1
|
||||
|
||||
* Make scroll bar dark in dark theme for Release Notes by default (#2187) (Pavel Moiseenko)
|
||||
* Fix memory leaks when using generate_appcast (#2193) (Zorg)
|
||||
* Update Italian localization (#2192) (VinBoiSoft)
|
||||
|
||||
# 2.2.0
|
||||
|
||||
* Update Focus Improvements (#924)
|
||||
* Present new scheduled updates in utmost focus only at opportune times (Zorg)
|
||||
* For regular apps opportune times are: app launch, app re-activation, and system being idle (without a power assertion being held to prevent display sleep).
|
||||
* For background (dockless) apps opportune time is just app launch. Otherwise, the update is now shown behind other applications and windows, instead of previously stealing focus from other active apps.
|
||||
* Add APIs and documentation for adding gentle update reminders to compliment Sparkle's standard user interface (Zorg) (#2122)
|
||||
* Allow status window to be minimizable for regular app installs (Zorg) (#2100)
|
||||
* Center status window and inherit key focus from the previously shown update alert window (Zorg)
|
||||
* Activate app when checking for updates if the app is not currently active (e.g, from a menu bar extra menu item) (Zorg)
|
||||
* Fix issue where bringing status window to front made other active windows exit in macOS Ventura's Stage Manager (#2153) (Zorg)
|
||||
* Fix showing update in focus not bringing the "checking for updates" window in focus (Zorg) (#2150)
|
||||
* Rename XPC Service filenames for Sandboxing to show more friendly human-readable name in authorization dialog (Zorg) (#2096)
|
||||
* Add support for running the framework and sparkle-cli as root (Zorg) (#2119)
|
||||
* Fix issue where update cycle may not complete in unusual configuration if automatic checks are disabled + automatic downloading is enabled + install requires user interaction (Zorg) (#2133)
|
||||
* Synchronize usage of XPC connections to main queue to fix potential race conditions (Zorg) (#2178)
|
||||
* Update last update check time when choosing to install an update & relaunch (Zorg) (#2136)
|
||||
* Improve error reporting in the framework and sparkle-cli when installation fails with no write permission (Zorg) (#2157)
|
||||
* Use displayVersionString instead of versionString for OS version mismatch error message (samschott) (#2138)
|
||||
* Make displayVersionString non-null and update fallback documentation (Zorg) (#2139)
|
||||
* Ignore custom icons set via resource forks when applying delta updates (Zorg) (#2114)
|
||||
* Fall back to regular update if delta update fails to download (Zorg) (#2118)
|
||||
* Skip downloading delta updates when application has been moved to a file system (like FAT) that doesn't support regular permission modes (Zorg) (#2148)
|
||||
* Bump initial installer message timeouts and declare daemon/agents processes as Interactive (Zorg) (#2162)
|
||||
* Add and improve translation strings and update pt-BR (BR Lingo) (#2094)
|
||||
* Update localisations (Eitot) (#2113)
|
||||
* Update Greek localizations (seitsme) (#2184, #2185)
|
||||
* Update Japanese localization (1024jp) (#2182)
|
||||
* Replace deprecated code with newer APIs (Eitot) (#2112)
|
||||
* Remove obsolete fallbacks for older OS versions (Eitot) (#2110)
|
||||
* Remove SPUURLRequest (Zorg) (#2124)
|
||||
* Silence ivar deprecation warnings (Zorg) (#2099)
|
||||
* Fix Xcode 14 project warnings (Zorg) (#2147, #2179)
|
||||
* Deprecate -s flag and add --ed-key-file option to generate_appcast (Zorg) (#2170)
|
||||
* Update text for external licenses (Zorg) (#2164)
|
||||
|
||||
This update renames the bundled XPC Services, brings improvements to notifying users of new updates without disrupting their focus, and adds [gentle update reminder APIs](https://sparkle-project.org/documentation/gentle-reminders/) to further customize how Sparkle's standard user interface delivers new update alerts.
|
||||
|
||||
The `-s` flag for passing a raw private EdDSA key to sign_update and generate_appcast is now deprecated. If you were using this option previously, please see the help pages of these tools for more information.
|
||||
|
||||
# 2.1.0
|
||||
|
||||
* New Binary Delta format (version 3)
|
||||
* Features a custom and more efficient container format, migrating away from the deprecated xar format (Zorg) (#2051)
|
||||
* Adds compression options for lzma, bzip2, zlib, lzfse, lz4, and no compression (Zorg) (#2051)
|
||||
* Changes default format compression from bzip2 (in version 2) to lzma (in version 3) resulting in smaller deltas (Zorg) (#2051)
|
||||
* Adds delta compression options for lzma, bzip2, zlib, lzfse, lz4, and no compression (Zorg) (#2051)
|
||||
* Changes default delta format compression from bzip2 (in version 2) to lzma (in version 3) resulting in smaller deltas (Zorg) (#2051)
|
||||
* Preserve file system (HFS+/apfs) level compression when applying delta updates (Zorg) (#2084)
|
||||
* Tracks renames and binary diffs for files that have moved around to new locations using intelligent heuristics (Zorg) (#2051, #2053)
|
||||
* Added more unit tests, UI tests, and generate_appcast/BinaryDelta tools support for the new format (Zorg) (#2052, #2054)
|
||||
* Major upgrade improvements (#2070)
|
||||
* Fix skipping a major version to not skip subsequent major versions (Zorg) (#2079)
|
||||
* Add sparkle:belowVersion element for informational updates (Zorg) (#2080)
|
||||
* Add option to allow developers to ignore/reset user skipped upgrades (Zorg) (#2081)
|
||||
* Fix progress bar and button alignment for checking updates (Zorg) (#2066)
|
||||
* This deprecates `-[SPUUserDriver showInstallingUpdate]` and `-[SPUUserDriver showSendingTerminationSignal]` in favor for `-[SPUUserDriver showInstallingUpdateWithApplicationTerminated:]`
|
||||
* Fix unsteady progress when installing updates (Zorg) (#2072)
|
||||
* Check http statusCode in didFinishDownloadingToURL (Eric Shapiro, Zorg) (#2049, #2073)
|
||||
* Use strcoll_l() for locale-independent comparisons for delta updates (Dan Rigdon-Bel) (#2087)
|
||||
* Fix version compare not treating '2.1.0' and '2.1' as being equal (Zorg) (#2065)
|
||||
* Add verify and account options for signing updates (Zorg) (#2074)
|
||||
* Add delta patch and Apple code signing verification in generate_appcast (Zorg) (#2076, #2077)
|
||||
@@ -18,6 +139,8 @@
|
||||
* Preserve the Entitlements directory in podspec (digitalMoksha) (#2062)
|
||||
* Add hidden option to generate_appcast to set max CDATA threshold (Zorg) (#2075)
|
||||
|
||||
This update introduces a new major format for [delta updates](https://sparkle-project.org/documentation/delta-updates/), which migrates away from deprecated APIs (xar) and creates smaller patches. If you don't use `generate_appcast`, please check the [compatibility notes for creating delta updates](https://sparkle-project.org/documentation/delta-updates/#compatibility).
|
||||
|
||||
# 2.0.0
|
||||
|
||||
* Support for Sandboxed Applications (Zorg)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"1.27.1": "https://github.com/sparkle-project/Sparkle/releases/download/1.27.1/Sparkle-1.27.1.tar.xz", "2.0.0-beta.6": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-beta.6/Sparkle-2.0.0-beta.6.tar.xz", "2.0.0-rc.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-rc.1/Sparkle-2.0.0-rc.1.tar.xz", "2.0.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0/Sparkle-2.0.0.tar.xz", "2.1.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.1/Sparkle-2.1.0-beta.1.tar.xz"}
|
||||
{"1.27.1": "https://github.com/sparkle-project/Sparkle/releases/download/1.27.1/Sparkle-1.27.1.tar.xz", "2.0.0-beta.6": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-beta.6/Sparkle-2.0.0-beta.6.tar.xz", "2.0.0-rc.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-rc.1/Sparkle-2.0.0-rc.1.tar.xz", "2.0.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0/Sparkle-2.0.0.tar.xz", "2.1.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.1/Sparkle-2.1.0-beta.1.tar.xz", "2.1.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.2/Sparkle-2.1.0-beta.2.tar.xz", "2.1.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0/Sparkle-2.1.0.tar.xz", "2.2.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.1/Sparkle-2.2.0-beta.1.tar.xz", "2.2.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.2/Sparkle-2.2.0-beta.2.tar.xz", "2.2.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0/Sparkle-2.2.0.tar.xz", "2.2.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.1/Sparkle-2.2.1.tar.xz", "2.2.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.2/Sparkle-2.2.2.tar.xz", "2.3.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.1/Sparkle-2.3.0-beta.1.tar.xz", "2.3.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.2/Sparkle-2.3.0-beta.2.tar.xz", "2.3.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0/Sparkle-2.3.0.tar.xz", "2.3.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.1/Sparkle-2.3.1.tar.xz", "2.3.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.2/Sparkle-2.3.2.tar.xz", "2.4.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.1/Sparkle-2.4.0-beta.1.tar.xz", "2.4.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.2/Sparkle-2.4.0-beta.2.tar.xz", "2.4.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0/Sparkle-2.4.0.tar.xz"}
|
||||
@@ -3,4 +3,4 @@
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
SWIFT_OBJC_BRIDGING_HEADER = $(PRODUCT_NAME)/Bridging-Header.h
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_TOOL=1
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_EXTERNALLY=1
|
||||
@@ -1,16 +1,76 @@
|
||||
// Common
|
||||
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_INSTALLER_PROGRESS_TOOL_NAME = Updater
|
||||
|
||||
// Set to 1 or 0 to bundle or not bundle provided XPC Services in Sparkle framework
|
||||
// Set to 1 or 0 to build and bundle the provided XPC Services in Sparkle framework
|
||||
// (Note for testing purposes for sandboxed apps, disabling all XPC services and then re-enabling them
|
||||
// may not work on the same login session due to a system caching issue. See comments for setting FRAMEWORK_VERSION for more info)
|
||||
SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE = 1
|
||||
// Embedding the downloader service also enables building legacy WebKit1 support
|
||||
SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE = 1
|
||||
SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE = 0
|
||||
SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE = 0
|
||||
|
||||
// Set this to your own prefix if you want to use XPC Service names with different prefix
|
||||
|
||||
// Set to 0 to disable building legacy 1.x SUUpdater stub
|
||||
SPARKLE_BUILD_LEGACY_SUUPDATER = 1
|
||||
|
||||
// Set to 0 to not build legacy DSA signing support
|
||||
// Don't disable this if you haven't migrated to EdDSA yet or if you support updating
|
||||
// other developer's applications that haven't migrated to EdDSA yet
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_LEGACY_DSA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build legacy DSA signing support for generate_appcast
|
||||
// Don't disable this if you still have items in your appcast feed that still need DSA signatures
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build legacy / xar based delta update support
|
||||
SPARKLE_BUILD_LEGACY_DELTA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build bzip2 support for version 3 delta based updates
|
||||
SPARKLE_BUILD_BZIP2_DELTA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build support for package (pkg) based installations
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_PACKAGE_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build support for extracting updates from disk images (dmgs)
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_DMG_SUPPORT = 1
|
||||
|
||||
// Set to 0 to only build all non-UI bits (which means client uses a custom SPUUserDriver)
|
||||
SPARKLE_BUILD_UI_BITS = 1
|
||||
|
||||
// Set to 0 to not use and copy localization / string files to framework
|
||||
SPARKLE_COPY_LOCALIZATIONS = 1
|
||||
|
||||
// Compilation flags for Swift tools and unit tests
|
||||
// If SPARKLE_BUILD_LEGACY_DELTA_SUPPORT is set to 0, remove -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
// If GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT is set to 0, remove -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT
|
||||
// If SPARKLE_BUILD_PACKAGE_SUPPORT is set to 0, remove -DSPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
// If SPARKLE_BUILD_DMG_SUPPORT is set to 0, remove -DSPARKLE_BUILD_DMG_SUPPORT
|
||||
OTHER_SWIFT_FLAGS_COMMON = -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT -DSPARKLE_BUILD_PACKAGE_SUPPORT -DSPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
// Minimum supported macOS version
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13
|
||||
|
||||
// Supported architectures
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
|
||||
// Default Sparkle names
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_INSTALLER_PROGRESS_TOOL_NAME = Updater
|
||||
|
||||
// Set these if you want to use custom name for the XPC Services
|
||||
// For the Installer one in particular, this name may show up in an authorization prompt
|
||||
// when installing an update that requires authorization.
|
||||
INSTALLER_CONNECTION_NAME = InstallerConnection
|
||||
INSTALLER_STATUS_NAME = InstallerStatus
|
||||
INSTALLER_LAUNCHER_NAME = Installer
|
||||
DOWNLOADER_NAME = Downloader
|
||||
|
||||
// Set this to your own prefix if you want to use XPC Service bundle IDs with different prefix
|
||||
XPC_SERVICE_BUNDLE_ID_PREFIX = org.sparkle-project
|
||||
|
||||
INSTALLER_CONNECTION_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerConnection
|
||||
@@ -18,9 +78,6 @@ 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
|
||||
|
||||
// Set to 0 to only build all non-UI bits
|
||||
SPARKLE_BUILD_UI_BITS = 1
|
||||
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
// following on to always reset the name back to "MyApp"
|
||||
@@ -34,25 +91,23 @@ SPARKLE_ICON_NAME = AppIcon
|
||||
// If you change any of these version details, you must increase CURRENT_PROJECT_VERSION
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_MAJOR = 2
|
||||
SPARKLE_VERSION_MINOR = 1
|
||||
SPARKLE_VERSION_MINOR = 4
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
|
||||
// This should be in SemVer format or empty, ie. "-beta.1"
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_SUFFIX = -beta.1
|
||||
CURRENT_PROJECT_VERSION = 2011
|
||||
SPARKLE_VERSION_SUFFIX =
|
||||
CURRENT_PROJECT_VERSION = 2025
|
||||
|
||||
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
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
|
||||
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}\"
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPU_OBJC_DIRECT=__attribute__((objc_direct)) SPU_OBJC_DIRECT_MEMBERS=__attribute__((objc_direct_members)) SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_COPY_LOCALIZATIONS=$(SPARKLE_COPY_LOCALIZATIONS) SPARKLE_BUILD_LEGACY_SUUPDATER=$(SPARKLE_BUILD_LEGACY_SUUPDATER) SPARKLE_BUILD_PACKAGE_SUPPORT=$(SPARKLE_BUILD_PACKAGE_SUPPORT) SPARKLE_BUILD_DMG_SUPPORT=$(SPARKLE_BUILD_DMG_SUPPORT) SPARKLE_BUILD_LEGACY_DELTA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DELTA_SUPPORT) SPARKLE_BUILD_BZIP2_DELTA_SUPPORT=$(SPARKLE_BUILD_BZIP2_DELTA_SUPPORT) SPARKLE_BUILD_LEGACY_DSA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DSA_SUPPORT) GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT=$(GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT) 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_NAME=\"${INSTALLER_LAUNCHER_NAME}\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_LAUNCHER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE) INSTALLER_CONNECTION_NAME=\"${INSTALLER_CONNECTION_NAME}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_CONNECTION_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE) INSTALLER_STATUS_NAME=\"${INSTALLER_STATUS_NAME}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" INSTALLER_STATUS_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE) DOWNLOADER_NAME=\"${DOWNLOADER_NAME}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\" DOWNLOADER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE)
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
SDKROOT = macosx
|
||||
@@ -106,8 +161,5 @@ GCC_WARN_UNUSED_LABEL = YES
|
||||
GCC_WARN_UNUSED_PARAMETER = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
|
||||
// These should be removed once the conversion to ARC is complete
|
||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
|
||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso $(WARNING_CFLAGS_EXTRA)
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso -Wno-direct-ivar-access -Wno-declaration-after-statement -Werror=undef
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
|
||||
@@ -13,5 +13,6 @@ DEBUG_INFORMATION_FORMAT = dwarf
|
||||
ENABLE_TESTABILITY = YES
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
ONLY_ACTIVE_ARCH = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
@@ -12,7 +12,9 @@ GCC_OPTIMIZATION_LEVEL = s
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=0
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
DEAD_CODE_STRIPPING = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
DEPLOYMENT_POSTPROCESSING = YES
|
||||
@@ -3,6 +3,7 @@
|
||||
INFOPLIST_FILE = Downloader/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${DOWNLOADER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${DOWNLOADER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${DOWNLOADER_NAME}
|
||||
CODE_SIGN_ENTITLEMENTS = Downloader/${DOWNLOADER_BUNDLE_ID}.entitlements
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_DOWNLOADER_SERVICE=1
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigFramework.xcconfig"
|
||||
|
||||
// Strip all non-global symbols (including debug symbols)
|
||||
STRIP_STYLE = non-global
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerConnection/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_CONNECTION_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_CONNECTION_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_CONNECTION_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerLauncher/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_LAUNCHER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_LAUNCHER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_LAUNCHER_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
INFOPLIST_FILE = Sparkle/InstallerProgress/InstallerProgress-Info.plist
|
||||
PRODUCT_NAME = $(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerStatus/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_STATUS_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_STATUS_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_STATUS_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -3,3 +3,4 @@
|
||||
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
@@ -11,4 +11,4 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
CLANG_ENABLE_MODULES = YES
|
||||
SWIFT_OBJC_BRIDGING_HEADER = Tests/Sparkle Unit Tests-Bridging-Header.h
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_TESTS=1
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_TESTS=1 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
@@ -48,8 +48,8 @@ if [ "$ACTION" = "" ] ; then
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Entitlements"
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements"
|
||||
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging/Entitlements/$DOWNLOADER_BUNDLE_ID.entitlements"
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements/$DOWNLOADER_BUNDLE_ID.entitlements"
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging/Entitlements/$DOWNLOADER_NAME.entitlements"
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements/$DOWNLOADER_NAME.entitlements"
|
||||
fi
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
@@ -66,8 +66,8 @@ if [ "$ACTION" = "" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Autoupdate.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Updater.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${INSTALLER_LAUNCHER_BUNDLE_ID}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${DOWNLOADER_BUNDLE_ID}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${INSTALLER_LAUNCHER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${DOWNLOADER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
fi
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/staging/Symbols" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
@@ -107,40 +107,46 @@ if [ "$ACTION" = "" ] ; then
|
||||
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"
|
||||
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"
|
||||
|
||||
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)
|
||||
latest_git_tag=$( git describe --tags --abbrev=0 || true )
|
||||
|
||||
# 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
|
||||
if [ -n "$latest_git_tag" ] ; then
|
||||
# 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"
|
||||
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
# Generate new Package manifest, podspec, and carthage files
|
||||
cd "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Carthage-dev.json" "$CONFIGURATION_BUILD_DIR"
|
||||
# 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"
|
||||
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
cd "$SRCROOT"
|
||||
|
||||
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
|
||||
# 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
|
||||
|
||||
# Generate new Package manifest, podspec, and carthage files
|
||||
cd "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Carthage-dev.json" "$CONFIGURATION_BUILD_DIR"
|
||||
fi
|
||||
|
||||
if [ -z "$latest_git_tag" ] ; then
|
||||
echo "warning: No git repository found so skipping updating package management files"
|
||||
elif [ "$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"
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
set -e
|
||||
|
||||
# Convenience script to automatically commit Package.swift after updating the checksum and move the latest tag
|
||||
latest_git_tag=$(git describe --tags --abbrev=0) # gets the latest tag name
|
||||
latest_git_tag=$( git describe --tags --abbrev=0 || true ) # gets the latest tag name
|
||||
if [ -z "$latest_git_tag" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
commits_since_tag=$(git rev-list ${latest_git_tag}.. --count)
|
||||
|
||||
function move_tag() {
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
FRAMEWORK_PATH="${TARGET_BUILD_DIR}"/"${FULL_PRODUCT_NAME}"
|
||||
|
||||
# Remove any unused XPC Services
|
||||
|
||||
removedservices=0
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_LAUNCHER_NAME}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${DOWNLOADER_NAME}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_STATUS_NAME}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_CONNECTION_NAME}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$removedservices" -eq 4 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"
|
||||
rm -rf "${FRAMEWORK_PATH}"/"XPCServices"
|
||||
fi
|
||||
|
||||
# Remove any unused nibs
|
||||
|
||||
if [[ "$SPARKLE_BUILD_UI_BITS" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"SUStatus.nib"
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"Base.lproj/SUUpdateAlert.nib"
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"Base.lproj/SUUpdatePermissionPrompt.nib"
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"ReleaseNotesColorStyle.css"
|
||||
fi
|
||||
|
||||
# Remove localization files if requested
|
||||
|
||||
if [[ "$SPARKLE_COPY_LOCALIZATIONS" -eq 0 ]]; then
|
||||
for dir in "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/*; do
|
||||
base=$(basename "$dir")
|
||||
if [[ "$base" =~ .*".lproj" ]]; then
|
||||
if [[ "$base" = "Base.lproj" ]]; then
|
||||
rm -rf "$dir/Sparkle.strings"
|
||||
# Remove Base.lproj if it's empty and the nibs have been stripped out already
|
||||
rmdir "$dir"
|
||||
else
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
FRAMEWORK_PATH="${TARGET_BUILD_DIR}"/"${FULL_PRODUCT_NAME}"
|
||||
|
||||
removedservices=0
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_LAUNCHER_BUNDLE_ID}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${DOWNLOADER_BUNDLE_ID}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_STATUS_BUNDLE_ID}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE" -eq 0 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_CONNECTION_BUNDLE_ID}.xpc"
|
||||
removedservices=$((removedservices+1))
|
||||
fi
|
||||
|
||||
if [[ "$removedservices" -eq 4 ]]; then
|
||||
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"
|
||||
rm -rf "${FRAMEWORK_PATH}"/"XPCServices"
|
||||
fi
|
||||
@@ -36,6 +36,12 @@ Two software components should not directly know about each other. Preferrably t
|
||||
|
||||
See `Documentation/graph-of-sparkle.png` for a graph of how the code looks like currently. This was generated via [objc_dep](https://github.com/nst/objc_dep) (great tool). Note that there are no red edges which would mean that two nodes know of each other.
|
||||
|
||||
## Attributes
|
||||
## Attributes & Code Size
|
||||
|
||||
`nonatomic` should really be used wherever possible with regards to obj-c properties (`atomic` is a bad default). `readonly` should be used wherever possible as well, which also implies that only ivar access should be used in initializers. `NS_ASSUME_NONNULL_BEGIN` and `NS_ASSUME_NONNULL_END` should be used around new headers whenever possible. AppKit prevention guards should be used for any non-UI class whenever possible.
|
||||
Instance variables and instance variable access should be used for private members (declared in `@implementation` block) whenever possible over properties. Preferring instance variables over properties for internal usage can significantly reduce code size. Instance variables should also be ordered by having the larger sized data members declared first.
|
||||
|
||||
`SPU_OBJC_DIRECT_MEMBERS` should be used for any internal class in Sparkle and `SPU_OBJC_DIRECT` should be used for any other internal methods to Sparkle that doesn't need to utilize the Obj-C runtime to reduce code size. Note these attributes should not be used for *any* class or method that is exported to the developer (this includes private headers / APIs we carefully decided to expose too). For internal methods and classes that are also used by our Swift tools or unit tests, we may not expose them as direct specifically when building for those targets.
|
||||
|
||||
`nonatomic` should really be used wherever possible with regards to obj-c properties (`atomic` is a bad default). `readonly` should be used wherever possible as well, which also implies that only ivar access should be used in initializers. `NS_ASSUME_NONNULL_BEGIN` and `NS_ASSUME_NONNULL_END` should be used around new headers whenever possible. AppKit prevention guards should be used for any non-UI class whenever possible.
|
||||
|
||||
Sparkle has several feature flags in ConfigCommon.xcconfig (e.g. `SPARKLE_BUILD_LEGACY_SUUPDATER`, `SPARKLE_BUILD_LEGACY_DSA_SUPPORT`, `SPARKLE_BUILD_UI_BITS`, etc). This allows disabling any combination of these features and building Sparkle with a more minimal feature set. These flags (with the exception for stripping UI bits, localizations, or XPC Services) are for disabling features that are legacy or not recommended to use for most applications. Note when altering these flags, `OTHER_SWIFT_FLAGS_COMMON` may need to be updated appropriately too.
|
||||
@@ -105,6 +105,8 @@ If the 2nd stage succeeds, the installer sends a `SPUInstallationFinishedStage2`
|
||||
|
||||
The updater receives a `SPUInstallationFinishedStage2` message, and reads if the target application had already been terminated. If the target application has not already terminated, the updater tells the user driver to show that the application is being sent a termination request.
|
||||
|
||||
In the case termination of the application is delayed or canceled, the user driver may re-try sending a `SPUResumeInstallationToStage2` message to the installer. This time the installer will recognize it already completed stage 2. If it hasn't proceeded onto stage 3 it will send another quit event to the application. This re-try can be done multiple times.
|
||||
|
||||
### Showing Progress
|
||||
|
||||
When the target application is terminated, if the updater allowed the installer to show UI progress and the installation type doesn't show progress on its own (only interactive package installer shows progress on its own), then the installer sends a `SPUUpdaterAlivePing` message to the updater. If the updater is still alive by now and receives the message, the updater will then send back a `SPUUpdaterAlivePong` message. This lets the installer know that the updater is still active after the target application is terminated, and whether the installer should later be responsible for displaying updater progress or not if a short time passes by, and the installation is still not finished. If the updater is still not alive, then the installer should be responsible for showing progress if otherwise allowed.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@protocol SPUDownloaderDelegate;
|
||||
|
||||
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
|
||||
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUDownloader : NSObject <SPUDownloaderProtocol>
|
||||
|
||||
// Due to XPC remote object reasons, this delegate is strongly referenced
|
||||
// Invoke cleanup when done with this instance
|
||||
|
||||
+76
-84
@@ -9,7 +9,6 @@
|
||||
#import "SPUDownloader.h"
|
||||
#import "SPUDownloaderDelegate.h"
|
||||
#import "SPULocalCacheDirectory.h"
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SPUDownloadDataPrivate.h"
|
||||
#import "SUErrors.h"
|
||||
@@ -26,31 +25,24 @@ typedef NS_ENUM(NSUInteger, SPUDownloadMode)
|
||||
static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
|
||||
@interface SPUDownloader () <NSURLSessionDownloadDelegate>
|
||||
|
||||
// Delegate is intentionally strongly referenced; see header
|
||||
@property (nonatomic) id <SPUDownloaderDelegate> delegate;
|
||||
@property (nonatomic) NSURLSessionDownloadTask *download;
|
||||
@property (nonatomic) NSURLSession *downloadSession;
|
||||
@property (nonatomic, copy) NSString *bundleIdentifier;
|
||||
@property (nonatomic, copy) NSString *desiredFilename;
|
||||
@property (nonatomic, copy) NSString *downloadFilename;
|
||||
@property (nonatomic) BOOL disabledAutomaticTermination;
|
||||
@property (nonatomic) SPUDownloadMode mode;
|
||||
@property (nonatomic) BOOL receivedExpectedBytes;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUDownloader
|
||||
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize download = _download;
|
||||
@synthesize downloadSession = _downloadSession;
|
||||
@synthesize bundleIdentifier = _bundleIdentifier;
|
||||
@synthesize desiredFilename = _desiredFilename;
|
||||
@synthesize downloadFilename = _downloadFilename;
|
||||
@synthesize disabledAutomaticTermination = _disabledAutomaticTermination;
|
||||
@synthesize mode = _mode;
|
||||
@synthesize receivedExpectedBytes = _receivedExpectedBytes;
|
||||
{
|
||||
NSURLSessionDownloadTask *_download;
|
||||
NSURLSession *_downloadSession;
|
||||
NSString *_bundleIdentifier;
|
||||
NSString *_desiredFilename;
|
||||
NSString *_downloadFilename;
|
||||
|
||||
// Delegate is intentionally strongly referenced; see header
|
||||
id <SPUDownloaderDelegate> _delegate;
|
||||
|
||||
SPUDownloadMode _mode;
|
||||
|
||||
BOOL _disabledAutomaticTermination;
|
||||
BOOL _receivedExpectedBytes;
|
||||
}
|
||||
|
||||
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate
|
||||
{
|
||||
@@ -61,58 +53,58 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startDownloadWithRequest:(SPUURLRequest *)request
|
||||
- (void)startDownloadWithRequest:(NSURLRequest *)request SPU_OBJC_DIRECT
|
||||
{
|
||||
self.downloadSession = [NSURLSession
|
||||
_downloadSession = [NSURLSession
|
||||
sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
|
||||
delegate:self
|
||||
delegateQueue:[NSOperationQueue mainQueue]];
|
||||
self.download = [self.downloadSession downloadTaskWithRequest:request.request];
|
||||
[self.download resume];
|
||||
_download = [_downloadSession downloadTaskWithRequest:request];
|
||||
[_download resume];
|
||||
}
|
||||
|
||||
// Don't implement dealloc - make the client call cleanup, which is the only way to remove the reference cycle from the delegate anyway
|
||||
|
||||
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
|
||||
- (void)startPersistentDownloadWithRequest:(NSURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.download == nil && self.delegate != nil) {
|
||||
if (self->_download == nil && self->_delegate != nil) {
|
||||
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||
self.disabledAutomaticTermination = YES;
|
||||
self->_disabledAutomaticTermination = YES;
|
||||
|
||||
self.mode = SPUDownloadModePersistent;
|
||||
self.desiredFilename = desiredFilename;
|
||||
self.bundleIdentifier = bundleIdentifier;
|
||||
self->_mode = SPUDownloadModePersistent;
|
||||
self->_desiredFilename = desiredFilename;
|
||||
self->_bundleIdentifier = [bundleIdentifier copy];
|
||||
|
||||
[self startDownloadWithRequest:request];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
|
||||
- (void)startTemporaryDownloadWithRequest:(NSURLRequest *)request
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.download == nil && self.delegate != nil) {
|
||||
if (self->_download == nil && self->_delegate != nil) {
|
||||
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||
self.disabledAutomaticTermination = YES;
|
||||
self->_disabledAutomaticTermination = YES;
|
||||
|
||||
self.mode = SPUDownloadModeTemporary;
|
||||
self->_mode = SPUDownloadModeTemporary;
|
||||
[self startDownloadWithRequest:request];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)enableAutomaticTermination
|
||||
- (void)enableAutomaticTermination SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.disabledAutomaticTermination) {
|
||||
if (_disabledAutomaticTermination) {
|
||||
[[NSProcessInfo processInfo] enableAutomaticTermination:SUDownloadingReason];
|
||||
self.disabledAutomaticTermination = NO;
|
||||
_disabledAutomaticTermination = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)rootPersistentDownloadCachePathForBundleIdentifier:(NSString *)bundleIdentifier
|
||||
- (NSString *)rootPersistentDownloadCachePathForBundleIdentifier:(NSString *)bundleIdentifier SPU_OBJC_DIRECT
|
||||
{
|
||||
return [[SPULocalCacheDirectory cachePathForBundleIdentifier:bundleIdentifier] stringByAppendingPathComponent:@"PersistentDownloads"];
|
||||
}
|
||||
@@ -134,19 +126,19 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_cleanup
|
||||
- (void)_cleanup SPU_OBJC_DIRECT
|
||||
{
|
||||
[self enableAutomaticTermination];
|
||||
[self.download cancel];
|
||||
[self.downloadSession finishTasksAndInvalidate];
|
||||
self.download = nil;
|
||||
self.downloadSession = nil;
|
||||
self.delegate = nil;
|
||||
[_download cancel];
|
||||
[_downloadSession finishTasksAndInvalidate];
|
||||
_download = nil;
|
||||
_downloadSession = nil;
|
||||
_delegate = nil;
|
||||
|
||||
if (self.mode == SPUDownloadModeTemporary && self.downloadFilename != nil)
|
||||
if (_mode == SPUDownloadModeTemporary && _downloadFilename != nil)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:NULL];
|
||||
self.downloadFilename = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath:_downloadFilename error:NULL];
|
||||
_downloadFilename = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,24 +151,24 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
});
|
||||
}
|
||||
|
||||
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *) downloadTask didFinishDownloadingToURL:(NSURL *)location
|
||||
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
|
||||
{
|
||||
NSInteger statusCode = [downloadTask.response isKindOfClass:[NSHTTPURLResponse class]] ? ((NSHTTPURLResponse *)downloadTask.response).statusCode : 200;
|
||||
if ((statusCode < 200) || (statusCode >= 400))
|
||||
{
|
||||
NSString *message = [NSString stringWithFormat:@"A network error occurred while downloading the update. %@ (%ld)", [NSHTTPURLResponse localizedStringForStatusCode:statusCode], (long)statusCode];
|
||||
NSString *message = [NSString stringWithFormat:@"A network error occurred while downloading %@. %@ (%ld)", downloadTask.originalRequest.URL.absoluteString, [NSHTTPURLResponse localizedStringForStatusCode:statusCode], (long)statusCode];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
[self.delegate downloaderDidFailWithError:error];
|
||||
[_delegate downloaderDidFailWithError:error];
|
||||
}
|
||||
else if (self.mode == SPUDownloadModeTemporary)
|
||||
else if (_mode == SPUDownloadModeTemporary)
|
||||
{
|
||||
self.downloadFilename = location.path;
|
||||
_downloadFilename = location.path;
|
||||
[self downloadDidFinish]; // file is already in a system temp dir
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove our old caches path so we don't start accumulating files in there
|
||||
NSString *rootPersistentDownloadCachePath = [self rootPersistentDownloadCachePathForBundleIdentifier:self.bundleIdentifier];
|
||||
NSString *rootPersistentDownloadCachePath = [self rootPersistentDownloadCachePathForBundleIdentifier:_bundleIdentifier];
|
||||
|
||||
[SPULocalCacheDirectory removeOldItemsInDirectory:rootPersistentDownloadCachePath];
|
||||
|
||||
@@ -184,23 +176,23 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
if (tempDir == nil)
|
||||
{
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[self.download cancel];
|
||||
self.download = nil;
|
||||
[_download cancel];
|
||||
_download = nil;
|
||||
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", tempDir] }];
|
||||
|
||||
[self.delegate downloaderDidFailWithError:error];
|
||||
[_delegate downloaderDidFailWithError:error];
|
||||
} else {
|
||||
NSString *downloadFileName = self.desiredFilename;
|
||||
NSString *downloadFileName = _desiredFilename;
|
||||
NSString *downloadFileNameDirectory = [tempDir stringByAppendingPathComponent:downloadFileName];
|
||||
|
||||
NSError *createError = nil;
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:downloadFileNameDirectory withIntermediateDirectories:NO attributes:nil error:&createError]) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a download file name %@ directory inside temporary directory for the update download at %@.", downloadFileName, downloadFileNameDirectory] }];
|
||||
|
||||
[self.delegate downloaderDidFailWithError:error];
|
||||
[_delegate downloaderDidFailWithError:error];
|
||||
} else {
|
||||
NSString *name = self.download.response.suggestedFilename;
|
||||
NSString *name = _download.response.suggestedFilename;
|
||||
if (!name) {
|
||||
name = location.lastPathComponent; // This likely contains nothing useful to identify the file (e.g. CFNetworkDownload_87LVIz.tmp)
|
||||
}
|
||||
@@ -208,11 +200,11 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
NSString *fromPath = location.path; // suppress moveItemAtPath: non-null warning
|
||||
NSError *error = nil;
|
||||
if ([[NSFileManager defaultManager] moveItemAtPath:fromPath toPath:toPath error:&error]) {
|
||||
self.downloadFilename = toPath;
|
||||
[self.delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
|
||||
_downloadFilename = toPath;
|
||||
[_delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
|
||||
[self downloadDidFinish];
|
||||
} else {
|
||||
[self.delegate downloaderDidFailWithError:error];
|
||||
[_delegate downloaderDidFailWithError:error];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,33 +214,33 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)__unused downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)__unused totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
|
||||
{
|
||||
|
||||
if (self.mode == SPUDownloadModePersistent && totalBytesExpectedToWrite > 0 && !self.receivedExpectedBytes) {
|
||||
self.receivedExpectedBytes = YES;
|
||||
[self.delegate downloaderDidReceiveExpectedContentLength:totalBytesExpectedToWrite];
|
||||
if (_mode == SPUDownloadModePersistent && totalBytesExpectedToWrite > 0 && !_receivedExpectedBytes) {
|
||||
_receivedExpectedBytes = YES;
|
||||
[_delegate downloaderDidReceiveExpectedContentLength:totalBytesExpectedToWrite];
|
||||
}
|
||||
|
||||
if (self.mode == SPUDownloadModePersistent && bytesWritten >= 0) {
|
||||
[self.delegate downloaderDidReceiveDataOfLength:(uint64_t)bytesWritten];
|
||||
if (_mode == SPUDownloadModePersistent && bytesWritten >= 0) {
|
||||
[_delegate downloaderDidReceiveDataOfLength:(uint64_t)bytesWritten];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish
|
||||
- (void)downloadDidFinish SPU_OBJC_DIRECT
|
||||
{
|
||||
assert(self.downloadFilename != nil);
|
||||
assert(_downloadFilename != nil);
|
||||
|
||||
SPUDownloadData *downloadData = nil;
|
||||
if (self.mode == SPUDownloadModeTemporary) {
|
||||
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
|
||||
if (_mode == SPUDownloadModeTemporary) {
|
||||
NSData *data = [NSData dataWithContentsOfFile:_downloadFilename];
|
||||
if (data != nil) {
|
||||
NSURLResponse *response = self.download.response;
|
||||
NSURLResponse *response = _download.response;
|
||||
assert(response != nil);
|
||||
|
||||
NSURL *responseURL = response.URL;
|
||||
if (responseURL == nil) {
|
||||
responseURL = self.download.currentRequest.URL;
|
||||
responseURL = _download.currentRequest.URL;
|
||||
}
|
||||
if (responseURL == nil) {
|
||||
responseURL = self.download.originalRequest.URL;
|
||||
responseURL = _download.originalRequest.URL;
|
||||
}
|
||||
assert(responseURL != nil);
|
||||
|
||||
@@ -256,29 +248,29 @@ static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||
}
|
||||
}
|
||||
|
||||
self.download = nil;
|
||||
_download = nil;
|
||||
|
||||
switch (self.mode) {
|
||||
switch (_mode) {
|
||||
case SPUDownloadModeTemporary:
|
||||
if (downloadData != nil) {
|
||||
[self.delegate downloaderDidFinishWithTemporaryDownloadData:downloadData];
|
||||
[_delegate downloaderDidFinishWithTemporaryDownloadData:downloadData];
|
||||
} else {
|
||||
[self.delegate downloaderDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", self.downloadFilename]}]];
|
||||
[_delegate downloaderDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", _downloadFilename]}]];
|
||||
}
|
||||
|
||||
[self _cleanup];
|
||||
break;
|
||||
case SPUDownloadModePersistent:
|
||||
[self.delegate downloaderDidFinishWithTemporaryDownloadData:nil];
|
||||
[_delegate downloaderDidFinishWithTemporaryDownloadData:nil];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)URLSession:(NSURLSession *)__unused session task:(NSURLSessionTask *)__unused task didCompleteWithError:(NSError *)error
|
||||
{
|
||||
self.download = nil;
|
||||
_download = nil;
|
||||
if (error != nil) {
|
||||
[self.delegate downloaderDidFailWithError:error];
|
||||
[_delegate downloaderDidFailWithError:error];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUURLRequest;
|
||||
|
||||
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
|
||||
@protocol SPUDownloaderProtocol
|
||||
|
||||
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
|
||||
- (void)startPersistentDownloadWithRequest:(NSURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
|
||||
|
||||
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
|
||||
- (void)startTemporaryDownloadWithRequest:(NSURLRequest *)request;
|
||||
|
||||
- (void)removeDownloadDirectory:(NSString *)directoryName bundleIdentifier:(NSString *)bundleIdentifier;
|
||||
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
|
||||
@interface SUInstallerConnection : NSObject <SUInstallerConnectionProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUInstallerConnection : NSObject <SUInstallerConnectionProtocol>
|
||||
|
||||
// Due to XPC reasons, this delegate is strongly referenced, until it's invalidated
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate;
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate remote:(BOOL)remote;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -14,101 +14,141 @@
|
||||
static NSString *SUInstallerConnectionKeepAliveReason = @"Installer Connection Keep Alive";
|
||||
|
||||
@interface SUInstallerConnection () <SUInstallerCommunicationProtocol>
|
||||
|
||||
// Intentionally not weak for XPC reasons
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> delegate;
|
||||
|
||||
@property (nonatomic) BOOL disabledAutomaticTermination;
|
||||
@property (nonatomic, copy) void (^invalidationBlock)(void);
|
||||
@property (nonatomic) NSXPCConnection *connection;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUInstallerConnection
|
||||
{
|
||||
NSXPCConnection *_connection;
|
||||
// Intentionally not weak for XPC reasons
|
||||
id<SUInstallerCommunicationProtocol> _delegate;
|
||||
|
||||
void (^_invalidationBlock)(void);
|
||||
|
||||
BOOL _disabledAutomaticTermination;
|
||||
BOOL _remote;
|
||||
}
|
||||
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize disabledAutomaticTermination = _disabledAutomaticTermination;
|
||||
@synthesize invalidationBlock = _invalidationBlock;
|
||||
@synthesize connection = _connection;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate remote:(BOOL)remote
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_delegate = delegate;
|
||||
_remote = remote;
|
||||
|
||||
// If we are a XPC service, protect it from being terminated until the invalidation handler is set
|
||||
_disabledAutomaticTermination = YES;
|
||||
[[NSProcessInfo processInfo] disableAutomaticTermination:SUInstallerConnectionKeepAliveReason];
|
||||
if (remote) {
|
||||
// If we are a XPC service, protect it from being terminated until the invalidation handler is set
|
||||
_disabledAutomaticTermination = YES;
|
||||
[[NSProcessInfo processInfo] disableAutomaticTermination:SUInstallerConnectionKeepAliveReason];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)enableAutomaticTermination
|
||||
- (void)enableAutomaticTermination SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.disabledAutomaticTermination) {
|
||||
if (_disabledAutomaticTermination) {
|
||||
[[NSProcessInfo processInfo] enableAutomaticTermination:SUInstallerConnectionKeepAliveReason];
|
||||
self.disabledAutomaticTermination = NO;
|
||||
_disabledAutomaticTermination = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler
|
||||
- (void)_setInvalidationHandler:(void (^)(void))invalidationHandler SPU_OBJC_DIRECT
|
||||
{
|
||||
self.invalidationBlock = invalidationHandler;
|
||||
_invalidationBlock = [invalidationHandler copy];
|
||||
|
||||
// No longer needed because of invalidation callback
|
||||
[self enableAutomaticTermination];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName systemDomain:(BOOL)systemDomain
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler
|
||||
{
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _setInvalidationHandler:invalidationHandler];
|
||||
});
|
||||
} else {
|
||||
[self _setInvalidationHandler:invalidationHandler];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_setServiceName:(NSString *)serviceName systemDomain:(BOOL)systemDomain SPU_OBJC_DIRECT
|
||||
{
|
||||
NSXPCConnectionOptions options = systemDomain ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:options];
|
||||
|
||||
connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
connection.exportedObject = self.delegate;
|
||||
connection.exportedObject = _delegate;
|
||||
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
|
||||
self.connection = connection;
|
||||
_connection = connection;
|
||||
|
||||
__weak SUInstallerConnection *weakSelf = self;
|
||||
self.connection.interruptionHandler = ^{
|
||||
[weakSelf.connection invalidate];
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
_connection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_connection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.connection.invalidationHandler = ^{
|
||||
SUInstallerConnection *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.connection = nil;
|
||||
[strongSelf invalidate];
|
||||
}
|
||||
_connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf->_connection = nil;
|
||||
[strongSelf _invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[self.connection resume];
|
||||
[_connection resume];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName systemDomain:(BOOL)systemDomain
|
||||
{
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _setServiceName:serviceName systemDomain:systemDomain];
|
||||
});
|
||||
} else {
|
||||
[self _setServiceName:serviceName systemDomain:systemDomain];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
{
|
||||
[(id<SUInstallerCommunicationProtocol>)self.connection.remoteObjectProxy handleMessageWithIdentifier:identifier data:data];
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(id<SUInstallerCommunicationProtocol>)self->_connection.remoteObjectProxy handleMessageWithIdentifier:identifier data:data];
|
||||
});
|
||||
} else {
|
||||
[(id<SUInstallerCommunicationProtocol>)_connection.remoteObjectProxy handleMessageWithIdentifier:identifier data:data];
|
||||
}
|
||||
}
|
||||
|
||||
// This method can be called by us or from a remote
|
||||
- (void)_invalidate SPU_OBJC_DIRECT
|
||||
{
|
||||
if (_invalidationBlock != nil) {
|
||||
_invalidationBlock();
|
||||
_invalidationBlock = nil;
|
||||
}
|
||||
|
||||
// Break the retain cycle
|
||||
_delegate = nil;
|
||||
|
||||
[self enableAutomaticTermination];
|
||||
}
|
||||
|
||||
// This method can be called from us or a remote
|
||||
- (void)invalidate
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.connection invalidate];
|
||||
self.connection = nil;
|
||||
[self->_connection invalidate];
|
||||
self->_connection = nil;
|
||||
|
||||
if (self.invalidationBlock != nil) {
|
||||
self.invalidationBlock();
|
||||
self.invalidationBlock = nil;
|
||||
}
|
||||
|
||||
// Break the retain cycle
|
||||
self.delegate = nil;
|
||||
|
||||
[self enableAutomaticTermination];
|
||||
[self _invalidate];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if INSTALLER_CONNECTION_XPC_SERVICE_EMBEDDED
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerConnectionProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUXPCInstallerConnection : NSObject <SUInstallerConnectionProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUXPCInstallerConnection : NSObject <SUInstallerConnectionProtocol>
|
||||
|
||||
// Due to XPC reasons, this delegate is strongly referenced, until it's invalidated
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate;
|
||||
@@ -19,3 +21,5 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -6,24 +6,21 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if INSTALLER_CONNECTION_XPC_SERVICE_EMBEDDED
|
||||
|
||||
#import "SUXPCInstallerConnection.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUXPCInstallerConnection ()
|
||||
|
||||
@property (nonatomic) NSXPCConnection *connection;
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> delegate; // intentionally not weak for XPC reasons
|
||||
@property (nonatomic, copy) void (^invalidationBlock)(void);
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUXPCInstallerConnection
|
||||
|
||||
@synthesize connection = _connection;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize invalidationBlock = _invalidationBlock;
|
||||
{
|
||||
NSXPCConnection *_connection;
|
||||
// Intentionally not weak for XPC reasons
|
||||
id<SUInstallerCommunicationProtocol> _delegate;
|
||||
|
||||
void (^_invalidationBlock)(void);
|
||||
}
|
||||
|
||||
- (instancetype)initWithDelegate:(id<SUInstallerCommunicationProtocol>)delegate
|
||||
{
|
||||
@@ -32,14 +29,17 @@
|
||||
_connection = [[NSXPCConnection alloc] initWithServiceName:@INSTALLER_CONNECTION_BUNDLE_ID];
|
||||
_connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerConnectionProtocol)];
|
||||
|
||||
__weak SUXPCInstallerConnection *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
_connection.invalidationHandler = ^{
|
||||
[weakSelf invokeInvalidation];
|
||||
};
|
||||
|
||||
_connection.interruptionHandler = ^{
|
||||
[weakSelf invokeInvalidation];
|
||||
[weakSelf.connection invalidate];
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf invokeInvalidation];
|
||||
[strongSelf->_connection invalidate];
|
||||
}
|
||||
};
|
||||
|
||||
_delegate = delegate;
|
||||
@@ -54,39 +54,41 @@
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler
|
||||
{
|
||||
self.invalidationBlock = invalidationHandler;
|
||||
_invalidationBlock = [invalidationHandler copy];
|
||||
|
||||
__weak SUXPCInstallerConnection *weakSelf = self;
|
||||
[(id<SUInstallerConnectionProtocol>)self.connection.remoteObjectProxy setInvalidationHandler:^{
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[(id<SUInstallerConnectionProtocol>)_connection.remoteObjectProxy setInvalidationHandler:^{
|
||||
[weakSelf invokeInvalidation];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName systemDomain:(BOOL)systemDomain
|
||||
{
|
||||
[(id<SUInstallerConnectionProtocol>)self.connection.remoteObjectProxy setServiceName:serviceName systemDomain:systemDomain];
|
||||
[(id<SUInstallerConnectionProtocol>)_connection.remoteObjectProxy setServiceName:serviceName systemDomain:systemDomain];
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
{
|
||||
[(id<SUInstallerConnectionProtocol>)self.connection.remoteObjectProxy handleMessageWithIdentifier:identifier data:data];
|
||||
[(id<SUInstallerConnectionProtocol>)_connection.remoteObjectProxy handleMessageWithIdentifier:identifier data:data];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[(id<SUInstallerConnectionProtocol>)self.connection.remoteObjectProxy invalidate];
|
||||
[self.connection invalidate];
|
||||
self.connection = nil;
|
||||
[(id<SUInstallerConnectionProtocol>)_connection.remoteObjectProxy invalidate];
|
||||
[_connection invalidate];
|
||||
_connection = nil;
|
||||
}
|
||||
|
||||
- (void)invokeInvalidation
|
||||
- (void)invokeInvalidation SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.invalidationBlock != nil) {
|
||||
self.invalidationBlock();
|
||||
self.invalidationBlock = nil;
|
||||
if (_invalidationBlock != nil) {
|
||||
_invalidationBlock();
|
||||
_invalidationBlock = nil;
|
||||
}
|
||||
// Break our retain cycle
|
||||
self.delegate = nil;
|
||||
_delegate = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerConnectionProtocol)];
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
|
||||
SUInstallerConnection *exportedObject = [[SUInstallerConnection alloc] initWithDelegate:newConnection.remoteObjectProxy];
|
||||
SUInstallerConnection *exportedObject = [[SUInstallerConnection alloc] initWithDelegate:newConnection.remoteObjectProxy remote:YES];
|
||||
|
||||
newConnection.exportedObject = exportedObject;
|
||||
|
||||
|
||||
@@ -9,10 +9,18 @@
|
||||
#ifndef SUInstallerLauncher_Private_h
|
||||
#define SUInstallerLauncher_Private_h
|
||||
|
||||
#if defined(BUILDING_SPARKLE_SOURCES_EXTERNALLY)
|
||||
// Ignore incorrect warning
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
|
||||
#import "SUExport.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#pragma clang diagnostic pop
|
||||
#else
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
// Chances are clients will need this too
|
||||
#import <Sparkle/SPUInstallationType.h>
|
||||
#endif
|
||||
|
||||
@class NSString;
|
||||
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
#import "SUHost.h"
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUInstallerLauncher
|
||||
|
||||
- (BOOL)submitProgressToolAtPath:(NSString *)progressToolPath withHostBundle:(NSBundle *)hostBundle inSystemDomainForInstaller:(BOOL)inSystemDomainForInstaller
|
||||
- (BOOL)submitProgressToolAtPath:(NSString *)progressToolPath withHostBundle:(NSBundle *)hostBundle inSystemDomainForInstaller:(BOOL)inSystemDomainForInstaller SPU_OBJC_DIRECT
|
||||
{
|
||||
SUFileManager *fileManager = [[SUFileManager alloc] init];
|
||||
|
||||
@@ -70,13 +73,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
// If we are running as the root user, there is no need to explicitly set the UserName / GroupName keys
|
||||
// because we are submitting under the user domain, which should automatically use the the console user.
|
||||
NSMutableDictionary *jobDictionary = [[NSMutableDictionary alloc] init];
|
||||
jobDictionary[@"Label"] = label;
|
||||
jobDictionary[@"ProgramArguments"] = arguments;
|
||||
jobDictionary[@"EnableTransactions"] = @NO;
|
||||
jobDictionary[@"KeepAlive"] = @{@"SuccessfulExit" : @NO};
|
||||
jobDictionary[@"RunAtLoad"] = @NO;
|
||||
jobDictionary[@"NICE"] = @0;
|
||||
jobDictionary[@"Nice"] = @0;
|
||||
jobDictionary[@"ProcessType"] = @"Interactive";
|
||||
jobDictionary[@"LaunchOnlyOnce"] = @YES;
|
||||
jobDictionary[@"MachServices"] = @{SPUStatusInfoServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES};
|
||||
|
||||
@@ -100,7 +106,7 @@
|
||||
return (submittedJob == true);
|
||||
}
|
||||
|
||||
- (SUInstallerLauncherStatus)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle updaterIdentifier:(NSString *)updaterIdentifier authorizationPrompt:(NSString *)authorizationPrompt inSystemDomain:(BOOL)systemDomain
|
||||
- (SUInstallerLauncherStatus)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle updaterIdentifier:(NSString *)updaterIdentifier userName:(NSString *)userName homeDirectory:(NSString *)homeDirectory authorizationPrompt:(NSString *)authorizationPrompt inSystemDomain:(BOOL)systemDomain rootUser:(BOOL)rootUser SPU_OBJC_DIRECT
|
||||
{
|
||||
SUFileManager *fileManager = [[SUFileManager alloc] init];
|
||||
|
||||
@@ -110,12 +116,6 @@
|
||||
NSString *hostBundleIdentifier = hostBundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
|
||||
NSString *homeDirectory = NSHomeDirectory();
|
||||
assert(homeDirectory != nil);
|
||||
|
||||
NSString *userName = NSUserName();
|
||||
assert(userName != nil);
|
||||
|
||||
// The first argument has to be the path to the program, and the second is a host identifier so that the installer knows what mach services to host
|
||||
// The third and forth arguments are for home directory and user name which only pkg installer scripts may need
|
||||
// We intentionally do not pass any more arguments. Anything else should be done via IPC.
|
||||
@@ -133,7 +133,7 @@
|
||||
|
||||
BOOL canceledAuthorization = NO;
|
||||
BOOL failedToUseSystemDomain = NO;
|
||||
if (auth != NULL && systemDomain) {
|
||||
if (auth != NULL && systemDomain && !rootUser) {
|
||||
// See Apple's 'EvenBetterAuthorizationSample' sample code and
|
||||
// https://developer.apple.com/library/mac/technotes/tn2095/_index.html#//apple_ref/doc/uid/DTS10003110-CH1-SECTION7
|
||||
// We can set a custom right name for authenticating as an administrator
|
||||
@@ -207,7 +207,17 @@
|
||||
NSString *path = [[NSString alloc] initWithUTF8String:pathBuffer];
|
||||
tempIconDestinationURL = [NSURL fileURLWithPath:path];
|
||||
|
||||
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, kUTTypePNG, 1, NULL);
|
||||
CGImageDestinationRef imageDestination = NULL;
|
||||
if (@available(macOS 11, *)) {
|
||||
CFStringRef uti = (__bridge CFStringRef)[UTTypePNG identifier];
|
||||
imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, uti, 1, NULL);
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
|
||||
else
|
||||
{
|
||||
imageDestination = CGImageDestinationCreateWithURL((CFURLRef)tempIconDestinationURL, kUTTypePNG, 1, NULL);
|
||||
}
|
||||
#endif
|
||||
if (imageDestination != NULL) {
|
||||
CGImageDestinationAddImageFromSource(imageDestination, imageSource, imageIndex, (CFDictionaryRef)@{});
|
||||
if (CGImageDestinationFinalize(imageDestination)) {
|
||||
@@ -269,7 +279,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"Nice" : @0, @"LaunchOnlyOnce": @YES, @"MachServices" : @{SPUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SPUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"Nice" : @0, @"ProcessType": @"Interactive", @"LaunchOnlyOnce": @YES, @"MachServices" : @{SPUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SPUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
#pragma clang diagnostic push
|
||||
@@ -301,7 +311,7 @@
|
||||
return status;
|
||||
}
|
||||
|
||||
- (NSString *)pathForBundledTool:(NSString *)toolName extension:(NSString *)extension fromBundle:(NSBundle *)bundle
|
||||
- (NSString *)pathForBundledTool:(NSString *)toolName extension:(NSString *)extension fromBundle:(NSBundle *)bundle SPU_OBJC_DIRECT
|
||||
{
|
||||
// If the path extension is empty, we don't want to add a "." at the end
|
||||
NSString *nameWithExtension = (extension.length > 0) ? [toolName stringByAppendingPathExtension:extension] : toolName;
|
||||
@@ -361,38 +371,57 @@ BOOL SPUSystemNeedsAuthorizationAccessForBundlePath(NSString *bundlePath)
|
||||
return needsAuthorization;
|
||||
}
|
||||
|
||||
static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installationType)
|
||||
static BOOL SPUUsesSystemDomainForBundlePath(NSString *path, BOOL rootUser
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
, NSString *installationType
|
||||
#endif
|
||||
)
|
||||
{
|
||||
BOOL needsAuthorization;
|
||||
if ([installationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
needsAuthorization = YES;
|
||||
} else if ([installationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
needsAuthorization = NO;
|
||||
if (!rootUser) {
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
if ([installationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
return YES;
|
||||
} else if ([installationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
return NO;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
return SPUSystemNeedsAuthorizationAccessForBundlePath(path);
|
||||
}
|
||||
} else {
|
||||
needsAuthorization = SPUSystemNeedsAuthorizationAccessForBundlePath(path);
|
||||
// If we are the root user we use the system domain even if we don't need escalated authorization.
|
||||
// Note interactive package installations are not supported as root.
|
||||
return YES;
|
||||
}
|
||||
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 completion:(void (^)(SUInstallerLauncherStatus, BOOL))completionHandler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
BOOL needsSystemAuthorization = SPUSystemNeedsAuthorizationAccess(hostBundlePath, installationType);
|
||||
// We could do a sort of preflight Authorization test instead of testing if we are running as root,
|
||||
// but I think this is not necessarily a better approach. We have to chown() the launcher cache directory later on,
|
||||
// and that is not necessarily related to a preflight test. It's more related to being ran under a root / different user from the active GUI session
|
||||
BOOL rootUser = (geteuid() == 0);
|
||||
|
||||
BOOL inSystemDomain = SPUUsesSystemDomainForBundlePath(hostBundlePath, rootUser
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
, installationType
|
||||
#endif
|
||||
);
|
||||
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
if (hostBundle == nil) {
|
||||
SULog(SULogLevelError, @"InstallerLauncher failed to create bundle at %@", hostBundlePath);
|
||||
SULog(SULogLevelError, @"Please make sure InstallerLauncher is not sandboxed and do not sign your app by passing --deep. Check: codesign -d --entitlements :- \"%@\"", NSBundle.mainBundle.bundlePath);
|
||||
SULog(SULogLevelError, @"More information regarding sandboxing: https://sparkle-project.org/documentation/sandboxing/");
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
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);
|
||||
// if we need to use the system authorization from non-root and we aren't allowed interaction, then try sometime later when interaction is allowed
|
||||
if (inSystemDomain && !rootUser && !allowingDriverInteraction) {
|
||||
completionHandler(SUInstallerLauncherAuthorizeLater, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -407,7 +436,7 @@ static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installa
|
||||
NSString *installerPath = [self pathForBundledTool:@""SPARKLE_RELAUNCH_TOOL_NAME extension:@"" fromBundle:ourBundle];
|
||||
if (installerPath == nil) {
|
||||
SULog(SULogLevelError, @"Error: Cannot submit installer because the installer could not be located");
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -416,7 +445,7 @@ static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installa
|
||||
|
||||
if (progressToolResourcePath == nil) {
|
||||
SULog(SULogLevelError, @"Error: Cannot submit progress tool because the progress tool could not be located");
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -432,25 +461,69 @@ static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installa
|
||||
NSString *launcherCachePath = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:rootLauncherCachePath];
|
||||
if (launcherCachePath == nil) {
|
||||
SULog(SULogLevelError, @"Failed to create cache directory for progress tool in %@", rootLauncherCachePath);
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [[SUFileManager alloc] init];
|
||||
|
||||
NSString *userName;
|
||||
NSString *homeDirectory;
|
||||
if (!rootUser) {
|
||||
// Normal path
|
||||
homeDirectory = NSHomeDirectory();
|
||||
assert(homeDirectory != nil);
|
||||
|
||||
userName = NSUserName();
|
||||
assert(userName != nil);
|
||||
} else {
|
||||
// As the root user we need to obtain the user name and home directory reflecting
|
||||
// the user's console session.
|
||||
|
||||
uid_t uid = 0;
|
||||
gid_t gid = 0;
|
||||
CFStringRef userNameRef = SCDynamicStoreCopyConsoleUser(NULL, &uid, &gid);
|
||||
if (userNameRef == NULL) {
|
||||
SULog(SULogLevelError, @"Failed to retrieve user name from the console user");
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
userName = (NSString *)CFBridgingRelease(userNameRef);
|
||||
homeDirectory = NSHomeDirectoryForUser(userName);
|
||||
if (homeDirectory == nil) {
|
||||
SULog(SULogLevelError, @"Failed to retrieve home directory for user: %@", userName);
|
||||
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure the console user has ownership of the launcher cache directory
|
||||
// Otherwise the updater may not launch and not be able to clean up itself
|
||||
NSError *changeOwnerAndGroupError = nil;
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtURL:[NSURL fileURLWithPath:launcherCachePath] ownerID:uid groupID:gid error:&changeOwnerAndGroupError]) {
|
||||
SULog(SULogLevelError, @"Failed to change owner and group for launcher cache directory: %@", changeOwnerAndGroupError);
|
||||
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NSString *progressToolPath = [launcherCachePath stringByAppendingPathComponent:@""SPARKLE_INSTALLER_PROGRESS_TOOL_NAME@".app"];
|
||||
|
||||
NSError *copyError = nil;
|
||||
// SUFileManager is more reliable for copying files around
|
||||
if (![[[SUFileManager alloc] init] copyItemAtURL:[NSURL fileURLWithPath:progressToolResourcePath] toURL:[NSURL fileURLWithPath:progressToolPath] error:©Error]) {
|
||||
if (![fileManager copyItemAtURL:[NSURL fileURLWithPath:progressToolResourcePath] toURL:[NSURL fileURLWithPath:progressToolPath] error:©Error]) {
|
||||
SULog(SULogLevelError, @"Failed to copy progress tool to cache: %@", copyError);
|
||||
completionHandler(SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(SUInstallerLauncherFailure, inSystemDomain);
|
||||
return;
|
||||
}
|
||||
|
||||
SUInstallerLauncherStatus installerStatus = [self submitInstallerAtPath:installerPath withHostBundle:hostBundle updaterIdentifier:updaterIdentifier authorizationPrompt:authorizationPrompt inSystemDomain:needsSystemAuthorization];
|
||||
SUInstallerLauncherStatus installerStatus = [self submitInstallerAtPath:installerPath withHostBundle:hostBundle updaterIdentifier:updaterIdentifier userName:userName homeDirectory:homeDirectory authorizationPrompt:authorizationPrompt inSystemDomain:inSystemDomain rootUser:rootUser];
|
||||
|
||||
BOOL submittedProgressTool = NO;
|
||||
if (installerStatus == SUInstallerLauncherSuccess) {
|
||||
submittedProgressTool = [self submitProgressToolAtPath:progressToolPath withHostBundle:hostBundle inSystemDomainForInstaller:needsSystemAuthorization];
|
||||
submittedProgressTool = [self submitProgressToolAtPath:progressToolPath withHostBundle:hostBundle inSystemDomainForInstaller:inSystemDomain];
|
||||
|
||||
if (!submittedProgressTool) {
|
||||
SULog(SULogLevelError, @"Failed to submit progress tool job");
|
||||
@@ -461,9 +534,9 @@ static BOOL SPUSystemNeedsAuthorizationAccess(NSString *path, NSString *installa
|
||||
}
|
||||
|
||||
if (installerStatus == SUInstallerLauncherCanceled) {
|
||||
completionHandler(installerStatus, needsSystemAuthorization);
|
||||
completionHandler(installerStatus, inSystemDomain);
|
||||
} else {
|
||||
completionHandler(submittedProgressTool ? SUInstallerLauncherSuccess : SUInstallerLauncherFailure, needsSystemAuthorization);
|
||||
completionHandler(submittedProgressTool ? SUInstallerLauncherSuccess : SUInstallerLauncherFailure, inSystemDomain);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#import "SUInstallerStatusProtocol.h"
|
||||
|
||||
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
|
||||
@interface SUInstallerStatus : NSObject <SUInstallerStatusProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUInstallerStatus : NSObject <SUInstallerStatusProtocol>
|
||||
|
||||
- (instancetype)initWithRemote:(BOOL)remote;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
@@ -11,68 +11,115 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUInstallerStatus ()
|
||||
|
||||
@property (nonatomic, copy) void (^invalidationBlock)(void);
|
||||
@property (nonatomic) NSXPCConnection *connection;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUInstallerStatus
|
||||
{
|
||||
NSXPCConnection *_connection;
|
||||
|
||||
void (^_invalidationBlock)(void);
|
||||
|
||||
BOOL _remote;
|
||||
}
|
||||
|
||||
@synthesize invalidationBlock = _invalidationBlock;
|
||||
@synthesize connection = _connection;
|
||||
- (instancetype)initWithRemote:(BOOL)remote
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_remote = remote;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler
|
||||
{
|
||||
self.invalidationBlock = invalidationHandler;
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self->_invalidationBlock = [invalidationHandler copy];
|
||||
});
|
||||
} else {
|
||||
_invalidationBlock = [invalidationHandler copy];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
- (void)_setServiceName:(NSString *)serviceName SPU_OBJC_DIRECT
|
||||
{
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:(NSXPCConnectionOptions)0];
|
||||
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUStatusInfoProtocol)];
|
||||
|
||||
self.connection = connection;
|
||||
_connection = connection;
|
||||
|
||||
__weak SUInstallerStatus *weakSelf = self;
|
||||
self.connection.interruptionHandler = ^{
|
||||
[weakSelf.connection invalidate];
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
_connection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_connection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.connection.invalidationHandler = ^{
|
||||
SUInstallerStatus *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.connection = nil;
|
||||
[strongSelf invalidate];
|
||||
}
|
||||
_connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf->_connection = nil;
|
||||
[strongSelf _invokeInvalidationBlock];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[self.connection resume];
|
||||
[_connection resume];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
{
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _setServiceName:serviceName];
|
||||
});
|
||||
} else {
|
||||
[self _setServiceName:serviceName];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable installationInfoData))reply
|
||||
{
|
||||
[(id<SUStatusInfoProtocol>)self.connection.remoteObjectProxy probeStatusInfoWithReply:reply];
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(id<SUStatusInfoProtocol>)self->_connection.remoteObjectProxy probeStatusInfoWithReply:reply];
|
||||
});
|
||||
} else {
|
||||
[(id<SUStatusInfoProtocol>)_connection.remoteObjectProxy probeStatusInfoWithReply:reply];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)probeStatusConnectivityWithReply:(void (^)(void))reply
|
||||
{
|
||||
[(id<SUStatusInfoProtocol>)self.connection.remoteObjectProxy probeStatusConnectivityWithReply:reply];
|
||||
if (_remote) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(id<SUStatusInfoProtocol>)self->_connection.remoteObjectProxy probeStatusConnectivityWithReply:reply];
|
||||
});
|
||||
} else {
|
||||
[(id<SUStatusInfoProtocol>)_connection.remoteObjectProxy probeStatusConnectivityWithReply:reply];
|
||||
}
|
||||
}
|
||||
|
||||
// This method can be called by us or from a remote
|
||||
- (void)_invokeInvalidationBlock SPU_OBJC_DIRECT
|
||||
{
|
||||
if (_invalidationBlock != nil) {
|
||||
_invalidationBlock();
|
||||
_invalidationBlock = nil;
|
||||
}
|
||||
}
|
||||
|
||||
// This method can be called from us or a remote
|
||||
- (void)invalidate
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.connection invalidate];
|
||||
self.connection = nil;
|
||||
[self->_connection invalidate];
|
||||
self->_connection = nil;
|
||||
|
||||
if (self.invalidationBlock != nil) {
|
||||
self.invalidationBlock();
|
||||
self.invalidationBlock = nil;
|
||||
}
|
||||
[self _invokeInvalidationBlock];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if INSTALLER_STATUS_XPC_SERVICE_EMBEDDED
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerStatusProtocol.h"
|
||||
|
||||
@interface SUXPCInstallerStatus : NSObject <SUInstallerStatusProtocol>
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,22 +6,19 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if INSTALLER_STATUS_XPC_SERVICE_EMBEDDED
|
||||
|
||||
#import "SUXPCInstallerStatus.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUXPCInstallerStatus ()
|
||||
|
||||
@property (nonatomic) NSXPCConnection *connection;
|
||||
@property (nonatomic, copy) void (^invalidationBlock)(void);
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUXPCInstallerStatus
|
||||
|
||||
@synthesize connection = _connection;
|
||||
@synthesize invalidationBlock = _invalidationBlock;
|
||||
{
|
||||
NSXPCConnection *_connection;
|
||||
|
||||
void (^_invalidationBlock)(void);
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
@@ -30,14 +27,17 @@
|
||||
_connection = [[NSXPCConnection alloc] initWithServiceName:@INSTALLER_STATUS_BUNDLE_ID];
|
||||
_connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerStatusProtocol)];
|
||||
|
||||
__weak SUXPCInstallerStatus *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
_connection.invalidationHandler = ^{
|
||||
[weakSelf invokeInvalidation];
|
||||
};
|
||||
|
||||
_connection.interruptionHandler = ^{
|
||||
[weakSelf invokeInvalidation];
|
||||
[weakSelf.connection invalidate];
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf invokeInvalidation];
|
||||
[strongSelf->_connection invalidate];
|
||||
}
|
||||
};
|
||||
|
||||
[_connection resume];
|
||||
@@ -47,42 +47,44 @@
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler
|
||||
{
|
||||
self.invalidationBlock = invalidationHandler;
|
||||
_invalidationBlock = [invalidationHandler copy];
|
||||
|
||||
__weak SUXPCInstallerStatus *weakSelf = self;
|
||||
[(id<SUInstallerStatusProtocol>)self.connection.remoteObjectProxy setInvalidationHandler:^{
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[(id<SUInstallerStatusProtocol>)_connection.remoteObjectProxy setInvalidationHandler:^{
|
||||
[weakSelf invokeInvalidation];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
{
|
||||
[(id<SUInstallerStatusProtocol>)self.connection.remoteObjectProxy setServiceName:serviceName];
|
||||
[(id<SUInstallerStatusProtocol>)_connection.remoteObjectProxy setServiceName:serviceName];
|
||||
}
|
||||
|
||||
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable installationInfoData))reply
|
||||
{
|
||||
[(id<SUInstallerStatusProtocol>)self.connection.remoteObjectProxy probeStatusInfoWithReply:reply];
|
||||
[(id<SUInstallerStatusProtocol>)_connection.remoteObjectProxy probeStatusInfoWithReply:reply];
|
||||
}
|
||||
|
||||
- (void)probeStatusConnectivityWithReply:(void (^)(void))reply
|
||||
{
|
||||
[(id<SUInstallerStatusProtocol>)self.connection.remoteObjectProxy probeStatusConnectivityWithReply:reply];
|
||||
[(id<SUInstallerStatusProtocol>)_connection.remoteObjectProxy probeStatusConnectivityWithReply:reply];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[(id<SUInstallerStatusProtocol>)self.connection.remoteObjectProxy invalidate];
|
||||
[self.connection invalidate];
|
||||
self.connection = nil;
|
||||
[(id<SUInstallerStatusProtocol>)_connection.remoteObjectProxy invalidate];
|
||||
[_connection invalidate];
|
||||
_connection = nil;
|
||||
}
|
||||
|
||||
- (void)invokeInvalidation
|
||||
{
|
||||
if (self.invalidationBlock != nil) {
|
||||
self.invalidationBlock();
|
||||
self.invalidationBlock = nil;
|
||||
if (_invalidationBlock != nil) {
|
||||
_invalidationBlock();
|
||||
_invalidationBlock = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -25,7 +25,7 @@
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerStatusProtocol)];
|
||||
|
||||
// Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object.
|
||||
SUInstallerStatus *exportedObject = [SUInstallerStatus new];
|
||||
SUInstallerStatus *exportedObject = [[SUInstallerStatus alloc] initWithRemote:YES];
|
||||
newConnection.exportedObject = exportedObject;
|
||||
|
||||
// Resuming the connection allows the system to deliver more incoming messages.
|
||||
|
||||
@@ -29,13 +29,86 @@ EXTERNAL LICENSES
|
||||
=================
|
||||
|
||||
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>:
|
||||
Copyright (c) 2003-2005 Colin Percival.
|
||||
|
||||
Copyright 2003-2005 Colin Percival
|
||||
All rights reserved
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted providing that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
--
|
||||
|
||||
sais.c and sais.c, from sais-lite (2010/08/07) <https://sites.google.com/site/yuta256/sais>:
|
||||
Copyright (c) 2008-2010 Yuta Mori.
|
||||
|
||||
The sais-lite copyright is as follows:
|
||||
|
||||
Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
--
|
||||
|
||||
Portable C implementation of Ed25519, from https://github.com/orlp/ed25519
|
||||
|
||||
Copyright (c) 2015 Orson Peters <orsonpeters@gmail.com>
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the
|
||||
authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the
|
||||
original software. If you use this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as
|
||||
being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
--
|
||||
|
||||
SUSignatureVerifier.m:
|
||||
Copyright (c) 2011 Mark Hamlin.
|
||||
|
||||
Copyright (c) 2011 Mark Hamlin.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ ifndef BUILDDIR
|
||||
endif
|
||||
|
||||
localizable-strings:
|
||||
rm -f Sparkle/en.lproj/Sparkle.strings
|
||||
genstrings -o Sparkle/en.lproj -s SULocalizedString Sparkle/*.m Sparkle/*.h
|
||||
iconv -f UTF-16 -t UTF-8 < Sparkle/en.lproj/Localizable.strings > Sparkle/en.lproj/Sparkle.strings
|
||||
rm Sparkle/en.lproj/Localizable.strings
|
||||
rm -f Sparkle/Base.lproj/Sparkle.strings
|
||||
genstrings -o Sparkle/Base.lproj -s SULocalizedString Sparkle/*.m
|
||||
iconv -f UTF-16 -t UTF-8 < Sparkle/Base.lproj/Localizable.strings > Sparkle/Base.lproj/Sparkle.strings
|
||||
rm Sparkle/Base.lproj/Localizable.strings
|
||||
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||
|
||||
+3
-3
@@ -2,10 +2,10 @@
|
||||
import PackageDescription
|
||||
|
||||
// Version is technically not required here, SPM doesn't check
|
||||
let version = "2.1.0-beta.1"
|
||||
let version = "2.4.0"
|
||||
// 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.1.0-beta.1"
|
||||
let checksum = "d555665e21a956b87ebeabd56b3522f7e81c5e89c258b320c3d75661ee6b573c"
|
||||
let tag = "2.4.0"
|
||||
let checksum = "44c1a2da814ab922aaf754ed53cd9acb183fe61d43615d1ee83b5744d1533263"
|
||||
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
let package = Package(
|
||||
|
||||
+5
-10
@@ -29,20 +29,13 @@ Please visit [Sparkle's website](http://sparkle-project.org) for up to date docu
|
||||
|
||||
## Requirements
|
||||
|
||||
* Runtime: macOS 10.11 or greater
|
||||
* Runtime: macOS 10.13 or greater for 2.3, macOS 10.11 or greater for 2.2.x
|
||||
* Build: Latest major Xcode (stable or beta, whichever is latest) and one major version less.
|
||||
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||
|
||||
## Usage
|
||||
|
||||
See [getting started guide](https://sparkle-project.org/documentation/). No code is necessary, but a bit of Xcode configuration is required.
|
||||
|
||||
## Development
|
||||
|
||||
This repository uses git submodules, and will not build unless you clone recursively. Also, GitHub-provided ZIP/tar archives are broken due to GitHub not supporting git submodules properly.
|
||||
|
||||
git clone https://github.com/sparkle-project/Sparkle
|
||||
git submodule update --init --recursive
|
||||
See [getting started guide](https://sparkle-project.org/documentation/). No code is necessary, but a bit of configuration is required.
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
@@ -59,7 +52,9 @@ If you are adding a symbol to the public API you must decorate the declaration w
|
||||
|
||||
### Building the distribution package
|
||||
|
||||
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.xz (or .bz2) will be created in a temporary directory and revealed in Finder after the build has completed.
|
||||
You do not usually need to build a Sparkle distribution unless you're making changes to Sparkle itself.
|
||||
|
||||
To build a Sparkle distribution, `cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.xz (or .bz2) will be created in a temporary directory and revealed in Finder after the build has completed.
|
||||
|
||||
Alternatively, build the Distribution scheme in the Xcode UI.
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html {
|
||||
color-scheme: dark;
|
||||
color: white;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>ADP2,1</key>
|
||||
<string>Developer Transition Kit</string>
|
||||
<key>iMac1,1</key>
|
||||
<string>iMac G3 (Rev A-D)</string>
|
||||
<key>iMac4,1</key>
|
||||
<string>iMac (Core Duo)</string>
|
||||
<key>iMac4,2</key>
|
||||
<string>iMac for Education (17 inch, Core Duo)</string>
|
||||
<key>iMac5,1</key>
|
||||
<string>iMac (Core 2 Duo, 17 or 20 inch, SuperDrive)</string>
|
||||
<key>iMac5,2</key>
|
||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||
<key>iMac6,1</key>
|
||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
||||
<key>iMac7,1</key>
|
||||
<string>iMac Intel Core 2 Duo (aluminum enclosure)</string>
|
||||
<key>iMac8,1</key>
|
||||
<string>iMac (Core 2 Duo, 20 or 24 inch, Early 2008 )</string>
|
||||
<key>iMac9,1</key>
|
||||
<string>iMac (Core 2 Duo, 20 or 24 inch, Early or Mid 2009 )</string>
|
||||
<key>iMac10,1</key>
|
||||
<string>iMac (Core 2 Duo, 21.5 or 27 inch, Late 2009 )</string>
|
||||
<key>iMac11,1</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2009)</string>
|
||||
<key>iMac11,2</key>
|
||||
<string>21.5" iMac (mid 2010)</string>
|
||||
<key>iMac11,3</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Mid 2010)</string>
|
||||
<key>iMac12,1</key>
|
||||
<string>iMac (Core i3 or i5 or i7, 21.5 inch Mid 2010 or Late 2011)</string>
|
||||
<key>iMac12,2</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Mid 2011)</string>
|
||||
<key>iMac13,1</key>
|
||||
<string>iMac (Core i3 or i5 or i7, 21.5 inch Late 2012 or Early 2013)</string>
|
||||
<key>iMac13,2</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2012)</string>
|
||||
<key>iMac14,1</key>
|
||||
<string>iMac (Core i5, 21.5 inch Late 2013)</string>
|
||||
<key>iMac14,2</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2013)</string>
|
||||
<key>iMac14,3</key>
|
||||
<string>iMac (Core i5 or i7, 21.5 inch Late 2013)</string>
|
||||
<key>iMac14,4</key>
|
||||
<string>iMac (Core i5, 21.5 inch Mid 2014)</string>
|
||||
<key>iMac15,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2014 or Mid 2015)</string>
|
||||
<key>iMac16,1</key>
|
||||
<string>iMac (Core i5, 21,5 inch Late 2015)</string>
|
||||
<key>iMac16,2</key>
|
||||
<string>iMac (Retina 4K Core i5 or i7, 21.5 inch Late 2015)</string>
|
||||
<key>iMac17,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2015)</string>
|
||||
<key>MacBook1,1</key>
|
||||
<string>MacBook (Core Duo)</string>
|
||||
<key>MacBook2,1</key>
|
||||
<string>MacBook (Core 2 Duo)</string>
|
||||
<key>MacBook4,1</key>
|
||||
<string>MacBook (Core 2 Duo Feb 2008)</string>
|
||||
<key>MacBook5,1</key>
|
||||
<string>MacBook (Core 2 Duo, Late 2008, Unibody)</string>
|
||||
<key>MacBook5,2</key>
|
||||
<string>MacBook (Core 2 Duo, Early 2009, White)</string>
|
||||
<key>MacBook6,1</key>
|
||||
<string>MacBook (Core 2 Duo, Late 2009, Unibody)</string>
|
||||
<key>MacBook7,1</key>
|
||||
<string>MacBook (Core 2 Duo, Mid 2010, White)</string>
|
||||
<key>MacBook8,1</key>
|
||||
<string>MacBook (Core M, 12 inch, Early 2015)</string>
|
||||
<key>MacBookAir1,1</key>
|
||||
<string>MacBook Air (Core 2 Duo, 13 inch, Early 2008)</string>
|
||||
<key>MacBookAir2,1</key>
|
||||
<string>MacBook Air (Core 2 Duo, 13 inch, Mid 2009)</string>
|
||||
<key>MacBookAir3,1</key>
|
||||
<string>MacBook Air (Core 2 Duo, 11 inch, Late 2010)</string>
|
||||
<key>MacBookAir3,2</key>
|
||||
<string>MacBook Air (Core 2 Duo, 13 inch, Late 2010)</string>
|
||||
<key>MacBookAir4,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2011)</string>
|
||||
<key>MacBookAir4,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2011)</string>
|
||||
<key>MacBookAir5,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2012)</string>
|
||||
<key>MacBookAir5,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2012)</string>
|
||||
<key>MacBookAir6,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir6,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir7,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Early 2015)</string>
|
||||
<key>MacBookAir7,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Early 2015)</string>
|
||||
<key>MacBookPro1,1</key>
|
||||
<string>MacBook Pro Core Duo (15-inch)</string>
|
||||
<key>MacBookPro1,2</key>
|
||||
<string>MacBook Pro Core Duo (17-inch)</string>
|
||||
<key>MacBookPro2,1</key>
|
||||
<string>MacBook Pro Core 2 Duo (17-inch)</string>
|
||||
<key>MacBookPro2,2</key>
|
||||
<string>MacBook Pro Core 2 Duo (15-inch)</string>
|
||||
<key>MacBookPro3,1</key>
|
||||
<string>MacBook Pro Core 2 Duo (15-inch LED, Core 2 Duo)</string>
|
||||
<key>MacBookPro3,2</key>
|
||||
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
||||
<key>MacBookPro4,1</key>
|
||||
<string>MacBook Pro (Core 2 Duo Feb 2008)</string>
|
||||
<key>MacBookPro5,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,2</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,3</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,4</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,5</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro6,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro6,2</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro7,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (mid 2010)</string>
|
||||
<key>MacBookPro8,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7, 13" (early 2011)</string>
|
||||
<key>MacBookPro8,2</key>
|
||||
<string>MacBook Pro Intel Core i7, 15" (early 2011)</string>
|
||||
<key>MacBookPro8,3</key>
|
||||
<string>MacBook Pro Intel Core i7, 17" (early 2011)</string>
|
||||
<key>MacBookPro9,1</key>
|
||||
<string>MacBook Pro (15-inch, Mid 2012)</string>
|
||||
<key>MacBookPro9,2</key>
|
||||
<string>MacBook Pro (13-inch, Mid 2012)</string>
|
||||
<key>MacBookPro10,1</key>
|
||||
<string>MacBook Pro (Retina, Mid 2012)</string>
|
||||
<key>MacBookPro10,2</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2012)</string>
|
||||
<key>MacBookPro11,1</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,2</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,3</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacbookPro11,4</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro11,5</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro12,1 </key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Early 2015)</string>
|
||||
<key>Macmini1,1</key>
|
||||
<string>Mac Mini (Core Solo/Duo)</string>
|
||||
<key>Macmini2,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini3,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini4,1</key>
|
||||
<string>Mac mini Intel Core (Mid 2010)</string>
|
||||
<key>Macmini5,1</key>
|
||||
<string>Mac mini (Core i5, Mid 2011)</string>
|
||||
<key>Macmini5,2</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Mid 2011)</string>
|
||||
<key>Macmini5,3</key>
|
||||
<string>Mac mini (Core i7, Server, Mid 2011)</string>
|
||||
<key>Macmini6,1</key>
|
||||
<string>Mac mini (Core i5, Late 2012)</string>
|
||||
<key>Macmini6,2</key>
|
||||
<string>Mac mini (Core i7, Normal or Server, Late 2012)</string>
|
||||
<key>Macmini7,1</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Late 2014)</string>
|
||||
<key>MacPro1,1,Quad</key>
|
||||
<string>Mac Pro</string>
|
||||
<key>MacPro1,1</key>
|
||||
<string>Mac Pro (four-core)</string>
|
||||
<key>MacPro2,1</key>
|
||||
<string>Mac Pro (eight-core)</string>
|
||||
<key>MacPro3,1</key>
|
||||
<string>Mac Pro (January 2008 4- or 8- core "Harpertown")</string>
|
||||
<key>MacPro4,1</key>
|
||||
<string>Mac Pro (March 2009)</string>
|
||||
<key>MacPro5,1</key>
|
||||
<string>Mac Pro (2010 or 2012)</string>
|
||||
<key>MacPro6,1</key>
|
||||
<string>Mac Pro (Late 2013)</string>
|
||||
<key>PowerBook1,1</key>
|
||||
<string>PowerBook G3</string>
|
||||
<key>PowerBook2,1</key>
|
||||
<string>iBook G3</string>
|
||||
<key>PowerBook2,2</key>
|
||||
<string>iBook G3 (FireWire)</string>
|
||||
<key>PowerBook2,3</key>
|
||||
<string>iBook G3</string>
|
||||
<key>PowerBook2,4</key>
|
||||
<string>iBook G3</string>
|
||||
<key>PowerBook3,1</key>
|
||||
<string>PowerBook G3 (FireWire)</string>
|
||||
<key>PowerBook3,2</key>
|
||||
<string>PowerBook G4</string>
|
||||
<key>PowerBook3,3</key>
|
||||
<string>PowerBook G4 (Gigabit Ethernet)</string>
|
||||
<key>PowerBook3,4</key>
|
||||
<string>PowerBook G4 (DVI)</string>
|
||||
<key>PowerBook3,5</key>
|
||||
<string>PowerBook G4 (1GHz / 867MHz)</string>
|
||||
<key>PowerBook4,1</key>
|
||||
<string>iBook G3 (Dual USB, Late 2001)</string>
|
||||
<key>PowerBook4,2</key>
|
||||
<string>iBook G3 (16MB VRAM)</string>
|
||||
<key>PowerBook4,3</key>
|
||||
<string>iBook G3 Opaque 16MB VRAM, 32MB VRAM, Early 2003)</string>
|
||||
<key>PowerBook5,1</key>
|
||||
<string>PowerBook G4 (17 inch)</string>
|
||||
<key>PowerBook5,2</key>
|
||||
<string>PowerBook G4 (15 inch FW 800)</string>
|
||||
<key>PowerBook5,3</key>
|
||||
<string>PowerBook G4 (17-inch 1.33GHz)</string>
|
||||
<key>PowerBook5,4</key>
|
||||
<string>PowerBook G4 (15 inch 1.5/1.33GHz)</string>
|
||||
<key>PowerBook5,5</key>
|
||||
<string>PowerBook G4 (17-inch 1.5GHz)</string>
|
||||
<key>PowerBook5,6</key>
|
||||
<string>PowerBook G4 (15 inch 1.67GHz/1.5GHz)</string>
|
||||
<key>PowerBook5,7</key>
|
||||
<string>PowerBook G4 (17-inch 1.67GHz)</string>
|
||||
<key>PowerBook5,8</key>
|
||||
<string>PowerBook G4 (Double layer SD, 15 inch)</string>
|
||||
<key>PowerBook5,9</key>
|
||||
<string>PowerBook G4 (Double layer SD, 17 inch)</string>
|
||||
<key>PowerBook6,1</key>
|
||||
<string>PowerBook G4 (12 inch)</string>
|
||||
<key>PowerBook6,2</key>
|
||||
<string>PowerBook G4 (12 inch, DVI)</string>
|
||||
<key>PowerBook6,3</key>
|
||||
<string>iBook G4</string>
|
||||
<key>PowerBook6,4</key>
|
||||
<string>PowerBook G4 (12 inch 1.33GHz)</string>
|
||||
<key>PowerBook6,5</key>
|
||||
<string>iBook G4 (Early-Late 2004)</string>
|
||||
<key>PowerBook6,7</key>
|
||||
<string>iBook G4 (Mid 2005)</string>
|
||||
<key>PowerBook6,8</key>
|
||||
<string>PowerBook G4 (12 inch 1.5GHz)</string>
|
||||
<key>PowerMac1,1</key>
|
||||
<string>Power Macintosh G3 (Blue & White)</string>
|
||||
<key>PowerMac1,2</key>
|
||||
<string>Power Macintosh G4 (PCI Graphics)</string>
|
||||
<key>PowerMac2,1</key>
|
||||
<string>iMac G3 (Slot-loading CD-ROM)</string>
|
||||
<key>PowerMac2,2</key>
|
||||
<string>iMac G3 (Summer 2000)</string>
|
||||
<key>PowerMac3,1</key>
|
||||
<string>Power Macintosh G4 (AGP Graphics)</string>
|
||||
<key>PowerMac3,2</key>
|
||||
<string>Power Macintosh G4 (AGP Graphics)</string>
|
||||
<key>PowerMac3,3</key>
|
||||
<string>Power Macintosh G4 (Gigabit Ethernet)</string>
|
||||
<key>PowerMac3,4</key>
|
||||
<string>Power Macintosh G4 (Digital Audio)</string>
|
||||
<key>PowerMac3,5</key>
|
||||
<string>Power Macintosh G4 (Quick Silver)</string>
|
||||
<key>PowerMac3,6</key>
|
||||
<string>Power Macintosh G4 (Mirrored Drive Door)</string>
|
||||
<key>PowerMac4,1</key>
|
||||
<string>iMac G3 (Early/Summer 2001)</string>
|
||||
<key>PowerMac4,2</key>
|
||||
<string>iMac G4 (Flat Panel)</string>
|
||||
<key>PowerMac4,4</key>
|
||||
<string>eMac</string>
|
||||
<key>PowerMac4,5</key>
|
||||
<string>iMac G4 (17-inch Flat Panel)</string>
|
||||
<key>PowerMac5,1</key>
|
||||
<string>Power Macintosh G4 Cube</string>
|
||||
<key>PowerMac5,2</key>
|
||||
<string>Power Mac G4 Cube</string>
|
||||
<key>PowerMac6,1</key>
|
||||
<string>iMac G4 (USB 2.0)</string>
|
||||
<key>PowerMac6,3</key>
|
||||
<string>iMac G4 (20-inch Flat Panel)</string>
|
||||
<key>PowerMac6,4</key>
|
||||
<string>eMac (USB 2.0, 2005)</string>
|
||||
<key>PowerMac7,2</key>
|
||||
<string>Power Macintosh G5</string>
|
||||
<key>PowerMac7,3</key>
|
||||
<string>Power Macintosh G5</string>
|
||||
<key>PowerMac8,1</key>
|
||||
<string>iMac G5</string>
|
||||
<key>PowerMac8,2</key>
|
||||
<string>iMac G5 (Ambient Light Sensor)</string>
|
||||
<key>PowerMac9,1</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac10,1</key>
|
||||
<string>Mac Mini G4</string>
|
||||
<key>PowerMac10,2</key>
|
||||
<string>Mac Mini (Late 2005)</string>
|
||||
<key>PowerMac11,2</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac12,1</key>
|
||||
<string>iMac G5 (iSight)</string>
|
||||
<key>RackMac1,1</key>
|
||||
<string>Xserve G4</string>
|
||||
<key>RackMac1,2</key>
|
||||
<string>Xserve G4 (slot-loading, cluster node)</string>
|
||||
<key>RackMac3,1</key>
|
||||
<string>Xserve G5</string>
|
||||
<key>Xserve1,1</key>
|
||||
<string>Xserve (Intel Xeon)</string>
|
||||
<key>Xserve2,1</key>
|
||||
<string>Xserve (January 2008 quad-core)</string>
|
||||
<key>Xserve3,1</key>
|
||||
<string>Xserve (early 2009)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -16,7 +16,7 @@
|
||||
</sparkle:fullReleaseNotesLink>
|
||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
||||
<enclosure url="https://you.com/app/Your%20Great%20App%202.0.zip" length="1623481" type="application/octet-stream" sparkle:edSignature="WVyVJpOx+a5+vNWJVY79TRjFKveNk+VhGJf2iti4CZtJsJewIUGvh/1AKKEAFbH1qUwx+vro1ECuzOsMmumoBA==" />
|
||||
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
|
||||
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
@@ -31,7 +31,7 @@
|
||||
</sparkle:fullReleaseNotesLink>
|
||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
||||
<enclosure url="https://you.com/app/Your%20Great%20App%201.5.zip" length="1472893" type="application/octet-stream" sparkle:edSignature="pNFd7KbcQSu+Mq7UYrbQXTPq82luht2ACXm/r2utp1u/Uv/5hWqctdT2jwQgMejW7DRoeV/hVr6J4VdZYdwWDw==" />
|
||||
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
|
||||
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
<!-- Now here's an example of a version with a weird internal version number (like an SVN revision) but a human-readable external one. -->
|
||||
@@ -48,7 +48,7 @@
|
||||
<sparkle:shortVersionString>1.4</sparkle:shortVersionString>
|
||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
||||
<enclosure url="https://you.com/app/Your%20Great%20App%201.4.zip" sparkle:edSignature="Ody3D/ybSMH4T+P/oNj3LN4F0SA8RJGLEr1TI4UemrBAiJ9aEcDnYV3u58P75AbcFjI13jPYmHDUHXMSTFQbDw==" length="1472349" type="application/octet-stream" />
|
||||
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
|
||||
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "2.1.0-beta.1"
|
||||
s.version = "2.4.0"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for macOS."
|
||||
s.homepage = "https://sparkle-project.org"
|
||||
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
|
||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||
}
|
||||
|
||||
s.platform = :osx, '10.11'
|
||||
s.platform = :osx, '10.13'
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.xz" }
|
||||
s.source_files = 'Sparkle.framework/Versions/B/Headers/*.h'
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Loaded 100 of 406 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user