Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
021950a5b2 | ||
|
|
2ff0da4f15 | ||
|
|
945968a0ef | ||
|
|
1e4f126f7e | ||
|
|
f47115d81f | ||
|
|
49781561f3 | ||
|
|
1587dd1dc3 | ||
|
|
c0b9eaaa0e | ||
|
|
91ac90ffcf | ||
|
|
8375922755 | ||
|
|
9dec304f64 | ||
|
|
8acd915b7b | ||
|
|
eb36100388 | ||
|
|
fb22a01a08 | ||
|
|
9a32766aeb | ||
|
|
fc468771c1 | ||
|
|
42dbf94738 | ||
|
|
86a0ca3883 | ||
|
|
ddb53f330d | ||
|
|
9dbaae64f1 | ||
|
|
d2f4687333 | ||
|
|
143045d673 | ||
|
|
d67351cb62 | ||
|
|
07d2897250 | ||
|
|
625c942561 | ||
|
|
bb299d075b | ||
|
|
73229f84f7 | ||
|
|
8152516b7f | ||
|
|
96baf2b2ce | ||
|
|
ed5dca3423 | ||
|
|
3a5c620b60 | ||
|
|
23ae527b96 | ||
|
|
2268f96759 | ||
|
|
898e063b4f | ||
|
|
e8f88bf0f1 | ||
|
|
a3407a2dbf | ||
|
|
88933a1e65 | ||
|
|
c3d8e4bbc5 | ||
|
|
f70c2a15b1 | ||
|
|
4eb518de7e | ||
|
|
5b2ce958bd | ||
|
|
077c64419f | ||
|
|
1195d4b5d2 | ||
|
|
c7a7704f3b | ||
|
|
64af6d04c2 | ||
|
|
0af27ea783 | ||
|
|
c36413ce46 | ||
|
|
13b9081873 | ||
|
|
3dccca8044 | ||
|
|
e28c62244a | ||
|
|
fec76fee12 | ||
|
|
ed3eab64d2 | ||
|
|
ee257c4070 | ||
|
|
bfec7a82c0 | ||
|
|
4cd472abe6 | ||
|
|
39268a13e5 | ||
|
|
4864dfb5aa | ||
|
|
71125e3d16 | ||
|
|
779d16e5a7 | ||
|
|
ee2e7fb46b | ||
|
|
d350cf33e0 | ||
|
|
20be93e96b | ||
|
|
668e258cff | ||
|
|
20f90f1544 | ||
|
|
6dbb0d9988 | ||
|
|
f700c96e47 | ||
|
|
626d2c96f5 | ||
|
|
5db4e1505b | ||
|
|
115686cd07 | ||
|
|
e2fc8b4258 | ||
|
|
99f34299f1 | ||
|
|
fdf79bc3a6 | ||
|
|
eb810c7d8f | ||
|
|
38af7cd8cd | ||
|
|
09889d01b1 | ||
|
|
5f2ebb8edf | ||
|
|
ac4ef7d9a0 | ||
|
|
cc7c0ae052 | ||
|
|
b8dc5b3f3d | ||
|
|
43e96f7ee8 | ||
|
|
dbff23ea9d | ||
|
|
ed97e6cb75 | ||
|
|
492664c611 | ||
|
|
fdf07644d0 | ||
|
|
092feba9f9 | ||
|
|
91c813b6ab | ||
|
|
1ced9c428a | ||
|
|
16de00d81d | ||
|
|
3f637c9674 | ||
|
|
4a4dc3629f | ||
|
|
6437e0448a | ||
|
|
c77cd49036 | ||
|
|
9d7e4d676d | ||
|
|
1aa0ee8152 | ||
|
|
9944f2496c | ||
|
|
33907ec4ed | ||
|
|
7892e41b27 | ||
|
|
53983d9452 | ||
|
|
f3a151d473 | ||
|
|
bb624ffa59 | ||
|
|
2963f788e1 | ||
|
|
9017962ab9 | ||
|
|
dd0805c05b | ||
|
|
e4c3c29a85 | ||
|
|
be1e86174a | ||
|
|
8b56fba39b | ||
|
|
db232a263b | ||
|
|
4d952e9961 | ||
|
|
64fd27d918 | ||
|
|
666e86b0bb | ||
|
|
601b4a7a7f | ||
|
|
1316707136 | ||
|
|
e485baf8b8 | ||
|
|
d71fe4a17d | ||
|
|
f990f5fcfc | ||
|
|
07ac154e2e | ||
|
|
48eb25fbf3 | ||
|
|
914bf9e333 | ||
|
|
271b7a1daf | ||
|
|
c11c660f22 | ||
|
|
0e2fe68399 | ||
|
|
852965d824 | ||
|
|
e2c60be805 | ||
|
|
71e15f4b1d | ||
|
|
8a4e4aea2c | ||
|
|
8fea6670c2 | ||
|
|
19fcca11f0 | ||
|
|
fd082a93d4 | ||
|
|
b9e8830f60 | ||
|
|
8576eb7cad | ||
|
|
cf4c02f1b0 | ||
|
|
8e57ca9284 | ||
|
|
3c2f24c340 | ||
|
|
7a9ff3de48 | ||
|
|
a3d4d9fac4 | ||
|
|
a937fa0a17 | ||
|
|
99be33d83b | ||
|
|
0132377a2a | ||
|
|
7fdedad68e | ||
|
|
aa7c46ba4f | ||
|
|
d263bf4fd0 | ||
|
|
bdb3dd8c36 | ||
|
|
c8ff1c0453 | ||
|
|
bb40663d37 | ||
|
|
b8588543cf | ||
|
|
cc332de4d1 | ||
|
|
d6b1c7de54 | ||
|
|
3a3f46f2c1 | ||
|
|
1ae0999082 | ||
|
|
c265e3f7bf | ||
|
|
2faf8ccdd2 | ||
|
|
2f724659a7 | ||
|
|
8cca51d08b | ||
|
|
c9fa1142c9 | ||
|
|
445cc55794 | ||
|
|
013e60204d | ||
|
|
b8fecf1f36 | ||
|
|
b319fb50f9 | ||
|
|
698e737b56 | ||
|
|
0be862708f | ||
|
|
1c8d54166b | ||
|
|
77511c8f19 | ||
|
|
d9a3afb869 | ||
|
|
34a78d59fc | ||
|
|
b95008e248 | ||
|
|
317423ae78 | ||
|
|
27cb8e66fe | ||
|
|
28e8a1fdaf | ||
|
|
f43c284f14 | ||
|
|
cd3d7d9f98 | ||
|
|
864044e44e | ||
|
|
48f18d000c | ||
|
|
d0adc0af39 | ||
|
|
64d95bb36f | ||
|
|
a52cbc38a1 | ||
|
|
530a90cb73 | ||
|
|
168c769eb0 | ||
|
|
5b3577c14c | ||
|
|
b9c664687d | ||
|
|
2a3e88bf96 | ||
|
|
004ac3f9ae | ||
|
|
8a04cc726f | ||
|
|
9f2604b888 | ||
|
|
0171ab2d84 | ||
|
|
c3ffd7f739 | ||
|
|
91e929cbf9 | ||
|
|
9671f7f52d | ||
|
|
2668d18266 | ||
|
|
a4bdbb7ab3 | ||
|
|
a11b1209a9 | ||
|
|
625f229a65 | ||
|
|
0d52e27968 | ||
|
|
674b2238b8 | ||
|
|
4eb2e9af00 | ||
|
|
b64cee8055 | ||
|
|
3163b6a729 | ||
|
|
7b61cdd8f8 | ||
|
|
b29bbdd14b | ||
|
|
5b79151690 | ||
|
|
c315a66151 | ||
|
|
b1d7c3ade9 | ||
|
|
682de21978 | ||
|
|
b5b1e3d51d | ||
|
|
efd94e2de0 | ||
|
|
b3dbb5db1f | ||
|
|
b795f56842 | ||
|
|
c0bda0c372 | ||
|
|
2a693e62bf | ||
|
|
eb3d962526 | ||
|
|
f90700e830 | ||
|
|
2b7f61f2a2 | ||
|
|
ffa449742d | ||
|
|
b40a4eefde | ||
|
|
4e60a61036 | ||
|
|
b3835717ab | ||
|
|
e05b397a00 | ||
|
|
7c48061b85 | ||
|
|
03ca628eef | ||
|
|
7aad8d3586 | ||
|
|
1e89891577 | ||
|
|
dd77e6bc5d | ||
|
|
0fe520f95b | ||
|
|
a6e9c8aff6 | ||
|
|
70f6929ac7 | ||
|
|
a360e60f76 | ||
|
|
2c6941e975 | ||
|
|
2afc553e03 | ||
|
|
5ed9c2615c | ||
|
|
ca22a43e46 | ||
|
|
d157a6fb2a | ||
|
|
503faf49e1 | ||
|
|
45f597cd2a | ||
|
|
26fd1b168a | ||
|
|
a9a0fe54b8 | ||
|
|
1c976de2b7 | ||
|
|
00ea872b76 | ||
|
|
836c0848cc | ||
|
|
95372134c8 | ||
|
|
27ce4ee92c | ||
|
|
6889b9b080 | ||
|
|
c81d190908 | ||
|
|
06826d426d | ||
|
|
62afa6b9a9 | ||
|
|
14839e4ab5 | ||
|
|
58003a8501 | ||
|
|
698fa40647 | ||
|
|
5fe3ee1300 | ||
|
|
b83f4c30f2 | ||
|
|
75551e8d0a | ||
|
|
e3d89ec3db | ||
|
|
27f00c04b0 | ||
|
|
30a72a1bd6 | ||
|
|
bbe3d4a811 | ||
|
|
e83540a1e9 | ||
|
|
254ae41759 | ||
|
|
aa11a9e934 | ||
|
|
0abe9ad994 | ||
|
|
452ff64740 | ||
|
|
4b2c4a5823 | ||
|
|
db3c9cb9c5 | ||
|
|
68e7fb5caa | ||
|
|
8420abe5b9 | ||
|
|
5e90d987de | ||
|
|
a0716aac49 | ||
|
|
1659180864 | ||
|
|
d308707f09 | ||
|
|
916554046d | ||
|
|
47c1761137 | ||
|
|
4022b01041 | ||
|
|
558f3bb10e | ||
|
|
ccc2c7cb5d | ||
|
|
3ed092e764 | ||
|
|
3bdf4aab9b | ||
|
|
373a3b4227 | ||
|
|
c78a314385 | ||
|
|
533a0ecf17 | ||
|
|
155782708b | ||
|
|
b6c023fdea | ||
|
|
6351ee86b9 | ||
|
|
a4bd5443f3 | ||
|
|
3120b47404 | ||
|
|
2ae4e42561 | ||
|
|
5112748e1b | ||
|
|
1388639079 | ||
|
|
72618a0d3a | ||
|
|
66a11b83f0 | ||
|
|
0bc66ab011 | ||
|
|
c98ef7c614 | ||
|
|
896a01cd40 | ||
|
|
4f88994cf0 | ||
|
|
93a5228f5b | ||
|
|
124d9a901f | ||
|
|
97c1a222ab | ||
|
|
35802dbb4d | ||
|
|
c848882778 | ||
|
|
374b8d6195 | ||
|
|
27c1b0f045 | ||
|
|
154aa1b0db | ||
|
|
658e5fcb9f | ||
|
|
292ba01dbf | ||
|
|
ff7966d96a | ||
|
|
9cf7437392 | ||
|
|
9f1884f100 | ||
|
|
8a208ce520 | ||
|
|
c850146ef6 | ||
|
|
ccf4f81ea0 | ||
|
|
3c957096c6 | ||
|
|
bc5ad0d919 | ||
|
|
9d06f5bc4d | ||
|
|
6818d1f180 | ||
|
|
ee72ec3dab | ||
|
|
9b74309eb5 | ||
|
|
948eccb169 | ||
|
|
ff342f1e5b | ||
|
|
a7af6fb82d | ||
|
|
d7e3b01bd6 | ||
|
|
117716da9e | ||
|
|
17da7b5fb8 | ||
|
|
545b8f2416 | ||
|
|
d1a62bba89 | ||
|
|
7ccf706a1d | ||
|
|
ef61691b34 | ||
|
|
a92c23bb26 | ||
|
|
21e4cc42cc | ||
|
|
abc307dc35 | ||
|
|
49e262e718 | ||
|
|
25be040bfc | ||
|
|
46c677ea57 | ||
|
|
165b772f8f | ||
|
|
bac2463ff2 | ||
|
|
c61b5d99a2 | ||
|
|
e54498dd35 | ||
|
|
9ca70a5157 | ||
|
|
f9b9184a39 | ||
|
|
b943af3b59 | ||
|
|
5afdc4f20e | ||
|
|
f85ac88595 | ||
|
|
e9e04e2cb4 | ||
|
|
114252dd09 | ||
|
|
2f41dec805 | ||
|
|
2ad01ad672 | ||
|
|
079666643d | ||
|
|
da370c0f2b | ||
|
|
b98026040f | ||
|
|
6d833143fe | ||
|
|
83578c1f38 | ||
|
|
2bc0b2a2b3 | ||
|
|
6af2fbfb6e | ||
|
|
999b265908 | ||
|
|
6599ba3a2d | ||
|
|
888f35c756 | ||
|
|
cc354cf8cf | ||
|
|
2b6ae33911 | ||
|
|
93a87a4dfd | ||
|
|
a7ff41b3ce | ||
|
|
6079739534 | ||
|
|
9822b4d2a1 | ||
|
|
03655cf8b2 | ||
|
|
32591954bc | ||
|
|
e17d4fc99f | ||
|
|
b746fc56bf | ||
|
|
831947ff55 | ||
|
|
e1002f0662 | ||
|
|
222fe94a05 | ||
|
|
aae9e12b8a | ||
|
|
dc0aca1d16 | ||
|
|
452aee0b83 | ||
|
|
73977c9aa5 | ||
|
|
f9731c92c1 | ||
|
|
88f308e2ae | ||
|
|
aa4cc6a7dc | ||
|
|
eead36eb47 | ||
|
|
39f17764e3 | ||
|
|
a9743f01fa | ||
|
|
e60baaeec8 | ||
|
|
9a32f6f21d | ||
|
|
175e84e618 | ||
|
|
2ff488c8c9 | ||
|
|
34652305ab | ||
|
|
bd3be288f2 | ||
|
|
00bcf21bc8 | ||
|
|
2c5d5fb40d | ||
|
|
394225a01a | ||
|
|
ff22549aa9 | ||
|
|
7c16bf8572 | ||
|
|
92c41cbb34 | ||
|
|
54747c24d1 | ||
|
|
d1a5aae242 | ||
|
|
d255967a73 | ||
|
|
637eaae9c7 | ||
|
|
926bdc8655 | ||
|
|
2ba0fa254f | ||
|
|
16c3534d40 | ||
|
|
3c436ce844 | ||
|
|
0b4488339d | ||
|
|
c0b73fe618 | ||
|
|
309aa157ab | ||
|
|
b79d717933 | ||
|
|
c78070c748 | ||
|
|
1159746505 | ||
|
|
b895d5af85 | ||
|
|
43f246d33f | ||
|
|
400014765a | ||
|
|
47c2bf31d4 | ||
|
|
f2cf1d8714 | ||
|
|
3d3372b485 | ||
|
|
964427eae5 | ||
|
|
3c583db3da | ||
|
|
f63e606600 | ||
|
|
2782b426d9 | ||
|
|
182652a231 | ||
|
|
ba73e52f09 | ||
|
|
5b469d702e | ||
|
|
758ed1dc38 | ||
|
|
0a840f11da | ||
|
|
9f674f6547 | ||
|
|
2e226f65ac | ||
|
|
06876e723f | ||
|
|
5d53d7277c | ||
|
|
d3aed95e39 | ||
|
|
4559b2bbf3 | ||
|
|
e6b39b6055 | ||
|
|
ea959cbd87 | ||
|
|
931424fa1b | ||
|
|
fd7628e658 | ||
|
|
8496bd030a | ||
|
|
8830ef5447 | ||
|
|
246130abec | ||
|
|
ec587ac7dc | ||
|
|
2205a8ab6b | ||
|
|
0cabab22be | ||
|
|
232fc61b90 | ||
|
|
1b0ca7b8ab | ||
|
|
531c012292 | ||
|
|
4187ec8655 | ||
|
|
333cbd9384 | ||
|
|
d302814f62 | ||
|
|
a746219a3f | ||
|
|
3e1c6da584 | ||
|
|
8a026f2f6e | ||
|
|
3c02940c7e | ||
|
|
abdeade019 | ||
|
|
99ac9eaf7c | ||
|
|
ee56cea7fd | ||
|
|
e1fa4804f9 | ||
|
|
b016cfb4b7 | ||
|
|
e447041337 | ||
|
|
147906f067 | ||
|
|
87702985dc | ||
|
|
f3e44d39ee | ||
|
|
59b94a2c7d | ||
|
|
c1f10ac7f0 | ||
|
|
0167c50b1d | ||
|
|
73c337b14e | ||
|
|
f625c4435c | ||
|
|
0418566e4c | ||
|
|
831e8fda9f | ||
|
|
f739101b4f | ||
|
|
d75856cfee | ||
|
|
973ef01be8 | ||
|
|
59d372222e | ||
|
|
70dcb05319 | ||
|
|
ce4dfe2507 | ||
|
|
01caea1611 | ||
|
|
7554daca65 | ||
|
|
7347631d34 | ||
|
|
d7b4d7c761 | ||
|
|
43442f8b9b | ||
|
|
93957e5183 | ||
|
|
e08422234b | ||
|
|
62f7b7aa0c | ||
|
|
b7073dc3ce | ||
|
|
d26f94fab1 | ||
|
|
ca86ce0a1c | ||
|
|
90b3e00e8d | ||
|
|
04d1f22d16 | ||
|
|
4d4bee73e3 | ||
|
|
b13ae2e972 | ||
|
|
1fdfb80fe4 | ||
|
|
dcd50d54e1 | ||
|
|
b165a419d5 | ||
|
|
dbae37bb5b | ||
|
|
d4b7a696af | ||
|
|
19876c5a56 | ||
|
|
9c8fb99184 | ||
|
|
5f88af7099 | ||
|
|
984c3dc0e1 | ||
|
|
9992fa28ed | ||
|
|
14fe42e7da | ||
|
|
0d9597c9a9 | ||
|
|
b3d8cf11f7 | ||
|
|
c7184c21da |
No files matched your search
@@ -28,6 +28,13 @@ Icon
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
# With Carthage, if Sparkle is included as a Git submodule (e.g. with the
|
||||
# --use-submodules option), the main module's .gitignore can't reach all the
|
||||
# way inside the submodule to ignore the added Carthage/Build symlink, and Git
|
||||
# keeps complaining about untracked changes in the submodule forever, which
|
||||
# is very annoying. To avoid that issue, ignore here in Sparkle instead.
|
||||
Carthage/Build
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
language: objective-c
|
||||
osx_image: xcode8
|
||||
before_install:
|
||||
- brew update
|
||||
script: make ci
|
||||
@@ -1,4 +1,108 @@
|
||||
# 1.11.0
|
||||
# 1.15.0
|
||||
|
||||
* A new icon! Thanks to 1024jp
|
||||
* Show alert when an update is sent over insecure HTTP with no DSA key (Zorg)
|
||||
- If you can't use HTTPS, you must at least sign updates with a DSA key.
|
||||
* Improved binary delta implementation (Zorg)
|
||||
* Added improved -validateMenuItem: as a method in SUUpdater.h for public use (Zorg)
|
||||
* Removed reachability preflight check (Zorg)
|
||||
* Clear update caches directory before downloading new update (Zorg)
|
||||
* Check the bundle's parent directory for writability too (Zorg)
|
||||
* Don't follow symbolic links for file operations (Zorg)
|
||||
* Don't bring up an authorized dialog during cleanup (Zorg)
|
||||
* Made Sparkle look for the highest compatible version regardless of timestamps (Zorg)
|
||||
* Fixed compatibility with 10.7
|
||||
* Fixed crash on 10.7 - subscript operator not available (kleuter)
|
||||
* Fixed warnings caused by -Wpartial-availability (Zorg)
|
||||
* Fixed german l10n. (Sebastian Volland)
|
||||
* Error code for download errors (Kornel Lesiński)
|
||||
* Update last update check date when the update driver finishes (Zorg)
|
||||
* Scale app icon up if needed in Software Update window (Nicholas Riley)
|
||||
* Don't register for termination notifications more than once (Zorg)
|
||||
* Don't terminate the app if we're already terminating (Zorg)
|
||||
* Removed SUEnableAutomaticChecksKeyOld and SUCheckAtStartup constants (Eitot)
|
||||
* Updated Sparkle framework headers to use modules if modules are available (B. Kevin Hardman)
|
||||
* Fixed warnings, fixed uses of SULocalizedString (Jerry Krinock)
|
||||
* Improved signing verifier to take any host and s/application/bundle/ (Zorg)
|
||||
* Improved Spotlight updates after delta extraction (Zorg)
|
||||
|
||||
# 1.14.0 (Mar 11, 2016)
|
||||
|
||||
* Disable javascript by default and make it opt-in (Zorg)
|
||||
* URL-encoding of appcast URLs is preserved (Kornel Lesiński)
|
||||
* Delegate is asked for fallback updates if delta update fails (Kornel Lesiński)
|
||||
* Fixed crash on 10.7 - subscript operator not available (kleuter)
|
||||
* Fixed check of feed URL before delegate had a chance to set it (Kornel Lesiński)
|
||||
* Re-added support for password-protected dmg images (Andrew K. Boyd)
|
||||
* Added warning about ATS blocking (Kornel Lesiński)
|
||||
* Translation fixes for pt-BR. (vitu)
|
||||
* Add some Japanese lozalized strings (1024jp)
|
||||
* Made test app available in all languages #695 (LIU Dongyuan / 柳东原)
|
||||
* Czech localizations update (Frantisek Erben)
|
||||
* Removed a test resource from the framework bundle (Karl Moskowski)
|
||||
* Test if the updated app is the frontmost one (Zorg)
|
||||
* UI Tests for the Test Application (Zorg)
|
||||
|
||||
# 1.13.1 (Jan 31, 2016)
|
||||
|
||||
Important security fixes:
|
||||
|
||||
* Prevent inclusion of local files via file:// XML entities
|
||||
* Disable redirects to non-HTTP URLs in release notes webview
|
||||
|
||||
# 1.13.0 (Dec 18, 2015)
|
||||
|
||||
* Changed framework's bundle ID from `org.andymatuschak.Sparkle` to `org.sparkle-project.Sparkle`.
|
||||
|
||||
# 1.12.0 (Dec 13, 2015)
|
||||
|
||||
* Rewritten file operations for updating an app (Zorg)
|
||||
- Ensuring atomic move operations, robust error handling.
|
||||
- Faster.
|
||||
- Using modern APIs where possible (no FSPathMakeRef, FSGetCatalogInfo, FSFindFolder, etc.)
|
||||
- Strong documentation, easier to read code.
|
||||
* Automatic updates won't be installed if the system is about to shut off (Zorg)
|
||||
* Deprecated serving over HTTP without DSA (Zorg)
|
||||
- Note that Apple has deprecated insecure HTTP in macOS 10.11
|
||||
* Improved Autoupdate application (Zorg)
|
||||
* Do all the installation work after the runloop is set up
|
||||
* TerminationListener only does termination listening now
|
||||
* Handle cases where host path is not installation path and host path is not desired executable path
|
||||
* Don't show Autoupdate dock icon if we shouldn't show UI
|
||||
* Update modification & access time for new update
|
||||
* Added installUpdatesIfAvailable (Ian Langworth)
|
||||
* Removed extensions from shell scripts (Jake Petroules)
|
||||
* Rewritten test app so it works again, and from a local web server (Zorg)
|
||||
* Replaced use of Python with built-in web server (Kevin Wojniak)
|
||||
* Set LD_RUNPATH_SEARCH_PATHS in Podspec (Jake Petroules)
|
||||
* Don't install automatic updates if the system might shut off (Zorg)
|
||||
* Don't show Autoupdate dock icon if we shouldn't show UI (Zorg)
|
||||
* Updated layout constraints when removing release notes (Zorg)
|
||||
* Improved BinaryDelta error handling & logging (Zorg)
|
||||
* Refactored quarantine removal (Zorg)
|
||||
* Fixed German localization (1024jp)
|
||||
* Updated zh_CN translation (LIU Dongyuan / 柳东原)
|
||||
* Updated Mac models list until July 2015 (Gabriel Ulici)
|
||||
* Updated Polish translation (Kornel Lesiński)
|
||||
* Updated Xcode project languages for which we have translations (Jake Petroules)
|
||||
* Updated XIB files (Kornel Lesiński)
|
||||
* Use NSByteCountFormatter if available (Jake Petroules)
|
||||
* Declared protocols on SUUpdateAlert for the 10.11 SDK (Daniel Jalkut)
|
||||
* Silenced warning about casting away const-ness and -Wassign-enum (Daniel Jalkut)
|
||||
* Added script to generate a report comparing the Sparkle.strings files (Kevin Wojniak)
|
||||
* Check for empty strings (as well as nil) in SUHost's -name method (Karl Moskowski)
|
||||
* Don't follow symlinks for checking file existence (Zorg)
|
||||
* Unit tests in Swift (Zorg, Jake Petroules)
|
||||
* Fixed framework imports (Felix Schulze)
|
||||
* Fixed issues with copying files from different mounted drives (Zorg)
|
||||
* Disallowed automatic updates when user can't write to the bundle (Zorg)
|
||||
* Set the task working directories instead of changing the process working directory (Kevin Wojniak)
|
||||
|
||||
# 1.11.1 (Nov 9, 2015)
|
||||
|
||||
* Don't install automatic updates when system is about to shut down
|
||||
|
||||
# 1.11.0 (Aug 24, 2015)
|
||||
|
||||
* Big improvements to code signing and DSA verification
|
||||
- Sparkle now checks not only whether an update is correctly signed, but also whether the updated version will be able to verify future updates. Updates now must either use DSA keys correctly, or not try to use them at all. Same goes for Apple Code Signing.
|
||||
@@ -16,7 +120,7 @@
|
||||
* Added logging of appcast/download URL on error (Kornel Lesiński)
|
||||
* More robust reading of Autoupdate.app path from Sparkle bundle
|
||||
|
||||
# 1.10.0
|
||||
# 1.10.0 (Apr 26, 2015)
|
||||
|
||||
* Massive improvements to the BinaryDelta tool (Zorg)
|
||||
- Ability to track file permissions (Zorg)
|
||||
@@ -32,7 +136,7 @@
|
||||
* Stdout used for non error outputs (JDuquennoy)
|
||||
* French locale update (Kent Sutherland)
|
||||
|
||||
# 1.9.0
|
||||
# 1.9.0 (Jan 26, 2015)
|
||||
|
||||
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
|
||||
* Make the error definitions public (C.W. Betts)
|
||||
@@ -42,7 +146,7 @@
|
||||
* Use Library/Caches rather than app support directory (Kornel Lesiński)
|
||||
* Check for a modal window being onscreen before trying to put up the Sparkle prompt (Alf Watt)
|
||||
* Fixed crashes on 10.7 (Chris Campbell, Ger Teunis)
|
||||
* Fixed Sparkle tags parsing (Tamás Lustyik)
|
||||
* Fixed Sparkle tags parsing (Tamás Lustyik)
|
||||
* SULog code cleanups (Kevin Wojniak)
|
||||
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
|
||||
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
|
||||
@@ -55,18 +159,18 @@
|
||||
* Turkish localization fixes (Emir)
|
||||
* Proofing of Ukrainian localization (Vera Tkachenko)
|
||||
|
||||
# 1.8.0
|
||||
# 1.8.0 (Jul 26, 2014)
|
||||
|
||||
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
|
||||
* New SUDSAVerifier based on up-to-date macOS APIs (Zachary Waldowski)
|
||||
* Detailed error log for failed signature checks (Kornel Lesiński)
|
||||
* Converted Sparkle to ARC (C.W. Betts)
|
||||
* Converted ivars to properties. (Jake Petroules)
|
||||
* Cocoapod support (Xhacker Liu)
|
||||
* Quarantine removal on OS X 10.10 (C.W. Betts)
|
||||
* Quarantine removal on macOS 10.10 (C.W. Betts)
|
||||
* Updated Japanese localization (1024jp)
|
||||
* Added Greek localization
|
||||
|
||||
# 1.7.1
|
||||
# 1.7.1 (Jul 2, 2014)
|
||||
|
||||
* Removed option to install unverified updates (Kornel Lesiński)
|
||||
* Added detailed log when code signing verification fails (Sam Deane)
|
||||
@@ -83,7 +187,7 @@
|
||||
|
||||
# 1.7.0
|
||||
|
||||
* Dropped support for OS X 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
|
||||
* Dropped support for macOS 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
|
||||
* Removed use of deprecated functions (Zachary Waldowski)
|
||||
* Switched to modern Obj-C runtime and new literals syntax
|
||||
* Removed pre-10.7 code. (C.W. Betts)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at kornel+sparkle@geekhood.net. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -1,7 +1,8 @@
|
||||
// Common
|
||||
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.andymatuschak.Sparkle
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_FILEOP_TOOL_NAME = fileop
|
||||
|
||||
SPARKLE_APPEND_VERSION_NUMBER = 1
|
||||
|
||||
@@ -15,8 +16,8 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
|
||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 11
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION_MINOR = 15
|
||||
SPARKLE_VERSION_PATCH = 1
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
|
||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||
@@ -31,11 +32,15 @@ MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = 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)\"
|
||||
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)\"
|
||||
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
COMBINE_HIDPI_IMAGES = NO;
|
||||
|
||||
// Enable warnings
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
|
||||
@@ -50,7 +55,6 @@ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
||||
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
|
||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||
@@ -78,8 +82,12 @@ GCC_WARN_UNUSED_LABEL = YES
|
||||
GCC_WARN_UNUSED_PARAMETER = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
|
||||
// Fixes a strange issue where the compiler thinks references to some enums are ambiguous
|
||||
CLANG_ENABLE_MODULES[sdk=macosx10.7] = NO
|
||||
CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
|
||||
|
||||
// These should be removed once the conversion to ARC is complete
|
||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
|
||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -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 $(WARNING_CFLAGS_EXTRA)
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
|
||||
@@ -3,10 +3,10 @@
|
||||
// Debug only
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = 0
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Onone
|
||||
DEBUG_INFORMATION_FORMAT = dwarf
|
||||
ENABLE_TESTABILITY = YES
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
SPARKLE_EXTRA_DEBUG = -DDEBUG
|
||||
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
|
||||
ONLY_ACTIVE_ARCH = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
@@ -3,8 +3,10 @@
|
||||
// Release only
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = s
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Ofast
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||
DEAD_CODE_STRIPPING = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fileop tool only
|
||||
|
||||
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_VERSION = 3.0
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Onone
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Ofast
|
||||
@@ -3,6 +3,5 @@
|
||||
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
|
||||
WRAPPER_EXTENSION = app
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||
CLANG_ENABLE_OBJC_ARC = NO
|
||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
|
||||
@@ -0,0 +1,13 @@
|
||||
// UI Test only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
INFOPLIST_FILE = UITests/UITests-Info.plist
|
||||
WRAPPER_EXTENSION = xctest
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
|
||||
TEST_TARGET_NAME = Sparkle Test App
|
||||
USES_XCTRUNNER = YES
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -1,5 +1,7 @@
|
||||
// Unit Test only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
|
||||
WRAPPER_EXTENSION = xctest
|
||||
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
|
||||
@@ -7,3 +9,6 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO
|
||||
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9
|
||||
CLANG_ENABLE_MODULES = YES
|
||||
SWIFT_OBJC_BRIDGING_HEADER = Tests/Sparkle Unit Tests-Bridging-Header.h
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -1 +1,2 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -1 +1,2 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -2,6 +2,13 @@
|
||||
set -e
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
# 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 [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
||||
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
|
||||
|
||||
@@ -13,14 +13,20 @@ if [ -z "$SRCROOT" ] || \
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the current Git master hash
|
||||
version=$(cd "$SRCROOT" ; git show-ref --abbrev heads/master | awk '{print $1}')
|
||||
if [ -z "$version" ] ; then
|
||||
echo "$0: Can't find a Git hash!" 1>&2
|
||||
version="$CURRENT_PROJECT_VERSION"
|
||||
|
||||
# Get version in format 1.x.x-commits-hash
|
||||
gitversion=$( cd "$SRCROOT"; git describe --tags --match '[12].*' || true )
|
||||
if [ -z "$gitversion" ] ; then
|
||||
echo "$0: Can't find a Git hash!" 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
version="$CURRENT_PROJECT_VERSION git-$version"
|
||||
# remove everything before the first "-" to keep the hash part only
|
||||
versionsuffix=${gitversion#*-};
|
||||
if [ "$versionsuffix" != "$gitversion" ]; then
|
||||
version="$version $versionsuffix"
|
||||
fi
|
||||
|
||||
# and use it to set the CFBundleShortVersionString value
|
||||
export PATH="$PATH:/usr/libexec"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
PROJECT_NAME = Sparkle
|
||||
PROJECT_NUMBER = 1.7.1
|
||||
PROJECT_BRIEF = "A software update framework for OS X"
|
||||
PROJECT_NUMBER = 1.14.0
|
||||
PROJECT_BRIEF = "A software update framework for macOS"
|
||||
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
|
||||
|
||||
RECURSIVE = YES
|
||||
|
||||
@@ -13,6 +13,8 @@ localizable-strings:
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||
cat Sparkle.podspec
|
||||
@echo "Don't forget to update CocoaPods! pod trunk push"
|
||||
|
||||
build:
|
||||
xcodebuild clean build
|
||||
@@ -20,9 +22,21 @@ build:
|
||||
test:
|
||||
xcodebuild -scheme Distribution -configuration Debug test
|
||||
|
||||
uitest:
|
||||
xcodebuild -scheme UITests -configuration Debug test
|
||||
|
||||
ci:
|
||||
for i in {7..11} ; do \
|
||||
for i in {7..9} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test ; \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
for i in {10..11} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
check-localizations:
|
||||
./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm"
|
||||
open "$(TMPDIR)/LocalizationsReport.htm"
|
||||
@@ -0,0 +1,24 @@
|
||||
# To update the icon run make -f Makefile-icon
|
||||
# Requires:
|
||||
# autoconf, automake, libtool, pkg-config, pngquant
|
||||
|
||||
ICONDIR=./Resources/Images.xcassets/AppIcon.appiconset
|
||||
OPTIMIZEDICONS=$(ICONDIR)/optimized_16x16.png $(ICONDIR)/optimized_32x32.png $(ICONDIR)/optimized_128x128.png $(ICONDIR)/optimized_512x512.png
|
||||
DESTICON=Resources/AppIcon.icns
|
||||
|
||||
all: $(DESTICON)
|
||||
|
||||
libicns:
|
||||
git clone https://github.com/pornel/libicns.git
|
||||
|
||||
libicns/Makefile: libicns
|
||||
( cd libicns && autoreconf -vif && ./configure )
|
||||
|
||||
libicns/icnsutils/png2icns: libicns/Makefile
|
||||
( cd libicns && make -j8 )
|
||||
|
||||
optimized_%.png: icon_%.png
|
||||
pngquant -s1 -f -o $@ $<
|
||||
|
||||
$(DESTICON): libicns/icnsutils/png2icns $(OPTIMIZEDICONS)
|
||||
./libicns/icnsutils/png2icns $@ $(OPTIMIZEDICONS)
|
||||
@@ -1,14 +1,14 @@
|
||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) <a href='https://app.ship.io/dashboard#/jobs/8814/history' target='_blank'><img src='https://app.ship.io/jobs/V3PoCLcN5ft5Pnq0/build_status.png' height='20' /></a>
|
||||
# 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>
|
||||
|
||||
An easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
<img src="Resources/Screenshot.png" width="715" 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">
|
||||
|
||||
## Changes since 1.5b
|
||||
|
||||
* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+.
|
||||
* Up-to-date with 10.11 SDK and Xcode 7. Supports macOS 10.7+.
|
||||
* Important security fixes.
|
||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
@@ -17,31 +17,41 @@ An easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
## Features
|
||||
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* True self-updating—the user can choose to automatically download and install all updates.
|
||||
* Displays a detailed progress window to the user.
|
||||
* Supports authentication for installing in secure locations.
|
||||
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
|
||||
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
|
||||
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Uses RSS-based appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Deep delegate support to make Sparkle work exactly as you need.
|
||||
* Optionally sends system information to the server when checking for updates.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
|
||||
## Developers
|
||||
## Requirements
|
||||
|
||||
Building Sparkle requires Xcode 5 or above.
|
||||
* Runtime: macOS 10.7 or greater
|
||||
* Build: Xcode 5 and 10.8 SDK or greater
|
||||
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||
|
||||
### API
|
||||
## API
|
||||
|
||||
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
||||
If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples).
|
||||
|
||||
### Building the distribution package
|
||||
## Building the distribution package
|
||||
|
||||
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed.
|
||||
|
||||
Alternatively, build the Distribution scheme in the Xcode UI.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
We pledge to have an open and welcoming environment. See our [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Project Sponsor
|
||||
|
||||
[StackPath](https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer)
|
||||
@@ -43,18 +43,21 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_256x256@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_512x512.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_512x512@2x.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 368 KiB |
@@ -16,6 +16,8 @@
|
||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||
<key>iMac6,1</key>
|
||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
||||
<key>iMac7,1</key>
|
||||
<string>iMac Intel Core 2 Duo (aluminum enclosure)</string>
|
||||
<key>iMac8,1</key>
|
||||
<string>iMac (Core 2 Duo, 20 or 24 inch, Early 2008 )</string>
|
||||
<key>iMac9,1</key>
|
||||
@@ -25,7 +27,7 @@
|
||||
<key>iMac11,1</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2009)</string>
|
||||
<key>iMac11,2</key>
|
||||
<string>iMac (Core i3 or i5, 27 inch Mid 2010)</string>
|
||||
<string>21.5" iMac (mid 2010)</string>
|
||||
<key>iMac11,3</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Mid 2010)</string>
|
||||
<key>iMac12,1</key>
|
||||
@@ -42,6 +44,16 @@
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2013)</string>
|
||||
<key>iMac14,3</key>
|
||||
<string>iMac (Core i5 or i7, 21.5 inch Late 2013)</string>
|
||||
<key>iMac14,4</key>
|
||||
<string>iMac (Core i5, 21.5 inch Mid 2014)</string>
|
||||
<key>iMac15,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2014 or Mid 2015)</string>
|
||||
<key>iMac16,1</key>
|
||||
<string>iMac (Core i5, 21,5 inch Late 2015)</string>
|
||||
<key>iMac16,2</key>
|
||||
<string>iMac (Retina 4K Core i5 or i7, 21.5 inch Late 2015)</string>
|
||||
<key>iMac17,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2015)</string>
|
||||
<key>MacBook1,1</key>
|
||||
<string>MacBook (Core Duo)</string>
|
||||
<key>MacBook2,1</key>
|
||||
@@ -56,6 +68,8 @@
|
||||
<string>MacBook (Core 2 Duo, Late 2009, Unibody)</string>
|
||||
<key>MacBook7,1</key>
|
||||
<string>MacBook (Core 2 Duo, Mid 2010, White)</string>
|
||||
<key>MacBook8,1</key>
|
||||
<string>MacBook (Core M, 12 inch, Early 2015)</string>
|
||||
<key>MacBookAir1,1</key>
|
||||
<string>MacBook Air (Core 2 Duo, 13 inch, Early 2008)</string>
|
||||
<key>MacBookAir2,1</key>
|
||||
@@ -76,6 +90,10 @@
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir6,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir7,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Early 2015)</string>
|
||||
<key>MacBookAir7,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Early 2015)</string>
|
||||
<key>MacBookPro1,1</key>
|
||||
<string>MacBook Pro Core Duo (15-inch)</string>
|
||||
<key>MacBookPro1,2</key>
|
||||
@@ -90,8 +108,70 @@
|
||||
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
||||
<key>MacBookPro4,1</key>
|
||||
<string>MacBook Pro (Core 2 Duo Feb 2008)</string>
|
||||
<key>MacBookPro5,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,2</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,3</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,4</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,5</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro6,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro6,2</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro7,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (mid 2010)</string>
|
||||
<key>MacBookPro8,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7, 13" (early 2011)</string>
|
||||
<key>MacBookPro8,2</key>
|
||||
<string>MacBook Pro Intel Core i7, 15" (early 2011)</string>
|
||||
<key>MacBookPro8,3</key>
|
||||
<string>MacBook Pro Intel Core i7, 17" (early 2011)</string>
|
||||
<key>MacBookPro9,1</key>
|
||||
<string>MacBook Pro (15-inch, Mid 2012)</string>
|
||||
<key>MacBookPro9,2</key>
|
||||
<string>MacBook Pro (13-inch, Mid 2012)</string>
|
||||
<key>MacBookPro10,1</key>
|
||||
<string>MacBook Pro (Retina, Mid 2012)</string>
|
||||
<key>MacBookPro10,2</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2012)</string>
|
||||
<key>MacBookPro11,1</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,2</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,3</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacbookPro11,4</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro11,5</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro12,1 </key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Early 2015)</string>
|
||||
<key>Macmini1,1</key>
|
||||
<string>Mac Mini (Core Solo/Duo)</string>
|
||||
<key>Macmini2,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini3,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini4,1</key>
|
||||
<string>Mac mini Intel Core (Mid 2010)</string>
|
||||
<key>Macmini5,1</key>
|
||||
<string>Mac mini (Core i5, Mid 2011)</string>
|
||||
<key>Macmini5,2</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Mid 2011)</string>
|
||||
<key>Macmini5,3</key>
|
||||
<string>Mac mini (Core i7, Server, Mid 2011)</string>
|
||||
<key>Macmini6,1</key>
|
||||
<string>Mac mini (Core i5, Late 2012)</string>
|
||||
<key>Macmini6,2</key>
|
||||
<string>Mac mini (Core i7, Normal or Server, Late 2012)</string>
|
||||
<key>Macmini7,1</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Late 2014)</string>
|
||||
<key>MacPro1,1,Quad</key>
|
||||
<string>Mac Pro</string>
|
||||
<key>MacPro1,1</key>
|
||||
<string>Mac Pro (four-core)</string>
|
||||
<key>MacPro2,1</key>
|
||||
@@ -101,7 +181,9 @@
|
||||
<key>MacPro4,1</key>
|
||||
<string>Mac Pro (March 2009)</string>
|
||||
<key>MacPro5,1</key>
|
||||
<string>Mac Pro (August 2010)</string>
|
||||
<string>Mac Pro (2010 or 2012)</string>
|
||||
<key>MacPro6,1</key>
|
||||
<string>Mac Pro (Late 2013)</string>
|
||||
<key>PowerBook1,1</key>
|
||||
<string>PowerBook G3</string>
|
||||
<key>PowerBook2,1</key>
|
||||
@@ -164,14 +246,6 @@
|
||||
<string>Power Macintosh G3 (Blue & White)</string>
|
||||
<key>PowerMac1,2</key>
|
||||
<string>Power Macintosh G4 (PCI Graphics)</string>
|
||||
<key>PowerMac10,1</key>
|
||||
<string>Mac Mini G4</string>
|
||||
<key>PowerMac10,2</key>
|
||||
<string>Mac Mini (Late 2005)</string>
|
||||
<key>PowerMac11,2</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac12,1</key>
|
||||
<string>iMac G5 (iSight)</string>
|
||||
<key>PowerMac2,1</key>
|
||||
<string>iMac G3 (Slot-loading CD-ROM)</string>
|
||||
<key>PowerMac2,2</key>
|
||||
@@ -198,6 +272,8 @@
|
||||
<string>iMac G4 (17-inch Flat Panel)</string>
|
||||
<key>PowerMac5,1</key>
|
||||
<string>Power Macintosh G4 Cube</string>
|
||||
<key>PowerMac5,2</key>
|
||||
<string>Power Mac G4 Cube</string>
|
||||
<key>PowerMac6,1</key>
|
||||
<string>iMac G4 (USB 2.0)</string>
|
||||
<key>PowerMac6,3</key>
|
||||
@@ -214,6 +290,14 @@
|
||||
<string>iMac G5 (Ambient Light Sensor)</string>
|
||||
<key>PowerMac9,1</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac10,1</key>
|
||||
<string>Mac Mini G4</string>
|
||||
<key>PowerMac10,2</key>
|
||||
<string>Mac Mini (Late 2005)</string>
|
||||
<key>PowerMac11,2</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac12,1</key>
|
||||
<string>iMac G5 (iSight)</string>
|
||||
<key>RackMac1,1</key>
|
||||
<string>Xserve G4</string>
|
||||
<key>RackMac1,2</key>
|
||||
@@ -224,5 +308,7 @@
|
||||
<string>Xserve (Intel Xeon)</string>
|
||||
<key>Xserve2,1</key>
|
||||
<string>Xserve (January 2008 quad-core)</string>
|
||||
<key>Xserve3,1</key>
|
||||
<string>Xserve (early 2009)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -2,7 +2,6 @@
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<channel>
|
||||
<title>Your Great App's Changelog</title>
|
||||
<link>http://you.com/app/appcast.xml</link>
|
||||
<description>Most recent changes with links to updates.</description>
|
||||
<language>en</language>
|
||||
<item>
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,26 +1,32 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.11.0"
|
||||
s.summary = "A software update framework for OS X"
|
||||
s.version = "1.15.1"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "http://sparkle-project.org"
|
||||
s.documentation_url = "http://sparkle-project.org/documentation/"
|
||||
s.screenshot = "http://sparkle-project.org/images/screenshot-noshadow@2x.png"
|
||||
s.license = {
|
||||
:type => 'MIT',
|
||||
:file => 'LICENSE'
|
||||
}
|
||||
s.authors = {
|
||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
|
||||
'Kornel Lesiński' => 'pornel@pornel.net',
|
||||
'C.W. Betts' => 'computers57@hotmail.com',
|
||||
'Jake Petroules' => 'jake.petroules@petroules.com',
|
||||
'C.W. Betts' => 'computers57@hotmail.com',
|
||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||
}
|
||||
|
||||
s.platform = :osx, '10.7'
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
|
||||
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
s.vendored_framework = 'Sparkle.framework'
|
||||
s.resources = 'Sparkle.framework'
|
||||
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
|
||||
s.vendored_frameworks = 'Sparkle.framework'
|
||||
s.xcconfig = {
|
||||
'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"',
|
||||
'LD_RUNPATH_SEARCH_PATHS' => '@loader_path/../Frameworks'
|
||||
}
|
||||
s.requires_arc = true
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -23,10 +23,10 @@
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -52,11 +52,11 @@
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
@@ -74,10 +74,10 @@
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -23,10 +23,10 @@
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -52,11 +52,11 @@
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugXPCServices = "NO"
|
||||
@@ -75,10 +75,10 @@
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "726B2B5C1C645FC900388755"
|
||||
BuildableName = "UI Tests.xctest"
|
||||
BlueprintName = "UI Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</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">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -28,5 +28,7 @@
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}.icns</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -3,16 +3,10 @@
|
||||
#import "SUHost.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*!
|
||||
* If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback.
|
||||
*/
|
||||
static const NSTimeInterval SUInstallationTimeLimit = 5;
|
||||
|
||||
/*!
|
||||
* Time this app uses to recheck if the parent has already died.
|
||||
*/
|
||||
@@ -20,165 +14,236 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
|
||||
|
||||
@interface TerminationListener : NSObject
|
||||
|
||||
@property (copy) NSString *hostpath;
|
||||
@property (copy) NSString *executablepath;
|
||||
@property (assign) pid_t parentprocessid;
|
||||
@property (copy) NSString *folderpath;
|
||||
- (instancetype)initWithProcessId:(pid_t)pid;
|
||||
|
||||
@property (copy) NSString *selfPath;
|
||||
@property (copy) NSString *installationPath;
|
||||
@property (strong) NSTimer *watchdogTimer;
|
||||
@property (strong) NSTimer *longInstallationTimer;
|
||||
@property (strong) SUHost *host;
|
||||
@property (assign) BOOL shouldRelaunch;
|
||||
@property (assign) BOOL shouldShowUI;
|
||||
@property (strong) SUStatusController *statusController;
|
||||
@end
|
||||
|
||||
- (void)parentHasQuit;
|
||||
@interface TerminationListener ()
|
||||
|
||||
- (void)relaunch;
|
||||
- (void)install;
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *)aTimer;
|
||||
- (void)watchdog:(NSTimer *)aTimer;
|
||||
@property (nonatomic, assign) pid_t processIdentifier;
|
||||
@property (nonatomic, strong) NSTimer *watchdogTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
|
||||
@synthesize hostpath;
|
||||
@synthesize executablepath;
|
||||
@synthesize parentprocessid;
|
||||
@synthesize folderpath;
|
||||
@synthesize processIdentifier = _processIdentifier;
|
||||
@synthesize watchdogTimer = _watchdogTimer;
|
||||
|
||||
@synthesize selfPath;
|
||||
@synthesize installationPath;
|
||||
@synthesize watchdogTimer;
|
||||
@synthesize longInstallationTimer;
|
||||
@synthesize host;
|
||||
@synthesize shouldRelaunch;
|
||||
@synthesize shouldShowUI;
|
||||
@synthesize statusController;
|
||||
|
||||
- (instancetype)initWithHostPath:(NSString *)inhostpath executablePath:(NSString *)execpath parentProcessId:(pid_t)ppid folderPath:(NSString *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
|
||||
- (instancetype)initWithProcessId:(pid_t)pid
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.hostpath = inhostpath;
|
||||
self.executablepath = execpath;
|
||||
self.parentprocessid = ppid;
|
||||
self.folderpath = infolderpath;
|
||||
self.selfPath = inSelfPath;
|
||||
self.shouldRelaunch = relaunch;
|
||||
self.shouldShowUI = showUI;
|
||||
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
|
||||
if (alreadyTerminated)
|
||||
[self parentHasQuit];
|
||||
else
|
||||
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
|
||||
self.processIdentifier = pid;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self.longInstallationTimer invalidate];
|
||||
[self.statusController close];
|
||||
}
|
||||
|
||||
|
||||
- (void)parentHasQuit
|
||||
- (void)cleanupWithCompletion:(void (^)(void))completionBlock
|
||||
{
|
||||
[self.watchdogTimer invalidate];
|
||||
self.longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
|
||||
target: self selector: @selector(showAppIconInDock:)
|
||||
userInfo:nil repeats:NO];
|
||||
completionBlock();
|
||||
}
|
||||
|
||||
if (self.folderpath)
|
||||
[self install];
|
||||
- (void)startListeningWithCompletion:(void (^)(void))completionBlock
|
||||
{
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
if (alreadyTerminated)
|
||||
[self cleanupWithCompletion:completionBlock];
|
||||
else
|
||||
[self relaunch];
|
||||
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:completionBlock repeats:YES];
|
||||
}
|
||||
|
||||
- (void)watchdog:(NSTimer *)__unused aTimer
|
||||
- (void)watchdog:(NSTimer *)timer
|
||||
{
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.parentprocessid]) {
|
||||
[self parentHasQuit];
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.processIdentifier]) {
|
||||
[self cleanupWithCompletion:timer.userInfo];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *)__unused aTimer
|
||||
@end
|
||||
|
||||
/*!
|
||||
* If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback.
|
||||
*/
|
||||
static const NSTimeInterval SUInstallationTimeLimit = 5;
|
||||
|
||||
/*!
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
* This delay should be be high enough to increase the likelihood that our updated app will be launched up front,
|
||||
* but should be low enough so that the user doesn't ponder why the updater hasn't finished terminating yet
|
||||
*/
|
||||
static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
|
||||
@interface AppInstaller : NSObject <NSApplicationDelegate>
|
||||
|
||||
/*
|
||||
* hostPath - path to host (original) application
|
||||
* relaunchPath - path to what the host wants to relaunch (default is same as hostPath)
|
||||
* parentProcessId - process identifier of the host before launching us
|
||||
* updateFolderPath - path to update folder (i.e, temporary directory containing the new update)
|
||||
* shouldRelaunch - indicates if the new installed app should re-launched
|
||||
* shouldShowUI - indicates if we should show the status window when installing the update
|
||||
*/
|
||||
- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI;
|
||||
|
||||
@end
|
||||
|
||||
@interface AppInstaller ()
|
||||
|
||||
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||
@property (nonatomic, strong) SUStatusController *statusController;
|
||||
|
||||
@property (nonatomic, copy) NSString *updateFolderPath;
|
||||
@property (nonatomic, copy) NSString *hostPath;
|
||||
@property (nonatomic, copy) NSString *relaunchPath;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||
|
||||
@property (nonatomic, assign) BOOL isTerminating;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInstaller
|
||||
|
||||
@synthesize terminationListener = _terminationListener;
|
||||
@synthesize statusController = _statusController;
|
||||
@synthesize updateFolderPath = _updateFolderPath;
|
||||
@synthesize hostPath = _hostPath;
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@synthesize shouldShowUI = _shouldShowUI;
|
||||
@synthesize isTerminating = _isTerminating;
|
||||
|
||||
- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.hostPath = hostPath;
|
||||
self.relaunchPath = relaunchPath;
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessId:parentProcessId];
|
||||
self.updateFolderPath = updateFolderPath;
|
||||
self.shouldRelaunch = shouldRelaunch;
|
||||
self.shouldShowUI = shouldShowUI;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)relaunch __attribute__((noreturn))
|
||||
- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification
|
||||
{
|
||||
if (self.shouldRelaunch)
|
||||
{
|
||||
NSString *appPath = nil;
|
||||
if (!self.folderpath || ![self.executablepath isEqualToString:self.hostpath])
|
||||
appPath = self.executablepath;
|
||||
else
|
||||
appPath = self.installationPath;
|
||||
[[NSWorkspace sharedWorkspace] openFile:appPath];
|
||||
}
|
||||
|
||||
if (self.folderpath)
|
||||
{
|
||||
NSError *theError = nil;
|
||||
if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError])
|
||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL];
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
[self.terminationListener startListeningWithCompletion:^{
|
||||
self.terminationListener = nil;
|
||||
|
||||
if (self.shouldShowUI) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.isTerminating) {
|
||||
// Show app icon in the dock
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[self install];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)install
|
||||
{
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostpath];
|
||||
self.host = [[SUHost alloc] initWithBundle:theBundle];
|
||||
self.installationPath = [[self.host installationPath] copy];
|
||||
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath];
|
||||
SUHost *host = [[SUHost alloc] initWithBundle:theBundle];
|
||||
NSString *installationPath = [[host installationPath] copy];
|
||||
|
||||
if (self.shouldShowUI) {
|
||||
SUStatusController *statusCtl = [[SUStatusController alloc] initWithHost:self.host]; // We quit anyway after we've installed, so leak this for now.
|
||||
[statusCtl setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
|
||||
[statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
|
||||
maxProgressValue: 0 statusText: @""];
|
||||
[statusCtl showWindow:self];
|
||||
|
||||
[self.statusController close]; // If there's an existing status controller, close it before we release our strong reference to it.
|
||||
self.statusController = statusCtl; // Keep a strong reference to the status controller, or else it might get prematurely deallocated.
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:host];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
|
||||
maxProgressValue: 0 statusText: @""];
|
||||
[self.statusController showWindow:self];
|
||||
}
|
||||
|
||||
[SUInstaller installFromUpdateFolder:self.folderpath
|
||||
overHost:self.host
|
||||
installationPath:self.installationPath
|
||||
|
||||
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
|
||||
SULog(@"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
|
||||
}
|
||||
|
||||
[SUInstaller installFromUpdateFolder:self.updateFolderPath
|
||||
overHost:host
|
||||
installationPath:installationPath
|
||||
fileOperationToolPath:fileOperationToolPath
|
||||
versionComparator:[SUStandardVersionComparator defaultComparator]
|
||||
completionHandler:^(NSError *error) {
|
||||
if (error) {
|
||||
if (self.shouldShowUI) {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"";
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert runModal];
|
||||
NSError *underlyingError = [error.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
|
||||
SULog(@"Installation Error: %@", error);
|
||||
if (self.shouldShowUI) {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"";
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert runModal];
|
||||
}
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
[self relaunch];
|
||||
NSString *pathToRelaunch = nil;
|
||||
// If the installation path differs from the host path, we give higher precedence for it than
|
||||
// if the desired relaunch path differs from the host path
|
||||
if (![installationPath.pathComponents isEqualToArray:self.hostPath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.hostPath.pathComponents]) {
|
||||
pathToRelaunch = installationPath;
|
||||
} else {
|
||||
pathToRelaunch = self.relaunchPath;
|
||||
}
|
||||
[self cleanupAndTerminateWithPathToRelaunch:pathToRelaunch];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath
|
||||
{
|
||||
self.isTerminating = YES;
|
||||
|
||||
dispatch_block_t cleanupAndExit = ^{
|
||||
NSError *theError = nil;
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:self.updateFolderPath error:&theError]) {
|
||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL];
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
};
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
// The auto updater can terminate before the newly updated app is finished launching
|
||||
// If that happens, the OS may not make the updated app active and frontmost
|
||||
// (Or it does become frontmost, but the OS backgrounds it afterwards.. It's some kind of timing/activation issue that doesn't occur all the time)
|
||||
// The only remedy I've been able to find is waiting an arbitrary delay before exiting our application
|
||||
|
||||
// Don't use -launchApplication: because we may not be launching an application. Eg: it could be a system prefpane
|
||||
if (![[NSWorkspace sharedWorkspace] openFile:relaunchPath]) {
|
||||
SULog(@"Failed to launch %@", relaunchPath);
|
||||
}
|
||||
|
||||
[self.statusController close];
|
||||
|
||||
// Don't even think about hiding the app icon from the dock if we've already shown it
|
||||
// Transforming the app back to a background one has a backfiring effect, decreasing the likelihood
|
||||
// that the updated app will be brought up front
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUTerminationTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
cleanupAndExit();
|
||||
});
|
||||
} else {
|
||||
cleanupAndExit();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main(int __unused argc, const char __unused *argv[])
|
||||
@@ -189,24 +254,22 @@ int main(int __unused argc, const char __unused *argv[])
|
||||
if (args.count < 5 || args.count > 7) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
NSApplication *application = [NSApplication sharedApplication];
|
||||
|
||||
BOOL shouldShowUI = (args.count > 6) ? [args[6] boolValue] : YES;
|
||||
BOOL shouldShowUI = (args.count > 6) ? [[args objectAtIndex:6] boolValue] : YES;
|
||||
if (shouldShowUI) {
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
[application activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:args[1]
|
||||
executablePath:args[2]
|
||||
parentProcessId:[args[3] intValue]
|
||||
folderPath:args[4]
|
||||
shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES
|
||||
shouldShowUI:shouldShowUI
|
||||
selfPath:[[NSBundle mainBundle] bundlePath]];
|
||||
|
||||
[[NSApplication sharedApplication] run];
|
||||
// Ensure termListen is not deallocated by ARC before caling -[NSApplication run]
|
||||
[termListen class];
|
||||
|
||||
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:[args objectAtIndex:1]
|
||||
relaunchPath:[args objectAtIndex:2]
|
||||
parentProcessId:[[args objectAtIndex:3] intValue]
|
||||
updateFolderPath:[args objectAtIndex:4]
|
||||
shouldRelaunch:(args.count > 5) ? [[args objectAtIndex:5] boolValue] : YES
|
||||
shouldShowUI:shouldShowUI];
|
||||
[application setDelegate:appInstaller];
|
||||
[application run];
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/xcrun swift
|
||||
|
||||
import Foundation
|
||||
|
||||
func die(msg: String) {
|
||||
print("ERROR: \(msg)")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
extension NSXMLElement {
|
||||
convenience init(name: String, attributes: [String: String], stringValue string: String? = nil) {
|
||||
self.init(name: name, stringValue: string)
|
||||
setAttributesWithDictionary(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
let ud = NSUserDefaults.standardUserDefaults()
|
||||
let sparkleRoot = ud.objectForKey("root") as? String
|
||||
let htmlPath = ud.objectForKey("htmlPath") as? String
|
||||
if sparkleRoot == nil || htmlPath == nil {
|
||||
die("Missing arguments")
|
||||
}
|
||||
|
||||
let enStringsPath = sparkleRoot! + "/Sparkle/en.lproj/Sparkle.strings"
|
||||
let enStringsDict = NSDictionary(contentsOfFile: enStringsPath)
|
||||
if enStringsDict == nil {
|
||||
die("Invalid English strings")
|
||||
}
|
||||
let enStringsDictKeys = enStringsDict!.allKeys
|
||||
|
||||
let dirPath = NSString(string: sparkleRoot! + "/Sparkle")
|
||||
let dirContents = try! NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath as String)
|
||||
let css =
|
||||
"body { font-family: sans-serif; font-size: 10pt; }" +
|
||||
"h1 { font-size: 12pt; }" +
|
||||
".missing { background-color: #FFBABA; color: #D6010E; white-space: pre; }" +
|
||||
".unused { background-color: #BDE5F8; color: #00529B; white-space: pre; }" +
|
||||
".unlocalized { background-color: #FEEFB3; color: #9F6000; white-space: pre; }"
|
||||
var html = NSXMLDocument(rootElement: NSXMLElement(name: "html"))
|
||||
html.DTD = NSXMLDTD()
|
||||
html.DTD!.name = html.rootElement()!.name
|
||||
html.characterEncoding = "UTF-8"
|
||||
html.documentContentKind = NSXMLDocumentContentKind.XHTMLKind
|
||||
var body = NSXMLElement(name: "body")
|
||||
var head = NSXMLElement(name: "head")
|
||||
html.rootElement()!.addChild(head)
|
||||
html.rootElement()!.addChild(body)
|
||||
head.addChild(NSXMLElement(name: "meta", attributes: ["charset": html.characterEncoding!]))
|
||||
head.addChild(NSXMLElement(name: "title", stringValue: "Sparkle Localizations Report"))
|
||||
head.addChild(NSXMLElement(name: "style", stringValue: css))
|
||||
|
||||
let locale = NSLocale.currentLocale()
|
||||
for dirEntry in dirContents {
|
||||
if NSString(string: dirEntry).pathExtension != "lproj" || dirEntry == "en.lproj" {
|
||||
continue
|
||||
}
|
||||
|
||||
let lang = locale.displayNameForKey(NSLocaleLanguageCode, value: NSString(string: dirEntry).stringByDeletingPathExtension)
|
||||
body.addChild(NSXMLElement(name: "h1", stringValue: "\(dirEntry) (\(lang!))"))
|
||||
|
||||
let stringsPath = NSString(string: dirPath.stringByAppendingPathComponent(dirEntry)).stringByAppendingPathComponent("Sparkle.strings")
|
||||
let stringsDict = NSDictionary(contentsOfFile: stringsPath)
|
||||
if stringsDict == nil {
|
||||
die("Invalid strings file \(dirEntry)")
|
||||
continue
|
||||
}
|
||||
|
||||
var missing: [String] = []
|
||||
var unlocalized: [String] = []
|
||||
var unused: [String] = []
|
||||
|
||||
for key in enStringsDictKeys {
|
||||
let str = stringsDict?.objectForKey(key) as? String
|
||||
if str == nil {
|
||||
missing.append(key as! String)
|
||||
} else if let enStr = enStringsDict?.objectForKey(key) as? String {
|
||||
if enStr == str {
|
||||
unlocalized.append(key as! String)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let stringsDictKeys = stringsDict!.allKeys
|
||||
for key in stringsDictKeys {
|
||||
if enStringsDict?.objectForKey(key) == nil {
|
||||
unused.append(key as! String)
|
||||
}
|
||||
}
|
||||
|
||||
let sorter = { (s1: String, s2: String) -> Bool in
|
||||
return s1 < s2
|
||||
}
|
||||
missing.sortInPlace(sorter)
|
||||
unlocalized.sortInPlace(sorter)
|
||||
unused.sortInPlace(sorter)
|
||||
|
||||
let addRow = { (prefix: String, cssClass: String, key: String) -> Void in
|
||||
body.addChild(NSXMLElement(name: "span", attributes: ["class": cssClass], stringValue: [prefix, key].joinWithSeparator(" ") + "\n"))
|
||||
}
|
||||
|
||||
for key in missing {
|
||||
addRow("Missing", "missing", key)
|
||||
}
|
||||
for key in unlocalized {
|
||||
addRow("Unlocalized", "unlocalized", key)
|
||||
}
|
||||
for key in unused {
|
||||
addRow("Unused", "unused", key)
|
||||
}
|
||||
}
|
||||
|
||||
var err: NSError?
|
||||
if !html.XMLData.writeToFile(htmlPath!, atomically: true) {
|
||||
die("Can't write report: \(err)")
|
||||
}
|
||||
@@ -9,7 +9,11 @@
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
@class SUAppcastItem;
|
||||
@@ -19,6 +23,7 @@ SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
@property (copy) NSDictionary *httpHeaders;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||
|
||||
@property (readonly, copy) NSArray *items;
|
||||
@end
|
||||
|
||||
@@ -30,7 +30,10 @@
|
||||
if (!attrName) {
|
||||
continue;
|
||||
}
|
||||
dictionary[attrName] = [attribute stringValue];
|
||||
NSString *attributeStringValue = [attribute stringValue];
|
||||
if (attributeStringValue != nil) {
|
||||
[dictionary setObject:attributeStringValue forKey:attrName];
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
@@ -93,147 +96,166 @@
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSArray *appcastItems = [self parseAppcastItemsFromXMLFile:[NSURL fileURLWithPath:self.downloadFilename] error:&error];
|
||||
|
||||
NSXMLDocument *document = nil;
|
||||
BOOL failed = NO;
|
||||
NSArray *xmlItems = nil;
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
|
||||
if (self.downloadFilename)
|
||||
{
|
||||
NSUInteger options = 0;
|
||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
||||
document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:self.downloadFilename] options:options error:&error];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = YES;
|
||||
if (appcastItems) {
|
||||
self.items = appcastItems;
|
||||
self.completionBlock(nil);
|
||||
self.completionBlock = nil;
|
||||
} else {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary
|
||||
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
|
||||
forKey: NSLocalizedDescriptionKey];
|
||||
if (error) {
|
||||
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
|
||||
}
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUAppcastParseError
|
||||
userInfo:userInfo]];
|
||||
}
|
||||
}
|
||||
|
||||
if (nil == document)
|
||||
{
|
||||
failed = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlItems = [document nodesForXPath:@"/rss/channel/item" error:&error];
|
||||
if (nil == xmlItems)
|
||||
{
|
||||
failed = YES;
|
||||
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
|
||||
{
|
||||
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
NSString *attrName = [self sparkleNamespacedNameOfNode:attribute];
|
||||
if (!attrName) {
|
||||
continue;
|
||||
}
|
||||
NSString *stringValue = [attribute stringValue];
|
||||
if (stringValue) {
|
||||
[dictionary setObject:stringValue forKey:attrName];
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
if (failed == NO)
|
||||
{
|
||||
-(NSString *)sparkleNamespacedNameOfNode:(NSXMLNode *)node {
|
||||
// XML namespace prefix is semantically meaningless, so compare namespace URI
|
||||
// NS URI isn't used to fetch anything, and must match exactly, so we look for http:// not https://
|
||||
if ([[node URI] isEqualToString:@"http://www.andymatuschak.org/xml-namespaces/sparkle"]) {
|
||||
NSString *localName = [node localName];
|
||||
assert(localName);
|
||||
return [@"sparkle:" stringByAppendingString:localName];
|
||||
} else {
|
||||
return [node name]; // Backwards compatibility
|
||||
}
|
||||
}
|
||||
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
|
||||
if (errorp) {
|
||||
*errorp = nil;
|
||||
}
|
||||
|
||||
if (!appcastFile) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
||||
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:appcastFile options:options error:errorp];
|
||||
if (nil == document) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSArray *xmlItems = [document nodesForXPath:@"/rss/channel/item" error:errorp];
|
||||
if (nil == xmlItems) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
|
||||
while((node = [nodeEnum nextObject])) {
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
|
||||
while (failed == NO && (node = [nodeEnum nextObject]))
|
||||
{
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
if ([[node children] count])
|
||||
{
|
||||
node = [node childAtIndex:0];
|
||||
while (nil != node)
|
||||
{
|
||||
NSString *name = [node name];
|
||||
if (name)
|
||||
{
|
||||
NSMutableArray *nodes = nodesDict[name];
|
||||
if (nodes == nil)
|
||||
{
|
||||
nodes = [NSMutableArray array];
|
||||
nodesDict[name] = nodes;
|
||||
}
|
||||
[nodes addObject:node];
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
if ([[node children] count]) {
|
||||
node = [node childAtIndex:0];
|
||||
while (nil != node) {
|
||||
NSString *name = [self sparkleNamespacedNameOfNode:node];
|
||||
if (name) {
|
||||
NSMutableArray *nodes = [nodesDict objectForKey:name];
|
||||
if (nodes == nil) {
|
||||
nodes = [NSMutableArray array];
|
||||
[nodesDict setObject:nodes forKey:name];
|
||||
}
|
||||
node = [node nextSibling];
|
||||
[nodes addObject:node];
|
||||
}
|
||||
node = [node nextSibling];
|
||||
}
|
||||
}
|
||||
|
||||
for (NSString *name in nodesDict)
|
||||
{
|
||||
node = [self bestNodeInNodes:nodesDict[name]];
|
||||
if ([name isEqualToString:SURSSElementEnclosure])
|
||||
{
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
||||
dict[name] = encDict;
|
||||
|
||||
}
|
||||
else if ([name isEqualToString:SURSSElementPubDate])
|
||||
{
|
||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
||||
NSString *string = node.stringValue;
|
||||
if (string) {
|
||||
NSDate *date = [NSDate dateWithNaturalLanguageString:string];
|
||||
if (date)
|
||||
dict[name] = date;
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementDeltas])
|
||||
{
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:SURSSElementEnclosure])
|
||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
||||
}
|
||||
dict[name] = deltas;
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||
NSMutableArray *tags = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
NSString *childName = child.name;
|
||||
if (childName)
|
||||
[tags addObject:childName];
|
||||
}
|
||||
dict[name] = tags;
|
||||
}
|
||||
else if (name != nil)
|
||||
{
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
dict[name] = theValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||
if (anItem)
|
||||
{
|
||||
[appcastItems addObject:anItem];
|
||||
for (NSString *name in nodesDict) {
|
||||
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
|
||||
if ([name isEqualToString:SURSSElementEnclosure]) {
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||
[dict setObject:encDict forKey:name];
|
||||
}
|
||||
else
|
||||
{
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||
// We don't want to parse and create a NSDate instance -
|
||||
// that's a risk we can avoid. We don't use the date anywhere other
|
||||
// than it being accessible from SUAppcastItem
|
||||
NSString *dateString = node.stringValue;
|
||||
if (dateString) {
|
||||
[dict setObject:dateString forKey:name];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:SURSSElementEnclosure]) {
|
||||
[deltas addObject:[self attributesOfNode:(NSXMLElement *)child]];
|
||||
}
|
||||
}
|
||||
[dict setObject:deltas forKey:name];
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||
NSMutableArray *tags = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
NSString *childName = child.name;
|
||||
if (childName) {
|
||||
[tags addObject:childName];
|
||||
}
|
||||
}
|
||||
[dict setObject:tags forKey:name];
|
||||
}
|
||||
[nodesDict removeAllObjects];
|
||||
[dict removeAllObjects];
|
||||
else if (name != nil) {
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
[dict setObject:theValue forKey:name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||
if (anItem) {
|
||||
[appcastItems addObject:anItem];
|
||||
}
|
||||
else {
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUAppcastParseError
|
||||
userInfo:@{NSLocalizedDescriptionKey: errString}];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
self.items = appcastItems;
|
||||
|
||||
if ([appcastItems count]) {
|
||||
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
|
||||
[appcastItems sortUsingDescriptors:@[sort]];
|
||||
self.items = appcastItems;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil) }]];
|
||||
} else {
|
||||
self.completionBlock(nil);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
return appcastItems;
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
||||
@@ -253,14 +275,18 @@
|
||||
|
||||
- (void)reportError:(NSError *)error
|
||||
{
|
||||
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
|
||||
|
||||
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||
NSUnderlyingErrorKey: error,
|
||||
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
|
||||
}]);
|
||||
}];
|
||||
|
||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
|
||||
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:userInfo]);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
|
||||
@@ -268,7 +294,7 @@
|
||||
{
|
||||
// We use this method to pick out the localized version of a node when one's available.
|
||||
if ([nodes count] == 1)
|
||||
return nodes[0];
|
||||
return [nodes objectAtIndex:0];
|
||||
else if ([nodes count] == 0)
|
||||
return nil;
|
||||
|
||||
@@ -279,12 +305,24 @@
|
||||
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
||||
[languages addObject:(lang ? lang : @"")];
|
||||
}
|
||||
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
|
||||
lang = [[NSBundle preferredLocalizationsFromArray:languages] objectAtIndex:0];
|
||||
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
||||
if (i == NSNotFound) {
|
||||
i = 0;
|
||||
}
|
||||
return nodes[i];
|
||||
return [nodes objectAtIndex:i];
|
||||
}
|
||||
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates {
|
||||
SUAppcast *other = [SUAppcast new];
|
||||
NSMutableArray *nonDeltaItems = [NSMutableArray new];
|
||||
|
||||
for(SUAppcastItem *item in self.items) {
|
||||
if (![item isDeltaUpdate]) [nonDeltaItems addObject:item];
|
||||
}
|
||||
|
||||
other.items = nonDeltaItems;
|
||||
return other;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,12 +9,16 @@
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@@ -32,6 +36,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
@interface SUAppcastItem ()
|
||||
@property (copy, readwrite) NSString *title;
|
||||
@property (copy, readwrite) NSDate *date;
|
||||
@property (copy, readwrite) NSString *dateString;
|
||||
@property (copy, readwrite) NSString *itemDescription;
|
||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@@ -31,7 +31,7 @@
|
||||
@end
|
||||
|
||||
@implementation SUAppcastItem
|
||||
@synthesize date;
|
||||
@synthesize dateString;
|
||||
@synthesize deltaUpdates;
|
||||
@synthesize displayVersionString;
|
||||
@synthesize DSASignature;
|
||||
@@ -47,12 +47,18 @@
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
return self.propertiesDictionary[SURSSElementEnclosure][SUAppcastAttributeDeltaFrom] != nil;
|
||||
NSDictionary *rssElementEnclosure = [self.propertiesDictionary objectForKey:SURSSElementEnclosure];
|
||||
return [rssElementEnclosure objectForKey:SUAppcastAttributeDeltaFrom] != nil;
|
||||
}
|
||||
|
||||
- (BOOL)isCriticalUpdate
|
||||
{
|
||||
return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||
return [[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||
}
|
||||
|
||||
- (BOOL)isInformationOnlyUpdate
|
||||
{
|
||||
return self.infoURL && !self.fileURL;
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict
|
||||
@@ -64,7 +70,7 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
id enclosure = dict[SURSSElementEnclosure];
|
||||
NSDictionary *enclosure = [dict objectForKey:SURSSElementEnclosure];
|
||||
|
||||
// Try to find a version string.
|
||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||
@@ -74,17 +80,17 @@
|
||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = enclosure[SUAppcastAttributeVersion];
|
||||
NSString *newVersion = [enclosure objectForKey:SUAppcastAttributeVersion];
|
||||
if (newVersion == nil) {
|
||||
newVersion = dict[SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
newVersion = [dict objectForKey:SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
}
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, enclosure[SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
|
||||
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, [enclosure objectForKey:SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
|
||||
|
||||
// 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.
|
||||
NSArray *fileComponents = [enclosure[SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
||||
NSArray *fileComponents = [[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
||||
if ([fileComponents count] > 1) {
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
@@ -98,11 +104,11 @@
|
||||
}
|
||||
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = dict[SURSSElementTitle];
|
||||
self.date = dict[SURSSElementPubDate];
|
||||
self.itemDescription = dict[SURSSElementDescription];
|
||||
self.title = [dict objectForKey:SURSSElementTitle];
|
||||
self.dateString = [dict objectForKey:SURSSElementPubDate];
|
||||
self.itemDescription = [dict objectForKey:SURSSElementDescription];
|
||||
|
||||
NSString *theInfoURL = dict[SURSSElementLink];
|
||||
NSString *theInfoURL = [dict objectForKey:SURSSElementLink];
|
||||
if (theInfoURL) {
|
||||
if (![theInfoURL isKindOfClass:[NSString class]]) {
|
||||
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
@@ -120,7 +126,7 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *enclosureURLString = enclosure[SURSSAttributeURL];
|
||||
NSString *enclosureURLString = [enclosure objectForKey:SURSSAttributeURL];
|
||||
if (!enclosureURLString && !theInfoURL) {
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
@@ -129,20 +135,21 @@
|
||||
}
|
||||
|
||||
if (enclosureURLString) {
|
||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
// Sparkle used to always URL-encode, so for backwards compatibility spaces in URLs must be forgiven.
|
||||
NSString *fileURLString = [enclosureURLString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = enclosure[SUAppcastAttributeDSASignature];
|
||||
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
|
||||
}
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = dict[SUAppcastElementMinimumSystemVersion];
|
||||
self.maximumSystemVersion = dict[SUAppcastElementMaximumSystemVersion];
|
||||
self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion];
|
||||
self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion];
|
||||
|
||||
NSString *shortVersionString = enclosure[SUAppcastAttributeShortVersionString];
|
||||
NSString *shortVersionString = [enclosure objectForKey:SUAppcastAttributeShortVersionString];
|
||||
if (nil == shortVersionString) {
|
||||
shortVersionString = dict[SUAppcastAttributeShortVersionString]; // fall back on the <item>
|
||||
shortVersionString = [dict objectForKey:SUAppcastAttributeShortVersionString]; // fall back on the <item>
|
||||
}
|
||||
|
||||
if (shortVersionString) {
|
||||
@@ -152,28 +159,33 @@
|
||||
}
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = dict[SUAppcastElementReleaseNotesLink];
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
if (releaseNotesString) {
|
||||
self.releaseNotesURL = [NSURL URLWithString:releaseNotesString];
|
||||
NSURL *url = [NSURL URLWithString:releaseNotesString];
|
||||
if ([url isFileURL]) {
|
||||
SULog(@"Release notes with file:// URLs are not supported");
|
||||
} else {
|
||||
self.releaseNotesURL = url;
|
||||
}
|
||||
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
} else {
|
||||
self.releaseNotesURL = nil;
|
||||
}
|
||||
|
||||
NSArray *deltaDictionaries = dict[SUAppcastElementDeltas];
|
||||
NSArray *deltaDictionaries = [dict objectForKey:SUAppcastElementDeltas];
|
||||
if (deltaDictionaries) {
|
||||
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||
NSString *deltaFrom = deltaDictionary[SUAppcastAttributeDeltaFrom];
|
||||
NSString *deltaFrom = [deltaDictionary objectForKey:SUAppcastAttributeDeltaFrom];
|
||||
if (!deltaFrom) continue;
|
||||
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
|
||||
fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary;
|
||||
[fakeAppCastDict setObject:deltaDictionary forKey:SURSSElementEnclosure];
|
||||
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
|
||||
|
||||
deltas[deltaFrom] = deltaItem;
|
||||
[deltas setObject:deltaItem forKey:deltaFrom];
|
||||
}
|
||||
self.deltaUpdates = deltas;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
@property (assign) BOOL postponingInstallation;
|
||||
@property (assign) BOOL showErrors;
|
||||
@property (assign) BOOL willUpdateOnTermination;
|
||||
@property (assign) BOOL isTerminating;
|
||||
@property (strong) SUAutomaticUpdateAlert *alert;
|
||||
@property (strong) NSTimer *showUpdateAlertTimer;
|
||||
|
||||
@@ -36,6 +37,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
@synthesize postponingInstallation;
|
||||
@synthesize showErrors;
|
||||
@synthesize willUpdateOnTermination;
|
||||
@synthesize isTerminating;
|
||||
@synthesize alert;
|
||||
@synthesize showUpdateAlertTimer;
|
||||
|
||||
@@ -63,6 +65,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
|
||||
|
||||
// Sudden termination is available on 10.6+
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
@@ -103,6 +106,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
if (self.willUpdateOnTermination)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil];
|
||||
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo enableSuddenTermination];
|
||||
|
||||
@@ -128,6 +133,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
self.isTerminating = NO;
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[super abortUpdate];
|
||||
@@ -150,7 +156,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
|
||||
case SUInstallLaterChoice:
|
||||
self.postponingInstallation = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
self.interruptible = YES;
|
||||
break;
|
||||
@@ -162,6 +167,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
if (relaunch) {
|
||||
@@ -172,11 +178,31 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||
}
|
||||
|
||||
- (void)systemWillPowerOff:(NSNotification *)__unused note
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil)
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)__unused note
|
||||
{
|
||||
// We don't want to terminate the app if the user or someone else initiated a termination
|
||||
// Use a property instead of passing an argument to installWithToolAndRelaunch:
|
||||
// because we give the delegate an invocation to our install methods and
|
||||
// this code was added later :|
|
||||
self.isTerminating = YES;
|
||||
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
}
|
||||
|
||||
- (void)terminateApp
|
||||
{
|
||||
if (!self.isTerminating) {
|
||||
[super terminateApp];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if (self.showErrors) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||
|
||||
@@ -9,17 +9,15 @@
|
||||
#import "SUBasicUpdateDriver.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUUpdateValidator.h"
|
||||
|
||||
@interface SUBasicUpdateDriver ()
|
||||
|
||||
@@ -31,6 +29,8 @@
|
||||
@property (copy) NSString *tempDir;
|
||||
@property (copy) NSString *relaunchPath;
|
||||
|
||||
@property (nonatomic) SUUpdateValidator *updateValidator;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUBasicUpdateDriver
|
||||
@@ -43,6 +43,8 @@
|
||||
@synthesize tempDir;
|
||||
@synthesize relaunchPath;
|
||||
|
||||
@synthesize updateValidator = _updateValidator;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
@@ -82,12 +84,28 @@
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
SUAppcastItem *item = nil;
|
||||
for(SUAppcastItem *candidate in appcastItems) {
|
||||
if ([[self class] hostSupportsItem:candidate]) {
|
||||
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||
item = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item && deltaItem) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
|
||||
*deltaItem = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
||||
@@ -97,15 +115,20 @@
|
||||
|
||||
// Check minimum and maximum System Version
|
||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
|
||||
}
|
||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
return minimumVersionOK && maximumVersionOK;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
@@ -115,7 +138,7 @@
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
{
|
||||
return ui && [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
@@ -133,17 +156,17 @@
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||
if ([item isDeltaUpdate]) {
|
||||
self.nonDeltaUpdateItem = [[self.updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
|
||||
}
|
||||
}
|
||||
else // If not, we'll take care of it ourselves.
|
||||
{
|
||||
// Find the first update we can actually use.
|
||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
||||
do {
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
|
||||
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
// Find the best supported update
|
||||
SUAppcastItem *deltaUpdateItem = nil;
|
||||
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||
|
||||
if (item && deltaUpdateItem) {
|
||||
self.nonDeltaUpdateItem = item;
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
@@ -187,8 +210,36 @@
|
||||
}]];
|
||||
}
|
||||
|
||||
- (NSString *)appCachePath
|
||||
{
|
||||
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cachePath = nil;
|
||||
if ([cachePaths count]) {
|
||||
cachePath = [cachePaths objectAtIndex:0];
|
||||
}
|
||||
if (!cachePath) {
|
||||
SULog(@"Failed to find user's cache directory! Using system default");
|
||||
cachePath = NSTemporaryDirectory();
|
||||
}
|
||||
|
||||
NSString *name = [self.host.bundle bundleIdentifier];
|
||||
if (!name) {
|
||||
name = [self.host name];
|
||||
}
|
||||
|
||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
||||
return cachePath;
|
||||
}
|
||||
|
||||
- (void)downloadUpdate
|
||||
{
|
||||
// Clear cache directory so that downloads can't possibly accumulate inside
|
||||
NSString *appCachePath = [self appCachePath];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
|
||||
}
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
|
||||
@@ -202,13 +253,14 @@
|
||||
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
{
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
||||
|
||||
|
||||
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:downloadFileName];
|
||||
|
||||
NSString *appCachePath = [self appCachePath];
|
||||
|
||||
self.tempDir = [appCachePath stringByAppendingPathComponent:downloadFileName];
|
||||
int cnt = 1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
||||
{
|
||||
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
||||
self.tempDir = [appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
||||
}
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
@@ -224,83 +276,6 @@
|
||||
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
/**
|
||||
* If the update is a package, then it must be signed using DSA. No other verification is done.
|
||||
*
|
||||
* If the update is a bundle, then it must meet any one of:
|
||||
*
|
||||
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
|
||||
*
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
|
||||
if (installSourcePath == nil) {
|
||||
SULog(@"No suitable install is found in the update. The update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Modern packages are not distributed as bundles and are code signed differently than regular applications
|
||||
if (isPackage) {
|
||||
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
|
||||
if (!packageValidated) {
|
||||
SULog(@"DSA signature validation of the package failed. The update will be rejected.");
|
||||
}
|
||||
|
||||
return packageValidated;
|
||||
}
|
||||
|
||||
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
|
||||
if (newBundle == nil) {
|
||||
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
||||
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath];
|
||||
|
||||
if (dsaKeysMatch) {
|
||||
NSError *error = nil;
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) {
|
||||
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
||||
|
||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) {
|
||||
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||
{
|
||||
assert(self.updateItem);
|
||||
@@ -310,22 +285,26 @@
|
||||
|
||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||
{
|
||||
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
|
||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||
if (!failingUrl) {
|
||||
failingUrl = [self.updateItem fileURL];
|
||||
}
|
||||
|
||||
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
||||
[[self.updater delegate] updater:self.updater
|
||||
failedToDownloadUpdate:self.updateItem
|
||||
error:error];
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
||||
NSUnderlyingErrorKey: error,
|
||||
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
|
||||
}]];
|
||||
}];
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
||||
}
|
||||
|
||||
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
@@ -337,14 +316,28 @@
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath]];
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:self.updater.decryptionPassword];
|
||||
|
||||
BOOL success;
|
||||
if (!unarchiver) {
|
||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
|
||||
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated];
|
||||
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
|
||||
|
||||
success = self.updateValidator.canValidate;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
[self unarchiverDidFail:nil];
|
||||
} else {
|
||||
unarchiver.delegate = self;
|
||||
[unarchiver start];
|
||||
}
|
||||
unarchiver.delegate = self;
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
- (void)failedToApplyDeltaUpdate
|
||||
@@ -365,6 +358,9 @@
|
||||
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
// No longer needed
|
||||
self.updateValidator = nil;
|
||||
|
||||
if ([self.updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
@@ -379,16 +375,42 @@
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
// Creates intermediate directories up until targetPath if they don't already exist,
|
||||
// and removes the directory at targetPath if one already exists there
|
||||
- (BOOL)preparePathForRelaunchTool:(NSString *)targetPath error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
NSFileManager *fileManager = [[NSFileManager alloc] init];
|
||||
if ([fileManager fileExistsAtPath:targetPath]) {
|
||||
NSError *removeError = nil;
|
||||
if (![fileManager removeItemAtPath:targetPath error:&removeError]) {
|
||||
if (error != NULL) {
|
||||
*error = removeError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
NSError *createDirectoryError = nil;
|
||||
if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&createDirectoryError]) {
|
||||
if (error != NULL) {
|
||||
*error = createDirectoryError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
assert(self.updateItem);
|
||||
|
||||
if (![self validateUpdateDownloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature publicDSAKey:self.host.publicDSAKey])
|
||||
{
|
||||
assert(self.updateValidator);
|
||||
|
||||
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
||||
if (!validationCheckSuccess) {
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
|
||||
};
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
|
||||
};
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
|
||||
return;
|
||||
}
|
||||
@@ -424,23 +446,43 @@
|
||||
// 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.
|
||||
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
||||
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
||||
if (relaunchPathToCopy != nil) {
|
||||
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];
|
||||
|
||||
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
|
||||
self.relaunchPath = targetPath;
|
||||
} else {
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
|
||||
}]];
|
||||
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
||||
NSString *relaunchCopyTargetPath = nil;
|
||||
NSError *error = nil;
|
||||
BOOL copiedRelaunchPath = NO;
|
||||
|
||||
if (relaunchToolSourcePath) {
|
||||
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
NSURL *relaunchToolSourceURL = [NSURL fileURLWithPath:relaunchToolSourcePath];
|
||||
NSURL *relaunchCopyTargetURL = [NSURL fileURLWithPath:relaunchCopyTargetPath];
|
||||
|
||||
// We only need to run our copy of the app by spawning a task
|
||||
// Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs
|
||||
if ([self preparePathForRelaunchTool:relaunchCopyTargetPath error:&error] && [fileManager copyItemAtURL:relaunchToolSourceURL toURL:relaunchCopyTargetURL error:&error]) {
|
||||
copiedRelaunchPath = YES;
|
||||
|
||||
// We probably don't need to release the quarantine, but we'll do it just in case it's necessary.
|
||||
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
|
||||
SULog(@"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!copiedRelaunchPath) {
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@",
|
||||
relaunchToolSourcePath, relaunchCopyTargetPath, (error ? [error localizedDescription] : @"")],
|
||||
}]];
|
||||
return;
|
||||
}
|
||||
|
||||
self.relaunchPath = relaunchCopyTargetPath; // Set for backwards compatibility, in case any delegates modify it
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[updaterDelegate updaterWillRelaunchApplication:self.updater];
|
||||
@@ -450,9 +492,8 @@
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@ and %@)", relaunchToolSourcePath, self.relaunchPath],
|
||||
}]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -460,6 +501,7 @@
|
||||
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
|
||||
}
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
@@ -469,6 +511,7 @@
|
||||
[self terminateApp];
|
||||
}
|
||||
|
||||
// Note: this is overridden by the automatic update driver to not terminate in some cases
|
||||
- (void)terminateApp
|
||||
{
|
||||
[NSApp terminate:self];
|
||||
@@ -511,7 +554,12 @@
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||
SULog(@"Error: %@ %@ (URL %@)", error.localizedDescription, error.localizedFailureReason, error.userInfo[NSURLErrorFailingURLErrorKey]);
|
||||
NSError *errorToDisplay = error;
|
||||
int finiteRecursion=5;
|
||||
do {
|
||||
SULog(@"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, [errorToDisplay.userInfo objectForKey:NSURLErrorFailingURLErrorKey]);
|
||||
errorToDisplay = [errorToDisplay.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||
} while(--finiteRecursion && errorToDisplay);
|
||||
}
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
#define SUBINARYDELTAAPPLY_H
|
||||
|
||||
@class NSString;
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose);
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error);
|
||||
|
||||
#endif
|
||||
@@ -25,12 +25,14 @@ static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFil
|
||||
return success;
|
||||
}
|
||||
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose)
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error)
|
||||
{
|
||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||
if (!x) {
|
||||
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to open %@. Giving up.", patchFile] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||
@@ -80,13 +82,17 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
}
|
||||
|
||||
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "Unable to identify diff-version %u in delta. Giving up.\n", majorDiffVersion);
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.", majorDiffVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "A later version is needed to apply this patch (on major version %u, but patch requests version %u).\n", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion);
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
@@ -95,8 +101,10 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
|
||||
|
||||
if (!expectedBeforeHash || !expectedAfterHash) {
|
||||
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -106,13 +114,23 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
|
||||
if (!beforeHash) {
|
||||
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [source fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![beforeHash isEqualToString:expectedBeforeHash]) {
|
||||
fprintf(stderr, "\nSource doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", expectedBeforeHash, beforeHash] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -120,12 +138,22 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
}
|
||||
|
||||
if (!removeTree(destination)) {
|
||||
fprintf(stderr, "\nFailed to remove %s\n", [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
if (!copyTree(source, destination)) {
|
||||
fprintf(stderr, "\nFailed to copy %s to %s\n", [source fileSystemRepresentation], [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
@@ -149,8 +177,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) ||
|
||||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||
if (!removeTree(destinationFilePath)) {
|
||||
fprintf(stderr, "\n%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_OLD_KEY, [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ or %@: failed to remove %@", @DELETE_KEY, @DELETE_THEN_EXTRACT_OLD_KEY, destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
|
||||
if (verbose) {
|
||||
@@ -164,8 +197,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
|
||||
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
|
||||
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) {
|
||||
fprintf(stderr, "\nUnable to patch %s to destination %s\n", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to patch %@ to destination %@", sourceFilePath, destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -175,8 +213,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
(!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
|
||||
|
||||
if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) {
|
||||
fprintf(stderr, "\nUnable to extract file to %s\n", [destinationFilePath fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -193,8 +236,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
||||
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
|
||||
if (!modifyPermissions(destinationFilePath, mode)) {
|
||||
fprintf(stderr, "\nUnable to modify permissions (%s) on file %s\n", value, [destinationFilePath fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%@) on file %@", @(value), destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -209,18 +257,28 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
}
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
|
||||
if (!afterHash) {
|
||||
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![afterHash isEqualToString:expectedAfterHash]) {
|
||||
fprintf(stderr, "\nDestination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", expectedAfterHash, afterHash] }];
|
||||
}
|
||||
removeTree(destination);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
return 0;
|
||||
return YES;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#import "SUFileManager.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <fcntl.h>
|
||||
@@ -145,7 +146,9 @@ NSData *hashOfFileContents(FTSENT *ent)
|
||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
{
|
||||
char pathBuffer[PATH_MAX] = {0};
|
||||
[path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
||||
if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
char * const sourcePaths[] = {pathBuffer, 0};
|
||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
@@ -218,7 +221,7 @@ BOOL removeTree(NSString *path)
|
||||
|
||||
BOOL copyTree(NSString *source, NSString *dest)
|
||||
{
|
||||
return [[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
|
||||
return [[SUFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
|
||||
}
|
||||
|
||||
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
||||
@@ -228,12 +231,12 @@ BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
||||
if (!attributes) {
|
||||
return NO;
|
||||
}
|
||||
NSNumber *permissions = attributes[NSFilePosixPermissions];
|
||||
NSNumber *permissions = [attributes objectForKey:NSFilePosixPermissions];
|
||||
if (!permissions) {
|
||||
return NO;
|
||||
}
|
||||
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
||||
int (*changeModeFunc)(const char *, mode_t) = [attributes[NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
||||
int (*changeModeFunc)(const char *, mode_t) = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
||||
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
|
||||
@class NSString;
|
||||
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose);
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error);
|
||||
|
||||
#endif
|
||||
@@ -87,7 +87,7 @@ static NSDictionary *infoForFile(FTSENT *ent)
|
||||
|
||||
static bool aclExists(const FTSENT *ent)
|
||||
{
|
||||
// OS X does not currently support ACLs for symlinks
|
||||
// macOS does not currently support ACLs for symlinks
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
return NO;
|
||||
}
|
||||
@@ -221,30 +221,32 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne
|
||||
return YES;
|
||||
}
|
||||
|
||||
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose)
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error)
|
||||
{
|
||||
if (majorVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "Version provided (%u) is not valid\n", majorVersion);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (majorVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", majorVersion);
|
||||
return 1;
|
||||
}
|
||||
assert(source);
|
||||
assert(destination);
|
||||
assert(patchFile);
|
||||
assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||
|
||||
SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
||||
|
||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||
|
||||
char pathBuffer[PATH_MAX] = {0};
|
||||
[source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
||||
if (![source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from source %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char *sourcePaths[] = {pathBuffer, 0};
|
||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on source: %@", @(strerror(errno))] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -265,19 +267,34 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
fprintf(stderr, "\nFailed to retrieve info for file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info for file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
originalTreeState[key] = info;
|
||||
|
||||
if (aclExists(ent)) {
|
||||
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in before-tree on file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in before-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (codeSignatureExtendedAttributeExists(ent)) {
|
||||
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
fts_close(fts);
|
||||
@@ -285,8 +302,13 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
|
||||
|
||||
if (!beforeHash) {
|
||||
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [source fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
|
||||
@@ -300,13 +322,23 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
}
|
||||
|
||||
pathBuffer[0] = 0;
|
||||
[destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
||||
if (![destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from destination %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
sourcePaths[0] = pathBuffer;
|
||||
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on destination: %@", @(strerror(errno))] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
@@ -322,8 +354,13 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
fprintf(stderr, "\nFailed to retrieve info from file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info from file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs,
|
||||
@@ -334,18 +371,33 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
if (!IS_VALID_PERMISSIONS(permissions)) {
|
||||
fprintf(stderr, "\nInvalid file permissions after-tree on file %s\nOnly permissions with modes 0755 and 0644 are supported\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
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)) {
|
||||
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in after-tree on file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in after-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (codeSignatureExtendedAttributeExists(ent)) {
|
||||
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %s\n", ent->fts_path);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
@@ -372,8 +424,13 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
|
||||
if (!afterHash) {
|
||||
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -382,6 +439,16 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
if (!x) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write to %@", temporaryFile] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
|
||||
@@ -479,8 +546,13 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
if (!resultPath) {
|
||||
fprintf(stderr, "\nFailed to create patch from source %s and destination %s\n", [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch from source %@ and destination %@", operation.relativePath, resultPath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
@@ -511,5 +583,5 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return YES;
|
||||
}
|
||||
@@ -28,11 +28,11 @@ static void printUsage(NSString *programName)
|
||||
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
||||
}
|
||||
|
||||
static int runCreateCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 5) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUInteger numberOflagsFound = 0;
|
||||
@@ -54,7 +54,7 @@ static int runCreateCommand(NSString *programName, NSArray *args)
|
||||
|
||||
if (args.count - numberOflagsFound < 3) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL verbose = (verboseIndex != NSNotFound);
|
||||
@@ -65,7 +65,7 @@ static int runCreateCommand(NSString *programName, NSArray *args)
|
||||
versionComponents = [versionField componentsSeparatedByString:@"="];
|
||||
if (versionComponents.count != 2) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,16 @@ static int runCreateCommand(NSString *programName, NSArray *args)
|
||||
!versionComponents ?
|
||||
LATEST_DELTA_DIFF_MAJOR_VERSION :
|
||||
(SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided
|
||||
|
||||
if (patchVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "Version provided (%u) is not valid\n", patchVersion);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (patchVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", patchVersion);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||
for (NSString *argument in args) {
|
||||
@@ -83,37 +93,43 @@ static int runCreateCommand(NSString *programName, NSArray *args)
|
||||
|
||||
if (fileArgs.count != 3) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL isDirectory;
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: before-tree must be a directory\n");
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[1] isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: after-tree must be a directory\n");
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
return createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose);
|
||||
NSError *createDiffError = nil;
|
||||
if (!createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose, &createDiffError)) {
|
||||
fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static int runApplyCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 4) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL verbose = [args containsObject:VERBOSE_FLAG];
|
||||
|
||||
if (args.count == 4 && !verbose) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||
@@ -125,30 +141,36 @@ static int runApplyCommand(NSString *programName, NSArray *args)
|
||||
|
||||
if (fileArgs.count != 3) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL isDirectory;
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: before-tree must be a directory\n");
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
return applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose);
|
||||
NSError *applyDiffError = nil;
|
||||
if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, &applyDiffError)) {
|
||||
fprintf(stderr, "%s\n", [applyDiffError.localizedDescription UTF8String]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static int runVersionCommand(NSString *programName, NSArray *args)
|
||||
static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count > 1) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (args.count == 0) {
|
||||
@@ -158,7 +180,7 @@ static int runVersionCommand(NSString *programName, NSArray *args)
|
||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||
if (!x) {
|
||||
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
|
||||
return 1;
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||
@@ -184,7 +206,7 @@ static int runVersionCommand(NSString *programName, NSArray *args)
|
||||
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return YES;
|
||||
}
|
||||
|
||||
int main(int __unused argc, char __unused *argv[])
|
||||
@@ -201,7 +223,7 @@ int main(int __unused argc, char __unused *argv[])
|
||||
NSString *command = args[1];
|
||||
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
||||
|
||||
int result;
|
||||
BOOL result;
|
||||
if ([command isEqualToString:CREATE_COMMAND]) {
|
||||
result = runCreateCommand(programName, commandArguments);
|
||||
} else if ([command isEqualToString:APPLY_COMMAND]) {
|
||||
@@ -209,10 +231,10 @@ int main(int __unused argc, char __unused *argv[])
|
||||
} else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) {
|
||||
result = runVersionCommand(programName, commandArguments);
|
||||
} else {
|
||||
result = 1;
|
||||
result = NO;
|
||||
printUsage(programName);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -10,46 +10,91 @@
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUHost.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUBinaryDeltaUnarchiver
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// According to https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/MDImporters/Concepts/Troubleshooting.html
|
||||
// We should make sure mdimporter bundles have an up to date time in the event they were delta updated.
|
||||
// We used to invoke mdimport on the bundle but this is not a very good approach.
|
||||
// There's no need to do that for non-delta updates and for updates that contain no mdimporters.
|
||||
// Moreover, updating the timestamp on the mdimporter bundles is what developers have to do anyway when shipping their new update outside of Sparkle
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath
|
||||
{
|
||||
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:targetPath error:nil];
|
||||
NSString *rootType = [rootAttributes objectForKey:NSFileType];
|
||||
|
||||
if ([rootType isEqualToString:NSFileTypeDirectory]) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
|
||||
NSMutableArray *filesToUpdate = [[NSMutableArray alloc] init];
|
||||
for (NSURL *file in directoryEnumerator) {
|
||||
if ([file.pathExtension isEqualToString:@"mdimporter"]) {
|
||||
[filesToUpdate addObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
for (NSURL *file in filesToUpdate) {
|
||||
NSError *error = nil;
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:file error:&error]) {
|
||||
SULog(@"Error: During delta unarchiving, failed to touch %@", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
@autoreleasepool {
|
||||
@autoreleasepool {
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO);
|
||||
if (!result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
}
|
||||
else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
}
|
||||
}
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError);
|
||||
if (success) {
|
||||
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
}
|
||||
else {
|
||||
SULog(@"Applying delta patch failed with error: %@", applyDiffError);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self applyBinaryDelta];
|
||||
});
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self applyBinaryDelta];
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,10 +12,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
||||
+ (BOOL)hostApplicationIsCodeSigned;
|
||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath;
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -13,53 +13,46 @@
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecCodeRef hostCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
SecStaticCodeRef oldCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy host code %d", result);
|
||||
goto finally;
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle for update");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
|
||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
|
||||
// Aditionally, there are several reasons to stay away from deep verification and to prefer DSA signing the download archive instead.
|
||||
// See https://github.com/sparkle-project/Sparkle/pull/523#commitcomment-17549302 and https://github.com/sparkle-project/Sparkle/issues/543
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
||||
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
@@ -70,61 +63,52 @@
|
||||
SULog(@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
CFRelease(requirementString);
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:hostCode label:@"host info"];
|
||||
|
||||
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
finally:
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (oldCode) CFRelease(oldCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == noErr);
|
||||
}
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle");
|
||||
result = -1;
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
|
||||
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not passed
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", applicationPath);
|
||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
finally:
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
return (result == noErr);
|
||||
@@ -136,49 +120,28 @@ static id valueOrNSNull(id value) {
|
||||
|
||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
CFDictionaryRef signingInfo = nil;
|
||||
const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation;
|
||||
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
|
||||
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||
relevantInfo[key] = valueOrNSNull(signingDict[key]);
|
||||
[relevantInfo setObject:valueOrNSNull([signingDict objectForKey:key]) forKey:key];
|
||||
}
|
||||
NSDictionary *infoPlist = signingDict[@"info-plist"];
|
||||
relevantInfo[@"version"] = valueOrNSNull(infoPlist[@"CFBundleShortVersionString"]);
|
||||
relevantInfo[@"build"] = valueOrNSNull(infoPlist[(__bridge NSString *)kCFBundleVersionKey]);
|
||||
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
|
||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
|
||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
|
||||
SULog(@"%@: %@", label, relevantInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
{
|
||||
OSStatus result;
|
||||
SecCodeRef hostCode = NULL;
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) return NO;
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
NSBundle *newBundle;
|
||||
|
||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle");
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
@@ -190,7 +153,7 @@ static id valueOrNSNull(id value) {
|
||||
CFRelease(requirement);
|
||||
}
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
return NO;
|
||||
}
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ extern NSString *const SUPublicDSAKeyFileKey;
|
||||
extern NSString *const SUAutomaticallyUpdateKey;
|
||||
extern NSString *const SUAllowsAutomaticUpdatesKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKeyOld;
|
||||
extern NSString *const SUEnableSystemProfilingKey;
|
||||
extern NSString *const SUSendProfileInfoKey;
|
||||
extern NSString *const SULastProfileSubmitDateKey;
|
||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
||||
extern NSString *const SUDefaultsDomainKey;
|
||||
extern NSString *const SUEnableJavaScriptKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
|
||||
extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER.")));
|
||||
extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES.")));
|
||||
|
||||
@@ -38,10 +38,10 @@ NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||
NSString *const SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup";
|
||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
||||
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
||||
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
||||
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||
CFArrayRef items = NULL;
|
||||
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, 0, NULL, NULL, &items);
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
|
||||
if (status != errSecSuccess || !items) {
|
||||
if (items) {
|
||||
CFRelease(items);
|
||||
@@ -65,7 +65,13 @@
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
#import "SULog.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
@@ -19,6 +18,11 @@
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMG
|
||||
{
|
||||
@@ -70,18 +74,46 @@
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSArray *arguments = @[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
|
||||
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
|
||||
if (self.decryptionPassword) {
|
||||
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
// From the hdiutil docs:
|
||||
// read a null-terminated passphrase from standard input
|
||||
//
|
||||
// Add the null terminator, then the newline
|
||||
[passwordData appendData:[NSData dataWithBytes:"\0" length:1]];
|
||||
[passwordData appendData:promptData];
|
||||
promptData = passwordData;
|
||||
|
||||
[arguments addObject:@"-stdinpass"];
|
||||
}
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
{
|
||||
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
||||
|
||||
taskResult = [task result];
|
||||
output = [[task output] copy];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = @"/usr/bin/hdiutil";
|
||||
task.currentDirectoryPath = @"/";
|
||||
task.arguments = arguments;
|
||||
|
||||
NSPipe *inputPipe = [NSPipe pipe];
|
||||
NSPipe *outputPipe = [NSPipe pipe];
|
||||
|
||||
task.standardInput = inputPipe;
|
||||
task.standardOutput = outputPipe;
|
||||
|
||||
[task launch];
|
||||
|
||||
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||
[inputPipe.fileHandleForWriting closeFile];
|
||||
|
||||
// Read data to end *before* waiting until the task ends so we don't deadlock if the stdout buffer becomes full if we haven't consumed from it
|
||||
output = [outputPipe.fileHandleForReading readDataToEndOfFile];
|
||||
|
||||
[task waitUntilExit];
|
||||
taskResult = task.terminationStatus;
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
@@ -131,10 +163,16 @@
|
||||
dispatch_async(dispatch_get_main_queue(), delegateFailure);
|
||||
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
else
|
||||
if (mountedSuccessfully) {
|
||||
@try {
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(@"Failed to unmount %@", mountPoint);
|
||||
SULog(@"Exception: %@", exception);
|
||||
}
|
||||
} else {
|
||||
SULog(@"Can't mount DMG %@", self.archivePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
#ifndef SUERRORS_H
|
||||
#define SUERRORS_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
/**
|
||||
@@ -23,10 +27,11 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUNoUpdateError = 1001,
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
|
||||
// Downlaod phase errors.
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
|
||||
SUDownloadError = 2001,
|
||||
|
||||
// Extraction phase errors.
|
||||
SUUnarchivingError = 3000,
|
||||
SUSignatureError = 3001,
|
||||
@@ -38,7 +43,11 @@ typedef NS_ENUM(OSStatus, SUError) {
|
||||
SUMissingInstallerToolError = 4003,
|
||||
SURelaunchError = 4004,
|
||||
SUInstallationError = 4005,
|
||||
SUDowngradeError = 4006
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCancelledError = 4007,
|
||||
|
||||
// System phase errors
|
||||
SUSystemPowerOffError = 5000
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// SUFileManager.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/18/15.
|
||||
// Copyright (c) 2015 zgcoder. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* A class used for performing file operations that may also perform authorization if allowed and if permission is denied when trying to
|
||||
* perform them normally as the running user. All operations on this class may be used on thread other than the main thread.
|
||||
* This class provides basic file operations and stays away from including much application-level logic.
|
||||
*/
|
||||
@interface SUFileManager : NSObject
|
||||
|
||||
/**
|
||||
* Creates a file manager that will not authorize for file operations
|
||||
* @return A new file manager instance
|
||||
*/
|
||||
+ (instancetype)defaultManager;
|
||||
|
||||
/**
|
||||
* Creates a file manager that allows authorizing for file operations
|
||||
* @param authorizationToolPath Specifies the path to the tool that can perform file operations and be run as root.
|
||||
* This tool will be invoked when read or write access is denied when attempting ordinary file operations. See the `fileop` tool included in Sparkle.
|
||||
* @return A new file manager instance
|
||||
*
|
||||
* This method just creates the file manager. It doesn't acquire authorization immediately or if it doesn't need to.
|
||||
*/
|
||||
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath;
|
||||
|
||||
/**
|
||||
* Returns a file manager that allows or disallows authorizing for file operations based on the current file manager
|
||||
* @return A file manager instance that can perform authorized operations if the current file manager has already performed them.
|
||||
* If the current file manager instance hasn't yet performed authorized operations, then neither can the instance returned by this method
|
||||
*
|
||||
* This may return a newly created file manager or re-use the existing file manager depending on the current authorization rights.
|
||||
*/
|
||||
- (instancetype)fileManagerByPreservingAuthorizationRights;
|
||||
|
||||
/**
|
||||
* Creates a temporary directory on the same volume as a provided URL
|
||||
* @param preferredName A name that may be used when creating the temporary directory. Note that in the uncommon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL
|
||||
* @param appropriateURL A URL to a directory that resides on the volume that the temporary directory will be created on. In the uncommon case, the temporary directory may be created inside this directory.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return A URL pointing to the newly created temporary directory, or nil with a populated error object if an error occurs.
|
||||
*
|
||||
* When moving an item from a source to a destination, it is desirable to create a temporary intermediate destination on the same volume as the destination to ensure
|
||||
* that the item will be moved, and not copied, from the intermediate point to the final destination. This ensures file atomicity.
|
||||
*/
|
||||
- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)appropriateURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Creates a directory at the target URL
|
||||
* @param targetURL A URL pointing to the directory to create. The item at this URL must not exist, and the parent directory of this URL must already exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was created successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is an atomic operation.
|
||||
*/
|
||||
- (BOOL)makeDirectoryAtURL:(NSURL *)targetURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Moves an item from a source to a destination
|
||||
* @param sourceURL A URL pointing to the item to move. The item at this URL must exist.
|
||||
* @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was moved successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* If sourceURL and destinationURL reside on the same volume, this operation will be an atomic move operation.
|
||||
* Otherwise this will be equivalent to a copy & remove which will be a nonatomic operation.
|
||||
*/
|
||||
- (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Copies an item from a source to a destination
|
||||
* @param sourceURL A URL pointing to the item to move. The item at this URL must exist.
|
||||
* @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was copied successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Moves an item at a specified URL to the running user's trash directory
|
||||
* @param url A URL pointing to the item to move to the trash. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was moved to the trash successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
*
|
||||
* This method has to locate the trash directory and uses an intermediate temporary directory before trashing the item.
|
||||
* A copy may have to be done if the url is not on the same volume as the running user's trash directory.
|
||||
* If a failure occurs in the middle of this operation, the item to remove may be lost forever or stuck in a temporary location.
|
||||
*
|
||||
* This is not an atomic operation, nor intended to be a recoverable operation if the worst comes to worst.
|
||||
*/
|
||||
- (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Removes an item at a URL
|
||||
* @param url A URL pointing to the item to remove. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was removed successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Changes the owner and group IDs of an item at a specified target URL to match another URL
|
||||
* @param targetURL A URL pointing to the target item whose owner and group IDs to alter. This will be applied recursively if the item is a directory. The item at this URL must exist.
|
||||
* @param matchURL A URL pointing to the item whose owner and group IDs will be used for changing on the targetURL. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the target item's owner and group IDs have changed to match the origin's ones, otherwise NO along with a populated error object
|
||||
*
|
||||
* If the owner and group IDs match on the root items of targetURL and matchURL, this method stops and assumes that nothing needs to be done.
|
||||
* Otherwise this method recursively changes the IDs if the target is a directory. If an item in the directory is encountered that is unable to be changed,
|
||||
* then this method stops and returns NO.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Updates the modification and access time of an item at a specified target URL to the current time
|
||||
* @param targetURL A URL pointing to the target item whose modification and access time to update. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the target item's modification and access times have been updated, otherwise NO along with a populated error object
|
||||
*
|
||||
* This method updates the modification and access time of an item to the current time, ideal for letting the system know we installed a new file or
|
||||
* application.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Releases Apple's quarantine extended attribute from the item at the specified root URL
|
||||
* @param rootURL A URL pointing to the item to release from Apple's quarantine. This will be applied recursively if the item is a directory. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if all the items at the target could be released from quarantine, otherwise NO if any items couldn't along with a populated error object
|
||||
*
|
||||
* This method removes quarantine attributes from an item, ideally an application, so that when the user launches a new application themselves, they
|
||||
* don't have to witness the system dialog alerting them that they downloaded an application from the internet and asking if they want to continue.
|
||||
* Note that this may not exactly mimic the system behavior when a user opens an application for the first time (i.e, the xattr isn't deleted),
|
||||
* but this should be sufficient enough for our purposes.
|
||||
*
|
||||
* This method may return NO even if some items do get released from quarantine if the target URL is pointing to a directory.
|
||||
* Thus if an item cannot be released from quarantine, this method still continues on to the next enumerated item.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Runs an installer package (pkg) in a headless mode using /usr/sbin/installer
|
||||
* @param packageURL A URL pointing to the package to execute. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the installer ran the package successfully, otherwise NO with a populated error object
|
||||
*
|
||||
* This method uses the system wide installer tool to run the provided package. This process does not show any UI, except for
|
||||
* an initial authorization prompt if the calling process does not have root privileges. In other words, root privileges are required to use this method, and the file manager instance must have been created by allowing authorization.
|
||||
* An error can occur if the package is unable to be ran by the installer, or if the installer reports a non-zero exit status code.
|
||||
*/
|
||||
- (BOOL)executePackageAtURL:(NSURL *)packageURL error:(NSError **)error;
|
||||
|
||||
@end
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
|
||||
|
||||
The installer package is installed using Mac OS X's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
||||
The installer package is installed using macOS's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
||||
|
||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
||||
|
||||
@@ -29,7 +29,7 @@ A guided installation can be started by applications other than the application
|
||||
@interface SUGuidedPackageInstaller : SUInstaller
|
||||
|
||||
/*! Perform the guided installation */
|
||||
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,137 +6,27 @@
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
#import <sys/stat.h>
|
||||
#import <Security/Security.h>
|
||||
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments)
|
||||
{
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
/* AuthorizationExecuteWithPrivileges used to support 10.4+; should be replaced with XPC or external process */
|
||||
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
int status = 0;
|
||||
pid_t pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
returnValue = NO;
|
||||
}
|
||||
else
|
||||
returnValue = NO;
|
||||
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
|
||||
|
||||
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
|
||||
{
|
||||
SUParameterAssert(executablePath);
|
||||
|
||||
// Get authorization using advice in Apple's Technical Q&A1172
|
||||
|
||||
// ...create authorization without specific rights
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus validAuth = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
// ...then extend authorization with desired rights
|
||||
if ((validAuth == errAuthorizationSuccess) &&
|
||||
(auth != NULL))
|
||||
{
|
||||
char executableFileSystemRepresentation[PATH_MAX];
|
||||
[executablePath getFileSystemRepresentation:executableFileSystemRepresentation maxLength:sizeof(executableFileSystemRepresentation)];
|
||||
|
||||
// Prepare a right allowing script to execute with privileges
|
||||
AuthorizationItem right = {
|
||||
.name = kAuthorizationRightExecute,
|
||||
.value = executableFileSystemRepresentation,
|
||||
.valueLength = strlen(executableFileSystemRepresentation),
|
||||
};
|
||||
|
||||
// Package up the single right
|
||||
AuthorizationRights rights;
|
||||
memset(&rights,0,sizeof(rights));
|
||||
rights.count = 1;
|
||||
rights.items = &right;
|
||||
|
||||
// Extend rights to run script
|
||||
validAuth = AuthorizationCopyRights(auth,
|
||||
&rights,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
(AuthorizationFlags)
|
||||
(kAuthorizationFlagPreAuthorize |
|
||||
kAuthorizationFlagExtendRights |
|
||||
kAuthorizationFlagInteractionAllowed),
|
||||
NULL);
|
||||
if (validAuth != errAuthorizationSuccess)
|
||||
{
|
||||
// Error, clean up authorization
|
||||
(void) AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
||||
auth = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
@end
|
||||
#import "SUFileManager.h"
|
||||
|
||||
@implementation SUGuidedPackageInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
SUParameterAssert(packagePath);
|
||||
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
|
||||
// Preflight
|
||||
NSString* installerPath = @"/usr/sbin/installer"; // Mac OS X 10.2+ command line installer tool
|
||||
NSError* error = nil;
|
||||
|
||||
// Create authorization for installer executable
|
||||
BOOL validInstallation = NO;
|
||||
AuthorizationRef auth = [self authorizationForExecutable:installerPath];
|
||||
if (auth != NULL)
|
||||
{
|
||||
char pathBuffer[PATH_MAX] = {0};
|
||||
[packagePath getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
||||
|
||||
// Permission was granted to execute the installer with privileges
|
||||
char * const arguments[] = {
|
||||
"-pkg",
|
||||
pathBuffer,
|
||||
"-target",
|
||||
"/",
|
||||
NULL
|
||||
};
|
||||
validInstallation = AuthorizationExecuteWithPrivilegesAndWait(auth,
|
||||
[installerPath fileSystemRepresentation],
|
||||
kAuthorizationFlagDefaults,
|
||||
arguments);
|
||||
// TODO: wait for communications pipe to close via fileno & CFSocketCreateWithNative
|
||||
AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Script authorization denied."];
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath];
|
||||
|
||||
NSError *error = nil;
|
||||
BOOL validInstallation = [fileManager executePackageAtURL:[NSURL fileURLWithPath:packagePath] error:&error];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self finishInstallationToPath:destinationPath
|
||||
withResult:validInstallation
|
||||
error:error
|
||||
completionHandler:completionHandler];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,15 +11,21 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
typedef struct {
|
||||
NSInteger majorVersion;
|
||||
NSInteger minorVersion;
|
||||
NSInteger patchVersion;
|
||||
} NSOperatingSystemVersion;
|
||||
#endif
|
||||
|
||||
@interface SUHost : NSObject
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||
@property (readonly, copy) NSString *bundlePath;
|
||||
@property (readonly, copy) NSString *appCachePath;
|
||||
@property (readonly) BOOL allowsAutomaticUpdates;
|
||||
@property (readonly, copy) NSString *installationPath;
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
@@ -28,6 +34,7 @@
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (getter=isBackgroundApplication, readonly) BOOL backgroundApplication;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||
@property (readonly, copy) NSArray *systemProfile;
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
|
||||
@@ -11,13 +11,9 @@
|
||||
#import "SUSystemProfiler.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
typedef struct {
|
||||
NSInteger majorVersion;
|
||||
NSInteger minorVersion;
|
||||
NSInteger patchVersion;
|
||||
} NSOperatingSystemVersion;
|
||||
@interface NSProcessInfo ()
|
||||
- (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
@end
|
||||
@@ -67,26 +63,46 @@ typedef struct {
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)appCachePath
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cachePath = nil;
|
||||
if ([cachePaths count]) {
|
||||
cachePath = cachePaths[0];
|
||||
// Does the developer want us to disable automatic updates?
|
||||
NSNumber *developerAllowsAutomaticUpdates = [self objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
|
||||
if (developerAllowsAutomaticUpdates != nil && !developerAllowsAutomaticUpdates.boolValue) {
|
||||
return NO;
|
||||
}
|
||||
if (!cachePath) {
|
||||
SULog(@"Failed to find user's cache directory! Using system default");
|
||||
cachePath = NSTemporaryDirectory();
|
||||
|
||||
// Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)?
|
||||
// Note it's very well possible to have the bundle be writable but not be able to write into the parent directory
|
||||
// And if the bundle isn't writable, but we can write into the parent directory, we will still need to authorize to replace it
|
||||
NSString *bundlePath = [self bundlePath];
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath.stringByDeletingLastPathComponent] || ![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *name = [self.bundle bundleIdentifier];
|
||||
if (!name) {
|
||||
name = [self name];
|
||||
|
||||
// Just because we have writability access does not mean we can set the correct owner/group silently
|
||||
// Test if we can set the owner/group on a temporarily created file
|
||||
// If we can, then we can probably perform an update without authorization
|
||||
// One place where this matters is if you copy and run an app from /tmp/
|
||||
|
||||
NSString *tempFilename = @"permission_test" ;
|
||||
|
||||
SUFileManager *suFileManager = [SUFileManager defaultManager];
|
||||
NSURL *tempDirectoryURL = [suFileManager makeTemporaryDirectoryWithPreferredName:tempFilename appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:NULL];
|
||||
|
||||
if (tempDirectoryURL == nil) {
|
||||
// I don't imagine this ever happening but in case it does, requesting authorization may be the better option
|
||||
return NO;
|
||||
}
|
||||
|
||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||
cachePath = [cachePath stringByAppendingPathComponent:@"Sparkle"];
|
||||
return cachePath;
|
||||
|
||||
NSURL *tempFileURL = [tempDirectoryURL URLByAppendingPathComponent:tempFilename];
|
||||
|
||||
BOOL changeOwnerAndGroupSuccess =
|
||||
[[NSData data] writeToURL:tempFileURL atomically:NO] &&
|
||||
[suFileManager changeOwnerAndGroupOfItemAtRootURL:tempFileURL toMatchURL:self.bundle.bundleURL error:NULL];
|
||||
|
||||
[suFileManager removeItemAtURL:tempDirectoryURL error:NULL];
|
||||
|
||||
return changeOwnerAndGroupSuccess;
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
@@ -94,7 +110,8 @@ typedef struct {
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) {
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:normalizedAppPath]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
}
|
||||
@@ -107,13 +124,13 @@ typedef struct {
|
||||
|
||||
// Allow host bundle to provide a custom name
|
||||
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
|
||||
if (name) return name;
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name) return name;
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||
if (name) return name;
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
|
||||
}
|
||||
@@ -139,11 +156,11 @@ typedef struct {
|
||||
{
|
||||
// Cache the application icon.
|
||||
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
||||
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// According to the macOS docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// the icon for the bundle. The filename you specify does not need to include the .icns
|
||||
// extension, although it may."
|
||||
//
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on macOS 10.3.9) so we'll also try:
|
||||
if (!iconPath) {
|
||||
iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:nil];
|
||||
}
|
||||
@@ -162,7 +179,7 @@ typedef struct {
|
||||
{
|
||||
struct statfs statfs_info;
|
||||
statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY);
|
||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||
}
|
||||
|
||||
- (BOOL)isBackgroundApplication
|
||||
@@ -179,7 +196,7 @@ typedef struct {
|
||||
}
|
||||
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
NSString *keyFilename = [self publicDSAKeyFileKey];
|
||||
if (!keyFilename) {
|
||||
return nil;
|
||||
}
|
||||
@@ -191,6 +208,11 @@ typedef struct {
|
||||
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
||||
}
|
||||
|
||||
- (NSString * __nullable)publicDSAKeyFileKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
}
|
||||
|
||||
- (NSArray *)systemProfile
|
||||
{
|
||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
||||
@@ -276,21 +298,4 @@ typedef struct {
|
||||
return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
+ (NSString *)systemVersionString
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // Present in 10.9 despite NS_AVAILABLE's claims
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wselector"
|
||||
// Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug?
|
||||
if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
return [NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"];
|
||||
}
|
||||
#endif
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -16,9 +16,8 @@
|
||||
@interface SUInstaller : NSObject
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr;
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (NSString *)updateFolder;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -16,30 +16,13 @@
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
static NSString *sUpdateFolder = nil;
|
||||
|
||||
+ (NSString *)updateFolder
|
||||
{
|
||||
return sUpdateFolder;
|
||||
}
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
{
|
||||
FSRef fileRef;
|
||||
OSStatus err = noErr;
|
||||
Boolean aliasFileFlag = false, folderFlag = false;
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
|
||||
if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef))
|
||||
err = coreFoundationUnknownErr;
|
||||
|
||||
if (noErr == err)
|
||||
err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag);
|
||||
|
||||
if (noErr == err)
|
||||
return !!(aliasFileFlag && folderFlag);
|
||||
else
|
||||
return NO;
|
||||
NSNumber *aliasFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
|
||||
NSNumber *directoryFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil];
|
||||
return aliasFlag.boolValue && directoryFlag.boolValue;
|
||||
}
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
@@ -58,8 +41,6 @@ static NSString *sUpdateFolder = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
||||
|
||||
sUpdateFolder = inUpdateFolder;
|
||||
|
||||
while ((currentFile = [dirEnum nextObject])) {
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
NSString *currentFilename = [currentFile lastPathComponent];
|
||||
@@ -122,7 +103,7 @@ static NSString *sUpdateFolder = nil;
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
@@ -132,39 +113,18 @@ static NSString *sUpdateFolder = nil;
|
||||
[self finishInstallationToPath:installationPath withResult:NO error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler];
|
||||
} else {
|
||||
if (isPackage && isGuided) {
|
||||
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
||||
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
} else if (isPackage) {
|
||||
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
||||
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
} else {
|
||||
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
||||
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
SULog(@"mdimporting");
|
||||
|
||||
NSTask *mdimport = [[NSTask alloc] init];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:@[installationPath]];
|
||||
@try {
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException *launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Error: %@", [launchException description]);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
||||
+ (void)finishInstallationToPath:(NSString *)__unused installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
if (result) {
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completionHandler(nil);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// SUOperatingSystem.h
|
||||
// Sparkle
|
||||
//
|
||||
// Copyright © 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUOperatingSystem : NSObject
|
||||
|
||||
+ (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version;
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// SUOperatingSystem.m
|
||||
// Sparkle
|
||||
//
|
||||
// Copyright © 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUOperatingSystem.h"
|
||||
|
||||
@implementation SUOperatingSystem
|
||||
|
||||
+ (NSOperatingSystemVersion)operatingSystemVersion
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wselector"
|
||||
// Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug?
|
||||
if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
NSOperatingSystemVersion version = { 0, 0, 0 };
|
||||
NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"];
|
||||
assert(url != nil);
|
||||
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];
|
||||
NSArray *components = [ [dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."];
|
||||
version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0;
|
||||
version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0;
|
||||
version.patchVersion = components.count > 2 ? [ [components objectAtIndex:2] integerValue] : 0;
|
||||
return version;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
return [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version
|
||||
{
|
||||
const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion;
|
||||
if (systemVersion.majorVersion == version.majorVersion) {
|
||||
if (systemVersion.minorVersion == version.minorVersion) {
|
||||
return systemVersion.patchVersion >= version.patchVersion;
|
||||
}
|
||||
return systemVersion.minorVersion >= version.minorVersion;
|
||||
}
|
||||
return systemVersion.majorVersion >= version.majorVersion;
|
||||
}
|
||||
|
||||
+ (NSString *)systemVersionString
|
||||
{
|
||||
NSOperatingSystemVersion version = self.operatingSystemVersion;
|
||||
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@implementation SUPackageInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host fileOperationToolPath:(NSString *)__unused fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
// Run installer using the "open" command to ensure it is launched in front of current application.
|
||||
// -W = wait until the app has quit.
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
NSString *lastPathComponent = [path lastPathComponent];
|
||||
for (NSString *currentType in typeSelectorDictionary)
|
||||
{
|
||||
NSString *value = typeSelectorDictionary[currentType];
|
||||
NSString *value = [typeSelectorDictionary objectForKey:currentType];
|
||||
assert(value);
|
||||
|
||||
if ([currentType length] > [lastPathComponent length]) continue;
|
||||
@@ -41,6 +41,11 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[NSThread detachNewThreadSelector:[[self class] selectorConformingToTypeOfPath:self.archivePath] toTarget:self withObject:nil];
|
||||
@@ -62,7 +67,8 @@
|
||||
SULog(@"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
|
||||
|
||||
// Get the file size.
|
||||
NSUInteger expectedLength = [[[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil][NSFileSize] unsignedIntegerValue];
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil];
|
||||
NSUInteger expectedLength = [[attributes objectForKey:NSFileSize] unsignedIntegerValue];
|
||||
if (expectedLength > 0) {
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:self.archivePath];
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
@interface SUPlainInstaller : SUInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -7,14 +7,155 @@
|
||||
//
|
||||
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUPlainInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
// Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one
|
||||
+ (NSString *)bundleVersionAppropriateForFilenameFromHost:(SUHost *)host
|
||||
{
|
||||
NSString *bundleVersion = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *trimmedVersion = @"";
|
||||
|
||||
if (bundleVersion != nil) {
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
|
||||
trimmedVersion = [bundleVersion stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
|
||||
return trimmedVersion.length > 0 ? trimmedVersion : nil;
|
||||
}
|
||||
|
||||
+ (BOOL)performInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (installationURL == nil || newURL == nil) {
|
||||
// this really shouldn't happen but just in case
|
||||
SULog(@"Failed to perform installation because either installation URL (%@) or new URL (%@) is nil", installationURL, newURL);
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because the paths to install at and from are not valid" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath];
|
||||
|
||||
// Create a temporary directory for our new app that resides on our destination's volume
|
||||
NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error];
|
||||
if (tempNewDirectoryURL == nil) {
|
||||
SULog(@"Failed to make new temp directory");
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Move the new app to our temporary directory
|
||||
NSString *newURLLastPathComponent = newURL.lastPathComponent;
|
||||
NSURL *newTempURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURLLastPathComponent];
|
||||
if (![fileManager moveItemAtURL:newURL toURL:newTempURL error:error]) {
|
||||
SULog(@"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newTempURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Release our new app from quarantine, fix its owner and group IDs, and update its modification time while it's at our temporary destination
|
||||
// We must leave moving the app to its destination as the final step in installing it, so that
|
||||
// it's not possible our new app can be left in an incomplete state at the final destination
|
||||
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:newTempURL error:&quarantineError]) {
|
||||
// Not big enough of a deal to fail the entire installation
|
||||
SULog(@"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError);
|
||||
}
|
||||
|
||||
NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath];
|
||||
if (oldURL == nil) {
|
||||
// this really shouldn't happen but just in case
|
||||
SULog(@"Failed to construct URL from bundle path: %@", host.bundlePath);
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because a path could not be constructed for the old installation" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:error]) {
|
||||
// But this is big enough of a deal to fail
|
||||
SULog(@"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:newTempURL error:error]) {
|
||||
// Not a fatal error, but a pretty unfortunate one
|
||||
SULog(@"Failed to update modification and access time of new app at %@", newTempURL.path);
|
||||
}
|
||||
|
||||
// Decide on a destination name we should use for the older app when we move it around the file system
|
||||
NSString *oldDestinationName = nil;
|
||||
if (SPARKLE_APPEND_VERSION_NUMBER) {
|
||||
NSString *oldBundleVersion = [self bundleVersionAppropriateForFilenameFromHost:host];
|
||||
|
||||
oldDestinationName = [oldURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingFormat:@" (%@)", oldBundleVersion != nil ? oldBundleVersion : @"old"];
|
||||
} else {
|
||||
oldDestinationName = oldURL.lastPathComponent.stringByDeletingPathExtension;
|
||||
}
|
||||
|
||||
NSString *oldURLExtension = oldURL.pathExtension;
|
||||
NSString *oldDestinationNameWithPathExtension = [oldDestinationName stringByAppendingPathExtension:oldURLExtension];
|
||||
|
||||
// Create a temporary directory for our old app that resides on its volume
|
||||
NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error];
|
||||
if (tempOldDirectoryURL == nil) {
|
||||
SULog(@"Failed to create temporary directory for old app at %@", oldURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Move the old app to the temporary directory
|
||||
NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension];
|
||||
if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) {
|
||||
SULog(@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path);
|
||||
|
||||
// Just forget about our updated app on failure
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
[fileManager removeItemAtURL:tempOldDirectoryURL error:NULL];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Move the new app to its final destination
|
||||
if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) {
|
||||
SULog(@"Failed to move new app at %@ to final destination %@", newTempURL.path, installationURL.path);
|
||||
|
||||
// Forget about our updated app on failure
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
|
||||
// Attempt to restore our old app back the way it was on failure
|
||||
[fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL];
|
||||
[fileManager removeItemAtURL:tempOldDirectoryURL error:NULL];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
// From here on out, we don't really need to bring up authorization if we haven't done so prior
|
||||
SUFileManager *constrainedFileManager = [fileManager fileManagerByPreservingAuthorizationRights];
|
||||
|
||||
// Cleanup: move the old app to the trash
|
||||
NSError *trashError = nil;
|
||||
if (![constrainedFileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) {
|
||||
SULog(@"Failed to move %@ to trash with error %@", oldTempURL, trashError);
|
||||
}
|
||||
|
||||
[constrainedFileManager removeItemAtURL:tempOldDirectoryURL error:NULL];
|
||||
|
||||
[constrainedFileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
SUParameterAssert(host);
|
||||
|
||||
@@ -23,7 +164,7 @@
|
||||
// Prevent malicious downgrades
|
||||
if (!allowDowngrades) {
|
||||
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) {
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
[self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler];
|
||||
return;
|
||||
@@ -32,24 +173,7 @@
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
NSError *error = nil;
|
||||
NSString *oldPath = [host bundlePath];
|
||||
NSString *tempName = [self temporaryNameForPath:[host installationPath]];
|
||||
|
||||
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error];
|
||||
|
||||
if (result) {
|
||||
if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) {
|
||||
result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error];
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath:oldPath];
|
||||
BOOL differentFromNew = ![oldPath isEqualToString:installationPath];
|
||||
if (haveOld && differentFromNew) {
|
||||
[self _movePathToTrash:oldPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER]; // On success, trash old copy if there's still one due to renaming.
|
||||
}
|
||||
}
|
||||
BOOL result = [self performInstallationToURL:[NSURL fileURLWithPath:installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:path] withHost:host fileOperationToolPath:fileOperationToolPath error:&error];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler];
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// SUPlainInstallerInternals.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/9/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUPLAININSTALLERINTERNALS_H
|
||||
#define SUPLAININSTALLERINTERNALS_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SUPlainInstaller.h"
|
||||
|
||||
@interface SUPlainInstaller (Internals)
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path;
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp appendVersion:(BOOL)a error:(NSError **)error;
|
||||
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)a;
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error;
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -1,639 +0,0 @@
|
||||
//
|
||||
// SUPlainInstallerInternals.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/9/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Security/Security.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE;
|
||||
#endif
|
||||
|
||||
static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
|
||||
{
|
||||
if ([NSThread isMainThread]) {
|
||||
theBlock();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), theBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@interface SUPlainInstaller (MMExtendedAttributes)
|
||||
// Removes the directory tree rooted at |root| from the file quarantine.
|
||||
// The quarantine was introduced on OS X 10.5 and is described at:
|
||||
//
|
||||
// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html
|
||||
//#apple_ref/doc/uid/TP40001369-DontLinkElementID_2
|
||||
//
|
||||
// If |root| is not a directory, then it alone is removed from the quarantine.
|
||||
// Symbolic links, including |root| if it is a symbolic link, will not be
|
||||
// traversed.
|
||||
//
|
||||
// Ordinarily, the quarantine is managed by calling LSSetItemAttribute
|
||||
// to set the kLSItemQuarantineProperties attribute to a dictionary specifying
|
||||
// the quarantine properties to be applied. However, it does not appear to be
|
||||
// possible to remove an item from the quarantine directly through any public
|
||||
// Launch Services calls. Instead, this method takes advantage of the fact
|
||||
// that the quarantine is implemented in part by setting an extended attribute,
|
||||
// "com.apple.quarantine", on affected files. Removing this attribute is
|
||||
// sufficient to remove files from the quarantine.
|
||||
+ (void)releaseFromQuarantine:(NSString *)root;
|
||||
@end
|
||||
|
||||
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably
|
||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments)
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
||||
BOOL returnValue = YES;
|
||||
|
||||
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
|
||||
{
|
||||
int status;
|
||||
pid_t pid = wait(&status);
|
||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
returnValue = NO;
|
||||
}
|
||||
else
|
||||
returnValue = NO;
|
||||
|
||||
signal(SIGCHLD, oldSigChildHandler);
|
||||
return returnValue;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@implementation SUPlainInstaller (Internals)
|
||||
|
||||
+ (NSString *)temporaryNameForPath:(NSString *)path
|
||||
{
|
||||
// Let's try to read the version number so the filename will be more meaningful.
|
||||
NSString *postFix;
|
||||
NSString *version;
|
||||
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
|
||||
{
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else
|
||||
postFix = @"old";
|
||||
NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix];
|
||||
NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
// Now let's make sure we get a unique path.
|
||||
unsigned int cnt = 2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]];
|
||||
return [tempDir lastPathComponent];
|
||||
}
|
||||
|
||||
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path appendVersion:(BOOL)appendVersion didFindTrash:(BOOL *)outDidFindTrash
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
NSString *tempDir = nil;
|
||||
|
||||
UInt8 trashPath[MAXPATHLEN + 1] = { 0 };
|
||||
FSRef trashRef, pathRef;
|
||||
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
|
||||
FSCatalogInfo catInfo;
|
||||
memset(&catInfo, 0, sizeof(catInfo));
|
||||
OSStatus err = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
|
||||
if( err == noErr )
|
||||
{
|
||||
err = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
|
||||
vSrcRefNum = catInfo.volume;
|
||||
}
|
||||
if (err == noErr)
|
||||
err = FSFindFolder(vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef);
|
||||
if (err == noErr)
|
||||
err = FSGetCatalogInfo(&trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
|
||||
if (err == noErr && vSrcRefNum != catInfo.volume)
|
||||
err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future.
|
||||
if (err == noErr)
|
||||
err = FSRefMakePath(&trashRef, trashPath, MAXPATHLEN);
|
||||
if (err == noErr)
|
||||
tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:(char *)trashPath length:strlen((char *)trashPath)];
|
||||
if (outDidFindTrash)
|
||||
*outDidFindTrash = (tempDir != nil);
|
||||
if (!tempDir)
|
||||
tempDir = [path stringByDeletingLastPathComponent];
|
||||
|
||||
// Let's try to read the version number so the filename will be more meaningful
|
||||
NSString *prefix;
|
||||
if (appendVersion) {
|
||||
NSString *postFix = nil;
|
||||
NSString *version = nil;
|
||||
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
|
||||
{
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
else {
|
||||
postFix = @"old";
|
||||
}
|
||||
prefix = [NSString stringWithFormat:@"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
|
||||
} else {
|
||||
prefix = [[path lastPathComponent] stringByDeletingPathExtension];
|
||||
}
|
||||
NSString *tempName = [prefix stringByAppendingPathExtension:[path pathExtension]];
|
||||
tempDir = [tempDir stringByAppendingPathComponent:tempName];
|
||||
|
||||
// Now let's make sure we get a unique path.
|
||||
int cnt = 2;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) {
|
||||
tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]];
|
||||
}
|
||||
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
char srcPath[PATH_MAX] = {0};
|
||||
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
|
||||
|
||||
char tmpPath[PATH_MAX] = {0};
|
||||
[tmp getFileSystemRepresentation:tmpPath maxLength:sizeof(tmpPath)];
|
||||
|
||||
char dstPath[PATH_MAX] = {0};
|
||||
[dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)];
|
||||
|
||||
struct stat dstSB;
|
||||
if (stat(dstPath, &dstSB) != 0) // Doesn't exist yet, try containing folder.
|
||||
{
|
||||
const char *dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
|
||||
if( stat(dstDirPath, &dstSB) != 0 )
|
||||
{
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while (authStat == errAuthorizationDenied) {
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess) {
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%u:%u",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined. It also needs to be
|
||||
// done before "chown" changes ownership, because the ownership
|
||||
// change will almost certainly make it impossible to change
|
||||
// attributes to release the files from the quarantine.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine");
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:src];
|
||||
});
|
||||
}
|
||||
|
||||
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
char *coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
|
||||
if (!res)
|
||||
SULog(@"chown -R %@ %@ failed.", @(uidgid), @(srcPath));
|
||||
}
|
||||
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
|
||||
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
char *rmParams[] = { "-rf", tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"rm failed");
|
||||
}
|
||||
|
||||
if (res && haveDst) // Move old exe to tmp path.
|
||||
{
|
||||
char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
|
||||
if (!res)
|
||||
SULog(@"mv 1 failed");
|
||||
}
|
||||
|
||||
if (res) // Move new exe to old exe's path.
|
||||
{
|
||||
char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2);
|
||||
if (!res)
|
||||
SULog(@"mv 2 failed");
|
||||
}
|
||||
|
||||
// if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover.
|
||||
// { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one.
|
||||
// const char* rmParams2[] = { "-rf", tmpPath, NULL };
|
||||
// res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 );
|
||||
// }
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home with "mv" in case it's moved across filesystems: if
|
||||
// that happens, "mv" actually performs a copy and may result
|
||||
// in the application being quarantined.
|
||||
if (res)
|
||||
{
|
||||
SULog(@"releaseFromQuarantine after installing");
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:dst];
|
||||
});
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst];
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != nil)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
char srcPath[PATH_MAX] = {0};
|
||||
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
|
||||
|
||||
char dstPath[PATH_MAX] = {0};
|
||||
[dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)];
|
||||
|
||||
char dstContainerPath[PATH_MAX] = {0};
|
||||
[dst.stringByDeletingLastPathComponent getFileSystemRepresentation:dstContainerPath maxLength:sizeof(dstContainerPath)];
|
||||
|
||||
struct stat dstSB;
|
||||
stat(dstContainerPath, &dstSB);
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
char uidgid[42];
|
||||
snprintf(uidgid, sizeof(uidgid), "%d:%d",
|
||||
dstSB.st_uid, dstSB.st_gid);
|
||||
|
||||
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
|
||||
{
|
||||
char *coParams[] = { "-R", uidgid, srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
|
||||
if (!res)
|
||||
SULog(@"Can't set permissions");
|
||||
}
|
||||
|
||||
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
|
||||
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
char *rmParams[] = { "-rf", dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
if (res) // Move!.
|
||||
{
|
||||
char *mvParams[] = { "-f", srcPath, dstPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
|
||||
if (!res)
|
||||
SULog(@"Can't move source file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
char srcPath[PATH_MAX] = {0};
|
||||
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus authStat = errAuthorizationDenied;
|
||||
while( authStat == errAuthorizationDenied )
|
||||
{
|
||||
authStat = AuthorizationCreate(NULL,
|
||||
kAuthorizationEmptyEnvironment,
|
||||
kAuthorizationFlagDefaults,
|
||||
&auth);
|
||||
}
|
||||
|
||||
BOOL res = NO;
|
||||
if (authStat == errAuthorizationSuccess)
|
||||
{
|
||||
res = YES;
|
||||
|
||||
if (res) // If there's something at our tmp path (previous failed update or whatever) delete that first.
|
||||
{
|
||||
char *rmParams[] = { "-rf", srcPath, NULL };
|
||||
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
|
||||
if (!res)
|
||||
SULog(@"Can't remove destination file");
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, 0);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
// Something went wrong somewhere along the way, but we're not sure exactly where.
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src];
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
BOOL success = YES;
|
||||
if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] )
|
||||
{
|
||||
success = [self _removeFileAtPathWithForcedAuthentication:path error:error];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)appendVersion
|
||||
{
|
||||
//SULog(@"Moving %@ to the trash.", path);
|
||||
NSInteger tag = 0;
|
||||
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag])
|
||||
{
|
||||
BOOL didFindTrash = NO;
|
||||
NSString *trashPath = [self _temporaryCopyNameForPath:path appendVersion:appendVersion didFindTrash:&didFindTrash];
|
||||
if( didFindTrash )
|
||||
{
|
||||
NSError *err = nil;
|
||||
if (![self _movePathWithForcedAuthentication:path toPath:trashPath error:&err]) {
|
||||
SULog(@"Error: couldn't move %@ to the trash (%@). %@", path, trashPath, err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SULog(@"Error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
|
||||
OSStatus err;
|
||||
BOOL hadFileAtDest = NO, didFindTrash = NO;
|
||||
NSString *tmpPath = [self _temporaryCopyNameForPath:dst appendVersion:appendVersion didFindTrash:&didFindTrash];
|
||||
|
||||
// Make FSRef for destination:
|
||||
err = FSPathMakeRefWithOptions((const UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
|
||||
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
if (0 != access([dst fileSystemRepresentation], W_OK) || 0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)
|
||||
|| 0 != access([[[dst stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK))
|
||||
{
|
||||
return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error];
|
||||
}
|
||||
}
|
||||
|
||||
if( hadFileAtDest )
|
||||
{
|
||||
err = FSPathMakeRef((const UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
if (err != noErr)
|
||||
FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
|
||||
|
||||
if (err == noErr && hadFileAtDest)
|
||||
{
|
||||
NSFileManager *manager = [[NSFileManager alloc] init];
|
||||
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
|
||||
if (!success && hadFileAtDest)
|
||||
{
|
||||
if (error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
err = FSPathMakeRef((const UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
|
||||
if (err == noErr)
|
||||
{
|
||||
NSFileManager *manager = [[NSFileManager alloc] init];
|
||||
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
|
||||
if (!success)
|
||||
{
|
||||
// We better move the old version back to its old location
|
||||
if (hadFileAtDest) {
|
||||
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
|
||||
}
|
||||
if (!success && error != NULL)
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }];
|
||||
return NO;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If the currently-running application is trusted, the new
|
||||
// version should be trusted as well. Remove it from the
|
||||
// quarantine to avoid a delay at launch, and to avoid
|
||||
// presenting the user with a confusing trust dialog.
|
||||
//
|
||||
// This needs to be done after the application is moved to its
|
||||
// new home in case it's moved across filesystems: if that
|
||||
// happens, the move is actually a copy, and it may result
|
||||
// in the application being quarantined.
|
||||
PerformOnMainThreadSync(^{
|
||||
[self releaseFromQuarantine:dst];
|
||||
});
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <sys/xattr.h>
|
||||
|
||||
@implementation SUPlainInstaller (MMExtendedAttributes)
|
||||
|
||||
+ (int)removeXAttr:(NSString *)name
|
||||
fromFile:(NSString *)file
|
||||
options:(int)options
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
const char *path = NULL;
|
||||
const char *attr = [name cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
@try {
|
||||
path = [file fileSystemRepresentation];
|
||||
}
|
||||
@catch (id) {
|
||||
// -[NSString fileSystemRepresentation] throws an exception if it's
|
||||
// unable to convert the string to something suitable. Map that to
|
||||
// EDOM, "argument out of domain", which sort of conveys that there
|
||||
// was a conversion failure.
|
||||
errno = EDOM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return removexattr(path, attr, options);
|
||||
}
|
||||
|
||||
+ (void)releaseFromQuarantine:(NSString *)root
|
||||
{
|
||||
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
|
||||
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
|
||||
if (!&NSURLQuarantinePropertiesKey) {
|
||||
NSString *const quarantineAttribute = (__bridge NSString *)kLSItemQuarantineProperties;
|
||||
const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:root
|
||||
options:removeXAttrOptions];
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil];
|
||||
NSString *rootType = rootAttributes[NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtPath:root];
|
||||
NSString *file = nil;
|
||||
while ((file = [directoryEnumerator nextObject])) {
|
||||
[self removeXAttr:quarantineAttribute
|
||||
fromFile:[root stringByAppendingPathComponent:file]
|
||||
options:removeXAttrOptions];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
NSURL *rootURL = [NSURL fileURLWithPath:root];
|
||||
id rootResourceValue = nil;
|
||||
[rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
if (rootResourceValue) {
|
||||
[rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
}
|
||||
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil];
|
||||
NSString *rootType = rootAttributes[NSFileType];
|
||||
|
||||
if (rootType == NSFileTypeDirectory) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
|
||||
for (NSURL *file in directoryEnumerator) {
|
||||
id fileResourceValue = nil;
|
||||
[file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
if (fileResourceValue) {
|
||||
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,7 +9,11 @@
|
||||
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
|
||||
#define SUSTANDARDVERSIONCOMPARATOR_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
|
||||
n = MIN([partsA count], [partsB count]);
|
||||
for (i = 0; i < n; ++i) {
|
||||
partA = partsA[i];
|
||||
partB = partsB[i];
|
||||
partA = [partsA objectAtIndex:i];
|
||||
partB = [partsB objectAtIndex:i];
|
||||
|
||||
typeA = [self typeOfCharacter:partA];
|
||||
typeB = [self typeOfCharacter:partB];
|
||||
@@ -142,11 +142,11 @@ typedef NS_ENUM(NSInteger, SUCharacterType) {
|
||||
NSComparisonResult shorterResult, largerResult;
|
||||
|
||||
if ([partsA count] > [partsB count]) {
|
||||
missingPart = partsA[n];
|
||||
missingPart = [partsA objectAtIndex:n];
|
||||
shorterResult = NSOrderedAscending;
|
||||
largerResult = NSOrderedDescending;
|
||||
} else {
|
||||
missingPart = partsB[n];
|
||||
missingPart = [partsB objectAtIndex:n];
|
||||
shorterResult = NSOrderedDescending;
|
||||
largerResult = NSOrderedAscending;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<connections>
|
||||
<outlet property="actionButton" destination="12" id="34"/>
|
||||
<outlet property="progressBar" destination="11" id="49"/>
|
||||
<outlet property="statusTextField" destination="16" id="MiZ-Tn-yVg"/>
|
||||
<outlet property="window" destination="5" id="25"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
@interface SUStatusController : SUWindowController
|
||||
@property (weak) IBOutlet NSButton *actionButton;
|
||||
@property (weak) IBOutlet NSProgressIndicator *progressBar;
|
||||
@property (weak) IBOutlet NSTextField *statusTextField;
|
||||
|
||||
@property (copy) NSString *statusText;
|
||||
@property double progressValue;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
@@ -28,6 +29,7 @@
|
||||
@synthesize host;
|
||||
@synthesize actionButton;
|
||||
@synthesize progressBar;
|
||||
@synthesize statusTextField;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
@@ -42,7 +44,7 @@
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
- (void)awakeFromNib
|
||||
- (void)windowDidLoad
|
||||
{
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[[self window] setLevel:NSFloatingWindowLevel];
|
||||
@@ -51,6 +53,13 @@
|
||||
[[self window] center];
|
||||
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
||||
[self.progressBar setUsesThreadedAnimation:YES];
|
||||
|
||||
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 11, 0}]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
[self.statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)windowTitle
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "SUSystemProfiler.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
static NSString *const SUSystemProfilerApplicationNameKey = @"appName";
|
||||
@@ -37,7 +38,8 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
|
||||
- (NSDictionary *)modelTranslationTable
|
||||
{
|
||||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
|
||||
// Use explicit class to use the correct bundle even when subclassed
|
||||
NSString *path = [[NSBundle bundleForClass:[SUSystemProfiler class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
|
||||
return [[NSDictionary alloc] initWithContentsOfFile:path];
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
size_t length = sizeof(value);
|
||||
|
||||
// OS version
|
||||
NSString *currentSystemVersion = [SUHost systemVersionString];
|
||||
NSString *currentSystemVersion = [SUOperatingSystem systemVersionString];
|
||||
if (currentSystemVersion != nil) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerOperatingSystemVersionKey, @"OS Version", currentSystemVersion, currentSystemVersion] forKeys:profileDictKeys]];
|
||||
}
|
||||
@@ -113,7 +115,7 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
error = sysctlbyname("hw.model", cpuModel, &length, NULL, 0);
|
||||
if (error == 0) {
|
||||
NSString *rawModelName = @(cpuModel);
|
||||
NSString *visibleModelName = modelTranslation[rawModelName];
|
||||
NSString *visibleModelName = [modelTranslation objectForKey:rawModelName];
|
||||
if (visibleModelName == nil) {
|
||||
visibleModelName = rawModelName;
|
||||
}
|
||||
@@ -133,7 +135,7 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
|
||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
|
||||
if ([languages count] > 0) {
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerPreferredLanguageKey, @"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
|
||||
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerPreferredLanguageKey, @"Preferred Language", [languages objectAtIndex:0], [languages objectAtIndex:0]] forKeys:profileDictKeys]];
|
||||
}
|
||||
|
||||
// Application sending the request
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert;
|
||||
- (void)showAlert:(NSAlert *)alert;
|
||||
- (IBAction)cancelDownload:(id)sender;
|
||||
- (void)installAndRestart:(id)sender;
|
||||
|
||||
|
||||
@@ -11,9 +11,25 @@
|
||||
#import "SUUpdateAlert.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1080
|
||||
@interface NSByteCountFormatter : NSFormatter {
|
||||
@private
|
||||
unsigned int _allowedUnits;
|
||||
char _countStyle;
|
||||
BOOL _allowsNonnumericFormatting, _includesUnit, _includesCount, _includesActualByteCount,
|
||||
_adaptive, _zeroPadsFractionDigits;
|
||||
int _formattingContext;
|
||||
int _reserved[5];
|
||||
}
|
||||
+ (NSString *)stringFromByteCount:(long long)byteCount
|
||||
countStyle:(NSByteCountFormatterCountStyle)countStyle;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUUIBasedUpdateDriver ()
|
||||
|
||||
@property (strong) SUStatusController *statusController;
|
||||
@@ -26,8 +42,25 @@
|
||||
@synthesize statusController;
|
||||
@synthesize updateAlert;
|
||||
|
||||
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater
|
||||
{
|
||||
if ((self = [super initWithUpdater:anUpdater])) {
|
||||
self.automaticallyInstallUpdates = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
if (self.automaticallyInstallUpdates) {
|
||||
[self updateAlertFinishedWithChoice:SUInstallUpdateChoice];
|
||||
return;
|
||||
}
|
||||
|
||||
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
|
||||
[self updateAlertFinishedWithChoice:choice];
|
||||
}];
|
||||
@@ -38,10 +71,6 @@
|
||||
}
|
||||
[self.updateAlert setVersionDisplayer:versDisp];
|
||||
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
@@ -63,11 +92,14 @@
|
||||
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
[self showModalAlert:alert];
|
||||
if (!self.automaticallyInstallUpdates) {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
|
||||
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
|
||||
[self showAlert:alert];
|
||||
}
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@@ -83,10 +115,6 @@
|
||||
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
|
||||
switch (choice) {
|
||||
case SUInstallUpdateChoice:
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
[self.statusController showWindow:self];
|
||||
[self downloadUpdate];
|
||||
break;
|
||||
|
||||
@@ -106,41 +134,77 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadUpdate
|
||||
{
|
||||
BOOL createdStatusController = NO;
|
||||
if (self.statusController == nil) {
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
|
||||
createdStatusController = YES;
|
||||
}
|
||||
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel", nil) target:self action:@selector(cancelDownload:) isDefault:NO];
|
||||
[self.statusController setButtonEnabled:YES];
|
||||
|
||||
if (createdStatusController) {
|
||||
[self.statusController showWindow:self];
|
||||
}
|
||||
|
||||
[super downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
|
||||
{
|
||||
[self.statusController setMaxProgressValue:[response expectedContentLength]];
|
||||
}
|
||||
|
||||
- (NSString *)humanReadableSizeFromDouble:(double)value
|
||||
- (NSString *)localizedStringFromByteCount:(long long)value
|
||||
{
|
||||
if (value < 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")];
|
||||
if (![SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) {
|
||||
if (value < 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1.0,
|
||||
SULocalizedString(@"B", @"the unit for bytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0,
|
||||
SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0,
|
||||
SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0,
|
||||
SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")];
|
||||
}
|
||||
|
||||
if (value < 1000 * 1000 * 1000) {
|
||||
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")];
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
NSByteCountFormatter *formatter = [[NSByteCountFormatter alloc] init];
|
||||
[formatter setZeroPadsFractionDigits:YES];
|
||||
return [formatter stringFromByteCount:value];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
|
||||
{
|
||||
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
|
||||
if ([self.statusController maxProgressValue] > 0.0)
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]], [self humanReadableSizeFromDouble:[self.statusController maxProgressValue]]]];
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue], [self localizedStringFromByteCount:(long long)self.statusController.maxProgressValue]]];
|
||||
else
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]]]];
|
||||
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue]]];
|
||||
}
|
||||
|
||||
- (IBAction)cancelDownload:(id)__unused sender
|
||||
{
|
||||
if (self.download)
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(userDidCancelDownload:)]) {
|
||||
[[self.updater delegate] userDidCancelDownload:self.updater];
|
||||
}
|
||||
}
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@@ -163,6 +227,11 @@
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
if (self.automaticallyInstallUpdates) {
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil];
|
||||
[self.statusController setProgressValue:1.0]; // Fill the bar.
|
||||
[self.statusController setButtonEnabled:YES];
|
||||
@@ -204,7 +273,7 @@
|
||||
alert.messageText = SULocalizedString(@"Update Error!", nil);
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
|
||||
[self showModalAlert:alert];
|
||||
[self showAlert:alert];
|
||||
[super abortUpdateWithError:error];
|
||||
}
|
||||
|
||||
@@ -218,7 +287,7 @@
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)showModalAlert:(NSAlert *)alert
|
||||
- (void)showAlert:(NSAlert *)alert
|
||||
{
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) {
|
||||
[[self.updater delegate] updaterWillShowModalAlert:self.updater];
|
||||
|
||||
@@ -18,11 +18,15 @@
|
||||
|
||||
@property (copy, readonly) NSString *archivePath;
|
||||
@property (copy, readonly) NSString *updateHostBundlePath;
|
||||
@property (copy, readonly) NSString *decryptionPassword;
|
||||
@property (weak) id<SUUnarchiverDelegate> delegate;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host;
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host withPassword:(NSString *)decryptionPassword;
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated;
|
||||
|
||||
- (void)start;
|
||||
|
||||
@end
|
||||
|
||||
@protocol SUUnarchiverDelegate <NSObject>
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
@synthesize archivePath;
|
||||
@synthesize updateHostBundlePath;
|
||||
@synthesize delegate;
|
||||
@synthesize decryptionPassword;
|
||||
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath
|
||||
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath withPassword:(NSString *)decryptionPassword
|
||||
{
|
||||
for (id current in [self unarchiverImplementations])
|
||||
{
|
||||
for (id current in [self unarchiverImplementations]) {
|
||||
if ([current canUnarchivePath:path]) {
|
||||
return [[current alloc] initWithPath:path hostBundlePath:hostPath];
|
||||
return [[current alloc] initWithPath:path hostBundlePath:hostPath password:decryptionPassword];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
@@ -39,12 +39,13 @@
|
||||
// No-op
|
||||
}
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path hostBundlePath:(NSString *)hostPath
|
||||
- (instancetype)initWithPath:(NSString *)path hostBundlePath:(NSString *)hostPath password:(NSString *)password
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
archivePath = [path copy];
|
||||
updateHostBundlePath = hostPath;
|
||||
decryptionPassword = password;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -54,6 +55,11 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)notifyDelegateOfProgress:(double)progress
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedProgress:)]) {
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
|
||||
SUOpenInfoURLChoice
|
||||
};
|
||||
|
||||
@class WebView, SUAppcastItem, SUHost;
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUUpdateAlert : SUWindowController
|
||||
|
||||
@property (weak) id<SUVersionDisplay> versionDisplayer;
|
||||
|
||||