Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
e1d4b19ce7 | ||
|
|
360c2ce7a9 | ||
|
|
f9740292d4 | ||
|
|
558be04121 | ||
|
|
b426426905 | ||
|
|
75835a5874 | ||
|
|
50c12d1c2b | ||
|
|
e452b7f6ba | ||
|
|
3034eca85b | ||
|
|
9ae41fe4ab | ||
|
|
7d931e22d7 | ||
|
|
b303ee312b | ||
|
|
9453761aef | ||
|
|
d19c98a877 | ||
|
|
7a4caad5fe | ||
|
|
8f546c93f4 | ||
|
|
1c4bcda012 | ||
|
|
a18282ec79 | ||
|
|
8a8ce49a23 | ||
|
|
2561af8270 | ||
|
|
035ad6a277 | ||
|
|
9cbae0edb6 | ||
|
|
3bbf84e332 | ||
|
|
a582d46096 | ||
|
|
3f3ace055d | ||
|
|
886e4b2c81 | ||
|
|
a418d8fe64 | ||
|
|
b48e80aa27 | ||
|
|
a19dfb2be0 | ||
|
|
7394593743 | ||
|
|
4973c0143f | ||
|
|
c171f381d4 | ||
|
|
dde4a0aae2 | ||
|
|
d5a1ba44ff | ||
|
|
0d03b4006d | ||
|
|
25993d0776 | ||
|
|
276707b3da | ||
|
|
23e88737ec | ||
|
|
d400a53ebd | ||
|
|
f39b07fd59 | ||
|
|
5bc8f3e535 | ||
|
|
503a292084 | ||
|
|
d60b16f633 | ||
|
|
de3e73b589 | ||
|
|
ad863775db | ||
|
|
79511c982a | ||
|
|
189ed9d315 | ||
|
|
ea94969188 | ||
|
|
57731f44d7 | ||
|
|
2a0514c93b | ||
|
|
467e1495c0 | ||
|
|
8ac254951a | ||
|
|
c83c9221f7 | ||
|
|
b46315df9c | ||
|
|
9c505dee2f | ||
|
|
2ed7402367 | ||
|
|
3afa47b092 | ||
|
|
874d6bce36 | ||
|
|
51a335b3fd | ||
|
|
578bb9ecb8 | ||
|
|
76e8838eb3 | ||
|
|
0a101b7902 | ||
|
|
865dd2e187 | ||
|
|
083bd9b453 | ||
|
|
b48bc4dcac | ||
|
|
bb6203f40a | ||
|
|
25204a66e0 | ||
|
|
c886947f55 | ||
|
|
f0460033ba | ||
|
|
1a71456ed9 | ||
|
|
e7cdbfc45e | ||
|
|
8b5c8b5cdf | ||
|
|
a7af48f0d1 | ||
|
|
03e28780d9 | ||
|
|
5b1c76db26 | ||
|
|
703e611eb5 | ||
|
|
6ee88124ad | ||
|
|
1cc5f230a5 | ||
|
|
429f950434 | ||
|
|
7df50ccfd3 | ||
|
|
9c301bfbf3 | ||
|
|
8a0474d644 | ||
|
|
dc85d63861 | ||
|
|
dc8e8b775a | ||
|
|
ecb608bb40 | ||
|
|
c3e546d7f8 | ||
|
|
2477a92b0f | ||
|
|
7f0bc6a244 | ||
|
|
68f62e5955 | ||
|
|
0cb0b2f2c7 | ||
|
|
b590722aad | ||
|
|
10f831fce8 | ||
|
|
a2ecdd2744 | ||
|
|
ec7f55d173 | ||
|
|
ddfc4089d2 | ||
|
|
80c34526e8 | ||
|
|
0c3994c571 | ||
|
|
fbda90ad64 | ||
|
|
40750b6f24 | ||
|
|
a7ba0bea6e | ||
|
|
558cfd2153 | ||
|
|
94074e2bdc | ||
|
|
56065fcf95 | ||
|
|
f24189e848 | ||
|
|
65b12a2be1 | ||
|
|
900de556a8 | ||
|
|
7c8ff2b969 | ||
|
|
43b4472d3c | ||
|
|
260170f372 | ||
|
|
ea85fc6442 | ||
|
|
a52604a264 | ||
|
|
39d6c616b0 | ||
|
|
043ad0464a | ||
|
|
d99339cf08 | ||
|
|
c541f95036 | ||
|
|
e678ffb3ca | ||
|
|
070ea362a2 | ||
|
|
c4db636d0b | ||
|
|
7e9f05865a | ||
|
|
3c14c950ef | ||
|
|
4438b69b50 | ||
|
|
6d0c734c26 | ||
|
|
e8805e0563 | ||
|
|
193036b2c4 | ||
|
|
33bf6732ea | ||
|
|
e94fb63ff0 | ||
|
|
84e5925578 | ||
|
|
bb83e9a0da | ||
|
|
26d4d75c36 | ||
|
|
fe5737f0b6 | ||
|
|
ac49a3b5b6 | ||
|
|
cbeaeb29ec | ||
|
|
d0a6c699da | ||
|
|
84b7e5e22f | ||
|
|
61774b3f7d | ||
|
|
55be13ca6f | ||
|
|
fc48e5e4df | ||
|
|
bfada07a2c | ||
|
|
4f965660f3 | ||
|
|
a2764158d6 | ||
|
|
60727bffa5 | ||
|
|
715163fe0d | ||
|
|
629c42d62d | ||
|
|
3e45211bbe | ||
|
|
89acca1318 | ||
|
|
4bc2e6e891 | ||
|
|
405c9fd9a1 | ||
|
|
9232316b19 | ||
|
|
423ee5a9d6 | ||
|
|
ac042821d8 | ||
|
|
662e84400a | ||
|
|
1683d2de34 | ||
|
|
615a08bc32 |
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
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.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
|
language: objective-c
|
||||||
osx_image: xcode8.2
|
osx_image:
|
||||||
before_install:
|
- xcode11.4
|
||||||
- brew update
|
- xcode12
|
||||||
script: make ci
|
script:
|
||||||
|
- set -o pipefail && xcodebuild test -project Sparkle.xcodeproj -scheme Distribution -derivedDataPath build -enableCodeCoverage YES | xcpretty
|
||||||
@@ -1,3 +1,134 @@
|
|||||||
|
# 1.24.0-alpha
|
||||||
|
|
||||||
|
* Fixed error about "about:blank" release notes (Louis Pontoise)
|
||||||
|
* 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)
|
||||||
|
* Update SUUpdateAlert.xib (DanielFirlej)
|
||||||
|
* Added help command line option (Dominik H)
|
||||||
|
* Added function that parses all command line options (Dominik H)
|
||||||
|
* Command line option to provide a download url prefix is now parsed and set on each archive item (Dominik H)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
* Add delegate callbacks for fininshed download and extraction related events (Csaba Horony)
|
||||||
|
* Don't check for updates if Do Not Disturb is on (Kornel)
|
||||||
|
* Expose `CodesigningVerifier`, add codesign info API (sunuslee)
|
||||||
|
* Threading fixes:
|
||||||
|
* Fix potential hang with `dispatch_sync` to main thread (Brian Bergstrand)
|
||||||
|
* Fix closeCheckingWindow called from background thread (Alexey Martemyanov)
|
||||||
|
* Improve 'read-only' error message (#1192) (Adrian Thomas)
|
||||||
|
* New Spanish localisation (Ken Arroyo Ohori)
|
||||||
|
* Updated Finnish language resources (Jason Pollack)
|
||||||
|
* Hungarian localization (Csaba Horony)
|
||||||
|
* Log more information about authentication requests (Kornel)
|
||||||
|
* Explicitly specify types to silence "Messaging unqualified id" warning that's new in Xcode 10. Removed __has_feature(objc_generics) check and use generisc to help silence the warnings. (Kent Sutherland)
|
||||||
|
* Fix binary delta creation on network drives (sagecook)
|
||||||
|
* Fix compilation issues on Xcode 10 with new build system (Leo Natan)
|
||||||
|
|
||||||
|
# 1.19.0
|
||||||
|
|
||||||
|
* Refactoring of downloader code to avoid deprecated methods (Deadpikle)
|
||||||
|
* Changes to which methods run on the main thread.
|
||||||
|
Note: some delegate methods may be called on non-main thread now. (Kornel)
|
||||||
|
* Update Japanese localization (1024jp)
|
||||||
|
* Update Sparkle.strings (Stefan Paychère)
|
||||||
|
* Fix Sparkle clients polling too frequently (Jonathan Bullard)
|
||||||
|
* Handle SecTransformExecute errors (Kornel)
|
||||||
|
* Silence Touch Bar availability warnings on Xcode 9 by using API_AVAILABLE. Disable gnu-zero-variadic-macro-arguments to prevent warnings from use of API_AVAILABLE. (Kent Sutherland)
|
||||||
|
* 10.11 SDK compatibility (David Fuhrmann)
|
||||||
|
|
||||||
|
# 1.18.1
|
||||||
|
|
||||||
|
* Add optional updaterDidRelaunchApplication: method on SUUpdaterDelegate (#1115) (App Tyrant)
|
||||||
|
* Implemented sparkle:os attribute as documented (Memphiz)
|
||||||
|
* Additional termination detection in case kpoll fails. (fujisoft)
|
||||||
|
* Included bin files in CocoaPods installation (Keith Smiley)
|
||||||
|
* Updated Dutch localization (Eitot)
|
||||||
|
* Updated German localization (Eitot)
|
||||||
|
* Updated Japanese translation (1024jp)
|
||||||
|
* Updated Portuguese translation (Victor)
|
||||||
|
* Updated to Xcode 9/Swift 4
|
||||||
|
|
||||||
|
# 1.18.0
|
||||||
|
|
||||||
|
* Name of the host app is used in authorization prompt (the `SPARKLE_RELAUNCH_TOOL_NAME` setting is now obsolete)
|
||||||
|
* More detailed progress bar for package installers (Kornel Lesiński)
|
||||||
|
* Disabled the keyboard shortcut for the install button for scheduled updates to avoid accidental installs. (George Nachman)
|
||||||
|
* generate_appcast tool adds release notes if there's an .html file with the same base name as the archive (Brett Walker)
|
||||||
|
* Added `sparkle:shortVersionString` to the enclosure, #1032 (Brett Walker)
|
||||||
|
* Fixed Japanese localization (1024jp)
|
||||||
|
* Fixed escaping of system profile URLs
|
||||||
|
* Added more logging in various failure cases (Kornel Lesiński)
|
||||||
|
* Better error message for quarantined apps that can't be updated
|
||||||
|
|
||||||
# 1.17.0
|
# 1.17.0
|
||||||
|
|
||||||
* Added Touch Bar support (Bi11)
|
* Added Touch Bar support (Bi11)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
|
|||||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||||
|
|
||||||
SPARKLE_VERSION_MAJOR = 1
|
SPARKLE_VERSION_MAJOR = 1
|
||||||
SPARKLE_VERSION_MINOR = 17
|
SPARKLE_VERSION_MINOR = 24
|
||||||
SPARKLE_VERSION_PATCH = 0
|
SPARKLE_VERSION_PATCH = 0
|
||||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
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)\"
|
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
|
CLANG_ENABLE_OBJC_ARC = YES
|
||||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
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_IMPLICIT_RETAIN_SELF = YES
|
||||||
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
||||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = 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_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
|
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
|
||||||
@@ -88,4 +90,4 @@ CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
|
|||||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||||
|
|
||||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
|
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments $(WARNING_CFLAGS_EXTRA)
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#include "ConfigCommonDebug.xcconfig"
|
|
||||||
|
|
||||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES
|
|
||||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
|
|
||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
// Debug only
|
// Debug only
|
||||||
|
|
||||||
|
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_OPTIMIZATION_LEVEL = 0
|
GCC_OPTIMIZATION_LEVEL = 0
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf
|
DEBUG_INFORMATION_FORMAT = dwarf
|
||||||
ENABLE_TESTABILITY = YES
|
ENABLE_TESTABILITY = YES
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
// Release only
|
// Release only
|
||||||
|
|
||||||
|
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_OPTIMIZATION_LEVEL = s
|
GCC_OPTIMIZATION_LEVEL = s
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
GCC_GENERATE_DEBUGGING_SYMBOLS = 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 +1,2 @@
|
|||||||
SWIFT_VERSION = 3.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
|
||||||
@@ -2,35 +2,70 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ "$ACTION" = "" ] ; then
|
if [ "$ACTION" = "" ] ; then
|
||||||
# Sanity check that the Podspec version matches the Sparkle version
|
# If using cocoapods, sanity check that the Podspec version matches the Sparkle version
|
||||||
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
|
if [ -x "$(command -v pod)" ]; then
|
||||||
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
|
||||||
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
||||||
exit 1
|
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
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-SPM-$CURRENT_PROJECT_VERSION.zip"
|
||||||
|
|
||||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
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"
|
||||||
|
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
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_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"
|
||||||
|
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.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
|
# 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
|
# because missing dSYMs in a release build SHOULD trigger a build failure
|
||||||
if [ "$CONFIGURATION" = "Release" ] ; then
|
if [ "$CONFIGURATION" = "Release" ] ; then
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
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_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"
|
||||||
|
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"
|
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
fi
|
fi
|
||||||
|
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||||
|
|
||||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
# Sorted file list groups similar files together, which improves tar compression
|
# 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"
|
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-SPM-$CURRENT_PROJECT_VERSION.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-SPM-$CURRENT_PROJECT_VERSION.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
|
fi
|
||||||
@@ -9,7 +9,7 @@ if [ -z "$SRCROOT" ] || \
|
|||||||
[ -z "$BUILT_PRODUCTS_DIR" ] || \
|
[ -z "$BUILT_PRODUCTS_DIR" ] || \
|
||||||
[ -z "$INFOPLIST_PATH" ] || \
|
[ -z "$INFOPLIST_PATH" ] || \
|
||||||
[ -z "$CURRENT_PROJECT_VERSION" ]; then
|
[ -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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ if [ "$ACTION" = "" ] ; then
|
|||||||
doxygen Documentation/Doxyfile
|
doxygen Documentation/Doxyfile
|
||||||
else
|
else
|
||||||
echo "warning: Doxygen not found in PATH"
|
echo "warning: Doxygen not found in PATH"
|
||||||
|
echo "open Terminal and type this command 'brew install doxygen' then click 'enter/return' key. finally build this target again"
|
||||||
fi
|
fi
|
||||||
elif [ "$ACTION" = "clean" ] ; then
|
elif [ "$ACTION" = "clean" ] ; then
|
||||||
rm -rf "$SRCROOT/Documentation/html"
|
rm -rf "$SRCROOT/Documentation/html"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
.PHONY: all localizable-strings release build test ci
|
.PHONY: all localizable-strings release build test ci
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
ifndef BUILDDIR
|
ifndef BUILDDIR
|
||||||
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
||||||
endif
|
endif
|
||||||
@@ -12,9 +14,10 @@ localizable-strings:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
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
|
cat Sparkle.podspec
|
||||||
@echo "Don't forget to update CocoaPods! pod trunk push"
|
@echo "Don't forget to update CocoaPods! pod trunk push"
|
||||||
|
@echo "Don't forget to commit the updated Package manifest before releasing!"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
xcodebuild clean build
|
xcodebuild clean build
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// swift-tools-version:5.3
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let version = "1.24.0"
|
||||||
|
let checksum = "2b6fec0cad2bb643ed222b708f37bf9e98f5ed84d77c9ba69e66dd2b82b0fffa"
|
||||||
|
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(version)/Sparkle-SPM-\(version).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.
|
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">
|
<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
|
## Features
|
||||||
|
|
||||||
* Seamless. There's no mention of Sparkle; your icons and app name are used.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* 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.
|
* Ability to mark updates as critical.
|
||||||
* Progress and status notifications for the host app.
|
* Progress and status notifications for the host app.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* Runtime: macOS 10.7 or greater
|
* Runtime: macOS 10.7 or greater
|
||||||
* Build: Xcode 7 and 10.8 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/))
|
* 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
|
## Usage
|
||||||
|
|
||||||
@@ -39,6 +34,20 @@ See [getting started guide](https://sparkle-project.org/documentation/). No code
|
|||||||
|
|
||||||
## Development
|
## 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
|
### API symbols
|
||||||
|
|
||||||
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
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
|
http://you.com/app/2.0.html
|
||||||
</sparkle:releaseNotesLink>
|
</sparkle:releaseNotesLink>
|
||||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
<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" />
|
<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>
|
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||||
</item>
|
</item>
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
http://you.com/app/1.5.html
|
http://you.com/app/1.5.html
|
||||||
</sparkle:releaseNotesLink>
|
</sparkle:releaseNotesLink>
|
||||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
<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" />
|
<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>
|
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||||
</item>
|
</item>
|
||||||
@@ -31,6 +33,7 @@
|
|||||||
http://you.com/app/1.4.html
|
http://you.com/app/1.4.html
|
||||||
</sparkle:releaseNotesLink>
|
</sparkle:releaseNotesLink>
|
||||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
<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" />
|
<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>
|
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 100 KiB |
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Sparkle"
|
s.name = "Sparkle"
|
||||||
s.version = "1.17.0"
|
s.version = "1.24.0"
|
||||||
s.summary = "A software update framework for macOS"
|
s.summary = "A software update framework for macOS"
|
||||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||||
s.homepage = "http://sparkle-project.org"
|
s.homepage = "http://sparkle-project.org"
|
||||||
@@ -22,6 +22,7 @@ Pod::Spec.new do |s|
|
|||||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||||
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||||
|
|
||||||
|
s.preserve_paths = 'bin/*'
|
||||||
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||||
s.vendored_frameworks = 'Sparkle.framework'
|
s.vendored_frameworks = 'Sparkle.framework'
|
||||||
s.xcconfig = {
|
s.xcconfig = {
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0830"
|
LastUpgradeVersion = "0920"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "NO"
|
||||||
buildImplicitDependencies = "YES">
|
buildImplicitDependencies = "YES">
|
||||||
<BuildActionEntries>
|
<BuildActionEntries>
|
||||||
<BuildActionEntry
|
<BuildActionEntry
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = ""
|
selectedDebuggerIdentifier = ""
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
|
language = ""
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0830"
|
LastUpgradeVersion = "0920"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = ""
|
selectedDebuggerIdentifier = ""
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
|
language = ""
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0830"
|
LastUpgradeVersion = "0920"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0830"
|
LastUpgradeVersion = "0920"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
</Testables>
|
</Testables>
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
@@ -61,8 +63,6 @@
|
|||||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
<CommandLineArguments>
|
|
||||||
</CommandLineArguments>
|
|
||||||
<AdditionalOptions>
|
<AdditionalOptions>
|
||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
|
|||||||
@@ -89,14 +89,14 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
|||||||
SULog(SULogLevelError, @"Failed to listen for application termination");
|
SULog(SULogLevelError, @"Failed to listen for application termination");
|
||||||
// Continue on with the installation anyway?
|
// Continue on with the installation anyway?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.shouldShowUI) {
|
if (self.shouldShowUI) {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
if (!self.isTerminating) {
|
if (!self.isTerminating) {
|
||||||
// Show app icon in the dock
|
// Show app icon in the dock
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ int main(int __unused argc, const char __unused *argv[])
|
|||||||
{
|
{
|
||||||
@autoreleasepool
|
@autoreleasepool
|
||||||
{
|
{
|
||||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
|
||||||
if (args.count < 5 || args.count > 7) {
|
if (args.count < 5 || args.count > 7) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,11 @@
|
|||||||
if ([self terminated]) {
|
if ([self terminated]) {
|
||||||
[self invokeCompletionWithSuccess:YES];
|
[self invokeCompletionWithSuccess:YES];
|
||||||
}
|
}
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
if ([self terminated]) {
|
||||||
|
[self invokeCompletionWithSuccess:YES];
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unused callBackTypes, void *info)
|
static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unused callBackTypes, void *info)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
html {
|
||||||
|
color: #FFFFFFD8;
|
||||||
|
}
|
||||||
|
:link {
|
||||||
|
color: #419CFF;
|
||||||
|
}
|
||||||
|
:link:active {
|
||||||
|
color: #FF1919;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloadData.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 8/10/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#import "SUExport.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* A class for containing downloaded data along with some information about it.
|
||||||
|
*/
|
||||||
|
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
|
||||||
|
|
||||||
|
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The raw data that was downloaded.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly) NSData *data;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The IANA charset encoding name if available. Eg: "utf-8"
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* The MIME type if available. Eg: "text/plain"
|
||||||
|
*/
|
||||||
|
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloadData.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 8/10/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUDownloadData.h"
|
||||||
|
|
||||||
|
#import "SUOperatingSystem.h"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
static NSString *SPUDownloadDataKey = @"SPUDownloadData";
|
||||||
|
static NSString *SPUDownloadTextEncodingKey = @"SPUDownloadTextEncoding";
|
||||||
|
static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
|
||||||
|
|
||||||
|
@implementation SPUDownloadData
|
||||||
|
|
||||||
|
@synthesize data = _data;
|
||||||
|
@synthesize textEncodingName = _textEncodingName;
|
||||||
|
@synthesize MIMEType = _MIMEType;
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString *)MIMEType
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_data = data;
|
||||||
|
_textEncodingName = textEncodingName;
|
||||||
|
_MIMEType = MIMEType;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
|
{
|
||||||
|
[coder encodeObject:self.data forKey:SPUDownloadDataKey];
|
||||||
|
|
||||||
|
if (self.textEncodingName != nil) {
|
||||||
|
[coder encodeObject:self.textEncodingName forKey:SPUDownloadTextEncodingKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.MIMEType != nil) {
|
||||||
|
[coder encodeObject:self.MIMEType forKey:SPUDownloadMIMETypeKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
abort(); // Not used on 10.7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloader.h
|
||||||
|
// Downloader
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 4/1/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
#import "SPUDownloaderProtocol.h"
|
||||||
|
|
||||||
|
@protocol SPUDownloaderDelegate;
|
||||||
|
|
||||||
|
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
|
||||||
|
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
|
||||||
|
|
||||||
|
// Due to XPC remote object reasons, this delegate is strongly referenced
|
||||||
|
// Invoke cleanup when done with this instance
|
||||||
|
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate;
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloader.m
|
||||||
|
// Downloader
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 4/1/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUDownloader.h"
|
||||||
|
#import "SPUDownloaderDelegate.h"
|
||||||
|
#import "SPULocalCacheDirectory.h"
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
#import "SPUDownloadData.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
#import "SPUDownloader_Private.h"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface SPUDownloader ()
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SPUDownloader
|
||||||
|
|
||||||
|
@synthesize delegate = _delegate;
|
||||||
|
@synthesize bundleIdentifier = _bundleIdentifier;
|
||||||
|
@synthesize desiredFilename = _desiredFilename;
|
||||||
|
@synthesize downloadFilename = _downloadFilename;
|
||||||
|
@synthesize disabledAutomaticTermination = _disabledAutomaticTermination;
|
||||||
|
@synthesize mode = _mode;
|
||||||
|
@synthesize receivedExpectedBytes = _receivedExpectedBytes;
|
||||||
|
|
||||||
|
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_delegate = delegate;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't implement dealloc - make the client call cleanup, which is the only way to remove the reference cycle from the delegate anyway
|
||||||
|
|
||||||
|
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)__unused request bundleIdentifier:(NSString *)__unused bundleIdentifier desiredFilename:(NSString *)__unused desiredFilename
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)__unused request
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)enableAutomaticTermination
|
||||||
|
{
|
||||||
|
if (self.disabledAutomaticTermination) {
|
||||||
|
[[NSProcessInfo processInfo] enableAutomaticTermination:SUDownloadingReason];
|
||||||
|
self.disabledAutomaticTermination = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cleanup
|
||||||
|
{
|
||||||
|
[self enableAutomaticTermination];
|
||||||
|
self.delegate = nil;
|
||||||
|
|
||||||
|
if (self.mode == SPUDownloadModeTemporary && self.downloadFilename != nil)
|
||||||
|
{
|
||||||
|
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:NULL];
|
||||||
|
self.downloadFilename = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloadDidFinish
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)downloadDidFinishWithData:(SPUDownloadData*)data
|
||||||
|
{
|
||||||
|
switch (self.mode) {
|
||||||
|
case SPUDownloadModeTemporary:
|
||||||
|
if (data != nil) {
|
||||||
|
[self.delegate downloaderDidFinishWithTemporaryDownloadData:data];
|
||||||
|
} else {
|
||||||
|
[self.delegate downloaderDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", self.downloadFilename]}]];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SPUDownloadModePersistent:
|
||||||
|
[self.delegate downloaderDidFinishWithTemporaryDownloadData:nil];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSString*)getAndCleanTempDirectory
|
||||||
|
{
|
||||||
|
NSString *rootPersistentDownloadCachePath = [[SPULocalCacheDirectory cachePathForBundleIdentifier:self.bundleIdentifier] stringByAppendingPathComponent:@"PersistentDownloads"];
|
||||||
|
|
||||||
|
[SPULocalCacheDirectory removeOldItemsInDirectory:rootPersistentDownloadCachePath];
|
||||||
|
|
||||||
|
NSString *tempDir = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:rootPersistentDownloadCachePath];
|
||||||
|
if (tempDir == nil) {
|
||||||
|
// Okay, something's really broken with this user's file structure.
|
||||||
|
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", tempDir] }];
|
||||||
|
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
|
||||||
|
[self cancel];
|
||||||
|
}
|
||||||
|
return tempDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderDelegate.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 4/1/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class SPUDownloadData;
|
||||||
|
|
||||||
|
@protocol SPUDownloaderDelegate <NSObject>
|
||||||
|
|
||||||
|
// This is only invoked for persistent downloads
|
||||||
|
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
|
||||||
|
|
||||||
|
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
|
||||||
|
// This is only invoked for persistent downloads
|
||||||
|
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
|
||||||
|
|
||||||
|
// This is only invoked for persistent downloads
|
||||||
|
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
|
||||||
|
|
||||||
|
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
|
||||||
|
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
|
||||||
|
|
||||||
|
- (void)downloaderDidFailWithError:(NSError *)error;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderDeprecated.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Deadpikle on 12/20/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUDownloader.h"
|
||||||
|
|
||||||
|
@interface SPUDownloaderDeprecated : SPUDownloader <SPUDownloaderProtocol>
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderDeprecated.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Deadpikle on 12/20/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUDownloaderDeprecated.h"
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
#import "SPUDownloader_Private.h"
|
||||||
|
#import "SPUDownloadData.h"
|
||||||
|
#import "SPULocalCacheDirectory.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface SPUDownloaderDeprecated () <NSURLDownloadDelegate>
|
||||||
|
|
||||||
|
@property (nonatomic) NSURLDownload *download;
|
||||||
|
@property (nonatomic) NSURLResponse *response;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SPUDownloaderDeprecated
|
||||||
|
|
||||||
|
@synthesize download = _download;
|
||||||
|
@synthesize response = _response;
|
||||||
|
|
||||||
|
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (self.download == nil && self.delegate != nil) {
|
||||||
|
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||||
|
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||||
|
self.disabledAutomaticTermination = YES;
|
||||||
|
|
||||||
|
self.mode = SPUDownloadModePersistent;
|
||||||
|
self.desiredFilename = desiredFilename;
|
||||||
|
self.bundleIdentifier = bundleIdentifier;
|
||||||
|
|
||||||
|
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (self.download == nil && self.delegate != nil) {
|
||||||
|
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||||
|
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||||
|
self.disabledAutomaticTermination = YES;
|
||||||
|
|
||||||
|
self.mode = SPUDownloadModeTemporary;
|
||||||
|
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||||
|
{
|
||||||
|
if (self.mode == SPUDownloadModeTemporary) {
|
||||||
|
// Files downloaded in temporary mode should not last for very long,
|
||||||
|
// so it's ideal to place them in a system temporary directory
|
||||||
|
NSString *destinationFilename = NSTemporaryDirectory();
|
||||||
|
if (destinationFilename) {
|
||||||
|
destinationFilename = [destinationFilename stringByAppendingPathComponent:name];
|
||||||
|
|
||||||
|
[self.download setDestination:destinationFilename allowOverwrite:NO];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NSString *tempDir = [super getAndCleanTempDirectory];
|
||||||
|
|
||||||
|
if (tempDir != nil) {
|
||||||
|
NSString *downloadFileName = self.desiredFilename;
|
||||||
|
NSString *downloadFileNameDirectory = [tempDir stringByAppendingPathComponent:downloadFileName];
|
||||||
|
|
||||||
|
NSError *createError = nil;
|
||||||
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:downloadFileNameDirectory withIntermediateDirectories:NO attributes:nil error:&createError]) {
|
||||||
|
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a download file name %@ directory inside temporary directory for the update download at %@.", downloadFileName, downloadFileNameDirectory] }];
|
||||||
|
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
} else {
|
||||||
|
[self.download setDestination:[downloadFileNameDirectory stringByAppendingPathComponent:name] allowOverwrite:YES];
|
||||||
|
|
||||||
|
[self.delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
|
||||||
|
{
|
||||||
|
self.downloadFilename = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
|
||||||
|
{
|
||||||
|
self.response = response;
|
||||||
|
|
||||||
|
if (self.mode == SPUDownloadModePersistent) {
|
||||||
|
// It might be tempting to send over the response object instead of the expected content length but this isn't a good idea
|
||||||
|
// For one, we are only ever concerned about the expected content length
|
||||||
|
// Another reason is that NSURLResponse doesn't support NSSecureCoding in older OS releases (eg: 10.8), which cause issues with XPC
|
||||||
|
[self.delegate downloaderDidReceiveExpectedContentLength:response.expectedContentLength];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
|
||||||
|
{
|
||||||
|
if (self.mode == SPUDownloadModePersistent) {
|
||||||
|
[self.delegate downloaderDidReceiveDataOfLength:length];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||||
|
{
|
||||||
|
[self downloadDidFinish];
|
||||||
|
[self cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
self.download = nil;
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
[self cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||||
|
{
|
||||||
|
// We don't want the download system to extract our gzips for persistent downloads
|
||||||
|
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
||||||
|
return (self.mode == SPUDownloadModeTemporary || [encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloadDidFinish
|
||||||
|
{
|
||||||
|
assert(self.response != nil);
|
||||||
|
assert(self.downloadFilename != nil);
|
||||||
|
|
||||||
|
SPUDownloadData *downloadData = nil;
|
||||||
|
if (self.mode == SPUDownloadModeTemporary) {
|
||||||
|
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
|
||||||
|
if (data != nil) {
|
||||||
|
downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:self.response.textEncodingName MIMEType:self.response.MIMEType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.download = nil;
|
||||||
|
|
||||||
|
[super downloadDidFinishWithData:downloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)cleanup
|
||||||
|
{
|
||||||
|
[self.download cancel];
|
||||||
|
self.download = nil;
|
||||||
|
self.response = nil;
|
||||||
|
[super cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancel
|
||||||
|
{
|
||||||
|
[self cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderProtocol.h
|
||||||
|
// PersistentDownloader
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 4/1/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class SPUURLRequest;
|
||||||
|
|
||||||
|
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
|
||||||
|
@protocol SPUDownloaderProtocol
|
||||||
|
|
||||||
|
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
|
||||||
|
|
||||||
|
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
|
||||||
|
|
||||||
|
- (void)downloadDidFinish;
|
||||||
|
|
||||||
|
- (void)cleanup;
|
||||||
|
|
||||||
|
- (void)cancel;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderSession.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Deadpikle on 12/20/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
#import "SPUDownloader.h"
|
||||||
|
#import "SPUDownloaderProtocol.h"
|
||||||
|
|
||||||
|
NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0)
|
||||||
|
@interface SPUDownloaderSession : SPUDownloader <SPUDownloaderProtocol>
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloaderSession.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Deadpikle on 12/20/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUDownloaderSession.h"
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
#import "SPUDownloader_Private.h"
|
||||||
|
#import "SPULocalCacheDirectory.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
#import "SPUDownloadData.h"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface SPUDownloaderSession () <NSURLSessionDelegate>
|
||||||
|
|
||||||
|
@property (nonatomic) NSURLSession *downloadSession;
|
||||||
|
@property (nonatomic) NSURLSessionDownloadTask *download;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SPUDownloaderSession
|
||||||
|
|
||||||
|
@synthesize downloadSession = _downloadSession;
|
||||||
|
@synthesize download = _download;
|
||||||
|
|
||||||
|
- (void)startDownloadWithRequest:(SPUURLRequest *)request
|
||||||
|
{
|
||||||
|
NSOperationQueue *queue = [NSOperationQueue mainQueue];
|
||||||
|
self.downloadSession = [NSURLSession
|
||||||
|
sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
|
||||||
|
delegate:self
|
||||||
|
delegateQueue:queue];
|
||||||
|
self.download = [self.downloadSession downloadTaskWithRequest:request.request];
|
||||||
|
[self.download resume];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (self.download == nil && self.delegate != nil) {
|
||||||
|
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||||
|
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||||
|
self.disabledAutomaticTermination = YES;
|
||||||
|
|
||||||
|
self.mode = SPUDownloadModePersistent;
|
||||||
|
self.desiredFilename = desiredFilename;
|
||||||
|
self.bundleIdentifier = bundleIdentifier;
|
||||||
|
|
||||||
|
[self startDownloadWithRequest:request];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (self.download == nil && self.delegate != nil) {
|
||||||
|
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
|
||||||
|
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
|
||||||
|
self.disabledAutomaticTermination = YES;
|
||||||
|
|
||||||
|
self.mode = SPUDownloadModeTemporary;
|
||||||
|
[self startDownloadWithRequest:request];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)__unused downloadTask didFinishDownloadingToURL:(NSURL *)location
|
||||||
|
{
|
||||||
|
if (self.mode == SPUDownloadModeTemporary) {
|
||||||
|
self.downloadFilename = location.path;
|
||||||
|
[self downloadDidFinish]; // file is already in a system temp dir
|
||||||
|
} else {
|
||||||
|
NSString *tempDir = [super getAndCleanTempDirectory];
|
||||||
|
|
||||||
|
if (tempDir != nil) {
|
||||||
|
NSString *downloadFileName = self.desiredFilename;
|
||||||
|
NSString *downloadFileNameDirectory = [tempDir stringByAppendingPathComponent:downloadFileName];
|
||||||
|
|
||||||
|
NSError *createError = nil;
|
||||||
|
if (![[NSFileManager defaultManager] createDirectoryAtPath:downloadFileNameDirectory withIntermediateDirectories:NO attributes:nil error:&createError]) {
|
||||||
|
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a download file name %@ directory inside temporary directory for the update download at %@.", downloadFileName, downloadFileNameDirectory] }];
|
||||||
|
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
} else {
|
||||||
|
NSString *name = self.download.response.suggestedFilename;
|
||||||
|
if (!name) {
|
||||||
|
name = location.lastPathComponent; // This likely contains nothing useful to identify the file (e.g. CFNetworkDownload_87LVIz.tmp)
|
||||||
|
}
|
||||||
|
NSString *toPath = [downloadFileNameDirectory stringByAppendingPathComponent:name];
|
||||||
|
NSString *fromPath = location.path; // suppress moveItemAtPath: non-null warning
|
||||||
|
NSError *error = nil;
|
||||||
|
if ([[NSFileManager defaultManager] moveItemAtPath:fromPath toPath:toPath error:&error]) {
|
||||||
|
self.downloadFilename = toPath;
|
||||||
|
[self.delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
|
||||||
|
[self downloadDidFinish];
|
||||||
|
} else {
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)__unused downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)__unused totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
|
||||||
|
{
|
||||||
|
|
||||||
|
if (self.mode == SPUDownloadModePersistent && totalBytesExpectedToWrite > 0 && !self.receivedExpectedBytes) {
|
||||||
|
self.receivedExpectedBytes = YES;
|
||||||
|
[self.delegate downloaderDidReceiveExpectedContentLength:totalBytesExpectedToWrite];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.mode == SPUDownloadModePersistent && bytesWritten >= 0) {
|
||||||
|
[self.delegate downloaderDidReceiveDataOfLength:(uint64_t)bytesWritten];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)URLSession:(NSURLSession *)__unused session task:(NSURLSessionTask *)__unused task didCompleteWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
self.download = nil;
|
||||||
|
if (error) {
|
||||||
|
[self.delegate downloaderDidFailWithError:error];
|
||||||
|
}
|
||||||
|
[self cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloadDidFinish
|
||||||
|
{
|
||||||
|
assert(self.downloadFilename != nil);
|
||||||
|
|
||||||
|
SPUDownloadData *downloadData = nil;
|
||||||
|
if (self.mode == SPUDownloadModeTemporary) {
|
||||||
|
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
|
||||||
|
if (data != nil) {
|
||||||
|
NSURLResponse *response = self.download.response;
|
||||||
|
assert(response != nil);
|
||||||
|
downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:response.textEncodingName MIMEType:response.MIMEType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.download = nil;
|
||||||
|
|
||||||
|
[super downloadDidFinishWithData:downloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)cleanup
|
||||||
|
{
|
||||||
|
[self.download cancel];
|
||||||
|
[self.downloadSession invalidateAndCancel];
|
||||||
|
self.download = nil;
|
||||||
|
self.downloadSession = nil;
|
||||||
|
[super cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cancel
|
||||||
|
{
|
||||||
|
[self cleanup];
|
||||||
|
}
|
||||||
|
|
||||||
|
// NSURLDownload has a [downlaod:shouldDecodeSourceDataOfMIMEType:] to determine if the data should be decoded.
|
||||||
|
// This does not exist for NSURLSessionDownloadTask and appears unnecessary. Data tasks will decode data, but not download tasks.
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// SPUDownloader_Private.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Deadpikle on 12/20/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef SPUDownloader_Private_h
|
||||||
|
#define SPUDownloader_Private_h
|
||||||
|
|
||||||
|
#import "SPUDownloaderDelegate.h"
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, SPUDownloadMode)
|
||||||
|
{
|
||||||
|
SPUDownloadModePersistent,
|
||||||
|
SPUDownloadModeTemporary
|
||||||
|
};
|
||||||
|
|
||||||
|
static NSString *SUDownloadingReason = @"Downloading update related file";
|
||||||
|
|
||||||
|
@interface SPUDownloader ()
|
||||||
|
|
||||||
|
// Delegate is intentionally strongly referenced; see header
|
||||||
|
@property (nonatomic) id <SPUDownloaderDelegate> delegate;
|
||||||
|
@property (nonatomic, copy) NSString *bundleIdentifier;
|
||||||
|
@property (nonatomic, copy) NSString *desiredFilename;
|
||||||
|
@property (nonatomic, copy) NSString *downloadFilename;
|
||||||
|
@property (nonatomic) BOOL disabledAutomaticTermination;
|
||||||
|
@property (nonatomic) SPUDownloadMode mode;
|
||||||
|
@property (nonatomic) BOOL receivedExpectedBytes;
|
||||||
|
|
||||||
|
// returns temp directory location if successful; if not successful,
|
||||||
|
// returns nil after sending error message to client and canceling download
|
||||||
|
-(NSString*)getAndCleanTempDirectory;
|
||||||
|
|
||||||
|
-(void)downloadDidFinishWithData:(SPUDownloadData*)data;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* SPUDownloader_Private_h */
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// SULocalCacheDirectory.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 6/23/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface SPULocalCacheDirectory : NSObject
|
||||||
|
|
||||||
|
// Returns a path to a suitable cache directory to create specifically for Sparkle
|
||||||
|
// Intermediate directories to this path may not exist yet
|
||||||
|
// This path may depend on the type of running process,
|
||||||
|
// such that sandboxed vs non-sandboxed processes could yield different paths
|
||||||
|
// The caller should create a subdirectory from the path that is returned here so they don't have files that
|
||||||
|
// conflict with other callers. Once that subdirectory name is decided, the caller can remove old items inside it (using +removeOldItemsInDirectory:)
|
||||||
|
// and then create a unique temporary directory inside it (using +createUniqueDirectoryInDirectory:)
|
||||||
|
+ (NSString *)cachePathForBundleIdentifier:(NSString *)bundleIdentifier;
|
||||||
|
|
||||||
|
// Remove old files inside a directory
|
||||||
|
// A caller may want to invoke this on a directory they own rather than remove and re-create an entire directory
|
||||||
|
// This does nothing if the supplied directory does not exist yet
|
||||||
|
+ (void)removeOldItemsInDirectory:(NSString *)directory;
|
||||||
|
|
||||||
|
// Create a unique directory inside a parent directory
|
||||||
|
// The parent directory doesn't have to exist yet. If it doesn't exist, intermediate directories will be created.
|
||||||
|
+ (NSString * _Nullable)createUniqueDirectoryInDirectory:(NSString *)directory;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
//
|
||||||
|
// SULocalCacheDirectory.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 6/23/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPULocalCacheDirectory.h"
|
||||||
|
#import "SULog.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
static NSTimeInterval OLD_ITEM_DELETION_INTERVAL = 86400 * 10; // 10 days
|
||||||
|
|
||||||
|
@implementation SPULocalCacheDirectory
|
||||||
|
|
||||||
|
// It is important to note this may return a different path whether invoked from a sanboxed vs non-sandboxed process, or from a different user
|
||||||
|
// For this reason, this method should not be a part of SUHost because its behavior depends on what kind of process it's being invoked from
|
||||||
|
+ (NSString *)cachePathForBundleIdentifier:(NSString *)bundleIdentifier
|
||||||
|
{
|
||||||
|
NSURL *cacheURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:NULL];
|
||||||
|
assert(cacheURL != nil);
|
||||||
|
|
||||||
|
NSString *resultPath = [[[cacheURL URLByAppendingPathComponent:bundleIdentifier] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER] path];
|
||||||
|
assert(resultPath != nil);
|
||||||
|
|
||||||
|
return resultPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)removeOldItemsInDirectory:(NSString *)directory
|
||||||
|
{
|
||||||
|
NSMutableArray<NSString *> *filePathsToRemove = [NSMutableArray array];
|
||||||
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
|
if ([fileManager fileExistsAtPath:directory]) {
|
||||||
|
NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:directory];
|
||||||
|
NSDate *currentDate = [NSDate date];
|
||||||
|
for (NSString *filename in directoryEnumerator)
|
||||||
|
{
|
||||||
|
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:[directory stringByAppendingPathComponent:filename] error:NULL];
|
||||||
|
if (fileAttributes != nil)
|
||||||
|
{
|
||||||
|
NSDate *lastModificationDate = [fileAttributes objectForKey:NSFileModificationDate];
|
||||||
|
if ([currentDate timeIntervalSinceDate:lastModificationDate] >= OLD_ITEM_DELETION_INTERVAL)
|
||||||
|
{
|
||||||
|
[filePathsToRemove addObject:[directory stringByAppendingPathComponent:filename]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[directoryEnumerator skipDescendants];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NSString *filename in filePathsToRemove)
|
||||||
|
{
|
||||||
|
[fileManager removeItemAtPath:filename error:NULL];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString * _Nullable)createUniqueDirectoryInDirectory:(NSString *)directory
|
||||||
|
{
|
||||||
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
|
NSError *createError = nil;
|
||||||
|
if (![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&createError]) {
|
||||||
|
SULog(SULogLevelError, @"Failed to create directory with intermediate components at %@ with error %@", directory, createError);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *templateString = [directory stringByAppendingPathComponent:@"XXXXXXXXX"];
|
||||||
|
char buffer[PATH_MAX] = {0};
|
||||||
|
if ([templateString getFileSystemRepresentation:buffer maxLength:sizeof(buffer)]) {
|
||||||
|
if (mkdtemp(buffer) != NULL) {
|
||||||
|
return [[NSString alloc] initWithUTF8String:buffer];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// SPUURLRequest.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 5/19/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
// A class that wraps NSURLRequest and implements NSSecureCoding
|
||||||
|
// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8
|
||||||
|
// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not
|
||||||
|
@interface SPUURLRequest : NSObject <NSSecureCoding>
|
||||||
|
|
||||||
|
// Creates a new URL request
|
||||||
|
// Only these properties are currently tracked:
|
||||||
|
// * URL
|
||||||
|
// * Cache policy
|
||||||
|
// * Timeout interval
|
||||||
|
// * HTTP header fields
|
||||||
|
// * networkServiceType
|
||||||
|
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) NSURLRequest *request;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
//
|
||||||
|
// SPUURLRequest.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 5/19/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
|
||||||
|
#import "SUOperatingSystem.h"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
static NSString *SPUURLRequestURLKey = @"SPUURLRequestURL";
|
||||||
|
static NSString *SPUURLRequestCachePolicyKey = @"SPUURLRequestCachePolicy";
|
||||||
|
static NSString *SPUURLRequestTimeoutIntervalKey = @"SPUURLRequestTimeoutInterval";
|
||||||
|
static NSString *SPUURLRequestHttpHeaderFieldsKey = @"SPUURLRequestHttpHeaderFields";
|
||||||
|
static NSString *SPUURLRequestNetworkServiceTypeKey = @"SPUURLRequestNetworkServiceType";
|
||||||
|
|
||||||
|
@interface SPUURLRequest ()
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) NSURL *url;
|
||||||
|
@property (nonatomic, readonly) NSURLRequestCachePolicy cachePolicy;
|
||||||
|
@property (nonatomic, readonly) NSTimeInterval timeoutInterval;
|
||||||
|
@property (nonatomic, readonly, nullable) NSDictionary<NSString *, NSString *> *httpHeaderFields;
|
||||||
|
@property (nonatomic, readonly) NSURLRequestNetworkServiceType networkServiceType;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SPUURLRequest
|
||||||
|
|
||||||
|
@synthesize url = _url;
|
||||||
|
@synthesize cachePolicy = _cachePolicy;
|
||||||
|
@synthesize timeoutInterval = _timeoutInterval;
|
||||||
|
@synthesize httpHeaderFields = _httpHeaderFields;
|
||||||
|
@synthesize networkServiceType = _networkServiceType;
|
||||||
|
|
||||||
|
- (instancetype)initWithURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval httpHeaderFields:(NSDictionary<NSString *, NSString *> *)httpHeaderFields networkServiceType:(NSURLRequestNetworkServiceType)networkServiceType
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_url = url;
|
||||||
|
_cachePolicy = cachePolicy;
|
||||||
|
_timeoutInterval = timeoutInterval;
|
||||||
|
_httpHeaderFields = httpHeaderFields;
|
||||||
|
_networkServiceType = networkServiceType;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request
|
||||||
|
{
|
||||||
|
return [(SPUURLRequest *)[[self class] alloc] initWithURL:request.URL cachePolicy:request.cachePolicy timeoutInterval:request.timeoutInterval httpHeaderFields:request.allHTTPHeaderFields networkServiceType:request.networkServiceType];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
|
{
|
||||||
|
[coder encodeObject:self.url forKey:SPUURLRequestURLKey];
|
||||||
|
[coder encodeInteger:(NSInteger)self.cachePolicy forKey:SPUURLRequestCachePolicyKey];
|
||||||
|
[coder encodeDouble:self.timeoutInterval forKey:SPUURLRequestTimeoutIntervalKey];
|
||||||
|
[coder encodeInteger:(NSInteger)self.networkServiceType forKey:SPUURLRequestNetworkServiceTypeKey];
|
||||||
|
|
||||||
|
if (self.httpHeaderFields != nil) {
|
||||||
|
[coder encodeObject:self.httpHeaderFields forKey:SPUURLRequestHttpHeaderFieldsKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||||
|
{
|
||||||
|
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];
|
||||||
|
} else {
|
||||||
|
abort(); // Not used on 10.7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURLRequest *)request
|
||||||
|
{
|
||||||
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:self.cachePolicy timeoutInterval:self.timeoutInterval];
|
||||||
|
if (self.httpHeaderFields != nil) {
|
||||||
|
request.allHTTPHeaderFields = self.httpHeaderFields;
|
||||||
|
}
|
||||||
|
request.networkServiceType = self.networkServiceType;
|
||||||
|
return [request copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -19,15 +19,10 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class SUAppcastItem;
|
@class SUAppcastItem;
|
||||||
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
SU_EXPORT @interface SUAppcast : NSObject
|
||||||
|
|
||||||
@property (copy, nullable) NSString *userAgentString;
|
@property (copy, nullable) NSString *userAgentString;
|
||||||
|
|
||||||
#if __has_feature(objc_generics)
|
|
||||||
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||||
#else
|
|
||||||
@property (copy, nullable) NSDictionary *httpHeaders;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
|
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
|
||||||
- (SUAppcast *)copyWithoutDeltaUpdates;
|
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
#import "SULocalizations.h"
|
#import "SULocalizations.h"
|
||||||
#import "SUErrors.h"
|
#import "SUErrors.h"
|
||||||
|
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
#import "SUOperatingSystem.h"
|
||||||
|
#import "SPUDownloadData.h"
|
||||||
|
#import "SPUDownloaderDelegate.h"
|
||||||
|
#import "SPUDownloaderDeprecated.h"
|
||||||
|
#import "SPUDownloaderSession.h"
|
||||||
|
|
||||||
#include "AppKitPrevention.h"
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@@ -39,18 +45,18 @@
|
|||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface SUAppcast () <NSURLDownloadDelegate>
|
@interface SUAppcast () <SPUDownloaderDelegate>
|
||||||
|
|
||||||
@property (strong) void (^completionBlock)(NSError *);
|
@property (strong) void (^completionBlock)(NSError *);
|
||||||
@property (copy) NSString *downloadFilename;
|
@property (strong) SPUDownloader *download;
|
||||||
@property (strong) NSURLDownload *download;
|
|
||||||
@property (copy) NSArray *items;
|
@property (copy) NSArray *items;
|
||||||
- (void)reportError:(NSError *)error;
|
- (void)reportError:(NSError *)error;
|
||||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
|
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUAppcast
|
@implementation SUAppcast
|
||||||
|
|
||||||
@synthesize downloadFilename;
|
|
||||||
@synthesize completionBlock;
|
@synthesize completionBlock;
|
||||||
@synthesize userAgentString;
|
@synthesize userAgentString;
|
||||||
@synthesize httpHeaders;
|
@synthesize httpHeaders;
|
||||||
@@ -79,49 +85,74 @@
|
|||||||
|
|
||||||
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
||||||
|
|
||||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
|
||||||
}
|
if (SUAVAILABLE(10, 9)) {
|
||||||
|
#pragma clang diagnostic push
|
||||||
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||||
{
|
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
|
||||||
NSString *destinationFilename = NSTemporaryDirectory();
|
#pragma clang diagnostic pop
|
||||||
if (destinationFilename)
|
|
||||||
{
|
|
||||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
|
||||||
[self.download setDestination:destinationFilename allowOverwrite:NO];
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
self.download = [[SPUDownloaderDeprecated alloc] initWithDelegate:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
SPUURLRequest *urlRequest = [SPUURLRequest URLRequestWithRequest:request];
|
||||||
|
[self.download startTemporaryDownloadWithRequest:urlRequest];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
|
- (void)downloaderDidSetDestinationName:(NSString *)__unused destinationName temporaryDirectory:(NSString *)__unused temporaryDirectory
|
||||||
{
|
{
|
||||||
self.downloadFilename = path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
|
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
|
||||||
{
|
{
|
||||||
NSError *error = nil;
|
}
|
||||||
NSArray *appcastItems = [self parseAppcastItemsFromXMLFile:[NSURL fileURLWithPath:self.downloadFilename] error:&error];
|
|
||||||
|
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
- (void)downloaderDidReceiveDataOfLength:(uint64_t)__unused length
|
||||||
self.downloadFilename = nil;
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if (appcastItems) {
|
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData
|
||||||
self.items = appcastItems;
|
{
|
||||||
self.completionBlock(nil);
|
if (downloadData != nil) {
|
||||||
self.completionBlock = nil;
|
NSError *parseError = nil;
|
||||||
} else {
|
NSArray *appcastItems = [self parseAppcastItemsFromXMLData:downloadData.data error:&parseError];
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary
|
|
||||||
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
|
if (appcastItems != nil) {
|
||||||
forKey: NSLocalizedDescriptionKey];
|
self.items = appcastItems;
|
||||||
if (error) {
|
self.completionBlock(nil);
|
||||||
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
|
self.completionBlock = nil;
|
||||||
|
} else {
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary
|
||||||
|
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
|
||||||
|
forKey: NSLocalizedDescriptionKey];
|
||||||
|
if (parseError != nil) {
|
||||||
|
[userInfo setObject:parseError forKey:NSUnderlyingErrorKey];
|
||||||
|
}
|
||||||
|
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||||
|
code:SUAppcastParseError
|
||||||
|
userInfo:userInfo]];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
SULog(SULogLevelError, @"Temp data download is null in SUAppcast");
|
||||||
|
|
||||||
|
NSDictionary *userInfo = [NSDictionary
|
||||||
|
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
|
||||||
|
forKey: NSLocalizedDescriptionKey];
|
||||||
|
|
||||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||||
code:SUAppcastParseError
|
code:SUDownloadError
|
||||||
userInfo:userInfo]];
|
userInfo:userInfo]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)downloaderDidFailWithError:(NSError *)error
|
||||||
|
{
|
||||||
|
SULog(SULogLevelError, @"Encountered download feed error: %@", error);
|
||||||
|
|
||||||
|
[self reportError:error];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
|
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
|
||||||
{
|
{
|
||||||
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
|
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
|
||||||
@@ -152,18 +183,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
|
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastURL error:(NSError *__autoreleasing*)errorp {
|
||||||
|
NSData *data = [NSData dataWithContentsOfURL:appcastURL];
|
||||||
|
return [self parseAppcastItemsFromXMLData:data error:errorp];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData error:(NSError *__autoreleasing*)errorp {
|
||||||
if (errorp) {
|
if (errorp) {
|
||||||
*errorp = nil;
|
*errorp = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appcastFile) {
|
if (!appcastData) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
||||||
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:appcastFile options:options error:errorp];
|
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:appcastData options:options error:errorp];
|
||||||
if (nil == document) {
|
if (nil == document) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +212,7 @@
|
|||||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||||
NSXMLNode *node;
|
NSXMLNode *node;
|
||||||
|
|
||||||
while((node = [nodeEnum nextObject])) {
|
while((node = [nodeEnum nextObject])) {
|
||||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
@@ -203,7 +239,7 @@
|
|||||||
// enclosure is flattened as a separate dictionary for some reason
|
// enclosure is flattened as a separate dictionary for some reason
|
||||||
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||||
[dict setObject:encDict forKey:name];
|
[dict setObject:encDict forKey:name];
|
||||||
}
|
}
|
||||||
else if ([name isEqualToString:SURSSElementPubDate]) {
|
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||||
// We don't want to parse and create a NSDate instance -
|
// 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
|
// that's a risk we can avoid. We don't use the date anywhere other
|
||||||
@@ -212,8 +248,8 @@
|
|||||||
if (dateString) {
|
if (dateString) {
|
||||||
[dict setObject:dateString forKey:name];
|
[dict setObject:dateString forKey:name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||||
NSMutableArray *deltas = [NSMutableArray array];
|
NSMutableArray *deltas = [NSMutableArray array];
|
||||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||||
for (NSXMLNode *child in childEnum) {
|
for (NSXMLNode *child in childEnum) {
|
||||||
@@ -222,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[dict setObject:deltas forKey:name];
|
[dict setObject:deltas forKey:name];
|
||||||
}
|
}
|
||||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||||
NSMutableArray *tags = [NSMutableArray array];
|
NSMutableArray *tags = [NSMutableArray array];
|
||||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||||
@@ -234,7 +270,7 @@
|
|||||||
}
|
}
|
||||||
[dict setObject:tags forKey:name];
|
[dict setObject:tags forKey:name];
|
||||||
}
|
}
|
||||||
else if (name != nil) {
|
else if (name != nil) {
|
||||||
// add all other values as strings
|
// add all other values as strings
|
||||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||||
if (theValue != nil) {
|
if (theValue != nil) {
|
||||||
@@ -247,7 +283,7 @@
|
|||||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||||
if (anItem) {
|
if (anItem) {
|
||||||
[appcastItems addObject:anItem];
|
[appcastItems addObject:anItem];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SULog(SULogLevelError, @"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
SULog(SULogLevelError, @"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||||
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
|
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
|
||||||
@@ -262,21 +298,6 @@
|
|||||||
return appcastItems;
|
return appcastItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
|
||||||
{
|
|
||||||
if (self.downloadFilename) {
|
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
|
||||||
}
|
|
||||||
self.downloadFilename = nil;
|
|
||||||
|
|
||||||
[self reportError:error];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSURLRequest *)download:(NSURLDownload *)__unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)__unused redirectResponse
|
|
||||||
{
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)reportError:(NSError *)error
|
- (void)reportError:(NSError *)error
|
||||||
{
|
{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||||
|
|||||||
@@ -15,21 +15,25 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#endif
|
#endif
|
||||||
#import "SUExport.h"
|
#import "SUExport.h"
|
||||||
|
@class SUSignatures;
|
||||||
|
|
||||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||||
@property (copy, readonly) NSString *title;
|
@property (copy, readonly) NSString *title;
|
||||||
@property (copy, readonly) NSString *dateString;
|
@property (copy, readonly) NSString *dateString;
|
||||||
|
@property (copy, readonly) NSDate *date;
|
||||||
@property (copy, readonly) NSString *itemDescription;
|
@property (copy, readonly) NSString *itemDescription;
|
||||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||||
@property (copy, readonly) NSString *DSASignature;
|
@property (strong, readonly) SUSignatures *signatures;
|
||||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||||
@property (strong, readonly) NSURL *fileURL;
|
@property (strong, readonly) NSURL *fileURL;
|
||||||
@property (nonatomic, readonly) uint64_t contentLength;
|
@property (nonatomic, readonly) uint64_t contentLength;
|
||||||
@property (copy, readonly) NSString *versionString;
|
@property (copy, readonly) NSString *versionString;
|
||||||
|
@property (copy, readonly) NSString *osString;
|
||||||
@property (copy, readonly) NSString *displayVersionString;
|
@property (copy, readonly) NSString *displayVersionString;
|
||||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||||
@property (strong, readonly) NSURL *infoURL;
|
@property (strong, readonly) NSURL *infoURL;
|
||||||
|
@property (copy, readonly) NSNumber* phasedRolloutInterval;
|
||||||
|
|
||||||
// Initializes with data from a dictionary provided by the RSS class.
|
// Initializes with data from a dictionary provided by the RSS class.
|
||||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||||
@@ -37,6 +41,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
|
|||||||
|
|
||||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||||
|
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||||
|
|
||||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#import "SUAppcastItem.h"
|
#import "SUAppcastItem.h"
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
|
#import "SUSignatures.h"
|
||||||
|
|
||||||
#include "AppKitPrevention.h"
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@@ -18,22 +18,24 @@
|
|||||||
@property (copy, readwrite) NSString *dateString;
|
@property (copy, readwrite) NSString *dateString;
|
||||||
@property (copy, readwrite) NSString *itemDescription;
|
@property (copy, readwrite) NSString *itemDescription;
|
||||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||||
@property (copy, readwrite) NSString *DSASignature;
|
@property (strong, readwrite) SUSignatures *signatures;
|
||||||
@property (copy, readwrite) NSString *minimumSystemVersion;
|
@property (copy, readwrite) NSString *minimumSystemVersion;
|
||||||
@property (copy, readwrite) NSString *maximumSystemVersion;
|
@property (copy, readwrite) NSString *maximumSystemVersion;
|
||||||
@property (strong, readwrite) NSURL *fileURL;
|
@property (strong, readwrite) NSURL *fileURL;
|
||||||
@property (copy, readwrite) NSString *versionString;
|
@property (copy, readwrite) NSString *versionString;
|
||||||
|
@property (copy, readwrite) NSString *osString;
|
||||||
@property (copy, readwrite) NSString *displayVersionString;
|
@property (copy, readwrite) NSString *displayVersionString;
|
||||||
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
||||||
@property (strong, readwrite) NSURL *infoURL;
|
@property (strong, readwrite) NSURL *infoURL;
|
||||||
@property (readwrite, copy) NSDictionary *propertiesDictionary;
|
@property (readwrite, copy) NSDictionary *propertiesDictionary;
|
||||||
|
@property (copy, readwrite) NSNumber* phasedRolloutInterval;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUAppcastItem
|
@implementation SUAppcastItem
|
||||||
@synthesize dateString;
|
@synthesize dateString;
|
||||||
@synthesize deltaUpdates;
|
@synthesize deltaUpdates;
|
||||||
@synthesize displayVersionString;
|
@synthesize displayVersionString;
|
||||||
@synthesize DSASignature;
|
@synthesize signatures;
|
||||||
@synthesize fileURL;
|
@synthesize fileURL;
|
||||||
@synthesize contentLength = _contentLength;
|
@synthesize contentLength = _contentLength;
|
||||||
@synthesize infoURL;
|
@synthesize infoURL;
|
||||||
@@ -43,7 +45,9 @@
|
|||||||
@synthesize releaseNotesURL;
|
@synthesize releaseNotesURL;
|
||||||
@synthesize title;
|
@synthesize title;
|
||||||
@synthesize versionString;
|
@synthesize versionString;
|
||||||
|
@synthesize osString;
|
||||||
@synthesize propertiesDictionary;
|
@synthesize propertiesDictionary;
|
||||||
|
@synthesize phasedRolloutInterval;
|
||||||
|
|
||||||
- (BOOL)isDeltaUpdate
|
- (BOOL)isDeltaUpdate
|
||||||
{
|
{
|
||||||
@@ -53,7 +57,24 @@
|
|||||||
|
|
||||||
- (BOOL)isCriticalUpdate
|
- (BOOL)isCriticalUpdate
|
||||||
{
|
{
|
||||||
return [[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
return [(NSArray *)[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isMacOsUpdate
|
||||||
|
{
|
||||||
|
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
|
- (BOOL)isInformationOnlyUpdate
|
||||||
@@ -90,7 +111,7 @@
|
|||||||
|
|
||||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||||
// then we remove the extension. Hopefully, this will be the version.
|
// then we remove the extension. Hopefully, this will be the version.
|
||||||
NSArray *fileComponents = [[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
NSArray<NSString *> *fileComponents = [(NSString *)[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
||||||
if ([fileComponents count] > 1) {
|
if ([fileComponents count] > 1) {
|
||||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||||
}
|
}
|
||||||
@@ -118,7 +139,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
// 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 (!enclosure && !theInfoURL) {
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = @"No enclosure in feed item";
|
*error = @"No enclosure in feed item";
|
||||||
@@ -149,7 +170,8 @@
|
|||||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||||
}
|
}
|
||||||
if (enclosure) {
|
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.versionString = newVersion;
|
||||||
@@ -167,6 +189,11 @@
|
|||||||
self.displayVersionString = self.versionString;
|
self.displayVersionString = self.versionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString* enclosureRolloutIntervalString = [enclosure objectForKey:SUAppcastAttributePhasedRolloutInterval];
|
||||||
|
if(enclosureRolloutIntervalString) {
|
||||||
|
self.phasedRolloutInterval = @(enclosureRolloutIntervalString.integerValue);
|
||||||
|
}
|
||||||
|
|
||||||
// Find the appropriate release notes URL.
|
// Find the appropriate release notes URL.
|
||||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||||
if (releaseNotesString) {
|
if (releaseNotesString) {
|
||||||
|
|||||||
@@ -110,14 +110,14 @@ static NSString *const SUAutomaticUpdateAlertTouchBarIndentifier = @"" SPARKLE_B
|
|||||||
|
|
||||||
- (NSTouchBar *)makeTouchBar
|
- (NSTouchBar *)makeTouchBar
|
||||||
{
|
{
|
||||||
NSTouchBar *touchBar = [[NSClassFromString(@"NSTouchBar") alloc] init];
|
NSTouchBar *touchBar = [(NSTouchBar *)[NSClassFromString(@"NSTouchBar") alloc] init];
|
||||||
touchBar.defaultItemIdentifiers = @[SUAutomaticUpdateAlertTouchBarIndentifier,];
|
touchBar.defaultItemIdentifiers = @[SUAutomaticUpdateAlertTouchBarIndentifier,];
|
||||||
touchBar.principalItemIdentifier = SUAutomaticUpdateAlertTouchBarIndentifier;
|
touchBar.principalItemIdentifier = SUAutomaticUpdateAlertTouchBarIndentifier;
|
||||||
touchBar.delegate = self;
|
touchBar.delegate = self;
|
||||||
return touchBar;
|
return touchBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSTouchBarItem *)touchBar:(NSTouchBar * __unused)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
- (NSTouchBarItem *)touchBar:(NSTouchBar * __unused)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macos(10.12.2))
|
||||||
{
|
{
|
||||||
if ([identifier isEqualToString:SUAutomaticUpdateAlertTouchBarIndentifier]) {
|
if ([identifier isEqualToString:SUAutomaticUpdateAlertTouchBarIndentifier]) {
|
||||||
NSCustomTouchBarItem* item = [(NSCustomTouchBarItem *)[NSClassFromString(@"NSCustomTouchBarItem") alloc] initWithIdentifier:identifier];
|
NSCustomTouchBarItem* item = [(NSCustomTouchBarItem *)[NSClassFromString(@"NSCustomTouchBarItem") alloc] initWithIdentifier:identifier];
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
@interface SUAutomaticUpdateDriver ()
|
@interface SUAutomaticUpdateDriver ()
|
||||||
|
|
||||||
@property (assign) BOOL postponingInstallation;
|
@property (assign) BOOL postponingInstallation;
|
||||||
@property (assign) BOOL showErrors;
|
|
||||||
@property (assign) BOOL willUpdateOnTermination;
|
@property (assign) BOOL willUpdateOnTermination;
|
||||||
@property (assign) BOOL isTerminating;
|
@property (assign) BOOL isTerminating;
|
||||||
@property (strong) SUAutomaticUpdateAlert *alert;
|
@property (strong) SUAutomaticUpdateAlert *alert;
|
||||||
@@ -40,7 +39,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
@implementation SUAutomaticUpdateDriver
|
@implementation SUAutomaticUpdateDriver
|
||||||
|
|
||||||
@synthesize postponingInstallation;
|
@synthesize postponingInstallation;
|
||||||
@synthesize showErrors;
|
|
||||||
@synthesize willUpdateOnTermination;
|
@synthesize willUpdateOnTermination;
|
||||||
@synthesize isTerminating;
|
@synthesize isTerminating;
|
||||||
@synthesize alert;
|
@synthesize alert;
|
||||||
@@ -98,6 +96,12 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
[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 this is marked as a critical update, we'll prompt the user to install it right away.
|
||||||
if ([self.updateItem isCriticalUpdate])
|
if ([self.updateItem isCriticalUpdate])
|
||||||
@@ -175,8 +179,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||||
{
|
{
|
||||||
self.alert = nil;
|
self.alert = nil;
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case SUInstallNowChoice:
|
case SUInstallNowChoice:
|
||||||
[self stopUpdatingOnTermination];
|
[self stopUpdatingOnTermination];
|
||||||
[self installWithToolAndRelaunch:YES];
|
[self installWithToolAndRelaunch:YES];
|
||||||
@@ -202,7 +206,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
[self stopUpdatingOnTermination];
|
[self stopUpdatingOnTermination];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.showErrors = YES;
|
|
||||||
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,21 +234,4 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)abortUpdateWithError:(NSError *)error
|
|
||||||
{
|
|
||||||
if (self.showErrors) {
|
|
||||||
[super abortUpdateWithError:error];
|
|
||||||
} else {
|
|
||||||
// Call delegate separately here because otherwise it won't know we stopped.
|
|
||||||
// Normally this gets called by the superclass
|
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
|
||||||
[updaterDelegate updater:self.updater didAbortWithError:error];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self abortUpdate];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -10,18 +10,22 @@
|
|||||||
#define SUBASICUPDATEDRIVER_H
|
#define SUBASICUPDATEDRIVER_H
|
||||||
|
|
||||||
#import "SUUpdateDriver.h"
|
#import "SUUpdateDriver.h"
|
||||||
|
#import "SPUDownloader.h"
|
||||||
|
#import "SPUDownloaderDelegate.h"
|
||||||
|
|
||||||
@class SUAppcast, SUAppcastItem, SUHost;
|
@class SUAppcast, SUAppcastItem, SUHost, SPUDownloadData;
|
||||||
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate>
|
@interface SUBasicUpdateDriver : SUUpdateDriver <SPUDownloaderDelegate>
|
||||||
|
|
||||||
@property (strong, readonly) SUAppcastItem *updateItem;
|
@property (strong, readonly) SUAppcastItem *updateItem;
|
||||||
@property (strong, readonly) NSURLDownload *download;
|
@property (strong, readonly) SUAppcastItem *latestAppcastItem;
|
||||||
|
@property (assign, readonly) NSComparisonResult latestAppcastItemComparisonResult;
|
||||||
|
@property (strong, readonly) SPUDownloader *download;
|
||||||
@property (copy, readonly) NSString *downloadPath;
|
@property (copy, readonly) NSString *downloadPath;
|
||||||
|
|
||||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||||
|
|
||||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
||||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
||||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||||
@@ -29,9 +33,12 @@
|
|||||||
- (void)didNotFindUpdate;
|
- (void)didNotFindUpdate;
|
||||||
|
|
||||||
- (void)downloadUpdate;
|
- (void)downloadUpdate;
|
||||||
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
|
// SPUDownloaderDelegate
|
||||||
- (void)downloadDidFinish:(NSURLDownload *)d;
|
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
|
||||||
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error;
|
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
|
||||||
|
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
|
||||||
|
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData *)downloadData;
|
||||||
|
- (void)downloaderDidFailWithError:(NSError *)error;
|
||||||
|
|
||||||
- (void)extractUpdate;
|
- (void)extractUpdate;
|
||||||
- (void)failedToApplyDeltaUpdate;
|
- (void)failedToApplyDeltaUpdate;
|
||||||
|
|||||||
@@ -22,13 +22,21 @@
|
|||||||
#import "SUUpdateValidator.h"
|
#import "SUUpdateValidator.h"
|
||||||
#import "SULocalizations.h"
|
#import "SULocalizations.h"
|
||||||
#import "SUErrors.h"
|
#import "SUErrors.h"
|
||||||
|
#import "SUUpdater.h"
|
||||||
#import "SUAppcast.h"
|
#import "SUAppcast.h"
|
||||||
#import "SUAppcastItem.h"
|
#import "SUAppcastItem.h"
|
||||||
|
#import "SUGlobalUpdateLock.h"
|
||||||
|
|
||||||
|
#import "SPUURLRequest.h"
|
||||||
|
#import "SPUDownloaderDeprecated.h"
|
||||||
|
#import "SPUDownloaderSession.h"
|
||||||
|
|
||||||
@interface SUBasicUpdateDriver ()
|
@interface SUBasicUpdateDriver ()
|
||||||
|
|
||||||
@property (strong) SUAppcastItem *updateItem;
|
@property (strong) SUAppcastItem *updateItem;
|
||||||
@property (strong) NSURLDownload *download;
|
@property (strong) SUAppcastItem *latestAppcastItem;
|
||||||
|
@property (assign) NSComparisonResult latestAppcastItemComparisonResult;
|
||||||
|
@property (strong) SPUDownloader *download;
|
||||||
@property (copy) NSString *downloadPath;
|
@property (copy) NSString *downloadPath;
|
||||||
|
|
||||||
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
|
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
|
||||||
@@ -42,6 +50,8 @@
|
|||||||
@implementation SUBasicUpdateDriver
|
@implementation SUBasicUpdateDriver
|
||||||
|
|
||||||
@synthesize updateItem;
|
@synthesize updateItem;
|
||||||
|
@synthesize latestAppcastItem;
|
||||||
|
@synthesize latestAppcastItemComparisonResult;
|
||||||
@synthesize download;
|
@synthesize download;
|
||||||
@synthesize downloadPath;
|
@synthesize downloadPath;
|
||||||
|
|
||||||
@@ -54,9 +64,17 @@
|
|||||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||||
{
|
{
|
||||||
[super checkForUpdatesAtURL:URL host:aHost];
|
[super checkForUpdatesAtURL:URL host:aHost];
|
||||||
if ([aHost isRunningOnReadOnlyVolume])
|
if ([aHost isRunningOnReadOnlyVolume])
|
||||||
{
|
{
|
||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]];
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +96,7 @@
|
|||||||
{
|
{
|
||||||
id<SUVersionComparison> comparator = nil;
|
id<SUVersionComparison> comparator = nil;
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
// Give the delegate a chance to provide a custom version comparator
|
// Give the delegate a chance to provide a custom version comparator
|
||||||
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||||
comparator = [[updater delegate] versionComparatorForUpdater:self.updater];
|
comparator = [[updater delegate] versionComparatorForUpdater:self.updater];
|
||||||
@@ -92,35 +110,53 @@
|
|||||||
return comparator;
|
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;
|
SUAppcastItem *item = nil;
|
||||||
|
NSComparisonResult order;
|
||||||
|
|
||||||
for(SUAppcastItem *candidate in appcastItems) {
|
for(SUAppcastItem *candidate in appcastItems) {
|
||||||
if ([[self class] hostSupportsItem:candidate]) {
|
if ([self hostSupportsItem:candidate]) {
|
||||||
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
// 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;
|
item = candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item && deltaItem) {
|
if (item && deltaItem) {
|
||||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||||
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
|
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||||
*deltaItem = deltaUpdateItem;
|
*deltaItem = deltaUpdateItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||||
{
|
{
|
||||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
BOOL osOK = [ui isMacOsUpdate];
|
||||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||||
|
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) {
|
||||||
|
return osOK;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL minimumVersionOK = TRUE;
|
BOOL minimumVersionOK = TRUE;
|
||||||
BOOL maximumVersionOK = TRUE;
|
BOOL maximumVersionOK = TRUE;
|
||||||
|
|
||||||
id<SUVersionComparison> versionComparator = [[SUStandardVersionComparator alloc] init];
|
id<SUVersionComparison> versionComparator = [[SUStandardVersionComparator alloc] init];
|
||||||
|
|
||||||
// Check minimum and maximum System Version
|
// Check minimum and maximum System Version
|
||||||
@@ -131,7 +167,7 @@
|
|||||||
maximumVersionOK = [versionComparator compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
maximumVersionOK = [versionComparator compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||||
}
|
}
|
||||||
|
|
||||||
return minimumVersionOK && maximumVersionOK;
|
return minimumVersionOK && maximumVersionOK && osOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||||
@@ -142,13 +178,13 @@
|
|||||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||||
{
|
{
|
||||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
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;
|
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
- (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
|
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||||
@@ -168,7 +204,7 @@
|
|||||||
{
|
{
|
||||||
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != nil) // Does the delegate want to handle it?
|
if (item != nil) // Does the delegate want to handle it?
|
||||||
{
|
{
|
||||||
if ([item isDeltaUpdate]) {
|
if ([item isDeltaUpdate]) {
|
||||||
@@ -179,27 +215,31 @@
|
|||||||
{
|
{
|
||||||
// Find the best supported update
|
// Find the best supported update
|
||||||
SUAppcastItem *deltaUpdateItem = nil;
|
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) {
|
if (item && deltaUpdateItem) {
|
||||||
self.nonDeltaUpdateItem = item;
|
self.nonDeltaUpdateItem = item;
|
||||||
item = deltaUpdateItem;
|
item = deltaUpdateItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.latestAppcastItem = item;
|
||||||
|
self.latestAppcastItemComparisonResult = [[self versionComparator] compareVersion:[self.host version] toVersion:[item versionString]];
|
||||||
|
|
||||||
|
|
||||||
if ([self itemContainsValidUpdate:item]) {
|
if ([self itemContainsValidUpdate:item]) {
|
||||||
self.updateItem = item;
|
self.updateItem = item;
|
||||||
[self didFindValidUpdate];
|
[self performSelectorOnMainThread:@selector(didFindValidUpdate) withObject:nil waitUntilDone:NO];
|
||||||
} else {
|
} else {
|
||||||
self.updateItem = nil;
|
self.updateItem = nil;
|
||||||
[self didNotFindUpdate];
|
[self performSelectorOnMainThread:@selector(didNotFindUpdate) withObject:nil waitUntilDone:NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didFindValidUpdate
|
- (void)didFindValidUpdate
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||||
@@ -215,7 +255,7 @@
|
|||||||
- (void)didNotFindUpdate
|
- (void)didNotFindUpdate
|
||||||
{
|
{
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||||
[[updater delegate] updaterDidNotFindUpdate:self.updater];
|
[[updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||||
}
|
}
|
||||||
@@ -240,12 +280,12 @@
|
|||||||
SULog(SULogLevelError, @"Failed to find user's cache directory! Using system default");
|
SULog(SULogLevelError, @"Failed to find user's cache directory! Using system default");
|
||||||
cachePath = NSTemporaryDirectory();
|
cachePath = NSTemporaryDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *name = [self.host.bundle bundleIdentifier];
|
NSString *name = [self.host.bundle bundleIdentifier];
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = [self.host name];
|
name = [self.host name];
|
||||||
}
|
}
|
||||||
|
|
||||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||||
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
||||||
return cachePath;
|
return cachePath;
|
||||||
@@ -253,12 +293,18 @@
|
|||||||
|
|
||||||
- (void)downloadUpdate
|
- (void)downloadUpdate
|
||||||
{
|
{
|
||||||
|
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||||
|
assert(bundleIdentifier != nil);
|
||||||
|
|
||||||
// Clear cache directory so that downloads can't possibly accumulate inside
|
// Clear cache directory so that downloads can't possibly accumulate inside
|
||||||
NSString *appCachePath = [self appCachePath];
|
NSString *appCachePath = [self appCachePath];
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
|
[[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;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||||
@@ -272,61 +318,69 @@
|
|||||||
willDownloadUpdate:self.updateItem
|
willDownloadUpdate:self.updateItem
|
||||||
withRequest:request];
|
withRequest:request];
|
||||||
}
|
}
|
||||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
|
||||||
|
if (SUAVAILABLE(10, 9)) {
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||||
|
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.download = [[SPUDownloaderDeprecated alloc] initWithDelegate:self];
|
||||||
|
}
|
||||||
|
SPUURLRequest *urlRequest = [SPUURLRequest URLRequestWithRequest:request];
|
||||||
|
NSString *desiredFilename = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
||||||
|
[self.download startPersistentDownloadWithRequest:urlRequest bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
|
||||||
|
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory
|
||||||
{
|
{
|
||||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
self.tempDir = temporaryDirectory;
|
||||||
|
self.downloadPath = [temporaryDirectory stringByAppendingPathComponent:destinationName];
|
||||||
NSString *appCachePath = [self appCachePath];
|
|
||||||
|
|
||||||
self.tempDir = [appCachePath stringByAppendingPathComponent:downloadFileName];
|
|
||||||
int cnt = 1;
|
|
||||||
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
|
||||||
{
|
|
||||||
self.tempDir = [appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the temporary directory if necessary.
|
|
||||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:self.tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
// Okay, something's really broken with this user's file structure.
|
|
||||||
[self.download cancel];
|
|
||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", self.tempDir] }]];
|
|
||||||
}
|
|
||||||
|
|
||||||
self.downloadPath = [self.tempDir stringByAppendingPathComponent:name];
|
|
||||||
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
|
||||||
{
|
{
|
||||||
|
// don't need to do anything here as there's no GUI with this driver (there can be with child classes)
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloaderDidReceiveDataOfLength:(uint64_t)__unused length
|
||||||
|
{
|
||||||
|
// don't need do anything here as there's no GUI with this driver (there can be with child classes)
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)__unused downloadData
|
||||||
|
{
|
||||||
|
// finished. downloadData should be nil as this was a permanent download
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updater:didDownloadUpdate:)]) {
|
||||||
|
[[updater delegate] updater:self.updater didDownloadUpdate:self.updateItem];
|
||||||
|
}
|
||||||
|
|
||||||
[self extractUpdate];
|
[self extractUpdate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
- (void)downloaderDidFailWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||||
if (!failingUrl) {
|
if (!failingUrl) {
|
||||||
failingUrl = [self.updateItem fileURL];
|
failingUrl = [self.updateItem fileURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
if ([[updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
||||||
[[updater delegate] updater:self.updater
|
[[updater delegate] updater:self.updater
|
||||||
failedToDownloadUpdate:self.updateItem
|
failedToDownloadUpdate:self.updateItem
|
||||||
error:error];
|
error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
||||||
NSUnderlyingErrorKey: error,
|
NSUnderlyingErrorKey: error,
|
||||||
}];
|
}];
|
||||||
if (failingUrl) {
|
if (failingUrl) {
|
||||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||||
}
|
}
|
||||||
@@ -334,43 +388,45 @@
|
|||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
|
||||||
{
|
|
||||||
// We don't want the download system to extract our gzips.
|
|
||||||
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
|
||||||
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)extractUpdate
|
- (void)extractUpdate
|
||||||
{
|
{
|
||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||||
|
|
||||||
BOOL success;
|
BOOL success = NO;
|
||||||
if (!unarchiver) {
|
if (!unarchiver) {
|
||||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||||
|
|
||||||
success = NO;
|
|
||||||
} else {
|
} 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
|
// 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];
|
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
|
||||||
|
|
||||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
|
if (needsPrevalidation) {
|
||||||
|
success = [self.updateValidator validateDownloadPath];
|
||||||
success = self.updateValidator.canValidate;
|
} else {
|
||||||
|
success = YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
|
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
|
||||||
[self unarchiverDidFailWithError:reason];
|
[self unarchiverDidFailWithError:reason];
|
||||||
} else {
|
} else {
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updater:willExtractUpdate:)]) {
|
||||||
|
[[updater delegate] updater:self.updater willExtractUpdate:self.updateItem];
|
||||||
|
}
|
||||||
|
|
||||||
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
|
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
|
||||||
if (err) {
|
if (err) {
|
||||||
[self unarchiverDidFailWithError:err];
|
[self unarchiverDidFailWithError:err];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updater:didExtractUpdate:)]) {
|
||||||
[self unarchiverDidFinish:nil];
|
[[updater delegate] updater:self.updater didExtractUpdate:self.updateItem];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self performSelectorOnMainThread:@selector(unarchiverDidFinish:) withObject:nil waitUntilDone:NO];
|
||||||
} progressBlock:^(double progress) {
|
} progressBlock:^(double progress) {
|
||||||
[self unarchiver:nil extractedProgress:progress];
|
[self unarchiver:nil extractedProgress:progress];
|
||||||
}];
|
}];
|
||||||
@@ -395,7 +451,7 @@
|
|||||||
- (void)unarchiverDidFinish:(id)__unused ua
|
- (void)unarchiverDidFinish:(id)__unused ua
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
|
||||||
[self installWithToolAndRelaunch:YES];
|
[self installWithToolAndRelaunch:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,12 +459,12 @@
|
|||||||
{
|
{
|
||||||
// No longer needed
|
// No longer needed
|
||||||
self.updateValidator = nil;
|
self.updateValidator = nil;
|
||||||
|
|
||||||
if ([self.updateItem isDeltaUpdate]) {
|
if ([self.updateItem isDeltaUpdate]) {
|
||||||
[self failedToApplyDeltaUpdate];
|
[self failedToApplyDeltaUpdate];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self abortUpdateWithError:err];
|
[self abortUpdateWithError:err];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +509,7 @@
|
|||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
assert(self.updateValidator);
|
assert(self.updateValidator);
|
||||||
|
|
||||||
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
||||||
if (!validationCheckSuccess) {
|
if (!validationCheckSuccess) {
|
||||||
NSDictionary *userInfo = @{
|
NSDictionary *userInfo = @{
|
||||||
@@ -474,35 +530,59 @@
|
|||||||
id<SUUpdaterPrivate> updater = self.updater;
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
static BOOL postponedOnce = NO;
|
static BOOL postponedOnce = NO;
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
if (!postponedOnce) {
|
||||||
{
|
if ([updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) {
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||||
[invocation setArgument:&relaunch atIndex:2];
|
[invocation setArgument:&relaunch atIndex:2];
|
||||||
[invocation setTarget:self];
|
[invocation setTarget:self];
|
||||||
postponedOnce = YES;
|
postponedOnce = YES;
|
||||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||||
return;
|
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:)]) {
|
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||||
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSBundle *sparkleBundle = updater.sparkleBundle;
|
NSBundle *sparkleBundle = updater.sparkleBundle;
|
||||||
|
if (!sparkleBundle) {
|
||||||
|
SULog(SULogLevelError, @"Sparkle bundle is gone?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||||
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
NSString *const relaunchToolSourceName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
||||||
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolSourceName ofType:@"app"];
|
||||||
NSString *relaunchCopyTargetPath = nil;
|
NSString *relaunchCopyTargetPath = nil;
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
BOOL copiedRelaunchPath = NO;
|
BOOL copiedRelaunchPath = NO;
|
||||||
|
|
||||||
|
if (!relaunchToolSourceName || ![relaunchToolSourceName length]) {
|
||||||
|
SULog(SULogLevelError, @"SPARKLE_RELAUNCH_TOOL_NAME not configued");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!relaunchToolSourcePath) {
|
||||||
|
SULog(SULogLevelError, @"Sparkle.framework is damaged. %@ is missing", relaunchToolSourceName);
|
||||||
|
}
|
||||||
|
|
||||||
if (relaunchToolSourcePath) {
|
if (relaunchToolSourcePath) {
|
||||||
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
|
NSString *hostBundleBaseName = [[self.host.bundlePath lastPathComponent] stringByDeletingPathExtension];
|
||||||
|
if (!hostBundleBaseName) {
|
||||||
|
SULog(SULogLevelError, @"Unable to get bundlePath");
|
||||||
|
hostBundleBaseName = @"Sparkle";
|
||||||
|
}
|
||||||
|
NSString *relaunchCopyBaseName = [NSString stringWithFormat:@"%@ (Autoupdate).app", hostBundleBaseName];
|
||||||
|
|
||||||
|
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:relaunchCopyBaseName];
|
||||||
|
|
||||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||||
|
|
||||||
@@ -518,7 +598,7 @@
|
|||||||
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
|
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
|
||||||
NSError *quarantineError = nil;
|
NSError *quarantineError = nil;
|
||||||
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -554,7 +634,10 @@
|
|||||||
pathToRelaunch = delegateRelaunchPath;
|
pathToRelaunch = delegateRelaunchPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set relaunching flag.
|
||||||
|
[self.host setBool:YES forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];
|
||||||
|
|
||||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||||
pathToRelaunch,
|
pathToRelaunch,
|
||||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||||
@@ -598,6 +681,9 @@
|
|||||||
|
|
||||||
- (void)abortUpdate
|
- (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];
|
[self cleanUpDownload];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
self.updateItem = nil;
|
self.updateItem = nil;
|
||||||
|
|||||||
@@ -190,6 +190,11 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
|||||||
|
|
||||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||||
uint16_t mode = ent->fts_statp->st_mode;
|
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 type = ent->fts_info;
|
||||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||||
|
|
||||||
@@ -242,7 +247,7 @@ BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
||||||
int (*changeModeFunc)(const char *, mode_t) = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
int (*changeModeFunc)(const char *, mode_t) = [(NSString *)[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
||||||
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ static NSDictionary *infoForFile(FTSENT *ent)
|
|||||||
INFO_SIZE_KEY: @(size) };
|
INFO_SIZE_KEY: @(size) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isSymLink(const FTSENT *ent)
|
||||||
|
{
|
||||||
|
if (ent->fts_info == FTS_SL)
|
||||||
|
{
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool aclExists(const FTSENT *ent)
|
static bool aclExists(const FTSENT *ent)
|
||||||
{
|
{
|
||||||
// macOS does not currently support ACLs for symlinks
|
// macOS does not currently support ACLs for symlinks
|
||||||
@@ -254,7 +263,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
|||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
||||||
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
|
fprintf(stderr, "Processing source, %s...", [source fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FTSENT *ent = 0;
|
FTSENT *ent = 0;
|
||||||
@@ -320,7 +329,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
|
fprintf(stderr, "\nProcessing destination, %s...", [destination fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pathBuffer[0] = 0;
|
pathBuffer[0] = 0;
|
||||||
@@ -371,14 +380,11 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
|||||||
// inside an application, and since we don't preserve extended attribitutes anyway
|
// inside an application, and since we don't preserve extended attribitutes anyway
|
||||||
|
|
||||||
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||||
if (!IS_VALID_PERMISSIONS(permissions)) {
|
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
|
||||||
|
permissions = 0755;
|
||||||
if (verbose) {
|
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)) {
|
if (aclExists(ent)) {
|
||||||
@@ -439,6 +445,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||||
|
if (verbose) {
|
||||||
|
fprintf(stderr, "\nWriting to temporary file %s...", [temporaryFile fileSystemRepresentation]);
|
||||||
|
}
|
||||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||||
if (!x) {
|
if (!x) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@@ -574,13 +583,19 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
|||||||
|
|
||||||
xar_close(x);
|
xar_close(x);
|
||||||
|
|
||||||
unlink([patchFile fileSystemRepresentation]);
|
NSFileManager *filemgr;
|
||||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
filemgr = [NSFileManager defaultManager];
|
||||||
unlink([temporaryFile fileSystemRepresentation]);
|
|
||||||
|
|
||||||
|
[filemgr removeItemAtPath: patchFile error: NULL];
|
||||||
|
if ([filemgr moveItemAtPath: temporaryFile toPath: patchFile error: NULL] != YES)
|
||||||
|
{
|
||||||
|
if (verbose) {
|
||||||
|
fprintf(stderr, "Failed to move temporary file, %s, to %s!\n", [temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nDone!\n");
|
fprintf(stderr, "\nDone!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -30,14 +30,14 @@ static void printUsage(NSString *programName)
|
|||||||
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
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) {
|
if (args.count < 3 || args.count > 5) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger numberOflagsFound = 0;
|
NSUInteger numberOfFlagsFound = 0;
|
||||||
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
||||||
NSUInteger versionIndex = NSNotFound;
|
NSUInteger versionIndex = NSNotFound;
|
||||||
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
|
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
|
||||||
@@ -48,13 +48,13 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verboseIndex != NSNotFound) {
|
if (verboseIndex != NSNotFound) {
|
||||||
++numberOflagsFound;
|
++numberOfFlagsFound;
|
||||||
}
|
}
|
||||||
if (versionIndex != NSNotFound) {
|
if (versionIndex != NSNotFound) {
|
||||||
++numberOflagsFound;
|
++numberOfFlagsFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.count - numberOflagsFound < 3) {
|
if (args.count - numberOfFlagsFound < 3) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
|||||||
BOOL verbose = (verboseIndex != NSNotFound);
|
BOOL verbose = (verboseIndex != NSNotFound);
|
||||||
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
||||||
|
|
||||||
NSArray *versionComponents = nil;
|
NSArray<NSString *> *versionComponents = nil;
|
||||||
if (versionField) {
|
if (versionField) {
|
||||||
versionComponents = [versionField componentsSeparatedByString:@"="];
|
versionComponents = [versionField componentsSeparatedByString:@"="];
|
||||||
if (versionComponents.count != 2) {
|
if (versionComponents.count != 2) {
|
||||||
@@ -124,7 +124,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
static BOOL runApplyCommand(NSString *programName, NSArray<NSString *> *args)
|
||||||
{
|
{
|
||||||
if (args.count < 3 || args.count > 4) {
|
if (args.count < 3 || args.count > 4) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
@@ -138,7 +138,7 @@ static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
NSMutableArray<NSString *> *fileArgs = [NSMutableArray array];
|
||||||
for (NSString *argument in args) {
|
for (NSString *argument in args) {
|
||||||
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
||||||
[fileArgs addObject:argument];
|
[fileArgs addObject:argument];
|
||||||
@@ -172,7 +172,7 @@ static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
static BOOL runVersionCommand(NSString *programName, NSArray<NSString *> *args)
|
||||||
{
|
{
|
||||||
if (args.count > 1) {
|
if (args.count > 1) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
@@ -218,7 +218,7 @@ static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
|||||||
int main(int __unused argc, char __unused *argv[])
|
int main(int __unused argc, char __unused *argv[])
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
|
||||||
NSString *programName = [args[0] lastPathComponent];
|
NSString *programName = [args[0] lastPathComponent];
|
||||||
|
|
||||||
if (args.count < 2) {
|
if (args.count < 2) {
|
||||||
@@ -227,7 +227,7 @@ int main(int __unused argc, char __unused *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSString *command = args[1];
|
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;
|
BOOL result;
|
||||||
if ([command isEqualToString:CREATE_COMMAND]) {
|
if ([command isEqualToString:CREATE_COMMAND]) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
return [[path pathExtension] isEqualToString:@"delta"];
|
return [[path pathExtension] isEqualToString:@"delta"];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
+ (BOOL)mustValidateBeforeExtraction
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,18 @@
|
|||||||
#ifndef SUCODESIGNINGVERIFIER_H
|
#ifndef SUCODESIGNINGVERIFIER_H
|
||||||
#define SUCODESIGNINGVERIFIER_H
|
#define SUCODESIGNINGVERIFIER_H
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
|
#import "SUExport.h"
|
||||||
|
|
||||||
@interface SUCodeSigningVerifier : NSObject
|
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
|
||||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||||
|
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -121,7 +121,22 @@ static id valueOrNSNull(id value) {
|
|||||||
return value ? value : [NSNull null];
|
return value ? value : [NSNull null];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath {
|
||||||
|
NSDictionary *info = nil;
|
||||||
|
SecStaticCodeRef code = NULL;
|
||||||
|
OSStatus result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundlePath, kSecCSDefaultFlags, &code);
|
||||||
|
if (result != noErr) {
|
||||||
|
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||||
|
goto finally;
|
||||||
|
}
|
||||||
|
info = [self codeSignatureInfoForCode:code];
|
||||||
|
|
||||||
|
finally:
|
||||||
|
if (code) CFRelease(code);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code {
|
||||||
CFDictionaryRef signingInfo = nil;
|
CFDictionaryRef signingInfo = nil;
|
||||||
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||||
@@ -133,8 +148,14 @@ static id valueOrNSNull(id value) {
|
|||||||
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
|
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
|
||||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
|
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
|
||||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
|
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
|
||||||
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
return [relevantInfo copy];
|
||||||
}
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||||
|
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
|
||||||
|
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Misc:
|
// Misc:
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
||||||
@@ -21,23 +21,28 @@ extern const NSTimeInterval SUDefaultUpdateCheckInterval;
|
|||||||
|
|
||||||
extern NSString *const SUBundleIdentifier;
|
extern NSString *const SUBundleIdentifier;
|
||||||
|
|
||||||
|
extern NSString *const SUAppcastAttributeValueMacOS;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Notifications:
|
// Notifications:
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern NSString *const SUTechnicalErrorInformationKey;
|
extern NSString *const SUTechnicalErrorInformationKey;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// PList keys::
|
// PList keys::
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern NSString *const SUFeedURLKey;
|
extern NSString *const SUFeedURLKey;
|
||||||
extern NSString *const SUHasLaunchedBeforeKey;
|
extern NSString *const SUHasLaunchedBeforeKey;
|
||||||
|
extern NSString *const SUUpdateRelaunchingMarkerKey;
|
||||||
extern NSString *const SUShowReleaseNotesKey;
|
extern NSString *const SUShowReleaseNotesKey;
|
||||||
extern NSString *const SUSkippedVersionKey;
|
extern NSString *const SUSkippedVersionKey;
|
||||||
extern NSString *const SUScheduledCheckIntervalKey;
|
extern NSString *const SUScheduledCheckIntervalKey;
|
||||||
extern NSString *const SULastCheckTimeKey;
|
extern NSString *const SULastCheckTimeKey;
|
||||||
extern NSString *const SUExpectsDSASignatureKey;
|
extern NSString *const SUExpectsDSASignatureKey;
|
||||||
|
extern NSString *const SUExpectsEDSignatureKey;
|
||||||
|
extern NSString *const SUPublicEDKeyKey;
|
||||||
extern NSString *const SUPublicDSAKeyKey;
|
extern NSString *const SUPublicDSAKeyKey;
|
||||||
extern NSString *const SUPublicDSAKeyFileKey;
|
extern NSString *const SUPublicDSAKeyFileKey;
|
||||||
extern NSString *const SUAutomaticallyUpdateKey;
|
extern NSString *const SUAutomaticallyUpdateKey;
|
||||||
@@ -45,9 +50,9 @@ extern NSString *const SUAllowsAutomaticUpdatesKey;
|
|||||||
extern NSString *const SUEnableAutomaticChecksKey;
|
extern NSString *const SUEnableAutomaticChecksKey;
|
||||||
extern NSString *const SUEnableSystemProfilingKey;
|
extern NSString *const SUEnableSystemProfilingKey;
|
||||||
extern NSString *const SUSendProfileInfoKey;
|
extern NSString *const SUSendProfileInfoKey;
|
||||||
|
extern NSString *const SUUpdateGroupIdentifierKey;
|
||||||
extern NSString *const SULastProfileSubmitDateKey;
|
extern NSString *const SULastProfileSubmitDateKey;
|
||||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
|
||||||
extern NSString *const SUDefaultsDomainKey;
|
extern NSString *const SUDefaultsDomainKey;
|
||||||
extern NSString *const SUEnableJavaScriptKey;
|
extern NSString *const SUEnableJavaScriptKey;
|
||||||
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
|
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
|
||||||
@@ -57,13 +62,16 @@ extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((dep
|
|||||||
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
|
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 SUAppcastAttributeDeltaFrom;
|
||||||
extern NSString *const SUAppcastAttributeDSASignature;
|
extern NSString *const SUAppcastAttributeDSASignature;
|
||||||
|
extern NSString *const SUAppcastAttributeEDSignature;
|
||||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||||
extern NSString *const SUAppcastAttributeVersion;
|
extern NSString *const SUAppcastAttributeVersion;
|
||||||
|
extern NSString *const SUAppcastAttributeOsType;
|
||||||
|
extern NSString *const SUAppcastAttributePhasedRolloutInterval;
|
||||||
|
|
||||||
extern NSString *const SUAppcastElementCriticalUpdate;
|
extern NSString *const SUAppcastElementCriticalUpdate;
|
||||||
extern NSString *const SUAppcastElementDeltas;
|
extern NSString *const SUAppcastElementDeltas;
|
||||||
@@ -81,4 +89,6 @@ extern NSString *const SURSSElementLink;
|
|||||||
extern NSString *const SURSSElementPubDate;
|
extern NSString *const SURSSElementPubDate;
|
||||||
extern NSString *const SURSSElementTitle;
|
extern NSString *const SURSSElementTitle;
|
||||||
|
|
||||||
|
extern NSString *const SUXMLLanguage;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -21,15 +21,20 @@ const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
|||||||
|
|
||||||
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
|
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
|
||||||
|
|
||||||
|
NSString *const SUAppcastAttributeValueMacOS = @"macos";
|
||||||
|
|
||||||
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
|
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
|
||||||
|
|
||||||
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
|
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
|
||||||
|
NSString *const SUUpdateRelaunchingMarkerKey = @"SUUpdateRelaunchingMarker";
|
||||||
NSString *const SUFeedURLKey = @"SUFeedURL";
|
NSString *const SUFeedURLKey = @"SUFeedURL";
|
||||||
NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes";
|
NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes";
|
||||||
NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
|
NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
|
||||||
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
||||||
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
|
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
|
||||||
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
||||||
|
NSString *const SUExpectsEDSignatureKey = @"SUExpectsEDSignatureKey";
|
||||||
|
NSString *const SUPublicEDKeyKey = @"SUPublicEDKey";
|
||||||
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
||||||
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
||||||
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||||
@@ -37,11 +42,11 @@ NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
|||||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||||
|
NSString *const SUUpdateGroupIdentifierKey = @"SUUpdateGroupIdentifier";
|
||||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||||
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
||||||
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
||||||
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
|
||||||
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
||||||
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
|
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
|
||||||
|
|
||||||
@@ -52,8 +57,11 @@ NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
|
|||||||
|
|
||||||
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
||||||
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
||||||
|
NSString *const SUAppcastAttributeEDSignature = @"sparkle:edSignature";
|
||||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||||
|
NSString *const SUAppcastAttributeOsType = @"sparkle:os";
|
||||||
|
NSString *const SUAppcastAttributePhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
|
||||||
|
|
||||||
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
||||||
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
||||||
@@ -70,3 +78,5 @@ NSString *const SURSSElementEnclosure = @"enclosure";
|
|||||||
NSString *const SURSSElementLink = @"link";
|
NSString *const SURSSElementLink = @"link";
|
||||||
NSString *const SURSSElementPubDate = @"pubDate";
|
NSString *const SURSSElementPubDate = @"pubDate";
|
||||||
NSString *const SURSSElementTitle = @"title";
|
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 = [[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"];
|
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
+ (BOOL)mustValidateBeforeExtraction
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
// Called on a non-main thread.
|
// Called on a non-main thread.
|
||||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
BOOL mountedSuccessfully = NO;
|
BOOL mountedSuccessfully = NO;
|
||||||
|
|
||||||
// get a unique mount point path
|
// get a unique mount point path
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
NSError *error;
|
NSError *error;
|
||||||
NSArray *contents;
|
NSArray *contents;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||||
@@ -135,8 +135,8 @@
|
|||||||
|
|
||||||
[notifier notifyProgress:0.5];
|
[notifier notifyProgress:0.5];
|
||||||
|
|
||||||
if (taskResult != 0)
|
if (taskResult != 0)
|
||||||
{
|
{
|
||||||
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
||||||
SULog(SULogLevelError, @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
SULog(SULogLevelError, @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
||||||
goto reportError;
|
goto reportError;
|
||||||
@@ -155,8 +155,8 @@
|
|||||||
double itemsCopied = 0;
|
double itemsCopied = 0;
|
||||||
double totalItems = [contents count];
|
double totalItems = [contents count];
|
||||||
|
|
||||||
for (NSString *item in contents)
|
for (NSString *item in contents)
|
||||||
{
|
{
|
||||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||||
|
|
||||||
@@ -169,8 +169,8 @@
|
|||||||
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||||
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||||
|
|
||||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||||
{
|
{
|
||||||
goto reportError;
|
goto reportError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,15 @@
|
|||||||
*/
|
*/
|
||||||
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
|
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
typedef NS_ENUM(OSStatus, SUError) {
|
typedef NS_ENUM(OSStatus, SUError) {
|
||||||
// Appcast phase errors.
|
// Appcast phase errors.
|
||||||
SUAppcastParseError = 1000,
|
SUAppcastParseError = 1000,
|
||||||
SUNoUpdateError = 1001,
|
SUNoUpdateError = 1001,
|
||||||
SUAppcastError = 1002,
|
SUAppcastError = 1002,
|
||||||
SURunningFromDiskImageError = 1003,
|
SURunningFromDiskImageError = 1003,
|
||||||
|
SURunningTranslocated = 1004,
|
||||||
|
|
||||||
// Download phase errors.
|
// Download phase errors.
|
||||||
SUTemporaryDirectoryError = 2000,
|
SUTemporaryDirectoryError = 2000,
|
||||||
@@ -49,5 +52,6 @@ typedef NS_ENUM(OSStatus, SUError) {
|
|||||||
// System phase errors
|
// System phase errors
|
||||||
SUSystemPowerOffError = 5000
|
SUSystemPowerOffError = 5000
|
||||||
};
|
};
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -7,10 +7,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "SUFileManager.h"
|
#import "SUFileManager.h"
|
||||||
#import "SUErrors.h"
|
|
||||||
#import "SUOperatingSystem.h"
|
#import "SUOperatingSystem.h"
|
||||||
#import "SUFileOperationConstants.h"
|
#import "SUFileOperationConstants.h"
|
||||||
|
|
||||||
|
#import "SUErrors.h"
|
||||||
|
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -71,12 +72,12 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
|
|
||||||
+ (instancetype)defaultManager
|
+ (instancetype)defaultManager
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithAuthorizationToolPath:nil];
|
return [(SUFileManager *)[self alloc] initWithAuthorizationToolPath:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath
|
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath
|
||||||
{
|
{
|
||||||
return [[self alloc] initWithAuthorizationToolPath:authorizationToolPath];
|
return [(SUFileManager *)[self alloc] initWithAuthorizationToolPath:authorizationToolPath];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)fileManagerByPreservingAuthorizationRights
|
- (instancetype)fileManagerByPreservingAuthorizationRights
|
||||||
@@ -109,20 +110,20 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
_auth = NULL;
|
_auth = NULL;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthorizationItem rightItems[] = {
|
AuthorizationItem rightItems[] = {
|
||||||
// The right that allows us to run tools as root user
|
// The right that allows us to run tools as root user
|
||||||
{.name = kAuthorizationRightExecute, .valueLength = 0, .value = NULL, .flags = 0}
|
{.name = kAuthorizationRightExecute, .valueLength = 0, .value = NULL, .flags = 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
AuthorizationRights rights = {
|
AuthorizationRights rights = {
|
||||||
.count = sizeof(rightItems) / sizeof(*rightItems),
|
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||||
.items = rightItems
|
.items = rightItems
|
||||||
};
|
};
|
||||||
|
|
||||||
AuthorizationFlags flags =
|
AuthorizationFlags flags =
|
||||||
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||||
|
|
||||||
// This will test if we can gain authorization for running utlities as root
|
// This will test if we can gain authorization for running utlities as root
|
||||||
OSStatus copyStatus = AuthorizationCopyRights(_auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
OSStatus copyStatus = AuthorizationCopyRights(_auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||||
if (copyStatus != errAuthorizationSuccess) {
|
if (copyStatus != errAuthorizationSuccess) {
|
||||||
@@ -133,13 +134,13 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed granting authorization rights with status code %d.", copyStatus] }];
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed granting authorization rights with status code %d.", copyStatus] }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
||||||
_auth = NULL;
|
_auth = NULL;
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +157,9 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *arguments[] = { command, sourcePath, destinationPath, NULL };
|
char *arguments[] = { command, sourcePath, destinationPath, NULL };
|
||||||
|
|
||||||
char toolPath[PATH_MAX] = {0};
|
char toolPath[PATH_MAX] = {0};
|
||||||
if (![_authorizationToolPath getFileSystemRepresentation:toolPath maxLength:sizeof(toolPath)]) {
|
if (![_authorizationToolPath getFileSystemRepresentation:toolPath maxLength:sizeof(toolPath)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -166,7 +167,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *pipe = NULL;
|
FILE *pipe = NULL;
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
@@ -174,11 +175,14 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
if (runStatus != errAuthorizationSuccess) {
|
if (runStatus != errAuthorizationSuccess) {
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to run authorization tool %s (%d).", toolPath, (int)runStatus] }];
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcstring-format-directive"
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to run authorization tool %s (error code %d).", toolPath, (int)runStatus] }];
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pidData = 0;
|
uint32_t pidData = 0;
|
||||||
if (fread(&pidData, sizeof(pidData), 1, pipe) < 1) {
|
if (fread(&pidData, sizeof(pidData), 1, pipe) < 1) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -187,7 +191,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
fclose(pipe);
|
fclose(pipe);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineCallback) {
|
if (lineCallback) {
|
||||||
NSFileHandle *pipeHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileno(pipe) closeOnDealloc:NO];
|
NSFileHandle *pipeHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileno(pipe) closeOnDealloc:NO];
|
||||||
[self parseLines:pipeHandle lineCallback:lineCallback];
|
[self parseLines:pipeHandle lineCallback:lineCallback];
|
||||||
@@ -195,21 +199,21 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
|
|
||||||
pid_t childPid = (int32_t)CFSwapInt32LittleToHost(pidData);
|
pid_t childPid = (int32_t)CFSwapInt32LittleToHost(pidData);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
pid_t waitResult;
|
pid_t waitResult;
|
||||||
do {
|
do {
|
||||||
waitResult = waitpid(childPid, &status, 0);
|
waitResult = waitpid(childPid, &status, 0);
|
||||||
} while (waitResult == -1 && errno == EINTR);
|
} while (waitResult == -1 && errno == EINTR);
|
||||||
|
|
||||||
fclose(pipe);
|
fclose(pipe);
|
||||||
|
|
||||||
if (waitResult == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
if (waitResult == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to execute authorized executable with result %d and status (%d, %d, %d).", waitResult, status, WIFEXITED(status), WEXITSTATUS(status)] }];
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to execute authorized executable with result %d and status (%d, %d, %d).", waitResult, status, WIFEXITED(status), WEXITSTATUS(status)] }];
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +270,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isDirectory != NULL) {
|
if (isDirectory != NULL) {
|
||||||
*isDirectory = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory];
|
*isDirectory = [(NSString *)[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory];
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
@@ -301,7 +305,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
- (BOOL)_removeQuarantineWithAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
|
- (BOOL)_removeQuarantineWithAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
// Because this is a system utility, it's fine to follow the symbolic link if one exists
|
// Because this is a system utility, it's fine to follow the symbolic link if one exists
|
||||||
if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) {
|
if (![_fileManager fileExistsAtPath:(NSString *)@(XATTR_UTILITY_PATH)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"xattr utility does not exist on this system." }];
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"xattr utility does not exist on this system." }];
|
||||||
}
|
}
|
||||||
@@ -315,7 +319,9 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to remove quarantine %@", rootURL);
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveQuarantineCommand sourcePath:path destinationPath:NULL error:&executeError];
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveQuarantineCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
if (!success && error != NULL) {
|
if (!success && error != NULL) {
|
||||||
@@ -513,7 +519,9 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to copy %@ to %@", sourceURL, destinationURL);
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
if (![self _authorizeAndExecuteCommand:SUFileOpCopyCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
if (![self _authorizeAndExecuteCommand:SUFileOpCopyCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -606,6 +614,8 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to move %@ to %@", sourceURL, destinationURL);
|
||||||
|
|
||||||
char sourcePath[PATH_MAX] = {0};
|
char sourcePath[PATH_MAX] = {0};
|
||||||
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -621,7 +631,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
if (![self _authorizeAndExecuteCommand:SUFileOpMoveCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
if (![self _authorizeAndExecuteCommand:SUFileOpMoveCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -651,11 +661,11 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use fchown instead of chown because the latter can follow symbolic links
|
// We use fchown instead of chown because the latter can follow symbolic links
|
||||||
BOOL success = fchown(fileDescriptor, ownerID.unsignedIntValue, groupID.unsignedIntValue) == 0;
|
BOOL success = fchown(fileDescriptor, ownerID.unsignedIntValue, groupID.unsignedIntValue) == 0;
|
||||||
close(fileDescriptor);
|
close(fileDescriptor);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (errno == EPERM) {
|
if (errno == EPERM) {
|
||||||
if (needsAuth != NULL) {
|
if (needsAuth != NULL) {
|
||||||
@@ -766,7 +776,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
char matchPath[PATH_MAX] = {0};
|
char matchPath[PATH_MAX] = {0};
|
||||||
if (![matchURLPath getFileSystemRepresentation:matchPath maxLength:sizeof(matchPath)]) {
|
if (![matchURLPath getFileSystemRepresentation:matchPath maxLength:sizeof(matchPath)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -775,6 +785,8 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to change permissions of %@ to match %@", targetURL, matchURL);
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpChangeOwnerAndGroupCommand sourcePath:targetPath destinationPath:matchPath error:&executeError];
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpChangeOwnerAndGroupCommand sourcePath:targetPath destinationPath:matchPath error:&executeError];
|
||||||
if (!success && error != NULL) {
|
if (!success && error != NULL) {
|
||||||
@@ -815,12 +827,12 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using futimes() because utimes() follows symbolic links
|
// Using futimes() because utimes() follows symbolic links
|
||||||
BOOL updatedTime = (futimes(fileDescriptor, NULL) == 0);
|
BOOL updatedTime = (futimes(fileDescriptor, NULL) == 0);
|
||||||
|
|
||||||
close(fileDescriptor);
|
close(fileDescriptor);
|
||||||
|
|
||||||
if (updatedTime) {
|
if (updatedTime) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -831,7 +843,9 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to update timestamp of %@", targetURL);
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpUpdateModificationAndAccessTimeCommand sourcePath:path destinationPath:NULL error:&executeError];
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpUpdateModificationAndAccessTimeCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
if (!success && error != NULL) {
|
if (!success && error != NULL) {
|
||||||
@@ -874,6 +888,8 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to make directory %@", url);
|
||||||
|
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -881,7 +897,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpMakeDirectoryCommand sourcePath:path destinationPath:NULL error:&executeError];
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpMakeDirectoryCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@@ -890,7 +906,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,6 +952,8 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to delete %@", url);
|
||||||
|
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -943,14 +961,14 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveCommand sourcePath:path destinationPath:NULL error:&executeError];
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
|
|
||||||
if (!success && error != NULL) {
|
if (!success && error != NULL) {
|
||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent], NSUnderlyingErrorKey: executeError }];
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent], NSUnderlyingErrorKey: executeError }];
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,7 +981,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
if (![packageURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
if (![packageURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
@@ -971,14 +989,16 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
|||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSLog(@"Sparkle: Authorization required to run pkg installer %@", packageURL);
|
||||||
|
|
||||||
NSError *executeError = nil;
|
NSError *executeError = nil;
|
||||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpInstallCommand sourcePath:path destinationPath:NULL lineCallback:^(NSString *line){
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpInstallCommand sourcePath:path destinationPath:NULL lineCallback:^(NSString *line){
|
||||||
if ([line hasPrefix:@"installer:%"]) {
|
if ([line hasPrefix:@"installer:%"]) {
|
||||||
progressBlock([[line substringFromIndex:11] doubleValue]/100.0);
|
progressBlock([[line substringFromIndex:11] doubleValue]/100.0);
|
||||||
}
|
}
|
||||||
} error:&executeError];
|
} error:&executeError];
|
||||||
|
|
||||||
if (!success && error != NULL) {
|
if (!success && error != NULL) {
|
||||||
NSString* errorMessage = @"Failed to execute package installer.";
|
NSString* errorMessage = @"Failed to execute package installer.";
|
||||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError}];
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError}];
|
||||||
|
|||||||
@@ -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>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class SUPublicKeys;
|
||||||
|
|
||||||
@interface SUHost : NSObject
|
@interface SUHost : NSObject
|
||||||
|
|
||||||
@property (strong, readonly) NSBundle *bundle;
|
@property (strong, readonly) NSBundle *bundle;
|
||||||
@@ -16,16 +20,20 @@
|
|||||||
@property (readonly, copy) NSString *name;
|
@property (readonly, copy) NSString *name;
|
||||||
@property (readonly, copy) NSString *version;
|
@property (readonly, copy) NSString *version;
|
||||||
@property (readonly, copy) NSString *displayVersion;
|
@property (readonly, copy) NSString *displayVersion;
|
||||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
@property (readonly) SUPublicKeys *publicKeys;
|
||||||
@property (readonly, copy) NSString *publicDSAKey;
|
|
||||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
|
||||||
|
|
||||||
- (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;
|
- (BOOL)boolForInfoDictionaryKey:(NSString *)key;
|
||||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName;
|
- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName;
|
||||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName;
|
- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName;
|
||||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName;
|
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName;
|
||||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName;
|
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName;
|
||||||
- (id)objectForKey:(NSString *)key;
|
- (nullable id)objectForKey:(NSString *)key;
|
||||||
- (BOOL)boolForKey:(NSString *)key;
|
- (BOOL)boolForKey:(NSString *)key;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -10,10 +10,12 @@
|
|||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
#import "SUSignatures.h"
|
||||||
|
|
||||||
#include "AppKitPrevention.h"
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
// This class should not rely on AppKit and should also be process independent
|
// 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,
|
// 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
|
// 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 (strong, readwrite) NSBundle *bundle;
|
||||||
@property (nonatomic, readonly) BOOL isMainBundle;
|
@property (nonatomic, readonly) BOOL isMainBundle;
|
||||||
@property (copy) NSString *defaultsDomain;
|
@property (copy, nullable) NSString *defaultsDomain;
|
||||||
@property (assign) BOOL usesStandardUserDefaults;
|
@property (assign) BOOL usesStandardUserDefaults;
|
||||||
|
@property (readonly, copy, nullable) NSString *publicDSAKey;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -38,8 +41,8 @@
|
|||||||
|
|
||||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
NSParameterAssert(aBundle);
|
NSParameterAssert(aBundle);
|
||||||
self.bundle = aBundle;
|
self.bundle = aBundle;
|
||||||
if (![self.bundle bundleIdentifier]) {
|
if (![self.bundle bundleIdentifier]) {
|
||||||
@@ -68,7 +71,7 @@
|
|||||||
return [self.bundle bundlePath];
|
return [self.bundle bundlePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)name
|
- (NSString *)name
|
||||||
{
|
{
|
||||||
NSString *name;
|
NSString *name;
|
||||||
|
|
||||||
@@ -77,15 +80,15 @@
|
|||||||
if (name && name.length > 0) return name;
|
if (name && name.length > 0) return name;
|
||||||
|
|
||||||
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||||
if (name && name.length > 0) return name;
|
if (name && name.length > 0) return name;
|
||||||
|
|
||||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
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.bundle bundlePath]] stringByDeletingPathExtension];
|
return [[[NSFileManager defaultManager] displayNameAtPath:[self bundlePath]] stringByDeletingPathExtension];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)version
|
- (NSString *)version
|
||||||
{
|
{
|
||||||
NSString *version = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
NSString *version = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||||
if (!version || [version isEqualToString:@""])
|
if (!version || [version isEqualToString:@""])
|
||||||
@@ -93,7 +96,7 @@
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)displayVersion
|
- (NSString *)displayVersion
|
||||||
{
|
{
|
||||||
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||||
if (shortVersionString)
|
if (shortVersionString)
|
||||||
@@ -109,17 +112,29 @@
|
|||||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
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
|
- (NSString *__nullable)publicDSAKey
|
||||||
{
|
{
|
||||||
// Maybe the key is just a string in the Info.plist.
|
// Maybe the key is just a string in the Info.plist.
|
||||||
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||||
if (key) {
|
if (key) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// More likely, we've got a reference to a Resources file by filename:
|
// More likely, we've got a reference to a Resources file by filename:
|
||||||
NSString *keyFilename = [self publicDSAKeyFileKey];
|
NSString *keyFilename = [self publicDSAKeyFileKey];
|
||||||
if (!keyFilename) {
|
if (!keyFilename) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +142,17 @@
|
|||||||
if (!keyPath) {
|
if (!keyPath) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
NSError *error = nil;
|
||||||
|
key = [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:&error];
|
||||||
|
if (error) {
|
||||||
|
SULog(SULogLevelError, @"Error loading %@: %@", keyPath, error);
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (SUPublicKeys *)publicKeys
|
||||||
|
{
|
||||||
|
return [[SUPublicKeys alloc] initWithDsa:[self publicDSAKey] ed:[self publicEDKey]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString * __nullable)publicDSAKeyFileKey
|
- (NSString * __nullable)publicDSAKeyFileKey
|
||||||
@@ -135,7 +160,7 @@
|
|||||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
- (nullable id)objectForInfoDictionaryKey:(NSString *)key
|
||||||
{
|
{
|
||||||
if (self.isMainBundle) {
|
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
|
// Common fast path - if we're updating the main bundle, that means our updater and host bundle's lifetime is the same
|
||||||
@@ -156,10 +181,10 @@
|
|||||||
|
|
||||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
||||||
{
|
{
|
||||||
return [[self objectForInfoDictionaryKey:key] boolValue];
|
return [(NSNumber *)[self objectForInfoDictionaryKey:key] boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName
|
- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||||
{
|
{
|
||||||
if (!defaultName || !self.defaultsDomain) {
|
if (!defaultName || !self.defaultsDomain) {
|
||||||
return nil;
|
return nil;
|
||||||
@@ -177,14 +202,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note this handles nil being passed for defaultName, in which case the user default will be removed
|
// 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];
|
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||||
}
|
}
|
||||||
@@ -200,10 +225,10 @@
|
|||||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||||
if (plr == NULL) {
|
if (plr == NULL) {
|
||||||
value = NO;
|
value = NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
value = CFBooleanGetValue((CFBooleanRef)plr) ? YES : NO;
|
||||||
CFRelease(plr);
|
CFRelease(plr);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -211,18 +236,18 @@
|
|||||||
|
|
||||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
||||||
{
|
{
|
||||||
if (self.usesStandardUserDefaults)
|
if (self.usesStandardUserDefaults)
|
||||||
{
|
{
|
||||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||||
CFPreferencesSynchronize((__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];
|
return [self objectForUserDefaultsKey:key] ? [self objectForUserDefaultsKey:key] : [self objectForInfoDictionaryKey:key];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,3 +256,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -152,8 +152,14 @@
|
|||||||
{
|
{
|
||||||
NSBundle *bundle = host.bundle;
|
NSBundle *bundle = host.bundle;
|
||||||
assert(bundle != nil);
|
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
|
// Roundtrip string through fileSystemRepresentation to ensure it uses filesystem's Unicode normalization
|
||||||
// rather than arbitrary Unicode form from Info.plist - #1017
|
// rather than arbitrary Unicode form from Info.plist - #1017
|
||||||
|
|||||||
@@ -7,15 +7,29 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "SULog.h"
|
#include "SULog.h"
|
||||||
|
|
||||||
#include <asl.h>
|
#include <asl.h>
|
||||||
|
#include <Availability.h>
|
||||||
|
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
|
||||||
#include <os/log.h>
|
#include <os/log.h>
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef struct os_log_s *os_log_t;
|
||||||
|
#define os_log_create(subsystem, category) nil
|
||||||
|
|
||||||
|
#define os_log(log, format, ...)
|
||||||
|
#define os_log_error(log, format, ...)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
#import "SUOperatingSystem.h"
|
#import "SUOperatingSystem.h"
|
||||||
|
|
||||||
// For converting constants to string literals using the preprocessor
|
// For converting constants to string literals using the preprocessor
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define TO_STRING(x) STRINGIFY(x)
|
#define TO_STRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
#include "AppKitPrevention.h"
|
|
||||||
|
|
||||||
void SULog(SULogLevel level, NSString *format, ...)
|
void SULog(SULogLevel level, NSString *format, ...)
|
||||||
{
|
{
|
||||||
@@ -30,6 +44,9 @@ void SULog(SULogLevel level, NSString *format, ...)
|
|||||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||||
|
|
||||||
hasOSLogging = [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 12, 0}];
|
hasOSLogging = [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 12, 0}];
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200
|
||||||
|
hasOSLogging = NO;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hasOSLogging) {
|
if (hasOSLogging) {
|
||||||
const char *subsystem = SPARKLE_BUNDLE_IDENTIFIER;
|
const char *subsystem = SPARKLE_BUNDLE_IDENTIFIER;
|
||||||
@@ -43,10 +60,10 @@ void SULog(SULogLevel level, NSString *format, ...)
|
|||||||
// Act the same way os_log() does; don't log to stderr if a terminal device is attached
|
// Act the same way os_log() does; don't log to stderr if a terminal device is attached
|
||||||
if (!isatty(STDERR_FILENO)) {
|
if (!isatty(STDERR_FILENO)) {
|
||||||
options |= ASL_OPT_STDERR;
|
options |= ASL_OPT_STDERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *displayName = [[NSFileManager defaultManager] displayNameAtPath:mainBundle.bundlePath];
|
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);
|
queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -77,10 +94,10 @@ void SULog(SULogLevel level, NSString *format, ...)
|
|||||||
// See docs for OS_LOG_TYPE_ERROR
|
// See docs for OS_LOG_TYPE_ERROR
|
||||||
os_log_error(logger, "%{public}@", logMessage);
|
os_log_error(logger, "%{public}@", logMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise use ASL
|
// Otherwise use ASL
|
||||||
// Make sure we do not async, because if we async, the log may not be delivered deterministically
|
// Make sure we do not async, because if we async, the log may not be delivered deterministically
|
||||||
|
|||||||
@@ -22,3 +22,9 @@ typedef struct {
|
|||||||
+ (NSString *)systemVersionString;
|
+ (NSString *)systemVersionString;
|
||||||
|
|
||||||
@end
|
@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
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"];
|
NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"];
|
||||||
assert(url != nil);
|
assert(url != nil);
|
||||||
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];
|
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];
|
||||||
NSArray *components = [ [dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."];
|
NSArray<NSString *> *components = [ (NSString *)[dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."];
|
||||||
version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0;
|
version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0;
|
||||||
version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0;
|
version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0;
|
||||||
version.patchVersion = components.count > 2 ? [ [components objectAtIndex:2] integerValue] : 0;
|
version.patchVersion = components.count > 2 ? [ [components objectAtIndex:2] integerValue] : 0;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
|||||||
// -W = wait until the app has quit.
|
// -W = wait until the app has quit.
|
||||||
// -n = Open another instance if already open.
|
// -n = Open another instance if already open.
|
||||||
// -b = app bundle identifier
|
// -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.
|
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||||
@try {
|
@try {
|
||||||
|
|||||||