mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Compare commits
791
Commits
ed2x
..
2.4.1-beta.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91a2c1c100 | ||
|
|
53d58921ef | ||
|
|
e15324773f | ||
|
|
b7b858dbf3 | ||
|
|
8e2107a57d | ||
|
|
631846cc82 | ||
|
|
3a99b31f37 | ||
|
|
151c256721 | ||
|
|
82b94a131d | ||
|
|
4ac6ea827a | ||
|
|
b5199e7a05 | ||
|
|
39495fd562 | ||
|
|
60568b82ba | ||
|
|
9ab2c0d58c | ||
|
|
665bba36cc | ||
|
|
1e8308116e | ||
|
|
245c6821aa | ||
|
|
ad936155fa | ||
|
|
d220346206 | ||
|
|
95f8e7e0cf | ||
|
|
362f50a8a1 | ||
|
|
87697ce10f | ||
|
|
da75bb432e | ||
|
|
fde8f0a35e | ||
|
|
06edf5695d | ||
|
|
ffc203b89a | ||
|
|
348c3a9658 | ||
|
|
077d7228ba | ||
|
|
be7f6952c2 | ||
|
|
91b8f4eaa0 | ||
|
|
cc90026ade | ||
|
|
68d539ce83 | ||
|
|
8154b1eab3 | ||
|
|
14e4a98b69 | ||
|
|
f36c34f2f4 | ||
|
|
bdc095bf3a | ||
|
|
8cd13b0cfd | ||
|
|
89e2f94872 | ||
|
|
a6536ea8f1 | ||
|
|
df313f7f59 | ||
|
|
f06ccf2711 | ||
|
|
ef9398ab32 | ||
|
|
8ac92e3ffa | ||
|
|
2a98381dfe | ||
|
|
9b4c91bc58 | ||
|
|
a7855eabe6 | ||
|
|
f86907c13c | ||
|
|
028e4c2bec | ||
|
|
891cd38eba | ||
|
|
a208bd5cf9 | ||
|
|
005392963f | ||
|
|
83cc66b988 | ||
|
|
a93317fb08 | ||
|
|
1b1a7db1ac | ||
|
|
d9c0cc7f53 | ||
|
|
7d68f8f7ae | ||
|
|
03f2452379 | ||
|
|
fc8000471b | ||
|
|
6c0e685063 | ||
|
|
c7c8b719cb | ||
|
|
4fa7b23f09 | ||
|
|
f1fe9e45f6 | ||
|
|
679cbc8652 | ||
|
|
6ef1f7fc7f | ||
|
|
6831a35e28 | ||
|
|
1c560652e7 | ||
|
|
863f85b5f5 | ||
|
|
f46ea87380 | ||
|
|
f5d4ad52ca | ||
|
|
926c47d48e | ||
|
|
fbfcec3453 | ||
|
|
8f77f066c1 | ||
|
|
47f335614a | ||
|
|
80a5b80ade | ||
|
|
e81ccbd891 | ||
|
|
dc2e1ff534 | ||
|
|
37ef179284 | ||
|
|
6a69f26dcc | ||
|
|
4cb6719c6b | ||
|
|
2c81393ec2 | ||
|
|
983d19580b | ||
|
|
6cbe8444a0 | ||
|
|
45a9099082 | ||
|
|
aa72b3f639 | ||
|
|
372f0504a5 | ||
|
|
470296a90e | ||
|
|
242ae2c392 | ||
|
|
059ce91287 | ||
|
|
cc0007de3a | ||
|
|
fe69cab530 | ||
|
|
14e511f901 | ||
|
|
80e60279ee | ||
|
|
c1bf68f91f | ||
|
|
4622061d8f | ||
|
|
a7e5320d6a | ||
|
|
90221e7a0f | ||
|
|
7c1cc5627b | ||
|
|
bececc3738 | ||
|
|
a6984d3c02 | ||
|
|
102c4a4009 | ||
|
|
d2fd9a50e0 | ||
|
|
d544d456e0 | ||
|
|
b1f6c161d1 | ||
|
|
06daa03196 | ||
|
|
e64b7649f2 | ||
|
|
220c1edac1 | ||
|
|
e866f8d786 | ||
|
|
2b6664cd8a | ||
|
|
a913fe1355 | ||
|
|
24b072c661 | ||
|
|
2ddef5179e | ||
|
|
308ba94373 | ||
|
|
9a1142a5b1 | ||
|
|
4cb4974107 | ||
|
|
5343305e3f | ||
|
|
72c866f964 | ||
|
|
6808a94dbb | ||
|
|
38ed86dad0 | ||
|
|
15e8270291 | ||
|
|
d7942768b8 | ||
|
|
f126876d35 | ||
|
|
9080bebc88 | ||
|
|
bf6dc6210f | ||
|
|
04d3c13043 | ||
|
|
a33bae7bad | ||
|
|
b3d31d254e | ||
|
|
024eec0b09 | ||
|
|
9ba73525b0 | ||
|
|
7ced6efba0 | ||
|
|
fabd3e6c7b | ||
|
|
58fa11ce04 | ||
|
|
503830bf24 | ||
|
|
2bc9471ed1 | ||
|
|
339e26984e | ||
|
|
9042c8dbd9 | ||
|
|
180f8975cf | ||
|
|
d5b650bae7 | ||
|
|
94719edeb3 | ||
|
|
c33a416b53 | ||
|
|
b0116ef31b | ||
|
|
c0cf32c2b7 | ||
|
|
f250bead4b | ||
|
|
640e988a39 | ||
|
|
183a930797 | ||
|
|
2f86c4f5fe | ||
|
|
286edd1fa2 | ||
|
|
242ba4e5c4 | ||
|
|
8edc77fdb2 | ||
|
|
eb938ad15a | ||
|
|
18c751eaf9 | ||
|
|
94b48c45e7 | ||
|
|
e8fea3481a | ||
|
|
8ea4d705f5 | ||
|
|
ac2ef612bc | ||
|
|
84252a64f8 | ||
|
|
930ea303fd | ||
|
|
452472ee3e | ||
|
|
d4499956e7 | ||
|
|
91bccdf0ad | ||
|
|
89e20a490d | ||
|
|
9e45a78e6f | ||
|
|
92d8b2bee6 | ||
|
|
6bed29c481 | ||
|
|
fa9bfc1fc4 | ||
|
|
05abb2f7e4 | ||
|
|
c029b98efb | ||
|
|
c30f6fe7fb | ||
|
|
403209b818 | ||
|
|
1641371e83 | ||
|
|
1f538981c3 | ||
|
|
0a152ed02d | ||
|
|
b05c058219 | ||
|
|
3bd1b25513 | ||
|
|
41f953d77b | ||
|
|
51ee14c3d3 | ||
|
|
f6396aecfb | ||
|
|
71fc8d7b11 | ||
|
|
23fc577184 | ||
|
|
a1add127eb | ||
|
|
fc44085602 | ||
|
|
85d3fa2e0e | ||
|
|
81b281b596 | ||
|
|
ee3f8f3285 | ||
|
|
26f1209fe9 | ||
|
|
2195ee0883 | ||
|
|
92c8142354 | ||
|
|
1d04bd44ab | ||
|
|
017f8f733e | ||
|
|
b37fa239db | ||
|
|
831e9b4eb7 | ||
|
|
0a19f6f30d | ||
|
|
3a64116913 | ||
|
|
1ef42e9d1c | ||
|
|
c500487077 | ||
|
|
acc4674c3e | ||
|
|
39cedd4092 | ||
|
|
4517d61db5 | ||
|
|
18fe269949 | ||
|
|
3a9c257691 | ||
|
|
3fcc87086c | ||
|
|
4b6527424a | ||
|
|
1adbbccf5e | ||
|
|
d792a3a4a9 | ||
|
|
32bc43fa9b | ||
|
|
4b9388d9aa | ||
|
|
c53ed49e5e | ||
|
|
011a7dbb36 | ||
|
|
fb1f5aafbe | ||
|
|
52511a2b1c | ||
|
|
5b312aa63e | ||
|
|
7cec9dbbe0 | ||
|
|
dde2b48af7 | ||
|
|
9b6f962b31 | ||
|
|
1cba9f466d | ||
|
|
dbe1ae94f9 | ||
|
|
45956ae5b0 | ||
|
|
4c1bebedf9 | ||
|
|
873a026627 | ||
|
|
9e54c5ca4d | ||
|
|
083790afa7 | ||
|
|
c3030a6621 | ||
|
|
e48edc6856 | ||
|
|
a81f8f3d2d | ||
|
|
88c325a66f | ||
|
|
0d43f88a83 | ||
|
|
2268b96c78 | ||
|
|
3de3591d13 | ||
|
|
7a9c1d76e6 | ||
|
|
fad6f1efe8 | ||
|
|
8045bf7af8 | ||
|
|
a436711133 | ||
|
|
ae7e7f12bc | ||
|
|
80abad4477 | ||
|
|
c9097ba42c | ||
|
|
08f473fe82 | ||
|
|
6f8e8e4789 | ||
|
|
a9d5a42768 | ||
|
|
9364c96336 | ||
|
|
ed9fa9bfed | ||
|
|
21b264543d | ||
|
|
eba1734f09 | ||
|
|
1dea970512 | ||
|
|
0f53f65241 | ||
|
|
c60f12ab47 | ||
|
|
364e797676 | ||
|
|
bf8216240c | ||
|
|
f599a7a1a9 | ||
|
|
7096317766 | ||
|
|
a8840953fe | ||
|
|
76acd9cb5f | ||
|
|
e4b2d96faf | ||
|
|
9229fc57b1 | ||
|
|
c396a53c6f | ||
|
|
2a67e2d732 | ||
|
|
a135f1a1ee | ||
|
|
30361b0128 | ||
|
|
cce5edd78d | ||
|
|
515b8259bc | ||
|
|
edc0fd0e56 | ||
|
|
b4e0dcca6c | ||
|
|
ee679586cf | ||
|
|
c6f1cd4e3c | ||
|
|
306ea26df8 | ||
|
|
d719b92636 | ||
|
|
b43b188c82 | ||
|
|
6b9981f567 | ||
|
|
34fcb8784b | ||
|
|
4f7ed347ab | ||
|
|
9823892062 | ||
|
|
a22562431b | ||
|
|
4db96f6c4f | ||
|
|
385673ff24 | ||
|
|
c3cdbf46cb | ||
|
|
89ab067477 | ||
|
|
29a2fa7974 | ||
|
|
cb9386a4ea | ||
|
|
119766a650 | ||
|
|
9eba644190 | ||
|
|
4a87deeb7f | ||
|
|
a09aad7ca0 | ||
|
|
9c360b465b | ||
|
|
d9d7e310a5 | ||
|
|
5677ca3f5a | ||
|
|
29d4b801fc | ||
|
|
2157f78ffd | ||
|
|
e5c63b6369 | ||
|
|
9f2629c892 | ||
|
|
b21647bcef | ||
|
|
ac1bb7036c | ||
|
|
eecc4802db | ||
|
|
e0a7304a81 | ||
|
|
78a66c7dda | ||
|
|
d8f5f58468 | ||
|
|
e5f1bd5e02 | ||
|
|
c329319b0c | ||
|
|
ad4ec8e3ab | ||
|
|
8997bad17e | ||
|
|
c631a52b48 | ||
|
|
dab34b62a0 | ||
|
|
c968334192 | ||
|
|
6639feaafc | ||
|
|
29c9b72be6 | ||
|
|
64484507b5 | ||
|
|
bc7e2d4845 | ||
|
|
9bb59b8c00 | ||
|
|
267f2b82b1 | ||
|
|
5fba1fe046 | ||
|
|
ccd8886bfd | ||
|
|
1c1b7416ba | ||
|
|
ed3e331f56 | ||
|
|
aa867a0cb9 | ||
|
|
5d27dc6fb3 | ||
|
|
fefce16697 | ||
|
|
28065e7240 | ||
|
|
d0f43e04d1 | ||
|
|
746bb1b248 | ||
|
|
ba5d895e8f | ||
|
|
7efa996ba9 | ||
|
|
2411d7538d | ||
|
|
3e1651d1cd | ||
|
|
4780cfccd5 | ||
|
|
50df5ed438 | ||
|
|
3d8e00eecd | ||
|
|
25e0de5988 | ||
|
|
6e3cd6b313 | ||
|
|
31f6f512e1 | ||
|
|
686fd05fce | ||
|
|
da30373a30 | ||
|
|
1444561899 | ||
|
|
fb8a0a02c8 | ||
|
|
9a3ada03f9 | ||
|
|
d794a2d803 | ||
|
|
b1f9bff9a1 | ||
|
|
c548721e16 | ||
|
|
eeb24ed92d | ||
|
|
66de9697f3 | ||
|
|
cb1e58e309 | ||
|
|
24a0485e98 | ||
|
|
29e7ad4495 | ||
|
|
961605c6d6 | ||
|
|
2b8d2a2be7 | ||
|
|
dfdd6ac978 | ||
|
|
52f3337eda | ||
|
|
defa8e4332 | ||
|
|
3636e22cc5 | ||
|
|
50ba774bbe | ||
|
|
432f10f804 | ||
|
|
232ce2543e | ||
|
|
efe1c8c02e | ||
|
|
1697c7966c | ||
|
|
5203518fbd | ||
|
|
9fd2e72913 | ||
|
|
ff83896e01 | ||
|
|
89ecb88f2b | ||
|
|
4825ac5d62 | ||
|
|
e2723717f1 | ||
|
|
b6956a480d | ||
|
|
7f87d8842e | ||
|
|
cbd1503c06 | ||
|
|
eda1b4bdaa | ||
|
|
7861cea66c | ||
|
|
c0691c4606 | ||
|
|
0063fbda17 | ||
|
|
d468757ee1 | ||
|
|
1013b2506a | ||
|
|
1aadf1b351 | ||
|
|
5287453cfd | ||
|
|
88f678ebe6 | ||
|
|
ee5e98d3dd | ||
|
|
062bfaaa97 | ||
|
|
f51bb996e6 | ||
|
|
8fb44df0b7 | ||
|
|
8f488c6ffd | ||
|
|
63e0b47c98 | ||
|
|
fabf415999 | ||
|
|
0e264dae2f | ||
|
|
60bbb373e2 | ||
|
|
1cc11d76a2 | ||
|
|
90bdd84832 | ||
|
|
b7f9b76dd9 | ||
|
|
253f45b476 | ||
|
|
433e1bf3de | ||
|
|
bbdebfdbee | ||
|
|
8a62dc06fe | ||
|
|
d7c504a254 | ||
|
|
87a4e349ce | ||
|
|
549a8ce117 | ||
|
|
91fc440d15 | ||
|
|
79cd07fc70 | ||
|
|
0cdb0976ef | ||
|
|
e0a414909c | ||
|
|
8e466eecc8 | ||
|
|
17eb15e9d3 | ||
|
|
7d3c7ae78a | ||
|
|
a630614dc4 | ||
|
|
87ecba77d3 | ||
|
|
455e63cc59 | ||
|
|
57b39fc1e5 | ||
|
|
b2127da6f5 | ||
|
|
8fc1689c26 | ||
|
|
898ac7253a | ||
|
|
f8ef9608dc | ||
|
|
d22ef79d9e | ||
|
|
8af1d18764 | ||
|
|
a7e090e3ca | ||
|
|
e607bf19dc | ||
|
|
7490a91406 | ||
|
|
9ee2a525d0 | ||
|
|
54caf47602 | ||
|
|
ed87bcdab6 | ||
|
|
ef577fe0c0 | ||
|
|
7c8defb75e | ||
|
|
f6d8b506ae | ||
|
|
3306ccd994 | ||
|
|
07aca30e11 | ||
|
|
be75bb38f6 | ||
|
|
debab803c9 | ||
|
|
8dc4e78cb2 | ||
|
|
e91ae897e7 | ||
|
|
91e71c219c | ||
|
|
f56e923043 | ||
|
|
50bec90279 | ||
|
|
1f9d76bc13 | ||
|
|
59fbd37bb1 | ||
|
|
f671b82e50 | ||
|
|
1565db3fec | ||
|
|
25b3d01efa | ||
|
|
d193f2e28b | ||
|
|
a79f6b2a85 | ||
|
|
0ee12d881d | ||
|
|
6d6cc2d052 | ||
|
|
039adc1ef2 | ||
|
|
62695379d9 | ||
|
|
f82f9eb878 | ||
|
|
a1aef4eca0 | ||
|
|
3d2dc8a7f6 | ||
|
|
5a3b71b96a | ||
|
|
3c9508bd2a | ||
|
|
79c1141155 | ||
|
|
ebb822af43 | ||
|
|
c882da7bc7 | ||
|
|
f1be9f72d5 | ||
|
|
e7441351d7 | ||
|
|
3cafb688b7 | ||
|
|
d84a79cfc2 | ||
|
|
c33ccd5921 | ||
|
|
6ad996338d | ||
|
|
46f7898d36 | ||
|
|
85ac073e6d | ||
|
|
7c46e8db3e | ||
|
|
fbe48e5738 | ||
|
|
b140c05bad | ||
|
|
c79785aad4 | ||
|
|
5da8199818 | ||
|
|
79a6bb1318 | ||
|
|
9b8756d824 | ||
|
|
712753d812 | ||
|
|
e8d5c8024c | ||
|
|
af245bfe62 | ||
|
|
9a12dbf62a | ||
|
|
477d0a243f | ||
|
|
ab294d607d | ||
|
|
26c63c1a7b | ||
|
|
6adb0c3017 | ||
|
|
7cb72238fa | ||
|
|
0eb5a706f8 | ||
|
|
e179443799 | ||
|
|
c00946ee20 | ||
|
|
12a3da9629 | ||
|
|
84cdb0c7e8 | ||
|
|
478cc98b90 | ||
|
|
bf35926cf3 | ||
|
|
8034404cc7 | ||
|
|
411360deb2 | ||
|
|
d91223a5b6 | ||
|
|
063974c553 | ||
|
|
97f15943e4 | ||
|
|
564f0c316a | ||
|
|
50942909f2 | ||
|
|
71557fac85 | ||
|
|
e51eb32403 | ||
|
|
6d0d1a7aa8 | ||
|
|
c44c164aff | ||
|
|
1244612946 | ||
|
|
842d258330 | ||
|
|
ef7c16bb9d | ||
|
|
f56f937ad2 | ||
|
|
02b85635c7 | ||
|
|
ce70a30be5 | ||
|
|
e8f41640dc | ||
|
|
7247803fea | ||
|
|
fe8b6b3e2a | ||
|
|
f0ff2e3ef0 | ||
|
|
c7ff8f4bb0 | ||
|
|
669c369ce7 | ||
|
|
db6ef214ab | ||
|
|
ba11897345 | ||
|
|
cc4c02f467 | ||
|
|
f58cc9e9b5 | ||
|
|
8f3e340e47 | ||
|
|
547fde293d | ||
|
|
302f3f41a3 | ||
|
|
af9935540a | ||
|
|
188a893174 | ||
|
|
3309abf936 | ||
|
|
1abe5f70db | ||
|
|
ab9ffdb901 | ||
|
|
e64253be0b | ||
|
|
8ff356bc7d | ||
|
|
3593157e3d | ||
|
|
2d0b9ae356 | ||
|
|
d9e0265d76 | ||
|
|
5ff2d7765e | ||
|
|
6b3d2af21a | ||
|
|
2f783e01f0 | ||
|
|
40545494f2 | ||
|
|
b0d9a75f98 | ||
|
|
ed89783a0e | ||
|
|
cb17e08b92 | ||
|
|
286af16842 | ||
|
|
a084e2f09d | ||
|
|
9524b32024 | ||
|
|
cb10bb8046 | ||
|
|
2d9bf07b18 | ||
|
|
eea87561ab | ||
|
|
e7bc17b192 | ||
|
|
07e96961bf | ||
|
|
895bb71fae | ||
|
|
372d711d20 | ||
|
|
5408ab10c1 | ||
|
|
3ea863d82b | ||
|
|
bd1769e82e | ||
|
|
0b634f4d76 | ||
|
|
9052ea912d | ||
|
|
833eb89bb5 | ||
|
|
e909c0d988 | ||
|
|
1f90f7c993 | ||
|
|
6db6a9892a | ||
|
|
e20f099c90 | ||
|
|
9b6e7ba828 | ||
|
|
8c53b1d3ec | ||
|
|
faf047c4ea | ||
|
|
71a36f8be4 | ||
|
|
ebc48cee5c | ||
|
|
467ffb15ca | ||
|
|
a79aa1690b | ||
|
|
e1fdd5a6c4 | ||
|
|
a108d4bc72 | ||
|
|
5a0529a2cd | ||
|
|
3a201a45ac | ||
|
|
93b8700060 | ||
|
|
2614af86ff | ||
|
|
5ae944778a | ||
|
|
f2986ef090 | ||
|
|
923bb96eda | ||
|
|
2af01e8844 | ||
|
|
414c8affc5 | ||
|
|
90aa98b68c | ||
|
|
7e8084b064 | ||
|
|
25001d83ee | ||
|
|
78b0570a76 | ||
|
|
9555cb7397 | ||
|
|
78ec0f46b7 | ||
|
|
f95bf0c7d5 | ||
|
|
cf14d09ee0 | ||
|
|
90448fd564 | ||
|
|
0a4846a186 | ||
|
|
b3e7a03660 | ||
|
|
83aac00fe6 | ||
|
|
89b7fef457 | ||
|
|
5fbf119e6a | ||
|
|
2e8fc4d17a | ||
|
|
454e6d2f13 | ||
|
|
28924f4b2a | ||
|
|
d102a50f66 | ||
|
|
bfc55ac8b0 | ||
|
|
1f35e7b5cd | ||
|
|
f23799a531 | ||
|
|
81453d1410 | ||
|
|
7064ac160b | ||
|
|
f74f9d288d | ||
|
|
3c8ebd921f | ||
|
|
579e7bd98b | ||
|
|
6d548efb2b | ||
|
|
2179eb1e39 | ||
|
|
3ded119af5 | ||
|
|
018d4ea630 | ||
|
|
ef68656783 | ||
|
|
aeffb2710a | ||
|
|
7c223ef0d1 | ||
|
|
724e9eb79e | ||
|
|
59c2c7358f | ||
|
|
dc7b2f2030 | ||
|
|
78a0d4e4e7 | ||
|
|
cd8794acce | ||
|
|
fd940884c8 | ||
|
|
e76e34ead8 | ||
|
|
2dd324d316 | ||
|
|
9e7548c4ff | ||
|
|
e21f7c4e87 | ||
|
|
370fdb8368 | ||
|
|
d3f6370828 | ||
|
|
efa9cc20d0 | ||
|
|
7d8e3059ec | ||
|
|
f400b27cb2 | ||
|
|
f43b5ee3c3 | ||
|
|
1526a024b8 | ||
|
|
5cd1d3c824 | ||
|
|
8a868914e5 | ||
|
|
f5ee4dedb4 | ||
|
|
ef23e7d65e | ||
|
|
d29d3f97a5 | ||
|
|
a1cba4dd91 | ||
|
|
699a9df7bf | ||
|
|
5aa68fa82b | ||
|
|
adc62f8e34 | ||
|
|
f977a92e4c | ||
|
|
dd24e8d938 | ||
|
|
03f20a05a8 | ||
|
|
7ecc624afb | ||
|
|
e331afddb1 | ||
|
|
45581d5658 | ||
|
|
9931992912 | ||
|
|
df3d9e2b14 | ||
|
|
e148659cbb | ||
|
|
0a8443c94a | ||
|
|
0e26a3e27a | ||
|
|
ea472ae3f0 | ||
|
|
59326e80d4 | ||
|
|
3c0962b137 | ||
|
|
2d666b4d84 | ||
|
|
c822f88cf1 | ||
|
|
16dc6c2b5b | ||
|
|
08a7122b36 | ||
|
|
8792137fda | ||
|
|
25820ccd4b | ||
|
|
1290b974de | ||
|
|
c39370e64b | ||
|
|
0b9bacfd0e | ||
|
|
ad545813f0 | ||
|
|
3f226ccdd7 | ||
|
|
13a36cb904 | ||
|
|
c5def52133 | ||
|
|
6b0d9f0de2 | ||
|
|
a9254d1e02 | ||
|
|
2b9a02c825 | ||
|
|
9d335b1233 | ||
|
|
43379af33e | ||
|
|
4c14d7d556 | ||
|
|
afe03b7161 | ||
|
|
79a9c50d2d | ||
|
|
c5add680aa | ||
|
|
e8ebf23504 | ||
|
|
da5be8902c | ||
|
|
7cffceb1f7 | ||
|
|
6c846d0fad | ||
|
|
044313db59 | ||
|
|
e089b9b435 | ||
|
|
98dc6314a5 | ||
|
|
915786e11f | ||
|
|
60fcc89b7e | ||
|
|
f9d421f851 | ||
|
|
27d7058e0e | ||
|
|
03503d37b6 | ||
|
|
0364e01c3a | ||
|
|
bc0e338cde | ||
|
|
d97dbf7ba0 | ||
|
|
9818eff9a2 | ||
|
|
4767ef60ec | ||
|
|
e197f3093a | ||
|
|
1d930b585e | ||
|
|
6da14f7c46 | ||
|
|
5ca8984c10 | ||
|
|
27f31a2913 | ||
|
|
3e544c7d26 | ||
|
|
507255224a | ||
|
|
c1381d48d1 | ||
|
|
c3ce4f624b | ||
|
|
0a35f9d807 | ||
|
|
fd209ced12 | ||
|
|
d85c1df752 | ||
|
|
4fdd01052b | ||
|
|
1278b426f2 | ||
|
|
e880f34f7c | ||
|
|
1d178a9a19 | ||
|
|
22af258dc8 | ||
|
|
01d19ca92e | ||
|
|
173ccc845a | ||
|
|
a0401fade9 | ||
|
|
c6a89eb32b | ||
|
|
f7906c45c0 | ||
|
|
6d0f7fce26 | ||
|
|
6308b262a0 | ||
|
|
2066cd7232 | ||
|
|
64d2ee1b5d | ||
|
|
7896b5ab44 | ||
|
|
c70b39ba79 | ||
|
|
7c7968b2f2 | ||
|
|
ae81bd27a2 | ||
|
|
fd6d480d3d | ||
|
|
fc18529767 | ||
|
|
6fc5011362 | ||
|
|
176ff8f3df | ||
|
|
f64436165b | ||
|
|
154b702552 | ||
|
|
c03cc0fa17 | ||
|
|
f858b99f93 | ||
|
|
85f41927f3 | ||
|
|
d8a8282b60 | ||
|
|
a6ffe0fa71 | ||
|
|
523542ad90 | ||
|
|
57d9a780b8 | ||
|
|
8d6d81c58f | ||
|
|
7a228c7e1d | ||
|
|
6e326f3cea | ||
|
|
3c0e02f333 | ||
|
|
32b0ca2e0f | ||
|
|
6316c53aba | ||
|
|
8fc7cadf69 | ||
|
|
cb5eb0e47d | ||
|
|
ea11447ab2 | ||
|
|
8a3cc2e073 | ||
|
|
03fb6d969f | ||
|
|
d4fb14f1fd | ||
|
|
ec4b113d17 | ||
|
|
ace5d99a27 | ||
|
|
164e0e4f9a | ||
|
|
09178f70e9 | ||
|
|
3bc20cb096 | ||
|
|
80cecd37b5 | ||
|
|
7951b81b69 | ||
|
|
066da58f4d | ||
|
|
5e5aebffd3 | ||
|
|
98eef51931 | ||
|
|
5e0b3f2a19 | ||
|
|
48a1379dbe | ||
|
|
3038218ea7 | ||
|
|
238fd42bb3 | ||
|
|
eac4522817 | ||
|
|
94d05336a6 | ||
|
|
93e4fd9424 | ||
|
|
741ec1a08b | ||
|
|
7a8ead559b | ||
|
|
c802a38c92 | ||
|
|
8947a6e50d | ||
|
|
5e73e70322 | ||
|
|
e2bf94df7e | ||
|
|
a266b400cb | ||
|
|
7b4c648812 | ||
|
|
d38fd92668 | ||
|
|
772e610537 | ||
|
|
02e11f3c3a | ||
|
|
8c7adbdca7 | ||
|
|
852d678585 | ||
|
|
e3ba2388e8 | ||
|
|
6f1fceb7d4 | ||
|
|
bc6d15a13c | ||
|
|
65cab6a14d | ||
|
|
923f15220f | ||
|
|
5fcc9a8aa9 | ||
|
|
500d97d8ff | ||
|
|
d1367393c2 | ||
|
|
404b67a256 | ||
|
|
de8de29df2 | ||
|
|
6a55563307 | ||
|
|
438f4a21d5 | ||
|
|
32bb57c029 | ||
|
|
1c77f59214 | ||
|
|
a95f1592cd | ||
|
|
e7f8161ae4 | ||
|
|
9422bf16ae | ||
|
|
418068e902 | ||
|
|
04b2122fed | ||
|
|
bdffcb0dd5 | ||
|
|
be25c2ac64 | ||
|
|
8487a24584 | ||
|
|
820fdadfd7 | ||
|
|
1343c27805 | ||
|
|
7acb6c4292 | ||
|
|
9592e35d1c | ||
|
|
e7e20e6ac8 | ||
|
|
2b4b2a4443 | ||
|
|
bd601b2f8c | ||
|
|
b137b7f072 | ||
|
|
705638799c | ||
|
|
6b47d3fe90 | ||
|
|
3e000a897f | ||
|
|
b969c31f07 | ||
|
|
299157c3e7 | ||
|
|
3a8040ae2e | ||
|
|
9a74b23f7f |
No files matched your search
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Enhancements and Bug Fixes
|
||||
about: Found a bug? Want to implement a new feature? Something else?
|
||||
title: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
If this is a question or an idea, please consider posting in Discussions first:
|
||||
https://github.com/sparkle-project/Sparkle/discussions
|
||||
|
||||
Otherwise the answer to your issue may already be in Console.app on your computer.
|
||||
Please use Console.app and search for Sparkle.
|
||||
|
||||
Please try troubleshooting steps:
|
||||
https://github.com/sparkle-project/Sparkle#troubleshooting
|
||||
|
||||
-->
|
||||
|
||||
## Summary
|
||||
|
||||
[provide general summary to the issue or enhancement and its rationale]
|
||||
|
||||
## Possible Fix
|
||||
|
||||
[not obligatory, but suggest fixes or reasons for the bug]
|
||||
|
||||
## Version
|
||||
|
||||
[please specify versions of Sparkle this is applicable to; note the old 1.x (master) branch is only taking fixes to regressions and security fixes now.]
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: Sparkle 2.x doesn't work in my app
|
||||
about: Problems with integration, unexpected errors using Sparkle 2
|
||||
title: ''
|
||||
labels: '2.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
The answer to your issue is probably already in Console.app on your computer.
|
||||
Please use Console.app and search for Sparkle.
|
||||
|
||||
Please try troubleshooting steps:
|
||||
https://github.com/sparkle-project/Sparkle#troubleshooting
|
||||
|
||||
-->
|
||||
|
||||
### Description of the problem
|
||||
|
||||
|
||||
### Do you use Sandboxing in your app?
|
||||
|
||||
### Version of `Sparkle.framework` in the latest version of your app
|
||||
|
||||
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
|
||||
|
||||
### Sparkle's output from Console.app
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
|
||||
[The more information provided and pasted verbatim, the easier it will be to diagnose an issue. If you can provide the affected application/binary and XML feed to reproduce an issue, share them]
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: Sparkle 1.x doesn't work in my app
|
||||
about: Problems with integration, unexpected errors using Sparkle 1
|
||||
title: ''
|
||||
labels: '1.x'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
The answer to your issue is probably already in Console.app on your computer.
|
||||
Please use Console.app and search for Sparkle.
|
||||
|
||||
Please try troubleshooting steps:
|
||||
https://github.com/sparkle-project/Sparkle#troubleshooting
|
||||
|
||||
-->
|
||||
|
||||
### Description of the problem
|
||||
|
||||
|
||||
### Do you use Sandboxing in your app?
|
||||
|
||||
### Version of `Sparkle.framework` in the latest version of your app
|
||||
|
||||
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
|
||||
|
||||
### Sparkle's output from Console.app
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
|
||||
[The more information provided and pasted verbatim, the easier it will be to diagnose an issue. If you can provide the affected application/binary and XML feed to reproduce an issue, share them]
|
||||
@@ -0,0 +1,23 @@
|
||||
(Insert summary of your pull request here)
|
||||
|
||||
Fixes # (issue)
|
||||
|
||||
## Misc Checklist
|
||||
|
||||
- [ ] My change requires a documentation update on [Sparkle's website repository](https://github.com/sparkle-project/sparkle-project.github.io)
|
||||
- [ ] My change requires changes to generate_appcast, generate_keys, or sign_update
|
||||
|
||||
Only bug fixes to regressions or security fixes are being backported to the 1.x (master) branch now. If you believe your change is significant enough to backport, please also create a separate pull request against the master branch.
|
||||
|
||||
## Testing
|
||||
|
||||
I tested and verified my change by using one or multiple of these methods:
|
||||
|
||||
- [ ] Sparkle Test App
|
||||
- [ ] Unit Tests
|
||||
- [ ] My own app
|
||||
- [ ] Other (please specify)
|
||||
|
||||
(Describe all the cases that were tested)
|
||||
|
||||
macOS version tested: [place version here]
|
||||
@@ -0,0 +1,106 @@
|
||||
name: Build & Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 2.x, master ]
|
||||
pull_request:
|
||||
branches: [ 2.x, master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
xcode: ['xcode14.2', 'xcode13.4.1']
|
||||
include:
|
||||
- xcode: 'xcode13.4.1'
|
||||
xcode-path: '/Applications/Xcode_13.4.1.app/Contents/Developer'
|
||||
upload-dist: false
|
||||
run-analyzer: true
|
||||
macos: 'macos-12'
|
||||
- xcode: 'xcode14.2'
|
||||
xcode-path: '/Applications/Xcode_14.2.app/Contents/Developer'
|
||||
upload-dist: true
|
||||
run-analyzer: false
|
||||
macos: 'macos-12'
|
||||
|
||||
name: Build and Test Sparkle
|
||||
runs-on: ${{ matrix.macos }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
- name: Build Unit Tests
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild build-for-testing -project Sparkle.xcodeproj -scheme Distribution -enableCodeCoverage YES -derivedDataPath build
|
||||
- name: Run Unit Tests
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild test-without-building -project Sparkle.xcodeproj -scheme Distribution -enableCodeCoverage YES -derivedDataPath build
|
||||
- name: Build UI Tests
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild build-for-testing -project Sparkle.xcodeproj -scheme UITests -configuration Debug -derivedDataPath build
|
||||
- name: Run UI Tests
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild test-without-building -project Sparkle.xcodeproj -scheme UITests -configuration Debug -derivedDataPath build
|
||||
|
||||
- name: Analyze Sparkle
|
||||
if: ${{ matrix.run-analyzer && github.event_name == 'pull_request' }}
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild analyze -project Sparkle.xcodeproj -quiet -scheme Sparkle -configuration Release -derivedDataPath analyze > anaylze_output.txt
|
||||
|
||||
- name: Find Analyzed Warnings
|
||||
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' }}
|
||||
id: findwarnings
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
if grep -q "warning:" anaylze_output.txt; then
|
||||
echo '::set-output name=analyzestatus::0'
|
||||
else
|
||||
echo '::set-output name=analyzestatus::1'
|
||||
fi
|
||||
|
||||
- name: Extract Analyzed Warnings
|
||||
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }}
|
||||
id: warnings
|
||||
run: |
|
||||
echo ::set-output name=content::$(cat anaylze_output.txt)
|
||||
|
||||
- name: Post Analyzed Warnings
|
||||
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }}
|
||||
uses: mshick/add-pr-comment@v1
|
||||
with:
|
||||
allow-repeats: false
|
||||
repo-token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
repo-token-user-login: 'Sparkle-Bot'
|
||||
message: "``` ${{ steps.warnings.outputs.content }} ```"
|
||||
|
||||
- name: Build Release Distribution
|
||||
env:
|
||||
DEVELOPER_DIR: ${{ matrix.xcode-path }}
|
||||
run: |
|
||||
xcodebuild build -project Sparkle.xcodeproj -scheme Distribution -configuration Release -derivedDataPath build
|
||||
- name: Archive Test Results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-logs
|
||||
path: build/Logs
|
||||
- name: Upload Distribution
|
||||
if: ${{ success() && matrix.upload-dist }}
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Sparkle-distribution-${{ matrix.xcode }}.tar.xz
|
||||
path: build/Build/Products/Release/sparkle-dist.tar.xz
|
||||
@@ -0,0 +1,101 @@
|
||||
name: "Create Draft Release"
|
||||
|
||||
env:
|
||||
BUILDDIR: "build"
|
||||
DEVELOPER_DIR: "/Applications/Xcode_14.2.app/Contents/Developer"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
marketingVersion:
|
||||
description: "Marketing Version"
|
||||
required: true
|
||||
default: ""
|
||||
|
||||
prereleaseSuffix:
|
||||
description: "Pre-release Suffix"
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
buildVersion:
|
||||
description: "Product Build"
|
||||
required: true
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
group: publish-release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: "Publish binaries for release"
|
||||
runs-on: macos-12
|
||||
|
||||
steps:
|
||||
- name: "Checkout sources"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Extract latest changes from CHANGELOG"
|
||||
run: |
|
||||
./Configurations/generate_latest_changes.py > latest-changes.txt
|
||||
|
||||
- name: "Overwrite project versions in project"
|
||||
run: |
|
||||
IFS='.' read major minor patch <<< "${{ github.event.inputs.marketingVersion }}"
|
||||
sed -E -i '' "s/SPARKLE_VERSION_MAJOR =.+/SPARKLE_VERSION_MAJOR = $major/g" ./Configurations/ConfigCommon.xcconfig
|
||||
sed -E -i '' "s/SPARKLE_VERSION_MINOR =.+/SPARKLE_VERSION_MINOR = $minor/g" ./Configurations/ConfigCommon.xcconfig
|
||||
sed -E -i '' "s/SPARKLE_VERSION_PATCH =.+/SPARKLE_VERSION_PATCH = $patch/g" ./Configurations/ConfigCommon.xcconfig
|
||||
|
||||
if [[ ! -z "${{ github.event.inputs.prereleaseSuffix }}" ]]; then
|
||||
sed -E -i '' "s/SPARKLE_VERSION_SUFFIX =.*/SPARKLE_VERSION_SUFFIX = ${{ github.event.inputs.prereleaseSuffix }}/g" ./Configurations/ConfigCommon.xcconfig
|
||||
else
|
||||
sed -E -i '' "s/SPARKLE_VERSION_SUFFIX =.*/SPARKLE_VERSION_SUFFIX =/g" ./Configurations/ConfigCommon.xcconfig
|
||||
fi
|
||||
|
||||
sed -E -i '' "s/CURRENT_PROJECT_VERSION =.+/CURRENT_PROJECT_VERSION = ${{ github.event.inputs.buildVersion }}/g" ./Configurations/ConfigCommon.xcconfig
|
||||
git add ./Configurations/ConfigCommon.xcconfig
|
||||
|
||||
- name: "Determine if this is a pre-release version"
|
||||
run: |
|
||||
if [[ ! -z "${{ github.event.inputs.prereleaseSuffix }}" ]]; then
|
||||
echo "PRERELEASE_VERSION=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "PRERELEASE_VERSION=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: "Set up git and create tag"
|
||||
run: |
|
||||
git config user.name Sparkle-Bot
|
||||
git config user.email sparkle.project.bot@gmail.com
|
||||
git tag "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
|
||||
- name: "Build release distribution"
|
||||
run: make release
|
||||
env:
|
||||
GITHUB_ACTOR: ${{ github.actor }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
|
||||
- name: "Push the updated package description"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
run: git push
|
||||
|
||||
- name: "Draft a release"
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
prerelease: ${{ env.PRERELEASE_VERSION }}
|
||||
target_commitish: ${{ github.ref_name }}
|
||||
name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||
body_path: latest-changes.txt
|
||||
files: |
|
||||
build/Build/Products/Release/Sparkle-*.tar.xz
|
||||
build/Build/Products/Release/Sparkle-for-Swift-Package-Manager.zip
|
||||
@@ -41,3 +41,7 @@ Carthage/Build
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Swift Package Manager
|
||||
/.build
|
||||
.swiftpm
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "Vendor/ed25519"]
|
||||
path = Vendor/ed25519
|
||||
url = https://github.com/orlp/ed25519
|
||||
@@ -1,7 +0,0 @@
|
||||
os: osx
|
||||
language: objective-c
|
||||
osx_image:
|
||||
- xcode10.3
|
||||
- xcode11.4
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -project Sparkle.xcodeproj -scheme Distribution -derivedDataPath build -enableCodeCoverage YES | xcpretty
|
||||
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUInstallerAgentProtocol;
|
||||
|
||||
@interface AgentConnection : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface AgentConnection : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate;
|
||||
|
||||
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@property (nonatomic, readonly, nullable) id<SPUInstallerAgentProtocol> agent;
|
||||
@property (nonatomic, readonly) BOOL connected;
|
||||
@property (nonatomic, nullable) NSError *invalidationError;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -16,21 +16,18 @@
|
||||
|
||||
@interface AgentConnection () <NSXPCListenerDelegate, SUInstallerAgentInitiationProtocol>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
@property (nonatomic, nullable) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic, nullable) id<SPUInstallerAgentProtocol> agent;
|
||||
@property (nonatomic, weak) id<AgentConnectionDelegate> delegate;
|
||||
@property (nonatomic) BOOL connected;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AgentConnection
|
||||
{
|
||||
NSXPCListener *_xpcListener;
|
||||
NSXPCConnection *_activeConnection;
|
||||
__weak id<AgentConnectionDelegate> _delegate;
|
||||
}
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize agent = _agent;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize connected = _connected;
|
||||
@synthesize invalidationError = _invalidationError;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate
|
||||
{
|
||||
@@ -47,23 +44,23 @@
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[_xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
self.delegate = nil;
|
||||
_delegate = nil;
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
self.activeConnection = nil;
|
||||
[_activeConnection invalidate];
|
||||
_activeConnection = nil;
|
||||
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
if (_activeConnection != nil) {
|
||||
[newConnection invalidate];
|
||||
return NO;
|
||||
}
|
||||
@@ -73,22 +70,30 @@
|
||||
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SPUInstallerAgentProtocol)];
|
||||
|
||||
self.activeConnection = newConnection;
|
||||
_activeConnection = newConnection;
|
||||
|
||||
__weak AgentConnection *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
newConnection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_activeConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.delegate agentConnectionDidInvalidate];
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_delegate agentConnectionDidInvalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[newConnection resume];
|
||||
|
||||
self.agent = newConnection.remoteObjectProxy;
|
||||
_agent = newConnection.remoteObjectProxy;
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -96,13 +101,20 @@
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.connected = YES;
|
||||
self->_connected = YES;
|
||||
|
||||
[self.delegate agentConnectionDidInitiate];
|
||||
self.delegate = nil;
|
||||
[self->_delegate agentConnectionDidInitiate];
|
||||
self->_delegate = nil;
|
||||
});
|
||||
|
||||
acknowledgement();
|
||||
}
|
||||
|
||||
- (void)connectionWillInvalidateWithError:(NSError *)error
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self->_invalidationError = error;
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,12 +9,16 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUnarchiverProtocol.h"
|
||||
|
||||
@interface AppInstaller : NSObject
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier;
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface AppInstaller : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName;
|
||||
|
||||
- (void)start;
|
||||
|
||||
- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn));
|
||||
- (void)cleanupAndExitWithStatus:(int)status error:(NSError * _Nullable)error __attribute__((noreturn));
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+236
-238
@@ -11,6 +11,7 @@
|
||||
#import "SUInstaller.h"
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SULog.h"
|
||||
#import "SULog+NSError.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
@@ -21,7 +22,7 @@
|
||||
#import "SUFileManager.h"
|
||||
#import "SPUInstallationInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SUInstallerCommunicationProtocol.h"
|
||||
#import "AgentConnection.h"
|
||||
#import "SPUInstallerAgentProtocol.h"
|
||||
@@ -31,10 +32,10 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 7ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 5ull
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 18ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 8ull
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Show display progress UI after a delay from starting the final part of the installation.
|
||||
* This should be long enough so that we don't show progress for very fast installations, but
|
||||
* short enough so that we don't leave the user wondering why nothing is happening.
|
||||
@@ -42,71 +43,50 @@
|
||||
static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
@interface AppInstaller () <NSXPCListenerDelegate, SUInstallerCommunicationProtocol, AgentConnectionDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener* xpcListener;
|
||||
@property (nonatomic) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> communicator;
|
||||
@property (nonatomic) AgentConnection *agentConnection;
|
||||
@property (nonatomic) BOOL receivedUpdaterPong;
|
||||
|
||||
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||
|
||||
@property (nonatomic) SUUpdateValidator *updateValidator;
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *hostBundleIdentifier;
|
||||
@property (nonatomic) SUHost *host;
|
||||
@property (nonatomic, copy) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy) NSString *downloadName;
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
@property (nonatomic, strong) SUSignatures *signatures;
|
||||
@property (nonatomic, copy) NSString *relaunchPath;
|
||||
@property (nonatomic, copy) NSString *installationType;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||
|
||||
@property (nonatomic) id<SUInstallerProtocol> installer;
|
||||
@property (nonatomic) BOOL willCompleteInstallation;
|
||||
@property (nonatomic) BOOL receivedInstallationData;
|
||||
@property (nonatomic) BOOL finishedValidation;
|
||||
@property (nonatomic) BOOL agentInitiatedConnection;
|
||||
|
||||
@property (nonatomic) dispatch_queue_t installerQueue;
|
||||
@property (nonatomic) BOOL performedStage1Installation;
|
||||
@property (nonatomic) BOOL performedStage2Installation;
|
||||
@property (nonatomic) BOOL performedStage3Installation;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInstaller
|
||||
{
|
||||
NSXPCListener* _xpcListener;
|
||||
NSXPCConnection *_activeConnection;
|
||||
id<SUInstallerCommunicationProtocol> _communicator;
|
||||
AgentConnection *_agentConnection;
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize communicator = _communicator;
|
||||
@synthesize agentConnection = _agentConnection;
|
||||
@synthesize receivedUpdaterPong = _receivedUpdaterPong;
|
||||
@synthesize hostBundleIdentifier = _hostBundleIdentifier;
|
||||
@synthesize terminationListener = _terminationListener;
|
||||
@synthesize updateValidator = _updateValidator;
|
||||
@synthesize host = _host;
|
||||
@synthesize updateDirectoryPath = _updateDirectoryPath;
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize installationType = _installationType;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@synthesize shouldShowUI = _shouldShowUI;
|
||||
@synthesize installer = _installer;
|
||||
@synthesize willCompleteInstallation = _willCompleteInstallation;
|
||||
@synthesize receivedInstallationData = _receivedInstallationData;
|
||||
@synthesize installerQueue = _installerQueue;
|
||||
@synthesize performedStage1Installation = _performedStage1Installation;
|
||||
@synthesize performedStage2Installation = _performedStage2Installation;
|
||||
@synthesize performedStage3Installation = _performedStage3Installation;
|
||||
@synthesize finishedValidation = _finishedValidation;
|
||||
@synthesize agentInitiatedConnection = _agentInitiatedConnection;
|
||||
TerminationListener *_terminationListener;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier
|
||||
SUUpdateValidator *_updateValidator;
|
||||
|
||||
NSString *_hostBundleIdentifier;
|
||||
NSString *_homeDirectory;
|
||||
NSString *_userName;
|
||||
SUHost *_host;
|
||||
NSString *_updateDirectoryPath;
|
||||
NSString *_downloadName;
|
||||
NSString *_decryptionPassword;
|
||||
SUSignatures *_signatures;
|
||||
NSString *_relaunchPath;
|
||||
NSString *_installationType;
|
||||
|
||||
id<SUInstallerProtocol> _installer;
|
||||
|
||||
dispatch_queue_t _installerQueue;
|
||||
|
||||
BOOL _shouldRelaunch;
|
||||
BOOL _shouldShowUI;
|
||||
|
||||
BOOL _receivedUpdaterPong;
|
||||
|
||||
BOOL _willCompleteInstallation;
|
||||
BOOL _receivedInstallationData;
|
||||
BOOL _finishedValidation;
|
||||
BOOL _agentInitiatedConnection;
|
||||
|
||||
BOOL _performedStage1Installation;
|
||||
BOOL _performedStage2Installation;
|
||||
BOOL _performedStage3Installation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
@@ -114,6 +94,9 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
_hostBundleIdentifier = [hostBundleIdentifier copy];
|
||||
|
||||
_homeDirectory = [homeDirectory copy];
|
||||
_userName = [userName copy];
|
||||
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
|
||||
@@ -124,109 +107,112 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
if (_activeConnection != nil) {
|
||||
SULog(SULogLevelDefault, @"Rejecting multiple connections...");
|
||||
[newConnection invalidate];
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.activeConnection = newConnection;
|
||||
_activeConnection = newConnection;
|
||||
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
newConnection.exportedObject = self;
|
||||
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
|
||||
__weak AppInstaller *weakSelf = self;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
newConnection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
[strongSelf->_activeConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
newConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
AppInstaller *strongSelf = weakSelf;
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
if (strongSelf.activeConnection != nil && !strongSelf.willCompleteInstallation) {
|
||||
SULog(SULogLevelError, @"Invalidation on remote port being called, and installation is not close enough to completion!");
|
||||
[strongSelf cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (strongSelf->_activeConnection != nil && !strongSelf->_willCompleteInstallation) {
|
||||
[strongSelf cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Invalidation on remote port being called, and installation is not close enough to completion!" }]];
|
||||
}
|
||||
strongSelf.communicator = nil;
|
||||
strongSelf.activeConnection = nil;
|
||||
strongSelf->_communicator = nil;
|
||||
strongSelf->_activeConnection = nil;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[newConnection resume];
|
||||
|
||||
self.communicator = newConnection.remoteObjectProxy;
|
||||
_communicator = newConnection.remoteObjectProxy;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[self.agentConnection startListener];
|
||||
[_xpcListener resume];
|
||||
[_agentConnection startListener];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FIRST_UPDATER_MESSAGE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.receivedInstallationData) {
|
||||
SULog(SULogLevelError, @"Timeout: installation data was never received");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (!self->_receivedInstallationData) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: installation data was never received" }]];
|
||||
}
|
||||
|
||||
if (!self.agentConnection.connected) {
|
||||
SULog(SULogLevelError, @"Timeout: agent connection was never initiated");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (!self->_agentConnection.connected) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: agent connection was never initiated" }]];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)extractAndInstallUpdate
|
||||
- (void)extractAndInstallUpdate SPU_OBJC_DIRECT
|
||||
{
|
||||
[self.communicator handleMessageWithIdentifier:SPUExtractionStarted data:[NSData data]];
|
||||
[_communicator handleMessageWithIdentifier:SPUExtractionStarted data:[NSData data]];
|
||||
|
||||
NSString *archivePath = [self.updateDirectoryPath stringByAppendingPathComponent:self.downloadName];
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:self.host.bundlePath decryptionPassword:self.decryptionPassword];
|
||||
NSString *archivePath = [_updateDirectoryPath stringByAppendingPathComponent:_downloadName];
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:_host.bundlePath decryptionPassword:_decryptionPassword expectingInstallationType:_installationType];
|
||||
|
||||
NSError *unarchiverError = nil;
|
||||
BOOL success = NO;
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@", archivePath);
|
||||
unarchiverError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"No valid unarchiver was found for %@", archivePath] }];
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:self.signatures host:self.host];
|
||||
_updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:_signatures host:_host];
|
||||
|
||||
// Delta & package updates will require validation before extraction
|
||||
// Normal application updates are a bit more lenient allowing developers to change one of apple dev ID or DSA keys
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![self.installationType isEqualToString:SPUInstallationTypeApplication];
|
||||
// Normal application updates are a bit more lenient allowing developers to change one of apple dev ID or EdDSA keys
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![_installationType isEqualToString:SPUInstallationTypeApplication];
|
||||
|
||||
if (needsPrevalidation) {
|
||||
success = [self.updateValidator validateDownloadPath];
|
||||
success = [_updateValidator validateDownloadPathWithError:&unarchiverError];
|
||||
} else {
|
||||
success = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
[self unarchiverDidFail];
|
||||
[self unarchiverDidFailWithError:unarchiverError];
|
||||
} else {
|
||||
[unarchiver
|
||||
unarchiveWithCompletionBlock:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
[self unarchiverDidFail];
|
||||
[self unarchiverDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to unarchive %@", archivePath], NSUnderlyingErrorKey: (NSError * _Nonnull)error }]];
|
||||
} else {
|
||||
[self.communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
|
||||
|
||||
BOOL validationSuccess = [self.updateValidator validateWithUpdateDirectory:self.updateDirectoryPath];
|
||||
NSError *validationError = nil;
|
||||
BOOL validationSuccess = [self->_updateValidator validateWithUpdateDirectory:self->_updateDirectoryPath error:&validationError];
|
||||
|
||||
if (!validationSuccess) {
|
||||
SULog(SULogLevelError, @"Error: update validation was a failure");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Update validation was a failure", NSUnderlyingErrorKey: validationError }]];
|
||||
} else {
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationStartedStage1 data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationStartedStage1 data:[NSData data]];
|
||||
|
||||
self.finishedValidation = YES;
|
||||
if (self.agentInitiatedConnection) {
|
||||
self->_finishedValidation = YES;
|
||||
if (self->_agentInitiatedConnection) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
@@ -237,103 +223,119 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
uint64_t progressValue = CFSwapInt64HostToLittle(*(uint64_t *)&progress);
|
||||
NSData *data = [NSData dataWithBytes:&progressValue length:sizeof(progressValue)];
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUExtractedArchiveWithProgress data:data];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUExtractedArchiveWithProgress data:data];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFail
|
||||
- (void)clearUpdateDirectory SPU_OBJC_DIRECT
|
||||
{
|
||||
if (_updateDirectoryPath != nil) {
|
||||
NSError *theError = nil;
|
||||
if (![[[SUFileManager alloc] init] removeItemAtURL:[NSURL fileURLWithPath:_updateDirectoryPath] error:&theError]) {
|
||||
SULog(SULogLevelError, @"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
_updateDirectoryPath = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFailWithError:(NSError *)error SPU_OBJC_DIRECT
|
||||
{
|
||||
SULog(SULogLevelError, @"Failed to unarchive file");
|
||||
SULogError(error);
|
||||
|
||||
// No longer need update validator until next possible extraction (eg: if initial delta update fails)
|
||||
self.updateValidator = nil;
|
||||
_updateValidator = nil;
|
||||
|
||||
// Client could try update again with different inputs
|
||||
// Eg: one common case is if a delta update fails, client may want to fall back to regular update
|
||||
// We really only need to set updateDirectoryPath to nil since that's the field we check if we've received installation data,
|
||||
// but may as well set other fields to nil too
|
||||
self.updateDirectoryPath = nil;
|
||||
self.downloadName = nil;
|
||||
self.decryptionPassword = nil;
|
||||
self.signatures = nil;
|
||||
self.relaunchPath = nil;
|
||||
self.host = nil;
|
||||
[self clearUpdateDirectory];
|
||||
_downloadName = nil;
|
||||
_decryptionPassword = nil;
|
||||
_signatures = nil;
|
||||
_relaunchPath = nil;
|
||||
_host = nil;
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUArchiveExtractionFailed data:[NSData data]];
|
||||
NSData *archivedError = SPUArchiveRootObjectSecurely(error);
|
||||
[_communicator handleMessageWithIdentifier:SPUArchiveExtractionFailed data:archivedError != nil ? archivedError : [NSData data]];
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInitiate
|
||||
{
|
||||
self.agentInitiatedConnection = YES;
|
||||
if (self.finishedValidation) {
|
||||
_agentInitiatedConnection = YES;
|
||||
if (_finishedValidation) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInvalidate
|
||||
{
|
||||
if (!self.finishedValidation || !self.agentInitiatedConnection) {
|
||||
SULog(SULogLevelError, @"Error: Agent connection invalidated before installation began");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (!_finishedValidation || !_agentInitiatedConnection) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Error: Agent connection invalidated before installation began" }];
|
||||
|
||||
NSError *agentError = _agentConnection.invalidationError;
|
||||
if (agentError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = agentError;
|
||||
}
|
||||
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:userInfo]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)retrieveProcessIdentifierAndStartInstallation
|
||||
- (void)retrieveProcessIdentifierAndStartInstallation SPU_OBJC_DIRECT
|
||||
{
|
||||
// We use the relaunch path for the bundle to listen for termination instead of the host path
|
||||
// For a plug-in this makes a big difference; we want to wait until the app hosting the plug-in terminates
|
||||
// Otherwise for an app, the relaunch path and host path should be identical
|
||||
|
||||
[self.agentConnection.agent registerApplicationBundlePath:self.relaunchPath reply:^(NSNumber * _Nullable processIdentifier) {
|
||||
[_agentConnection.agent registerApplicationBundlePath:_relaunchPath reply:^(NSNumber * _Nullable processIdentifier) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
self->_terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
[self startInstallation];
|
||||
});
|
||||
}];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (self.terminationListener == nil) {
|
||||
SULog(SULogLevelError, @"Timeout error: failed to retreive process identifier from agent");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (self->_terminationListener == nil) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout error: failed to retreive process identifier from agent" }]];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
{
|
||||
if (identifier == SPUInstallationData && self.updateDirectoryPath == nil) {
|
||||
if (identifier == SPUInstallationData && _updateDirectoryPath == nil) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Mark that we have received the installation data
|
||||
// Do not rely on eg: self.ipdateDirectoryPath != nil because we may set it to nil again if an early stage fails (i.e, archive extraction)
|
||||
self.receivedInstallationData = YES;
|
||||
// Do not rely on eg: self->_updateDirectoryPath != nil because we may set it to nil again if an early stage fails (i.e, archive extraction)
|
||||
self->_receivedInstallationData = YES;
|
||||
|
||||
SPUInstallationInputData *installationData = (SPUInstallationInputData *)SPUUnarchiveRootObjectSecurely(data, [SPUInstallationInputData class]);
|
||||
if (installationData == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to unarchive input installation data");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to unarchive input installation data" }]];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *installationType = installationData.installationType;
|
||||
if (!SPUValidInstallationType(installationType)) {
|
||||
SULog(SULogLevelError, @"Error: Received invalid installation type: %@", installationType);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Received invalid installation type: %@", installationType] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:installationData.hostBundlePath];
|
||||
|
||||
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self.hostBundleIdentifier]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to match host bundle identifiers %@ and %@", self.hostBundleIdentifier, bundleIdentifier);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self->_hostBundleIdentifier]) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to match host bundle identifiers %@ and %@", self->_hostBundleIdentifier, bundleIdentifier] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
// This will be important later
|
||||
if (installationData.relaunchPath == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to obtain relaunch path from installation data");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to obtain relaunch path from installation data" }]];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -344,8 +346,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
NSString *cacheInstallationPath = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:rootCacheInstallationPath];
|
||||
if (cacheInstallationPath == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to create installation cache directory in %@", rootCacheInstallationPath);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to create installation cache directory in %@", rootCacheInstallationPath] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -358,8 +359,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
NSError *moveError = nil;
|
||||
if (![[[SUFileManager alloc] init] moveItemAtURL:downloadURL toURL:downloadDestinationURL error:&moveError]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to move download archive to new location: %@", moveError);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to move download archive to new location", NSUnderlyingErrorKey: moveError }]];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -367,44 +367,43 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
NSError *attributesError = nil;
|
||||
NSString *downloadDestinationPath = downloadDestinationURL.path;
|
||||
if (downloadDestinationPath == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to retrieve download archive path from %@", downloadDestinationURL);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to retrieve download archive path from %@", downloadDestinationURL] }]];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary<NSString *, id> *archiveAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadDestinationPath error:&attributesError];
|
||||
|
||||
if (archiveAttributes == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to retrieve download archive attributes from %@", downloadDestinationPath);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to retrieve download archive attributes from %@", downloadDestinationPath] }]];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (![(NSString *)archiveAttributes[NSFileType] isEqualToString:NSFileTypeRegular]) {
|
||||
SULog(SULogLevelError, @"Error: Received bad archive file type: %@", archiveAttributes[NSFileType]);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Received bad archive file type: %@", archiveAttributes[NSFileType]] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
// Carry these properities separately rather than using the SUInstallationInputData object
|
||||
// Some of our properties may slightly differ than our input and we don't want to make the mistake of using one of those
|
||||
self.installationType = installationType;
|
||||
self.relaunchPath = installationData.relaunchPath;
|
||||
self.downloadName = installationData.downloadName;
|
||||
self.signatures = installationData.signatures;
|
||||
self.updateDirectoryPath = cacheInstallationPath;
|
||||
self.host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
self->_installationType = installationType;
|
||||
self->_relaunchPath = installationData.relaunchPath;
|
||||
self->_downloadName = installationData.downloadName;
|
||||
self->_signatures = installationData.signatures;
|
||||
self->_updateDirectoryPath = cacheInstallationPath;
|
||||
self->_host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
|
||||
[self extractAndInstallUpdate];
|
||||
});
|
||||
} else if (identifier == SPUSentUpdateAppcastItemData) {
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SPUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
|
||||
if (updateItem != nil) {
|
||||
SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[self.installer canInstallSilently]];
|
||||
SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[_installer canInstallSilently]];
|
||||
|
||||
NSData *archivedData = SPUArchiveRootObjectSecurely(installationInfo);
|
||||
if (archivedData != nil) {
|
||||
[self.agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
[_agentConnection.agent registerInstallationInfoData:archivedData];
|
||||
}
|
||||
}
|
||||
} else if (identifier == SPUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
|
||||
@@ -414,47 +413,58 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// This flag has an impact on interactive type installations and showing UI progress during non-interactive installations
|
||||
self.shouldShowUI = (BOOL)showsUI;
|
||||
self->_shouldShowUI = (BOOL)showsUI;
|
||||
// Don't test if the application was alive initially, leave that to the progress agent if we decide to relaunch
|
||||
self.shouldRelaunch = (BOOL)relaunch;
|
||||
self->_shouldRelaunch = (BOOL)relaunch;
|
||||
|
||||
if (self.performedStage1Installation) {
|
||||
if (self->_performedStage1Installation) {
|
||||
// Resume the installation if we aren't done with stage 2 yet, and remind the client we are prepared to relaunch
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
[self performStage2InstallationIfNeeded];
|
||||
dispatch_async(self->_installerQueue, ^{
|
||||
if (!self->_performedStage2Installation) {
|
||||
[self performStage2Installation];
|
||||
} else if (!self->_performedStage3Installation) {
|
||||
// If we already performed the 2nd stage, re-purpose this request to re-try sending another termination signal
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Don't check if the target is already terminated, leave that to the progress agent
|
||||
// We could be slightly off if there were multiple instances running
|
||||
[self->_agentConnection.agent sendTerminationSignal];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (identifier == SPUCancelInstallation) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:0 error:nil];
|
||||
});
|
||||
} else if (identifier == SPUUpdaterAlivePong) {
|
||||
self.receivedUpdaterPong = YES;
|
||||
_receivedUpdaterPong = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startInstallation
|
||||
- (void)startInstallation SPU_OBJC_DIRECT
|
||||
{
|
||||
self.willCompleteInstallation = YES;
|
||||
_willCompleteInstallation = YES;
|
||||
|
||||
self.installerQueue = dispatch_queue_create("org.sparkle-project.sparkle.installer", DISPATCH_QUEUE_SERIAL);
|
||||
_installerQueue = dispatch_queue_create("org.sparkle-project.sparkle.installer", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
dispatch_async(_installerQueue, ^{
|
||||
NSError *installerError = nil;
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self.host expectedInstallationType:self.installationType updateDirectory:self.updateDirectoryPath error:&installerError];
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self->_host expectedInstallationType:self->_installationType updateDirectory:self->_updateDirectoryPath homeDirectory:self->_homeDirectory userName:self->_userName error:&installerError];
|
||||
|
||||
if (installer == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to create installer instance with error: %@", installerError);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to create installer instance", NSUnderlyingErrorKey: installerError }]];
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *firstStageError = nil;
|
||||
if (![installer performInitialInstallation:&firstStageError]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to start installer with error: %@", firstStageError);
|
||||
self.installer = nil;
|
||||
self->_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to start installer", NSUnderlyingErrorKey: firstStageError }]];
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -462,17 +472,17 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
uint8_t canPerformSilentInstall = (uint8_t)[installer canInstallSilently];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.installer = installer;
|
||||
self->_installer = installer;
|
||||
|
||||
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
|
||||
uint8_t targetTerminated = (uint8_t)self->_terminationListener.terminated;
|
||||
|
||||
uint8_t sendInformation[] = {canPerformSilentInstall, targetTerminated};
|
||||
|
||||
NSData *sendData = [NSData dataWithBytes:sendInformation length:sizeof(sendInformation)];
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData];
|
||||
|
||||
self.performedStage1Installation = YES;
|
||||
self->_performedStage1Installation = YES;
|
||||
|
||||
// Stage 2 can still be run before we finish installation
|
||||
// if the updater requests for it before the app is terminated
|
||||
@@ -481,141 +491,129 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)performStage2InstallationIfNeeded
|
||||
- (void)performStage2Installation SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.performedStage2Installation) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL performedSecondStage = self.shouldShowUI || [self.installer canInstallSilently];
|
||||
if (performedSecondStage) {
|
||||
self.performedStage2Installation = YES;
|
||||
BOOL canPerformSecondStage = _shouldShowUI || [_installer canInstallSilently];
|
||||
if (canPerformSecondStage) {
|
||||
_performedStage2Installation = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
|
||||
uint8_t targetTerminated = (uint8_t)self->_terminationListener.terminated;
|
||||
|
||||
NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)];
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData];
|
||||
|
||||
// Don't check if the target is already terminated, leave that to the progress agent
|
||||
// We could be slightly off if there were multiple instances running
|
||||
[self.agentConnection.agent sendTerminationSignal];
|
||||
[self->_agentConnection.agent sendTerminationSignal];
|
||||
});
|
||||
} else {
|
||||
SULog(SULogLevelError, @"Error: Failed to resume installer on stage 2 because installation cannot be installed silently");
|
||||
self.installer = nil;
|
||||
_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to resume installer on stage 2 because installation cannot be installed silently" }]];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)finishInstallationAfterHostTermination
|
||||
- (void)finishInstallationAfterHostTermination SPU_OBJC_DIRECT
|
||||
{
|
||||
[self.terminationListener startListeningWithCompletion:^(BOOL success) {
|
||||
[_terminationListener startListeningWithCompletion:^(BOOL success) {
|
||||
if (!success) {
|
||||
SULog(SULogLevelError, @"Failed to listen for application termination");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to listen for application termination" }]];
|
||||
return;
|
||||
}
|
||||
|
||||
// Show our installer progress UI tool if only after a certain amount of time passes,
|
||||
// and if our installer is silent (i.e, doesn't show progress on its own)
|
||||
__block BOOL shouldShowUIProgress = YES;
|
||||
if (self.shouldShowUI && [self.installer canInstallSilently]) {
|
||||
if (self->_shouldShowUI && [self->_installer canInstallSilently]) {
|
||||
// Ask the updater if it is still alive
|
||||
// If they are, we will receive a pong response back
|
||||
// Reset if we received a pong just to be on the safe side
|
||||
self.receivedUpdaterPong = NO;
|
||||
[self.communicator handleMessageWithIdentifier:SPUUpdaterAlivePing data:[NSData data]];
|
||||
self->_receivedUpdaterPong = NO;
|
||||
[self->_communicator handleMessageWithIdentifier:SPUUpdaterAlivePing data:[NSData data]];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUDisplayProgressTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// Make sure we're still eligible for showing the installer progress
|
||||
// Also if the updater process is still alive, showing the progress should not be our duty
|
||||
// if the communicator object is nil, the updater definitely isn't alive. However, if it is not nil,
|
||||
// this does not necessarily mean the updater is alive, so we should also check if we got a recent response back from the updater
|
||||
if (shouldShowUIProgress && (!self.receivedUpdaterPong || self.communicator == nil)) {
|
||||
[self.agentConnection.agent showProgress];
|
||||
if (shouldShowUIProgress && (!self->_receivedUpdaterPong || self->_communicator == nil)) {
|
||||
[self->_agentConnection.agent showProgress];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
[self performStage2InstallationIfNeeded];
|
||||
dispatch_async(self->_installerQueue, ^{
|
||||
if (!self->_performedStage2Installation) {
|
||||
[self performStage2Installation];
|
||||
}
|
||||
|
||||
if (!self.performedStage2Installation) {
|
||||
if (!self->_performedStage2Installation) {
|
||||
// We failed and we're going to exit shortly
|
||||
return;
|
||||
}
|
||||
|
||||
// Used later for relaunching
|
||||
// Compute this now before we set this installer property to nil
|
||||
NSString *installationPath = [self.installer installationPath];
|
||||
|
||||
NSError *thirdStageError = nil;
|
||||
if (![self.installer performFinalInstallationProgressBlock:nil error:&thirdStageError]) {
|
||||
SULog(SULogLevelError, @"Failed to finalize installation with error: %@", thirdStageError);
|
||||
|
||||
self.installer = nil;
|
||||
if (![self->_installer performFinalInstallationProgressBlock:nil error:&thirdStageError]) {
|
||||
[self->_installer performCleanup];
|
||||
self->_installer = nil;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to finalize installation", NSUnderlyingErrorKey: thirdStageError }]];
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
self.performedStage3Installation = YES;
|
||||
self->_performedStage3Installation = YES;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Make sure to stop our displayed progress before we move onto cleanup & relaunch
|
||||
// This will also stop the agent from broadcasting the status info service, which we want to do before
|
||||
// we relaunch the app because the relaunched app could check the service upon launch..
|
||||
[self.agentConnection.agent stopProgress];
|
||||
[self->_agentConnection.agent stopProgress];
|
||||
shouldShowUIProgress = NO;
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SPUInstallationFinishedStage3 data:[NSData data]];
|
||||
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage3 data:[NSData data]];
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
NSString *pathToRelaunch = nil;
|
||||
// If the relaunch path is the same as the host bundle path, use the installation path from the installer which may be normalized
|
||||
// Otherwise use the requested relaunch path in all other cases
|
||||
if ([self.relaunchPath.pathComponents isEqualToArray:self.host.bundlePath.pathComponents]) {
|
||||
pathToRelaunch = installationPath;
|
||||
} else {
|
||||
pathToRelaunch = self.relaunchPath;
|
||||
}
|
||||
|
||||
if (self->_shouldRelaunch) {
|
||||
// This will also signal to the agent that it will terminate soon
|
||||
[self.agentConnection.agent relaunchPath:pathToRelaunch];
|
||||
[self->_agentConnection.agent relaunchApplication];
|
||||
}
|
||||
|
||||
[self cleanupAndExitWithStatus:EXIT_SUCCESS];
|
||||
[self->_installer performCleanup];
|
||||
|
||||
[self cleanupAndExitWithStatus:EXIT_SUCCESS error:nil];
|
||||
});
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn))
|
||||
- (void)cleanupAndExitWithStatus:(int)status error:(NSError * _Nullable)error __attribute__((noreturn))
|
||||
{
|
||||
// It's nice to tell the other end we're invalidating
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
self.activeConnection = nil;
|
||||
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
|
||||
[self.agentConnection invalidate];
|
||||
self.agentConnection = nil;
|
||||
|
||||
if (self.updateDirectoryPath != nil) {
|
||||
NSError *theError = nil;
|
||||
if (![[[SUFileManager alloc] init] removeItemAtURL:[NSURL fileURLWithPath:self.updateDirectoryPath] error:&theError]) {
|
||||
SULog(SULogLevelError, @"Couldn't remove update folder: %@.", theError);
|
||||
if (error != nil) {
|
||||
SULogError(error);
|
||||
|
||||
NSData *errorData = SPUArchiveRootObjectSecurely((NSError * _Nonnull)error);
|
||||
if (errorData != nil) {
|
||||
[_communicator handleMessageWithIdentifier:SPUInstallerError data:errorData];
|
||||
}
|
||||
}
|
||||
|
||||
// It's nice to tell the other end we're invalidating
|
||||
|
||||
[_activeConnection invalidate];
|
||||
_activeConnection = nil;
|
||||
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
|
||||
[_agentConnection invalidate];
|
||||
_agentConnection = nil;
|
||||
|
||||
[self clearUpdateDirectory];
|
||||
|
||||
exit(status);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SPUDeltaArchive.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/29/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol SPUDeltaArchiveProtocol;
|
||||
@class SPUDeltaArchiveHeader;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Opens patch file for reading and decodes the archive header
|
||||
id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFile, SPUDeltaArchiveHeader * _Nullable __autoreleasing * _Nullable outHeader);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// SPUDeltaArchive.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/29/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUDeltaArchive.h"
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
#import "SPUSparkleDeltaArchive.h"
|
||||
#import "SPUXarDeltaArchive.h"
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
SPUDeltaCompressionMode SPUDeltaCompressionModeDefault = (SPUDeltaCompressionMode)UINT8_MAX;
|
||||
|
||||
id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFile, SPUDeltaArchiveHeader * _Nullable __autoreleasing * _Nullable outHeader)
|
||||
{
|
||||
id<SPUDeltaArchiveProtocol> sparkleArchive = [[SPUSparkleDeltaArchive alloc] initWithPatchFileForReading:patchFile];
|
||||
|
||||
SPUDeltaArchiveHeader *header = [sparkleArchive readHeader];
|
||||
if (header == nil) {
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
NSError *archiveError = sparkleArchive.error;
|
||||
if (archiveError != nil && [archiveError.domain isEqualToString:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN] && archiveError.code == SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC) {
|
||||
// Retry with XAR archive if the magic value is unexpected
|
||||
[sparkleArchive close];
|
||||
|
||||
id<SPUDeltaArchiveProtocol> xarArchive = [[SPUXarDeltaArchive alloc] initWithPatchFileForReading:patchFile];
|
||||
|
||||
SPUDeltaArchiveHeader *xarHeader = [xarArchive readHeader];
|
||||
if (outHeader != NULL) {
|
||||
*outHeader = xarHeader;
|
||||
}
|
||||
return xarArchive;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (outHeader != NULL) {
|
||||
*outHeader = nil;
|
||||
}
|
||||
return sparkleArchive;
|
||||
}
|
||||
} else {
|
||||
if (outHeader != NULL) {
|
||||
*outHeader = header;
|
||||
}
|
||||
return sparkleArchive;
|
||||
}
|
||||
}
|
||||
|
||||
@implementation SPUDeltaArchiveItem
|
||||
|
||||
@synthesize relativeFilePath = _relativeFilePath;
|
||||
@synthesize itemFilePath = _itemFilePath;
|
||||
@synthesize clonedRelativePath = _clonedRelativePath;
|
||||
@synthesize sourcePath = _sourcePath;
|
||||
@synthesize commands = _commands;
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
@synthesize xarContext = _xarContext;
|
||||
#endif
|
||||
@synthesize mode = _mode;
|
||||
@synthesize codedDataLength = _codedDataLength;
|
||||
|
||||
- (instancetype)initWithRelativeFilePath:(NSString *)relativeFilePath commands:(SPUDeltaItemCommands)commands mode:(uint16_t)mode
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_relativeFilePath = [relativeFilePath copy];
|
||||
_commands = commands;
|
||||
_mode = mode;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUDeltaArchiveHeader
|
||||
{
|
||||
unsigned char _beforeTreeHash[CC_SHA1_DIGEST_LENGTH];
|
||||
unsigned char _afterTreeHash[CC_SHA1_DIGEST_LENGTH];
|
||||
}
|
||||
|
||||
@synthesize compression = _compression;
|
||||
@synthesize compressionLevel = _compressionLevel;
|
||||
@synthesize fileSystemCompression = _fileSystemCompression;
|
||||
@synthesize majorVersion = _majorVersion;
|
||||
@synthesize minorVersion = _minorVersion;
|
||||
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_compression = compression;
|
||||
_compressionLevel = compressionLevel;
|
||||
_fileSystemCompression = fileSystemCompression;
|
||||
|
||||
_majorVersion = majorVersion;
|
||||
_minorVersion = minorVersion;
|
||||
|
||||
memcpy(_beforeTreeHash, beforeTreeHash, sizeof(_beforeTreeHash));
|
||||
memcpy(_afterTreeHash, afterTreeHash, sizeof(_afterTreeHash));
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (unsigned char *)beforeTreeHash
|
||||
{
|
||||
return _beforeTreeHash;
|
||||
}
|
||||
|
||||
- (unsigned char *)afterTreeHash
|
||||
{
|
||||
return _afterTreeHash;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// SPUDeltaArchiveProtocol.h
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/28/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SPUDeltaCompressionMode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Attributes for an item we extract/write to the archive
|
||||
|
||||
// Note: BinaryDiff cannot coexist together with Delete
|
||||
typedef NS_ENUM(uint8_t, SPUDeltaItemCommands) {
|
||||
SPUDeltaItemCommandEndMarker = 0,
|
||||
SPUDeltaItemCommandDelete = (1u << 0),
|
||||
SPUDeltaItemCommandExtract = (1u << 1),
|
||||
SPUDeltaItemCommandModifyPermissions = (1u << 2),
|
||||
SPUDeltaItemCommandBinaryDiff = (1u << 3),
|
||||
SPUDeltaItemCommandClone = (1u << 4),
|
||||
};
|
||||
|
||||
// Represents header for our archive
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveHeader : NSObject
|
||||
|
||||
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash;
|
||||
|
||||
@property (nonatomic, readonly) SPUDeltaCompressionMode compression;
|
||||
@property (nonatomic, readonly) uint8_t compressionLevel;
|
||||
@property (nonatomic, readonly) bool fileSystemCompression;
|
||||
@property (nonatomic, readonly) uint16_t majorVersion;
|
||||
@property (nonatomic, readonly) uint16_t minorVersion;
|
||||
@property (nonatomic, readonly) unsigned char *beforeTreeHash;
|
||||
@property (nonatomic, readonly) unsigned char *afterTreeHash;
|
||||
|
||||
@end
|
||||
|
||||
// Represents an item we read or write to in our delta archive
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveItem : NSObject
|
||||
|
||||
- (instancetype)initWithRelativeFilePath:(NSString *)relativeFilePath commands:(SPUDeltaItemCommands)commands mode:(uint16_t)mode;
|
||||
|
||||
// The relative file path of the item, eg /Contents/MacOS/Foo
|
||||
@property (nonatomic, readonly) NSString *relativeFilePath;
|
||||
// For extraction, the path where the item will be extracted. For creation, the path to the item to add to the archive.
|
||||
@property (nonatomic, nullable) NSString *itemFilePath;
|
||||
// The relative file path of the originating item for clones. This may be null.
|
||||
// For example, if /Contents/Resources/hello/foo.txt moves to /Contents/Resources/hello2/foo.txt, the former is the relative path
|
||||
@property (nonatomic, nullable) NSString *clonedRelativePath;
|
||||
// The source path of the item to extract file metadata from such as file size.
|
||||
@property (nonatomic, nullable) NSString *sourcePath;
|
||||
// The commands that describe the actions to take for this item.
|
||||
@property (nonatomic, readonly) SPUDeltaItemCommands commands;
|
||||
// Provided change in permissions for item or tracking file mode for the item
|
||||
@property (nonatomic) uint16_t mode;
|
||||
|
||||
// Private properties
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
// xar_file context for Xar delta archiver
|
||||
@property (nonatomic, nullable) const void *xarContext;
|
||||
#endif
|
||||
// Tracking length of item's data in data section, when encoding items and when extracting items
|
||||
@property (nonatomic) uint64_t codedDataLength;
|
||||
|
||||
@end
|
||||
|
||||
// A protocol for reading and writing binary delta patches
|
||||
// Operations must be done in order. The header must first be read or written before any other operations.
|
||||
// For reading, file items cannot be extracted out of order.
|
||||
@protocol SPUDeltaArchiveProtocol <NSObject>
|
||||
|
||||
@property (nonatomic, readonly, class) BOOL maySupportSafeExtraction;
|
||||
|
||||
// If non-nil, there was an error with reading or writing data from the archive
|
||||
@property (nonatomic, readonly, nullable) NSError *error;
|
||||
|
||||
// Closes file for reading/writing, called in -dealloc if it's not called manually
|
||||
- (void)close;
|
||||
|
||||
// For reading
|
||||
|
||||
// Retrieves metadata for the archive including major/minor version and expected bundle hashes
|
||||
- (nullable SPUDeltaArchiveHeader *)readHeader;
|
||||
|
||||
// Enumerate through items in the patch file and read the path, attributes, permissions (if permission attribute is available), and way to stop enumeration
|
||||
- (void)enumerateItems:(void (^)(SPUDeltaArchiveItem *item, BOOL *stop))itemHandler;
|
||||
|
||||
// Extract a file item from the patch file to a destination file
|
||||
// The item's physical file path must be set as a destination
|
||||
- (BOOL)extractItem:(SPUDeltaArchiveItem *)item;
|
||||
|
||||
// ------------
|
||||
|
||||
// For writing
|
||||
|
||||
// Set metadata for archive including major/minor version and expected bundle hashes
|
||||
- (void)writeHeader:(SPUDeltaArchiveHeader *)header;
|
||||
|
||||
// Add item to patch file
|
||||
// Physical file path must be provided if there is an extract or binary delta attribute
|
||||
// Permissions are used only if there is a modify permissions attribute
|
||||
- (void)addItem:(SPUDeltaArchiveItem *)item;
|
||||
|
||||
// Finishes encoding items after having added all of them
|
||||
- (void)finishEncodingItems;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// SPUDeltaCompressionMode.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/3/22.
|
||||
// Copyright © 2022 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Compression mode to use during patch creation
|
||||
typedef NS_ENUM(uint8_t, SPUDeltaCompressionMode) {
|
||||
SPUDeltaCompressionModeNone = 0,
|
||||
SPUDeltaCompressionModeBzip2,
|
||||
SPUDeltaCompressionModeLZMA,
|
||||
SPUDeltaCompressionModeLZFSE,
|
||||
SPUDeltaCompressionModeLZ4,
|
||||
SPUDeltaCompressionModeZLIB
|
||||
};
|
||||
|
||||
// For Swift access
|
||||
extern SPUDeltaCompressionMode SPUDeltaCompressionModeDefault;
|
||||
@@ -12,13 +12,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
|
||||
@interface SPUInstallationInfo : NSObject <NSSecureCoding>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInfo : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentyInstall;
|
||||
|
||||
@property (nonatomic, readonly) SUAppcastItem *appcastItem;
|
||||
@property (nonatomic, readonly) BOOL canSilentlyInstall;
|
||||
|
||||
@property (nonatomic) BOOL systemDomain;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -14,22 +14,30 @@
|
||||
|
||||
static NSString *SUAppcastItemKey = @"SUAppcastItem";
|
||||
static NSString *SUCanSilentlyInstallKey = @"SUCanSilentlyInstall";
|
||||
static NSString *SUSystemDomainKey = @"SUSystemDomain";
|
||||
|
||||
@implementation SPUInstallationInfo
|
||||
|
||||
@synthesize appcastItem = _appcastItem;
|
||||
@synthesize canSilentlyInstall = _canSilentlyInstall;
|
||||
@synthesize systemDomain = _systemDomain;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall systemDomain:(BOOL)systemDomain
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_appcastItem = appcastItem;
|
||||
_canSilentlyInstall = canSilentlyInstall;
|
||||
_systemDomain = systemDomain;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall
|
||||
{
|
||||
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:NO];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
SUAppcastItem *appcastItem = [decoder decodeObjectOfClass:[SUAppcastItem class] forKey:SUAppcastItemKey];
|
||||
@@ -38,13 +46,15 @@ static NSString *SUCanSilentlyInstallKey = @"SUCanSilentlyInstall";
|
||||
}
|
||||
|
||||
BOOL canSilentlyInstall = [decoder decodeBoolForKey:SUCanSilentlyInstallKey];
|
||||
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall];
|
||||
BOOL systemDomain = [decoder decodeBoolForKey:SUSystemDomainKey];
|
||||
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:systemDomain];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.appcastItem forKey:SUAppcastItemKey];
|
||||
[coder encodeBool:self.canSilentlyInstall forKey:SUCanSilentlyInstallKey];
|
||||
[coder encodeObject:_appcastItem forKey:SUAppcastItemKey];
|
||||
[coder encodeBool:_canSilentlyInstall forKey:SUCanSilentlyInstallKey];
|
||||
[coder encodeBool:_systemDomain forKey:SUSystemDomainKey];
|
||||
}
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUInstallationInputData : NSObject <NSSecureCoding>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInputData : NSObject <NSSecureCoding>
|
||||
|
||||
/*
|
||||
* relaunchPath - path to application bundle to relaunch and listen for termination
|
||||
@@ -22,14 +22,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* signatures - signatures for the update that came from the appcast item
|
||||
* decryptionPassword - optional decryption password for dmg archives
|
||||
*/
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relaunchPath;
|
||||
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy, readonly) NSString *downloadName;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (nonatomic, strong, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, readonly, nullable) SUSignatures *signatures; // nullable because although not using signatures is deprecated, it's still supported
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,7 +30,7 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize installationType = _installationType;
|
||||
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -87,14 +87,14 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.relaunchPath forKey:SURelaunchPathKey];
|
||||
[coder encodeObject:self.hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:self.installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:self.signatures forKey:SUSignaturesKey];
|
||||
if (self.decryptionPassword != nil) {
|
||||
[coder encodeObject:self.decryptionPassword forKey:SUDecryptionPasswordKey];
|
||||
[coder encodeObject:_relaunchPath forKey:SURelaunchPathKey];
|
||||
[coder encodeObject:_hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:_updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:_installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:_downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:_signatures forKey:SUSignaturesKey];
|
||||
if (_decryptionPassword != nil) {
|
||||
[coder encodeObject:_decryptionPassword forKey:SUDecryptionPasswordKey];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUHost;
|
||||
|
||||
extern NSString *SPUAppcastItemArchiveKey;
|
||||
|
||||
// Order matters; higher stages have higher values.
|
||||
typedef NS_ENUM(int32_t, SPUInstallerMessageType)
|
||||
{
|
||||
@@ -26,7 +22,8 @@ typedef NS_ENUM(int32_t, SPUInstallerMessageType)
|
||||
SPUInstallationFinishedStage1 = 6,
|
||||
SPUInstallationFinishedStage2 = 7,
|
||||
SPUInstallationFinishedStage3 = 8,
|
||||
SPUUpdaterAlivePing = 9
|
||||
SPUUpdaterAlivePing = 9,
|
||||
SPUInstallerError = 10
|
||||
};
|
||||
|
||||
typedef NS_ENUM(int32_t, SPUUpdaterMessageType)
|
||||
@@ -34,15 +31,19 @@ typedef NS_ENUM(int32_t, SPUUpdaterMessageType)
|
||||
SPUInstallationData = 0,
|
||||
SPUSentUpdateAppcastItemData = 1,
|
||||
SPUResumeInstallationToStage2 = 2,
|
||||
SPUUpdaterAlivePong = 3
|
||||
SPUUpdaterAlivePong = 3,
|
||||
SPUCancelInstallation = 4
|
||||
};
|
||||
|
||||
BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUInstallerMessageType newMessageType);
|
||||
|
||||
// Used by framework to communicate to installer (Autoupdate)
|
||||
NSString *SPUInstallerServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
// Used by framework to communicate to progress agent tool (Updater)
|
||||
NSString *SPUStatusInfoServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
// Used by progress agent tool to communicate to installer (Autoupdate)
|
||||
NSString *SPUProgressAgentServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -7,24 +7,19 @@
|
||||
//
|
||||
|
||||
#import "SPUMessageTypes.h"
|
||||
#import "SUHost.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
NSString *SPUAppcastItemArchiveKey = @"SPUAppcastItemArchive";
|
||||
|
||||
// Tags added to the bundle identifier which is used as Mach service names
|
||||
// These should be very short because length restrictions exist on earlier versions of macOS
|
||||
// These should be very short because of length restrictions
|
||||
#define SPARKLE_INSTALLER_TAG @"-spki"
|
||||
#define SPARKLE_STATUS_TAG @"-spks"
|
||||
#define SPARKLE_PROGRESS_TAG @"-spkp"
|
||||
#define SPARKLE_PROGRESS_LAUNCH_INSTALLER_TAG @"-spkl"
|
||||
|
||||
// macOS 10.8 at least can't handle service names that are 64 characters or longer
|
||||
// This was fixed some point after 10.8, but I'm not sure if it was fixed in 10.9 or 10.10 or 10.11
|
||||
// If we knew when it was fixed, this could only be relevant to OS versions prior to that
|
||||
#define MAX_SERVICE_NAME_LENGTH 63u
|
||||
// macOS 10.8 couldn't handle service names that are >= 64 characters,
|
||||
// but 10.9 raised this to >= 128 characters
|
||||
#define MAX_SERVICE_NAME_LENGTH 127u
|
||||
|
||||
BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUInstallerMessageType newMessageType)
|
||||
{
|
||||
@@ -55,9 +50,10 @@ BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUI
|
||||
case SPUInstallationFinishedStage3:
|
||||
legal = (oldMessageType == SPUInstallationFinishedStage2);
|
||||
break;
|
||||
case SPUInstallerError:
|
||||
case SPUUpdaterAlivePing:
|
||||
// Having this state being dependent on other installation states would make the complicate our logic
|
||||
// So just always allow this type of message
|
||||
// So just always allow these type of messages
|
||||
legal = YES;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// SPUSparkleDeltaArchive.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
#import "SPUDeltaCompressionMode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN @"Sparkle Delta Archive"
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC 1
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_COMPRESSION_VALUE 2
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CHUNK_SIZE 3
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP 4
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES 5
|
||||
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG 6
|
||||
|
||||
/*
|
||||
Modern container format for binary delta archives.
|
||||
|
||||
Delta archive format has four sections which are the header, the relative file path table, the commands, and the data blobs.
|
||||
|
||||
The relative file path table records all the file paths the archive needs to know about.
|
||||
The commands are the operations to be recorded (eg: extract, clone, binary diff, delete).
|
||||
The commands may additionally have more metadata such as file permission modes, relative path indexes in the case of clones, or file sizes for the data blobs.
|
||||
The data blobs contain all file data from extract and binary diff outputs.
|
||||
|
||||
The implementation design of this archive is such that we do not seek backwards or skip ahead to fetch data.
|
||||
We go through the archive when writing or reading from it in a single pass.
|
||||
|
||||
-- UNCOMPRESSED --
|
||||
|
||||
[ HEADER (part 1) ]
|
||||
magic (length: 4)
|
||||
compression (length: 1)
|
||||
metadata (See format below. length: 1)
|
||||
|
||||
-- METADATA --
|
||||
compressionLevel (bits [0, 4])
|
||||
(bits [5, 6] reserved)
|
||||
fileSystemCompression (bit 7)
|
||||
|
||||
-- COMPRESSED --
|
||||
|
||||
[ HEADER (part 2)]
|
||||
majorVersion (length: 2)
|
||||
minorVersion (length: 2)
|
||||
beforeTreeHash (length: 40)
|
||||
afterTreeHash (length: 40)
|
||||
|
||||
[ RELATIVE_FILE_PATH_TABLE ]
|
||||
sizeOfRelativeFilePathTable (length: 8 bytes)
|
||||
List of null terminated path strings joined together (N paths)
|
||||
|
||||
[ COMMANDS ]
|
||||
[ Command ]
|
||||
Set of command types for entry (length: 1 byte)
|
||||
Additional metadata for command (see below section)
|
||||
(M commands where M <= N paths)
|
||||
(Indexes for commands refer to indexes to relative file path table, excluding extraneous trailing entries in relative path table used for clones)
|
||||
(Last command must be a ZERO COMMAND (a null terminating command))
|
||||
|
||||
[COMMAND METADATA]
|
||||
[COMMAND: DELETE]
|
||||
N/A: no additional data
|
||||
|
||||
[COMMAND: MODIFY_PERMISSIONS]
|
||||
fileMode (length: 2)
|
||||
|
||||
[COMMAND: CLONE_FILE]
|
||||
sourceRelativePathIndex (length: 4)
|
||||
|
||||
[COMMAND: EXTRACT_FILE]
|
||||
dataLength (length: 8 for regular files, 2 for symbolic links, 0 for directories)
|
||||
|
||||
[COMMAND: BINARY_DIFF_FILE]
|
||||
dataLength (length: 8)
|
||||
|
||||
Note: These command types may be OR'd or combined. In those cases, different commands
|
||||
that have the same attribute (eg dataLength) are not repeated. This list of metadata is also
|
||||
in order in what will be encoded/decoded first.
|
||||
|
||||
EXTRACT_FILE and BINARY_DIFF_FILE cannot be combined.
|
||||
CLONE_FILE and EXTRACT_FILE cannot be combined.
|
||||
MODIFY_PERMISSIONS can be combined with either CLONE_FILE, EXTRACT_FILE, BINARY_DIFF_FILE, or just by itself.
|
||||
CLONE_FILE can be combined with BINARY_DIFF_FILE or just by itself.
|
||||
DELETE can be combined with EXTRACT_FILE, or just by itself. It is only combined with EXTRACT_FILE when the file type (regular, directory, or symlink) changes.
|
||||
|
||||
[ DATA_BLOBS ]
|
||||
All raw binary data joined together
|
||||
(P number of blobs where P <= M commands)
|
||||
(Indexes for data blobs correspond to indexes for a filtered list of applicable commands (EXTRACT_FILE, BINARY_DIFF_FILE) that have data content)
|
||||
*/
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUSparkleDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile;
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// SPUXarDeltaArchive.h
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/28/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
#import "SPUDeltaCompressionMode.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Legacy container format for binary delta archives
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SPUXarDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile SPU_OBJC_DIRECT;
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile SPU_OBJC_DIRECT;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,413 @@
|
||||
//
|
||||
// SPUXarDeltaArchive.m
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/28/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
|
||||
#import "SPUXarDeltaArchive.h"
|
||||
#include <xar/xar.h>
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#import <Availability.h>
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
|
||||
#define HAS_XAR_GET_SAFE_PATH 1
|
||||
#else
|
||||
#define HAS_XAR_GET_SAFE_PATH 0
|
||||
#endif
|
||||
|
||||
#if HAS_XAR_GET_SAFE_PATH
|
||||
// This is preferred over xar_get_path (which is deprecated) when it's available
|
||||
// Don't use OS availability for this API
|
||||
extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
|
||||
#endif
|
||||
|
||||
// Xar attribute keys
|
||||
#define BINARY_DELTA_ATTRIBUTES_KEY "binary-delta-attributes"
|
||||
#define MAJOR_DIFF_VERSION_KEY "major-version"
|
||||
#define MINOR_DIFF_VERSION_KEY "minor-version"
|
||||
#define BEFORE_TREE_SHA1_KEY "before-tree-sha1"
|
||||
#define AFTER_TREE_SHA1_KEY "after-tree-sha1"
|
||||
#define DELETE_KEY "delete"
|
||||
#define EXTRACT_KEY "extract"
|
||||
#define BINARY_DELTA_KEY "binary-delta"
|
||||
#define MODIFY_PERMISSIONS_KEY "mod-permissions"
|
||||
|
||||
// Errors
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN @"Sparkle XAR Archive"
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE 1
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE 2
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE 3
|
||||
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE 4
|
||||
|
||||
@implementation SPUXarDeltaArchive
|
||||
{
|
||||
NSMutableDictionary<NSString *, NSValue *> *_fileTable;
|
||||
NSString *_patchFile;
|
||||
|
||||
xar_t _x;
|
||||
int32_t _xarMode;
|
||||
}
|
||||
|
||||
@synthesize error = _error;
|
||||
|
||||
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_patchFile = [patchFile copy];
|
||||
_xarMode = WRITE;
|
||||
_fileTable = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_patchFile = [patchFile copy];
|
||||
_xarMode = READ;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self close];
|
||||
}
|
||||
|
||||
- (void)close
|
||||
{
|
||||
if (_x != NULL) {
|
||||
xar_close(_x);
|
||||
_x = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// This indicates if safe extraction is available at compile time (SDK), but not if it's available at runtime.
|
||||
+ (BOOL)maySupportSafeExtraction
|
||||
{
|
||||
return HAS_XAR_GET_SAFE_PATH;
|
||||
}
|
||||
|
||||
- (nullable SPUDeltaArchiveHeader *)readHeader
|
||||
{
|
||||
NSString *patchFile = _patchFile;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Sparkle's XAR delta archives have been superceded by Sparkle's own format
|
||||
xar_t x = xar_open(patchFile.fileSystemRepresentation, READ);
|
||||
#pragma clang diagnostic pop
|
||||
if (x == NULL) {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for reading: %@", patchFile] }];
|
||||
return nil;
|
||||
}
|
||||
|
||||
_x = x;
|
||||
|
||||
uint16_t majorDiffVersion = SUBinaryDeltaMajorVersionFirst;
|
||||
uint16_t minorDiffVersion = 0;
|
||||
NSString *expectedBeforeHash = nil;
|
||||
NSString *expectedAfterHash = nil;
|
||||
|
||||
xar_subdoc_t subdoc;
|
||||
for (subdoc = xar_subdoc_first(_x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
if (strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY) == 0) {
|
||||
{
|
||||
// available in version 2.0 or later
|
||||
const char *value = NULL;
|
||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||
if (value != NULL) {
|
||||
majorDiffVersion = (uint16_t)[@(value) intValue];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// available in version 2.0 or later
|
||||
const char *value = NULL;
|
||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||
if (value != NULL) {
|
||||
minorDiffVersion = (uint16_t)[@(value) intValue];
|
||||
}
|
||||
}
|
||||
|
||||
// available in version 2.0 or later
|
||||
{
|
||||
const char *value = NULL;
|
||||
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
|
||||
if (value != NULL) {
|
||||
expectedBeforeHash = @(value);
|
||||
}
|
||||
}
|
||||
|
||||
// available in version 2.0 or later
|
||||
{
|
||||
const char *value = NULL;
|
||||
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
|
||||
if (value != NULL) {
|
||||
expectedAfterHash = @(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char rawExpectedBeforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
getRawHashFromDisplayHash(rawExpectedBeforeHash, expectedBeforeHash);
|
||||
|
||||
unsigned char rawExpectedAfterHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
getRawHashFromDisplayHash(rawExpectedAfterHash, expectedAfterHash);
|
||||
|
||||
// I wasn't able to figure out how to retrieve the compression options from xar,
|
||||
// so we will use default flags to indicate the info isn't available
|
||||
return [[SPUDeltaArchiveHeader alloc] initWithCompression:SPUDeltaCompressionModeDefault compressionLevel:0 fileSystemCompression:false majorVersion:majorDiffVersion minorVersion:minorDiffVersion beforeTreeHash:rawExpectedBeforeHash afterTreeHash:rawExpectedAfterHash];
|
||||
}
|
||||
|
||||
- (void)writeHeader:(SPUDeltaArchiveHeader *)header
|
||||
{
|
||||
NSString *patchFile = _patchFile;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Sparkle's XAR delta archives have been superceded by Sparkle's own format
|
||||
xar_t x = xar_open(patchFile.fileSystemRepresentation, WRITE);
|
||||
#pragma clang diagnostic pop
|
||||
if (x == NULL) {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for writing: %@", patchFile] }];
|
||||
return;
|
||||
}
|
||||
|
||||
_x = x;
|
||||
|
||||
SPUDeltaCompressionMode compression = (header.compression == SPUDeltaCompressionModeDefault ? SPUDeltaCompressionModeBzip2 : header.compression);
|
||||
|
||||
uint8_t compressionLevel;
|
||||
// Only 1 - 9 are valid, 0 is special case to use default level 9
|
||||
if (header.compressionLevel <= 0 || header.compressionLevel > 9) {
|
||||
compressionLevel = 9;
|
||||
} else {
|
||||
compressionLevel = header.compressionLevel;
|
||||
}
|
||||
|
||||
switch (compression) {
|
||||
case SPUDeltaCompressionModeNone:
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, XAR_OPT_VAL_NONE);
|
||||
break;
|
||||
case SPUDeltaCompressionModeBzip2: {
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
|
||||
char buffer[256] = {0};
|
||||
snprintf(buffer, sizeof(buffer) - 1, "%d", compressionLevel);
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSIONARG, buffer);
|
||||
|
||||
break;
|
||||
}
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
case SPUDeltaCompressionModeZLIB: {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Version 2 patches only support bzip2 compression."] }];
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
|
||||
|
||||
xar_subdoc_prop_set(attributes, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", header.majorVersion] UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", header.minorVersion] UTF8String]);
|
||||
|
||||
xar_subdoc_prop_set(attributes, BEFORE_TREE_SHA1_KEY, [displayHashFromRawHash(header.beforeTreeHash) UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, AFTER_TREE_SHA1_KEY, [displayHashFromRawHash(header.afterTreeHash) UTF8String]);
|
||||
}
|
||||
|
||||
static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTable, xar_t x, NSString *relativePath, NSString *filePath)
|
||||
{
|
||||
NSArray<NSString *> *rootRelativePathComponents = relativePath.pathComponents;
|
||||
// Relative path must at least have starting "/" component and one more path component
|
||||
if (rootRelativePathComponents.count < 2) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSArray<NSString *> *relativePathComponents = [rootRelativePathComponents subarrayWithRange:NSMakeRange(1, rootRelativePathComponents.count - 1)];
|
||||
|
||||
NSUInteger relativePathComponentsCount = relativePathComponents.count;
|
||||
|
||||
// Build parent files as needed until we get to our final file we want to add
|
||||
// So if we get "Contents/Resources/foo.txt", we will first add "Contents" parent,
|
||||
// then "Resources" parent, then "foo.txt" as the final entry we want to add
|
||||
// We store every file we add into a fileTable for easy referencing
|
||||
// Note if a diff has Contents/Resources/foo/ and Contents/Resources/foo/bar.txt,
|
||||
// due to sorting order we will add the foo directory first and won't end up with
|
||||
// mis-ordering bugs
|
||||
xar_file_t lastParent = NULL;
|
||||
for (NSUInteger componentIndex = 0; componentIndex < relativePathComponentsCount; componentIndex++) {
|
||||
NSArray<NSString *> *subpathComponents = [relativePathComponents subarrayWithRange:NSMakeRange(0, componentIndex + 1)];
|
||||
NSString *subpathKey = [subpathComponents componentsJoinedByString:@"/"];
|
||||
|
||||
xar_file_t cachedFile = [fileTable[subpathKey] pointerValue];
|
||||
if (cachedFile != NULL) {
|
||||
lastParent = cachedFile;
|
||||
} else {
|
||||
xar_file_t newParent;
|
||||
|
||||
BOOL atLastIndex = (componentIndex == relativePathComponentsCount - 1);
|
||||
|
||||
NSString *lastPathComponent = subpathComponents.lastObject;
|
||||
if (atLastIndex && filePath != nil) {
|
||||
newParent = xar_add_frompath(x, lastParent, lastPathComponent.fileSystemRepresentation, filePath.fileSystemRepresentation);
|
||||
} else {
|
||||
newParent = xar_add_frombuffer(x, lastParent, lastPathComponent.fileSystemRepresentation, "", 1);
|
||||
}
|
||||
|
||||
lastParent = newParent;
|
||||
fileTable[subpathKey] = [NSValue valueWithPointer:newParent];
|
||||
}
|
||||
}
|
||||
return lastParent;
|
||||
}
|
||||
|
||||
- (void)addItem:(SPUDeltaArchiveItem *)item
|
||||
{
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *relativeFilePath = item.relativeFilePath;
|
||||
NSString *filePath = item.itemFilePath;
|
||||
SPUDeltaItemCommands commands = item.commands;
|
||||
uint16_t mode = item.mode;
|
||||
|
||||
xar_file_t newFile = _xarAddFile(_fileTable, _x, relativeFilePath, filePath);
|
||||
if (newFile == NULL) {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to add xar file entry: %@", relativeFilePath] }];
|
||||
return;
|
||||
}
|
||||
|
||||
if ((commands & SPUDeltaItemCommandDelete) != 0) {
|
||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||
}
|
||||
|
||||
if ((commands & SPUDeltaItemCommandExtract) != 0) {
|
||||
xar_prop_set(newFile, EXTRACT_KEY, "true");
|
||||
}
|
||||
|
||||
if ((commands & SPUDeltaItemCommandBinaryDiff) != 0) {
|
||||
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
|
||||
}
|
||||
|
||||
if ((commands & SPUDeltaItemCommandModifyPermissions) != 0) {
|
||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [NSString stringWithFormat:@"%u", mode].UTF8String);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)finishEncodingItems
|
||||
{
|
||||
// Items are already encoded when they are extracted prior
|
||||
}
|
||||
|
||||
- (void)enumerateItems:(void (^)(SPUDeltaArchiveItem *, BOOL *))itemHandler
|
||||
{
|
||||
if (_error != nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL exitedEarly = NO;
|
||||
xar_iter_t iter = xar_iter_new();
|
||||
for (xar_file_t file = xar_file_first(_x, iter); file; file = xar_file_next(iter)) {
|
||||
char *pathCString;
|
||||
#if HAS_XAR_GET_SAFE_PATH
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
||||
if (xar_get_safe_path != NULL) {
|
||||
pathCString = xar_get_safe_path(file);
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
pathCString = xar_get_path(file);
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
if (pathCString == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *relativePath = [[NSString alloc] initWithBytesNoCopy:pathCString length:strlen(pathCString) encoding:NSUTF8StringEncoding freeWhenDone:YES];
|
||||
if (relativePath == nil) {
|
||||
free(pathCString);
|
||||
continue;
|
||||
}
|
||||
|
||||
SPUDeltaItemCommands commands = 0;
|
||||
{
|
||||
const char *value = NULL;
|
||||
if (xar_prop_get(file, DELETE_KEY, &value) == 0) {
|
||||
commands |= SPUDeltaItemCommandDelete;
|
||||
}
|
||||
}
|
||||
{
|
||||
const char *value = NULL;
|
||||
if (xar_prop_get(file, BINARY_DELTA_KEY, &value) == 0) {
|
||||
commands |= SPUDeltaItemCommandBinaryDiff;
|
||||
}
|
||||
}
|
||||
{
|
||||
const char *value = NULL;
|
||||
if (xar_prop_get(file, EXTRACT_KEY, &value) == 0) {
|
||||
commands |= SPUDeltaItemCommandExtract;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t mode = 0;
|
||||
{
|
||||
const char *value = NULL;
|
||||
if (xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value) == 0) {
|
||||
commands |= SPUDeltaItemCommandModifyPermissions;
|
||||
mode = (uint16_t)[@(value) intValue];
|
||||
}
|
||||
}
|
||||
|
||||
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:relativePath commands:commands mode:mode];
|
||||
item.xarContext = file;
|
||||
|
||||
itemHandler(item, &exitedEarly);
|
||||
if (exitedEarly) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xar_iter_free(iter);
|
||||
}
|
||||
|
||||
- (BOOL)extractItem:(SPUDeltaArchiveItem *)item
|
||||
{
|
||||
if (_error != nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
assert(item.itemFilePath != nil);
|
||||
assert(item.xarContext != NULL);
|
||||
|
||||
xar_file_t file = item.xarContext;
|
||||
if (xar_extract_tofile(_x, file, item.itemFilePath.fileSystemRepresentation) != 0) {
|
||||
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to extract xar file entry to %@", item.itemFilePath] }];
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+313
-132
@@ -8,104 +8,77 @@
|
||||
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
#import "SPUDeltaArchive.h"
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "bspatch.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <xar/xar.h>
|
||||
#import <sys/stat.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
|
||||
static BOOL applyBinaryDeltaToFile(NSString *patchFile, NSString *sourceFilePath, NSString *destinationFilePath)
|
||||
{
|
||||
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
|
||||
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
|
||||
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
|
||||
BOOL success = (bspatch(4, argv) == 0);
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
return success;
|
||||
}
|
||||
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *finalDestination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
|
||||
{
|
||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||
if (!x) {
|
||||
SPUDeltaArchiveHeader *header = nil;
|
||||
id<SPUDeltaArchiveProtocol> archive = SPUDeltaArchiveReadPatchAndHeader(patchFile, &header);
|
||||
if (archive.error != nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to open %@. Giving up.", patchFile] }];
|
||||
*error = archive.error;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||
int minorDiffVersion = 0;
|
||||
progressCallback(0/7.0);
|
||||
|
||||
NSString *expectedBeforeHashv1 = nil;
|
||||
NSString *expectedAfterHashv1 = nil;
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = header.majorVersion;
|
||||
uint16_t minorDiffVersion = header.minorVersion;
|
||||
|
||||
NSString *expectedNewBeforeHash = nil;
|
||||
NSString *expectedNewAfterHash = nil;
|
||||
|
||||
progressCallback(0/6.0);
|
||||
|
||||
xar_subdoc_t subdoc;
|
||||
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
||||
const char *value = 0;
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
minorDiffVersion = [@(value) intValue];
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
|
||||
if (value)
|
||||
expectedNewBeforeHash = @(value);
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
|
||||
if (value)
|
||||
expectedNewAfterHash = @(value);
|
||||
|
||||
// only available in version 1.0
|
||||
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_OLD_KEY, &value);
|
||||
if (value)
|
||||
expectedBeforeHashv1 = @(value);
|
||||
|
||||
// only available in version 1.0
|
||||
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_OLD_KEY, &value);
|
||||
if (value)
|
||||
expectedAfterHashv1 = @(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||
unsigned char *expectedBeforeHash = header.beforeTreeHash;
|
||||
unsigned char *expectedAfterHash = header.afterTreeHash;
|
||||
|
||||
if (majorDiffVersion < SUBinaryDeltaMajorVersionFirst) {
|
||||
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) {
|
||||
|
||||
if (majorDiffVersion < SUBinaryDeltaMajorVersionFirstSupported) {
|
||||
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] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Applying version %u patches is no longer supported.", majorDiffVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
if (majorDiffVersion > SUBinaryDeltaMajorVersionLatest) {
|
||||
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).", SUBinaryDeltaMajorVersionLatest, majorDiffVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Reject patches that did not generate valid hierarchical xar container paths
|
||||
// These will not succeed to patch using recent versions of BinaryDelta
|
||||
if ([[archive class] maySupportSafeExtraction] && majorDiffVersion == SUBinaryDeltaMajorVersion2 && minorDiffVersion < 3) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"This patch version (%u.%u) is too old and potentially unsafe to apply. Please re-generate the patch using the latest version of BinaryDelta or generate_appcast. New version %u.%u patches will still be compatible with older versions of Sparkle.", majorDiffVersion, minorDiffVersion, majorDiffVersion, latestMinorVersionForMajorVersion(majorDiffVersion)] }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
|
||||
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
|
||||
|
||||
if (!expectedBeforeHash || !expectedAfterHash) {
|
||||
if (expectedBeforeHash == nil || expectedAfterHash == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }];
|
||||
}
|
||||
@@ -117,10 +90,10 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
fprintf(stderr, "Verifying source...");
|
||||
}
|
||||
|
||||
progressCallback(1/6.0);
|
||||
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
|
||||
if (!beforeHash) {
|
||||
progressCallback(1/7.0);
|
||||
|
||||
unsigned char beforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeWithVersion(beforeHash, source, majorDiffVersion)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@@ -130,12 +103,12 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![beforeHash isEqualToString:expectedBeforeHash]) {
|
||||
if (memcmp(beforeHash, expectedBeforeHash, CC_SHA1_DIGEST_LENGTH) != 0) {
|
||||
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] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", displayHashFromRawHash(expectedBeforeHash), displayHashFromRawHash(beforeHash)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
@@ -144,7 +117,17 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
fprintf(stderr, "\nCopying files...");
|
||||
}
|
||||
|
||||
progressCallback(2/6.0);
|
||||
progressCallback(2/7.0);
|
||||
|
||||
// Make a temporary destination path if necessary
|
||||
// If we want to apply file system compression after we're done applying, we'll need to use a different
|
||||
// temporary path
|
||||
NSString *destination;
|
||||
if (header.fileSystemCompression) {
|
||||
destination = [finalDestination.stringByDeletingLastPathComponent stringByAppendingPathComponent:[NSString stringWithFormat:@".tmp.%@", finalDestination.lastPathComponent]];
|
||||
} else {
|
||||
destination = finalDestination;
|
||||
}
|
||||
|
||||
if (!removeTree(destination)) {
|
||||
if (verbose) {
|
||||
@@ -156,7 +139,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(3/6.0);
|
||||
progressCallback(3/7.0);
|
||||
|
||||
if (!copyTree(source, destination)) {
|
||||
if (verbose) {
|
||||
@@ -168,130 +151,328 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(4/6.0);
|
||||
|
||||
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
progressCallback(4/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nPatching...");
|
||||
}
|
||||
NSFileManager *fileManager = [[NSFileManager alloc] init];
|
||||
xar_file_t file;
|
||||
xar_iter_t iter = xar_iter_new();
|
||||
for (file = xar_file_first(x, iter); file; file = xar_file_next(iter)) {
|
||||
NSString *path = @(xar_get_path(file));
|
||||
NSString *sourceFilePath = [source stringByAppendingPathComponent:path];
|
||||
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
|
||||
|
||||
// Ensure error is cleared out in advance
|
||||
if (error != NULL) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
[archive enumerateItems:^(SPUDeltaArchiveItem *item, BOOL *stop) {
|
||||
NSString *relativePath = item.relativeFilePath;
|
||||
|
||||
if ([relativePath.pathComponents containsObject:@".."]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path '%@' contains '..' path component", relativePath] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *sourceFilePath = [source stringByAppendingPathComponent:relativePath];
|
||||
NSString *destinationFilePath = [destination stringByAppendingPathComponent:relativePath];
|
||||
{
|
||||
NSString *destinationParentDirectory = destinationFilePath.stringByDeletingLastPathComponent;
|
||||
NSDictionary<NSFileAttributeKey, id> *destinationParentDirectoryAttributes = [fileManager attributesOfItemAtPath:destinationParentDirectory error:NULL];
|
||||
|
||||
// It is OK for the directory parent to not exist if it has already been removed
|
||||
if (destinationParentDirectoryAttributes != nil) {
|
||||
// But if it does exist, make sure the entry in the parent directory we're looking at is good
|
||||
// If it's inside a symlink, this is not good in any circumstance
|
||||
NSString *fileType = destinationParentDirectoryAttributes[NSFileType];
|
||||
if ([fileType isEqualToString:NSFileTypeSymbolicLink]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch because '%@' cannot be a symbolic link.", destinationParentDirectory] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
|
||||
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
|
||||
BOOL removedFile = NO;
|
||||
|
||||
const char *value;
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||
|
||||
// Files that have no property set that we check for will get ignored
|
||||
// This is important because they aren't part of the delta, just part of the directory structure
|
||||
SPUDeltaItemCommands commands = item.commands;
|
||||
if ((commands & SPUDeltaItemCommandDelete) != 0) {
|
||||
if (!removeTree(destinationFilePath)) {
|
||||
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] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"delete: failed to remove %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
||||
}
|
||||
continue;
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
removedFile = YES;
|
||||
}
|
||||
|
||||
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
|
||||
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) {
|
||||
if ((commands & SPUDeltaItemCommandClone) != 0 && (commands & SPUDeltaItemCommandBinaryDiff) == 0) {
|
||||
NSString *clonedRelativePath = item.clonedRelativePath;
|
||||
if ([clonedRelativePath.pathComponents containsObject:@".."]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone '%@' contains '..' path component", clonedRelativePath] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *clonedOriginalPath = [source stringByAppendingPathComponent:clonedRelativePath];
|
||||
|
||||
// Ensure there isn't an item already at our destination
|
||||
[fileManager removeItemAtPath:destinationFilePath error:NULL];
|
||||
|
||||
NSError *copyError = nil;
|
||||
if (![fileManager copyItemAtPath:clonedOriginalPath toPath:destinationFilePath error:©Error]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = copyError;
|
||||
}
|
||||
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n✂️ %s %s -> %s", VERBOSE_CLONED, [clonedRelativePath fileSystemRepresentation], [relativePath fileSystemRepresentation]);
|
||||
}
|
||||
} else if ((commands & SPUDeltaItemCommandBinaryDiff) != 0) {
|
||||
NSString *tempDiffFile = temporaryFilename(@"apply-binary-delta");
|
||||
item.itemFilePath = tempDiffFile;
|
||||
|
||||
if (![archive extractItem:item]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract diffed file to %@", tempDiffFile], NSUnderlyingErrorKey: (NSError * _Nonnull)archive.error }];
|
||||
}
|
||||
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *sourceDiffFilePath;
|
||||
NSString *clonedRelativePath;
|
||||
if ((commands & SPUDeltaItemCommandClone) != 0) {
|
||||
clonedRelativePath = item.clonedRelativePath;
|
||||
if ([clonedRelativePath.pathComponents containsObject:@".."]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone '%@' contains '..' path component", clonedRelativePath] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
sourceDiffFilePath = [source stringByAppendingPathComponent:clonedRelativePath];
|
||||
} else {
|
||||
sourceDiffFilePath = sourceFilePath;
|
||||
clonedRelativePath = nil;
|
||||
}
|
||||
|
||||
// Decide if we need to preserve original file permissions from the original file
|
||||
// applyBinaryDeltaToFile() normally preserves file permissions on the file it's replacing.
|
||||
// However this is not possible if the destination file we're patching is not writable.
|
||||
// We also need to preserve permissions for clones except when we'll be changing permissions later anyway.
|
||||
BOOL needsToCopyFilePermissions;
|
||||
if (![fileManager isWritableFileAtPath:destinationFilePath]) {
|
||||
// Remove the file non-writable we're patching that may cause issues
|
||||
[fileManager removeItemAtPath:destinationFilePath error:NULL];
|
||||
|
||||
// We will need to preserve permissons if there is no need to make permission changes later on
|
||||
needsToCopyFilePermissions = (commands & SPUDeltaItemCommandModifyPermissions) == 0;
|
||||
} else {
|
||||
needsToCopyFilePermissions = ((commands & SPUDeltaItemCommandClone) != 0) && ((commands & SPUDeltaItemCommandModifyPermissions) == 0);
|
||||
}
|
||||
|
||||
if (!applyBinaryDeltaToFile(tempDiffFile, sourceDiffFilePath, destinationFilePath)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to patch %@ to destination %@", sourceFilePath, destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (needsToCopyFilePermissions) {
|
||||
struct stat sourceFileInfo = {0};
|
||||
if (lstat(sourceDiffFilePath.fileSystemRepresentation, &sourceFileInfo) != 0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to retrieve stat info from %@", sourceFilePath] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (chmod(destinationFilePath.fileSystemRepresentation, sourceFileInfo.st_mode) != 0) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%u) on file %@", sourceFileInfo.st_mode, destinationFilePath] }];
|
||||
}
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
|
||||
if ((commands & SPUDeltaItemCommandClone) != 0) {
|
||||
fprintf(stderr, "\n🔨 %s %s -> %s", VERBOSE_PATCHED, [clonedRelativePath fileSystemRepresentation], [relativePath fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [relativePath fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) || (!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) {
|
||||
} else if ((commands & SPUDeltaItemCommandExtract) != 0) { // extract and permission modifications don't coexist
|
||||
item.itemFilePath = destinationFilePath;
|
||||
if (![archive extractItem:item]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath], NSUnderlyingErrorKey: (NSError * _Nonnull)archive.error }];
|
||||
}
|
||||
return NO;
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
if (fileExisted) {
|
||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
|
||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [relativePath fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [path fileSystemRepresentation]);
|
||||
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [relativePath fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
} else if (verbose && removedFile) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [relativePath fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
||||
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
|
||||
if ((commands & SPUDeltaItemCommandModifyPermissions) != 0) {
|
||||
mode_t mode = (mode_t)item.mode;
|
||||
if (!modifyPermissions(destinationFilePath, mode)) {
|
||||
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] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%u) on file %@", mode, destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
|
||||
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [relativePath fileSystemRepresentation], mode & PERMISSION_FLAGS);
|
||||
}
|
||||
}
|
||||
}
|
||||
xar_close(x);
|
||||
|
||||
progressCallback(5/6.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nVerifying destination...");
|
||||
}
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
|
||||
if (!afterHash) {
|
||||
}];
|
||||
|
||||
[archive close];
|
||||
|
||||
// Set error from enumerating items if we have encountered an error and haven't set it yet
|
||||
NSError *archiveError = archive.error;
|
||||
if (archiveError != nil) {
|
||||
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]) {
|
||||
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] }];
|
||||
if (error != NULL && *error == nil) {
|
||||
*error = archiveError;
|
||||
}
|
||||
removeTree(destination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(6/6.0);
|
||||
progressCallback(5/7.0);
|
||||
|
||||
// Re-apply file system compression is requested
|
||||
if (header.fileSystemCompression) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nApplying file system compression...");
|
||||
}
|
||||
|
||||
NSTask *dittoTask = [[NSTask alloc] init];
|
||||
|
||||
dittoTask.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto" isDirectory:NO];
|
||||
dittoTask.arguments = @[@"--hfsCompression", destination, finalDestination];
|
||||
|
||||
// If we fail to apply file system compression, we will try falling back to not doing this
|
||||
BOOL failedToApplyFileSystemCompression = NO;
|
||||
|
||||
NSError *launchError = nil;
|
||||
if (![dittoTask launchAndReturnError:&launchError]) {
|
||||
failedToApplyFileSystemCompression = YES;
|
||||
|
||||
fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", launchError.localizedDescription.UTF8String);
|
||||
}
|
||||
|
||||
if (!failedToApplyFileSystemCompression) {
|
||||
[dittoTask waitUntilExit];
|
||||
|
||||
if (dittoTask.terminationStatus != 0) {
|
||||
failedToApplyFileSystemCompression = YES;
|
||||
|
||||
fprintf(stderr, "\nWarning: ditto task for file compression returned exit status %d", dittoTask.terminationStatus);
|
||||
}
|
||||
}
|
||||
|
||||
if (failedToApplyFileSystemCompression) {
|
||||
// Try to replace bundle normally
|
||||
if (![fileManager replaceItemAtURL:[NSURL fileURLWithPath:finalDestination] withItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] backupItemName:nil options:0 resultingItemURL:NULL error:error]) {
|
||||
removeTree(destination);
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
// Remove original copy
|
||||
[fileManager removeItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
progressCallback(6/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nVerifying destination...");
|
||||
}
|
||||
|
||||
unsigned char afterHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeWithVersion(afterHash, finalDestination, majorDiffVersion)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", finalDestination] }];
|
||||
}
|
||||
removeTree(finalDestination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (memcmp(afterHash, expectedAfterHash, CC_SHA1_DIGEST_LENGTH) != 0) {
|
||||
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.", displayHashFromRawHash(expectedAfterHash), displayHashFromRawHash(afterHash)] }];
|
||||
}
|
||||
removeTree(finalDestination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
progressCallback(7/7.0);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
|
||||
@@ -10,33 +10,19 @@
|
||||
#define SUBINARYDELTACOMMON_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SPUDeltaCompressionMode.h"
|
||||
#include <fts.h>
|
||||
|
||||
#define PERMISSION_FLAGS (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)
|
||||
|
||||
#define IS_VALID_PERMISSIONS(mode) \
|
||||
(((mode & PERMISSION_FLAGS) == 0755) || ((mode & PERMISSION_FLAGS) == 0644))
|
||||
#define VALID_SYMBOLIC_LINK_PERMISSIONS 0755
|
||||
// Enforcing Sparkle's executable permissions to be valid allows us to perform a preflight test before
|
||||
// downloading delta items
|
||||
#define VALID_SPARKLE_EXECUTABLE_PERMISSIONS 0755
|
||||
|
||||
#define APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY "com.apple.cs.CodeDirectory"
|
||||
#define APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY "com.apple.cs.CodeRequirements"
|
||||
#define APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY "com.apple.cs.CodeSignature"
|
||||
|
||||
#define BINARY_DELTA_ATTRIBUTES_KEY "binary-delta-attributes"
|
||||
#define MAJOR_DIFF_VERSION_KEY "major-version"
|
||||
#define MINOR_DIFF_VERSION_KEY "minor-version"
|
||||
#define BEFORE_TREE_SHA1_KEY "before-tree-sha1"
|
||||
#define AFTER_TREE_SHA1_KEY "after-tree-sha1"
|
||||
#define DELETE_KEY "delete"
|
||||
#define EXTRACT_KEY "extract"
|
||||
#define BINARY_DELTA_KEY "binary-delta"
|
||||
#define MODIFY_PERMISSIONS_KEY "mod-permissions"
|
||||
|
||||
// Properties no longer used in new patches
|
||||
#define DELETE_THEN_EXTRACT_OLD_KEY "delete-then-extract"
|
||||
#define BEFORE_TREE_SHA1_OLD_KEY "before-sha1"
|
||||
#define AFTER_TREE_SHA1_OLD_KEY "after-sha1"
|
||||
|
||||
#define VERBOSE_DELETED "Deleted" // file is deleted from the file system when applying a patch
|
||||
#define VERBOSE_REMOVED "Removed" // file is set to be removed when creating a patch
|
||||
#define VERBOSE_ADDED "Added" // file is added to the patch or file system
|
||||
@@ -44,24 +30,41 @@
|
||||
#define VERBOSE_PATCHED "Patched" // file is patched when applying a patch
|
||||
#define VERBOSE_UPDATED "Updated" // file's contents are updated
|
||||
#define VERBOSE_MODIFIED "Modified" // file's metadata is modified
|
||||
#define VERBOSE_CLONED "Cloned" // file is cloned in content from a differently named file
|
||||
|
||||
#define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
|
||||
|
||||
// Each major version will be assigned a name of a color
|
||||
// Relative path of custom icon data that may be set on a bundle via a resource fork
|
||||
#define CUSTOM_ICON_PATH @"/Icon\r"
|
||||
|
||||
// Changes that break backwards compatibility will have different major versions
|
||||
// Changes that affect creating but not applying patches will have different minor versions
|
||||
|
||||
typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
|
||||
{
|
||||
SUAzureMajorVersion = 1,
|
||||
SUBeigeMajorVersion = 2
|
||||
// Note: support for creating or applying version 1 deltas have been removed
|
||||
SUBinaryDeltaMajorVersion1 = 1,
|
||||
SUBinaryDeltaMajorVersion2 = 2,
|
||||
SUBinaryDeltaMajorVersion3 = 3
|
||||
};
|
||||
|
||||
#define FIRST_DELTA_DIFF_MAJOR_VERSION SUAzureMajorVersion
|
||||
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported;
|
||||
|
||||
// Additional compression methods for version 3 patches that we have for debugging are zlib, bzip2, none
|
||||
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma' (best compression, slowest), 'lzfse' (good compression, fast), 'lz4' (worse compression, fastest), and 'default'. Note that version 2 delta files only support 'bzip2', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 delta files is currently lzma."
|
||||
|
||||
//#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
|
||||
|
||||
SPUDeltaCompressionMode deltaCompressionModeFromDescription(NSString *description, BOOL *requestValid);
|
||||
NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode);
|
||||
|
||||
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
||||
extern NSData *hashOfFileContents(FTSENT *ent);
|
||||
BOOL getRawHashOfTreeWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion);
|
||||
BOOL getRawHashOfTreeAndFileTablesWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion, NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *hashToFileKeyDictionary, NSMutableDictionary<NSString *, NSData *> *fileKeyToHashDictionary);
|
||||
NSString *displayHashFromRawHash(const unsigned char *hash);
|
||||
void getRawHashFromDisplayHash(unsigned char *hash, NSString *hexHash);
|
||||
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
|
||||
extern NSString *hashOfTree(NSString *path);
|
||||
extern BOOL removeTree(NSString *path);
|
||||
@@ -71,5 +74,5 @@ extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
|
||||
NSString *temporaryFilename(NSString *base);
|
||||
NSString *temporaryDirectory(NSString *base);
|
||||
NSString *stringWithFileSystemRepresentation(const char*);
|
||||
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
|
||||
uint16_t latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
|
||||
#endif
|
||||
@@ -16,13 +16,81 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <xar/xar.h>
|
||||
#include <xlocale.h>
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
// Note: the framework bundle version must be bumped, and generate_appcast must be updated to compare it,
|
||||
// when we add/change new major versions and defaults. Unit tests need to be updated to use new versions too.
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault = SUBinaryDeltaMajorVersion3;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest = SUBinaryDeltaMajorVersion3;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst = SUBinaryDeltaMajorVersion1;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported = SUBinaryDeltaMajorVersion2;
|
||||
|
||||
SPUDeltaCompressionMode deltaCompressionModeFromDescription(NSString *requestedDescription, BOOL *requestValid)
|
||||
{
|
||||
// Set to NO later if request was not valid
|
||||
if (requestValid != NULL) {
|
||||
*requestValid = YES;
|
||||
}
|
||||
|
||||
SPUDeltaCompressionMode compression;
|
||||
NSString *description = requestedDescription.lowercaseString;
|
||||
|
||||
if ([description isEqualToString:@"default"]) {
|
||||
compression = SPUDeltaCompressionModeDefault;
|
||||
} else if ([description isEqualToString:@"none"]) {
|
||||
compression = SPUDeltaCompressionModeNone;
|
||||
} else if ([description isEqualToString:@"bzip2"]) {
|
||||
compression = SPUDeltaCompressionModeBzip2;
|
||||
} else if ([description isEqualToString:@"lzma"]) {
|
||||
compression = SPUDeltaCompressionModeLZMA;
|
||||
} else if ([description isEqualToString:@"lzfse"]) {
|
||||
compression = SPUDeltaCompressionModeLZFSE;
|
||||
} else if ([description isEqualToString:@"lz4"]) {
|
||||
compression = SPUDeltaCompressionModeLZ4;
|
||||
} else if ([description isEqualToString:@"zlib"]) {
|
||||
compression = SPUDeltaCompressionModeZLIB;
|
||||
} else {
|
||||
compression = SPUDeltaCompressionModeDefault;
|
||||
|
||||
if (requestValid != NULL) {
|
||||
*requestValid = NO;
|
||||
}
|
||||
}
|
||||
|
||||
return compression;
|
||||
}
|
||||
|
||||
NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case SPUDeltaCompressionModeBzip2:
|
||||
return @"bzip2";
|
||||
case SPUDeltaCompressionModeLZMA:
|
||||
return @"LZMA";
|
||||
case SPUDeltaCompressionModeNone:
|
||||
return @"no";
|
||||
case SPUDeltaCompressionModeLZ4:
|
||||
return @"LZ4";
|
||||
case SPUDeltaCompressionModeLZFSE:
|
||||
return @"LZFSE";
|
||||
case SPUDeltaCompressionModeZLIB:
|
||||
return @"ZLIB";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode == SPUDeltaCompressionModeDefault) {
|
||||
return @"default";
|
||||
}
|
||||
|
||||
return @"unknown";
|
||||
}
|
||||
|
||||
int compareFiles(const FTSENT **a, const FTSENT **b)
|
||||
{
|
||||
return strcoll((*a)->fts_name, (*b)->fts_name);
|
||||
return strcoll_l((*a)->fts_name, (*b)->fts_name, _c_locale);
|
||||
}
|
||||
|
||||
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
|
||||
@@ -39,13 +107,15 @@ NSString *stringWithFileSystemRepresentation(const char *input)
|
||||
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
|
||||
}
|
||||
|
||||
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
||||
uint16_t latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
||||
{
|
||||
switch (majorVersion) {
|
||||
case SUAzureMajorVersion:
|
||||
return 1;
|
||||
case SUBeigeMajorVersion:
|
||||
case SUBinaryDeltaMajorVersion1:
|
||||
return 2;
|
||||
case SUBinaryDeltaMajorVersion2:
|
||||
return 4;
|
||||
case SUBinaryDeltaMajorVersion3:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -96,7 +166,7 @@ static void _hashOfBuffer(unsigned char *hash, const char *buffer, ssize_t buffe
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
}
|
||||
|
||||
static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
|
||||
static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent, void *tempBuffer, size_t tempBufferSize)
|
||||
{
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
char linkDestination[MAXPATHLEN + 1];
|
||||
@@ -108,27 +178,37 @@ static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
|
||||
|
||||
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
|
||||
} else if (ent->fts_info == FTS_F) {
|
||||
int fileDescriptor = open(ent->fts_path, O_RDONLY);
|
||||
if (fileDescriptor == -1) {
|
||||
perror("open");
|
||||
return NO;
|
||||
}
|
||||
|
||||
ssize_t fileSize = ent->fts_statp->st_size;
|
||||
if (fileSize == 0) {
|
||||
if (fileSize <= 0) {
|
||||
_hashOfBuffer(hash, NULL, 0);
|
||||
} else {
|
||||
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
||||
if (buffer == (void *)-1) {
|
||||
close(fileDescriptor);
|
||||
perror("mmap");
|
||||
FILE *file = fopen(ent->fts_path, "rb");
|
||||
if (file == NULL) {
|
||||
perror("fopen");
|
||||
return NO;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, buffer, fileSize);
|
||||
munmap(buffer, (size_t)fileSize);
|
||||
|
||||
CC_SHA1_CTX hashContext;
|
||||
CC_SHA1_Init(&hashContext);
|
||||
|
||||
size_t bytesLeft = (size_t)fileSize;
|
||||
while (bytesLeft > 0) {
|
||||
size_t bytesToConsume = (bytesLeft >= tempBufferSize) ? tempBufferSize : bytesLeft;
|
||||
|
||||
if (fread(tempBuffer, bytesToConsume, 1, file) < 1) {
|
||||
perror("fread");
|
||||
fclose(file);
|
||||
return NO;
|
||||
}
|
||||
|
||||
CC_SHA1_Update(&hashContext, tempBuffer, (CC_LONG)bytesToConsume);
|
||||
bytesLeft -= bytesToConsume;
|
||||
}
|
||||
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
close(fileDescriptor);
|
||||
} else if (ent->fts_info == FTS_D) {
|
||||
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
|
||||
} else {
|
||||
@@ -137,27 +217,31 @@ static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSData *hashOfFileContents(FTSENT *ent)
|
||||
BOOL getRawHashOfTreeWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion)
|
||||
{
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
if (!_hashOfFileContents(fileHash, ent)) {
|
||||
return nil;
|
||||
}
|
||||
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
|
||||
return getRawHashOfTreeAndFileTablesWithVersion(hashBuffer, path, majorVersion, nil, nil);
|
||||
}
|
||||
|
||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
BOOL getRawHashOfTreeAndFileTablesWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t __unused majorVersion, NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *hashToFileKeyDictionary, NSMutableDictionary<NSString *, NSData *> *fileKeyToHashDictionary)
|
||||
{
|
||||
char pathBuffer[PATH_MAX] = { 0 };
|
||||
if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
return nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
const size_t tempBufferSize = 16384;
|
||||
void *tempBuffer = calloc(1, tempBufferSize);
|
||||
if (tempBuffer == NULL) {
|
||||
perror("calloc");
|
||||
return NO;
|
||||
}
|
||||
|
||||
char *const sourcePaths[] = { pathBuffer, 0 };
|
||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return nil;
|
||||
free(tempBuffer);
|
||||
return NO;
|
||||
}
|
||||
|
||||
CC_SHA1_CTX hashContext;
|
||||
@@ -171,48 +255,97 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
|
||||
continue;
|
||||
|
||||
if (ent->fts_info == FTS_D && !MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
|
||||
// Ignore icon resource fork data
|
||||
if (relativePath.length == 0 || [relativePath isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (relativePath.length == 0)
|
||||
continue;
|
||||
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
if (!_hashOfFileContents(fileHash, ent)) {
|
||||
return nil;
|
||||
if (!_hashOfFileContents(fileHash, ent, tempBuffer, tempBufferSize)) {
|
||||
fts_close(fts);
|
||||
free(tempBuffer);
|
||||
return NO;
|
||||
}
|
||||
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
|
||||
|
||||
// For file hash tables we only track regular files
|
||||
if (ent->fts_info == FTS_F) {
|
||||
NSData *hashKey = [NSData dataWithBytes:fileHash length:sizeof(fileHash)];
|
||||
|
||||
if (hashToFileKeyDictionary != nil) {
|
||||
if (hashToFileKeyDictionary[hashKey] == nil) {
|
||||
hashToFileKeyDictionary[hashKey] = [NSMutableArray array];
|
||||
}
|
||||
[hashToFileKeyDictionary[hashKey] addObject:relativePath];
|
||||
}
|
||||
|
||||
if (fileKeyToHashDictionary != nil) {
|
||||
fileKeyToHashDictionary[relativePath] = hashKey;
|
||||
}
|
||||
}
|
||||
|
||||
const char *relativePathBytes = [relativePath fileSystemRepresentation];
|
||||
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
|
||||
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
uint16_t mode = ent->fts_statp->st_mode;
|
||||
uint16_t type = ent->fts_info;
|
||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||
uint16_t mode = ent->fts_statp->st_mode;
|
||||
uint16_t type = ent->fts_info;
|
||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||
|
||||
// permission of symlinks are 0777 on some linux file systems and can't be changed,
|
||||
// differing from the 0755 macOS default.
|
||||
// hardcoding a value helps avoid differences between filesystems.
|
||||
uint16_t hashedPermissions = (ent->fts_info == FTS_SL) ? VALID_SYMBOLIC_LINK_PERMISSIONS : permissions;
|
||||
|
||||
CC_SHA1_Update(&hashContext, &type, sizeof(type));
|
||||
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
|
||||
}
|
||||
CC_SHA1_Update(&hashContext, &type, sizeof(type));
|
||||
CC_SHA1_Update(&hashContext, &hashedPermissions, sizeof(hashedPermissions));
|
||||
}
|
||||
|
||||
free(tempBuffer);
|
||||
|
||||
fts_close(fts);
|
||||
|
||||
unsigned char hash[CC_SHA1_DIGEST_LENGTH];
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
CC_SHA1_Final(hashBuffer, &hashContext);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1];
|
||||
size_t i;
|
||||
for (i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
|
||||
sprintf(hexHash + i * 2, "%02x", hash[i]);
|
||||
void getRawHashFromDisplayHash(unsigned char *hash, NSString *hexHash)
|
||||
{
|
||||
const char *hexString = hexHash.UTF8String;
|
||||
if (hexString == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t blockIndex = 0; blockIndex < CC_SHA1_DIGEST_LENGTH; blockIndex++) {
|
||||
const char *currentBlock = hexString + blockIndex * 2;
|
||||
char convertedBlock[3] = {currentBlock[0], currentBlock[1], '\0'};
|
||||
hash[blockIndex] = (unsigned char)strtol(convertedBlock, NULL, 16);
|
||||
}
|
||||
}
|
||||
|
||||
NSString *displayHashFromRawHash(const unsigned char *hash)
|
||||
{
|
||||
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1] = {0};
|
||||
for (size_t i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
|
||||
snprintf(hexHash + i * 2, 3, "%02x", hash[i]);
|
||||
}
|
||||
return @(hexHash);
|
||||
}
|
||||
|
||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
{
|
||||
unsigned char hash[CC_SHA1_DIGEST_LENGTH];
|
||||
if (!getRawHashOfTreeWithVersion(hash, path, majorVersion)) {
|
||||
return nil;
|
||||
}
|
||||
return displayHashFromRawHash(hash);
|
||||
}
|
||||
|
||||
extern NSString *hashOfTree(NSString *path)
|
||||
{
|
||||
return hashOfTreeWithVersion(path, LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||
return hashOfTreeWithVersion(path, SUBinaryDeltaMajorVersionLatest);
|
||||
}
|
||||
|
||||
BOOL removeTree(NSString *path)
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
#define SUBINARYDELTACREATE_H
|
||||
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
|
||||
@class NSString;
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error);
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, SPUDeltaCompressionMode compression, uint8_t compressionLevel, BOOL verbose, NSError * __autoreleasing *error);
|
||||
|
||||
#endif
|
||||
+552
-128
@@ -9,6 +9,9 @@
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
#import "SPUSparkleDeltaArchive.h"
|
||||
#import "SPUXarDeltaArchive.h"
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
@@ -19,38 +22,54 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/xattr.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
extern int bsdiff(int argc, const char **argv);
|
||||
|
||||
@interface CreateBinaryDeltaOperation : NSOperation
|
||||
@property (copy) NSString *relativePath;
|
||||
@property (strong) NSString *resultPath;
|
||||
@property (strong) NSNumber *oldPermissions;
|
||||
@property (strong) NSNumber *permissions;
|
||||
@property (strong) NSString *_fromPath;
|
||||
@property (strong) NSString *_toPath;
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relativePath;
|
||||
@property (nonatomic, copy, readonly) NSString *clonedRelativePath;
|
||||
@property (nonatomic, readonly) NSString *resultPath;
|
||||
@property (nonatomic, readonly) NSNumber *oldPermissions;
|
||||
@property (nonatomic, readonly) NSNumber *permissions;
|
||||
@property (nonatomic, readonly) NSString *fromPath;
|
||||
@property (nonatomic, readonly) BOOL changingPermissions;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath clonedRelativePath:(NSString *)clonedRelativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions changingPermissions:(BOOL)changingPermissions SPU_OBJC_DIRECT;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CreateBinaryDeltaOperation
|
||||
{
|
||||
NSString *_toPath;
|
||||
}
|
||||
|
||||
@synthesize relativePath = _relativePath;
|
||||
@synthesize clonedRelativePath = _clonedRelativePath;
|
||||
@synthesize resultPath = _resultPath;
|
||||
@synthesize oldPermissions = _oldPermissions;
|
||||
@synthesize permissions = _permissions;
|
||||
@synthesize _fromPath = _fromPath;
|
||||
@synthesize _toPath = _toPath;
|
||||
@synthesize fromPath = _fromPath;
|
||||
@synthesize changingPermissions = _changingPermissions;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions
|
||||
- (id)initWithRelativePath:(NSString *)relativePath clonedRelativePath:(NSString *)clonedRelativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions changingPermissions:(BOOL)changingPermissions
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.relativePath = relativePath;
|
||||
self.oldPermissions = oldPermissions;
|
||||
self.permissions = permissions;
|
||||
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
_relativePath = [relativePath copy];
|
||||
_clonedRelativePath = [clonedRelativePath copy];
|
||||
_oldPermissions = oldPermissions;
|
||||
_permissions = permissions;
|
||||
_changingPermissions = changingPermissions;
|
||||
|
||||
if (clonedRelativePath == nil) {
|
||||
_fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
} else {
|
||||
_fromPath = [oldTree stringByAppendingPathComponent:clonedRelativePath];
|
||||
}
|
||||
_toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -58,47 +77,37 @@ extern int bsdiff(int argc, const char **argv);
|
||||
- (void)main
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = { "/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
|
||||
const char *argv[] = { "/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
self.resultPath = temporaryFile;
|
||||
if (result == 0) {
|
||||
_resultPath = temporaryFile;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#define INFO_HASH_KEY @"hash"
|
||||
#define INFO_PATH_KEY @"path"
|
||||
#define INFO_TYPE_KEY @"type"
|
||||
#define INFO_PERMISSIONS_KEY @"permissions"
|
||||
#define INFO_SIZE_KEY @"size"
|
||||
|
||||
static NSDictionary *infoForFile(FTSENT *ent)
|
||||
{
|
||||
NSData *hash = hashOfFileContents(ent);
|
||||
if (!hash) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
|
||||
|
||||
assert(ent->fts_statp != NULL);
|
||||
|
||||
mode_t permissions = ent->fts_statp->st_mode & PERMISSION_FLAGS;
|
||||
|
||||
return @{ INFO_HASH_KEY: hash,
|
||||
NSString *path = @(ent->fts_path);
|
||||
assert(path != nil);
|
||||
|
||||
return @{ INFO_PATH_KEY: path != nil ? path : @"",
|
||||
INFO_TYPE_KEY: @(ent->fts_info),
|
||||
INFO_PERMISSIONS_KEY: @(permissions),
|
||||
INFO_SIZE_KEY: @(size) };
|
||||
}
|
||||
|
||||
static bool isSymLink(const FTSENT *ent)
|
||||
{
|
||||
if (ent->fts_info == FTS_SL)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool aclExists(const FTSENT *ent)
|
||||
{
|
||||
// macOS does not currently support ACLs for symlinks
|
||||
@@ -174,12 +183,18 @@ static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
unsigned short originalInfoType = [(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
unsigned short newInfoType = [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
if (originalInfoType != newInfoType || originalInfoType != FTS_F) {
|
||||
// File types are different or they're not regular files
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([(NSData *)originalInfo[INFO_HASH_KEY] isEqual:(NSData *)newInfo[INFO_HASH_KEY]]) {
|
||||
// this is possible if just the permissions have changed
|
||||
NSString *originalPath = originalInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = newInfo[INFO_PATH_KEY];
|
||||
|
||||
// Skip delta if the files are equal in content
|
||||
if ([[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -205,11 +220,21 @@ static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newIn
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
unsigned short originalInfoType = [(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
unsigned short newInfoType = [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
|
||||
if (originalInfoType != newInfoType) {
|
||||
// File types are different
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![(NSData *)originalInfo[INFO_HASH_KEY] isEqual:(NSData *)newInfo[INFO_HASH_KEY]]) {
|
||||
|
||||
NSString *originalPath = originalInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = newInfo[INFO_PATH_KEY];
|
||||
|
||||
// Don't skip extract if files/symlinks entries are not equal in content
|
||||
// (note if the entries are directories, they are equal)
|
||||
if (originalInfoType != FTS_D && ![[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -221,26 +246,171 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne
|
||||
if (!originalInfo) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
unsigned short originalInfoType = [(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
unsigned short newInfoType = [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue];
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
if (originalInfoType != newInfoType) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
unsigned short oldPermissions = [(NSNumber *)originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
unsigned short newPermissions = [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
|
||||
if ([(NSNumber *)originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
|
||||
if (oldPermissions == newPermissions) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We don't track new permissions on symbolic links that aren't the 0755 macOS default
|
||||
// Some linux / remotely mounted filesystems may not track permissions on symlinks and use 0777
|
||||
// We don't want to pick up bad permissions
|
||||
if (newInfoType == FTS_SL && newPermissions != VALID_SYMBOLIC_LINK_PERMISSIONS) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError *__autoreleasing *error)
|
||||
#define MIN_SIZE_FOR_CLONE 4096
|
||||
#define MIN_SIZE_FOR_CLONE_DIFF (4096 * 4)
|
||||
static NSString *cloneableRelativePath(NSDictionary<NSString *, NSData *> *afterFileKeyToHashDictionary, NSDictionary<NSData *, NSArray<NSString *> *> *beforeHashToFileKeyDictionary, NSDictionary<NSString *, NSString *> *frameworkVersionsSubstitutes, NSDictionary<NSString *, NSString *> *fileSubstitutes, NSDictionary *originalTreeState, NSDictionary *newInfo, NSString *key, NSNumber * __autoreleasing *outNewPermissions, BOOL *clonePermissionsChanged, BOOL *clonedBinaryDiff)
|
||||
{
|
||||
// Avoid clones for small files. Small files can compress very well, sometimes better than tracking clones.
|
||||
if ([(NSNumber *)newInfo[INFO_SIZE_KEY] unsignedLongLongValue] <= MIN_SIZE_FOR_CLONE) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue] != FTS_F) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
{
|
||||
NSData *keyHash = afterFileKeyToHashDictionary[key];
|
||||
if (keyHash != nil) {
|
||||
// Check for identical clones first
|
||||
for (NSString *oldRelativePath in beforeHashToFileKeyDictionary[keyHash]) {
|
||||
NSDictionary *oldCloneInfo = originalTreeState[oldRelativePath];
|
||||
if (oldCloneInfo == nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([(NSNumber *)oldCloneInfo[INFO_TYPE_KEY] unsignedShortValue] != FTS_F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *clonePath = oldCloneInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = newInfo[INFO_PATH_KEY];
|
||||
|
||||
if (![[NSFileManager defaultManager] contentsEqualAtPath:clonePath andPath:newPath]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSNumber *newPermissions = newInfo[INFO_PERMISSIONS_KEY];
|
||||
if (outNewPermissions != NULL) {
|
||||
*outNewPermissions = newPermissions;
|
||||
}
|
||||
|
||||
if (clonePermissionsChanged != NULL) {
|
||||
*clonePermissionsChanged = ([(NSNumber *)oldCloneInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] != [newPermissions unsignedShortValue]);
|
||||
}
|
||||
|
||||
if (clonedBinaryDiff != NULL) {
|
||||
*clonedBinaryDiff = NO;
|
||||
}
|
||||
|
||||
return oldRelativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For non-identical files where we do a binary diff, make sure file size matches a more strict file size test
|
||||
if ([(NSNumber *)newInfo[INFO_SIZE_KEY] unsignedLongLongValue] <= MIN_SIZE_FOR_CLONE_DIFF) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Look out for any .framework/Versions/{A -> B} changes
|
||||
for (NSString *frameworkVersionPrefix in frameworkVersionsSubstitutes) {
|
||||
if (![key hasPrefix:frameworkVersionPrefix]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *cloneFrameworkSubstitutePrefix = frameworkVersionsSubstitutes[frameworkVersionPrefix];
|
||||
if (cloneFrameworkSubstitutePrefix == nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *cloneRelativeKey = [key stringByReplacingCharactersInRange:NSMakeRange(0, frameworkVersionPrefix.length) withString:cloneFrameworkSubstitutePrefix];
|
||||
|
||||
NSDictionary *oldCloneInfo = originalTreeState[cloneRelativeKey];
|
||||
if (oldCloneInfo == nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSNumber *newPermissions = newInfo[INFO_PERMISSIONS_KEY];
|
||||
if (outNewPermissions != NULL) {
|
||||
*outNewPermissions = newPermissions;
|
||||
}
|
||||
|
||||
if (clonePermissionsChanged != NULL) {
|
||||
*clonePermissionsChanged = ([(NSNumber *)oldCloneInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] != [newPermissions unsignedShortValue]);
|
||||
}
|
||||
|
||||
if (clonedBinaryDiff != NULL) {
|
||||
*clonedBinaryDiff = YES;
|
||||
}
|
||||
|
||||
return cloneRelativeKey;
|
||||
}
|
||||
|
||||
// Look out for any changes that involve the same named file moving to another directory
|
||||
do {
|
||||
NSString *cloneRelativeKey = fileSubstitutes[key.lastPathComponent];
|
||||
if (cloneRelativeKey == nil) {
|
||||
break;
|
||||
}
|
||||
|
||||
NSDictionary *oldCloneInfo = originalTreeState[cloneRelativeKey];
|
||||
if (oldCloneInfo == nil) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t cloneSize = [(NSNumber *)oldCloneInfo[INFO_SIZE_KEY] unsignedLongValue];
|
||||
uint64_t newSize = [(NSNumber *)newInfo[INFO_SIZE_KEY] unsignedLongValue];
|
||||
uint64_t minSize = MIN(cloneSize, newSize);
|
||||
uint64_t maxSize = MAX(cloneSize, newSize);
|
||||
|
||||
// Ensure file is at least 60% the same size
|
||||
if (minSize == 0 || maxSize == 0 || (double)minSize / (double)maxSize < 0.60) {
|
||||
break;
|
||||
}
|
||||
|
||||
NSNumber *newPermissions = newInfo[INFO_PERMISSIONS_KEY];
|
||||
if (outNewPermissions != NULL) {
|
||||
*outNewPermissions = newPermissions;
|
||||
}
|
||||
|
||||
if (clonePermissionsChanged != NULL) {
|
||||
*clonePermissionsChanged = ([(NSNumber *)oldCloneInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] != [newPermissions unsignedShortValue]);
|
||||
}
|
||||
|
||||
if (clonedBinaryDiff != NULL) {
|
||||
*clonedBinaryDiff = YES;
|
||||
}
|
||||
|
||||
return cloneRelativeKey;
|
||||
} while (NO);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, SPUDeltaCompressionMode compression, uint8_t compressionLevel, BOOL verbose, NSError *__autoreleasing *error)
|
||||
{
|
||||
assert(source);
|
||||
assert(destination);
|
||||
assert(patchFile);
|
||||
assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||
assert(majorVersion >= SUBinaryDeltaMajorVersionFirst && majorVersion <= SUBinaryDeltaMajorVersionLatest);
|
||||
|
||||
int minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
||||
uint16_t minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
||||
|
||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||
|
||||
@@ -262,7 +432,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
||||
fprintf(stderr, "Creating version %u.%u patch using %s compression...\n", majorVersion, minorVersion, deltaCompressionStringFromMode(compression).UTF8String);
|
||||
fprintf(stderr, "Processing source, %s...", [source fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
@@ -276,6 +446,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([key isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing bundles with a custom icon set via a resource fork is not supported. Detected presence of %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
@@ -289,6 +469,20 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
originalTreeState[key] = info;
|
||||
|
||||
// Ensure Sparkle executable permissions are valid
|
||||
if (ent->fts_info == FTS_F && [key.lastPathComponent isEqualToString:@"Sparkle"] && [key.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"Sparkle.framework"]) {
|
||||
mode_t permissions = (mode_t)[(NSNumber *)info[INFO_PERMISSIONS_KEY] shortValue];
|
||||
if (permissions != VALID_SPARKLE_EXECUTABLE_PERMISSIONS) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Permissions for Sparkle executable must be 0%o (found 0%o) on file %@", VALID_SPARKLE_EXECUTABLE_PERMISSIONS, permissions, @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (aclExists(ent)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -311,9 +505,11 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
|
||||
|
||||
if (!beforeHash) {
|
||||
// This dictionary will help us keep track of clones
|
||||
NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *beforeHashToFileKeyDictionary = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) ? [NSMutableDictionary dictionary] : nil;
|
||||
|
||||
unsigned char beforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeAndFileTablesWithVersion(beforeHash, source, majorVersion, beforeHashToFileKeyDictionary, nil)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@@ -351,7 +547,11 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
bool foundFilesystemCompression = false;
|
||||
|
||||
uint32_t warningsCount = 0;
|
||||
const uint32_t maxWarningsToPrint = 16;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||
continue;
|
||||
@@ -361,6 +561,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ([key isEqualToString:CUSTOM_ICON_PATH]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing bundles with a custom icon set via a resource fork is not supported. Detected presence of %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
@@ -373,23 +583,24 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs,
|
||||
// or in the case of permissions if the patch version is 1
|
||||
|
||||
// Ensure Sparkle executable permissions are valid
|
||||
if (ent->fts_info == FTS_F && [key.lastPathComponent isEqualToString:@"Sparkle"] && [key.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.stringByDeletingLastPathComponent.lastPathComponent isEqualToString:@"Sparkle.framework"]) {
|
||||
mode_t permissions = (mode_t)[(NSNumber *)info[INFO_PERMISSIONS_KEY] shortValue];
|
||||
if (permissions != VALID_SPARKLE_EXECUTABLE_PERMISSIONS) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Permissions for Sparkle executable must be 0%o (found 0%o) on file %@", VALID_SPARKLE_EXECUTABLE_PERMISSIONS, permissions, @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// We should validate ACLs even if we don't store the info in the diff in the case of ACLs
|
||||
// We should also not allow files with code signed extended attributes since Apple doesn't recommend inserting these
|
||||
// inside an application, and since we don't preserve extended attribitutes anyway
|
||||
|
||||
mode_t permissions = [(NSNumber*)info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
|
||||
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)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
@@ -409,10 +620,50 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (warningsCount < maxWarningsToPrint) {
|
||||
uint16_t permissions = (ent->fts_statp->st_mode & PERMISSION_FLAGS);
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
if (permissions != VALID_SYMBOLIC_LINK_PERMISSIONS) {
|
||||
fprintf(stderr, "\nWarning: file permissions 0%o of symbolic link '%s' won't be preserved in the delta update (only permissions with mode 0755 are supported for symbolic links).", permissions, ent->fts_path);
|
||||
|
||||
warningsCount++;
|
||||
}
|
||||
} else if (permissions != 0755 && permissions != 0644) {
|
||||
// This could indicate something is wrong inside of the bundle so it's worth warning the user about
|
||||
fprintf(stderr, "\nWarning: detected irregular file permissions 0%o for '%s'", permissions, ent->fts_path);
|
||||
|
||||
warningsCount++;
|
||||
}
|
||||
|
||||
if (warningsCount == maxWarningsToPrint) {
|
||||
fprintf(stderr, "\nWarning: encountered too many warnings.. Ignoring the rest..");
|
||||
}
|
||||
}
|
||||
|
||||
// If we find any executable files that are using file system compression, that is sufficient
|
||||
// for recording that the applier should re-apply file system compression.
|
||||
// We check for executable files because they are likely candidates to be compressed.
|
||||
if (!foundFilesystemCompression && MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) && ent->fts_info == FTS_F && (ent->fts_statp->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0 && (ent->fts_statp->st_flags & UF_COMPRESSED) != 0) {
|
||||
foundFilesystemCompression = true;
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, " File system compression detected.");
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
|
||||
if ([info isEqual:oldInfo]) {
|
||||
BOOL hasEqualInfo;
|
||||
if (![info isEqual:oldInfo]) {
|
||||
hasEqualInfo = NO;
|
||||
} else {
|
||||
NSString *originalPath = oldInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = info[INFO_PATH_KEY];
|
||||
hasEqualInfo = [[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath];
|
||||
}
|
||||
|
||||
if (hasEqualInfo) {
|
||||
[newTreeState removeObjectForKey:key];
|
||||
} else {
|
||||
newTreeState[key] = info;
|
||||
@@ -432,8 +683,11 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
|
||||
if (!afterHash) {
|
||||
// This dictionary will help us keep track of clones
|
||||
NSMutableDictionary<NSString *, NSData *> *afterFileKeyToHashDictionary = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) ? [NSMutableDictionary dictionary] : nil;
|
||||
|
||||
unsigned char afterHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
if (!getRawHashOfTreeAndFileTablesWithVersion(afterHash, destination, majorVersion, nil, afterFileKeyToHashDictionary)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@@ -451,31 +705,37 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nWriting to temporary file %s...", [temporaryFile fileSystemRepresentation]);
|
||||
}
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
if (!x) {
|
||||
|
||||
id<SPUDeltaArchiveProtocol> archive;
|
||||
if (majorVersion >= SUBinaryDeltaMajorVersion3) {
|
||||
archive = [[SPUSparkleDeltaArchive alloc] initWithPatchFileForWriting:temporaryFile];
|
||||
} else {
|
||||
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
|
||||
archive = [[SPUXarDeltaArchive alloc] initWithPatchFileForWriting:temporaryFile];
|
||||
#else
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write to %@", temporaryFile] }];
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: @"Support for creating legacy delta updates is disabled" }];
|
||||
}
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
SPUDeltaArchiveHeader *header = [[SPUDeltaArchiveHeader alloc] initWithCompression:compression compressionLevel:compressionLevel fileSystemCompression:foundFilesystemCompression majorVersion:majorVersion minorVersion:minorVersion beforeTreeHash:beforeHash afterTreeHash:afterHash];
|
||||
|
||||
[archive writeHeader:header];
|
||||
if (archive.error != nil) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = archive.error;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
|
||||
|
||||
xar_subdoc_prop_set(attributes, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", majorVersion] UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", minorVersion] UTF8String]);
|
||||
|
||||
// Version 1 patches don't have a major or minor version field, so we need to differentiate between the hash keys
|
||||
const char *beforeHashKey = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? BEFORE_TREE_SHA1_KEY : BEFORE_TREE_SHA1_OLD_KEY;
|
||||
const char *afterHashKey = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? AFTER_TREE_SHA1_KEY : AFTER_TREE_SHA1_OLD_KEY;
|
||||
|
||||
xar_subdoc_prop_set(attributes, beforeHashKey, [beforeHash UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, afterHashKey, [afterHash UTF8String]);
|
||||
|
||||
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
|
||||
NSMutableArray *deltaOperations = [NSMutableArray array];
|
||||
|
||||
@@ -489,13 +749,105 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
|
||||
}];
|
||||
|
||||
// Using a couple of heursitics we track if files have been moved to other locations within the app bundle
|
||||
NSMutableDictionary<NSString *, NSString *> *frameworkVersionsSubstitutes = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary<NSString *, NSString *> *fileSubstitutes = [NSMutableDictionary dictionary];
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3)) {
|
||||
// Heuristic #1: track if an old framework version was removed and a new framework version was added
|
||||
// Keep track of these prefixes in a dictionary
|
||||
// Eg: /Contents/Frameworks/Foo.framework/Versions/B/ (new) -> /Contents/Frameworks/Foo.framework/Versions/A/ (old)
|
||||
|
||||
NSMutableDictionary<NSString *, NSString *> *oldFrameworkVersions = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
if (![(NSObject *)value isEqual:[NSNull null]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *originalInfo = originalTreeState[key];
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *keyWithoutLastPathComponent = key.stringByDeletingLastPathComponent;
|
||||
|
||||
if (![keyWithoutLastPathComponent.lastPathComponent isEqualToString:@"Versions"]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *keyWithoutLastLastPathComponent = keyWithoutLastPathComponent.stringByDeletingLastPathComponent;
|
||||
|
||||
if (![keyWithoutLastLastPathComponent.pathExtension isEqualToString:@"framework"]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
oldFrameworkVersions[keyWithoutLastLastPathComponent] = key;
|
||||
}
|
||||
|
||||
for (NSString *key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
if ([(NSObject *)value isEqual:[NSNull null]] || originalTreeState[key] != nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *newInfo = value;
|
||||
if ([(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *keyWithoutLastPathComponent = key.stringByDeletingLastPathComponent;
|
||||
|
||||
if (![keyWithoutLastPathComponent.lastPathComponent isEqualToString:@"Versions"]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *keyWithoutLastLastPathComponent = keyWithoutLastPathComponent.stringByDeletingLastPathComponent;
|
||||
|
||||
if (![keyWithoutLastLastPathComponent.pathExtension isEqualToString:@"framework"]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *oldFrameworkVersionKey = oldFrameworkVersions[keyWithoutLastLastPathComponent];
|
||||
if (oldFrameworkVersionKey == nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
frameworkVersionsSubstitutes[[key stringByAppendingString:@"/"]] = [oldFrameworkVersionKey stringByAppendingString:@"/"];
|
||||
}
|
||||
|
||||
// Heuristic #2: Keep a table of removed filenames, collapsing them by the largest file per unique name
|
||||
// This sees if a file has just been moved to another location
|
||||
for (NSString *key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
if (![(NSObject *)value isEqual:[NSNull null]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *keyInfo = originalTreeState[key];
|
||||
if ([(NSNumber *)keyInfo[INFO_TYPE_KEY] unsignedShortValue] != FTS_F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *lastPathComponent = key.lastPathComponent;
|
||||
|
||||
NSString *existingKey = fileSubstitutes[lastPathComponent];
|
||||
if (existingKey == nil) {
|
||||
fileSubstitutes[lastPathComponent] = key;
|
||||
} else {
|
||||
NSDictionary *existingKeyInfo = originalTreeState[existingKey];
|
||||
if ([(NSNumber *)keyInfo[INFO_SIZE_KEY] unsignedLongValue] > [(NSNumber *)existingKeyInfo[INFO_SIZE_KEY] unsignedLongValue]) {
|
||||
fileSubstitutes[lastPathComponent] = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (NSString *key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
|
||||
if ([(NSObject *)value isEqual:[NSNull null]]) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||
[archive addItem:[[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:key commands:SPUDeltaItemCommandDelete mode:0]];
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
|
||||
@@ -506,47 +858,73 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
NSDictionary *originalInfo = originalTreeState[key];
|
||||
NSDictionary *newInfo = newTreeState[key];
|
||||
if (shouldSkipDeltaCompression(originalInfo, newInfo)) {
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && shouldSkipExtracting(originalInfo, newInfo)) {
|
||||
if (shouldSkipExtracting(originalInfo, newInfo)) {
|
||||
if (shouldChangePermissions(originalInfo, newInfo)) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
|
||||
[archive addItem:[[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:key commands:SPUDeltaItemCommandModifyPermissions mode:[(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]]];
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [(NSNumber *)originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [(NSNumber *)newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NSString *path = [destination stringByAppendingPathComponent:key];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||
// Check if the new file can be cloned from an old existing one located at a different path
|
||||
NSNumber *newPermissions = nil;
|
||||
BOOL clonePermissionsChanged = NO;
|
||||
BOOL clonedBinaryDiff = NO;
|
||||
NSString *clonedRelativePath = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) ? cloneableRelativePath(afterFileKeyToHashDictionary, beforeHashToFileKeyDictionary, frameworkVersionsSubstitutes, fileSubstitutes, originalTreeState, newInfo, key, &newPermissions, &clonePermissionsChanged, &clonedBinaryDiff) : nil;
|
||||
if (clonedRelativePath != nil) {
|
||||
if (clonedBinaryDiff) {
|
||||
NSDictionary *cloneInfo = originalTreeState[clonedRelativePath];
|
||||
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key clonedRelativePath:clonedRelativePath oldTree:source newTree:destination oldPermissions:cloneInfo[INFO_PERMISSIONS_KEY] newPermissions:newPermissions changingPermissions:clonePermissionsChanged];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
} else {
|
||||
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
|
||||
SPUDeltaItemCommands commands = SPUDeltaItemCommandClone;
|
||||
if (clonePermissionsChanged) {
|
||||
commands |= SPUDeltaItemCommandModifyPermissions;
|
||||
}
|
||||
|
||||
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:key commands:commands mode:(clonePermissionsChanged ? newPermissions.unsignedShortValue : 0)];
|
||||
// Physical path for clones points to the old file
|
||||
item.itemFilePath = [source stringByAppendingPathComponent:clonedRelativePath];
|
||||
item.sourcePath = item.itemFilePath;
|
||||
item.clonedRelativePath = clonedRelativePath;
|
||||
|
||||
[archive addItem:item];
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n✂️ %s %s -> %s", VERBOSE_CLONED, [clonedRelativePath fileSystemRepresentation], [key fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Otherwise add a new file
|
||||
NSString *path = [destination stringByAppendingPathComponent:key];
|
||||
|
||||
SPUDeltaItemCommands commands = SPUDeltaItemCommandExtract;
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||
commands |= SPUDeltaItemCommandDelete;
|
||||
}
|
||||
|
||||
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:key commands:commands mode:0];
|
||||
item.itemFilePath = path;
|
||||
item.sourcePath = path;
|
||||
|
||||
[archive addItem:item];
|
||||
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
xar_prop_set(newFile, EXTRACT_KEY, "true");
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
if (originalInfo) {
|
||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [key fileSystemRepresentation]);
|
||||
if (verbose) {
|
||||
if (originalInfo) {
|
||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [key fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NSNumber *permissions =
|
||||
(MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && shouldChangePermissions(originalInfo, newInfo)) ?
|
||||
newInfo[INFO_PERMISSIONS_KEY] :
|
||||
nil;
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:source newTree:destination oldPermissions:originalInfo[INFO_PERMISSIONS_KEY] newPermissions:permissions];
|
||||
NSNumber *permissions = newInfo[INFO_PERMISSIONS_KEY];
|
||||
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key clonedRelativePath:nil oldTree:source newTree:destination oldPermissions:originalInfo[INFO_PERMISSIONS_KEY] newPermissions:permissions changingPermissions:shouldChangePermissions(originalInfo, newInfo)];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
}
|
||||
@@ -554,37 +932,83 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
[deltaQueue waitUntilAllOperationsAreFinished];
|
||||
|
||||
BOOL deltaOperationsFailed = NO;
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
if (!resultPath) {
|
||||
NSString *resultPath = operation.resultPath;
|
||||
if (resultPath == nil) {
|
||||
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;
|
||||
deltaOperationsFailed = YES;
|
||||
break;
|
||||
}
|
||||
|
||||
NSString *clonedRelativePath = [operation clonedRelativePath];
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
||||
if (clonedRelativePath == nil) {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n🔨 %s %s -> %s", VERBOSE_DIFFED, [clonedRelativePath fileSystemRepresentation], [[operation relativePath] fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
|
||||
NSNumber *mode = operation.permissions;
|
||||
NSString *relativePath = operation.relativePath;
|
||||
|
||||
SPUDeltaItemCommands commands = SPUDeltaItemCommandBinaryDiff;
|
||||
if (operation.changingPermissions) {
|
||||
commands |= SPUDeltaItemCommandModifyPermissions;
|
||||
}
|
||||
if (clonedRelativePath != nil) {
|
||||
commands |= SPUDeltaItemCommandClone;
|
||||
}
|
||||
|
||||
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:relativePath commands:commands mode:mode.unsignedShortValue];
|
||||
item.itemFilePath = resultPath;
|
||||
item.sourcePath = operation.fromPath;
|
||||
item.clonedRelativePath = clonedRelativePath;
|
||||
|
||||
[archive addItem:item];
|
||||
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
|
||||
unlink([resultPath fileSystemRepresentation]);
|
||||
|
||||
if (operation.permissions) {
|
||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
|
||||
|
||||
if (operation.changingPermissions) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
|
||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, relativePath.fileSystemRepresentation, operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xar_close(x);
|
||||
|
||||
if (!deltaOperationsFailed) {
|
||||
[archive finishEncodingItems];
|
||||
}
|
||||
|
||||
[archive close];
|
||||
|
||||
// Clean up operations after the archive has finished encoding
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = operation.resultPath;
|
||||
if (resultPath != nil) {
|
||||
unlink(resultPath.fileSystemRepresentation);
|
||||
}
|
||||
}
|
||||
|
||||
if (deltaOperationsFailed) {
|
||||
// We already set an error so let's bail
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *archiveError = archive.error;
|
||||
if (archiveError != nil) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = archiveError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSFileManager *filemgr;
|
||||
filemgr = [NSFileManager defaultManager];
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
//
|
||||
// SUBinaryDeltaTool.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mark Rowe on 2009-06-01.
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#include "SUBinaryDeltaApply.h"
|
||||
#include "SUBinaryDeltaCreate.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
#define VERBOSE_FLAG @"--verbose"
|
||||
#define VERSION_FLAG @"--version"
|
||||
|
||||
#define CREATE_COMMAND @"create"
|
||||
#define APPLY_COMMAND @"apply"
|
||||
#define VERSION_COMMAND @"version"
|
||||
#define VERSION_ALTERNATE_COMMAND @"--version"
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
static void printUsage(NSString *programName)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, "%s create [--verbose] [--version=<version>] <before-tree> <after-tree> <patch-file>\n", [programName UTF8String]);
|
||||
fprintf(stderr, "%s apply [--verbose] <before-tree> <after-tree> <patch-file>\n", [programName UTF8String]);
|
||||
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
||||
}
|
||||
|
||||
static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 5) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUInteger numberOflagsFound = 0;
|
||||
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
||||
NSUInteger versionIndex = NSNotFound;
|
||||
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
|
||||
if ([args[argumentIndex] hasPrefix:VERSION_FLAG]) {
|
||||
versionIndex = argumentIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (verboseIndex != NSNotFound) {
|
||||
++numberOflagsFound;
|
||||
}
|
||||
if (versionIndex != NSNotFound) {
|
||||
++numberOflagsFound;
|
||||
}
|
||||
|
||||
if (args.count - numberOflagsFound < 3) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL verbose = (verboseIndex != NSNotFound);
|
||||
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
||||
|
||||
NSArray *versionComponents = nil;
|
||||
if (versionField) {
|
||||
versionComponents = [versionField componentsSeparatedByString:@"="];
|
||||
if (versionComponents.count != 2) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion patchVersion =
|
||||
!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) {
|
||||
if (![argument hasPrefix:VERSION_FLAG] && ![argument isEqualToString:VERBOSE_FLAG]) {
|
||||
[fileArgs addObject:argument];
|
||||
}
|
||||
}
|
||||
|
||||
if (fileArgs.count != 3) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *sourcePath = fileArgs[0];
|
||||
NSString *destPath = fileArgs[1];
|
||||
NSString *patchPath = fileArgs[2];
|
||||
|
||||
BOOL isDirectory;
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:sourcePath isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: before-tree must be a directory\n");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:destPath isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: after-tree must be a directory\n");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *createDiffError = nil;
|
||||
if (!createBinaryDelta(sourcePath, destPath, patchPath, patchVersion, verbose, &createDiffError)) {
|
||||
fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count < 3 || args.count > 4) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL verbose = [args containsObject:VERBOSE_FLAG];
|
||||
|
||||
if (args.count == 4 && !verbose) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||
for (NSString *argument in args) {
|
||||
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
||||
[fileArgs addObject:argument];
|
||||
}
|
||||
}
|
||||
|
||||
if (fileArgs.count != 3) {
|
||||
printUsage(programName);
|
||||
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 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 NO;
|
||||
}
|
||||
|
||||
NSError *applyDiffError = nil;
|
||||
if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, ^(__unused double x){}, &applyDiffError)) {
|
||||
fprintf(stderr, "%s\n", [applyDiffError.localizedDescription UTF8String]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
if (args.count > 1) {
|
||||
printUsage(programName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (args.count == 0) {
|
||||
fprintf(stdout, "%u.%u\n", LATEST_DELTA_DIFF_MAJOR_VERSION, latestMinorVersionForMajorVersion(LATEST_DELTA_DIFF_MAJOR_VERSION));
|
||||
} else {
|
||||
NSString *patchFile = args[0];
|
||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||
if (!x) {
|
||||
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||
int minorDiffVersion = 0;
|
||||
|
||||
xar_subdoc_t subdoc;
|
||||
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
||||
const char *value = 0;
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
minorDiffVersion = [@(value) intValue];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
int main(int __unused argc, char __unused *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||
NSString *programName = [args[0] lastPathComponent];
|
||||
|
||||
if (args.count < 2) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
NSString *command = args[1];
|
||||
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
||||
|
||||
BOOL result;
|
||||
if ([command isEqualToString:CREATE_COMMAND]) {
|
||||
result = runCreateCommand(programName, commandArguments);
|
||||
} else if ([command isEqualToString:APPLY_COMMAND]) {
|
||||
result = runApplyCommand(programName, commandArguments);
|
||||
} else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) {
|
||||
result = runVersionCommand(programName, commandArguments);
|
||||
} else {
|
||||
result = NO;
|
||||
printUsage(programName);
|
||||
}
|
||||
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,15 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT_MEMBERS
|
||||
#endif
|
||||
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -16,17 +16,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUBinaryDeltaUnarchiver
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize updateHostBundlePath = _updateHostBundlePath;
|
||||
{
|
||||
NSString *_archivePath;
|
||||
NSString *_updateHostBundlePath;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -43,7 +37,11 @@
|
||||
// We used to invoke mdimport on the bundle but this is not a very good approach.
|
||||
// There's no need to do that for non-delta updates and for updates that contain no mdimporters.
|
||||
// Moreover, updating the timestamp on the mdimporter bundles is what developers have to do anyway when shipping their new update outside of Sparkle
|
||||
// Note: this is used from unit tests
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT
|
||||
#endif
|
||||
{
|
||||
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
@@ -95,17 +93,17 @@
|
||||
|
||||
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
{
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
NSString *sourcePath = _updateHostBundlePath;
|
||||
NSString *targetPath = [[_archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, _archivePath, NO, ^(double progress){
|
||||
[notifier notifyProgress:progress];
|
||||
|
||||
}, &applyDiffError);
|
||||
|
||||
if (success) {
|
||||
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||
[SUBinaryDeltaUnarchiver updateSpotlightImportersAtBundlePath:targetPath];
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
else {
|
||||
@@ -113,6 +111,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
@@ -11,9 +11,18 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef BUILDING_SPARKLE_TESTS
|
||||
SPU_OBJC_DIRECT_MEMBERS
|
||||
#endif
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError **)error;
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError **)error;
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL checkNestedCode:(BOOL)checkNestedCode error:(NSError **)error;
|
||||
|
||||
// Same as above except does not check for nested code. This method should be used by the framework.
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error;
|
||||
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL;
|
||||
@end
|
||||
|
||||
|
||||
@@ -10,65 +10,112 @@
|
||||
#include <Security/SecCode.h>
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError * __autoreleasing *)error
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecStaticCodeRef oldCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Bundle is not code signed: %@", newBundleURL] }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
NSString *message = [NSString stringWithFormat:@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result];
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
NSString *message = [NSString stringWithFormat:@"Failed to get static code %d", result];
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// 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
|
||||
// Aditionally, there are several reasons to stay away from deep verification and to prefer DSA signing the download archive instead.
|
||||
// Aditionally, there are several reasons to stay away from deep verification and to prefer EdDSA 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(SULogLevelError, @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
if (result != errSecSuccess) {
|
||||
NSError *underlyingError;
|
||||
if (cfError != NULL) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
underlyingError = tmpError;
|
||||
} else {
|
||||
underlyingError = nil;
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
if (underlyingError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
if (result == errSecCSUnsigned) {
|
||||
NSString *message = @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else if (result == errSecCSReqFailed) {
|
||||
CFStringRef requirementString = nil;
|
||||
NSString *initialMessage;
|
||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
||||
SULog(SULogLevelError, @"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
initialMessage = [NSString stringWithFormat:@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString];
|
||||
|
||||
SULog(SULogLevelError, @"%@", initialMessage);
|
||||
CFRelease(requirementString);
|
||||
} else {
|
||||
initialMessage = @"Code signature of new version doesn't match the old version. Please ensure that old and new app is signed using exactly the same certificate.";
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
NSDictionary *oldInfo = [self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"%@ old info: %@. new info: %@", initialMessage, oldInfo, newInfo];
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = @"Error: Old app bundle code signing signature failed to match new bundle code signature";
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,35 +127,76 @@ finally:
|
||||
}
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
return [self codeSignatureIsValidAtBundleURL:bundleURL checkNestedCode:NO error:error];
|
||||
}
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL checkNestedCode:(BOOL)checkNestedCode error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to get static code for verifying code signature: %d", result] }];
|
||||
}
|
||||
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not passed
|
||||
// See in -codeSignatureIsValidAtBundleURL:andMatchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not always passed
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
if (checkNestedCode) {
|
||||
flags |= kSecCSCheckNestedCode;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(SULogLevelError, @"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
if (result != errSecSuccess) {
|
||||
NSError *underlyingError;
|
||||
if (cfError != NULL) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
underlyingError = tmpError;
|
||||
} else {
|
||||
underlyingError = nil;
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
if (underlyingError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
if (result == errSecCSUnsigned) {
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app is not signed using Apple Code Signing. %@", bundleURL];
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else if (result == errSecCSReqFailed) {
|
||||
if (error != NULL) {
|
||||
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@ - new info: %@", bundleURL, newInfo];
|
||||
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@", bundleURL];
|
||||
|
||||
userInfo[NSLocalizedDescriptionKey] = message;
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,22 +209,8 @@ static id valueOrNSNull(id value) {
|
||||
return value ? value : [NSNull null];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath {
|
||||
NSDictionary *info = nil;
|
||||
SecStaticCodeRef code = NULL;
|
||||
OSStatus result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundlePath, kSecCSDefaultFlags, &code);
|
||||
if (result != noErr) {
|
||||
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
info = [self codeSignatureInfoForCode:code];
|
||||
|
||||
finally:
|
||||
if (code) CFRelease(code);
|
||||
return info;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code {
|
||||
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code SPU_OBJC_DIRECT
|
||||
{
|
||||
CFDictionaryRef signingInfo = nil;
|
||||
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||
@@ -153,9 +227,11 @@ finally:
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
+ (NSDictionary *)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label SPU_OBJC_DIRECT
|
||||
{
|
||||
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
|
||||
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
||||
return relevantInfo;
|
||||
}
|
||||
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
#ifndef SUDISKIMAGEUNARCHIVER_H
|
||||
#define SUDISKIMAGEUNARCHIVER_H
|
||||
|
||||
@@ -14,12 +16,16 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SULog.h"
|
||||
@@ -13,17 +15,11 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUDiskImageUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUDiskImageUnarchiver
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
{
|
||||
NSString *_archivePath;
|
||||
NSString *_decryptionPassword;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -54,7 +50,7 @@
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT
|
||||
{
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
@@ -62,8 +58,8 @@
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
NSFileManager *manager;
|
||||
NSError *error;
|
||||
NSArray *contents;
|
||||
NSError *error = nil;
|
||||
NSArray *contents = nil;
|
||||
do
|
||||
{
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
@@ -82,13 +78,12 @@
|
||||
// Note: this check does not follow symbolic links, which is what we want
|
||||
while ([[NSURL fileURLWithPath:mountPoint] checkResourceIsReachableAndReturnError:NULL]);
|
||||
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
NSData *promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
NSMutableArray *arguments = [@[@"attach", _archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
|
||||
if (self.decryptionPassword) {
|
||||
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
if (_decryptionPassword) {
|
||||
NSMutableData *passwordData = [[_decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
// From the hdiutil docs:
|
||||
// read a null-terminated passphrase from standard input
|
||||
//
|
||||
@@ -102,7 +97,7 @@
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
|
||||
{
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = @"/usr/bin/hdiutil";
|
||||
@@ -115,23 +110,51 @@
|
||||
task.standardInput = inputPipe;
|
||||
task.standardOutput = outputPipe;
|
||||
|
||||
[task launch];
|
||||
NSFileHandle *fileStdHandle = outputPipe.fileHandleForReading;
|
||||
NSMutableData *currentOutput = [NSMutableData data];
|
||||
|
||||
fileStdHandle.readabilityHandler = ^(NSFileHandle *file) {
|
||||
[currentOutput appendData:file.availableData];
|
||||
};
|
||||
|
||||
dispatch_semaphore_t terminationSemaphore = dispatch_semaphore_create(0);
|
||||
task.terminationHandler = ^(NSTask *__unused terminatingTask) {
|
||||
fileStdHandle.readabilityHandler = nil;
|
||||
|
||||
dispatch_semaphore_signal(terminationSemaphore);
|
||||
};
|
||||
|
||||
if (![task launchAndReturnError:&error]) {
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
[notifier notifyProgress:0.125];
|
||||
|
||||
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||
|
||||
if (@available(macOS 10.15, *)) {
|
||||
if (![inputPipe.fileHandleForWriting writeData:promptData error:&error]) {
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
@try {
|
||||
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||
} @catch (NSException *) {
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[inputPipe.fileHandleForWriting closeFile];
|
||||
|
||||
// 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];
|
||||
dispatch_semaphore_wait(terminationSemaphore, DISPATCH_TIME_FOREVER);
|
||||
output = [currentOutput copy];
|
||||
|
||||
[task waitUntilExit];
|
||||
taskResult = task.terminationStatus;
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
[notifier notifyProgress:0.5];
|
||||
|
||||
@@ -146,27 +169,27 @@
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
manager = [[NSFileManager alloc] init];
|
||||
contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
if (error)
|
||||
if (contents == nil)
|
||||
{
|
||||
SULog(SULogLevelError, @"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
double itemsCopied = 0;
|
||||
double totalItems = [contents count];
|
||||
double totalItems = (double)[contents count];
|
||||
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
NSString *toPath = [[_archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
itemsCopied += 1.0;
|
||||
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||
|
||||
// We skip any files in the DMG which are not readable but include the item in the progress
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
@@ -190,18 +213,19 @@
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
task.standardError = [NSPipe pipe];
|
||||
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *exception) {
|
||||
NSError *launchCleanupError = nil;
|
||||
if (![task launchAndReturnError:&launchCleanupError]) {
|
||||
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
|
||||
SULog(SULogLevelError, @"Exception: %@", exception);
|
||||
SULog(SULogLevelError, @"Error: %@", launchCleanupError);
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"Can't mount DMG %@", self.archivePath);
|
||||
SULog(SULogLevelError, @"Can't mount DMG %@", _archivePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// SUFlatPackageUnarchiver.h
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUnarchiverProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// An unarchiver for flat packages that doesn't really do any unarchiving
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath expectingInstallationType:(NSString *)installationType;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// SUFlatPackageUnarchiver.m
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import "SUFlatPackageUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUFlatPackageUnarchiver
|
||||
{
|
||||
NSString *_flatPackagePath;
|
||||
NSString *_expectedInstallationType;
|
||||
}
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [path.pathExtension isEqualToString:@"pkg"] || [path.pathExtension isEqualToString:@"mpkg"];
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath expectingInstallationType:(NSString *)installationType
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_flatPackagePath = [flatPackagePath copy];
|
||||
_expectedInstallationType = [installationType copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
|
||||
|
||||
// Flat packages must use guided package installs, not interactive
|
||||
BOOL isDirectory = NO;
|
||||
if (![_expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not have guided installation type but %@ instead", _expectedInstallationType]}]];
|
||||
} else if (![[NSFileManager defaultManager] fileExistsAtPath:_flatPackagePath isDirectory:&isDirectory] || isDirectory) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", _flatPackagePath]}]];
|
||||
} else {
|
||||
[notifier notifyProgress:1.0];
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _flatPackagePath]; }
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
/*!
|
||||
/**
|
||||
# Sparkle Guided Installations
|
||||
|
||||
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
|
||||
@@ -16,11 +16,15 @@ The installer package is installed using macOS's built-in command line installer
|
||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
||||
*/
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerProtocol.h"
|
||||
|
||||
@interface SUGuidedPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUGuidedPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath;
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,31 +6,29 @@
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <sys/stat.h>
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUGuidedPackageInstaller ()
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *packagePath;
|
||||
@property (nonatomic, readonly, copy) NSString *installationPath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUGuidedPackageInstaller
|
||||
{
|
||||
NSString *_packagePath;
|
||||
NSString *_homeDirectory;
|
||||
NSString *_userName;
|
||||
}
|
||||
|
||||
@synthesize packagePath = _packagePath;
|
||||
@synthesize installationPath = _installationPath;
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_packagePath = [packagePath copy];
|
||||
_installationPath = [installationPath copy];
|
||||
_homeDirectory = [homeDirectory copy];
|
||||
_userName = [userName copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -47,27 +45,41 @@
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = installerPath;
|
||||
task.arguments = @[@"-pkg", self.packagePath, @"-target", @"/"];
|
||||
task.standardError = [NSPipe pipe];
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
task.arguments = @[@"-pkg", _packagePath, @"-target", @"/"];
|
||||
// Set the $HOME and $USER variables so pre/post install scripts reference the correct user environment
|
||||
task.environment = @{@"HOME": _homeDirectory, @"USER": _userName};
|
||||
task.standardError = nil;
|
||||
task.standardOutput = nil;
|
||||
|
||||
BOOL success = YES;
|
||||
@try {
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
if (task.terminationStatus != EXIT_SUCCESS) {
|
||||
success = NO;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer returned non-zero exit status (%d)", task.terminationStatus] }];
|
||||
}
|
||||
}
|
||||
} @catch (NSException *) {
|
||||
success = NO;
|
||||
NSError *launchError = nil;
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer task threw an exception"] }];
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];
|
||||
|
||||
if (launchError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = launchError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return success;
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
if (task.terminationStatus != EXIT_SUCCESS) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer returned non-zero exit status (%d)", task.terminationStatus] }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)performCleanup
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
@@ -76,3 +88,5 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -13,11 +13,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUHost;
|
||||
|
||||
@interface SUInstaller : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUInstaller : NSObject
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError **)error;
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError **)error;
|
||||
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr;
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr
|
||||
#endif
|
||||
;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+46
-23
@@ -13,15 +13,16 @@
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SUNormalization.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path SPU_OBJC_DIRECT
|
||||
{
|
||||
NSNumber *aliasFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
|
||||
@@ -30,7 +31,10 @@
|
||||
return aliasFlag.boolValue && directoryFlag.boolValue;
|
||||
}
|
||||
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
#endif
|
||||
{
|
||||
NSParameterAssert(inUpdateFolder);
|
||||
NSParameterAssert(host);
|
||||
@@ -40,23 +44,31 @@
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
NSString *fallbackPackagePath = nil;
|
||||
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = YES;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
#endif
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
||||
|
||||
while ((currentFile = [dirEnum nextObject])) {
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
NSString *currentFilename = [currentFile lastPathComponent];
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
NSString *currentExtension = [currentFile pathExtension];
|
||||
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
|
||||
#endif
|
||||
if ([currentFilename isEqualToString:bundleFileName] ||
|
||||
[currentFilename isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage = NO;
|
||||
#endif
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
} else if ([currentExtension isEqualToString:@"pkg"] ||
|
||||
[currentExtension isEqualToString:@"mpkg"]) {
|
||||
if ([currentFilenameNoExtension isEqualToString:bundleFileNameNoExtension]) {
|
||||
@@ -67,12 +79,15 @@
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
|
||||
if (incomingBundle && [incomingBundle.bundleIdentifier isEqualToString:hostBundleIdentifier]) {
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage = NO;
|
||||
#endif
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
@@ -83,6 +98,7 @@
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil) {
|
||||
@@ -104,18 +120,33 @@
|
||||
*isPackagePtr = isPackage;
|
||||
if (isGuidedPtr)
|
||||
*isGuidedPtr = isGuided;
|
||||
|
||||
#endif
|
||||
|
||||
if (!newAppDownloadPath) {
|
||||
SULog(SULogLevelError, @"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
|
||||
SULog(SULogLevelError, @"Searched %@ for %@.(app%@)", inUpdateFolder, bundleFileNameNoExtension,
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
@"|pkg"
|
||||
#else
|
||||
@""
|
||||
#endif
|
||||
);
|
||||
}
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError * __autoreleasing *)error
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host isPackage:&isPackage isGuided:&isGuided];
|
||||
#endif
|
||||
|
||||
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
isPackage:&isPackage isGuided:&isGuided
|
||||
#endif
|
||||
];
|
||||
|
||||
if (newDownloadPath == nil) {
|
||||
if (error != NULL) {
|
||||
@@ -128,13 +159,14 @@
|
||||
// We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine
|
||||
// ahead of time whether or not this installer tool should be ran as root or not
|
||||
id <SUInstallerProtocol> installer = nil;
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
if (isPackage && isGuided) {
|
||||
if (![expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found guided package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SPUInstallationTypeGuidedPackage] }];
|
||||
}
|
||||
} else {
|
||||
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath installationPath:host.bundlePath];
|
||||
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath homeDirectory:homeDirectory userName:userName];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
if (![expectedInstallationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
@@ -142,9 +174,11 @@
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SPUInstallationTypeInteractivePackage] }];
|
||||
}
|
||||
} else {
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath installationPath:host.bundlePath];
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (![expectedInstallationType isEqualToString:SPUInstallationTypeApplication]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found regular application update but expected '%@=%@' from the appcast item enclosure instead", SUAppcastAttributeInstallationType, expectedInstallationType] }];
|
||||
@@ -152,11 +186,12 @@
|
||||
} else {
|
||||
NSString *normalizedInstallationPath = nil;
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||
normalizedInstallationPath = [self normalizedInstallationPathForHost:host];
|
||||
normalizedInstallationPath = SUNormalizedInstallationPath(host);
|
||||
}
|
||||
|
||||
// If we have a normalized path, 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.
|
||||
// Otherwise if there's no normalized path (the more likely case), we'll just use the host bundle's path
|
||||
// Check progress agent app which computes normalized path too according to these rules
|
||||
NSString *installationPath;
|
||||
if (normalizedInstallationPath != nil && ![[NSFileManager defaultManager] fileExistsAtPath:normalizedInstallationPath]) {
|
||||
installationPath = normalizedInstallationPath;
|
||||
@@ -171,16 +206,4 @@
|
||||
return installer;
|
||||
}
|
||||
|
||||
+ (NSString *)normalizedInstallationPathForHost:(SUHost *)host
|
||||
{
|
||||
NSBundle *bundle = host.bundle;
|
||||
assert(bundle != nil);
|
||||
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]];
|
||||
|
||||
// Roundtrip string through fileSystemRepresentation to ensure it uses filesystem's Unicode normalization
|
||||
// rather than arbitrary Unicode form from Info.plist - #1017
|
||||
return [NSString stringWithUTF8String:[normalizedAppPath fileSystemRepresentation]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -22,14 +22,17 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Should be able to be called from non-main thread
|
||||
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))cb error:(NSError **)error;
|
||||
|
||||
// Any clean up work can be done here
|
||||
// This is work that may be performed after the user application may have been updated / relaunched,
|
||||
// or after an error occurred in the previous stages.
|
||||
// Should be able to be called from any thread
|
||||
- (void)performCleanup;
|
||||
|
||||
// Indicates whether or not this installer can install the update silently in the background, without hindering the user
|
||||
// If this returns NO, then the installation can fail if the user did not directly request for the install to occur.
|
||||
// Should be thread safe
|
||||
- (BOOL)canInstallSilently;
|
||||
|
||||
// The destination and installation path of the bundle being updated
|
||||
- (NSString *)installationPath;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -6,14 +6,18 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerProtocol.h"
|
||||
|
||||
// This is the deprecated package installation type, aka the "interactive" package installer
|
||||
// For a more supported package installation, see SUGuidedPackageInstaller
|
||||
|
||||
@interface SUPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPackageInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath;
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -6,34 +6,28 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
|
||||
#import "SUPackageInstaller.h"
|
||||
#import "SUConstants.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SULog.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPackageInstaller ()
|
||||
|
||||
@property (nonatomic, readonly, copy) NSString *packagePath;
|
||||
@property (nonatomic, readonly, copy) NSString *installationPath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPackageInstaller
|
||||
{
|
||||
NSString *_packagePath;
|
||||
}
|
||||
|
||||
static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
|
||||
@synthesize packagePath = _packagePath;
|
||||
@synthesize installationPath = _installationPath;
|
||||
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath
|
||||
- (instancetype)initWithPackagePath:(NSString *)packagePath
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_packagePath = [packagePath copy];
|
||||
_installationPath = [installationPath copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -55,7 +49,7 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
// -W = wait until the app has quit.
|
||||
// -n = Open another instance if already open.
|
||||
// -b = app bundle identifier
|
||||
NSArray *args = @[@"-W", @"-n", @"-b", @"com.apple.installer", self.packagePath];
|
||||
NSArray *args = @[@"-W", @"-n", @"-b", @"com.apple.installer", _packagePath];
|
||||
|
||||
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||
@try {
|
||||
@@ -73,9 +67,15 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)performCleanup
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -14,10 +14,12 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
+139
-55
@@ -9,22 +9,17 @@
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SULog.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPipedUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPipedUnarchiver
|
||||
{
|
||||
NSString *_archivePath;
|
||||
}
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
|
||||
+ (nullable NSArray <NSString *> *)commandAndArgumentsConformingToTypeOfPath:(NSString *)path
|
||||
static NSArray <NSString *> * _Nullable _commandAndArgumentsConformingToTypeOfPath(NSString *path)
|
||||
{
|
||||
NSArray <NSString *> *extractTGZ = @[@"/usr/bin/tar", @"-zxC"];
|
||||
NSArray <NSString *> *extractTBZ = @[@"/usr/bin/tar", @"-jxC"];
|
||||
@@ -55,7 +50,7 @@
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
|
||||
return _commandAndArgumentsConformingToTypeOfPath(path) != nil;
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
@@ -74,7 +69,7 @@
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
NSArray <NSString *> *commandAndArguments = [[self class] commandAndArgumentsConformingToTypeOfPath:self.archivePath];
|
||||
NSArray <NSString *> *commandAndArguments = _commandAndArgumentsConformingToTypeOfPath(_archivePath);
|
||||
assert(commandAndArguments != nil);
|
||||
|
||||
NSString *command = commandAndArguments.firstObject;
|
||||
@@ -89,67 +84,156 @@
|
||||
}
|
||||
|
||||
// This method abstracts the types that use a command line tool piping data from stdin.
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier
|
||||
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
@autoreleasepool {
|
||||
NSError *error = nil;
|
||||
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
|
||||
NSString *destination = [_archivePath stringByDeletingLastPathComponent];
|
||||
|
||||
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
|
||||
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], _archivePath, destination);
|
||||
|
||||
// Get the file size.
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil];
|
||||
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:_archivePath error:nil];
|
||||
NSUInteger expectedLength = [(NSNumber *)[attributes objectForKey:NSFileSize] unsignedIntegerValue];
|
||||
if (expectedLength > 0) {
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:self.archivePath];
|
||||
|
||||
if (expectedLength == 0) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", _archivePath]}];
|
||||
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
|
||||
[notifier notifyFailureWithError:error];
|
||||
return;
|
||||
}
|
||||
|
||||
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:_archivePath];
|
||||
|
||||
NSPipe *pipe = [NSPipe pipe];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
[task setStandardInput:pipe];
|
||||
[task setStandardError:[NSFileHandle fileHandleWithStandardError]];
|
||||
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
|
||||
[task setLaunchPath:command];
|
||||
[task setArguments:[args arrayByAddingObject:destination]];
|
||||
|
||||
NSError *launchError = nil;
|
||||
if (![task launchAndReturnError:&launchError]) {
|
||||
[notifier notifyFailureWithError:launchError];
|
||||
return;
|
||||
}
|
||||
|
||||
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
|
||||
NSUInteger bytesWritten = 0;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
BOOL hasIOErrorMethods;
|
||||
if (@available(macOS 10.15, *)) {
|
||||
hasIOErrorMethods = YES;
|
||||
} else {
|
||||
hasIOErrorMethods = NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
do {
|
||||
NSData *data;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
if (!hasIOErrorMethods) {
|
||||
@try {
|
||||
data = [archiveInput readDataOfLength:256*1024];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to read data from archive with exception reason %@", exception.reason);
|
||||
data = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NSError *readError = nil;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
data = [archiveInput readDataUpToLength:256*1024 error:&readError];
|
||||
#pragma clang diagnostic pop
|
||||
if (data == nil) {
|
||||
SULog(SULogLevelError, @"Failed to read data from archive with error %@", readError);
|
||||
}
|
||||
}
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
[task setStandardInput:[pipe fileHandleForReading]];
|
||||
[task setStandardError:[NSFileHandle fileHandleWithStandardError]];
|
||||
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
|
||||
[task setLaunchPath:command];
|
||||
[task setArguments:[args arrayByAddingObject:destination]];
|
||||
[task launch];
|
||||
NSUInteger len = [data length];
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
NSUInteger bytesRead = 0;
|
||||
do {
|
||||
NSData *data = [archiveInput readDataOfLength:256*1024];
|
||||
NSUInteger len = [data length];
|
||||
if (!len) {
|
||||
NSError *writeError = nil;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
if (!hasIOErrorMethods) {
|
||||
@try {
|
||||
[archiveOutput writeData:data];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(SULogLevelError, @"Failed to write data to pipe with exception reason %@", exception.reason);
|
||||
break;
|
||||
}
|
||||
bytesRead += len;
|
||||
[archiveOutput writeData:data];
|
||||
[notifier notifyProgress:(double)bytesRead / (double)expectedLength];
|
||||
}
|
||||
while(bytesRead < expectedLength);
|
||||
|
||||
[archiveOutput closeFile];
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
if ([task terminationStatus] == 0) {
|
||||
if (bytesRead == expectedLength) {
|
||||
[notifier notifySuccess];
|
||||
return;
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesRead, (long)expectedLength]}];
|
||||
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
if (![archiveOutput writeData:data error:&writeError]) {
|
||||
#pragma clang diagnostic pop
|
||||
SULog(SULogLevelError, @"Failed to write data to pipe with error %@", writeError);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]]}];
|
||||
}
|
||||
} else {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", self.archivePath]}];
|
||||
|
||||
bytesWritten += len;
|
||||
|
||||
[notifier notifyProgress:(double)bytesWritten / (double)expectedLength];
|
||||
}
|
||||
[notifier notifyFailureWithError:error];
|
||||
while(bytesWritten < expectedLength);
|
||||
|
||||
if (@available(macOS 10.15, *)) {
|
||||
NSError *archiveOutputCloseError = nil;
|
||||
if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) {
|
||||
SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError);
|
||||
}
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
[archiveOutput closeFile];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (@available(macOS 10.15, *)) {
|
||||
NSError *archiveInputCloseError = nil;
|
||||
if (![archiveInput closeAndReturnError:&archiveInputCloseError]) {
|
||||
SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError);
|
||||
}
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
|
||||
else
|
||||
{
|
||||
[archiveInput closeFile];
|
||||
}
|
||||
#endif
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
if ([task terminationStatus] != 0) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]]}];
|
||||
|
||||
[notifier notifyFailureWithError:error];
|
||||
return;
|
||||
}
|
||||
|
||||
if (bytesWritten != expectedLength) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesWritten, (long)expectedLength]}];
|
||||
|
||||
[notifier notifyFailureWithError:error];
|
||||
return;
|
||||
}
|
||||
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
|
||||
|
||||
@end
|
||||
@@ -12,9 +12,9 @@
|
||||
@class SUHost;
|
||||
@protocol SUVersionComparison;
|
||||
|
||||
@interface SUPlainInstaller : NSObject <SUInstallerProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUPlainInstaller : NSObject <SUInstallerProtocol>
|
||||
|
||||
/*!
|
||||
/**
|
||||
@param host The current (old) bundle host
|
||||
@param bundlePath The path to the new bundle that will be installed.
|
||||
@param installationPath The path the new bundlePath will be installed to.
|
||||
|
||||
+195
-147
@@ -11,26 +11,22 @@
|
||||
#import "SUConstants.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUPlainInstaller ()
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, copy, readonly) NSString *bundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *installationPath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPlainInstaller
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize bundlePath = _bundlePath;
|
||||
@synthesize installationPath = _installationPath;
|
||||
{
|
||||
SUHost *_host;
|
||||
NSString *_bundlePath;
|
||||
NSString *_installationPath;
|
||||
NSURL *_temporaryOldDirectory;
|
||||
// We get an obj-c warning if we use 'newTemporaryDirectory' name about new + ownership stuff, so use 'temporaryNewDirectory' instead
|
||||
NSURL *_temporaryNewDirectory;
|
||||
}
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath
|
||||
{
|
||||
@@ -43,23 +39,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one
|
||||
- (NSString *)bundleVersionAppropriateForFilenameFromHost:(SUHost *)host
|
||||
{
|
||||
NSString *bundleVersion = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
NSString *trimmedVersion = @"";
|
||||
|
||||
if (bundleVersion != nil) {
|
||||
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
|
||||
|
||||
trimmedVersion = [bundleVersion stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
|
||||
}
|
||||
|
||||
return trimmedVersion.length > 0 ? trimmedVersion : nil;
|
||||
}
|
||||
|
||||
- (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host progressBlock:(nullable void(^)(double))progress error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host progressBlock:(nullable void(^)(double))progress error:(NSError * __autoreleasing *)error SPU_OBJC_DIRECT
|
||||
{
|
||||
if (installationURL == nil || newURL == nil) {
|
||||
// this really shouldn't happen but just in case
|
||||
@@ -80,49 +60,21 @@
|
||||
// The system periodically cleans up files by looking at the mod & access times, so we have to make sure they're up to date
|
||||
// They could be potentially be preserved when archiving an application, but also an update could just be sitting on the system for a long time
|
||||
// before being installed
|
||||
if (![fileManager updateAccessTimeOfItemAtRootURL:newURL error:error]) {
|
||||
SULog(SULogLevelError, @"Failed to recursively update new application's modification time before moving into temporary directory");
|
||||
NSError *accessTimeError = nil;
|
||||
if (![fileManager updateAccessTimeOfItemAtRootURL:newURL error:&accessTimeError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Failed to recursively update new application's modification time before moving into temporary directory" }];
|
||||
|
||||
if (accessTimeError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = accessTimeError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Create a temporary directory for our new app that resides on our destination's volume
|
||||
NSString *preferredName = [installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"];
|
||||
NSURL *installationDirectory = installationURL.URLByDeletingLastPathComponent;
|
||||
NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:preferredName appropriateForDirectoryURL:installationDirectory error:error];
|
||||
|
||||
if (tempNewDirectoryURL == nil) {
|
||||
SULog(SULogLevelError, @"Failed to make new temp directory");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(2/10.0);
|
||||
}
|
||||
|
||||
// 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(SULogLevelError, @"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newTempURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(3/10.0);
|
||||
}
|
||||
|
||||
// Release our new app from quarantine
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:newTempURL error:&quarantineError]) {
|
||||
// Not big enough of a deal to fail the entire installation
|
||||
SULog(SULogLevelError, @"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(4/10.0);
|
||||
}
|
||||
|
||||
NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath];
|
||||
if (oldURL == nil) {
|
||||
// this really shouldn't happen but just in case
|
||||
@@ -133,19 +85,80 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
// 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
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:error]) {
|
||||
// But this is big enough of a deal to fail
|
||||
SULog(SULogLevelError, @"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
if (progress) {
|
||||
progress(2/10.0);
|
||||
}
|
||||
|
||||
// Create a temporary directory for our new app that resides on our destination's volume
|
||||
// We use oldURL here instead of installationURL because in the case of normalization, installationURL may not exist
|
||||
// And we don't want to use either of the URL's parent directories because the parent directory could be on a different volume
|
||||
NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryAppropriateForDirectoryURL:oldURL error:error];
|
||||
if (tempNewDirectoryURL == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
_temporaryNewDirectory = tempNewDirectoryURL;
|
||||
|
||||
if (progress) {
|
||||
progress(3/10.0);
|
||||
}
|
||||
|
||||
// Move the new app to our temporary directory
|
||||
NSString *newURLLastPathComponent = newURL.lastPathComponent;
|
||||
NSURL *newTempURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURLLastPathComponent];
|
||||
NSError *newTempMoveError = nil;
|
||||
if (![fileManager moveItemAtURL:newURL toURL:newTempURL error:&newTempMoveError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newTempURL.path] }];
|
||||
|
||||
if (newTempMoveError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = newTempMoveError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(4/10.0);
|
||||
}
|
||||
|
||||
// Release our new app from quarantine
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:newTempURL error:&quarantineError]) {
|
||||
// Not big enough of a deal to fail the entire installation
|
||||
SULog(SULogLevelError, @"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(5/10.0);
|
||||
}
|
||||
|
||||
// Try to preserve Finder Tags
|
||||
NSArray *resourceTags = nil;
|
||||
BOOL retrievedResourceTags = [oldURL getResourceValue:&resourceTags forKey:NSURLTagNamesKey error:NULL];
|
||||
if (retrievedResourceTags && resourceTags.count > 0) {
|
||||
[newTempURL setResourceValue:resourceTags forKey:NSURLTagNamesKey error:NULL];
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(6/10.0);
|
||||
}
|
||||
|
||||
// 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 *changeOwnerAndGroupError = nil;
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:&changeOwnerAndGroupError]) {
|
||||
// Not a fatal error
|
||||
SULog(SULogLevelError, @"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path);
|
||||
SULog(SULogLevelError, @"Error: %@", changeOwnerAndGroupError);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(7/10.0);
|
||||
}
|
||||
|
||||
NSError *touchError = nil;
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:newTempURL error:&touchError]) {
|
||||
@@ -154,65 +167,91 @@
|
||||
SULog(SULogLevelError, @"Error: %@", touchError);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(6/10.0);
|
||||
}
|
||||
|
||||
// Decide on a destination name we should use for the older app when we move it around the file system
|
||||
NSString *oldDestinationName = oldURL.lastPathComponent.stringByDeletingPathExtension;
|
||||
NSString *oldDestinationNameWithPathExtension = oldURL.lastPathComponent;
|
||||
|
||||
// Create a temporary directory for our old app that resides on its volume
|
||||
NSURL *oldDirectoryURL = oldURL.URLByDeletingLastPathComponent;
|
||||
NSURL *tempOldDirectoryURL = (oldDirectoryURL != nil) ? [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldDirectoryURL error:error] : nil;
|
||||
if (tempOldDirectoryURL == nil) {
|
||||
SULog(SULogLevelError, @"Failed to create temporary directory for old app at %@", oldURL.path);
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(7/10.0);
|
||||
}
|
||||
|
||||
// Move the old app to the temporary directory
|
||||
NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension];
|
||||
if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) {
|
||||
SULog(SULogLevelError, @"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;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(8/10.0);
|
||||
}
|
||||
|
||||
// Move the new app to its final destination
|
||||
if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) {
|
||||
SULog(SULogLevelError, @"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;
|
||||
|
||||
// First try swapping the application atomically
|
||||
NSError *swapError = nil;
|
||||
BOOL swappedApp;
|
||||
// If the app is normalized and the installation path differs, go through the old swap path
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
|
||||
swappedApp = NO;
|
||||
} else {
|
||||
// We will be cleaning up the temporary directory later in -performCleanup:
|
||||
// We don't want to clean it up now because it can take some time
|
||||
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newTempURL error:&swapError];
|
||||
}
|
||||
|
||||
if (!swappedApp) {
|
||||
// Otherwise swap out the old and new applications using the legacy path
|
||||
|
||||
if (swapError != nil) {
|
||||
SULog(SULogLevelDefault, @"Invoking fallback from failing to replace original item with error: %@", swapError);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(9/10.0);
|
||||
// Create a temporary directory for our old app that resides on its volume
|
||||
NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryAppropriateForDirectoryURL:oldURL error:error];
|
||||
if (tempOldDirectoryURL == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
_temporaryOldDirectory = tempOldDirectoryURL;
|
||||
|
||||
if (progress) {
|
||||
progress(9/10.0);
|
||||
}
|
||||
|
||||
NSString *oldURLFilename = oldURL.lastPathComponent;
|
||||
if (oldURLFilename == nil) {
|
||||
// this really shouldn't happen..
|
||||
SULog(SULogLevelError, @"Failed to retrieve last path component from old URL: %@", oldURL.path);
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because the last path component of the old installation URL could not be constructed." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Move the old app to the temporary directory
|
||||
NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURLFilename];
|
||||
NSError *oldMoveError = nil;
|
||||
if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:&oldMoveError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path] }];
|
||||
|
||||
if (oldMoveError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = oldMoveError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
progress(9.5/10.0);
|
||||
}
|
||||
|
||||
// Move the new app to its final destination
|
||||
NSError *installMoveError = nil;
|
||||
if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:&installMoveError]) {
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move new app at %@ to final destination %@", newTempURL.path, installationURL.path] }];
|
||||
|
||||
if (installMoveError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = installMoveError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
|
||||
}
|
||||
|
||||
// Attempt to restore our old app back the way it was on failure
|
||||
[fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL];
|
||||
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
[fileManager removeItemAtURL:tempOldDirectoryURL error:NULL];
|
||||
[fileManager removeItemAtURL:tempNewDirectoryURL error:NULL];
|
||||
|
||||
if (progress) {
|
||||
progress(10/10.0);
|
||||
}
|
||||
@@ -222,28 +261,24 @@
|
||||
|
||||
- (BOOL)performInitialInstallation:(NSError * __autoreleasing *)error
|
||||
{
|
||||
BOOL allowDowngrades = SPARKLE_AUTOMATED_DOWNGRADES;
|
||||
|
||||
// Prevent malicious downgrades
|
||||
// Note that we may not be able to do this for package installations, hence this code being done here
|
||||
if (!allowDowngrades) {
|
||||
NSString *hostVersion = [self.host version];
|
||||
NSString *hostVersion = [_host version];
|
||||
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:_bundlePath];
|
||||
SUHost *updateHost = [[SUHost alloc] initWithBundle:bundle];
|
||||
NSString *updateVersion = [updateHost objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
|
||||
id<SUVersionComparison> comparator = [[SUStandardVersionComparator alloc] init];
|
||||
if (!updateVersion || [comparator compareVersion:hostVersion toVersion:updateVersion] == NSOrderedDescending) {
|
||||
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:self.bundlePath];
|
||||
SUHost *updateHost = [[SUHost alloc] initWithBundle:bundle];
|
||||
NSString *updateVersion = [updateHost objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
|
||||
id<SUVersionComparison> comparator = [[SUStandardVersionComparator alloc] init];
|
||||
if (!updateVersion || [comparator compareVersion:hostVersion toVersion:updateVersion] == NSOrderedDescending) {
|
||||
if (error != NULL) {
|
||||
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.", hostVersion, updateVersion];
|
||||
|
||||
if (error != NULL) {
|
||||
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.", hostVersion, updateVersion];
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
@@ -253,7 +288,20 @@
|
||||
{
|
||||
// Note: we must do most installation work in the third stage due to relying on our application sitting in temporary directories.
|
||||
// It must not be possible for our update to sit in temporary directories for a very long time.
|
||||
return [self startInstallationToURL:[NSURL fileURLWithPath:self.installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:self.bundlePath] withHost:self.host progressBlock:cb error:error];
|
||||
return [self startInstallationToURL:[NSURL fileURLWithPath:_installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:_bundlePath] withHost:_host progressBlock:cb error:error];
|
||||
}
|
||||
|
||||
- (void)performCleanup
|
||||
{
|
||||
SUFileManager *fileManager = [[SUFileManager alloc] init];
|
||||
|
||||
if (_temporaryNewDirectory != nil) {
|
||||
[fileManager removeItemAtURL:_temporaryNewDirectory error:NULL];
|
||||
}
|
||||
|
||||
if (_temporaryOldDirectory != nil) {
|
||||
[fileManager removeItemAtURL:_temporaryOldDirectory error:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
@class SUSignatures;
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys;
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error;
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures;
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -15,43 +15,47 @@
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUErrors.h"
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "ed25519.h" // Run `git submodule update --init` if you get an error here
|
||||
#endif
|
||||
#import "ed25519.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUSignatureVerifier ()
|
||||
@property (readonly) SUPublicKeys *pubKeys;
|
||||
@end
|
||||
|
||||
@implementation SUSignatureVerifier {
|
||||
@implementation SUSignatureVerifier
|
||||
{
|
||||
SUPublicKeys *_pubKeys;
|
||||
}
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
|
||||
if (!verifier) {
|
||||
if (verifier == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create SUSignatureVerifier instance" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [verifier verifyFileAtPath:path signatures:signatures];
|
||||
return [verifier verifyFileAtPath:path signatures:signatures error:error];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
|
||||
{
|
||||
self = [super init];
|
||||
_pubKeys = pubkeys;
|
||||
|
||||
if (self != nil) {
|
||||
_pubKeys = pubkeys;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SecKeyRef)dsaSecKeyRef {
|
||||
|
||||
NSData *data = [self.pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
- (SecKeyRef)dsaSecKeyRef SPU_OBJC_DIRECT
|
||||
{
|
||||
NSData *data = [_pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
@@ -84,74 +88,208 @@
|
||||
CFRelease(items);
|
||||
return dsaPubKeySecKey;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (!path || !path.length) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Path passed to verify has zero length and is not valid" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!signatures) {
|
||||
SULog(SULogLevelDefault, @"No signatures given to verifyFileAtPath");
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"No signatures given to verifyFileAtPath" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSData *dsaSignature = signatures.dsaSignature;
|
||||
NSString *dsaPubKey = self.pubKeys.dsaPubKey;
|
||||
|
||||
const unsigned char *edSignature = signatures.ed25519Signature;
|
||||
const unsigned char *edPubKey = self.pubKeys.ed25519PubKey;
|
||||
|
||||
if (edPubKey && !edSignature) {
|
||||
SULog(SULogLevelDefault, @"There is no EdDSA signature in the update, but the app is capable of verifying them");
|
||||
} if (!edPubKey && edSignature) {
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it won't be used, because the old app doesn't have an EdDSA public key");
|
||||
} else if (edPubKey && edSignature) {
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&error];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, error);
|
||||
switch (_pubKeys.ed25519PubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it won't be used, because the old app doesn't have an EdDSA public key");
|
||||
}
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
|
||||
NSString *message = @"The update has an EdDSA signature, but the app has an invalid EdDSA public key, so the update will automatically be rejected.";
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(edSignature, data.bytes, data.length, edPubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
|
||||
if (!dsaPubKey) {
|
||||
return YES;
|
||||
SULog(SULogLevelDefault, @"The app has an invalid EdDSA public key, but there is no EdDSA signature in the update. Falling back to DSA.");
|
||||
break;
|
||||
case SUSigningInputStatusPresent:
|
||||
switch (signatures.ed25519SignatureStatus) {
|
||||
case SUSigningInputStatusAbsent: {
|
||||
NSString *message = @"The app has an EdDSA public key, but there is no EdDSA signature in the update, so the update will be rejected.";
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
case SUSigningInputStatusInvalid: {
|
||||
NSString *message = @"The update has an EdDSA signature, but it's invalid, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
case SUSigningInputStatusPresent: {
|
||||
NSError *dataError = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&dataError];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, dataError);
|
||||
|
||||
if (error != NULL) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Failed to load file: %@", path];
|
||||
if (dataError != nil) {
|
||||
userInfo[NSUnderlyingErrorKey] = dataError;
|
||||
}
|
||||
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(signatures.ed25519Signature, data.bytes, data.length, _pubKeys.ed25519PubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
// No need to check DSA when EdDSA verification succeeded, unless a DSA signature is provided and it's
|
||||
// erroneously invalid
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusInvalid)
|
||||
#endif
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelDefault, @"This app has a DSA public key, so a DSA signature is required too");
|
||||
NSString *message = @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (dsaSignature) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dsaSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
} else if (!dsaPubKey) {
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
|
||||
} else {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:dsaSignature];
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
switch (_pubKeys.dsaPubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
|
||||
}
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
|
||||
// We will have already logged an error for this failure when the public key was read in, so just do an informational log here.
|
||||
NSString *message = @"The update has a DSA signature, but the app has an invalid DSA public key, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
SULog(SULogLevelDefault, @"The app has an invalid DSA public key, but there is no DSA signature in the update.");
|
||||
break;
|
||||
case SUSigningInputStatusPresent:
|
||||
switch (signatures.dsaSignatureStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
break;
|
||||
case SUSigningInputStatusInvalid: {
|
||||
NSString *message = @"The update has a DSA signature, but it's invalid, so the update will automatically be rejected.";
|
||||
|
||||
SULog(SULogLevelError, @"%@", message);
|
||||
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
case SUSigningInputStatusPresent: {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:signatures.dsaSignature error:error];
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
switch (_pubKeys.dsaPubKeyStatus) {
|
||||
case SUSigningInputStatusAbsent:
|
||||
break;
|
||||
case SUSigningInputStatusInvalid:
|
||||
// We don't keep track of DSA signatures, so we will ignore this mistake and treat it as if it were absent
|
||||
break;
|
||||
case SUSigningInputStatusPresent:
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"The old app has a DSA public key but DSA support is disabled, and the old app does not have an EdDSA public key." }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error != NULL) {
|
||||
// Use generic failure
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"EdDSA and DSA verification for the update has failed" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature
|
||||
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature error:(NSError * __autoreleasing *)outError SPU_OBJC_DIRECT
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Invalid arguments to verifyStream" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
|
||||
if (!dsaPubKeySecKey) {
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create DSA Sec Key Ref" }];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Sparkle's DSA support is deprecated
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
@@ -170,48 +308,85 @@
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(SULogLevelError, @"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecTransform for input stream)" }];
|
||||
}
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecDigest for input stream)" }];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
if (!dataVerifyTransform) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
if (outError != NULL) {
|
||||
NSError *underlyingError = (__bridge NSError *)error;
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Could not understand format of the signature data %@", dsaSignature];
|
||||
if (underlyingError != NULL) {
|
||||
userInfo[NSUnderlyingErrorKey] = underlyingError;
|
||||
}
|
||||
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (error) {
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data read transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"%@", error);
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data digest transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
#pragma clang diagnostic pop
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature verification failed", NSUnderlyingErrorKey: (__bridge NSError *)error}];
|
||||
}
|
||||
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(SULogLevelError, @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (outError != NULL) {
|
||||
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set"}];
|
||||
}
|
||||
}
|
||||
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -12,9 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUUnarchiverProtocol;
|
||||
|
||||
@interface SUUnarchiver : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUUnarchiver : NSObject
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword expectingInstallationType:(NSString *)installationType;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -11,25 +11,36 @@
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUFlatPackageUnarchiver.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@implementation SUUnarchiver
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword expectingInstallationType:(NSString *)installationType
|
||||
{
|
||||
if ([SUPipedUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUPipedUnarchiver alloc] initWithArchivePath:path];
|
||||
|
||||
} else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
|
||||
}
|
||||
#if SPARKLE_BUILD_DMG_SUPPORT
|
||||
else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path decryptionPassword:decryptionPassword];
|
||||
|
||||
} else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
|
||||
}
|
||||
#endif
|
||||
else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
|
||||
assert(hostPath != nil);
|
||||
NSString *nonNullHostPath = hostPath;
|
||||
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath];
|
||||
}
|
||||
#if SPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
|
||||
// Flat packages are only supported for guided packaage installs
|
||||
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path expectingInstallationType:installationType];
|
||||
}
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUUnarchiverNotifier : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface SUUnarchiverNotifier : NSObject
|
||||
|
||||
- (instancetype)initWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
|
||||
@@ -8,22 +8,16 @@
|
||||
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SULocalizations.h"
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUUnarchiverNotifier ()
|
||||
|
||||
@property (nonatomic, readonly, copy) void (^completionBlock)(NSError * _Nullable);
|
||||
@property (nonatomic, readonly, copy) void (^ _Nullable progressBlock)(double);
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUUnarchiverNotifier
|
||||
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize progressBlock = _progressBlock;
|
||||
{
|
||||
void (^_completionBlock)(NSError * _Nullable);
|
||||
void (^ _Nullable _progressBlock)(double);
|
||||
}
|
||||
|
||||
- (instancetype)initWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
@@ -31,6 +25,8 @@
|
||||
if (self != nil) {
|
||||
_completionBlock = [completionBlock copy];
|
||||
_progressBlock = [progressBlock copy];
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -38,13 +34,13 @@
|
||||
- (void)notifySuccess
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.completionBlock(nil);
|
||||
self->_completionBlock(nil);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)notifyFailureWithError:(NSError * _Nullable)reason
|
||||
{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) forKey:NSLocalizedDescriptionKey];
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:@"An error occurred while extracting the archive. Please try again later." forKey:NSLocalizedDescriptionKey];
|
||||
if (reason) {
|
||||
[userInfo setObject:(NSError * _Nonnull)reason forKey:NSUnderlyingErrorKey];
|
||||
}
|
||||
@@ -52,15 +48,15 @@
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:userInfo];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.completionBlock(error);
|
||||
self->_completionBlock(error);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)notifyProgress:(double)progress
|
||||
{
|
||||
if (self.progressBlock != nil) {
|
||||
if (_progressBlock != nil) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.progressBlock(progress);
|
||||
self->_progressBlock(progress);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUUnarchiverProtocol <NSObject>
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction;
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface StatusInfo : NSObject <SUStatusInfoProtocol>
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface StatusInfo : NSObject <SUStatusInfoProtocol>
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier;
|
||||
|
||||
|
||||
+44
-8
@@ -12,15 +12,19 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
#define REPLY_STATUS_INFO_TIMEOUT 2
|
||||
|
||||
@interface StatusInfo () <NSXPCListenerDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
|
||||
@end
|
||||
|
||||
@implementation StatusInfo
|
||||
{
|
||||
NSXPCListener *_xpcListener;
|
||||
NSMutableDictionary *_pendingReplies;
|
||||
|
||||
NSUInteger _pendingReplyCounter;
|
||||
}
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize installationInfoData = _installationInfoData;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier
|
||||
@@ -29,19 +33,20 @@
|
||||
if (self != nil) {
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUStatusInfoServiceNameForBundleIdentifier(bundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
_pendingReplies = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[_xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
[_xpcListener invalidate];
|
||||
_xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
@@ -54,10 +59,41 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setInstallationInfoData:(NSData *)installationInfoData
|
||||
{
|
||||
_installationInfoData = installationInfoData;
|
||||
|
||||
// Respond to all of our pending replies
|
||||
for (NSNumber *replyKey in _pendingReplies) {
|
||||
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[replyKey];
|
||||
replyBlock(_installationInfoData);
|
||||
}
|
||||
|
||||
[_pendingReplies removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
reply(self.installationInfoData);
|
||||
if (self->_installationInfoData != nil) {
|
||||
reply(self->_installationInfoData);
|
||||
} else {
|
||||
// If we don't have the installation info data currently, we may receive it in a very short window afterwards
|
||||
// In this case wait a bit for the reply. If we receive the data it will be in -setInstallationInfoData:
|
||||
NSUInteger currentReplyCounter = self->_pendingReplyCounter;
|
||||
self->_pendingReplyCounter++;
|
||||
|
||||
NSNumber *currentReplyCounterKey = @(currentReplyCounter);
|
||||
self->_pendingReplies[currentReplyCounterKey] = [reply copy];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(REPLY_STATUS_INFO_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[currentReplyCounterKey];
|
||||
if (replyBlock != nil) {
|
||||
replyBlock(self->_installationInfoData);
|
||||
[self->_pendingReplies removeObjectForKey:currentReplyCounterKey];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TerminationListener : NSObject
|
||||
SPU_OBJC_DIRECT_MEMBERS @interface TerminationListener : NSObject
|
||||
|
||||
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier;
|
||||
|
||||
|
||||
@@ -16,19 +16,14 @@
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface TerminationListener ()
|
||||
|
||||
@property (nonatomic, readonly, nullable) NSNumber *processIdentifier;
|
||||
@property (nonatomic) BOOL watchedTermination;
|
||||
@property (nonatomic, copy) void (^completionBlock)(BOOL);
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
|
||||
@synthesize completionBlock = _completionBlock;
|
||||
@synthesize processIdentifier = _processIdentifier;
|
||||
@synthesize watchedTermination = _watchedTermination;
|
||||
{
|
||||
NSNumber *_processIdentifier;
|
||||
|
||||
void (^_completionBlock)(BOOL);
|
||||
|
||||
BOOL _watchedTermination;
|
||||
}
|
||||
|
||||
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier
|
||||
{
|
||||
@@ -42,22 +37,22 @@
|
||||
|
||||
- (BOOL)terminated
|
||||
{
|
||||
return (self.watchedTermination || self.processIdentifier == nil) ? YES : (kill(self.processIdentifier.intValue, 0) != 0);
|
||||
return (_watchedTermination || _processIdentifier == nil) ? YES : (kill(_processIdentifier.intValue, 0) != 0);
|
||||
}
|
||||
|
||||
- (void)invokeCompletionWithSuccess:(BOOL)success
|
||||
- (void)invokeCompletionWithSuccess:(BOOL)success SPU_OBJC_DIRECT
|
||||
{
|
||||
if (self.completionBlock != nil) {
|
||||
self.completionBlock(success);
|
||||
self.completionBlock = nil;
|
||||
if (_completionBlock != nil) {
|
||||
_completionBlock(success);
|
||||
_completionBlock = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startListeningWithCompletion:(void (^)(BOOL))completionBlock
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
_completionBlock = [completionBlock copy];
|
||||
|
||||
if (self.processIdentifier == nil) {
|
||||
if (_processIdentifier == nil) {
|
||||
[self invokeCompletionWithSuccess:YES];
|
||||
return;
|
||||
}
|
||||
@@ -66,7 +61,7 @@
|
||||
// As described in https://developer.apple.com/library/mac/technotes/tn2050/_index.html#//apple_ref/doc/uid/DTS10003081-CH1-SUBSECTION10
|
||||
// By using kqueues, we can stay away from using AppKit in case we ever decide to abandon it
|
||||
|
||||
pid_t processIdentifier = self.processIdentifier.intValue;
|
||||
pid_t processIdentifier = _processIdentifier.intValue;
|
||||
int queue = kqueue();
|
||||
if (queue == -1) {
|
||||
SULog(SULogLevelError, @"Failed to create kqueue() due to error %d: %@", errno, @(strerror(errno)));
|
||||
@@ -124,7 +119,7 @@ static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unu
|
||||
kevent(CFFileDescriptorGetNativeDescriptor(file), NULL, 0, &event, 1, NULL);
|
||||
|
||||
TerminationListener *self = CFBridgingRelease(info);
|
||||
self.watchedTermination = YES;
|
||||
self->_watchedTermination = YES;
|
||||
[self invokeCompletionWithSuccess:YES];
|
||||
}
|
||||
|
||||
|
||||
+8
-3
@@ -9,21 +9,26 @@ int main(int __unused argc, const char __unused *argv[])
|
||||
@autoreleasepool
|
||||
{
|
||||
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
|
||||
if (args.count != 2) {
|
||||
if (args.count != 4) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
NSString *hostBundleIdentifier = args[1];
|
||||
NSString *homeDirectory = args[2];
|
||||
NSString *userName = args[3];
|
||||
|
||||
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostBundleIdentifier:hostBundleIdentifier];
|
||||
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostBundleIdentifier:hostBundleIdentifier homeDirectory:homeDirectory userName:userName];
|
||||
[appInstaller start];
|
||||
|
||||
// Ignore SIGTERM because we are going to catch it ourselves
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
// Ignore SIGPIPE because we won't want read or write failures due to broken pipe to unexpectably
|
||||
// terminate the process (e.g, when extracting archives or performing package installs).
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
|
||||
dispatch_source_set_event_handler(sigtermSource, ^{
|
||||
[appInstaller cleanupAndExitWithStatus:SIGTERM];
|
||||
[appInstaller cleanupAndExitWithStatus:SIGTERM error:nil];
|
||||
});
|
||||
dispatch_resume(sigtermSource);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import "SPUDeltaArchive.h"
|
||||
#import "SPUDeltaArchiveProtocol.h"
|
||||
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// main.swift
|
||||
// BinaryDelta
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/3/22.
|
||||
// Copyright © 2022 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import ArgumentParser
|
||||
|
||||
// Create a patch from an old and new bundle
|
||||
struct Create: ParsableCommand {
|
||||
@Option(name: .long, help: ArgumentHelp("The major version of the patch to generate. Defaults to the latest stable version. Older versions will need to be specified for updating from applications using older versions of Sparkle.", valueName: "version"))
|
||||
var version: Int = Int(SUBinaryDeltaMajorVersionDefault.rawValue)
|
||||
|
||||
@Flag(name: .customLong("verbose"), help: ArgumentHelp("Enable logging of the changes being archived into the generated patch."))
|
||||
var verbose: Bool = false
|
||||
|
||||
@Option(name: .long, help: ArgumentHelp(COMPRESSION_METHOD_ARGUMENT_DESCRIPTION, valueName: "compression"))
|
||||
var compression: String = "default"
|
||||
|
||||
@Option(name: .long, help: .hidden)
|
||||
var compressionLevel: UInt8 = 0
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to original bundle to create a patch from."))
|
||||
var beforeTree: String
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to new bundle to create a patch from."))
|
||||
var afterTree: String
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to new patch file to create."))
|
||||
var patchFile: String
|
||||
|
||||
func validate() throws {
|
||||
var validCompression: ObjCBool = false
|
||||
let compressionMode = deltaCompressionModeFromDescription(compression, &validCompression)
|
||||
guard validCompression.boolValue else {
|
||||
fputs("Error: unrecognized compression \(compression)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
switch compressionMode {
|
||||
case SPUDeltaCompressionModeDefault:
|
||||
fallthrough
|
||||
case .none:
|
||||
guard compressionLevel == 0 else {
|
||||
fputs("Error: compression level must be 0 for compression \(compression)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
break
|
||||
case .bzip2:
|
||||
guard compressionLevel >= 0 && compressionLevel <= 9 else {
|
||||
fputs("Error: compression level \(compressionLevel) is not valid.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
break
|
||||
case .LZMA:
|
||||
fallthrough
|
||||
case .LZFSE:
|
||||
fallthrough
|
||||
case .LZ4:
|
||||
fallthrough
|
||||
case .ZLIB:
|
||||
guard version >= 3 else {
|
||||
fputs("Error: version \(version) patch files do not support compression \(compression)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
guard compressionLevel == 0 else {
|
||||
fputs("Error: compression level provided must be 0 for compression \(compression)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
break
|
||||
@unknown default:
|
||||
fputs("Error: unrecognized compression \(compression)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
guard version >= SUBinaryDeltaMajorVersionFirst.rawValue else {
|
||||
fputs("Error: version provided \(version) is not valid.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
guard version >= SUBinaryDeltaMajorVersionFirstSupported.rawValue else {
|
||||
fputs("Error: creating version \(version) patches is no longer supported.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
guard version <= SUBinaryDeltaMajorVersionLatest.rawValue else {
|
||||
fputs("Error: this program is too old to create a version \(version) patch, or the version number provided is invalid.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
let fileManager = FileManager.default
|
||||
|
||||
var isDirectory: ObjCBool = false
|
||||
if !fileManager.fileExists(atPath: beforeTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
|
||||
fputs("Error: before-tree must be a directory\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
if !fileManager.fileExists(atPath: afterTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
|
||||
fputs("Error: after-tree must be a directory\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run() throws {
|
||||
let compressionMode = deltaCompressionModeFromDescription(compression, nil)
|
||||
|
||||
guard let majorDeltaVersion = SUBinaryDeltaMajorVersion(rawValue: UInt16(version)) else {
|
||||
// We shouldn't reach here
|
||||
fputs("Error: failed to retrieve major version from provided version: \(version)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
var createDiffError: NSError? = nil
|
||||
if !createBinaryDelta(beforeTree, afterTree, patchFile, majorDeltaVersion, compressionMode, compressionLevel, verbose, &createDiffError) {
|
||||
if let error = createDiffError {
|
||||
fputs("\(error.localizedDescription)\n", stderr)
|
||||
} else {
|
||||
fputs("Error: Failed to create patch due to unknown reason.\n", stderr)
|
||||
}
|
||||
throw ExitCode(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply a patch from an old bundle to generate a new bundle
|
||||
struct Apply: ParsableCommand {
|
||||
static let configuration = CommandConfiguration(abstract: "Apply a patch against an original bundle to generate a new bundle.")
|
||||
|
||||
@Flag(name: .customLong("verbose"), help: ArgumentHelp("Enable logging of changes being applied from the patch."))
|
||||
var verbose: Bool = false
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to original bundle to patch."))
|
||||
var beforeTree: String
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to new bundle to create."))
|
||||
var afterTree: String
|
||||
|
||||
@Argument(help: ArgumentHelp("Path to patch file to apply."))
|
||||
var patchFile: String
|
||||
|
||||
func validate() throws {
|
||||
let fileManager = FileManager.default
|
||||
|
||||
var isDirectory: ObjCBool = false
|
||||
if !fileManager.fileExists(atPath: beforeTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
|
||||
fputs("Error: before-tree must be a directory\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
if !fileManager.fileExists(atPath: patchFile, isDirectory: &isDirectory) || isDirectory.boolValue {
|
||||
fputs("Error: patch-file must be a file\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run() throws {
|
||||
var applyDiffError: NSError?
|
||||
if (!applyBinaryDelta(beforeTree, afterTree, patchFile, verbose, { _ in }, &applyDiffError)) {
|
||||
if let error = applyDiffError {
|
||||
fputs("\(error.localizedDescription)\n", stderr)
|
||||
} else {
|
||||
fputs("Error: patch failed to apply for unknown reason\n", stderr)
|
||||
}
|
||||
throw ExitCode(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Output information for BinaryDelta or from a patch file
|
||||
struct Info: ParsableCommand {
|
||||
@Argument(help: ArgumentHelp("Path to patch file to extract information from."))
|
||||
var patchFile : String?
|
||||
|
||||
func run() throws {
|
||||
if let patchFile = patchFile {
|
||||
// Print version of patch file
|
||||
var header: SPUDeltaArchiveHeader? = nil
|
||||
let archive = SPUDeltaArchiveReadPatchAndHeader(patchFile, &header)
|
||||
if let error = archive.error {
|
||||
fputs("Error: Unable to open patch \(patchFile): \(error.localizedDescription)\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
if let header = header {
|
||||
if header.majorVersion < SUBinaryDeltaMajorVersionFirst.rawValue {
|
||||
fputs("Error: major version \(header.majorVersion) is invalid.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
|
||||
fputs("Patch version \(header.majorVersion).\(header.minorVersion)", stdout)
|
||||
|
||||
// Print out compression info only if it's available
|
||||
// We can't get compression info from version 2 files
|
||||
if header.compression != SPUDeltaCompressionModeDefault, let compressionDescription = deltaCompressionStringFromMode(header.compression) {
|
||||
fputs(" using \(compressionDescription) compression", stdout)
|
||||
|
||||
// Compression level isn't available or applicable for all formats
|
||||
if header.compressionLevel != 0 {
|
||||
fputs(" with level \(header.compressionLevel)", stdout)
|
||||
}
|
||||
}
|
||||
|
||||
fputs("\n", stdout)
|
||||
} else {
|
||||
fputs("Error: Failed to retrieve header due to unknown reason.\n", stderr)
|
||||
throw ExitCode(1)
|
||||
}
|
||||
} else {
|
||||
// Print version of program
|
||||
fputs("BinaryDelta version \(SUBinaryDeltaMajorVersionLatest.rawValue).\(latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersionLatest))\n", stdout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct BinaryDelta: ParsableCommand {
|
||||
static let configuration = CommandConfiguration(commandName: "BinaryDelta", abstract: "Create and apply small and efficient delta patches between an old and new version of a bundle.", subcommands: [Create.self, Apply.self, Info.self])
|
||||
}
|
||||
|
||||
DispatchQueue.global().async(execute: {
|
||||
BinaryDelta.main()
|
||||
CFRunLoopStop(CFRunLoopGetMain())
|
||||
})
|
||||
CFRunLoopRun()
|
||||
@@ -1,3 +1,354 @@
|
||||
# 2.4.1
|
||||
|
||||
* Remove auxiliary apps and relocate symbols in SPM package to resolve missing AvailableLibraries warnings (#2356) (Zorg)
|
||||
* Add -Wno-declaration-after-statement to silence warnings that only apply to pre-C99 (#2345) (Kent Sutherland)
|
||||
* Fix compile error when setting SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE=0 (#2346) (Zorg)
|
||||
|
||||
# 2.4.0
|
||||
|
||||
* Reduce code size
|
||||
* Enable deployment postprocessing in Release to properly strip debug symbols and strip all non-global symbols (#2286, #2305) (Zorg)
|
||||
* Remove duplicate Sparkle localization strings in Updater app (#2288) (Zorg)
|
||||
* Optimize codebase for generated code size (less properties, direct methods, etc) (#2305) (Zorg)
|
||||
* Add additional settings to `ConfigCommon.xcconfig` for disabling features
|
||||
* Ask permission for automatically downloading and installing new updates (#2285) (Zorg)
|
||||
* Add support for plain text release notes view that does not use web view (#2315) (Zorg)
|
||||
* Update `SUVersionDisplay` to better customize and display how versions are shown (#2321) (Zorg)
|
||||
* Add deprecations/warnings for incorrect background update checking usage (#2295) (Zorg)
|
||||
* Deprecate `-[SPUUpdater setFeedURL:]` API and add `-[SPUUpdater clearFeedURLFromUserDefaults]` for migrating away from `-[SPUUpdater setFeedURL:]` (#2295)
|
||||
* Trigger a new update check in `-[SPUUpdater resetUpdateCycle]` if the updater's feed or allowed channels have changed (#2324) (Zorg)
|
||||
* Exit with an error if generate_appcast cannot sign an update that must be signed (#2322) (Zorg)
|
||||
* Remove a redundant Apple code signing check when verifying new updates (#2341) (Zorg)
|
||||
* Turn off auto-linking for XPC targets to alleviate circular dependency issues (#2332) (Daniel Jalkut)
|
||||
|
||||
# 2.3.2
|
||||
|
||||
* Fix potential crash during download if appcast item includes invalid enclosure URL (#2317) (Zorg)
|
||||
* Add delegate method to hide showing version history option (#2303) (Zorg)
|
||||
* Finnish localization grammar fixes (#2311) (Lauri-Matti Parppei)
|
||||
|
||||
# 2.3.1
|
||||
|
||||
* Fix update permission alert title text overlapping with question text in some languages (#2284) (Zorg)
|
||||
* Log the URL that failed to download correctly (#2296) (Zorg)
|
||||
* Update Czech translation (#2275) (Sam)
|
||||
* Add zh_HK (Chinese, Hong Kong) localization (#2273) (Bing Zheung)
|
||||
|
||||
# 2.3.0
|
||||
|
||||
* Bump minimum deployment target to macOS 10.13 (#2196) (Zorg)
|
||||
* Remove and preserve necessary updates in generate_appcast (#2218) (Zorg)
|
||||
* Move old update files no longer needed to old_updates/ in archive directory in generate_appcast (#2228) (Zorg)
|
||||
* Expose maximum-versions option (per branch) in generate_appcast to preserve in the feed (#2259) (Zorg)
|
||||
* Add -p option to sign_update to only print the signed signature (#2268) (Zorg)
|
||||
* Hide automatic install check box when allowsAutomaticUpdates is disabled (#2202) (Jie)
|
||||
* Allow developer to always force allowing automatic updates (#2266) (Zorg)
|
||||
* Fix update window going haywire during resize when release notes are hidden by disabling resizing (#2200) (Zorg)
|
||||
* Allow user to re-try installing/relaunching application when quit is delayed/cancelled (#2234) (Zorg)
|
||||
* Add delta update attributes for validating an app hasn't been stripped from removed localizations or architectures (#2219) (Zorg)
|
||||
* Fix delta patches not applying edge case if files from source that need to be diffed are not writeable (#2211) (Zorg)
|
||||
* Add delegate callback when user makes choice to install, dismiss, or skip an update (#2250) (Zorg)
|
||||
* Reject serving updates with DSA only and no EdDSA (#2167) (Zorg)
|
||||
* Find potential matching running apps that are translocated in the updater agent (#2233) (Zorg)
|
||||
* Expose -[SPUStandardUserDriver activeUpdateAlert] as private API (#2255) (Zorg)
|
||||
* Add zh_CN l10n for "Version History" (#2247) (kakaiikaka)
|
||||
* Update zh_TW localization (#2271) (Chiahong)
|
||||
* Remove ed25519 git submodule in favor of including the dependency directly (#2244) (Zorg)
|
||||
* Clean up left-over code (#2243) (Eitot)
|
||||
* Update Package.resolved (#2245) (Zorg)
|
||||
* Remove model translation table for system profiling (#2188) (Zorg)
|
||||
* Improve documentation usage for SPUUpdater properties (#2256) (Zorg)
|
||||
|
||||
This release improves generate_appcast by automatically removing updates that are no longer needed in the generated appcast, and moving old update files to old_updates/ in the archives directory. New delta update attributes are also added to let Sparkle know when to skip downloading delta updates if the application has been stripped.
|
||||
|
||||
macOS 10.13 or later is now required (due to Xcode 14 dropping support for deploying to older OS versions).
|
||||
|
||||
If you're not generating appcasts automatically, remember to add `<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>` element to `<item>`s in your appcast.
|
||||
|
||||
# 2.2.2
|
||||
|
||||
* Critical update alerts may not show up as promptly as they should when they are being automatically installed (#2230) (Zorg)
|
||||
* Remove module imports from framework headers (#2217) (Zorg)
|
||||
* Update Portuguese localization (#2224) (Kent Sutherland)
|
||||
* Update zh_TW localization (#2246) (Chiahong)
|
||||
|
||||
# 2.2.1
|
||||
|
||||
* Make scroll bar dark in dark theme for Release Notes by default (#2187) (Pavel Moiseenko)
|
||||
* Fix memory leaks when using generate_appcast (#2193) (Zorg)
|
||||
* Update Italian localization (#2192) (VinBoiSoft)
|
||||
|
||||
# 2.2.0
|
||||
|
||||
* Update Focus Improvements (#924)
|
||||
* Present new scheduled updates in utmost focus only at opportune times (Zorg)
|
||||
* For regular apps opportune times are: app launch, app re-activation, and system being idle (without a power assertion being held to prevent display sleep).
|
||||
* For background (dockless) apps opportune time is just app launch. Otherwise, the update is now shown behind other applications and windows, instead of previously stealing focus from other active apps.
|
||||
* Add APIs and documentation for adding gentle update reminders to compliment Sparkle's standard user interface (Zorg) (#2122)
|
||||
* Allow status window to be minimizable for regular app installs (Zorg) (#2100)
|
||||
* Center status window and inherit key focus from the previously shown update alert window (Zorg)
|
||||
* Activate app when checking for updates if the app is not currently active (e.g, from a menu bar extra menu item) (Zorg)
|
||||
* Fix issue where bringing status window to front made other active windows exit in macOS Ventura's Stage Manager (#2153) (Zorg)
|
||||
* Fix showing update in focus not bringing the "checking for updates" window in focus (Zorg) (#2150)
|
||||
* Rename XPC Service filenames for Sandboxing to show more friendly human-readable name in authorization dialog (Zorg) (#2096)
|
||||
* Add support for running the framework and sparkle-cli as root (Zorg) (#2119)
|
||||
* Fix issue where update cycle may not complete in unusual configuration if automatic checks are disabled + automatic downloading is enabled + install requires user interaction (Zorg) (#2133)
|
||||
* Synchronize usage of XPC connections to main queue to fix potential race conditions (Zorg) (#2178)
|
||||
* Update last update check time when choosing to install an update & relaunch (Zorg) (#2136)
|
||||
* Improve error reporting in the framework and sparkle-cli when installation fails with no write permission (Zorg) (#2157)
|
||||
* Use displayVersionString instead of versionString for OS version mismatch error message (samschott) (#2138)
|
||||
* Make displayVersionString non-null and update fallback documentation (Zorg) (#2139)
|
||||
* Ignore custom icons set via resource forks when applying delta updates (Zorg) (#2114)
|
||||
* Fall back to regular update if delta update fails to download (Zorg) (#2118)
|
||||
* Skip downloading delta updates when application has been moved to a file system (like FAT) that doesn't support regular permission modes (Zorg) (#2148)
|
||||
* Bump initial installer message timeouts and declare daemon/agents processes as Interactive (Zorg) (#2162)
|
||||
* Add and improve translation strings and update pt-BR (BR Lingo) (#2094)
|
||||
* Update localisations (Eitot) (#2113)
|
||||
* Update Greek localizations (seitsme) (#2184, #2185)
|
||||
* Update Japanese localization (1024jp) (#2182)
|
||||
* Replace deprecated code with newer APIs (Eitot) (#2112)
|
||||
* Remove obsolete fallbacks for older OS versions (Eitot) (#2110)
|
||||
* Remove SPUURLRequest (Zorg) (#2124)
|
||||
* Silence ivar deprecation warnings (Zorg) (#2099)
|
||||
* Fix Xcode 14 project warnings (Zorg) (#2147, #2179)
|
||||
* Deprecate -s flag and add --ed-key-file option to generate_appcast (Zorg) (#2170)
|
||||
* Update text for external licenses (Zorg) (#2164)
|
||||
|
||||
This update renames the bundled XPC Services, brings improvements to notifying users of new updates without disrupting their focus, and adds [gentle update reminder APIs](https://sparkle-project.org/documentation/gentle-reminders/) to further customize how Sparkle's standard user interface delivers new update alerts.
|
||||
|
||||
The `-s` flag for passing a raw private EdDSA key to sign_update and generate_appcast is now deprecated. If you were using this option previously, please see the help pages of these tools for more information.
|
||||
|
||||
# 2.1.0
|
||||
|
||||
* New Binary Delta format (version 3)
|
||||
* Features a custom and more efficient container format, migrating away from the deprecated xar format (Zorg) (#2051)
|
||||
* Adds delta compression options for lzma, bzip2, zlib, lzfse, lz4, and no compression (Zorg) (#2051)
|
||||
* Changes default delta format compression from bzip2 (in version 2) to lzma (in version 3) resulting in smaller deltas (Zorg) (#2051)
|
||||
* Preserve file system (HFS+/apfs) level compression when applying delta updates (Zorg) (#2084)
|
||||
* Tracks renames and binary diffs for files that have moved around to new locations using intelligent heuristics (Zorg) (#2051, #2053)
|
||||
* Added more unit tests, UI tests, and generate_appcast/BinaryDelta tools support for the new format (Zorg) (#2052, #2054)
|
||||
* Major upgrade improvements (#2070)
|
||||
* Fix skipping a major version to not skip subsequent major versions (Zorg) (#2079)
|
||||
* Add sparkle:belowVersion element for informational updates (Zorg) (#2080)
|
||||
* Add option to allow developers to ignore/reset user skipped upgrades (Zorg) (#2081)
|
||||
* Fix progress bar and button alignment for checking updates (Zorg) (#2066)
|
||||
* This deprecates `-[SPUUserDriver showInstallingUpdate]` and `-[SPUUserDriver showSendingTerminationSignal]` in favor for `-[SPUUserDriver showInstallingUpdateWithApplicationTerminated:]`
|
||||
* Fix unsteady progress when installing updates (Zorg) (#2072)
|
||||
* Check http statusCode in didFinishDownloadingToURL (Eric Shapiro, Zorg) (#2049, #2073)
|
||||
* Use strcoll_l() for locale-independent comparisons for delta updates (Dan Rigdon-Bel) (#2087)
|
||||
* Fix version compare not treating '2.1.0' and '2.1' as being equal (Zorg) (#2065)
|
||||
* Add verify and account options for signing updates (Zorg) (#2074)
|
||||
* Add delta patch and Apple code signing verification in generate_appcast (Zorg) (#2076, #2077)
|
||||
* Use more modern NSSecureCoding APIs when available (Zorg) (#2058)
|
||||
* Use more modern FileManager APIs for copying files (Zorg) (#2059)
|
||||
* Fix make release failing when customizing XPC_SERVICE_BUNDLE_ID_PREFIX (Zorg) (#2060)
|
||||
* Preserve the Entitlements directory in podspec (digitalMoksha) (#2062)
|
||||
* Add hidden option to generate_appcast to set max CDATA threshold (Zorg) (#2075)
|
||||
|
||||
This update introduces a new major format for [delta updates](https://sparkle-project.org/documentation/delta-updates/), which migrates away from deprecated APIs (xar) and creates smaller patches. If you don't use `generate_appcast`, please check the [compatibility notes for creating delta updates](https://sparkle-project.org/documentation/delta-updates/#compatibility).
|
||||
|
||||
# 2.0.0
|
||||
|
||||
* Support for Sandboxed Applications (Zorg)
|
||||
* Support for writing custom user interfaces (Zorg)
|
||||
* Support for updating external Sparkle-based bundles (Zorg)
|
||||
* Added command line utility to update Sparkle-based bundles (Zorg)
|
||||
* Modern architecture
|
||||
* Moves extraction, validation, and installation into a submitted launchd agent/daemon with XPC communication (Zorg)
|
||||
* Features faster installs with shorter update/relaunch times (#1802) (Zorg)
|
||||
* Provides more robust installs when user authorization is needed (Zorg)
|
||||
* Adoption of improved atomic-safe updates leveraging APFS (#1801) (Zorg)
|
||||
* API Changes
|
||||
* Introduced new SPUStandardUpdaterController, SPUUpdater, SPUUserDriver classes/protocols (Zorg)
|
||||
* Decoupled AppKit and UI logic in the framework from core functionality (Zorg)
|
||||
* Ensure (most) API compatibility with Sparkle 1; you can likely test Sparkle 2 in an existing app with little to no changes (Zorg)
|
||||
* Deprecated SUUpdater, albeit it is still functional for testing and transitional purposes (Zorg)
|
||||
* `-bestValidUpdateInAppcast:forUpdater:` delegate method behavior has been refined and discouraged for some cases. Please review its updated header documentation in `SPUUpdaterDelegate.h` if you use this method. (#1838, #1862, #1879, #1880) (Zorg)
|
||||
* Delegation methods may have been removed or added to the newer updater API. Please review `SPUUpdaterDelegate` if using `SPUUpdater`. (Zorg)
|
||||
* Updater Changes
|
||||
* Automatic silent and manual update alert prompts are now merged together (Zorg)
|
||||
* Updates will attempt to install even if the user quits the application without relaunching the application update explicitly (Zorg)
|
||||
* Updates can be downloaded in the background automatically but later prompt the user to install them, particularly if Sparkle doesn't have sufficient permission to install them without the user's permission (Zorg)
|
||||
* Authorization now occurs before launching the installer and before terminating the application, which can be canceled by the user cleanly (Zorg)
|
||||
* Sparkle uses the icon of the bundle to update for its authorization dialog. A 32x32 image representation of the icon is needed. (Zorg)
|
||||
* Sudden termination for silent automatic updates isn't disabled anymore (Zorg)
|
||||
* Policy Changes
|
||||
* Non-bare package based updates that are zipped or archived must add sparkle:installationType="package" to the appcast item enclosure (this doesn't apply to bare packages which aren't archived) (Zorg)
|
||||
* We now recommend using sparkle:version and sparkle:shortVersionString top level elements instead of enclosure attributes (#1878) (Zorg)
|
||||
* The link element in an appcast item is now used for directing users to the product's website if they don't meet minimum system requirements (#1877) (Zorg)
|
||||
* Expose why a new update is unavailable and direct user to prior release notes or website info (#1877, #1886) (Zorg)
|
||||
* Add <sparkle:fullReleaseNotesLink> element allowing Sparkle to show a better stylized and full changelog to the user (#2001) (aONe)
|
||||
* Add delegate API allowing applications to show full in-app or offline version history to the user (#1989) (Billy Gray)
|
||||
* Major/Paid Upgrades Enhancements
|
||||
* Latest minor updates are preferred over major updates (specified by sparkle:minimumAutoupdateVersion) (#1850) (Zorg)
|
||||
* Major updates can be skipped with a user confirmation (#1853) (Zorg)
|
||||
* Informational only and critical updates can be specified selectively by app version (#1862)
|
||||
* Add support for posting updates only on specific channels (eg for supporting beta updates) (#1879) (Zorg)
|
||||
* System profiler privacy and transparency (#1690) (Martin Pilkington)
|
||||
* Support getting app icon from asset catalog (#1694) (Charles Srstka)
|
||||
* Don't bring up authorization just because group ID doesn't match (#1830) (Zorg)
|
||||
* Raise minimum system version to macOS 10.11 (Zorg)
|
||||
* Special thanks to developers using early builds of this release in production and contributors for keeping this running (Kornel, Jonas Zaugg, Gwynne Raskind, Jordan Rose, Tony Arnold, Bryan Jones, Christian Tietze, Jakob Egger, and many more)
|
||||
|
||||
Please visit [Sparkle's website](http://sparkle-project.org) for more information on documentation and migration.
|
||||
|
||||
If you are migrating from earlier beta versions of Sparkle 2 and use sandboxing, please re-familiarize yourself with the [Sandboxing guide](https://sparkle-project.org/documentation/sandboxing/). Some of the XPC Services are now optional and integration with XPC Services and code signing have been simplified. The SPUUserDriver protocol for custom user interfaces has been greatly simplified too.
|
||||
|
||||
# 1.27.1
|
||||
|
||||
* Use px instead of pt when specifying font size to fix default font size in WebView from #1962 (regressed in 1.25.0 with WKWebView adoption) (Daniel Jalkut)
|
||||
* Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut)
|
||||
* Add safer handling of applying binary delta files from #1990 (Zorg)
|
||||
* Don't use current date unless necessary when scheduling next update from #1991 (Zorg)
|
||||
* Whitelist about:srcdoc as a safe web URL from #1938, #2007 (Louis Pontoise, Zorg)
|
||||
* Backport not hiding update window on deactivation from #2008 (Zorg)
|
||||
|
||||
# 1.27.0
|
||||
|
||||
* Deprecate not using EdDSA and skip DSA verification when possible in #1892 (Zorg)
|
||||
* Pass http headers and user agent when downloading release notes from #1873 (Zorg)
|
||||
* Fix project warnings from #1893 (Zorg)
|
||||
* Update sample appcast from #1895 (Zorg)
|
||||
* Fix appcast pubDate tag generation in different locales from #1898 (Sungbin Jo)
|
||||
* Create valid xar archives for generating binary delta files from #1906 (Zorg)
|
||||
* Fix a few issues with German localization from #1931 (J-rg)
|
||||
* Fix issues with Russian localizations from #1947 (Konstantin Zamyakin)
|
||||
* Fix issues with Czech localizations from #1943 (Vojtěch Koňařík)
|
||||
* Add an automated workflow that builds and publishes official Sparkle releases (Tony Arnold, Zorg)
|
||||
|
||||
# 1.26.0
|
||||
|
||||
* Flat package support from #1745 (Zorg)
|
||||
* Correct generate_appcast -s command line argument usage help (Lance Lovette)
|
||||
* Fix -f command line argument handling (Lance Lovette)
|
||||
* Fix progress for guided pkg install (Zorg)
|
||||
* Fix XQuartz update failing because NSLog caused issues (Zorg)
|
||||
* Update localization (Vojtěch Koňařík)
|
||||
* Various fixes to SPM logic (Jonas Zaugg)
|
||||
|
||||
# 1.25.0
|
||||
|
||||
* Raise minimum system version to 10.9 (Kornel)
|
||||
* Allow an appcast to prevent the new version from being installed automatically (#1688) (pierswalter)
|
||||
* UI fixes
|
||||
* Show check for updates button only when automatic updates are enabled (Lorena Rangel)
|
||||
* Don't initialize the webview if we don't show release notes (Tobias Fonfara)
|
||||
* Keep skip button available if there is a minimum autoupdate version (Zorg)
|
||||
* Fix automatic updates checkbox state when not showing release notes (Zorg)
|
||||
* Fix edge cases with hiding alert buttons and using "Install Later" (Zorg)
|
||||
* Re-add setting WebUIDelegate fix for legacy web view (Zorg)
|
||||
* Adopt WKWebView for 1.x (Zorg)
|
||||
* Add auto layout constraints to SUAutomaticUpdateAlert window (Zorg)
|
||||
* Made buttons wide enough to display the full text. Made window wide enough to display the widened buttons (el, fi, ru, uk) (Piers Uso Walter)
|
||||
* Remove max size from update alert. (George Nachman)
|
||||
* Integrate generate_keys export/import options changes from #1730 (Zorg)
|
||||
* Add `—release-notes-url-prefix` support to localized release notes (Adam Tharani)
|
||||
* Translations
|
||||
* Enable base internalization for alert xibs (Zorg)
|
||||
* Capitalizes french translation of "Vous utilisez actuellement..." ("You are currently running...") (Micah Moore)
|
||||
* Fix and cleanup Hebrew, Catalan, Finnish localizations (Zorg)
|
||||
* Remove non-english localizations from TestApplication (Zorg)
|
||||
* Fix catch-22 Swift Package Manager binary target (Jonas Zaugg)
|
||||
* Add explicit dependencies to fix Xcode linking errors (Kornel)
|
||||
* Add phased rollouts feature to automatic update driver too (Zorg)
|
||||
* Remove hiding skip button and retitling later button (Zorg)
|
||||
* Deprecate installUpdatesIfAvailable (Zorg)
|
||||
* Apply custom headers to app download (Geraint White)
|
||||
|
||||
# 1.24.0
|
||||
|
||||
* Prioritize UserDefaults when fetching value for EnableAutomaticChecks (Nicolas Bosi)
|
||||
* Improve best appcast item selection handling (Ian Bytchek)
|
||||
* Create lockfile for improved compatibility with 3rd party updaters (CoreCode)
|
||||
* Enable SPM support via binary target (Jonas Zaugg)
|
||||
* `generate_appcast` improvements:
|
||||
* follow symbolic links (Denis Dzyubenko)
|
||||
* update the release notes element’s URL when required (Brad Andalman)
|
||||
* Added output filename option to generate_appcast (Brad Andalman)
|
||||
* Added —release-notes-url-prefix to generate_appcast (Brad Andalman)
|
||||
* Command line option to provide a download url prefix is now parsed and set on each archive item (Dominik H)
|
||||
* Added help command line option (Dominik H)
|
||||
* Locale updates:
|
||||
* Update zh_CN localization (柳东原 · Dongyuan Liu)
|
||||
* Update Sparkle.strings (Vojtěch Koňařík)
|
||||
* Update Croatian (#1603) (milotype)
|
||||
* Update SUUpdateAlert.xib (DanielFirlej)
|
||||
* fix: read SUAutomaticallyUpdate from Info.plist (Trevor DeVore)
|
||||
* Fix casting Boolean to BOOL on Apple Silicon (Kevin Wojniak)
|
||||
* Use build matrix to test on multiple Xcode versions (Rajiv Shah)
|
||||
* Set UpdateAlert and AutomaticUpdateAlert window's fullscreen collectionBehavior to NSWindowCollectionBehaviorFullScreenAuxiliary to allow them to present on top of the Main App's window if it's fullscreen. (Micah Moore)
|
||||
* Fixed error about "about:blank" release notes (Louis Pontoise)
|
||||
* Support App Store URL scheme in release note webview (Bi11)
|
||||
* Use the SHA-256 hash of the archive as the cache path (Nate Weaver)
|
||||
* Don't return an optional from the FileHandle method (Nate Weaver)
|
||||
* Added URL+Hashing (Nate Weaver)
|
||||
|
||||
# 1.23.0
|
||||
|
||||
* Support generating appcast with localizations (#1499) (Alik Vovkotrub)
|
||||
* Support versions with git commit SHA (#1504) (Alec Larson)
|
||||
* Hide "Skip..." and "Remind..." buttons when they're not relevant (#1480) (Kenneth Johnsen)
|
||||
* Preserve Finder tags while updating apps (#1512) (CoreCode)
|
||||
* Read-only update alert dialog formatting improvements (#1515) (Quinn Taylor)
|
||||
* Check if `SUBundleName` is set before normalizing (Jake Fenton)
|
||||
* `NSInteger` cast warning on Xcode 11 (Marga Keuvelaar)
|
||||
* Correct appcast file extension (Tom Vos)
|
||||
* Update Sparkle.strings (Emir Sarı)
|
||||
* Fix spelling (#1508) (Frank Chiarulli Jr)
|
||||
|
||||
# 1.22.0
|
||||
|
||||
* Enabled "Hardened Runtime" build option for Apple's notarization requirement
|
||||
* Add delegate methods to suppress update alerts (George Nachman)
|
||||
* Improved error when running from translocated location (Michael Buckley)
|
||||
* Add phased rollout feature (#1381) (Fabian Jäger)
|
||||
* Ignore non-standard permissions in delta updates instead of failing the build (Kornel Lesiński)
|
||||
* Notify user when installed version is newer than the latest in the appcast (CoreCode)
|
||||
* Reset timers after computer sleep (CoreCode)
|
||||
* Block-based alternatives to `NSInvocation`-based delegate methods (Fabian Jäger)
|
||||
* Add delegate `userDidSkipThisVersion` (BobZombie, Leo Natan, bono yusuke)
|
||||
* Pass item to updaterShouldShowUpdateAlertForScheduledUpdate delegate method (George Nachman)
|
||||
* Support providing private key as argument in `generate_appcast` (Yakuhzi, marchyang)
|
||||
* Separate the ed25519 sources into a new static library (Tony Arnold)
|
||||
* Disambiguate signing error messages (Nate Weaver)
|
||||
* Use `XMLNode.Options.nodePrettyPrint` in `generate_appcast` instead of trying to add whitespace manually (fumoboy007)
|
||||
* Annotate SUHost for nullability (Michael Buckley)
|
||||
* Use SUAVAILABLE macro (Christiaan Hofman)
|
||||
* Fix warnings when using modules (nivekkagicom)
|
||||
* Correction of Czech localization inconsistency (#1403) (vojtakonarik)
|
||||
* BR locale fix (BR Lingo)
|
||||
* Update Japanese localization (fujisoft)
|
||||
* French Sparkle.strings (Jean-Baptiste)
|
||||
|
||||
# 1.21.3
|
||||
|
||||
* Losslessly reduced the size of PNG (Barijaona Ramaholimihaso)
|
||||
* Catch exceptions from subcommands (Julian Mayer)
|
||||
* `generate_appcast` can sign any bundles instead of just apps (Nate Weaver)
|
||||
* Check that effectiveAppearance is being observed before calling removeObserver (Pierluigi)
|
||||
|
||||
# 1.21.2
|
||||
|
||||
* Allow EdDSA for delta updates, too (Kornel)
|
||||
* Warning fixes (Brian Bergstrand)
|
||||
* Improvements to release notes view context menu and dark mode (Bi11)
|
||||
|
||||
# 1.21.0
|
||||
|
||||
* Added support EdDSA (ed25519) signatures (Kornel)
|
||||
* DSA signatures are considered outdated, and Apple's `Security.framework` only supports weaker SHA-1-based DSA.
|
||||
* Both old DSA and new EdDSA are still supported (and one app can use both), but new applications should use EdDSA only, and we recommend migrating away from DSA signatures.
|
||||
* `generate_keys` is now a Swift tool that stores EdDSA private keys in the Keychain
|
||||
* Existing apps can continue using their old DSA keys, but we've dropped support for generation of old DSA keys
|
||||
* `sign_update` is now a Swift tool that signs using EdDSA from private keys in the Keychain
|
||||
* The old DSA-based signing script has been moved to `bin/old_dsa_scripts`
|
||||
* The old DSA-based signing script has been fixed to work on pre-10.13 systems (Thomas Tempelmann)
|
||||
* `generate_appcast` has been updated to support EdDSA signatures
|
||||
* It can sign both DSA (if `dsa_priv.pem` file is specified) and EdDSA (from Keychain)
|
||||
* The tool now uses Caches directory and doesn't generate unnecessary delta files
|
||||
* Fixed verification of delta updates on filesystems that change permissions of symlinks
|
||||
* Fixed `NSURLSession` leak (Michael Ehrmann)
|
||||
|
||||
# 1.20.0
|
||||
|
||||
* `generate_appcast` option to read private key directly from the keychain (Tamás Lustyik)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"1.27.1": "https://github.com/sparkle-project/Sparkle/releases/download/1.27.1/Sparkle-1.27.1.tar.xz", "2.0.0-beta.6": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-beta.6/Sparkle-2.0.0-beta.6.tar.xz", "2.0.0-rc.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-rc.1/Sparkle-2.0.0-rc.1.tar.xz", "2.0.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0/Sparkle-2.0.0.tar.xz", "2.1.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.1/Sparkle-2.1.0-beta.1.tar.xz", "2.1.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.2/Sparkle-2.1.0-beta.2.tar.xz", "2.1.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0/Sparkle-2.1.0.tar.xz", "2.2.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.1/Sparkle-2.2.0-beta.1.tar.xz", "2.2.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.2/Sparkle-2.2.0-beta.2.tar.xz", "2.2.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0/Sparkle-2.2.0.tar.xz", "2.2.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.1/Sparkle-2.2.1.tar.xz", "2.2.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.2/Sparkle-2.2.2.tar.xz", "2.3.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.1/Sparkle-2.3.0-beta.1.tar.xz", "2.3.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.2/Sparkle-2.3.0-beta.2.tar.xz", "2.3.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0/Sparkle-2.3.0.tar.xz", "2.3.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.1/Sparkle-2.3.1.tar.xz", "2.3.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.2/Sparkle-2.3.2.tar.xz", "2.4.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.1/Sparkle-2.4.0-beta.1.tar.xz", "2.4.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.2/Sparkle-2.4.0-beta.2.tar.xz", "2.4.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0/Sparkle-2.4.0.tar.xz", "2.4.1-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.1-beta.1/Sparkle-2.4.1-beta.1.tar.xz"}
|
||||
@@ -3,4 +3,4 @@
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
SWIFT_OBJC_BRIDGING_HEADER = $(PRODUCT_NAME)/Bridging-Header.h
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_EXTERNALLY=1
|
||||
@@ -1 +0,0 @@
|
||||
// BinaryDelta tool only
|
||||
@@ -1,51 +1,123 @@
|
||||
// Common
|
||||
|
||||
// Set to 1 or 0 to build and bundle the provided XPC Services in Sparkle framework
|
||||
// (Note for testing purposes for sandboxed apps, disabling all XPC services and then re-enabling them
|
||||
// may not work on the same login session due to a system caching issue. See comments for setting FRAMEWORK_VERSION for more info)
|
||||
SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE = 1
|
||||
// Embedding the downloader service also enables building legacy WebKit1 support
|
||||
SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE = 1
|
||||
SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE = 0
|
||||
SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE = 0
|
||||
|
||||
// Set to 0 to disable building legacy 1.x SUUpdater stub
|
||||
SPARKLE_BUILD_LEGACY_SUUPDATER = 1
|
||||
|
||||
// Set to 0 to not build legacy DSA signing support
|
||||
// Don't disable this if you haven't migrated to EdDSA yet or if you support updating
|
||||
// other developer's applications that haven't migrated to EdDSA yet
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_LEGACY_DSA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build legacy DSA signing support for generate_appcast
|
||||
// Don't disable this if you still have items in your appcast feed that still need DSA signatures
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build legacy / xar based delta update support
|
||||
SPARKLE_BUILD_LEGACY_DELTA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build bzip2 support for version 3 delta based updates
|
||||
SPARKLE_BUILD_BZIP2_DELTA_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build support for package (pkg) based installations
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_PACKAGE_SUPPORT = 1
|
||||
|
||||
// Set to 0 to not build support for extracting updates from disk images (dmgs)
|
||||
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
|
||||
SPARKLE_BUILD_DMG_SUPPORT = 1
|
||||
|
||||
// Set to 0 to only build all non-UI bits (which means client uses a custom SPUUserDriver)
|
||||
SPARKLE_BUILD_UI_BITS = 1
|
||||
|
||||
// Set to 0 to not use and copy localization / string files to framework
|
||||
SPARKLE_COPY_LOCALIZATIONS = 1
|
||||
|
||||
// Compilation flags for Swift tools and unit tests
|
||||
// If SPARKLE_BUILD_LEGACY_DELTA_SUPPORT is set to 0, remove -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT
|
||||
// If GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT is set to 0, remove -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT
|
||||
// If SPARKLE_BUILD_PACKAGE_SUPPORT is set to 0, remove -DSPARKLE_BUILD_PACKAGE_SUPPORT
|
||||
// If SPARKLE_BUILD_DMG_SUPPORT is set to 0, remove -DSPARKLE_BUILD_DMG_SUPPORT
|
||||
OTHER_SWIFT_FLAGS_COMMON = -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT -DSPARKLE_BUILD_PACKAGE_SUPPORT -DSPARKLE_BUILD_DMG_SUPPORT
|
||||
|
||||
// Minimum supported macOS version
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13
|
||||
|
||||
// Supported architectures
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
|
||||
// Default Sparkle names
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_INSTALLER_PROGRESS_TOOL_NAME = Updater
|
||||
|
||||
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
|
||||
// if your app has a downgrade function or URL handler, turn this on
|
||||
SPARKLE_AUTOMATED_DOWNGRADES = 0
|
||||
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
// following on to always reset the name back to "MyApp":
|
||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_ICON_NAME = AppIcon
|
||||
|
||||
SPARKLE_VERSION_MAJOR = 2
|
||||
SPARKLE_VERSION_MINOR = 0
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
|
||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
// NSURLSession requirements
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
// Set these if you want to use custom name for the XPC Services
|
||||
// For the Installer one in particular, this name may show up in an authorization prompt
|
||||
// when installing an update that requires authorization.
|
||||
INSTALLER_CONNECTION_NAME = InstallerConnection
|
||||
INSTALLER_STATUS_NAME = InstallerStatus
|
||||
INSTALLER_LAUNCHER_NAME = Installer
|
||||
DOWNLOADER_NAME = Downloader
|
||||
|
||||
// Set this to your own prefix if you want to use XPC Service bundle IDs with different prefix
|
||||
XPC_SERVICE_BUNDLE_ID_PREFIX = org.sparkle-project
|
||||
|
||||
INSTALLER_CONNECTION_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerConnection
|
||||
INSTALLER_STATUS_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerStatus
|
||||
INSTALLER_LAUNCHER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerLauncher
|
||||
DOWNLOADER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.Downloader
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\"
|
||||
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
|
||||
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
|
||||
// following on to always reset the name back to "MyApp"
|
||||
// If you are using this option to change the name of your app, you should
|
||||
// disable the option again when you no longer need it
|
||||
// Note this option is only supported for regular application updates and not plug-ins
|
||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_ICON_NAME = AppIcon
|
||||
|
||||
// If you change any of these version details, you must increase CURRENT_PROJECT_VERSION
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_MAJOR = 2
|
||||
SPARKLE_VERSION_MINOR = 4
|
||||
SPARKLE_VERSION_PATCH = 1
|
||||
|
||||
// This should be in SemVer format or empty, ie. "-beta.1"
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_SUFFIX = -beta.1
|
||||
CURRENT_PROJECT_VERSION = 2026
|
||||
|
||||
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPU_OBJC_DIRECT=__attribute__((objc_direct)) SPU_OBJC_DIRECT_MEMBERS=__attribute__((objc_direct_members)) SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_COPY_LOCALIZATIONS=$(SPARKLE_COPY_LOCALIZATIONS) SPARKLE_BUILD_LEGACY_SUUPDATER=$(SPARKLE_BUILD_LEGACY_SUUPDATER) SPARKLE_BUILD_PACKAGE_SUPPORT=$(SPARKLE_BUILD_PACKAGE_SUPPORT) SPARKLE_BUILD_DMG_SUPPORT=$(SPARKLE_BUILD_DMG_SUPPORT) SPARKLE_BUILD_LEGACY_DELTA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DELTA_SUPPORT) SPARKLE_BUILD_BZIP2_DELTA_SUPPORT=$(SPARKLE_BUILD_BZIP2_DELTA_SUPPORT) SPARKLE_BUILD_LEGACY_DSA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DSA_SUPPORT) GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT=$(GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" MARKETING_VERSION=\"$(MARKETING_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_NAME=\"${INSTALLER_LAUNCHER_NAME}\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_LAUNCHER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE) INSTALLER_CONNECTION_NAME=\"${INSTALLER_CONNECTION_NAME}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_CONNECTION_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE) INSTALLER_STATUS_NAME=\"${INSTALLER_STATUS_NAME}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" INSTALLER_STATUS_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE) DOWNLOADER_NAME=\"${DOWNLOADER_NAME}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\" DOWNLOADER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE)
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
SDKROOT = macosx
|
||||
ENABLE_HARDENED_RUNTIME = YES
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
COMBINE_HIDPI_IMAGES = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES
|
||||
COMBINE_HIDPI_IMAGES = NO
|
||||
|
||||
// Enable warnings
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
|
||||
@@ -88,11 +160,5 @@ 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.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-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments $(WARNING_CFLAGS_EXTRA)
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso -Wno-direct-ivar-access -Wno-declaration-after-statement -Werror=undef
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
|
||||
SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
// Debug only
|
||||
|
||||
SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 1
|
||||
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
@@ -15,5 +13,6 @@ DEBUG_INFORMATION_FORMAT = dwarf
|
||||
ENABLE_TESTABILITY = YES
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
ONLY_ACTIVE_ARCH = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
// Release only
|
||||
|
||||
SPARKLE_ALLOW_ARBITRARY_HTTP_LOADS = 0
|
||||
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
@@ -13,7 +11,10 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = s
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=0
|
||||
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
|
||||
DEAD_CODE_STRIPPING = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
DEPLOYMENT_POSTPROCESSING = YES
|
||||
@@ -3,5 +3,7 @@
|
||||
INFOPLIST_FILE = Downloader/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${DOWNLOADER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${DOWNLOADER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${DOWNLOADER_NAME}
|
||||
CODE_SIGN_ENTITLEMENTS = Downloader/${DOWNLOADER_BUNDLE_ID}.entitlements
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -1,4 +1,2 @@
|
||||
// Downloader Debug
|
||||
#include "ConfigDownloader.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -4,7 +4,15 @@ DYLIB_INSTALL_NAME_BASE = @rpath
|
||||
DYLIB_COMPATIBILITY_VERSION = 1.6
|
||||
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
WRAPPER_EXTENSION = framework
|
||||
FRAMEWORK_VERSION = A
|
||||
|
||||
// Sparkle 2 used to support developers embedding XPC Services in their own app bundle
|
||||
// However the Sparkle framework now bundles these XPC Services. Unfortunately this causes
|
||||
// a cache conflict in the system from upgrading from previous to newer versions of Sparkle, and
|
||||
// XPC Services inside Sparkle may not launch (a system reboot would fix this though).
|
||||
// The system cache seems to depend on the Sparkle file path,
|
||||
// so as a better workaround we have changed the FRAMEWORK_VERSION from A to B
|
||||
FRAMEWORK_VERSION = B
|
||||
|
||||
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
|
||||
SKIP_INSTALL = YES
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigFramework.xcconfig"
|
||||
|
||||
// Strip all non-global symbols (including debug symbols)
|
||||
STRIP_STYLE = non-global
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerConnection/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_CONNECTION_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_CONNECTION_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_CONNECTION_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -1,5 +1,3 @@
|
||||
// InstallerConnection Debug
|
||||
|
||||
#include "ConfigInstallerConnection.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerLauncher/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_LAUNCHER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_LAUNCHER_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_LAUNCHER_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -1,4 +1,2 @@
|
||||
// Installer Launcher Debug
|
||||
#include "ConfigInstallerLauncher.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
INFOPLIST_FILE = Sparkle/InstallerProgress/InstallerProgress-Info.plist
|
||||
PRODUCT_NAME = $(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
@@ -3,4 +3,6 @@
|
||||
INFOPLIST_FILE = InstallerStatus/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_STATUS_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_STATUS_BUNDLE_ID}
|
||||
PRODUCT_NAME = ${INSTALLER_STATUS_NAME}
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
CLANG_MODULES_AUTOLINK = NO
|
||||
@@ -1,5 +1,3 @@
|
||||
// InstallerStatus Debug
|
||||
|
||||
#include "ConfigInstallerStatus.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -3,3 +3,4 @@
|
||||
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
@@ -4,3 +4,4 @@ INFOPLIST_FILE = sparkle-cli/Info.plist
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.sparkle-cli
|
||||
PRODUCT_NAME = sparkle
|
||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks/
|
||||
ENABLE_HARDENED_RUNTIME = NO
|
||||
@@ -1,2 +1,2 @@
|
||||
SWIFT_VERSION = 4.0
|
||||
SWIFT_VERSION = 5
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
@@ -1 +1,2 @@
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Owholemodule
|
||||
SWIFT_OPTIMIZATION_LEVEL = -O
|
||||
SWIFT_COMPILATION_MODE = wholemodule
|
||||
@@ -6,4 +6,4 @@ ASSETCATALOG_COMPILER_APPICON_NAME = $(SPARKLE_ICON_NAME)
|
||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
|
||||
CODE_SIGN_ENTITLEMENTS = TestApplication/Sparkle-Test-App.entitlements
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10
|
||||
ENABLE_HARDENED_RUNTIME = NO
|
||||
@@ -1,4 +1,2 @@
|
||||
// Test Application Debug
|
||||
#include "ConfigTestApp.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -4,3 +4,4 @@ INFOPLIST_FILE = TestAppHelper/Info.plist
|
||||
WRAPPER_EXTENSION = xpc
|
||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../../../../Frameworks
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.TestAppHelper
|
||||
ENABLE_HARDENED_RUNTIME = NO
|
||||
@@ -1,4 +1,2 @@
|
||||
// Test Application Helper Debug
|
||||
#include "ConfigTestAppHelper.xcconfig"
|
||||
|
||||
CODE_SIGN_IDENTITY = -
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
INFOPLIST_FILE = UITests/UITests-Info.plist
|
||||
WRAPPER_EXTENSION = xctest
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
ENABLE_HARDENED_RUNTIME = NO
|
||||
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
|
||||
@@ -9,6 +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
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_TESTS=1 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright © 2019 Sparkle Project. All rights reserved.
|
||||
|
||||
#include "bsdiff-Shared.xcconfig"
|
||||
|
||||
// Disable asserts for performance
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) NDEBUG=1
|
||||
@@ -12,3 +12,6 @@ ALWAYS_SEARCH_USER_PATHS = NO
|
||||
|
||||
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
|
||||
WARNING_CFLAGS = $(inherited) -Wno-cast-qual -Wno-conversion -Wno-sign-conversion
|
||||
|
||||
// Disable dead stores analyzer warning
|
||||
CLANG_ANALYZER_DEADCODE_DEADSTORES = NO
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys
|
||||
|
||||
# Ignore the first version line starting with # x.y.z..
|
||||
# and print everything until the second version line starting with # x.y.z..
|
||||
|
||||
hit_first_changelog_note = False
|
||||
with open("CHANGELOG", "r") as changelog_file:
|
||||
for line in changelog_file:
|
||||
if line.startswith("#"):
|
||||
if hit_first_changelog_note:
|
||||
# We are done with printing changes
|
||||
break
|
||||
else:
|
||||
# We haven't hit an important changelog line yet, so continue
|
||||
continue
|
||||
|
||||
if not hit_first_changelog_note and len(line.strip()) == 0:
|
||||
continue
|
||||
|
||||
hit_first_changelog_note = True
|
||||
sys.stdout.write(line)
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# If Carthage is trying to build us, it won't preserve code signing information from our bundled tools properly
|
||||
# Building Sparkle from source with Carthage is thus not supported
|
||||
if [ "$CARTHAGE" = "YES" ]; then
|
||||
echo "Error: Building Sparkle from source using Carthage is not supported. Please visit https://sparkle-project.org/documentation/ for proper Carthage integration."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create symlinks to our helper tools in Sparkle framework bundle
|
||||
# so URLForAuxiliaryExecutable: will pick up the tools. Doing this is supported in the Code Signing in Depth guide.
|
||||
|
||||
FRAMEWORK_PATH="${TARGET_BUILD_DIR}"/"${FULL_PRODUCT_NAME}"
|
||||
|
||||
ln -h -f -s "Versions/Current/""${SPARKLE_RELAUNCH_TOOL_NAME}" "${FRAMEWORK_PATH}"/"${SPARKLE_RELAUNCH_TOOL_NAME}"
|
||||
ln -h -f -s "Versions/Current/""${SPARKLE_INSTALLER_PROGRESS_TOOL_NAME}".app "${FRAMEWORK_PATH}"/"${SPARKLE_INSTALLER_PROGRESS_TOOL_NAME}".app
|
||||
@@ -1,56 +1,188 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
# If using cocoapods, sanity check that the Podspec version matches the Sparkle version
|
||||
if [ -x "$(command -v pod)" ]; then
|
||||
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
|
||||
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
||||
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Tests the code signing validity of the extracted products within the provided path.
|
||||
# This guards against our archives being corrupt / created incorrectly.
|
||||
function verify_code_signatures() {
|
||||
verification_directory="$1"
|
||||
check_aux_apps="$2"
|
||||
|
||||
if [[ -z "$verification_directory" ]]; then
|
||||
echo "Provided verification directory does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Search the current directory for all instances of the framework to verify them (XCFrameworks can have multiple copies of a framework for different platforms).
|
||||
find "${verification_directory}" -name "Sparkle.framework" -type d -exec codesign --verify -vvv --deep {} \;
|
||||
|
||||
if [ "$check_aux_apps" = true ] ; then
|
||||
codesign --verify -vvv --deep "${verification_directory}/sparkle.app"
|
||||
codesign --verify -vvv --deep "${verification_directory}/Sparkle Test App.app"
|
||||
fi
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/BinaryDelta"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/generate_appcast"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/sign_update"
|
||||
codesign --verify -vvv --deep "${verification_directory}/bin/generate_keys"
|
||||
}
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
rm -f "Sparkle-$MARKETING_VERSION.tar.xz"
|
||||
rm -f "Sparkle-$MARKETING_VERSION.tar.bz2"
|
||||
rm -f "Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/INSTALL.markdown" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/INSTALL" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/INSTALL" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/SparkleCore.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.xcframework" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
if [[ "$SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE" -eq 1 ]]; then
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Entitlements"
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements"
|
||||
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging/Entitlements/$DOWNLOADER_NAME.entitlements"
|
||||
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements/$DOWNLOADER_NAME.entitlements"
|
||||
fi
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_LAUNCHER_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$DOWNLOADER_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_CONNECTION_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
|
||||
cp "$SRCROOT/Downloader/$DOWNLOADER_BUNDLE_ID.entitlements" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
|
||||
# because missing dSYMs in a release build SHOULD trigger a build failure
|
||||
if [ "$CONFIGURATION" = "Release" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/SparkleCore.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_LAUNCHER_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$DOWNLOADER_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_CONNECTION_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/$INSTALLER_STATUS_BUNDLE_ID.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/XPCServices"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Autoupdate.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Updater.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${INSTALLER_LAUNCHER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/${DOWNLOADER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
|
||||
fi
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
if [ -x "$(command -v xz)" ]; then
|
||||
XZ_EXISTS=1
|
||||
else
|
||||
XZ_EXISTS=0
|
||||
fi
|
||||
|
||||
rm -rf "/tmp/sparkle-extract"
|
||||
mkdir -p "/tmp/sparkle-extract"
|
||||
|
||||
# Sorted file list groups similar files together, which improves tar compression
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
|
||||
if [ "$XZ_EXISTS" -eq 1 ] ; then
|
||||
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$MARKETING_VERSION.tar.xz"
|
||||
|
||||
# Copy archived distribution for CI
|
||||
cp -f "../Sparkle-$MARKETING_VERSION.tar.xz" "../sparkle-dist.tar.xz"
|
||||
|
||||
# Extract archive for testing binary validity
|
||||
tar -xf "../Sparkle-$MARKETING_VERSION.tar.xz" -C "/tmp/sparkle-extract"
|
||||
else
|
||||
# Fallback to bz2 compression if xz utility is not available
|
||||
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$MARKETING_VERSION.tar.bz2" --files-from=-
|
||||
|
||||
# Extract archive for testing binary validity
|
||||
tar -xf "../Sparkle-$MARKETING_VERSION.tar.bz2" -C "/tmp/sparkle-extract"
|
||||
fi
|
||||
|
||||
# Test code signing validity of the extracted products
|
||||
# This guards against our archives being corrupt / created incorrectly
|
||||
verify_code_signatures "/tmp/sparkle-extract" true
|
||||
|
||||
rm -rf "/tmp/sparkle-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
# Get latest git tag
|
||||
cd "$SRCROOT"
|
||||
latest_git_tag=$( git describe --tags --abbrev=0 || true )
|
||||
|
||||
if [ -n "$latest_git_tag" ] ; then
|
||||
# Generate zip containing the xcframework for SPM
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
mkdir -p "/tmp/sparkle-spm-extract"
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
# rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
|
||||
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
# Test code signing validity of the extracted Swift package
|
||||
# This guards against our archives being corrupt / created incorrectly
|
||||
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
|
||||
verify_code_signatures "/tmp/sparkle-spm-extract" false
|
||||
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
cd "$SRCROOT"
|
||||
|
||||
# Check semantic versioning
|
||||
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
|
||||
echo "Tag $latest_git_tag follows semantic versioning"
|
||||
else
|
||||
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate new Package manifest, podspec, and carthage files
|
||||
cd "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
|
||||
cp "$SRCROOT/Carthage-dev.json" "$CONFIGURATION_BUILD_DIR"
|
||||
fi
|
||||
|
||||
if [ -z "$latest_git_tag" ] ; then
|
||||
echo "warning: No git repository found so skipping updating package management files"
|
||||
elif [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
|
||||
# is equivalent to shasum -a 256 FILE
|
||||
spm_checksum=$(swift package compute-checksum "Sparkle-for-Swift-Package-Manager.zip")
|
||||
rm -rf ".build"
|
||||
sed -E -i '' -e "/let tag/ s/\".+\"/\"$latest_git_tag\"/" -e "/let version/ s/\".+\"/\"$MARKETING_VERSION\"/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
|
||||
cp "Package.swift" "$SRCROOT"
|
||||
echo "Package.swift updated with the following values:"
|
||||
echo "Version: $MARKETING_VERSION"
|
||||
echo "Tag: $latest_git_tag"
|
||||
echo "Checksum: $spm_checksum"
|
||||
|
||||
sed -E -i '' -e "/s\.version.+=/ s/\".+\"/\"$MARKETING_VERSION\"/" "Sparkle.podspec"
|
||||
|
||||
"$SRCROOT/Configurations/update-carthage.py" "Carthage-dev.json" "$MARKETING_VERSION"
|
||||
cp "Sparkle.podspec" "$SRCROOT"
|
||||
# Note the Carthage-dev.json file will finally be copied to the website repo in Carthage/Sparkle.json in the end
|
||||
cp "Carthage-dev.json" "$SRCROOT"
|
||||
echo "Sparkle.podspec and Carthage-dev.json updated with following values:"
|
||||
echo "Version: $MARKETING_VERSION"
|
||||
else
|
||||
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
|
||||
fi
|
||||
|
||||
if [ "$XZ_EXISTS" -ne 1 ] ; then
|
||||
echo "WARNING: xz compression is used for official releases but bz2 is being used instead because xz tool is not installed on your system."
|
||||
fi
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
fi
|
||||
Loaded 100 of 706 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user