Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
891afd44c7 | ||
|
|
489ae19e74 | ||
|
|
0e162c98be | ||
|
|
cf8e5163b6 | ||
|
|
c8f6eca09a | ||
|
|
dbfb300931 | ||
|
|
eeab95936a | ||
|
|
04dbde7b8d | ||
|
|
c1e7c09886 | ||
|
|
c15b9da2a7 | ||
|
|
80264da368 | ||
|
|
a5725cf443 | ||
|
|
22bc73be59 | ||
|
|
989589524b | ||
|
|
dcf59b1f8a | ||
|
|
a64af3517c | ||
|
|
cfd963002f | ||
|
|
7233bb93e7 | ||
|
|
f2fc729b69 | ||
|
|
7c7e924ed4 | ||
|
|
640ba1b737 | ||
|
|
215b7db5a1 | ||
|
|
4fec1b7301 | ||
|
|
7c84c537a5 | ||
|
|
a3a0ec7e2f | ||
|
|
7ea72a2af4 | ||
|
|
752849d727 | ||
|
|
360575c611 | ||
|
|
bfccdabfa2 | ||
|
|
4f47fb02db | ||
|
|
7962e95fd9 | ||
|
|
2629a05e48 | ||
|
|
a56ca505ea | ||
|
|
17d78dfc0f | ||
|
|
23a24f17ec | ||
|
|
1ac42dcd5b | ||
|
|
8199aee292 | ||
|
|
b3e5f7b000 | ||
|
|
dd12653c29 | ||
|
|
c7f1a75f95 | ||
|
|
7c5adb11ac | ||
|
|
cae2068a44 | ||
|
|
d95a0d5c92 | ||
|
|
1ff3ed7fad | ||
|
|
b7793249e0 | ||
|
|
e26f1dab23 | ||
|
|
8a9963bf04 | ||
|
|
0b14472ede | ||
|
|
d0e054fc54 | ||
|
|
df718b0c4c | ||
|
|
1690ce6cbc | ||
|
|
a746675f53 | ||
|
|
13cadf0118 | ||
|
|
6c3ce5cb97 | ||
|
|
372d75cc09 | ||
|
|
6468ea2bb5 | ||
|
|
c49df15f13 | ||
|
|
0090aa227b | ||
|
|
e9ab9d09a5 | ||
|
|
9c13919fd8 | ||
|
|
6d7753ea66 | ||
|
|
b9fa2f43b7 | ||
|
|
2c1125a86a | ||
|
|
d37d85b812 | ||
|
|
388915c8d0 | ||
|
|
e33a10638d | ||
|
|
d1d71dc127 | ||
|
|
4ed56d5961 | ||
|
|
1ab5ad82b5 | ||
|
|
d01298c9ce | ||
|
|
a242035c74 | ||
|
|
8f19f6a8cc | ||
|
|
9568732f78 | ||
|
|
f49295b054 | ||
|
|
aff67ceda8 | ||
|
|
c8d5d18ce0 | ||
|
|
f1167b3649 | ||
|
|
3077864a3e | ||
|
|
2db0d8cb37 | ||
|
|
0d16b459a5 | ||
|
|
4c3e202d2e | ||
|
|
96d162c7e5 | ||
|
|
01b48d44e8 | ||
|
|
c39f7df513 | ||
|
|
ec15362770 | ||
|
|
962878b843 | ||
|
|
9d8909c38d | ||
|
|
99a00a2c17 | ||
|
|
1d2b74e39d | ||
|
|
b097e64b56 | ||
|
|
28a245dd53 | ||
|
|
4eabf002c5 | ||
|
|
ae4af4d61f | ||
|
|
dd9c7d0e1c | ||
|
|
7ab8823757 | ||
|
|
dd287029db | ||
|
|
6ec6007091 | ||
|
|
985be854c4 | ||
|
|
8129cc1c03 | ||
|
|
dddba708d2 | ||
|
|
2596a54935 | ||
|
|
794a90a5e2 | ||
|
|
9e7c3463e0 | ||
|
|
ed40ef1267 | ||
|
|
b9a4917f81 | ||
|
|
1081dcdda1 | ||
|
|
3a497ddcbd | ||
|
|
8f6c7ccdeb | ||
|
|
0e9d96a303 | ||
|
|
531b767c0b | ||
|
|
0cfedd4516 | ||
|
|
8f01babdd3 | ||
|
|
5dab9c40ab | ||
|
|
f2dd8fe371 | ||
|
|
5d0e5dd407 | ||
|
|
39fb433131 | ||
|
|
e68a2621ed | ||
|
|
cb6545d601 | ||
|
|
6dbbf08654 | ||
|
|
d5222353e6 | ||
|
|
2657a41d55 | ||
|
|
08d3ff747d | ||
|
|
fedb22e224 | ||
|
|
8293c3c6ae | ||
|
|
181f813b01 | ||
|
|
a10a974609 | ||
|
|
f8572f79cb | ||
|
|
2b54753090 | ||
|
|
2db2fffab9 | ||
|
|
035bfc4919 | ||
|
|
48fc202f36 | ||
|
|
28ff3069ff | ||
|
|
795ce1278d | ||
|
|
6ac853271d | ||
|
|
7e5e91888f | ||
|
|
b0d29ae798 | ||
|
|
09bbf9fdc6 | ||
|
|
f2bd7ea2b2 | ||
|
|
35deefdc0c | ||
|
|
3e53979236 | ||
|
|
f8971098be | ||
|
|
efd1840f35 | ||
|
|
17dbdf98e1 | ||
|
|
79f110a17b | ||
|
|
5ab0baf84c | ||
|
|
578dac0ad7 | ||
|
|
920b5bac5e | ||
|
|
9ae7224a47 | ||
|
|
685be61bc3 | ||
|
|
9be76d3d5a | ||
|
|
fc1960966a | ||
|
|
7248e40fda | ||
|
|
b8d37346a6 | ||
|
|
2769221117 | ||
|
|
6317a6c74f | ||
|
|
f785c7177c | ||
|
|
cd78595c63 | ||
|
|
4fd2a7b15f | ||
|
|
186bbb83d5 | ||
|
|
0cc8a2f16a | ||
|
|
0eb1caeec5 | ||
|
|
7138663f86 | ||
|
|
b767285be0 | ||
|
|
5886c2b9b9 | ||
|
|
f9b534a6b6 | ||
|
|
5a586d393a | ||
|
|
b3cc7aed8a | ||
|
|
deb8ea8cc1 | ||
|
|
4a3cc18dc3 | ||
|
|
75404f6d83 | ||
|
|
954ed60ecb | ||
|
|
ecb5257b2b | ||
|
|
fb18c1e542 | ||
|
|
99f5573619 | ||
|
|
1edfcaba71 | ||
|
|
fc3221c5d2 | ||
|
|
26db6982b3 | ||
|
|
f550b92f72 | ||
|
|
5f5fe1b5f9 | ||
|
|
6027f2852a | ||
|
|
60c2f16c9d | ||
|
|
5ae7fa7212 | ||
|
|
614b2cc1f3 | ||
|
|
6500bf8c2f | ||
|
|
3e060d4a7b | ||
|
|
5286371cb7 | ||
|
|
2a802447a3 | ||
|
|
c40b42deb1 | ||
|
|
5d9f41142b | ||
|
|
d540c6a1b9 | ||
|
|
e63bcbc047 | ||
|
|
4f65e14ee8 | ||
|
|
fdca1ce6cf | ||
|
|
c3255ed3a7 | ||
|
|
9b6346516e | ||
|
|
e1f13ebcad | ||
|
|
420be06ba0 | ||
|
|
c7beba948d | ||
|
|
639b6df47b | ||
|
|
c9a9cba167 | ||
|
|
9f01fd303c | ||
|
|
1ff1577108 | ||
|
|
74f2ea540e | ||
|
|
2652be32f7 | ||
|
|
5118f2b27f | ||
|
|
b97b60b611 | ||
|
|
3c793482c8 | ||
|
|
89b4bcde61 | ||
|
|
3690dd028a | ||
|
|
52e2ef88eb | ||
|
|
d81633a7d3 | ||
|
|
a9e20c7d0a | ||
|
|
03a9f57704 | ||
|
|
2f8df626d7 | ||
|
|
f5cb6988ed | ||
|
|
2bfab80998 | ||
|
|
4fa2a37798 | ||
|
|
888a7f48a6 | ||
|
|
82726c4386 | ||
|
|
a5b23cdbee | ||
|
|
b19120f5cd | ||
|
|
4b0a037685 | ||
|
|
8dadd0003e | ||
|
|
457319f217 | ||
|
|
0480b9bb25 | ||
|
|
4390eb9eb2 | ||
|
|
f5c8314c88 | ||
|
|
1b209e6726 | ||
|
|
a4373e4e0f | ||
|
|
d430c33bf4 | ||
|
|
7ef4635d8c | ||
|
|
deb4be7a1b | ||
|
|
5f1bc6b612 | ||
|
|
1cde8110df | ||
|
|
1926b7bfa6 | ||
|
|
f80907fa2c | ||
|
|
091a86f672 | ||
|
|
208b0dc49a | ||
|
|
5acf3989d2 | ||
|
|
5529a3610d | ||
|
|
920ff7f83f | ||
|
|
5ff1488f0c | ||
|
|
c0c1c51d8d | ||
|
|
5139179487 | ||
|
|
f50cbce0e8 | ||
|
|
14f1d3520a | ||
|
|
9c4729ed4a | ||
|
|
f04a61e159 | ||
|
|
80d8758fc2 | ||
|
|
081301d590 | ||
|
|
397370297b | ||
|
|
b30dcd979f | ||
|
|
ee123edd74 | ||
|
|
984625cc7e | ||
|
|
7b6e7957c6 | ||
|
|
2815514c23 | ||
|
|
49eaa4c5cc | ||
|
|
09bcee7280 | ||
|
|
49ea08b284 | ||
|
|
f9dc70ade2 | ||
|
|
6fb3eee91b | ||
|
|
19be83b15f | ||
|
|
d90529ccaa | ||
|
|
623b7b6bda | ||
|
|
65bcb3815e | ||
|
|
d5cd95e0ef | ||
|
|
b9150d2938 | ||
|
|
1006326157 | ||
|
|
68856e074b | ||
|
|
a86bdb2fa8 | ||
|
|
92e00baafb | ||
|
|
98ea3e3d57 | ||
|
|
c094a38231 | ||
|
|
6df898f9b7 | ||
|
|
7f51a4e344 | ||
|
|
8ad1f57672 | ||
|
|
8b88183c7d | ||
|
|
d036d3e3ae | ||
|
|
8b13eb5dcf | ||
|
|
ba5b7341fa | ||
|
|
9453761aef |
No files matched your search
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Other issues
|
||||
about: Found a bug? Want to implement a new feature?
|
||||
title: ''
|
||||
labels: '1.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Other issues related to Sparkle 2.x
|
||||
about: Found a bug? Want to implement a new feature?
|
||||
title: ''
|
||||
labels: '2.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: Sparkle 1.x doesn't work in my app
|
||||
about: Problems with integration, unexpected errors
|
||||
title: ''
|
||||
labels: '1.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
The answer to your issue is probably already 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
|
||||
|
||||
-->
|
||||
|
||||
### Description of the problem
|
||||
|
||||
|
||||
### Do you use Sandboxing in your app?
|
||||
|
||||
### Version of `Sparkle.framework` in the latest version of your app
|
||||
|
||||
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
|
||||
|
||||
### Sparkle's output from Console.app
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
name: Sparkle 2.x doesn't work in my app
|
||||
about: Problems with using the beta version of Sparkle 2
|
||||
title: ''
|
||||
labels: '2.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
The answer to your issue is probably already 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
|
||||
|
||||
-->
|
||||
|
||||
### Description of the problem
|
||||
|
||||
|
||||
### Do you use Sandboxing in your app?
|
||||
|
||||
### Version of `Sparkle.framework` in the latest version of your app
|
||||
|
||||
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
|
||||
|
||||
### Sparkle's output from Console.app
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
@@ -41,3 +41,7 @@ Carthage/Build
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Swift Package Manager
|
||||
/.build
|
||||
.swiftpm
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "Vendor/ed25519"]
|
||||
path = Vendor/ed25519
|
||||
url = https://github.com/orlp/ed25519
|
||||
@@ -0,0 +1,20 @@
|
||||
excluded:
|
||||
- Vendor
|
||||
disabled_rules:
|
||||
- opening_brace
|
||||
- empty_parentheses_with_trailing_closure
|
||||
- function_body_length
|
||||
- line_length
|
||||
- cyclomatic_complexity
|
||||
- large_tuple
|
||||
|
||||
# Rule-specific config
|
||||
trailing_comma:
|
||||
mandatory_comma: true
|
||||
force_try:
|
||||
severity: warning
|
||||
force_cast:
|
||||
severity: warning
|
||||
identifier_name:
|
||||
min_length:
|
||||
warning: 2
|
||||
@@ -1,5 +1,7 @@
|
||||
os: osx
|
||||
language: objective-c
|
||||
osx_image: xcode9
|
||||
before_install:
|
||||
- brew update
|
||||
script: make ci
|
||||
osx_image:
|
||||
- xcode11.4
|
||||
- xcode12
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -project Sparkle.xcodeproj -scheme Distribution -derivedDataPath build -enableCodeCoverage YES | xcpretty
|
||||
@@ -1,3 +1,97 @@
|
||||
# 1.24.0
|
||||
|
||||
* Prioritize UserDefaults when fetching value for EnableAutomaticChecks (Nicolas Bosi)
|
||||
* Improve best appcast item selection handling (Ian Bytchek)
|
||||
* Create lockfile for improved compatibility with 3rd party updaters (CoreCode)
|
||||
* Enable SPM support via binary target (Jonas Zaugg)
|
||||
* `generate_appcast` improvements:
|
||||
* follow symbolic links (Denis Dzyubenko)
|
||||
* update the release notes element’s URL when required (Brad Andalman)
|
||||
* Added output filename option to generate_appcast (Brad Andalman)
|
||||
* Added —release-notes-url-prefix to generate_appcast (Brad Andalman)
|
||||
* Command line option to provide a download url prefix is now parsed and set on each archive item (Dominik H)
|
||||
* Added help command line option (Dominik H)
|
||||
* Locale updates:
|
||||
* Update zh_CN localization (柳东原 · Dongyuan Liu)
|
||||
* Update Sparkle.strings (Vojtěch Koňařík)
|
||||
* Update Croatian (#1603) (milotype)
|
||||
* Update SUUpdateAlert.xib (DanielFirlej)
|
||||
* fix: read SUAutomaticallyUpdate from Info.plist (Trevor DeVore)
|
||||
* Fix casting Boolean to BOOL on Apple Silicon (Kevin Wojniak)
|
||||
* Use build matrix to test on multiple Xcode versions (Rajiv Shah)
|
||||
* Set UpdateAlert and AutomaticUpdateAlert window's fullscreen collectionBehavior to NSWindowCollectionBehaviorFullScreenAuxiliary to allow them to present on top of the Main App's window if it's fullscreen. (Micah Moore)
|
||||
* Fixed error about "about:blank" release notes (Louis Pontoise)
|
||||
* Support App Store URL scheme in release note webview (Bi11)
|
||||
* Use the SHA-256 hash of the archive as the cache path (Nate Weaver)
|
||||
* Don't return an optional from the FileHandle method (Nate Weaver)
|
||||
* Added URL+Hashing (Nate Weaver)
|
||||
|
||||
# 1.23.0
|
||||
|
||||
* Support generating appcast with localizations (#1499) (Alik Vovkotrub)
|
||||
* Support versions with git commit SHA (#1504) (Alec Larson)
|
||||
* Hide "Skip..." and "Remind..." buttons when they're not relevant (#1480) (Kenneth Johnsen)
|
||||
* Preserve Finder tags while updating apps (#1512) (CoreCode)
|
||||
* Read-only update alert dialog formatting improvements (#1515) (Quinn Taylor)
|
||||
* Check if `SUBundleName` is set before normalizing (Jake Fenton)
|
||||
* `NSInteger` cast warning on Xcode 11 (Marga Keuvelaar)
|
||||
* Correct appcast file extension (Tom Vos)
|
||||
* Update Sparkle.strings (Emir Sarı)
|
||||
* Fix spelling (#1508) (Frank Chiarulli Jr)
|
||||
|
||||
# 1.22.0
|
||||
|
||||
* Enabled "Hardened Runtime" build option for Apple's notarization requirement
|
||||
* Add delegate methods to suppress update alerts (George Nachman)
|
||||
* Improved error when running from translocated location (Michael Buckley)
|
||||
* Add phased rollout feature (#1381) (Fabian Jäger)
|
||||
* Ignore non-standard permissions in delta updates instead of failing the build (Kornel Lesiński)
|
||||
* Notify user when installed version is newer than the latest in the appcast (CoreCode)
|
||||
* Reset timers after computer sleep (CoreCode)
|
||||
* Block-based alternatives to `NSInvocation`-based delegate methods (Fabian Jäger)
|
||||
* Add delegate `userDidSkipThisVersion` (BobZombie, Leo Natan, bono yusuke)
|
||||
* Pass item to updaterShouldShowUpdateAlertForScheduledUpdate delegate method (George Nachman)
|
||||
* Support providing private key as argument in `generate_appcast` (Yakuhzi, marchyang)
|
||||
* Separate the ed25519 sources into a new static library (Tony Arnold)
|
||||
* Disambiguate signing error messages (Nate Weaver)
|
||||
* Use `XMLNode.Options.nodePrettyPrint` in `generate_appcast` instead of trying to add whitespace manually (fumoboy007)
|
||||
* Annotate SUHost for nullability (Michael Buckley)
|
||||
* Use SUAVAILABLE macro (Christiaan Hofman)
|
||||
* Fix warnings when using modules (nivekkagicom)
|
||||
* Correction of Czech localization inconsistency (#1403) (vojtakonarik)
|
||||
* BR locale fix (BR Lingo)
|
||||
* Update Japanese localization (fujisoft)
|
||||
* French Sparkle.strings (Jean-Baptiste)
|
||||
|
||||
# 1.21.3
|
||||
|
||||
* Losslessly reduced the size of PNG (Barijaona Ramaholimihaso)
|
||||
* Catch exceptions from subcommands (Julian Mayer)
|
||||
* `generate_appcast` can sign any bundles instead of just apps (Nate Weaver)
|
||||
* Check that effectiveAppearance is being observed before calling removeObserver (Pierluigi)
|
||||
|
||||
# 1.21.2
|
||||
|
||||
* Allow EdDSA for delta updates, too (Kornel)
|
||||
* Warning fixes (Brian Bergstrand)
|
||||
* Improvements to release notes view context menu and dark mode (Bi11)
|
||||
|
||||
# 1.21.0
|
||||
|
||||
* Added support EdDSA (ed25519) signatures (Kornel)
|
||||
* DSA signatures are considered outdated, and Apple's `Security.framework` only supports weaker SHA-1-based DSA.
|
||||
* Both old DSA and new EdDSA are still supported (and one app can use both), but new applications should use EdDSA only, and we recommend migrating away from DSA signatures.
|
||||
* `generate_keys` is now a Swift tool that stores EdDSA private keys in the Keychain
|
||||
* Existing apps can continue using their old DSA keys, but we've dropped support for generation of old DSA keys
|
||||
* `sign_update` is now a Swift tool that signs using EdDSA from private keys in the Keychain
|
||||
* The old DSA-based signing script has been moved to `bin/old_dsa_scripts`
|
||||
* The old DSA-based signing script has been fixed to work on pre-10.13 systems (Thomas Tempelmann)
|
||||
* `generate_appcast` has been updated to support EdDSA signatures
|
||||
* It can sign both DSA (if `dsa_priv.pem` file is specified) and EdDSA (from Keychain)
|
||||
* The tool now uses Caches directory and doesn't generate unnecessary delta files
|
||||
* Fixed verification of delta updates on filesystems that change permissions of symlinks
|
||||
* Fixed `NSURLSession` leak (Michael Ehrmann)
|
||||
|
||||
# 1.20.0
|
||||
|
||||
* `generate_appcast` option to read private key directly from the keychain (Tamás Lustyik)
|
||||
|
||||
@@ -16,7 +16,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
|
||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 20
|
||||
SPARKLE_VERSION_MINOR = 24
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
|
||||
@@ -32,6 +32,7 @@ PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034id
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
|
||||
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
@@ -54,6 +55,7 @@ CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
|
||||
@@ -0,0 +1,7 @@
|
||||
// Generate Appcast only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
SWIFT_OBJC_BRIDGING_HEADER = generate_keys/Bridging-Header.h
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
PRODUCT_NAME = generate_keys
|
||||
@@ -0,0 +1,4 @@
|
||||
// Generate Appcast Debug
|
||||
|
||||
#include "ConfigGenerateKeys.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -0,0 +1,4 @@
|
||||
// Generate Appcast Release
|
||||
|
||||
#include "ConfigGenerateKeys.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -1,2 +1,2 @@
|
||||
SWIFT_VERSION = 4.0
|
||||
SWIFT_VERSION = 4.2
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -0,0 +1,3 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
#include "bsdiff-Shared.xcconfig"
|
||||
@@ -0,0 +1,3 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
#include "bsdiff-Shared.xcconfig"
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
// Deployment
|
||||
SKIP_INSTALL = YES
|
||||
|
||||
// Packaging
|
||||
EXECUTABLE_PREFIX = lib
|
||||
PRODUCT_NAME = $(TARGET_NAME)
|
||||
|
||||
// Search Paths
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
|
||||
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
|
||||
WARNING_CFLAGS = $(inherited) -Wno-comma
|
||||
@@ -0,0 +1,3 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
#include "ed25519-Shared.xcconfig"
|
||||
@@ -0,0 +1,3 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
#include "ed25519-Shared.xcconfig"
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
// Deployment
|
||||
SKIP_INSTALL = YES
|
||||
|
||||
// Packaging
|
||||
EXECUTABLE_PREFIX = lib
|
||||
PRODUCT_NAME = $(TARGET_NAME)
|
||||
|
||||
// Search Paths
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
|
||||
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
|
||||
WARNING_CFLAGS = $(inherited) -Wno-cast-qual -Wno-conversion -Wno-sign-conversion
|
||||
@@ -12,27 +12,60 @@ if [ "$ACTION" = "" ] ; then
|
||||
fi
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
|
||||
rm -f "Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.xcframework" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
|
||||
# because missing dSYMs in a release build SHOULD trigger a build failure
|
||||
if [ "$CONFIGURATION" = "Release" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
fi
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||
# Sorted file list groups similar files together, which improves tar compression
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
|
||||
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
# Generate zip containing the xcframework for SPM
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
#rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
|
||||
zip -rqyX -9 "../Sparkle-for-Swift-Package-Manager.zip" *
|
||||
# Generate new Package manifest
|
||||
cd "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
|
||||
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
|
||||
# is equivalent to shasum -a 256 FILE
|
||||
spm_checksum=$(swift package compute-checksum "Sparkle-for-Swift-Package-Manager.zip")
|
||||
rm -rf ".build"
|
||||
sed -E -i '' -e "/let version/ s/[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/$CURRENT_PROJECT_VERSION/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
|
||||
cp "Package.swift" "$SRCROOT"
|
||||
echo "Package.swift updated with the following values:"
|
||||
echo "Version: $CURRENT_PROJECT_VERSION"
|
||||
echo "Checksum: $spm_checksum"
|
||||
else
|
||||
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
|
||||
fi
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
fi
|
||||
@@ -9,7 +9,7 @@ if [ -z "$SRCROOT" ] || \
|
||||
[ -z "$BUILT_PRODUCTS_DIR" ] || \
|
||||
[ -z "$INFOPLIST_PATH" ] || \
|
||||
[ -z "$CURRENT_PROJECT_VERSION" ]; then
|
||||
echo "$0: Must be run from Xcode!" 1>&2
|
||||
echo "$0: Must be run from Xcode!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ if [ "$ACTION" = "" ] ; then
|
||||
doxygen Documentation/Doxyfile
|
||||
else
|
||||
echo "warning: Doxygen not found in PATH"
|
||||
echo "open Terminal and type this command `brew install doxygen` then click `enter/return` key. finally build this target again"
|
||||
echo "open Terminal and type this command 'brew install doxygen' then click 'enter/return' key. finally build this target again"
|
||||
fi
|
||||
elif [ "$ACTION" = "clean" ] ; then
|
||||
rm -rf "$SRCROOT/Documentation/html"
|
||||
|
||||
@@ -14,9 +14,10 @@ localizable-strings:
|
||||
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||
open "$(BUILDDIR)/Build/Products/Release/"
|
||||
cat Sparkle.podspec
|
||||
@echo "Don't forget to update CocoaPods! pod trunk push"
|
||||
@echo "Don't forget to commit the updated Package manifest before releasing!"
|
||||
|
||||
build:
|
||||
xcodebuild clean build
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// swift-tools-version:5.3
|
||||
import PackageDescription
|
||||
|
||||
let version = "1.24.0"
|
||||
let checksum = "a9ae129446739a685d2fb60b392606df020ee8e8d132dcc3a5959a8dd0775f35"
|
||||
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(version)/Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
let package = Package(
|
||||
name: "Sparkle",
|
||||
platforms: [.macOS(.v10_11)],
|
||||
products: [
|
||||
.library(
|
||||
name: "Sparkle",
|
||||
targets: ["Sparkle"])
|
||||
],
|
||||
targets: [
|
||||
.binaryTarget(
|
||||
name: "Sparkle",
|
||||
url: url,
|
||||
checksum: checksum
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,37 +1,32 @@
|
||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) [](https://github.com/Carthage/Carthage) []() <a href="https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
|
||||
# Sparkle 1.x [](https://travis-ci.org/sparkle-project/Sparkle) [](https://github.com/Carthage/Carthage) []() <a href="https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
|
||||
|
||||
Secure and reliable software update framework for Cocoa developers.
|
||||
|
||||
<img src="Resources/Screenshot.png" width="732" alt="Sparkle shows familiar update window with release notes">
|
||||
|
||||
This branch is the production ready, battle-tested version of Sparkle used by thousands of Mac apps.
|
||||
The upcoming Sparkle 2 (currently in beta) can be found in the [2.x branch](https://github.com/sparkle-project/Sparkle/tree/2.x).
|
||||
|
||||
## Features
|
||||
|
||||
* Seamless. There's no mention of Sparkle; your icons and app name are used.
|
||||
* Secure. Updates are verified using DSA signatures and Apple Code Signing.
|
||||
* Secure. Updates are verified using EdDSA signatures and Apple Code Signing.
|
||||
* Fast. Supports delta updates which only patch files that have changed.
|
||||
* Easy to install. Sparkle requires no code in your app, and only needs static files on a web server.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
||||
* Handles permissions, quarantine and automatically asks for authentication if needed.
|
||||
* Uses RSS-based appcasts for release information. Appcasts are a de-facto standard supported by 3rd party update-tracking programs and websites.
|
||||
* Sparkle stays hidden until second launch for better first impressions.
|
||||
* Stays hidden until second launch for better first impressions.
|
||||
* Truly self-updating — the user can choose to automatically download and install all updates in the background.
|
||||
|
||||
## Changes since 1.5b
|
||||
|
||||
* Compatibilty with macOS Sierra.
|
||||
* Up-to-date with 10.12 SDK and Xcode 8 (supports macOS 10.7+).
|
||||
* Important security fixes.
|
||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Upgraded and more reliable binary delta and code signing verification.
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Runtime: macOS 10.7 or greater
|
||||
* Build: Xcode 7 and 10.11 SDK or greater
|
||||
* Build: Xcode 9 and 10.11 SDK or greater (Xcode 12 if using Swift Package Manager)
|
||||
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||
* No sandboxing. Sparkle 1.x can't update sandboxed apps. However, [Sparkle 2.x](https://github.com/sparkle-project/Sparkle/tree/2.x) can.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -39,6 +34,20 @@ See [getting started guide](https://sparkle-project.org/documentation/). No code
|
||||
|
||||
## 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 --recursive https://github.com/sparkle-project/Sparkle
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
* Please check **Console.app**. Sparkle prints detailed information there about all problems it encounters. It often also suggests solutions to the problems, so please read Sparkle's log messages carefully.
|
||||
|
||||
* Use the `generate_appcast` tool which creates appcast files, correct signatures, and delta updates automatically.
|
||||
|
||||
* Make sure the URL specified in [`SUFeedURL`](https://sparkle-project.org/documentation/customization/) is valid (typos/404s are a common error!), and that it uses modern TLS ([test it](https://www.ssllabs.com/ssltest/)).
|
||||
|
||||
* Delete your app's preferences (in `~/Library/Preferences/<your bundle id>`) if you've set another feed URL programmatically via Sparkle's Objective-C interface.
|
||||
|
||||
### API symbols
|
||||
|
||||
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 662 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 368 KiB After Width: | Height: | Size: 176 KiB |
@@ -10,6 +10,7 @@
|
||||
http://you.com/app/2.0.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
@@ -20,6 +21,7 @@
|
||||
http://you.com/app/1.5.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
@@ -31,6 +33,7 @@
|
||||
http://you.com/app/1.4.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 100 KiB |
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.20.0"
|
||||
s.version = "1.24.0"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "http://sparkle-project.org"
|
||||
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
||||
}
|
||||
|
||||
s.platform = :osx, '10.7'
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.xz" }
|
||||
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
|
||||
s.preserve_paths = 'bin/*'
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -3,7 +3,7 @@
|
||||
LastUpgradeVersion = "0920"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
parallelizeBuildables = "NO"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "895C5DB924D75F370058A82D"
|
||||
BuildableName = "XCFramework"
|
||||
BlueprintName = "XCFramework"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "895C5DB924D75F370058A82D"
|
||||
BuildableName = "XCFramework"
|
||||
BlueprintName = "XCFramework"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -89,14 +89,14 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
SULog(SULogLevelError, @"Failed to listen for application termination");
|
||||
// Continue on with the installation anyway?
|
||||
}
|
||||
|
||||
|
||||
if (self.shouldShowUI) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.isTerminating) {
|
||||
// Show app icon in the dock
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
if (!self.isTerminating) {
|
||||
// Show app icon in the dock
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
html {
|
||||
color: #FFFFFFD8;
|
||||
}
|
||||
:link {
|
||||
color: #419CFF;
|
||||
}
|
||||
:link:active {
|
||||
color: #FF1919;
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "SPUDownloadData.h"
|
||||
|
||||
#import "SUOperatingSystem.h"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -52,7 +53,9 @@ static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
if (@available(macOS 10.8, *)) {
|
||||
if (SUAVAILABLE(10, 8)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUDownloadDataKey];
|
||||
if (data == nil) {
|
||||
return nil;
|
||||
@@ -61,6 +64,7 @@ static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
|
||||
NSString *textEncodingName = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadTextEncodingKey];
|
||||
|
||||
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadMIMETypeKey];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return [self initWithData:data textEncodingName:textEncodingName MIMEType:MIMEType];
|
||||
} else {
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||
{
|
||||
[self downloadDidFinish];
|
||||
[self cleanup];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
-(void)cleanup
|
||||
{
|
||||
[self.download cancel];
|
||||
[self.downloadSession invalidateAndCancel];
|
||||
self.download = nil;
|
||||
self.downloadSession = nil;
|
||||
[super cleanup];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "SPUURLRequest.h"
|
||||
|
||||
#import "SUOperatingSystem.h"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -61,9 +62,9 @@ static NSString *SPUURLRequestNetworkServiceTypeKey = @"SPUURLRequestNetworkServ
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.url forKey:SPUURLRequestURLKey];
|
||||
[coder encodeInteger:self.cachePolicy forKey:SPUURLRequestCachePolicyKey];
|
||||
[coder encodeInteger:(NSInteger)self.cachePolicy forKey:SPUURLRequestCachePolicyKey];
|
||||
[coder encodeDouble:self.timeoutInterval forKey:SPUURLRequestTimeoutIntervalKey];
|
||||
[coder encodeInteger:self.networkServiceType forKey:SPUURLRequestNetworkServiceTypeKey];
|
||||
[coder encodeInteger:(NSInteger)self.networkServiceType forKey:SPUURLRequestNetworkServiceTypeKey];
|
||||
|
||||
if (self.httpHeaderFields != nil) {
|
||||
[coder encodeObject:self.httpHeaderFields forKey:SPUURLRequestHttpHeaderFieldsKey];
|
||||
@@ -72,11 +73,14 @@ static NSString *SPUURLRequestNetworkServiceTypeKey = @"SPUURLRequestNetworkServ
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
if (@available(macOS 10.8, *)) {
|
||||
if (SUAVAILABLE(10, 8)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey];
|
||||
NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey];
|
||||
NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey];
|
||||
NSDictionary<NSString *, NSString *> *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey];
|
||||
#pragma clang diagnostic pop
|
||||
NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey];
|
||||
|
||||
return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType];
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
||||
|
||||
|
||||
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 9, 0}]) {
|
||||
if (SUAVAILABLE(10, 9)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
|
||||
@@ -199,7 +199,7 @@
|
||||
|
||||
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
||||
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:appcastData options:options error:errorp];
|
||||
if (nil == document) {
|
||||
if (nil == document) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
|
||||
while((node = [nodeEnum nextObject])) {
|
||||
while((node = [nodeEnum nextObject])) {
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||
[dict setObject:encDict forKey:name];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||
// We don't want to parse and create a NSDate instance -
|
||||
// that's a risk we can avoid. We don't use the date anywhere other
|
||||
@@ -248,8 +248,8 @@
|
||||
if (dateString) {
|
||||
[dict setObject:dateString forKey:name];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
@@ -258,7 +258,7 @@
|
||||
}
|
||||
}
|
||||
[dict setObject:deltas forKey:name];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||
NSMutableArray *tags = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
@@ -270,7 +270,7 @@
|
||||
}
|
||||
[dict setObject:tags forKey:name];
|
||||
}
|
||||
else if (name != nil) {
|
||||
else if (name != nil) {
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
@@ -283,7 +283,7 @@
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||
if (anItem) {
|
||||
[appcastItems addObject:anItem];
|
||||
}
|
||||
}
|
||||
else {
|
||||
SULog(SULogLevelError, @"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
|
||||
|
||||
@@ -15,13 +15,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
@class SUSignatures;
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (strong, readonly) SUSignatures *signatures;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@@ -31,6 +33,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
@property (copy, readonly) NSNumber* phasedRolloutInterval;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SULog.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
#import "SUSignatures.h"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
@property (copy, readwrite) NSString *dateString;
|
||||
@property (copy, readwrite) NSString *itemDescription;
|
||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@property (strong, readwrite) SUSignatures *signatures;
|
||||
@property (copy, readwrite) NSString *minimumSystemVersion;
|
||||
@property (copy, readwrite) NSString *maximumSystemVersion;
|
||||
@property (strong, readwrite) NSURL *fileURL;
|
||||
@@ -28,13 +28,14 @@
|
||||
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
||||
@property (strong, readwrite) NSURL *infoURL;
|
||||
@property (readwrite, copy) NSDictionary *propertiesDictionary;
|
||||
@property (copy, readwrite) NSNumber* phasedRolloutInterval;
|
||||
@end
|
||||
|
||||
@implementation SUAppcastItem
|
||||
@synthesize dateString;
|
||||
@synthesize deltaUpdates;
|
||||
@synthesize displayVersionString;
|
||||
@synthesize DSASignature;
|
||||
@synthesize signatures;
|
||||
@synthesize fileURL;
|
||||
@synthesize contentLength = _contentLength;
|
||||
@synthesize infoURL;
|
||||
@@ -46,6 +47,7 @@
|
||||
@synthesize versionString;
|
||||
@synthesize osString;
|
||||
@synthesize propertiesDictionary;
|
||||
@synthesize phasedRolloutInterval;
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
@@ -63,6 +65,18 @@
|
||||
return self.osString == nil || [self.osString isEqualToString:SUAppcastAttributeValueMacOS];
|
||||
}
|
||||
|
||||
- (NSDate*)date {
|
||||
if(self.dateString == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
|
||||
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = @"E, dd MMM yyyy HH:mm:ss Z";
|
||||
|
||||
return [dateFormatter dateFromString:self.dateString];
|
||||
}
|
||||
|
||||
- (BOOL)isInformationOnlyUpdate
|
||||
{
|
||||
return self.infoURL && !self.fileURL;
|
||||
@@ -125,7 +139,7 @@
|
||||
}
|
||||
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
// page, latter to download & install:
|
||||
if (!enclosure && !theInfoURL) {
|
||||
if (error) {
|
||||
*error = @"No enclosure in feed item";
|
||||
@@ -156,10 +170,10 @@
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
|
||||
self.signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:[enclosure objectForKey:SUAppcastAttributeEDSignature]];
|
||||
self.osString = [enclosure objectForKey:SUAppcastAttributeOsType];
|
||||
}
|
||||
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion];
|
||||
self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion];
|
||||
@@ -175,6 +189,11 @@
|
||||
self.displayVersionString = self.versionString;
|
||||
}
|
||||
|
||||
NSString* enclosureRolloutIntervalString = [enclosure objectForKey:SUAppcastAttributePhasedRolloutInterval];
|
||||
if(enclosureRolloutIntervalString) {
|
||||
self.phasedRolloutInterval = @(enclosureRolloutIntervalString.integerValue);
|
||||
}
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
if (releaseNotesString) {
|
||||
|
||||
@@ -96,6 +96,12 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
|
||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
||||
}
|
||||
else if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)])
|
||||
{
|
||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
|
||||
[self installWithToolAndRelaunch:YES displayingUserInterface:NO];
|
||||
}];
|
||||
}
|
||||
|
||||
// If this is marked as a critical update, we'll prompt the user to install it right away.
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
@@ -173,8 +179,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||
{
|
||||
self.alert = nil;
|
||||
switch (choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case SUInstallNowChoice:
|
||||
[self stopUpdatingOnTermination];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver <SPUDownloaderDelegate>
|
||||
|
||||
@property (strong, readonly) SUAppcastItem *updateItem;
|
||||
@property (strong, readonly) SUAppcastItem *latestAppcastItem;
|
||||
@property (assign, readonly) NSComparisonResult latestAppcastItemComparisonResult;
|
||||
@property (strong, readonly) SPUDownloader *download;
|
||||
@property (copy, readonly) NSString *downloadPath;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUGlobalUpdateLock.h"
|
||||
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SPUDownloaderDeprecated.h"
|
||||
@@ -32,6 +34,8 @@
|
||||
@interface SUBasicUpdateDriver ()
|
||||
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) SUAppcastItem *latestAppcastItem;
|
||||
@property (assign) NSComparisonResult latestAppcastItemComparisonResult;
|
||||
@property (strong) SPUDownloader *download;
|
||||
@property (copy) NSString *downloadPath;
|
||||
|
||||
@@ -46,6 +50,8 @@
|
||||
@implementation SUBasicUpdateDriver
|
||||
|
||||
@synthesize updateItem;
|
||||
@synthesize latestAppcastItem;
|
||||
@synthesize latestAppcastItemComparisonResult;
|
||||
@synthesize download;
|
||||
@synthesize downloadPath;
|
||||
|
||||
@@ -58,9 +64,17 @@
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated, because it was opened from a read-only or a temporary location. Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
NSString *hostName = [aHost name];
|
||||
if ([aHost isRunningTranslocated])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningTranslocated userInfo:@{ NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"Quit %1$@, move it into your Applications folder, relaunch it from there and try again.", nil), hostName], NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can’t be updated if it’s running from the location it was downloaded to.", nil), hostName], }]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated, because it was opened from a read-only or a temporary location.", nil), hostName], NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.", nil), hostName] }]];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,7 +96,7 @@
|
||||
{
|
||||
id<SUVersionComparison> comparator = nil;
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||
comparator = [[updater delegate] versionComparatorForUpdater:self.updater];
|
||||
@@ -96,31 +110,46 @@
|
||||
return comparator;
|
||||
}
|
||||
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
|
||||
// This method is only used for testing
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator {
|
||||
SUBasicUpdateDriver* basicUpdateDriver = [[SUBasicUpdateDriver alloc] initWithUpdater:(id<SUUpdaterPrivate>)[SUUpdater sharedUpdater]];
|
||||
return [basicUpdateDriver bestItemFromAppcastItems:appcastItems getDeltaItem:deltaItem withHostVersion:hostVersion comparator:comparator];
|
||||
}
|
||||
|
||||
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
SUAppcastItem *item = nil;
|
||||
NSComparisonResult order;
|
||||
|
||||
for(SUAppcastItem *candidate in appcastItems) {
|
||||
if ([[self class] hostSupportsItem:candidate]) {
|
||||
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||
if ([self hostSupportsItem:candidate]) {
|
||||
// Pick this item if nothing is picked yet. Always pick an item with a higher version. Only if versions are the same
|
||||
// compare their dates and pick this item if its date is not lower – this covers cases when no date is available
|
||||
// and picks items at the end of the appcast list as they are more likely to be the most recent releases.
|
||||
if (
|
||||
!item
|
||||
|| (order = [comparator compareVersion:item.versionString toVersion:candidate.versionString]) == NSOrderedAscending
|
||||
|| (order == NSOrderedSame && [item.date compare:candidate.date] != NSOrderedDescending)
|
||||
) {
|
||||
item = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item && deltaItem) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
*deltaItem = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
BOOL osOK = [ui isMacOsUpdate];
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) {
|
||||
return osOK;
|
||||
}
|
||||
@@ -149,13 +178,13 @@
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
{
|
||||
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
return ui && [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
@@ -175,7 +204,7 @@
|
||||
{
|
||||
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||
}
|
||||
|
||||
|
||||
if (item != nil) // Does the delegate want to handle it?
|
||||
{
|
||||
if ([item isDeltaUpdate]) {
|
||||
@@ -186,14 +215,18 @@
|
||||
{
|
||||
// Find the best supported update
|
||||
SUAppcastItem *deltaUpdateItem = nil;
|
||||
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||
|
||||
item = [self bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||
|
||||
if (item && deltaUpdateItem) {
|
||||
self.nonDeltaUpdateItem = item;
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
|
||||
self.latestAppcastItem = item;
|
||||
self.latestAppcastItemComparisonResult = [[self versionComparator] compareVersion:[self.host version] toVersion:[item versionString]];
|
||||
|
||||
|
||||
if ([self itemContainsValidUpdate:item]) {
|
||||
self.updateItem = item;
|
||||
[self performSelectorOnMainThread:@selector(didFindValidUpdate) withObject:nil waitUntilDone:NO];
|
||||
@@ -206,7 +239,7 @@
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
assert(self.updateItem);
|
||||
|
||||
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
@@ -222,7 +255,7 @@
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||
}
|
||||
@@ -247,12 +280,12 @@
|
||||
SULog(SULogLevelError, @"Failed to find user's cache directory! Using system default");
|
||||
cachePath = NSTemporaryDirectory();
|
||||
}
|
||||
|
||||
|
||||
NSString *name = [self.host.bundle bundleIdentifier];
|
||||
if (!name) {
|
||||
name = [self.host name];
|
||||
}
|
||||
|
||||
|
||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
||||
return cachePath;
|
||||
@@ -262,13 +295,16 @@
|
||||
{
|
||||
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
|
||||
|
||||
// Clear cache directory so that downloads can't possibly accumulate inside
|
||||
NSString *appCachePath = [self appCachePath];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
|
||||
}
|
||||
|
||||
// Ensure no other thirdparty app-updater is concurrently updating this app.
|
||||
[[SUGlobalUpdateLock sharedLock] lock];
|
||||
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||
@@ -282,8 +318,8 @@
|
||||
willDownloadUpdate:self.updateItem
|
||||
withRequest:request];
|
||||
}
|
||||
|
||||
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 9, 0}]) {
|
||||
|
||||
if (SUAVAILABLE(10, 9)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
|
||||
@@ -322,7 +358,7 @@
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didDownloadUpdate:)]) {
|
||||
[[updater delegate] updater:self.updater didDownloadUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
|
||||
[self extractUpdate];
|
||||
}
|
||||
|
||||
@@ -332,15 +368,15 @@
|
||||
if (!failingUrl) {
|
||||
failingUrl = [self.updateItem fileURL];
|
||||
}
|
||||
|
||||
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
||||
[[updater delegate] updater:self.updater
|
||||
failedToDownloadUpdate:self.updateItem
|
||||
error:error];
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
||||
NSUnderlyingErrorKey: error,
|
||||
@@ -348,7 +384,7 @@
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
||||
}
|
||||
|
||||
@@ -356,21 +392,23 @@
|
||||
{
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||
|
||||
BOOL success;
|
||||
|
||||
BOOL success = NO;
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
|
||||
|
||||
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
|
||||
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated];
|
||||
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
|
||||
|
||||
success = self.updateValidator.canValidate;
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
|
||||
|
||||
if (needsPrevalidation) {
|
||||
success = [self.updateValidator validateDownloadPath];
|
||||
} else {
|
||||
success = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!success) {
|
||||
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
|
||||
[self unarchiverDidFailWithError:reason];
|
||||
@@ -378,7 +416,7 @@
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willExtractUpdate:)]) {
|
||||
[[updater delegate] updater:self.updater willExtractUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
|
||||
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
|
||||
if (err) {
|
||||
[self unarchiverDidFailWithError:err];
|
||||
@@ -387,7 +425,7 @@
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didExtractUpdate:)]) {
|
||||
[[updater delegate] updater:self.updater didExtractUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
|
||||
[self performSelectorOnMainThread:@selector(unarchiverDidFinish:) withObject:nil waitUntilDone:NO];
|
||||
} progressBlock:^(double progress) {
|
||||
[self unarchiver:nil extractedProgress:progress];
|
||||
@@ -413,7 +451,7 @@
|
||||
- (void)unarchiverDidFinish:(id)__unused ua
|
||||
{
|
||||
assert(self.updateItem);
|
||||
|
||||
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
@@ -421,12 +459,12 @@
|
||||
{
|
||||
// No longer needed
|
||||
self.updateValidator = nil;
|
||||
|
||||
|
||||
if ([self.updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self abortUpdateWithError:err];
|
||||
}
|
||||
|
||||
@@ -471,7 +509,7 @@
|
||||
{
|
||||
assert(self.updateItem);
|
||||
assert(self.updateValidator);
|
||||
|
||||
|
||||
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
||||
if (!validationCheckSuccess) {
|
||||
NSDictionary *userInfo = @{
|
||||
@@ -492,19 +530,24 @@
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
static BOOL postponedOnce = NO;
|
||||
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
return;
|
||||
if (!postponedOnce) {
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) {
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
return;
|
||||
}
|
||||
} else if ([updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:)]) {
|
||||
postponedOnce = YES;
|
||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
||||
}
|
||||
@@ -555,7 +598,7 @@
|
||||
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
|
||||
SULog(SULogLevelError, @"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
|
||||
SULog(SULogLevelDefault, @"Warning: could not remove quarantine metadata from %@: %@. This may not be a problem, the update process will continue.", relaunchCopyTargetPath, quarantineError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -591,10 +634,10 @@
|
||||
pathToRelaunch = delegateRelaunchPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Set relaunching flag.
|
||||
[self.host setBool:YES forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];
|
||||
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
@@ -638,6 +681,9 @@
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
// Remove lockfile to prevent 3rd party updaters from updating this app if the update is not going to happen anyway
|
||||
[[SUGlobalUpdateLock sharedLock] unlock];
|
||||
|
||||
[self cleanUpDownload];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
self.updateItem = nil;
|
||||
|
||||
@@ -190,6 +190,11 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
uint16_t mode = ent->fts_statp->st_mode;
|
||||
// permission of symlinks is irrelevant and can't be changed.
|
||||
// hardcoding a value helps avoid differences between filesystems.
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
mode = 0755;
|
||||
}
|
||||
uint16_t type = ent->fts_info;
|
||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||
|
||||
|
||||
@@ -381,13 +381,10 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
|
||||
permissions = 0755;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "\nwarning: file permissions %o of '%s' won't be preserved in the delta update (only permissions with modes 0755 and 0644 are supported).\n", permissions & PERMISSION_FLAGS, ent->fts_path);
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Invalid file permissions after-tree on file %@ (only permissions with modes 0755 and 0644 are supported)", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (aclExists(ent)) {
|
||||
@@ -588,7 +585,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
NSFileManager *filemgr;
|
||||
filemgr = [NSFileManager defaultManager];
|
||||
|
||||
|
||||
[filemgr removeItemAtPath: patchFile error: NULL];
|
||||
if ([filemgr moveItemAtPath: temporaryFile toPath: patchFile error: NULL] != YES)
|
||||
{
|
||||
|
||||
@@ -30,14 +30,14 @@ static void printUsage(NSString *programName)
|
||||
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
||||
}
|
||||
|
||||
static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runCreateCommand(NSString *programName, NSArray<NSString *> *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 5) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUInteger numberOflagsFound = 0;
|
||||
NSUInteger numberOfFlagsFound = 0;
|
||||
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
||||
NSUInteger versionIndex = NSNotFound;
|
||||
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
|
||||
@@ -48,13 +48,13 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
}
|
||||
|
||||
if (verboseIndex != NSNotFound) {
|
||||
++numberOflagsFound;
|
||||
++numberOfFlagsFound;
|
||||
}
|
||||
if (versionIndex != NSNotFound) {
|
||||
++numberOflagsFound;
|
||||
++numberOfFlagsFound;
|
||||
}
|
||||
|
||||
if (args.count - numberOflagsFound < 3) {
|
||||
if (args.count - numberOfFlagsFound < 3) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
BOOL verbose = (verboseIndex != NSNotFound);
|
||||
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
||||
|
||||
NSArray *versionComponents = nil;
|
||||
NSArray<NSString *> *versionComponents = nil;
|
||||
if (versionField) {
|
||||
versionComponents = [versionField componentsSeparatedByString:@"="];
|
||||
if (versionComponents.count != 2) {
|
||||
@@ -124,7 +124,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runApplyCommand(NSString *programName, NSArray<NSString *> *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 4) {
|
||||
printUsage(programName);
|
||||
@@ -138,7 +138,7 @@ static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||
NSMutableArray<NSString *> *fileArgs = [NSMutableArray array];
|
||||
for (NSString *argument in args) {
|
||||
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
||||
[fileArgs addObject:argument];
|
||||
@@ -172,7 +172,7 @@ static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runVersionCommand(NSString *programName, NSArray<NSString *> *args)
|
||||
{
|
||||
if (args.count > 1) {
|
||||
printUsage(programName);
|
||||
@@ -218,7 +218,7 @@ static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
||||
int main(int __unused argc, char __unused *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
|
||||
NSString *programName = [args[0] lastPathComponent];
|
||||
|
||||
if (args.count < 2) {
|
||||
@@ -227,7 +227,7 @@ int main(int __unused argc, char __unused *argv[])
|
||||
}
|
||||
|
||||
NSString *command = args[1];
|
||||
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
||||
NSArray<NSString *> *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
||||
|
||||
BOOL result;
|
||||
if ([command isEqualToString:CREATE_COMMAND]) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
#ifndef SUCODESIGNINGVERIFIER_H
|
||||
#define SUCODESIGNINGVERIFIER_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Misc:
|
||||
// Misc:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
||||
@@ -24,13 +24,13 @@ extern NSString *const SUBundleIdentifier;
|
||||
extern NSString *const SUAppcastAttributeValueMacOS;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Notifications:
|
||||
// Notifications:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUTechnicalErrorInformationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// PList keys::
|
||||
// PList keys::
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUFeedURLKey;
|
||||
@@ -41,6 +41,8 @@ extern NSString *const SUSkippedVersionKey;
|
||||
extern NSString *const SUScheduledCheckIntervalKey;
|
||||
extern NSString *const SULastCheckTimeKey;
|
||||
extern NSString *const SUExpectsDSASignatureKey;
|
||||
extern NSString *const SUExpectsEDSignatureKey;
|
||||
extern NSString *const SUPublicEDKeyKey;
|
||||
extern NSString *const SUPublicDSAKeyKey;
|
||||
extern NSString *const SUPublicDSAKeyFileKey;
|
||||
extern NSString *const SUAutomaticallyUpdateKey;
|
||||
@@ -48,6 +50,7 @@ extern NSString *const SUAllowsAutomaticUpdatesKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKey;
|
||||
extern NSString *const SUEnableSystemProfilingKey;
|
||||
extern NSString *const SUSendProfileInfoKey;
|
||||
extern NSString *const SUUpdateGroupIdentifierKey;
|
||||
extern NSString *const SULastProfileSubmitDateKey;
|
||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||
extern NSString *const SUDefaultsDomainKey;
|
||||
@@ -59,16 +62,16 @@ extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((dep
|
||||
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Appcast keys::
|
||||
// Appcast keys::
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUAppcastAttributeDeltaFrom;
|
||||
extern NSString *const SUAppcastAttributeDSASignature;
|
||||
extern NSString *const SUAppcastAttributeEDSignature;
|
||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||
extern NSString *const SUAppcastAttributeVersion;
|
||||
extern NSString *const SUAppcastAttributeOsType;
|
||||
|
||||
|
||||
extern NSString *const SUAppcastAttributePhasedRolloutInterval;
|
||||
|
||||
extern NSString *const SUAppcastElementCriticalUpdate;
|
||||
extern NSString *const SUAppcastElementDeltas;
|
||||
@@ -86,4 +89,6 @@ extern NSString *const SURSSElementLink;
|
||||
extern NSString *const SURSSElementPubDate;
|
||||
extern NSString *const SURSSElementTitle;
|
||||
|
||||
extern NSString *const SUXMLLanguage;
|
||||
|
||||
#endif
|
||||
@@ -33,6 +33,8 @@ NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
|
||||
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
||||
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
|
||||
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
||||
NSString *const SUExpectsEDSignatureKey = @"SUExpectsEDSignatureKey";
|
||||
NSString *const SUPublicEDKeyKey = @"SUPublicEDKey";
|
||||
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
||||
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
||||
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
@@ -40,6 +42,7 @@ NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||
NSString *const SUUpdateGroupIdentifierKey = @"SUUpdateGroupIdentifier";
|
||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
||||
@@ -54,9 +57,11 @@ NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
|
||||
|
||||
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
||||
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
||||
NSString *const SUAppcastAttributeEDSignature = @"sparkle:edSignature";
|
||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||
NSString *const SUAppcastAttributeOsType = @"sparkle:os";
|
||||
NSString *const SUAppcastAttributePhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
|
||||
|
||||
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
||||
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
||||
@@ -73,3 +78,5 @@ NSString *const SURSSElementEnclosure = @"enclosure";
|
||||
NSString *const SURSSElementLink = @"link";
|
||||
NSString *const SURSSElementPubDate = @"pubDate";
|
||||
NSString *const SURSSElementTitle = @"title";
|
||||
|
||||
NSString *const SUXMLLanguage = @"xml:lang";
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// SUDSAVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -1,168 +0,0 @@
|
||||
//
|
||||
// SUDSAVerifier.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SULog.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUDSAVerifier {
|
||||
SecKeyRef _secKey;
|
||||
}
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
if (!encodedSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature to check");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUDSAVerifier *verifier = [(SUDSAVerifier *)[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
NSData *signature = [[NSData alloc] initWithBase64Encoding:strippedSignature];
|
||||
return [verifier verifyFileAtPath:path signature:signature];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecExternalFormat format = kSecFormatOpenSSL;
|
||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||
CFArrayRef items = NULL;
|
||||
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
|
||||
if (status != errSecSuccess || !items) {
|
||||
if (items) {
|
||||
CFRelease(items);
|
||||
}
|
||||
SULog(SULogLevelError, @"Public DSA key could not be imported: %d", status);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
|
||||
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
|
||||
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_secKey) {
|
||||
CFRelease(_secKey);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
|
||||
{
|
||||
if (!path.length) {
|
||||
return NO;
|
||||
}
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyStream:dataInputStream signature:signature];
|
||||
}
|
||||
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !signature) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
__block SecTransformRef dataVerifyTransform = NULL;
|
||||
__block CFErrorRef error = NULL;
|
||||
|
||||
BOOL (^cleanup)(void) = ^{
|
||||
if (group) CFRelease(group);
|
||||
if (dataReadTransform) CFRelease(dataReadTransform);
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
return NO;
|
||||
};
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(SULogLevelError, @"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(SULogLevelError, @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
}
|
||||
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -30,7 +30,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
{
|
||||
@autoreleasepool {
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
// get a unique mount point path
|
||||
@@ -65,7 +65,7 @@
|
||||
NSError *error;
|
||||
NSArray *contents;
|
||||
do
|
||||
{
|
||||
{
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
@@ -135,8 +135,8 @@
|
||||
|
||||
[notifier notifyProgress:0.5];
|
||||
|
||||
if (taskResult != 0)
|
||||
{
|
||||
if (taskResult != 0)
|
||||
{
|
||||
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
||||
SULog(SULogLevelError, @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
||||
goto reportError;
|
||||
@@ -155,8 +155,8 @@
|
||||
double itemsCopied = 0;
|
||||
double totalItems = [contents count];
|
||||
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
@@ -169,8 +169,8 @@
|
||||
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUNoUpdateError = 1001,
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
SURunningTranslocated = 1004,
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
//
|
||||
|
||||
#import "SUFileManager.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUFileOperationConstants.h"
|
||||
|
||||
#import "SUErrors.h"
|
||||
|
||||
#include <sys/xattr.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// SUGlobalUpdateLock.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Bibhas Acharya on 7/12/20.
|
||||
// Copyright © 2020 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUGLOBALUPDATELOCK_H
|
||||
#define SUGLOBALUPDATELOCK_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
@interface SUGlobalUpdateLock : NSObject
|
||||
|
||||
+ (SUGlobalUpdateLock *)sharedLock;
|
||||
- (void)lock;
|
||||
- (void)unlock;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// SUGlobalUpdateFileLock.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Bibhas Acharya on 7/12/20.
|
||||
// Copyright © 2020 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUGlobalUpdateLock.h"
|
||||
#import "SULog.h"
|
||||
|
||||
|
||||
@implementation SUGlobalUpdateLock
|
||||
|
||||
+ (SUGlobalUpdateLock *)sharedLock
|
||||
{
|
||||
static dispatch_once_t once;
|
||||
static SUGlobalUpdateLock *sharedInstance = nil;
|
||||
dispatch_once(&once, ^{
|
||||
sharedInstance = [self new];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)lock
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *fileLockPath = [self fileLockPath];
|
||||
|
||||
BOOL success = [fileManager createFileAtPath:fileLockPath contents:nil attributes:nil];
|
||||
if (!success) {
|
||||
SULog(SULogLevelDefault, @"Couldn't create lockfile at: %@", fileLockPath);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unlock
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *fileLockPath = [self fileLockPath];
|
||||
|
||||
if ([fileManager fileExistsAtPath:fileLockPath]) {
|
||||
NSError *error = nil;
|
||||
[fileManager removeItemAtPath:fileLockPath error:&error];
|
||||
if (error != nil) {
|
||||
SULog(SULogLevelError, @"Couldn't remove lockfile at: %@ [%@]", fileLockPath, [error localizedDescription]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)identifier
|
||||
{
|
||||
NSString *resp = [[NSBundle mainBundle] bundleIdentifier];
|
||||
if (resp == nil) {
|
||||
// If there's no bundle identifier, use the executable path
|
||||
resp = [[[NSBundle mainBundle] executablePath] stringByReplacingOccurrencesOfString:@"/" withString:@"."];
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
- (NSString *)fileLockPath
|
||||
{
|
||||
return [NSString stringWithFormat:@"/private/tmp/%@.Sparkle.pid", [self identifier]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUHost : NSObject
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
@@ -16,16 +20,20 @@
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
@property (readonly, copy) NSString *displayVersion;
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||
@property (readonly) SUPublicKeys *publicKeys;
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (getter=isRunningTranslocated, readonly) BOOL runningTranslocated;
|
||||
@property (readonly, nonatomic, copy, nullable) NSString *publicDSAKeyFileKey;
|
||||
|
||||
- (nullable id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key;
|
||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName;
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName;
|
||||
- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName;
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName;
|
||||
- (id)objectForKey:(NSString *)key;
|
||||
- (nullable id)objectForKey:(NSString *)key;
|
||||
- (BOOL)boolForKey:(NSString *)key;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -10,10 +10,12 @@
|
||||
#import "SUConstants.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
|
||||
#import "SUSignatures.h"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// This class should not rely on AppKit and should also be process independent
|
||||
// For example, it should not have code that tests writabilty to somewhere on disk,
|
||||
// as that may depend on the privileges of the process owner. Or code that depends on
|
||||
@@ -24,8 +26,9 @@
|
||||
|
||||
@property (strong, readwrite) NSBundle *bundle;
|
||||
@property (nonatomic, readonly) BOOL isMainBundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (copy, nullable) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
@property (readonly, copy, nullable) NSString *publicDSAKey;
|
||||
|
||||
@end
|
||||
|
||||
@@ -38,8 +41,8 @@
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
NSParameterAssert(aBundle);
|
||||
self.bundle = aBundle;
|
||||
if (![self.bundle bundleIdentifier]) {
|
||||
@@ -68,7 +71,7 @@
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *__nonnull)name
|
||||
- (NSString *)name
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
@@ -77,15 +80,15 @@
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name && name.length > 0) return name;
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||
if (name && name.length > 0) return name;
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[self bundlePath]] stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
- (NSString *__nonnull)version
|
||||
- (NSString *)version
|
||||
{
|
||||
NSString *version = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
@@ -93,7 +96,7 @@
|
||||
return version;
|
||||
}
|
||||
|
||||
- (NSString *__nonnull)displayVersion
|
||||
- (NSString *)displayVersion
|
||||
{
|
||||
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
@@ -109,17 +112,29 @@
|
||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||
}
|
||||
|
||||
- (BOOL)isRunningTranslocated
|
||||
{
|
||||
NSString *path = [self.bundle bundlePath];
|
||||
return [path rangeOfString:@"/AppTranslocation/"].location != NSNotFound;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *__nullable)publicEDKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicEDKeyKey];
|
||||
}
|
||||
|
||||
- (NSString *__nullable)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
if (key) {
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self publicDSAKeyFileKey];
|
||||
if (!keyFilename) {
|
||||
if (!keyFilename) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -135,12 +150,17 @@
|
||||
return key;
|
||||
}
|
||||
|
||||
- (SUPublicKeys *)publicKeys
|
||||
{
|
||||
return [[SUPublicKeys alloc] initWithDsa:[self publicDSAKey] ed:[self publicEDKey]];
|
||||
}
|
||||
|
||||
- (NSString * __nullable)publicDSAKeyFileKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
}
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||
- (nullable id)objectForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
if (self.isMainBundle) {
|
||||
// Common fast path - if we're updating the main bundle, that means our updater and host bundle's lifetime is the same
|
||||
@@ -164,7 +184,7 @@
|
||||
return [(NSNumber *)[self objectForInfoDictionaryKey:key] boolValue];
|
||||
}
|
||||
|
||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||
- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (!defaultName || !self.defaultsDomain) {
|
||||
return nil;
|
||||
@@ -182,14 +202,14 @@
|
||||
}
|
||||
|
||||
// Note this handles nil being passed for defaultName, in which case the user default will be removed
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName
|
||||
- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
@@ -205,10 +225,10 @@
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||
if (plr == NULL) {
|
||||
value = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = CFBooleanGetValue((CFBooleanRef)plr) ? YES : NO;
|
||||
CFRelease(plr);
|
||||
}
|
||||
return value;
|
||||
@@ -216,18 +236,18 @@
|
||||
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)objectForKey:(NSString *)key {
|
||||
- (nullable id)objectForKey:(NSString *)key {
|
||||
return [self objectForUserDefaultsKey:key] ? [self objectForUserDefaultsKey:key] : [self objectForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
@@ -236,3 +256,5 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -152,8 +152,14 @@
|
||||
{
|
||||
NSBundle *bundle = host.bundle;
|
||||
assert(bundle != nil);
|
||||
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]];
|
||||
|
||||
NSString * baseBundleName = [host objectForInfoDictionaryKey:@"SUBundleName"];
|
||||
|
||||
if (baseBundleName == nil) {
|
||||
baseBundleName = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||
}
|
||||
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", baseBundleName, [[bundle bundlePath] pathExtension]]];
|
||||
|
||||
// Roundtrip string through fileSystemRepresentation to ensure it uses filesystem's Unicode normalization
|
||||
// rather than arbitrary Unicode form from Info.plist - #1017
|
||||
|
||||
@@ -63,7 +63,7 @@ void SULog(SULogLevel level, NSString *format, ...)
|
||||
}
|
||||
|
||||
NSString *displayName = [[NSFileManager defaultManager] displayNameAtPath:mainBundle.bundlePath];
|
||||
client = asl_open([displayName stringByAppendingString:@" [Sparkle]"].UTF8String, SPARKLE_BUNDLE_IDENTIFIER, options);
|
||||
client = asl_open([displayName stringByAppendingString:@" [Sparkle " TO_STRING(SPARKLE_VERSION) "]"].UTF8String, SPARKLE_BUNDLE_IDENTIFIER, options);
|
||||
queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,3 +22,9 @@ typedef struct {
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__clang_major__) && __clang_major__ >= 9
|
||||
#define SUAVAILABLE(major, minor) @available(macOS major##.##minor, *)
|
||||
#else
|
||||
#define SUAVAILABLE(major, minor) [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){major, minor, 0}]
|
||||
#endif
|
||||
@@ -55,7 +55,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<NSString *> *args = @[@"-W", @"-n", @"-b", @"com.apple.installer", self.packagePath];
|
||||
|
||||
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||
@try {
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@@ -92,7 +92,7 @@
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
@autoreleasepool {
|
||||
@autoreleasepool {
|
||||
NSError *error = nil;
|
||||
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
|
||||
|
||||
@@ -105,43 +105,49 @@
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:self.archivePath];
|
||||
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
[task setStandardInput:[pipe fileHandleForReading]];
|
||||
[task setStandardError:[NSFileHandle fileHandleWithStandardError]];
|
||||
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
|
||||
[task setLaunchPath:command];
|
||||
[task setArguments:[args arrayByAddingObject:destination]];
|
||||
[task launch];
|
||||
|
||||
NSUInteger bytesRead = 0;
|
||||
do {
|
||||
NSData *data = [archiveInput readDataOfLength:256*1024];
|
||||
NSUInteger len = [data length];
|
||||
if (!len) {
|
||||
break;
|
||||
}
|
||||
bytesRead += len;
|
||||
[archiveOutput writeData:data];
|
||||
[notifier notifyProgress:(double)bytesRead / (double)expectedLength];
|
||||
@try {
|
||||
[task launch];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, -[NSTask launch] threw exception '%@'", e.description]}];
|
||||
}
|
||||
while(bytesRead < expectedLength);
|
||||
|
||||
[archiveOutput closeFile];
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
if ([task terminationStatus] == 0) {
|
||||
if (bytesRead == expectedLength) {
|
||||
[notifier notifySuccess];
|
||||
return;
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesRead, (long)expectedLength]}];
|
||||
|
||||
if (!error) {
|
||||
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
|
||||
NSUInteger bytesRead = 0;
|
||||
do {
|
||||
NSData *data = [archiveInput readDataOfLength:256*1024];
|
||||
NSUInteger len = [data length];
|
||||
if (!len) {
|
||||
break;
|
||||
}
|
||||
bytesRead += len;
|
||||
[archiveOutput writeData:data];
|
||||
[notifier notifyProgress:(double)bytesRead / (double)expectedLength];
|
||||
}
|
||||
while(bytesRead < expectedLength);
|
||||
|
||||
[archiveOutput closeFile];
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
if ([task terminationStatus] == 0) {
|
||||
if (bytesRead == expectedLength) {
|
||||
[notifier notifySuccess];
|
||||
return;
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesRead, (long)expectedLength]}];
|
||||
|
||||
}
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]]}];
|
||||
}
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]]}];
|
||||
}
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", self.archivePath]}];
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -208,6 +209,15 @@
|
||||
progress(9/10.0);
|
||||
}
|
||||
|
||||
// Try to preserve Finder tags. Failure can be accepted without complaint as previous Sparkle versions did not do this at all
|
||||
if (SUAVAILABLE(10, 9)) {
|
||||
NSArray *resourceTags;
|
||||
BOOL success = [oldTempURL getResourceValue:&resourceTags forKey:NSURLTagNamesKey error:NULL];
|
||||
if (success && resourceTags.count) {
|
||||
[installationURL setResourceValue:resourceTags forKey:NSURLTagNamesKey error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
// From here on out, we don't really need to bring up authorization if we haven't done so prior
|
||||
SUFileManager *constrainedFileManager = [fileManager fileManagerByPreservingAuthorizationRights];
|
||||
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
#import "SUUpdaterPrivate.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
|
||||
@interface SUScheduledUpdateDriver ()
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
|
||||
@interface SUScheduledUpdateDriver ()
|
||||
- (BOOL)isItemReadyForPhasedRollout:(SUAppcastItem *)ui;
|
||||
@end
|
||||
|
||||
@implementation SUScheduledUpdateDriver
|
||||
@@ -24,6 +27,28 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui {
|
||||
return [super hostSupportsItem:ui] && [self isItemReadyForPhasedRollout:ui];
|
||||
}
|
||||
|
||||
- (BOOL)isItemReadyForPhasedRollout:(SUAppcastItem *)ui {
|
||||
if([ui isCriticalUpdate] || ![ui phasedRolloutInterval]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSDate* itemReleaseDate = ui.date;
|
||||
if(!itemReleaseDate) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSTimeInterval timeSinceRelease = [[NSDate date] timeIntervalSinceDate:itemReleaseDate];
|
||||
|
||||
NSTimeInterval phasedRolloutInterval = [[ui phasedRolloutInterval] doubleValue];
|
||||
NSTimeInterval timeToWaitForGroup = phasedRolloutInterval * [SUSystemUpdateInfo updateGroupForHost:self.host];
|
||||
|
||||
return timeSinceRelease >= timeToWaitForGroup;
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
self.showErrors = YES; // We only start showing errors after we present the UI for the first time.
|
||||
@@ -47,4 +72,20 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)shouldShowUpdateAlertForItem:(SUAppcastItem *)item {
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterShouldShowUpdateAlertForScheduledUpdate:forItem:)]) {
|
||||
return [updaterDelegate updaterShouldShowUpdateAlertForScheduledUpdate:self.updater forItem:item];
|
||||
}
|
||||
|
||||
return [super shouldShowUpdateAlertForItem:item];
|
||||
}
|
||||
|
||||
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable) downloadData {
|
||||
[SUSystemUpdateInfo setNewUpdateGroupIdentifierForHost:self.host]; // use new update group next time
|
||||
[super downloaderDidFinishWithTemporaryDownloadData:downloadData];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// SUDSAVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class SUSignatures;
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// SUDSAVerifier.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUSignatureVerifier ()
|
||||
@property (readonly) SUPublicKeys *pubKeys;
|
||||
@end
|
||||
|
||||
@implementation SUSignatureVerifier {
|
||||
}
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [verifier verifyFileAtPath:path signatures:signatures];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
|
||||
{
|
||||
self = [super init];
|
||||
_pubKeys = pubkeys;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SecKeyRef)dsaSecKeyRef {
|
||||
|
||||
NSData *data = [self.pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecExternalFormat format = kSecFormatOpenSSL;
|
||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||
CFArrayRef items = NULL;
|
||||
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
|
||||
if (status != errSecSuccess || !items) {
|
||||
if (items) {
|
||||
CFRelease(items);
|
||||
}
|
||||
SULog(SULogLevelError, @"Public DSA key could not be imported: %d", status);
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = nil;
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
|
||||
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
|
||||
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
dsaPubKeySecKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
return dsaPubKeySecKey;
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures
|
||||
{
|
||||
if (!path || !path.length) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!signatures) {
|
||||
SULog(SULogLevelDefault, @"No signatures given to verifyFileAtPath");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSData *dsaSignature = signatures.dsaSignature;
|
||||
NSString *dsaPubKey = self.pubKeys.dsaPubKey;
|
||||
|
||||
const unsigned char *edSignature = signatures.ed25519Signature;
|
||||
const unsigned char *edPubKey = self.pubKeys.ed25519PubKey;
|
||||
|
||||
if (edPubKey && !edSignature) {
|
||||
SULog(SULogLevelDefault, @"There is no EdDSA signature in the update, but the app is capable of verifying them");
|
||||
} if (!edPubKey && edSignature) {
|
||||
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");
|
||||
} else if (edPubKey && edSignature) {
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&error];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, error);
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(edSignature, data.bytes, data.length, edPubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
|
||||
if (!dsaPubKey) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(SULogLevelDefault, @"This app has a DSA public key, so a DSA signature is required too");
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (dsaSignature) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dsaSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
} else if (!dsaPubKey) {
|
||||
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");
|
||||
} else {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:dsaSignature];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
|
||||
if (!dsaPubKeySecKey) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
__block SecTransformRef dataVerifyTransform = NULL;
|
||||
__block CFErrorRef error = NULL;
|
||||
|
||||
BOOL (^cleanup)(void) = ^{
|
||||
if (group) CFRelease(group);
|
||||
if (dataReadTransform) CFRelease(dataReadTransform);
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
if (dsaPubKeySecKey) CFRelease(dsaPubKeySecKey);
|
||||
return NO;
|
||||
};
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(SULogLevelError, @"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
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 || error) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(SULogLevelError, @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
}
|
||||
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// SUSignatures.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Kornel on 15/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUSignatures : NSObject {
|
||||
unsigned char ed25519_signature[64];
|
||||
}
|
||||
@property (strong, readonly, nullable) NSData *dsaSignature;
|
||||
@property (readonly, nullable, nonatomic) const unsigned char *ed25519Signature;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed;
|
||||
@end
|
||||
|
||||
|
||||
@interface SUPublicKeys : NSObject {
|
||||
unsigned char ed25519_public_key[32];
|
||||
}
|
||||
@property (strong, readonly, nullable) NSString *dsaPubKey;
|
||||
@property (readonly, nullable, nonatomic) const unsigned char *ed25519PubKey;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed;
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// SUSignatures.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Kornel on 15/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUSignatures.h"
|
||||
#import <assert.h>
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUSignatures
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
|
||||
static NSData *decode(NSString *str) {
|
||||
if (str == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *stripped = [str stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
return [[NSData alloc] initWithBase64Encoding:stripped];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (maybeDsa != nil) {
|
||||
_dsaSignature = decode(maybeDsa);
|
||||
}
|
||||
if (maybeEd25519 != nil) {
|
||||
NSData *data = decode(maybeEd25519);
|
||||
assert(64 == sizeof(self->ed25519_signature));
|
||||
[data getBytes:self->ed25519_signature length:sizeof(self->ed25519_signature)];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (const unsigned char *)ed25519Signature {
|
||||
// Xcode may enable this in pedantic mode
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
for(size_t i=0; i < sizeof(self->ed25519_signature); i++) {
|
||||
if (self->ed25519_signature[i] != 0) {
|
||||
return self->ed25519_signature;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPublicKeys
|
||||
@synthesize dsaPubKey = _dsaPubKey;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_dsaPubKey = maybeDsa;
|
||||
if (maybeEd25519 != nil) {
|
||||
NSData *ed = decode(maybeEd25519);
|
||||
assert(32 == sizeof(self->ed25519_public_key));
|
||||
[ed getBytes:self->ed25519_public_key length:sizeof(self->ed25519_public_key)];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key {
|
||||
NSString *thisKey = self.dsaPubKey;
|
||||
NSString *thatKey = key.dsaPubKey;
|
||||
if (thisKey == nil || thatKey == nil) {
|
||||
return NO;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (const unsigned char *)ed25519PubKey {
|
||||
// Xcode may enable this in pedantic mode
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
for(size_t i=0; i < sizeof(self->ed25519_public_key); i++) {
|
||||
if (self->ed25519_public_key[i] != 0) {
|
||||
return self->ed25519_public_key;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -33,12 +33,15 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
kNumberType,
|
||||
kStringType,
|
||||
kSeparatorType,
|
||||
kDashType,
|
||||
};
|
||||
|
||||
- (SUCharacterType)typeOfCharacter:(NSString *)character
|
||||
{
|
||||
if ([character isEqualToString:@"."]) {
|
||||
return kSeparatorType;
|
||||
} else if ([character isEqualToString:@"-"]) {
|
||||
return kDashType;
|
||||
} else if ([[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[character characterAtIndex:0]]) {
|
||||
return kNumberType;
|
||||
} else if ([[NSCharacterSet whitespaceAndNewlineCharacterSet] characterIsMember:[character characterAtIndex:0]]) {
|
||||
@@ -50,7 +53,7 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)splitVersionString:(NSString *)version
|
||||
- (NSArray<NSString *> *)splitVersionString:(NSString *)version
|
||||
{
|
||||
NSString *character;
|
||||
NSMutableString *s;
|
||||
@@ -67,6 +70,9 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
for (i = 1; i <= n; ++i) {
|
||||
character = [version substringWithRange:NSMakeRange(i, 1)];
|
||||
newType = [self typeOfCharacter:character];
|
||||
if (newType == kDashType) {
|
||||
break;
|
||||
}
|
||||
if (oldType != newType || oldType == kSeparatorType) {
|
||||
// We've reached a new segment
|
||||
NSString *aPart = [[NSString alloc] initWithString:s];
|
||||
@@ -86,8 +92,8 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB
|
||||
{
|
||||
NSArray *partsA = [self splitVersionString:versionA];
|
||||
NSArray *partsB = [self splitVersionString:versionB];
|
||||
NSArray<NSString *> *partsA = [self splitVersionString:versionA];
|
||||
NSArray<NSString *> *partsB = [self splitVersionString:versionB];
|
||||
|
||||
NSString *partA, *partB;
|
||||
NSUInteger i, n;
|
||||
|
||||
@@ -37,8 +37,8 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
|
||||
- (instancetype)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUStatus"];
|
||||
if (self)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
}
|
||||
@@ -57,7 +57,7 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
|
||||
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
||||
[self.progressBar setUsesThreadedAnimation:YES];
|
||||
|
||||
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 11, 0}]) {
|
||||
if (SUAVAILABLE(10, 11)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
[self.statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]];
|
||||
@@ -125,7 +125,7 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
|
||||
|
||||
- (void)setMaxProgressValue:(double)value
|
||||
{
|
||||
if (value < 0.0) value = 0.0;
|
||||
if (value < 0.0) value = 0.0;
|
||||
maxProgressValue = value;
|
||||
[self setProgressValue:0.0];
|
||||
[self.progressBar setIndeterminate:(value == 0.0)];
|
||||
|
||||
@@ -43,7 +43,7 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
|
||||
// Gather profile information and append it to the URL.
|
||||
NSMutableArray<NSDictionary<NSString *, NSString *> *> *profileArray = [NSMutableArray array];
|
||||
NSArray *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"];
|
||||
NSArray<NSString *> *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"];
|
||||
int error = 0;
|
||||
int value = 0;
|
||||
size_t length = sizeof(value);
|
||||
@@ -62,9 +62,9 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
NSString *visibleCPUType;
|
||||
switch (value) {
|
||||
case CPU_TYPE_ARM: visibleCPUType = @"ARM"; break;
|
||||
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
|
||||
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
|
||||
default: visibleCPUType = @"Unknown"; break;
|
||||
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
|
||||
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
|
||||
default: visibleCPUType = @"Unknown"; break;
|
||||
}
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUTypeKey, @"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
|
||||
}
|
||||
@@ -92,10 +92,10 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
} else if (cpuType == 18) {
|
||||
// PowerPC
|
||||
switch (value) {
|
||||
case 9: visibleCPUSubType=@"G3"; break;
|
||||
case 10: case 11: visibleCPUSubType=@"G4"; break;
|
||||
case 100: visibleCPUSubType=@"G5"; break;
|
||||
default: visibleCPUSubType=@"Other"; break;
|
||||
case 9: visibleCPUSubType=@"G3"; break;
|
||||
case 10: case 11: visibleCPUSubType=@"G4"; break;
|
||||
case 100: visibleCPUSubType=@"G5"; break;
|
||||
default: visibleCPUSubType=@"Other"; break;
|
||||
}
|
||||
} else {
|
||||
visibleCPUSubType = @"Other";
|
||||
|
||||
@@ -16,6 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (BOOL)systemAllowsAutomaticUpdatesForHost:(SUHost *)host;
|
||||
|
||||
+ (NSUInteger)updateGroupForHost:(SUHost*)host;
|
||||
+ (NSNumber*)updateGroupIdentifierForHost:(SUHost*)host;
|
||||
+ (NSNumber*)setNewUpdateGroupIdentifierForHost:(SUHost*)host;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -58,4 +58,28 @@
|
||||
return changeOwnerAndGroupSuccess;
|
||||
}
|
||||
|
||||
#define NUM_UPDATE_GROUPS 7
|
||||
+ (NSUInteger)updateGroupForHost:(SUHost*)host {
|
||||
NSNumber* updateGroupIdentifier = [self updateGroupIdentifierForHost:host];
|
||||
return ([updateGroupIdentifier unsignedIntValue] % NUM_UPDATE_GROUPS);
|
||||
}
|
||||
|
||||
+ (NSNumber*)updateGroupIdentifierForHost:(SUHost*)host {
|
||||
NSNumber* updateGroupIdentifier = [host objectForInfoDictionaryKey:SUUpdateGroupIdentifierKey];
|
||||
if(updateGroupIdentifier == nil) {
|
||||
updateGroupIdentifier = [self setNewUpdateGroupIdentifierForHost:host];
|
||||
}
|
||||
|
||||
return updateGroupIdentifier;
|
||||
}
|
||||
|
||||
+ (NSNumber*)setNewUpdateGroupIdentifierForHost:(SUHost*)host {
|
||||
unsigned int r = arc4random_uniform(UINT_MAX);
|
||||
NSNumber* updateGroupIdentifier = @(r);
|
||||
|
||||
[host setObject:updateGroupIdentifier forUserDefaultsKey:SUUpdateGroupIdentifierKey];
|
||||
|
||||
return updateGroupIdentifier;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -20,6 +20,7 @@
|
||||
- (void)showAlert:(NSAlert *)alert;
|
||||
- (IBAction)cancelDownload:(id)sender;
|
||||
- (void)installAndRestart:(id)sender;
|
||||
- (BOOL)shouldShowUpdateAlertForItem:(SUAppcastItem *)item;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -56,6 +56,10 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)shouldShowUpdateAlertForItem:(SUAppcastItem *)__unused item {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
@@ -64,12 +68,18 @@
|
||||
}
|
||||
|
||||
if (self.automaticallyInstallUpdates) {
|
||||
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
|
||||
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice forItem:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
[self updateAlertFinishedWithChoice:choice];
|
||||
SUAppcastItem *updateItem = self.updateItem;
|
||||
if (![self shouldShowUpdateAlertForItem:updateItem]) {
|
||||
[self abortUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
[self updateAlertFinishedWithChoice:choice forItem:updateItem];
|
||||
}];
|
||||
|
||||
id<SUVersionDisplay> versDisp = nil;
|
||||
@@ -110,9 +120,25 @@
|
||||
|
||||
if (!self.automaticallyInstallUpdates) {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
|
||||
if (self.latestAppcastItem) // if the appcast was successfully loaded
|
||||
{
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
|
||||
if (self.latestAppcastItemComparisonResult == NSOrderedDescending ) { // this means the user is a 'newer than latest' version. give a slight hint to the user instead of wrongly claiming this version is identical to the latest feed version.
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.\n(You are currently running version %@.)", nil), [self.host name], self.latestAppcastItem.displayVersionString, [self.host displayVersion]];
|
||||
}
|
||||
else {
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
}
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
}
|
||||
else {
|
||||
alert.messageText = SULocalizedString(@"Update Error!", nil);
|
||||
alert.informativeText = SULocalizedString(@"No valid update information could be loaded.", nil);
|
||||
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
|
||||
}
|
||||
|
||||
[self showAlert:alert];
|
||||
}
|
||||
|
||||
@@ -125,26 +151,44 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice
|
||||
- (void)didDismissAlertPermanently:(BOOL)permanently forItem:(SUAppcastItem *)item {
|
||||
if (item == nil) {
|
||||
return;
|
||||
}
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
if ([updater.delegate respondsToSelector:@selector(updater:didDismissUpdateAlertPermanently:forItem:)]) {
|
||||
[updater.delegate updater:self.updater didDismissUpdateAlertPermanently:permanently forItem:item];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice forItem:(SUAppcastItem *)item
|
||||
{
|
||||
self.updateAlert = nil;
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
switch (choice) {
|
||||
case SUInstallUpdateChoice:
|
||||
[self didDismissAlertPermanently:NO forItem:item];
|
||||
[self downloadUpdate];
|
||||
break;
|
||||
|
||||
case SUOpenInfoURLChoice:
|
||||
[self didDismissAlertPermanently:NO forItem:item];
|
||||
[[NSWorkspace sharedWorkspace] openURL:[self.updateItem infoURL]];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SUSkipThisVersionChoice:
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:userDidSkipThisVersion:)]) {
|
||||
[[updater delegate] updater:self.updater userDidSkipThisVersion:self.updateItem];
|
||||
}
|
||||
[self didDismissAlertPermanently:YES forItem:item];
|
||||
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
|
||||
case SURemindMeLaterChoice:
|
||||
[self didDismissAlertPermanently:NO forItem:item];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
@@ -329,8 +373,8 @@
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
if (self.statusController)
|
||||
{
|
||||
if (self.statusController)
|
||||
{
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated;
|
||||
+ (BOOL)mustValidateBeforeExtraction;
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Headers:
|
||||
// Headers:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#import "SUUpdateAlert.h"
|
||||
@@ -21,6 +21,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUTouchBarForwardDeclarations.h"
|
||||
#import "SUTouchBarButtonGroup.h"
|
||||
|
||||
@@ -33,9 +34,11 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
@end
|
||||
@protocol WebPolicyDelegate <NSObject>
|
||||
@end
|
||||
@protocol WebUIDelegate <NSObject>
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUUpdateAlert () <WebFrameLoadDelegate, WebPolicyDelegate, NSTouchBarDelegate>
|
||||
@interface SUUpdateAlert () <WebFrameLoadDelegate, WebPolicyDelegate, WebUIDelegate, NSTouchBarDelegate>
|
||||
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) SUHost *host;
|
||||
@@ -43,6 +46,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@property (strong) NSProgressIndicator *releaseNotesSpinner;
|
||||
@property (assign) BOOL webViewFinishedLoading;
|
||||
@property (assign) BOOL observingAppearance;
|
||||
|
||||
@property (weak) IBOutlet WebView *releaseNotesView;
|
||||
@property (weak) IBOutlet NSView *releaseNotesContainerView;
|
||||
@@ -64,6 +68,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
@synthesize releaseNotesSpinner;
|
||||
@synthesize webViewFinishedLoading;
|
||||
@synthesize observingAppearance;
|
||||
|
||||
@synthesize releaseNotesView;
|
||||
@synthesize releaseNotesContainerView;
|
||||
@@ -76,8 +81,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdateAlert"];
|
||||
if (self)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
self.completionBlock = block;
|
||||
host = aHost;
|
||||
updateItem = item;
|
||||
@@ -91,6 +96,23 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||
if (SUAVAILABLE(10, 14)) {
|
||||
if (self.observingAppearance) {
|
||||
[self.window removeObserver:self forKeyPath:@"effectiveAppearance"];
|
||||
self.observingAppearance = NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(__attribute__((unused)) NSDictionary<NSKeyValueChangeKey,id> *)change context:(__attribute__((unused)) void *)context {
|
||||
if (object == self.window && [keyPath isEqualToString:@"effectiveAppearance"]) {
|
||||
[self adaptReleaseNotesAppearance];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||
|
||||
- (void)disableKeyboardShortcutForInstallButton {
|
||||
@@ -100,8 +122,9 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
- (void)endWithSelection:(SUUpdateAlertChoice)choice
|
||||
{
|
||||
[self.releaseNotesView stopLoading:self];
|
||||
[self.releaseNotesView setFrameLoadDelegate:nil];
|
||||
[self.releaseNotesView setPolicyDelegate:nil];
|
||||
self.releaseNotesView.frameLoadDelegate = nil;
|
||||
self.releaseNotesView.policyDelegate = nil;
|
||||
self.releaseNotesView.UIDelegate = nil;
|
||||
[self.releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
|
||||
[self close];
|
||||
self.completionBlock(choice);
|
||||
@@ -137,12 +160,32 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
prefs.javaScriptEnabled = [self.host boolForInfoDictionaryKey:SUEnableJavaScriptKey];
|
||||
self.releaseNotesView.frameLoadDelegate = self;
|
||||
self.releaseNotesView.policyDelegate = self;
|
||||
self.releaseNotesView.UIDelegate = self;
|
||||
|
||||
// Set the default font
|
||||
// "-apple-system-font" is a reference to the system UI font. "-apple-system" is the new recommended token, but for backward compatibility we can't use it.
|
||||
prefs.standardFontFamily = @"-apple-system-font";
|
||||
prefs.defaultFontSize = (int)[NSFont systemFontSize];
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||
if (SUAVAILABLE(10, 14))
|
||||
{
|
||||
NSBox *darkBackgroundView = [[NSBox alloc] initWithFrame:self.releaseNotesView.frame];
|
||||
darkBackgroundView.boxType = NSBoxCustom;
|
||||
darkBackgroundView.fillColor = [NSColor textBackgroundColor];
|
||||
darkBackgroundView.borderColor = [NSColor clearColor];
|
||||
// Using auto-resizing mask instead of contraints works well enough
|
||||
darkBackgroundView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
[self.releaseNotesView.superview addSubview:darkBackgroundView positioned:NSWindowBelow relativeTo:self.releaseNotesView];
|
||||
self.releaseNotesView.drawsBackground = NO;
|
||||
|
||||
prefs.userStyleSheetLocation = [[NSBundle bundleForClass:[self class]] URLForResource:@"DarkAqua" withExtension:@"css"];
|
||||
if (!self.observingAppearance) {
|
||||
[self.window addObserver:self forKeyPath:@"effectiveAppearance" options:NSKeyValueObservingOptionInitial context:nil];
|
||||
self.observingAppearance = YES;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Stick a nice big spinner in the middle of the web view until the page is loaded.
|
||||
NSRect frame = [[self.releaseNotesView superview] frame];
|
||||
self.releaseNotesSpinner = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame) - 16, NSMidY(frame) - 16, 32, 32)];
|
||||
@@ -152,12 +195,12 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
[[self.releaseNotesView superview] addSubview:self.releaseNotesSpinner];
|
||||
|
||||
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
|
||||
if ([self.updateItem releaseNotesURL])
|
||||
{
|
||||
if ([self.updateItem releaseNotesURL])
|
||||
{
|
||||
[[self.releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self.releaseNotesView mainFrame] loadHTMLString:[self.updateItem itemDescription] baseURL:nil];
|
||||
}
|
||||
}
|
||||
@@ -165,14 +208,14 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
- (BOOL)showsReleaseNotes
|
||||
{
|
||||
NSNumber *shouldShowReleaseNotes = [self.host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
|
||||
if (shouldShowReleaseNotes == nil)
|
||||
{
|
||||
if (shouldShowReleaseNotes == nil)
|
||||
{
|
||||
// Don't show release notes if RSS item contains no description and no release notes URL:
|
||||
return (([self.updateItem itemDescription] != nil
|
||||
&& [[[self.updateItem itemDescription] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|
||||
|| [self.updateItem releaseNotesURL] != nil);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
return [shouldShowReleaseNotes boolValue];
|
||||
}
|
||||
|
||||
@@ -219,15 +262,32 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
if ([self.updateItem isCriticalUpdate]) {
|
||||
self.skipButton.enabled = NO;
|
||||
self.skipButton.hidden = YES;
|
||||
self.laterButton.enabled = NO;
|
||||
self.laterButton.hidden = YES;
|
||||
}
|
||||
|
||||
if (![self automaticChecksEnabled]) {
|
||||
self.laterButton.enabled = NO;
|
||||
self.laterButton.hidden = YES;
|
||||
}
|
||||
[self.window center];
|
||||
}
|
||||
|
||||
- (BOOL)automaticChecksEnabled {
|
||||
NSNumber *automaticChecksEnabled = [self.host objectForKey:SUEnableAutomaticChecksKey];
|
||||
if (automaticChecksEnabled == nil)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return [automaticChecksEnabled boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose:(NSNotification *) __unused note
|
||||
{
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
return YES;
|
||||
[self endWithSelection:SURemindMeLaterChoice];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSImage *)applicationIcon
|
||||
@@ -263,6 +323,21 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
return finalString;
|
||||
}
|
||||
|
||||
- (void)adaptReleaseNotesAppearance
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
|
||||
if (SUAVAILABLE(10, 14))
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
NSAppearanceName bestAppearance = [self.window.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
||||
BOOL isDarkAqua = ([bestAppearance isEqualToString:NSAppearanceNameDarkAqua]);
|
||||
self.releaseNotesView.preferences.userStyleSheetEnabled = isDarkAqua;
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
|
||||
{
|
||||
if ([frame parentFrame] == nil) {
|
||||
@@ -276,7 +351,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
{
|
||||
NSURL *requestURL = request.URL;
|
||||
NSString *scheme = requestURL.scheme;
|
||||
BOOL whitelistedSafe = [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [requestURL.absoluteString isEqualToString:@"about:blank"];
|
||||
BOOL isAboutBlank = [requestURL.absoluteString isEqualToString:@"about:blank"];
|
||||
BOOL whitelistedSafe = isAboutBlank || [@[@"http", @"https", @"macappstore", @"macappstores", @"itms-apps", @"itms-appss"] containsObject:scheme];
|
||||
|
||||
// Do not allow redirects to dangerous protocols such as file://
|
||||
if (!whitelistedSafe) {
|
||||
@@ -286,7 +362,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
}
|
||||
|
||||
if (self.webViewFinishedLoading) {
|
||||
if (requestURL) {
|
||||
if (requestURL && !isAboutBlank) {
|
||||
[[NSWorkspace sharedWorkspace] openURL:requestURL];
|
||||
}
|
||||
|
||||
@@ -298,18 +374,18 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
}
|
||||
|
||||
// Clean up the contextual menu.
|
||||
- (NSArray *)webView:(WebView *)__unused sender contextMenuItemsForElement:(NSDictionary *)__unused element defaultMenuItems:(NSArray *)defaultMenuItems
|
||||
- (NSArray<NSMenuItem *> *)webView:(WebView *)__unused sender contextMenuItemsForElement:(NSDictionary *)__unused element defaultMenuItems:(NSArray<NSMenuItem *> *)defaultMenuItems
|
||||
{
|
||||
NSMutableArray *webViewMenuItems = [defaultMenuItems mutableCopy];
|
||||
NSMutableArray<NSMenuItem *> *webViewMenuItems = [defaultMenuItems mutableCopy];
|
||||
|
||||
if (webViewMenuItems)
|
||||
{
|
||||
for (NSMenuItem *menuItem in defaultMenuItems)
|
||||
{
|
||||
if (webViewMenuItems)
|
||||
{
|
||||
for (NSMenuItem *menuItem in defaultMenuItems)
|
||||
{
|
||||
NSInteger tag = [menuItem tag];
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
switch (tag)
|
||||
{
|
||||
case WebMenuItemTagOpenLinkInNewWindow:
|
||||
case WebMenuItemTagDownloadLinkToDisk:
|
||||
case WebMenuItemTagOpenImageInNewWindow:
|
||||
|
||||
@@ -58,8 +58,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
|
||||
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile reply:(void (^)(SUUpdatePermissionResponse *))reply
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdatePermissionPrompt"];
|
||||
if (self)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
_reply = reply;
|
||||
host = aHost;
|
||||
self.isShowingMoreInfo = NO;
|
||||
@@ -75,7 +75,7 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
|
||||
// If this is a background application we need to focus it in order to bring the prompt
|
||||
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
|
||||
// the user would not know why the application was paused.
|
||||
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
|
||||
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
|
||||
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
if (![self shouldAskAboutProfile])
|
||||
{
|
||||
if (![self shouldAskAboutProfile])
|
||||
{
|
||||
NSRect frame = [[self window] frame];
|
||||
frame.size.height -= [self.moreInfoButton frame].size.height;
|
||||
[[self window] setFrame:frame display:YES];
|
||||
@@ -128,8 +128,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
|
||||
NSRect profileMoreInfoButtonFrame = [self.moreInfoButton frame];
|
||||
NSRect descriptionFrame = [self.descriptionTextField frame];
|
||||
|
||||
if (self.isShowingMoreInfo)
|
||||
{
|
||||
if (self.isShowingMoreInfo)
|
||||
{
|
||||
// Add the subview
|
||||
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
|
||||
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUHost;
|
||||
@class SUSignatures;
|
||||
|
||||
@interface SUUpdateValidator : NSObject
|
||||
|
||||
// Pass YES to performingPrevalidation if archive validation must be done immediately, before extraction
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation;
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host;
|
||||
|
||||
// Indicates whether we can perform (post) validation later
|
||||
@property (nonatomic, readonly) BOOL canValidate;
|
||||
// This is "pre" validation, before the archive has been extracted
|
||||
- (BOOL)validateDownloadPath;
|
||||
|
||||
// precondition: validation must be possible (see -canValidate)
|
||||
// This is "post" validation, after an archive has been extracted
|
||||
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory;
|
||||
|
||||
|
||||
@@ -7,20 +7,21 @@
|
||||
//
|
||||
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#import "SUSignatures.h"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUUpdateValidator ()
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly) BOOL prevalidatedDsaSignature;
|
||||
@property (nonatomic, readonly) NSString *dsaSignature;
|
||||
@property (nonatomic) BOOL prevalidatedSignature;
|
||||
@property (nonatomic) BOOL downloadPrevalidationFailed;
|
||||
@property (strong, nonatomic, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, readonly) NSString *downloadPath;
|
||||
|
||||
@end
|
||||
@@ -28,59 +29,50 @@
|
||||
@implementation SUUpdateValidator
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize canValidate = _canValidate;
|
||||
@synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize prevalidatedSignature = _prevalidatedSignature;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize downloadPrevalidationFailed = _downloadPrevalidationFailed;
|
||||
@synthesize downloadPath = _downloadPath;
|
||||
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
BOOL canValidate;
|
||||
BOOL prevalidatedDsaSignature;
|
||||
if (performingPrevalidation) {
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
if (publicDSAKey == nil) {
|
||||
prevalidatedDsaSignature = NO;
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA key was found");
|
||||
} else if (dsaSignature == nil) {
|
||||
prevalidatedDsaSignature = NO;
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA signature was found");
|
||||
} else {
|
||||
prevalidatedDsaSignature = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:dsaSignature withPublicDSAKey:publicDSAKey];
|
||||
if (!prevalidatedDsaSignature) {
|
||||
SULog(SULogLevelError, @"DSA signature validation before unarchiving failed for update %@", downloadPath);
|
||||
}
|
||||
}
|
||||
|
||||
canValidate = prevalidatedDsaSignature;
|
||||
} else {
|
||||
prevalidatedDsaSignature = NO;
|
||||
canValidate = YES;
|
||||
}
|
||||
|
||||
_canValidate = canValidate;
|
||||
_prevalidatedDsaSignature = prevalidatedDsaSignature;
|
||||
_downloadPath = [downloadPath copy];
|
||||
_dsaSignature = [dsaSignature copy];
|
||||
_signatures = signatures;
|
||||
_host = host;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)validateDownloadPath {
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
SUSignatures *signatures = self.signatures;
|
||||
|
||||
if (publicKeys.dsaPubKey == nil && publicKeys.ed25519PubKey == nil) {
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no (Ed)DSA public key was found in the old app");
|
||||
} else {
|
||||
if ([SUSignatureVerifier validatePath:self.downloadPath withSignatures:signatures withPublicKeys:publicKeys]) {
|
||||
self.prevalidatedSignature = YES;
|
||||
return YES;
|
||||
}
|
||||
SULog(SULogLevelError, @"(Ed)DSA signature validation before unarchiving failed for update %@", self.downloadPath);
|
||||
}
|
||||
self.downloadPrevalidationFailed = YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory
|
||||
{
|
||||
assert(self.canValidate);
|
||||
if (self.downloadPrevalidationFailed) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *DSASignature = self.dsaSignature;
|
||||
NSString *publicDSAKey = self.host.publicDSAKey;
|
||||
SUSignatures *signatures = self.signatures;
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
NSString *downloadPath = self.downloadPath;
|
||||
SUHost *host = self.host;
|
||||
|
||||
BOOL prevalidatedDsaSignature = self.prevalidatedDsaSignature;
|
||||
|
||||
BOOL isPackage = NO;
|
||||
|
||||
// install source could point to a new bundle or a package
|
||||
@@ -92,18 +84,18 @@
|
||||
|
||||
NSURL *installSourceURL = [NSURL fileURLWithPath:installSource];
|
||||
|
||||
if (!prevalidatedDsaSignature) {
|
||||
if (!self.prevalidatedSignature) {
|
||||
// Check to see if we have a package or bundle to validate
|
||||
if (isPackage) {
|
||||
// For package type updates, all we do is check if the DSA signature is valid
|
||||
BOOL validationCheckSuccess = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
BOOL validationCheckSuccess = [SUSignatureVerifier validatePath:downloadPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
if (!validationCheckSuccess) {
|
||||
SULog(SULogLevelError, @"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
|
||||
}
|
||||
return validationCheckSuccess;
|
||||
} else {
|
||||
// For application bundle updates, we check both the DSA and Apple code signing signatures
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL DSASignature:DSASignature];
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL signatures:signatures];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
// We shouldn't get here because we don't validate packages before extracting them currently
|
||||
@@ -131,7 +123,7 @@
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL DSASignature:(NSString *)DSASignature
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL signatures:(SUSignatures *)signatures
|
||||
{
|
||||
NSBundle *newBundle = [NSBundle bundleWithURL:newBundleURL];
|
||||
if (newBundle == nil) {
|
||||
@@ -139,55 +131,83 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
SUPublicKeys *publicKeys = host.publicKeys;
|
||||
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
SUPublicKeys *newPublicKeys = newHost.publicKeys;
|
||||
BOOL oldHasLegacyDSAKey = publicKeys.dsaPubKey != nil;
|
||||
BOOL oldHasEdDSAKey = publicKeys.ed25519PubKey != nil;
|
||||
BOOL oldHasAnyDSAKey = oldHasLegacyDSAKey || oldHasEdDSAKey;
|
||||
BOOL newHasLegacyDSAKey = newPublicKeys.dsaPubKey != nil;
|
||||
BOOL newHasEdDSAKey = newPublicKeys.ed25519PubKey != nil;
|
||||
BOOL newHasAnyDSAKey = newHasLegacyDSAKey || newHasEdDSAKey;
|
||||
BOOL migratesDSAKeys = oldHasLegacyDSAKey && !oldHasEdDSAKey && newHasEdDSAKey && !newHasLegacyDSAKey;
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
// Downgrade in DSA security should not be possible
|
||||
if (publicDSAKey != nil && newPublicDSAKey == nil) {
|
||||
SULog(SULogLevelError, @"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
|
||||
// This is not essential for security, only a policy
|
||||
if (oldHasAnyDSAKey && !newHasAnyDSAKey) {
|
||||
SULog(SULogLevelError, @"A public (Ed)DSA key was found in the old bundle but no public (Ed)DSA key was found in the new update. Sparkle only supports rotation, but not removal of (Ed)DSA keys. Please add an EdDSA key to the new app.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
// Security-critical part starts here
|
||||
BOOL passedDSACheck = NO;
|
||||
BOOL passedCodeSigning = NO;
|
||||
|
||||
if (oldHasAnyDSAKey) {
|
||||
// it's critical to check against the old public key, rather than the new key
|
||||
passedDSACheck = [SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
}
|
||||
|
||||
if (hostIsCodeSigned) {
|
||||
NSError *error = nil;
|
||||
passedCodeSigning = [SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error];
|
||||
}
|
||||
// End of security-critical part
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
// However if the new and old DSA keys are the same, then this is a security measure.
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
||||
SULog(SULogLevelError, @"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
||||
if (!passedDSACheck && newHasAnyDSAKey) {
|
||||
if (![SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:newPublicKeys]) {
|
||||
SULog(SULogLevelError, @"The update has a public (Ed)DSA key, but the public key shipped with the update doesn't match the signature. To prevent future problems, the update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
|
||||
|
||||
if (dsaKeysMatch) {
|
||||
NSError *error = nil;
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
NSError *error = nil;
|
||||
if (passedDSACheck && updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive has a valid (Ed)DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Either DSA must be valid, or Apple Code Signing must be valid.
|
||||
// We allow failure of one of them, because this allows key rotation without breaking chain of trust.
|
||||
if (passedDSACheck || passedCodeSigning) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Now this just explains the failure
|
||||
|
||||
NSString *dsaStatus;
|
||||
if (migratesDSAKeys) {
|
||||
dsaStatus = @"migrates to new EdDSA keys without keeping the old DSA key for transition";
|
||||
} else if (newHasAnyDSAKey) {
|
||||
dsaStatus = @"has a new (Ed)DSA key that doesn't match the previous one";
|
||||
} else if (oldHasAnyDSAKey) {
|
||||
dsaStatus = @"removes the (Ed)DSA key";
|
||||
} else {
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(SULogLevelError, @"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(SULogLevelError, @"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
return NO;
|
||||
}
|
||||
dsaStatus = @"isn't signed with an EdDSA key";
|
||||
}
|
||||
|
||||
return YES;
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(SULogLevelError, @"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
} else {
|
||||
SULog(SULogLevelError, @"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -189,6 +189,8 @@ SU_EXPORT @interface SUUpdater : NSObject
|
||||
For UI-less/daemon apps that aren't usually quit, instead of this function,
|
||||
you can use the delegate method
|
||||
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation:
|
||||
or
|
||||
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationBlock:
|
||||
to immediately start installation when an update was found.
|
||||
|
||||
A progress dialog is shown but the user will never be prompted to read the
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
#import "SUSystemProfiler.h"
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUGlobalUpdateLock.h"
|
||||
|
||||
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
|
||||
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
|
||||
@@ -35,6 +38,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
@interface SUUpdater () <SUUpdaterPrivate>
|
||||
@property (strong) NSTimer *checkTimer;
|
||||
@property (assign) BOOL shouldRescheduleOnWake;
|
||||
@property (strong) NSBundle *sparkleBundle;
|
||||
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
@@ -57,6 +61,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
@synthesize delegate;
|
||||
@synthesize checkTimer;
|
||||
@synthesize shouldRescheduleOnWake;
|
||||
@synthesize userAgentString = customUserAgentString;
|
||||
@synthesize httpHeaders;
|
||||
@synthesize driver;
|
||||
@@ -68,7 +73,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
static NSMutableDictionary *sharedUpdaters = nil;
|
||||
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
|
||||
#ifdef DEBUG
|
||||
// Debug is not defined in released builds and pedantic mode can enable -Wundef
|
||||
#if defined(DEBUG) && DEBUG
|
||||
+ (void)load
|
||||
{
|
||||
// Debug builds have different configurations for update check intervals
|
||||
@@ -110,14 +116,17 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
if (self) {
|
||||
[self registerAsObserver];
|
||||
}
|
||||
|
||||
[NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(receiveSleepNote) name:NSWorkspaceWillSleepNotification object:NULL];
|
||||
[NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(receiveWakeNote) name:NSWorkspaceDidWakeNotification object:NULL];
|
||||
|
||||
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater)
|
||||
{
|
||||
{
|
||||
self = updater;
|
||||
}
|
||||
else if (self)
|
||||
{
|
||||
}
|
||||
else if (self)
|
||||
{
|
||||
if (sharedUpdaters == nil) {
|
||||
sharedUpdaters = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
@@ -138,30 +147,24 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
}
|
||||
|
||||
-(void)checkIfConfiguredProperly {
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
BOOL hasPublicKey = self.host.publicKeys.dsaPubKey != nil || self.host.publicKeys.ed25519PubKey != nil;
|
||||
BOOL isMainBundle = [self.host.bundle isEqualTo:[NSBundle mainBundle]];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.host.bundle.bundleURL];
|
||||
NSURL *feedURL = [self feedURL];
|
||||
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
|
||||
NSString *name = self.host.name;
|
||||
|
||||
if (!hasPublicDSAKey) {
|
||||
// If we failed to retrieve a DSA key but the bundle specifies a path to one, we should consider this a configuration failure
|
||||
NSString *publicDSAKeyFileKey = [self.host publicDSAKeyFileKey];
|
||||
if (publicDSAKeyFileKey != nil) {
|
||||
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
|
||||
informativeText:[NSString stringWithFormat:SULocalizedString(@"For security reasons, the file (%@) indicated by the '%@' key needs to exist in the bundle's Resources.", nil), publicDSAKeyFileKey, SUPublicDSAKeyFileKey]];
|
||||
if (!hasPublicKey) {
|
||||
if (!isMainBundle) {
|
||||
[self showAlertText:SULocalizedString(@"Auto-update not configured", nil)
|
||||
informativeText:[NSString stringWithFormat:SULocalizedString(@"For security reasons, updates to %@ need to be signed with an EdDSA key. See Sparkle's documentation for more information.", nil), name]];
|
||||
} else {
|
||||
if (!isMainBundle) {
|
||||
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
|
||||
informativeText:SULocalizedString(@"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", nil)];
|
||||
} else {
|
||||
if (!hostIsCodeSigned) {
|
||||
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
|
||||
informativeText:SULocalizedString(@"For security reasons, you need to code sign your application or sign your updates with a DSA key. See https://sparkle-project.org/documentation/ for more information.", nil)];
|
||||
} else if (!servingOverHttps) {
|
||||
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
|
||||
informativeText:SULocalizedString(@"For security reasons, you need to serve your updates over HTTPS and/or sign your updates with a DSA key. See https://sparkle-project.org/documentation/ for more information.", nil)];
|
||||
}
|
||||
if (!hostIsCodeSigned) {
|
||||
[self showAlertText:SULocalizedString(@"Auto-update not configured", nil)
|
||||
informativeText:[NSString stringWithFormat:SULocalizedString(@"For security reasons, %@ needs to be code-signed or its updates need to be signed with an EdDSA key. See https://sparkle-project.org/documentation/ for more information.", nil), name]];
|
||||
} else if (!servingOverHttps) {
|
||||
[self showAlertText:SULocalizedString(@"Auto-update not configured", nil)
|
||||
informativeText:[NSString stringWithFormat:SULocalizedString(@"For security reasons, updates to %@ need to be served over HTTPS and/or signed with an EdDSA key. See https://sparkle-project.org/documentation/ for more information.", nil), name]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,6 +223,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
[self.host setBool:NO forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];
|
||||
}
|
||||
|
||||
[[SUGlobalUpdateLock sharedLock] unlock]; // For safety, remove active lock if present in any case and not just when relaunching from an app update
|
||||
|
||||
if (shouldPrompt) {
|
||||
NSArray<NSDictionary<NSString *, NSString *> *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
|
||||
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
|
||||
@@ -246,8 +251,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)updateDriverDidFinish:(NSNotification *)note
|
||||
{
|
||||
if ([note object] == self.driver && [self.driver finished])
|
||||
{
|
||||
if ([note object] == self.driver && [self.driver finished])
|
||||
{
|
||||
self.driver = nil;
|
||||
[self updateLastUpdateCheckDate];
|
||||
[self scheduleNextUpdateCheck];
|
||||
@@ -274,16 +279,16 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)scheduleNextUpdateCheck
|
||||
{
|
||||
if (self.checkTimer)
|
||||
{
|
||||
if (self.checkTimer)
|
||||
{
|
||||
[self.checkTimer invalidate];
|
||||
self.checkTimer = nil; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
if (![self automaticallyChecksForUpdates]) return;
|
||||
if (![self automaticallyChecksForUpdates]) return;
|
||||
|
||||
// How long has it been since last we checked for an update?
|
||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
@@ -297,13 +302,34 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
- (void)receiveSleepNote
|
||||
{
|
||||
if (self.checkTimer)
|
||||
{
|
||||
[self.checkTimer invalidate];
|
||||
self.checkTimer = nil;
|
||||
self.shouldRescheduleOnWake = YES;
|
||||
}
|
||||
else
|
||||
self.shouldRescheduleOnWake = NO;
|
||||
}
|
||||
|
||||
- (void)receiveWakeNote
|
||||
{
|
||||
if (self.shouldRescheduleOnWake) // the reason for rescheduling the update-check timer is that NSTimer does behave as if the time the Mac spends asleep did not exist at all, which can significantly prolong the time between update checks
|
||||
[self scheduleNextUpdateCheck];
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
{
|
||||
BOOL automatic = [self automaticallyDownloadsUpdates];
|
||||
|
||||
if (!automatic) {
|
||||
if (@available(macOS 10.9, *)) {
|
||||
if (SUAVAILABLE(10, 9)) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.apple.notificationcenterui"];
|
||||
#pragma clang diagnostic pop
|
||||
BOOL dnd = [defaults boolForKey:@"doNotDisturb"];
|
||||
if (dnd) {
|
||||
SULog(SULogLevelDefault, @"Delayed update, because Do Not Disturb is on");
|
||||
@@ -353,13 +379,13 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
|
||||
{
|
||||
if ([self updateInProgress]) { return; }
|
||||
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
if ([self updateInProgress]) { return; }
|
||||
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
|
||||
[self updateLastUpdateCheckDate];
|
||||
|
||||
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] )
|
||||
{
|
||||
{
|
||||
[self scheduleNextUpdateCheck];
|
||||
return;
|
||||
}
|
||||
@@ -391,8 +417,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)unregisterAsObserver
|
||||
{
|
||||
@try
|
||||
{
|
||||
@try
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
|
||||
@@ -405,7 +431,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext))
|
||||
if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext))
|
||||
{
|
||||
// Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking.
|
||||
// Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them.
|
||||
@@ -459,7 +485,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
}
|
||||
|
||||
// Otherwise, automatically downloading updates is allowed. Does the user want it?
|
||||
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
|
||||
return [self.host boolForKey:SUAutomaticallyUpdateKey];
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
@@ -541,12 +567,12 @@ static NSString *escapeURLComponent(NSString *str) {
|
||||
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
|
||||
}
|
||||
if (sendingSystemProfile)
|
||||
{
|
||||
if (sendingSystemProfile)
|
||||
{
|
||||
parameters = [parameters arrayByAddingObjectsFromArray:[SUSystemProfiler systemProfileArrayForHost:self.host]];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
|
||||
}
|
||||
if ([parameters count] == 0) { return baseFeedURL; }
|
||||
if ([parameters count] == 0) { return baseFeedURL; }
|
||||
|
||||
// Build up the parameterized URL.
|
||||
NSMutableArray *parameterStrings = [NSMutableArray array];
|
||||
@@ -589,7 +615,7 @@ static NSString *escapeURLComponent(NSString *str) {
|
||||
- (void)dealloc
|
||||
{
|
||||
[self unregisterAsObserver];
|
||||
if (checkTimer) { [checkTimer invalidate]; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
if (checkTimer) { [checkTimer invalidate]; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
|
||||
@@ -36,7 +36,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Delegate:
|
||||
// SUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
@@ -117,6 +117,23 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called just before the scheduled update driver prompts the user to install an update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
|
||||
\return YES to allow the update prompt to be shown (the default behavior), or NO to suppress it.
|
||||
*/
|
||||
- (BOOL)updaterShouldShowUpdateAlertForScheduledUpdate:(SUUpdater *)updater forItem:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called after the user dismisses the update alert.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param permanently YES if the alert will not appear again for this update; NO if it may reappear.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didDismissUpdateAlertPermanently:(BOOL)permanently forItem:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
|
||||
@@ -124,6 +141,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the Skip This Version button.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater userDidSkipThisVersion:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
@@ -195,6 +219,21 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
This method acts as a simpler alternative to SUUpdaterDelegate::updater:shouldPostponeRelaunchForUpdate:untilInvoking: avoiding usage of NSInvocation, which is not available in Swift environments.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
|
||||
\return \c YES to delay the relaunch.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
@@ -280,6 +319,18 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit.
|
||||
This is after an update has been automatically downloaded in the background.
|
||||
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
|
||||
This method acts as a more modern alternative to SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation: using a block instead of NSInvocation, which is not available in Swift environments.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param installationBlock Can be used to trigger an immediate silent install and relaunch.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))installationBlock;
|
||||
|
||||
/*!
|
||||
Calls after an update that was scheduled to be silently installed on quit has been canceled.
|
||||
|
||||
|
||||