Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dec304f64 | ||
|
|
8acd915b7b | ||
|
|
eb36100388 | ||
|
|
fb22a01a08 | ||
|
|
fc468771c1 | ||
|
|
42dbf94738 | ||
|
|
86a0ca3883 | ||
|
|
ddb53f330d | ||
|
|
9dbaae64f1 | ||
|
|
d2f4687333 | ||
|
|
143045d673 | ||
|
|
d67351cb62 | ||
|
|
07d2897250 | ||
|
|
625c942561 | ||
|
|
bb299d075b | ||
|
|
73229f84f7 | ||
|
|
8152516b7f | ||
|
|
96baf2b2ce | ||
|
|
ed5dca3423 | ||
|
|
3a5c620b60 | ||
|
|
23ae527b96 | ||
|
|
2268f96759 | ||
|
|
a3407a2dbf | ||
|
|
88933a1e65 | ||
|
|
c3d8e4bbc5 | ||
|
|
f70c2a15b1 | ||
|
|
4eb518de7e | ||
|
|
077c64419f | ||
|
|
1195d4b5d2 | ||
|
|
c7a7704f3b | ||
|
|
64af6d04c2 | ||
|
|
0af27ea783 | ||
|
|
c36413ce46 | ||
|
|
13b9081873 | ||
|
|
3dccca8044 | ||
|
|
ed3eab64d2 | ||
|
|
ee257c4070 | ||
|
|
bfec7a82c0 | ||
|
|
4cd472abe6 | ||
|
|
39268a13e5 | ||
|
|
4864dfb5aa | ||
|
|
71125e3d16 | ||
|
|
779d16e5a7 | ||
|
|
ee2e7fb46b | ||
|
|
d350cf33e0 | ||
|
|
20be93e96b | ||
|
|
668e258cff | ||
|
|
20f90f1544 | ||
|
|
6dbb0d9988 | ||
|
|
f700c96e47 | ||
|
|
626d2c96f5 | ||
|
|
5db4e1505b | ||
|
|
115686cd07 | ||
|
|
e2fc8b4258 | ||
|
|
99f34299f1 | ||
|
|
fdf79bc3a6 | ||
|
|
eb810c7d8f | ||
|
|
38af7cd8cd | ||
|
|
09889d01b1 | ||
|
|
5f2ebb8edf | ||
|
|
ac4ef7d9a0 | ||
|
|
cc7c0ae052 | ||
|
|
b8dc5b3f3d | ||
|
|
43e96f7ee8 | ||
|
|
dbff23ea9d | ||
|
|
ed97e6cb75 | ||
|
|
492664c611 | ||
|
|
fdf07644d0 | ||
|
|
092feba9f9 | ||
|
|
91c813b6ab | ||
|
|
1ced9c428a | ||
|
|
16de00d81d | ||
|
|
3f637c9674 | ||
|
|
4a4dc3629f | ||
|
|
6437e0448a | ||
|
|
c77cd49036 | ||
|
|
9d7e4d676d | ||
|
|
1aa0ee8152 | ||
|
|
9944f2496c | ||
|
|
33907ec4ed | ||
|
|
7892e41b27 | ||
|
|
53983d9452 | ||
|
|
f3a151d473 | ||
|
|
bb624ffa59 | ||
|
|
2963f788e1 | ||
|
|
9017962ab9 | ||
|
|
dd0805c05b | ||
|
|
e4c3c29a85 | ||
|
|
be1e86174a | ||
|
|
8b56fba39b | ||
|
|
db232a263b | ||
|
|
4d952e9961 | ||
|
|
64fd27d918 | ||
|
|
666e86b0bb | ||
|
|
601b4a7a7f | ||
|
|
1316707136 | ||
|
|
e485baf8b8 | ||
|
|
d71fe4a17d | ||
|
|
f990f5fcfc | ||
|
|
07ac154e2e | ||
|
|
48eb25fbf3 | ||
|
|
914bf9e333 | ||
|
|
271b7a1daf | ||
|
|
c11c660f22 | ||
|
|
0e2fe68399 | ||
|
|
852965d824 | ||
|
|
e2c60be805 | ||
|
|
71e15f4b1d | ||
|
|
8a4e4aea2c | ||
|
|
8fea6670c2 | ||
|
|
19fcca11f0 | ||
|
|
fd082a93d4 | ||
|
|
b9e8830f60 | ||
|
|
8576eb7cad | ||
|
|
cf4c02f1b0 | ||
|
|
8e57ca9284 | ||
|
|
3c2f24c340 | ||
|
|
7a9ff3de48 | ||
|
|
a3d4d9fac4 | ||
|
|
a937fa0a17 | ||
|
|
99be33d83b | ||
|
|
0132377a2a | ||
|
|
7fdedad68e | ||
|
|
aa7c46ba4f | ||
|
|
d263bf4fd0 | ||
|
|
bdb3dd8c36 | ||
|
|
c8ff1c0453 | ||
|
|
bb40663d37 | ||
|
|
b8588543cf | ||
|
|
cc332de4d1 | ||
|
|
d6b1c7de54 | ||
|
|
3a3f46f2c1 | ||
|
|
1ae0999082 | ||
|
|
c265e3f7bf | ||
|
|
2faf8ccdd2 | ||
|
|
2f724659a7 | ||
|
|
8cca51d08b | ||
|
|
c9fa1142c9 | ||
|
|
445cc55794 | ||
|
|
013e60204d | ||
|
|
b8fecf1f36 | ||
|
|
b319fb50f9 | ||
|
|
698e737b56 | ||
|
|
0be862708f | ||
|
|
1c8d54166b | ||
|
|
77511c8f19 | ||
|
|
d9a3afb869 | ||
|
|
34a78d59fc | ||
|
|
b95008e248 | ||
|
|
317423ae78 | ||
|
|
27cb8e66fe | ||
|
|
28e8a1fdaf | ||
|
|
f43c284f14 | ||
|
|
cd3d7d9f98 | ||
|
|
864044e44e | ||
|
|
48f18d000c | ||
|
|
d0adc0af39 | ||
|
|
64d95bb36f | ||
|
|
a52cbc38a1 | ||
|
|
530a90cb73 | ||
|
|
168c769eb0 | ||
|
|
5b3577c14c | ||
|
|
b9c664687d | ||
|
|
2a3e88bf96 | ||
|
|
004ac3f9ae | ||
|
|
8a04cc726f | ||
|
|
9f2604b888 | ||
|
|
0171ab2d84 | ||
|
|
c3ffd7f739 | ||
|
|
91e929cbf9 | ||
|
|
9671f7f52d | ||
|
|
2668d18266 | ||
|
|
a4bdbb7ab3 | ||
|
|
a11b1209a9 | ||
|
|
625f229a65 | ||
|
|
0d52e27968 | ||
|
|
674b2238b8 | ||
|
|
4eb2e9af00 | ||
|
|
b64cee8055 | ||
|
|
3163b6a729 | ||
|
|
7b61cdd8f8 | ||
|
|
b29bbdd14b | ||
|
|
5b79151690 | ||
|
|
c315a66151 | ||
|
|
b1d7c3ade9 | ||
|
|
682de21978 | ||
|
|
b5b1e3d51d | ||
|
|
efd94e2de0 | ||
|
|
b3dbb5db1f | ||
|
|
b795f56842 | ||
|
|
c0bda0c372 | ||
|
|
2a693e62bf | ||
|
|
eb3d962526 | ||
|
|
f90700e830 | ||
|
|
2b7f61f2a2 | ||
|
|
ffa449742d | ||
|
|
b40a4eefde | ||
|
|
4e60a61036 | ||
|
|
b3835717ab | ||
|
|
e05b397a00 | ||
|
|
7c48061b85 | ||
|
|
03ca628eef | ||
|
|
7aad8d3586 | ||
|
|
1e89891577 | ||
|
|
dd77e6bc5d | ||
|
|
0fe520f95b | ||
|
|
a6e9c8aff6 | ||
|
|
70f6929ac7 | ||
|
|
a360e60f76 | ||
|
|
2c6941e975 | ||
|
|
2afc553e03 | ||
|
|
5ed9c2615c | ||
|
|
ca22a43e46 | ||
|
|
d157a6fb2a | ||
|
|
503faf49e1 | ||
|
|
45f597cd2a | ||
|
|
26fd1b168a | ||
|
|
a9a0fe54b8 | ||
|
|
1c976de2b7 | ||
|
|
00ea872b76 | ||
|
|
836c0848cc | ||
|
|
95372134c8 | ||
|
|
27ce4ee92c | ||
|
|
6889b9b080 | ||
|
|
c81d190908 | ||
|
|
06826d426d | ||
|
|
62afa6b9a9 | ||
|
|
14839e4ab5 | ||
|
|
58003a8501 | ||
|
|
698fa40647 | ||
|
|
5fe3ee1300 | ||
|
|
b83f4c30f2 | ||
|
|
75551e8d0a | ||
|
|
e3d89ec3db | ||
|
|
27f00c04b0 | ||
|
|
30a72a1bd6 | ||
|
|
bbe3d4a811 | ||
|
|
e83540a1e9 | ||
|
|
254ae41759 | ||
|
|
aa11a9e934 | ||
|
|
0abe9ad994 | ||
|
|
452ff64740 | ||
|
|
4b2c4a5823 | ||
|
|
db3c9cb9c5 | ||
|
|
68e7fb5caa | ||
|
|
8420abe5b9 | ||
|
|
5e90d987de | ||
|
|
a0716aac49 | ||
|
|
1659180864 | ||
|
|
d308707f09 | ||
|
|
916554046d | ||
|
|
47c1761137 | ||
|
|
4022b01041 | ||
|
|
558f3bb10e | ||
|
|
ccc2c7cb5d | ||
|
|
3ed092e764 | ||
|
|
3bdf4aab9b | ||
|
|
373a3b4227 | ||
|
|
c78a314385 | ||
|
|
533a0ecf17 | ||
|
|
155782708b | ||
|
|
b6c023fdea | ||
|
|
6351ee86b9 | ||
|
|
a4bd5443f3 | ||
|
|
3120b47404 | ||
|
|
2ae4e42561 | ||
|
|
5112748e1b | ||
|
|
1388639079 | ||
|
|
72618a0d3a | ||
|
|
66a11b83f0 | ||
|
|
0bc66ab011 | ||
|
|
c98ef7c614 | ||
|
|
896a01cd40 | ||
|
|
4f88994cf0 | ||
|
|
93a5228f5b | ||
|
|
124d9a901f | ||
|
|
97c1a222ab | ||
|
|
35802dbb4d | ||
|
|
c848882778 | ||
|
|
374b8d6195 | ||
|
|
27c1b0f045 | ||
|
|
154aa1b0db | ||
|
|
658e5fcb9f | ||
|
|
292ba01dbf | ||
|
|
ff7966d96a | ||
|
|
9cf7437392 | ||
|
|
9f1884f100 | ||
|
|
8a208ce520 | ||
|
|
c850146ef6 | ||
|
|
ccf4f81ea0 | ||
|
|
3c957096c6 | ||
|
|
bc5ad0d919 | ||
|
|
9d06f5bc4d | ||
|
|
6818d1f180 | ||
|
|
ee72ec3dab | ||
|
|
9b74309eb5 | ||
|
|
948eccb169 | ||
|
|
ff342f1e5b | ||
|
|
a7af6fb82d | ||
|
|
d7e3b01bd6 | ||
|
|
117716da9e | ||
|
|
17da7b5fb8 | ||
|
|
545b8f2416 | ||
|
|
d1a62bba89 | ||
|
|
7ccf706a1d | ||
|
|
ef61691b34 | ||
|
|
a92c23bb26 | ||
|
|
21e4cc42cc | ||
|
|
abc307dc35 | ||
|
|
49e262e718 | ||
|
|
25be040bfc | ||
|
|
46c677ea57 | ||
|
|
165b772f8f | ||
|
|
bac2463ff2 | ||
|
|
c61b5d99a2 | ||
|
|
e54498dd35 | ||
|
|
9ca70a5157 | ||
|
|
f9b9184a39 | ||
|
|
b943af3b59 | ||
|
|
5afdc4f20e | ||
|
|
f85ac88595 | ||
|
|
e9e04e2cb4 | ||
|
|
114252dd09 | ||
|
|
2f41dec805 | ||
|
|
2ad01ad672 | ||
|
|
079666643d | ||
|
|
da370c0f2b | ||
|
|
b98026040f | ||
|
|
6d833143fe | ||
|
|
83578c1f38 | ||
|
|
2bc0b2a2b3 | ||
|
|
6af2fbfb6e | ||
|
|
999b265908 | ||
|
|
6599ba3a2d | ||
|
|
888f35c756 | ||
|
|
cc354cf8cf | ||
|
|
2b6ae33911 | ||
|
|
93a87a4dfd | ||
|
|
a7ff41b3ce | ||
|
|
6079739534 | ||
|
|
9822b4d2a1 | ||
|
|
03655cf8b2 | ||
|
|
32591954bc | ||
|
|
e17d4fc99f | ||
|
|
b746fc56bf | ||
|
|
831947ff55 | ||
|
|
e1002f0662 | ||
|
|
222fe94a05 | ||
|
|
aae9e12b8a | ||
|
|
dc0aca1d16 | ||
|
|
452aee0b83 | ||
|
|
73977c9aa5 | ||
|
|
f9731c92c1 | ||
|
|
88f308e2ae | ||
|
|
aa4cc6a7dc | ||
|
|
eead36eb47 | ||
|
|
39f17764e3 | ||
|
|
a9743f01fa | ||
|
|
e60baaeec8 | ||
|
|
9a32f6f21d | ||
|
|
175e84e618 | ||
|
|
2ff488c8c9 | ||
|
|
34652305ab | ||
|
|
bd3be288f2 | ||
|
|
00bcf21bc8 | ||
|
|
2c5d5fb40d | ||
|
|
394225a01a | ||
|
|
ff22549aa9 | ||
|
|
7c16bf8572 | ||
|
|
92c41cbb34 | ||
|
|
54747c24d1 | ||
|
|
d1a5aae242 | ||
|
|
d255967a73 | ||
|
|
637eaae9c7 | ||
|
|
926bdc8655 | ||
|
|
2ba0fa254f | ||
|
|
16c3534d40 | ||
|
|
3c436ce844 | ||
|
|
0b4488339d | ||
|
|
c0b73fe618 | ||
|
|
309aa157ab | ||
|
|
b79d717933 | ||
|
|
c78070c748 | ||
|
|
1159746505 | ||
|
|
b895d5af85 | ||
|
|
43f246d33f | ||
|
|
400014765a | ||
|
|
47c2bf31d4 | ||
|
|
f2cf1d8714 | ||
|
|
3d3372b485 | ||
|
|
964427eae5 | ||
|
|
3c583db3da | ||
|
|
f63e606600 | ||
|
|
2782b426d9 | ||
|
|
182652a231 | ||
|
|
ba73e52f09 | ||
|
|
5b469d702e | ||
|
|
758ed1dc38 | ||
|
|
0a840f11da | ||
|
|
9f674f6547 | ||
|
|
2e226f65ac | ||
|
|
06876e723f | ||
|
|
5d53d7277c | ||
|
|
d3aed95e39 | ||
|
|
4559b2bbf3 | ||
|
|
e6b39b6055 | ||
|
|
ea959cbd87 | ||
|
|
931424fa1b | ||
|
|
fd7628e658 | ||
|
|
8496bd030a | ||
|
|
8830ef5447 | ||
|
|
246130abec | ||
|
|
ec587ac7dc | ||
|
|
2205a8ab6b | ||
|
|
0cabab22be | ||
|
|
232fc61b90 | ||
|
|
1b0ca7b8ab | ||
|
|
531c012292 | ||
|
|
4187ec8655 | ||
|
|
333cbd9384 | ||
|
|
d302814f62 | ||
|
|
a746219a3f | ||
|
|
3e1c6da584 | ||
|
|
8a026f2f6e | ||
|
|
3c02940c7e | ||
|
|
abdeade019 | ||
|
|
99ac9eaf7c | ||
|
|
ee56cea7fd | ||
|
|
e1fa4804f9 | ||
|
|
b016cfb4b7 | ||
|
|
e447041337 | ||
|
|
147906f067 | ||
|
|
87702985dc | ||
|
|
f3e44d39ee | ||
|
|
59b94a2c7d | ||
|
|
c1f10ac7f0 | ||
|
|
0167c50b1d | ||
|
|
73c337b14e | ||
|
|
f625c4435c | ||
|
|
0418566e4c | ||
|
|
831e8fda9f | ||
|
|
f739101b4f | ||
|
|
d75856cfee | ||
|
|
973ef01be8 | ||
|
|
59d372222e | ||
|
|
70dcb05319 | ||
|
|
ce4dfe2507 | ||
|
|
01caea1611 | ||
|
|
7554daca65 | ||
|
|
7347631d34 | ||
|
|
d7b4d7c761 | ||
|
|
43442f8b9b | ||
|
|
93957e5183 | ||
|
|
e08422234b | ||
|
|
62f7b7aa0c | ||
|
|
b7073dc3ce | ||
|
|
d26f94fab1 | ||
|
|
ca86ce0a1c | ||
|
|
90b3e00e8d | ||
|
|
04d1f22d16 | ||
|
|
4d4bee73e3 | ||
|
|
b13ae2e972 | ||
|
|
1fdfb80fe4 | ||
|
|
dcd50d54e1 | ||
|
|
b165a419d5 | ||
|
|
dbae37bb5b | ||
|
|
d4b7a696af | ||
|
|
19876c5a56 | ||
|
|
9c8fb99184 | ||
|
|
5f88af7099 | ||
|
|
57101a1c5b | ||
|
|
382b04fe4a | ||
|
|
07c773ace2 | ||
|
|
984c3dc0e1 | ||
|
|
a85a48c59a | ||
|
|
cf17fff3fc | ||
|
|
4cc1702093 | ||
|
|
86fdb0c2ac | ||
|
|
3e7c7fe249 | ||
|
|
ce21e1b7e7 | ||
|
|
e9fa7c3d4a | ||
|
|
9992fa28ed | ||
|
|
14fe42e7da | ||
|
|
0d9597c9a9 | ||
|
|
b3d8cf11f7 | ||
|
|
c7184c21da | ||
|
|
ceee82c4b1 | ||
|
|
7c39af9c99 | ||
|
|
e086125cb8 | ||
|
|
5e6acc824e | ||
|
|
ae27726b3b | ||
|
|
83f6dd3052 | ||
|
|
fb9b4a4f35 | ||
|
|
6d7f95d912 | ||
|
|
46249cc49f | ||
|
|
51712d2322 | ||
|
|
24898ad60d | ||
|
|
cf9edce775 | ||
|
|
2387feeb7c | ||
|
|
363a41234d | ||
|
|
06573e4b81 | ||
|
|
e702246bb5 | ||
|
|
78c14cc574 | ||
|
|
976e83159f | ||
|
|
d7e532d268 | ||
|
|
33ef8ca2b4 | ||
|
|
e5e560e751 | ||
|
|
4e33285068 | ||
|
|
313f4a497d | ||
|
|
ddb67d1c84 | ||
|
|
99dedafc67 | ||
|
|
0b7e343a56 | ||
|
|
cd4da94cb9 | ||
|
|
882fecea6b | ||
|
|
efdf9d4421 | ||
|
|
33c2eb89c9 | ||
|
|
dc1cd3a259 | ||
|
|
11eaa3e092 | ||
|
|
4adb53dc51 | ||
|
|
d0cc3b63b4 | ||
|
|
2aefacb7f2 | ||
|
|
3f433561d4 | ||
|
|
7bb0c69f76 | ||
|
|
2c7ad5bc29 | ||
|
|
7ebb603ab7 | ||
|
|
7b9e1fb431 | ||
|
|
9f23c4f11e | ||
|
|
ce2a721a73 | ||
|
|
eebadf5230 | ||
|
|
51b62de4cb | ||
|
|
4643becaff | ||
|
|
4bbfac11aa | ||
|
|
0f4f7c3509 | ||
|
|
91af4db0c0 | ||
|
|
21a894cd63 | ||
|
|
e8035cc912 | ||
|
|
342aec164d | ||
|
|
517f7862ab | ||
|
|
6ca90a8c11 | ||
|
|
a7e8e2aad5 | ||
|
|
e9e5791e51 | ||
|
|
7c705e5fff | ||
|
|
b1d887264f | ||
|
|
da06dc80d6 | ||
|
|
2ed2f3def3 | ||
|
|
3292c4ea10 | ||
|
|
fbc7a7fbf7 | ||
|
|
4733fe7785 | ||
|
|
8585d06bb5 | ||
|
|
4d111b96e4 | ||
|
|
0557a5ba5c | ||
|
|
61d43f860a | ||
|
|
4dd4548be4 | ||
|
|
9c3ef30f4c | ||
|
|
585194908e | ||
|
|
330c733958 | ||
|
|
4c782a67ed | ||
|
|
3a304123d9 | ||
|
|
87da4cc0f2 | ||
|
|
12f29384ea | ||
|
|
253f7c1023 | ||
|
|
65bfa1ccf2 | ||
|
|
f19038e5fe | ||
|
|
619e4a60a2 | ||
|
|
6e92311aaa | ||
|
|
7d7aeb9f65 | ||
|
|
ae3d04660e | ||
|
|
2068da1cf9 | ||
|
|
19fdb9276d | ||
|
|
f55d2a4439 | ||
|
|
28ea47f796 | ||
|
|
9646b0b790 | ||
|
|
afb524a46a | ||
|
|
56ac1c931b | ||
|
|
3a788e9546 | ||
|
|
0b2f37beb9 | ||
|
|
353a5635e1 | ||
|
|
35dfed44de | ||
|
|
3680b0bb67 | ||
|
|
209d6db3a1 | ||
|
|
bb7af6145f | ||
|
|
77fd19a134 | ||
|
|
38a70c61c4 | ||
|
|
d2fd67ac84 | ||
|
|
f911c29bf0 | ||
|
|
63052aa3d1 | ||
|
|
eb28fe7ebd | ||
|
|
06c6a3b7f2 | ||
|
|
d4843c90e8 | ||
|
|
5ba0b2d656 | ||
|
|
482301aa0d | ||
|
|
87dfb72484 | ||
|
|
ea07f716b8 | ||
|
|
e7786dde97 | ||
|
|
b02a65974d | ||
|
|
6017c982c5 | ||
|
|
836c6ef09e | ||
|
|
ab4a058ac4 | ||
|
|
da9e48cf29 | ||
|
|
08aed29870 | ||
|
|
f31921e775 | ||
|
|
578ba9adaf | ||
|
|
efac6b053d | ||
|
|
e978cb0a3a | ||
|
|
b780b476c6 | ||
|
|
ba75b79a97 | ||
|
|
f9043aa0e6 | ||
|
|
5890ec6cfe | ||
|
|
fef73cc297 | ||
|
|
c7a8d5d42a | ||
|
|
9e9fef0d51 | ||
|
|
509df736bc | ||
|
|
063056e193 | ||
|
|
d1908b1645 | ||
|
|
06a1ab8787 | ||
|
|
cd478a4c48 | ||
|
|
acbd622369 | ||
|
|
817bbc46b1 | ||
|
|
dbc9123dce | ||
|
|
c2cb3094af | ||
|
|
65931f6277 | ||
|
|
0f6697214d | ||
|
|
3c78139ec8 | ||
|
|
5c921de24f | ||
|
|
a715babce3 | ||
|
|
fd68e649db | ||
|
|
186cfa8486 | ||
|
|
c5bc6fe95b | ||
|
|
285cd3063f | ||
|
|
8a4f4677bd | ||
|
|
57122a40e6 | ||
|
|
e2fca42f6c | ||
|
|
443a6064b3 | ||
|
|
86754e0537 | ||
|
|
78a940fcf4 | ||
|
|
4029788163 | ||
|
|
16cd57b8eb | ||
|
|
a5687d9c1d | ||
|
|
e93888ad3f | ||
|
|
7aaf002651 | ||
|
|
742648a166 | ||
|
|
c1f9fcb456 | ||
|
|
47d56a5485 | ||
|
|
498ed027dd | ||
|
|
31d03b314d | ||
|
|
8bbe487c86 | ||
|
|
4d6eeb363c | ||
|
|
419b6aabef | ||
|
|
54522aa725 | ||
|
|
d374d99e51 | ||
|
|
33de6ed878 | ||
|
|
0c40d99740 | ||
|
|
bcab57d8f5 | ||
|
|
2ca0a739e5 | ||
|
|
9895f123a7 | ||
|
|
87dfe0a4ed | ||
|
|
08434edf79 | ||
|
|
695e05eba4 | ||
|
|
b9a8adba73 | ||
|
|
91f504ed9f | ||
|
|
6033bd4228 | ||
|
|
3de3b11523 | ||
|
|
707f86a2f4 | ||
|
|
e9817380d2 | ||
|
|
21999e4a75 | ||
|
|
616cc70775 | ||
|
|
09d98932d9 | ||
|
|
3b8513546e | ||
|
|
5589a604b8 | ||
|
|
44b027a178 | ||
|
|
2dfc8494d7 | ||
|
|
729087f696 | ||
|
|
7656128c55 | ||
|
|
5fe670ce05 | ||
|
|
d700b69072 | ||
|
|
ddde2822fa | ||
|
|
a7d11f88c7 | ||
|
|
e7ed4aa32f | ||
|
|
090285ec7e | ||
|
|
bc99dbd560 | ||
|
|
fbd90763f9 | ||
|
|
f88439923f | ||
|
|
8f4ab3eb56 | ||
|
|
f216ef7a13 | ||
|
|
1db20c4882 | ||
|
|
0a6de47783 | ||
|
|
2a1760a5a9 | ||
|
|
65238c35a9 | ||
|
|
5e4e904efd | ||
|
|
4d6d766a21 | ||
|
|
2cb531066c | ||
|
|
e41fbdee49 | ||
|
|
c2672cf89c | ||
|
|
6146b0a002 | ||
|
|
ce22598d13 | ||
|
|
c067f7a13b | ||
|
|
89c21b3acd | ||
|
|
2adadf56e1 | ||
|
|
57530564a6 | ||
|
|
3bebcfdd68 | ||
|
|
b5fc2be113 | ||
|
|
a8d96e0dce | ||
|
|
6dc6240fab | ||
|
|
4aecd9056b | ||
|
|
979ab661de | ||
|
|
fbd20b7084 | ||
|
|
d695893329 | ||
|
|
8443f88bb2 | ||
|
|
acb1568708 | ||
|
|
51581fd3f5 | ||
|
|
15b2d6256f | ||
|
|
5d2fd5ca6d | ||
|
|
6f0e194705 | ||
|
|
4f4800bf26 | ||
|
|
1d3d15d5c1 | ||
|
|
f139ccc5e7 | ||
|
|
760a1589ba | ||
|
|
b9f987382c | ||
|
|
313b146b8e | ||
|
|
3676feef94 | ||
|
|
7157782c4c | ||
|
|
f803d31274 | ||
|
|
f996ad8e04 | ||
|
|
91166ca7ea | ||
|
|
e1a6467792 | ||
|
|
152ed05389 | ||
|
|
df57ff045d | ||
|
|
c5868c6eea | ||
|
|
ebcbb71e8c | ||
|
|
a90b075eec | ||
|
|
f7629eb044 | ||
|
|
f1132002b9 | ||
|
|
82674cfa9b | ||
|
|
096180e879 | ||
|
|
be7e968834 | ||
|
|
7fcd8be9d2 | ||
|
|
85f1815d8b | ||
|
|
bb5e302980 | ||
|
|
814028cb83 | ||
|
|
7e1b47976d | ||
|
|
feae8bf7b3 | ||
|
|
7a6d4bd380 | ||
|
|
3f9e50d10f | ||
|
|
ba407a84b9 | ||
|
|
86429ecd50 | ||
|
|
0344e2d5fa | ||
|
|
46f2c07587 | ||
|
|
1690bfa9bd | ||
|
|
19c6098d30 | ||
|
|
ecf602f589 | ||
|
|
49721abdaa | ||
|
|
d7ef18ec91 | ||
|
|
89081ca030 | ||
|
|
8d74807b23 | ||
|
|
f72bd52e87 | ||
|
|
771a4c9b6b | ||
|
|
945a82e9f0 | ||
|
|
a4c5e78794 | ||
|
|
25cda72d66 | ||
|
|
d3c6bd0250 | ||
|
|
aa88b40b24 | ||
|
|
c87ab4b9c1 | ||
|
|
352aa18377 | ||
|
|
6638b7f9c4 | ||
|
|
ec5b2a22c8 | ||
|
|
c926aa48f5 | ||
|
|
c839ccf916 | ||
|
|
0171677513 | ||
|
|
3314d9e3a5 | ||
|
|
2d33875017 | ||
|
|
0ff409a3d9 | ||
|
|
e89d3a7e15 | ||
|
|
bce54912ee | ||
|
|
0851dc9a67 | ||
|
|
bfaeffc8f9 | ||
|
|
223436a6b7 | ||
|
|
8db491ade0 | ||
|
|
b774241f25 | ||
|
|
bb743d80e0 | ||
|
|
888c3d4797 | ||
|
|
54de8d1f2a | ||
|
|
68dff7ac81 | ||
|
|
83032dc7ac | ||
|
|
2820b36d7e | ||
|
|
2a7b94bc9d | ||
|
|
c393d58fe5 | ||
|
|
8d8cc35c96 | ||
|
|
69bfc27960 | ||
|
|
d2ebc47c1e | ||
|
|
ee73e4c3e9 | ||
|
|
8ecbb25274 | ||
|
|
e437b720a4 | ||
|
|
b8e28910ba | ||
|
|
852b6e0976 | ||
|
|
b7eb5403ff | ||
|
|
0b186dc939 | ||
|
|
22dff08b8d | ||
|
|
b9e94d49ae | ||
|
|
867a91cbe4 | ||
|
|
aadadeef5b | ||
|
|
7b7e3f6e23 | ||
|
|
e2e37da3ce | ||
|
|
6d861c5d92 | ||
|
|
80dee159de | ||
|
|
de9ec2a849 | ||
|
|
7a1f627c79 | ||
|
|
cf7711fb83 | ||
|
|
c7ec996c23 | ||
|
|
a8c2a98379 | ||
|
|
7148c0f3e6 | ||
|
|
05b5758058 | ||
|
|
c2f498f157 | ||
|
|
e11f8387b2 | ||
|
|
d3198961d7 | ||
|
|
3f37fe7674 | ||
|
|
245b4e1608 | ||
|
|
9516d6d667 | ||
|
|
b13b57e800 | ||
|
|
9480f40522 | ||
|
|
32d4de464d | ||
|
|
578666e9e6 | ||
|
|
591d7d0049 | ||
|
|
417e018432 | ||
|
|
fa2a121217 | ||
|
|
5a3fd1e12a | ||
|
|
cb19fe8864 | ||
|
|
fb206d9f71 | ||
|
|
83c93809c4 | ||
|
|
b95f5bc83c | ||
|
|
35efebf76f | ||
|
|
21657c9fb1 | ||
|
|
cca13834ca | ||
|
|
c36aee449d | ||
|
|
2d15514466 | ||
|
|
2471a5f05d | ||
|
|
d61e0d57a9 | ||
|
|
7dc42eb6ea | ||
|
|
59114fb9dc | ||
|
|
8f73838fa0 | ||
|
|
fce6957a66 | ||
|
|
def8cfa1ff | ||
|
|
99df53ba96 | ||
|
|
77d16de08a | ||
|
|
e040ccfef1 | ||
|
|
f2ca019cb0 | ||
|
|
336db58e96 | ||
|
|
6826505d3e | ||
|
|
8e41993ead | ||
|
|
19c3d2ebf3 | ||
|
|
c9a631d2e4 | ||
|
|
f2cd127729 | ||
|
|
b001a3e52e | ||
|
|
c9bb1bf81c | ||
|
|
d9c287c899 | ||
|
|
18d7c5f8cd | ||
|
|
4697623be6 | ||
|
|
4f1cfa0d9c | ||
|
|
697a3436e5 | ||
|
|
ae72844847 | ||
|
|
8385dfd0f4 | ||
|
|
31ee181ad2 | ||
|
|
0e14c9ca6a | ||
|
|
aac2a91833 | ||
|
|
ce10ccd97e | ||
|
|
77a58843fe | ||
|
|
3b1f97a298 | ||
|
|
7e4f74af14 | ||
|
|
4ac95c9560 | ||
|
|
6d7092f10a | ||
|
|
c209639c4d | ||
|
|
9ec502f5ab | ||
|
|
8ae0f10162 | ||
|
|
6b86508d38 | ||
|
|
841e14e8b8 | ||
|
|
2bc1de6f1f | ||
|
|
3604e36917 | ||
|
|
69f349397b | ||
|
|
c778dff301 | ||
|
|
51a012896f | ||
|
|
66962fe8d8 | ||
|
|
b463afee27 | ||
|
|
71c7e2f9a2 | ||
|
|
969622840d | ||
|
|
6910ce4413 | ||
|
|
1c5523ed83 | ||
|
|
b87a89c24d | ||
|
|
5106d7010a | ||
|
|
1a968424db | ||
|
|
000c4a9832 | ||
|
|
66b734322d | ||
|
|
93e339f32e |
No files matched your search
@@ -21,7 +21,7 @@ ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
#DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ForEachMacros: foreach,Q_FOREACH
|
||||
#ForEachMacros: foreach,Q_FOREACH
|
||||
IndentCaseLabels: true
|
||||
IndentFunctionDeclarationAfterType: true
|
||||
IndentWidth: 4
|
||||
|
||||
@@ -28,6 +28,13 @@ Icon
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
# With Carthage, if Sparkle is included as a Git submodule (e.g. with the
|
||||
# --use-submodules option), the main module's .gitignore can't reach all the
|
||||
# way inside the submodule to ignore the added Carthage/Build symlink, and Git
|
||||
# keeps complaining about untracked changes in the submodule forever, which
|
||||
# is very annoying. To avoid that issue, ignore here in Sparkle instead.
|
||||
Carthage/Build
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
language: objective-c
|
||||
osx_image: xcode8
|
||||
before_install:
|
||||
- brew update
|
||||
script: make ci
|
||||
@@ -1,4 +1,176 @@
|
||||
# 1.7.1
|
||||
# 1.15.0
|
||||
|
||||
* A new icon! Thanks to 1024jp
|
||||
* Show alert when an update is sent over insecure HTTP with no DSA key (Zorg)
|
||||
- If you can't use HTTPS, you must at least sign updates with a DSA key.
|
||||
* Improved binary delta implementation (Zorg)
|
||||
* Added improved -validateMenuItem: as a method in SUUpdater.h for public use (Zorg)
|
||||
* Removed reachability preflight check (Zorg)
|
||||
* Clear update caches directory before downloading new update (Zorg)
|
||||
* Check the bundle's parent directory for writability too (Zorg)
|
||||
* Don't follow symbolic links for file operations (Zorg)
|
||||
* Don't bring up an authorized dialog during cleanup (Zorg)
|
||||
* Made Sparkle look for the highest compatible version regardless of timestamps (Zorg)
|
||||
* Fixed compatibility with 10.7
|
||||
* Fixed crash on 10.7 - subscript operator not available (kleuter)
|
||||
* Fixed warnings caused by -Wpartial-availability (Zorg)
|
||||
* Fixed german l10n. (Sebastian Volland)
|
||||
* Error code for download errors (Kornel Lesiński)
|
||||
* Update last update check date when the update driver finishes (Zorg)
|
||||
* Scale app icon up if needed in Software Update window (Nicholas Riley)
|
||||
* Don't register for termination notifications more than once (Zorg)
|
||||
* Don't terminate the app if we're already terminating (Zorg)
|
||||
* Removed SUEnableAutomaticChecksKeyOld and SUCheckAtStartup constants (Eitot)
|
||||
* Updated Sparkle framework headers to use modules if modules are available (B. Kevin Hardman)
|
||||
* Fixed warnings, fixed uses of SULocalizedString (Jerry Krinock)
|
||||
* Improved signing verifier to take any host and s/application/bundle/ (Zorg)
|
||||
* Improved Spotlight updates after delta extraction (Zorg)
|
||||
|
||||
# 1.14.0 (Mar 11, 2016)
|
||||
|
||||
* Disable javascript by default and make it opt-in (Zorg)
|
||||
* URL-encoding of appcast URLs is preserved (Kornel Lesiński)
|
||||
* Delegate is asked for fallback updates if delta update fails (Kornel Lesiński)
|
||||
* Fixed crash on 10.7 - subscript operator not available (kleuter)
|
||||
* Fixed check of feed URL before delegate had a chance to set it (Kornel Lesiński)
|
||||
* Re-added support for password-protected dmg images (Andrew K. Boyd)
|
||||
* Added warning about ATS blocking (Kornel Lesiński)
|
||||
* Translation fixes for pt-BR. (vitu)
|
||||
* Add some Japanese lozalized strings (1024jp)
|
||||
* Made test app available in all languages #695 (LIU Dongyuan / 柳东原)
|
||||
* Czech localizations update (Frantisek Erben)
|
||||
* Removed a test resource from the framework bundle (Karl Moskowski)
|
||||
* Test if the updated app is the frontmost one (Zorg)
|
||||
* UI Tests for the Test Application (Zorg)
|
||||
|
||||
# 1.13.1 (Jan 31, 2016)
|
||||
|
||||
Important security fixes:
|
||||
|
||||
* Prevent inclusion of local files via file:// XML entities
|
||||
* Disable redirects to non-HTTP URLs in release notes webview
|
||||
|
||||
# 1.13.0 (Dec 18, 2015)
|
||||
|
||||
* Changed framework's bundle ID from `org.andymatuschak.Sparkle` to `org.sparkle-project.Sparkle`.
|
||||
|
||||
# 1.12.0 (Dec 13, 2015)
|
||||
|
||||
* Rewritten file operations for updating an app (Zorg)
|
||||
- Ensuring atomic move operations, robust error handling.
|
||||
- Faster.
|
||||
- Using modern APIs where possible (no FSPathMakeRef, FSGetCatalogInfo, FSFindFolder, etc.)
|
||||
- Strong documentation, easier to read code.
|
||||
* Automatic updates won't be installed if the system is about to shut off (Zorg)
|
||||
* Deprecated serving over HTTP without DSA (Zorg)
|
||||
- Note that Apple has deprecated insecure HTTP in macOS 10.11
|
||||
* Improved Autoupdate application (Zorg)
|
||||
* Do all the installation work after the runloop is set up
|
||||
* TerminationListener only does termination listening now
|
||||
* Handle cases where host path is not installation path and host path is not desired executable path
|
||||
* Don't show Autoupdate dock icon if we shouldn't show UI
|
||||
* Update modification & access time for new update
|
||||
* Added installUpdatesIfAvailable (Ian Langworth)
|
||||
* Removed extensions from shell scripts (Jake Petroules)
|
||||
* Rewritten test app so it works again, and from a local web server (Zorg)
|
||||
* Replaced use of Python with built-in web server (Kevin Wojniak)
|
||||
* Set LD_RUNPATH_SEARCH_PATHS in Podspec (Jake Petroules)
|
||||
* Don't install automatic updates if the system might shut off (Zorg)
|
||||
* Don't show Autoupdate dock icon if we shouldn't show UI (Zorg)
|
||||
* Updated layout constraints when removing release notes (Zorg)
|
||||
* Improved BinaryDelta error handling & logging (Zorg)
|
||||
* Refactored quarantine removal (Zorg)
|
||||
* Fixed German localization (1024jp)
|
||||
* Updated zh_CN translation (LIU Dongyuan / 柳东原)
|
||||
* Updated Mac models list until July 2015 (Gabriel Ulici)
|
||||
* Updated Polish translation (Kornel Lesiński)
|
||||
* Updated Xcode project languages for which we have translations (Jake Petroules)
|
||||
* Updated XIB files (Kornel Lesiński)
|
||||
* Use NSByteCountFormatter if available (Jake Petroules)
|
||||
* Declared protocols on SUUpdateAlert for the 10.11 SDK (Daniel Jalkut)
|
||||
* Silenced warning about casting away const-ness and -Wassign-enum (Daniel Jalkut)
|
||||
* Added script to generate a report comparing the Sparkle.strings files (Kevin Wojniak)
|
||||
* Check for empty strings (as well as nil) in SUHost's -name method (Karl Moskowski)
|
||||
* Don't follow symlinks for checking file existence (Zorg)
|
||||
* Unit tests in Swift (Zorg, Jake Petroules)
|
||||
* Fixed framework imports (Felix Schulze)
|
||||
* Fixed issues with copying files from different mounted drives (Zorg)
|
||||
* Disallowed automatic updates when user can't write to the bundle (Zorg)
|
||||
* Set the task working directories instead of changing the process working directory (Kevin Wojniak)
|
||||
|
||||
# 1.11.1 (Nov 9, 2015)
|
||||
|
||||
* Don't install automatic updates when system is about to shut down
|
||||
|
||||
# 1.11.0 (Aug 24, 2015)
|
||||
|
||||
* Big improvements to code signing and DSA verification
|
||||
- Sparkle now checks not only whether an update is correctly signed, but also whether the updated version will be able to verify future updates. Updates now must either use DSA keys correctly, or not try to use them at all. Same goes for Apple Code Signing.
|
||||
- Rely on code signing and the DSA key in the new app instead of appcast. If the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed. (Zorg)
|
||||
* More verbose error message when DSA keys don't match (Kornel Lesiński)
|
||||
* Added delegate methods for pre-download and immediately post-failed-download (Isaac Greenspan)
|
||||
* Fix Lucida Grande is always used for release notes (LIU Dongyuan / 柳东原)
|
||||
* Only remove quarantine with setResourceValue: when it's present. Fixes "Unable to quarantine: 93" messages from showing up in the console. (Zorg)
|
||||
* Fixed const and nullability warnings (Jake Petroules, Kornel Lesiński)
|
||||
* Replaced deprecated NSRunAlertPanel/alertWithMessageText (Kevin Wojniak)
|
||||
* Imported the Foundation umbrella header in all the public headers (C.W. Betts)
|
||||
* pt-BR localization update (Victor Figueiredo)
|
||||
* Reject unsupported code-signing xattrs in binary delta (Zorg)
|
||||
* Fixed crash while applying delta update (antonc27)
|
||||
* Added logging of appcast/download URL on error (Kornel Lesiński)
|
||||
* More robust reading of Autoupdate.app path from Sparkle bundle
|
||||
|
||||
# 1.10.0 (Apr 26, 2015)
|
||||
|
||||
* Massive improvements to the BinaryDelta tool (Zorg)
|
||||
- Ability to track file permissions (Zorg)
|
||||
- Nicely formatted log output (Zorg)
|
||||
- Numerous bug fixes in handling of symlinks, empty directories, case-insensitive names, etc. (Zorg)
|
||||
- Refactored and modernized code (Zorg)
|
||||
- libxar is no longer weak-linked (C.W. Betts)
|
||||
* Double-check the code signature of the the app after installation (Isaac Wankerl)
|
||||
* Added headless guided package installation (Graham Miln)
|
||||
* Added ability to inject custom HTTP headers in appcast request (Mattias Gunneras)
|
||||
* Changes to make unarching more reliable (Zorg, Kornel Lesiński)
|
||||
* Have Sparkle build a framework module (C.W. Betts)
|
||||
* Stdout used for non error outputs (JDuquennoy)
|
||||
* French locale update (Kent Sutherland)
|
||||
|
||||
# 1.9.0 (Jan 26, 2015)
|
||||
|
||||
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
|
||||
* Make the error definitions public (C.W. Betts)
|
||||
* Add support for lzma compressed tarballs (Kyle Fuller)
|
||||
* Back to SKIP_INSTALL=YES by default (Tony Arnold)
|
||||
* Properly set install names and rpaths for targets (Jake Petroules)
|
||||
* Use Library/Caches rather than app support directory (Kornel Lesiński)
|
||||
* Check for a modal window being onscreen before trying to put up the Sparkle prompt (Alf Watt)
|
||||
* Fixed crashes on 10.7 (Chris Campbell, Ger Teunis)
|
||||
* Fixed Sparkle tags parsing (Tamás Lustyik)
|
||||
* SULog code cleanups (Kevin Wojniak)
|
||||
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
|
||||
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
|
||||
* Fix warnings under Xcode 6.1 relating the SUUpdateAlert XIB (Tony Arnold)
|
||||
* Prefer string constants to strings (Jake Petroules)
|
||||
* Use Info.plist keys instead of macros (Jake Petroules)
|
||||
* Only export public symbols. (Jake Petroules)
|
||||
* BinaryDelta: avoid crash with bad paths (Jake Petroules)
|
||||
* Fixing Swedish translations (Erik Vikström)
|
||||
* Turkish localization fixes (Emir)
|
||||
* Proofing of Ukrainian localization (Vera Tkachenko)
|
||||
|
||||
# 1.8.0 (Jul 26, 2014)
|
||||
|
||||
* New SUDSAVerifier based on up-to-date macOS APIs (Zachary Waldowski)
|
||||
* Detailed error log for failed signature checks (Kornel Lesiński)
|
||||
* Converted Sparkle to ARC (C.W. Betts)
|
||||
* Converted ivars to properties. (Jake Petroules)
|
||||
* Cocoapod support (Xhacker Liu)
|
||||
* Quarantine removal on macOS 10.10 (C.W. Betts)
|
||||
* Updated Japanese localization (1024jp)
|
||||
* Added Greek localization
|
||||
|
||||
# 1.7.1 (Jul 2, 2014)
|
||||
|
||||
* Removed option to install unverified updates (Kornel Lesiński)
|
||||
* Added detailed log when code signing verification fails (Sam Deane)
|
||||
@@ -15,7 +187,7 @@
|
||||
|
||||
# 1.7.0
|
||||
|
||||
* Dropped support for OS X 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
|
||||
* Dropped support for macOS 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
|
||||
* Removed use of deprecated functions (Zachary Waldowski)
|
||||
* Switched to modern Obj-C runtime and new literals syntax
|
||||
* Removed pre-10.7 code. (C.W. Betts)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at kornel+sparkle@geekhood.net. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -1,4 +1 @@
|
||||
// BinaryDelta tool only
|
||||
|
||||
PRODUCT_NAME = BinaryDelta
|
||||
GCC_PREFIX_HEADER =
|
||||
@@ -1,26 +1,52 @@
|
||||
// Common
|
||||
|
||||
FINISH_INSTALL_TOOL_NAME = Autoupdate
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_FILEOP_TOOL_NAME = fileop
|
||||
|
||||
SPARKLE_APPEND_VERSION_NUMBER = 1
|
||||
|
||||
// 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_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 7
|
||||
SPARKLE_VERSION_PATCH = 1
|
||||
SPARKLE_VERSION_MINOR = 15
|
||||
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_PRECOMPILE_PREFIX_HEADER = YES
|
||||
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
|
||||
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
|
||||
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
COMBINE_HIDPI_IMAGES = NO;
|
||||
|
||||
// Enable warnings
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
|
||||
CLANG_ENABLE_MODULES = YES
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
|
||||
CLANG_WARN_ASSIGN_ENUM = YES
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
|
||||
CLANG_WARN_EMPTY_BODY = YES
|
||||
@@ -29,9 +55,11 @@ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
||||
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
|
||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
|
||||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
|
||||
@@ -54,8 +82,12 @@ GCC_WARN_UNUSED_LABEL = YES
|
||||
GCC_WARN_UNUSED_PARAMETER = YES
|
||||
GCC_WARN_UNUSED_VARIABLE = YES
|
||||
|
||||
// Fixes a strange issue where the compiler thinks references to some enums are ambiguous
|
||||
CLANG_ENABLE_MODULES[sdk=macosx10.7] = NO
|
||||
CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
|
||||
|
||||
// These should be removed once the conversion to ARC is complete
|
||||
WARNING_CFLAGS_EXTRA = -Wno-objc-interface-ivars -Wno-direct-ivar-access -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
|
||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression $(WARNING_CFLAGS_EXTRA)
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigCommonDebug.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = YES
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
|
||||
@@ -3,9 +3,10 @@
|
||||
// Debug only
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = 0
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Onone
|
||||
DEBUG_INFORMATION_FORMAT = dwarf
|
||||
ENABLE_TESTABILITY = YES
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
SPARKLE_EXTRA_DEBUG = -DDEBUG
|
||||
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
|
||||
ONLY_ACTIVE_ARCH = YES
|
||||
COPY_PHASE_STRIP = NO
|
||||
@@ -3,8 +3,10 @@
|
||||
// Release only
|
||||
|
||||
GCC_OPTIMIZATION_LEVEL = s
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Ofast
|
||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||
DEAD_CODE_STRIPPING = YES
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||
@@ -0,0 +1,5 @@
|
||||
// Fileop tool only
|
||||
|
||||
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
@@ -1,11 +1,13 @@
|
||||
// Framework only
|
||||
|
||||
INSTALL_PATH = @loader_path/../Frameworks
|
||||
DYLIB_INSTALL_NAME_BASE = @rpath
|
||||
DYLIB_COMPATIBILITY_VERSION = 1.6
|
||||
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
PRODUCT_NAME = Sparkle
|
||||
WRAPPER_EXTENSION = framework
|
||||
FRAMEWORK_VERSION = A
|
||||
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
|
||||
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
|
||||
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
|
||||
SKIP_INSTALL = YES
|
||||
DEFINES_MODULE = YES
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ${SPARKLE_BUNDLE_IDENTIFIER}
|
||||
@@ -1,2 +1,4 @@
|
||||
#include "ConfigFramework.xcconfig"
|
||||
|
||||
// Unit tests need access to non-public classes
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO
|
||||
@@ -1,7 +1,8 @@
|
||||
// Relaunch Tool only
|
||||
|
||||
INFOPLIST_FILE = Sparkle/Autoupdate/Autoupdate-Info.plist
|
||||
PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
|
||||
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
GCC_PREFIX_HEADER = Sparkle/Autoupdate/Autoupdate.pch
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_VERSION = 3.0
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Onone
|
||||
@@ -0,0 +1 @@
|
||||
SWIFT_OPTIMIZATION_LEVEL = -Ofast
|
||||
@@ -1,6 +1,7 @@
|
||||
// Test Application only
|
||||
|
||||
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
|
||||
PRODUCT_NAME = Sparkle Test App
|
||||
WRAPPER_EXTENSION = app
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
|
||||
@@ -0,0 +1,13 @@
|
||||
// UI Test only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
INFOPLIST_FILE = UITests/UITests-Info.plist
|
||||
WRAPPER_EXTENSION = xctest
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
|
||||
TEST_TARGET_NAME = Sparkle Test App
|
||||
USES_XCTRUNNER = YES
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "ConfigUITest.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -1,6 +1,14 @@
|
||||
// Unit Test only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
|
||||
PRODUCT_NAME = Sparkle Unit Tests
|
||||
WRAPPER_EXTENSION = xctest
|
||||
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO
|
||||
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9
|
||||
CLANG_ENABLE_MODULES = YES
|
||||
SWIFT_OBJC_BRIDGING_HEADER = Tests/Sparkle Unit Tests-Bridging-Header.h
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
|
||||
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||
@@ -1 +1,2 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -1 +1,2 @@
|
||||
#include "ConfigUnitTest.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -2,20 +2,33 @@
|
||||
set -e
|
||||
|
||||
if [ "$ACTION" = "" ] ; then
|
||||
# Sanity check that the Podspec version matches the Sparkle version
|
||||
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
|
||||
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
|
||||
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.zip"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
# 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/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
fi
|
||||
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||
zip --symlinks -r "../Sparkle-$CURRENT_PROJECT_VERSION.zip" .
|
||||
# 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=-
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if ! which -s git ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$SRCROOT" ] || \
|
||||
[ -z "$BUILT_PRODUCTS_DIR" ] || \
|
||||
[ -z "$INFOPLIST_PATH" ] || \
|
||||
[ -z "$CURRENT_PROJECT_VERSION" ]; then
|
||||
echo "$0: Must be run from Xcode!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="$CURRENT_PROJECT_VERSION"
|
||||
|
||||
# Get version in format 1.x.x-commits-hash
|
||||
gitversion=$(cd "$SRCROOT" ; git describe --tags --match '[12].*')
|
||||
if [ -z "$gitversion" ] ; then
|
||||
echo "$0: Can't find a Git hash!" 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# remove everything before the first "-" to keep the hash part only
|
||||
versionsuffix=${gitversion#*-};
|
||||
if [ "$versionsuffix" != "$gitversion" ]; then
|
||||
version="$version $versionsuffix"
|
||||
fi
|
||||
|
||||
# and use it to set the CFBundleShortVersionString value
|
||||
export PATH="$PATH:/usr/libexec"
|
||||
PlistBuddy -c "Set :CFBundleShortVersionString '$version'" \
|
||||
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
|
||||
@@ -1,6 +1,6 @@
|
||||
PROJECT_NAME = Sparkle
|
||||
PROJECT_NUMBER = 1.7.1
|
||||
PROJECT_BRIEF = "A software update framework for OS X"
|
||||
PROJECT_NUMBER = 1.14.0
|
||||
PROJECT_BRIEF = "A software update framework for macOS"
|
||||
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
|
||||
|
||||
RECURSIVE = YES
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Copyright (c) 2006-2014 Andy Matuschak
|
||||
Copyright (c) 2013-2014 Kornel Lesinski
|
||||
Copyright (c) 2014 Petroules Corporation, Sparkle Project contributors
|
||||
Copyright (c) 2006-2013 Andy Matuschak.
|
||||
Copyright (c) 2009-2013 Elgato Systems GmbH.
|
||||
Copyright (c) 2011-2014 Kornel Lesiński.
|
||||
Copyright (c) 2014 C.W. Betts.
|
||||
Copyright (c) 2014 Petroules Corporation.
|
||||
Copyright (c) 2014 Big Nerd Ranch.
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -23,10 +27,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
EXTERNAL LICENSES
|
||||
=================
|
||||
|
||||
License for bsdiff.c and bspatch.c, from bsdiff 4.3 (<http://www.daemonology.net/bsdiff/>):
|
||||
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>:
|
||||
Copyright (c) 2003-2005 Colin Percival.
|
||||
|
||||
Copyright 2003-2005 Colin Percival
|
||||
All rights reserved
|
||||
sais.c and sais.c, from sais-lite (2010/08/07) <https://sites.google.com/site/yuta256/sais>:
|
||||
Copyright (c) 2008-2010 Yuta Mori.
|
||||
|
||||
SUDSAVerifier.m:
|
||||
Copyright (c) 2011 Mark Hamlin.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted providing that the following conditions
|
||||
|
||||
@@ -1,13 +1,42 @@
|
||||
.PHONY: all localizable-strings
|
||||
.PHONY: all localizable-strings release build test ci
|
||||
|
||||
builddir := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
||||
ifndef BUILDDIR
|
||||
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
|
||||
endif
|
||||
|
||||
localizable-strings:
|
||||
rm Sparkle/en.lproj/Sparkle.strings || TRUE
|
||||
rm -f Sparkle/en.lproj/Sparkle.strings
|
||||
genstrings -o Sparkle/en.lproj -s SULocalizedString Sparkle/*.m Sparkle/*.h
|
||||
iconv -f UTF-16 -t UTF-8 < Sparkle/en.lproj/Localizable.strings > Sparkle/en.lproj/Sparkle.strings
|
||||
rm Sparkle/en.lproj/Localizable.strings
|
||||
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(builddir)"
|
||||
open -R "$(builddir)/Build/Products/Release/Sparkle-"*.zip
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||
cat Sparkle.podspec
|
||||
@echo "Don't forget to update CocoaPods!"
|
||||
|
||||
build:
|
||||
xcodebuild clean build
|
||||
|
||||
test:
|
||||
xcodebuild -scheme Distribution -configuration Debug test
|
||||
|
||||
uitest:
|
||||
xcodebuild -scheme UITests -configuration Debug test
|
||||
|
||||
ci:
|
||||
for i in {7..9} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
for i in {10..11} ; do \
|
||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \
|
||||
fi ; \
|
||||
done
|
||||
|
||||
check-localizations:
|
||||
./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm"
|
||||
open "$(TMPDIR)/LocalizationsReport.htm"
|
||||
@@ -0,0 +1,24 @@
|
||||
# To update the icon run make -f Makefile-icon
|
||||
# Requires:
|
||||
# autoconf, automake, libtool, pkg-config, pngquant
|
||||
|
||||
ICONDIR=./Resources/Images.xcassets/AppIcon.appiconset
|
||||
OPTIMIZEDICONS=$(ICONDIR)/optimized_16x16.png $(ICONDIR)/optimized_32x32.png $(ICONDIR)/optimized_128x128.png $(ICONDIR)/optimized_512x512.png
|
||||
DESTICON=Resources/AppIcon.icns
|
||||
|
||||
all: $(DESTICON)
|
||||
|
||||
libicns:
|
||||
git clone https://github.com/pornel/libicns.git
|
||||
|
||||
libicns/Makefile: libicns
|
||||
( cd libicns && autoreconf -vif && ./configure )
|
||||
|
||||
libicns/icnsutils/png2icns: libicns/Makefile
|
||||
( cd libicns && make -j8 )
|
||||
|
||||
optimized_%.png: icon_%.png
|
||||
pngquant -s1 -f -o $@ $<
|
||||
|
||||
$(DESTICON): libicns/icnsutils/png2icns $(OPTIMIZEDICONS)
|
||||
./libicns/icnsutils/png2icns $@ $(OPTIMIZEDICONS)
|
||||
@@ -1,31 +1,57 @@
|
||||
# Sparkle <img src="Resources/Sparkle.png" width=48 height=48 alt=""/>
|
||||
is an easy-to-use software update framework for Cocoa developers.
|
||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) [](https://github.com/Carthage/Carthage) []() <a href="https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
|
||||
|
||||
## Changes since 1.5
|
||||
An easy-to-use software update framework for Cocoa developers.
|
||||
|
||||
* Up to date with 10.9 SDK and Xcode 5/6. Supports OS X 10.7+.
|
||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
||||
* Merged official Sparkle branch with truly automatic background updates (no UI at all)
|
||||
when user agreed to "Automatically download and install updates in the future."
|
||||
<img src="Resources/Screenshot.png" width="732" alt="Sparkle shows familiar update window with release notes">
|
||||
|
||||
## Changes since 1.5b
|
||||
|
||||
* Up-to-date with 10.11 SDK and Xcode 7. Supports macOS 10.7+.
|
||||
* Important security fixes.
|
||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||
* Ability to mark updates as critical.
|
||||
* Progress and status notifications for the host app.
|
||||
* Name of finish_installation.app can be configured to match your app's name.
|
||||
* Upgraded and more reliable binary delta and code signing verification.
|
||||
|
||||
## Features
|
||||
|
||||
* True self-updating—no work required from the user.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* True self-updating—the user can choose to automatically download and install all updates.
|
||||
* Displays a detailed progress window to the user.
|
||||
* Supports authentication for installing in secure locations.
|
||||
* Really, really easy to install.
|
||||
* Uses appcasts for release information.
|
||||
* The user can choose to automatically download and install all updates.
|
||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
||||
* Supports DSA signatures for ultra-secure updates.
|
||||
* Sparkle requires no code in your app, so it's trivial to upgrade or remove the module.
|
||||
* Optionally sends user demographic information to the server when checking for updates.
|
||||
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
|
||||
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
|
||||
* Uses RSS-based appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
||||
* Displays release notes to the user via WebKit.
|
||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
||||
* Sparkle can install .pkg files for more complicated products.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
* Deep delegate support to make Sparkle work exactly as you need.
|
||||
* Optionally sends system information to the server when checking for updates.
|
||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
||||
* Supports branches due to minimum OS version requirements.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Runtime: macOS 10.7 or greater
|
||||
* Build: Xcode 5 and 10.8 SDK or greater
|
||||
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||
|
||||
## API
|
||||
|
||||
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
||||
If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples).
|
||||
|
||||
## Building the distribution package
|
||||
|
||||
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed.
|
||||
|
||||
Alternatively, build the Distribution scheme in the Xcode UI.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
We pledge to have an open and welcoming environment. See our [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Project Sponsor
|
||||
|
||||
[StackPath](https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer)
|
||||
@@ -43,18 +43,21 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_256x256@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_512x512.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "icon_512x512@2x.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 368 KiB |
@@ -16,6 +16,8 @@
|
||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||
<key>iMac6,1</key>
|
||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
||||
<key>iMac7,1</key>
|
||||
<string>iMac Intel Core 2 Duo (aluminum enclosure)</string>
|
||||
<key>iMac8,1</key>
|
||||
<string>iMac (Core 2 Duo, 20 or 24 inch, Early 2008 )</string>
|
||||
<key>iMac9,1</key>
|
||||
@@ -25,7 +27,7 @@
|
||||
<key>iMac11,1</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2009)</string>
|
||||
<key>iMac11,2</key>
|
||||
<string>iMac (Core i3 or i5, 27 inch Mid 2010)</string>
|
||||
<string>21.5" iMac (mid 2010)</string>
|
||||
<key>iMac11,3</key>
|
||||
<string>iMac (Core i5 or i7, 27 inch Mid 2010)</string>
|
||||
<key>iMac12,1</key>
|
||||
@@ -42,6 +44,16 @@
|
||||
<string>iMac (Core i5 or i7, 27 inch Late 2013)</string>
|
||||
<key>iMac14,3</key>
|
||||
<string>iMac (Core i5 or i7, 21.5 inch Late 2013)</string>
|
||||
<key>iMac14,4</key>
|
||||
<string>iMac (Core i5, 21.5 inch Mid 2014)</string>
|
||||
<key>iMac15,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2014 or Mid 2015)</string>
|
||||
<key>iMac16,1</key>
|
||||
<string>iMac (Core i5, 21,5 inch Late 2015)</string>
|
||||
<key>iMac16,2</key>
|
||||
<string>iMac (Retina 4K Core i5 or i7, 21.5 inch Late 2015)</string>
|
||||
<key>iMac17,1</key>
|
||||
<string>iMac (Retina 5K Core i5 or i7, 27 inch Late 2015)</string>
|
||||
<key>MacBook1,1</key>
|
||||
<string>MacBook (Core Duo)</string>
|
||||
<key>MacBook2,1</key>
|
||||
@@ -56,6 +68,8 @@
|
||||
<string>MacBook (Core 2 Duo, Late 2009, Unibody)</string>
|
||||
<key>MacBook7,1</key>
|
||||
<string>MacBook (Core 2 Duo, Mid 2010, White)</string>
|
||||
<key>MacBook8,1</key>
|
||||
<string>MacBook (Core M, 12 inch, Early 2015)</string>
|
||||
<key>MacBookAir1,1</key>
|
||||
<string>MacBook Air (Core 2 Duo, 13 inch, Early 2008)</string>
|
||||
<key>MacBookAir2,1</key>
|
||||
@@ -76,6 +90,10 @@
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir6,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2013 or Early 2014)</string>
|
||||
<key>MacBookAir7,1</key>
|
||||
<string>MacBook Air (Core i5 or i7, 11 inch, Early 2015)</string>
|
||||
<key>MacBookAir7,2</key>
|
||||
<string>MacBook Air (Core i5 or i7, 13 inch, Early 2015)</string>
|
||||
<key>MacBookPro1,1</key>
|
||||
<string>MacBook Pro Core Duo (15-inch)</string>
|
||||
<key>MacBookPro1,2</key>
|
||||
@@ -90,8 +108,70 @@
|
||||
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
||||
<key>MacBookPro4,1</key>
|
||||
<string>MacBook Pro (Core 2 Duo Feb 2008)</string>
|
||||
<key>MacBookPro5,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,2</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,3</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,4</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro5,5</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (aluminum unibody)</string>
|
||||
<key>MacBookPro6,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro6,2</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7 (mid 2010)</string>
|
||||
<key>MacBookPro7,1</key>
|
||||
<string>MacBook Pro Intel Core 2 Duo (mid 2010)</string>
|
||||
<key>MacBookPro8,1</key>
|
||||
<string>MacBook Pro Intel Core i5, Intel Core i7, 13" (early 2011)</string>
|
||||
<key>MacBookPro8,2</key>
|
||||
<string>MacBook Pro Intel Core i7, 15" (early 2011)</string>
|
||||
<key>MacBookPro8,3</key>
|
||||
<string>MacBook Pro Intel Core i7, 17" (early 2011)</string>
|
||||
<key>MacBookPro9,1</key>
|
||||
<string>MacBook Pro (15-inch, Mid 2012)</string>
|
||||
<key>MacBookPro9,2</key>
|
||||
<string>MacBook Pro (13-inch, Mid 2012)</string>
|
||||
<key>MacBookPro10,1</key>
|
||||
<string>MacBook Pro (Retina, Mid 2012)</string>
|
||||
<key>MacBookPro10,2</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2012)</string>
|
||||
<key>MacBookPro11,1</key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,2</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacBookPro11,3</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Late 2013)</string>
|
||||
<key>MacbookPro11,4</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro11,5</key>
|
||||
<string>MacBook Pro (Retina, 15-inch, Mid 2015)</string>
|
||||
<key>MacbookPro12,1 </key>
|
||||
<string>MacBook Pro (Retina, 13-inch, Early 2015)</string>
|
||||
<key>Macmini1,1</key>
|
||||
<string>Mac Mini (Core Solo/Duo)</string>
|
||||
<key>Macmini2,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini3,1</key>
|
||||
<string>Mac mini Intel Core</string>
|
||||
<key>Macmini4,1</key>
|
||||
<string>Mac mini Intel Core (Mid 2010)</string>
|
||||
<key>Macmini5,1</key>
|
||||
<string>Mac mini (Core i5, Mid 2011)</string>
|
||||
<key>Macmini5,2</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Mid 2011)</string>
|
||||
<key>Macmini5,3</key>
|
||||
<string>Mac mini (Core i7, Server, Mid 2011)</string>
|
||||
<key>Macmini6,1</key>
|
||||
<string>Mac mini (Core i5, Late 2012)</string>
|
||||
<key>Macmini6,2</key>
|
||||
<string>Mac mini (Core i7, Normal or Server, Late 2012)</string>
|
||||
<key>Macmini7,1</key>
|
||||
<string>Mac mini (Core i5 or Core i7, Late 2014)</string>
|
||||
<key>MacPro1,1,Quad</key>
|
||||
<string>Mac Pro</string>
|
||||
<key>MacPro1,1</key>
|
||||
<string>Mac Pro (four-core)</string>
|
||||
<key>MacPro2,1</key>
|
||||
@@ -101,7 +181,9 @@
|
||||
<key>MacPro4,1</key>
|
||||
<string>Mac Pro (March 2009)</string>
|
||||
<key>MacPro5,1</key>
|
||||
<string>Mac Pro (August 2010)</string>
|
||||
<string>Mac Pro (2010 or 2012)</string>
|
||||
<key>MacPro6,1</key>
|
||||
<string>Mac Pro (Late 2013)</string>
|
||||
<key>PowerBook1,1</key>
|
||||
<string>PowerBook G3</string>
|
||||
<key>PowerBook2,1</key>
|
||||
@@ -164,14 +246,6 @@
|
||||
<string>Power Macintosh G3 (Blue & White)</string>
|
||||
<key>PowerMac1,2</key>
|
||||
<string>Power Macintosh G4 (PCI Graphics)</string>
|
||||
<key>PowerMac10,1</key>
|
||||
<string>Mac Mini G4</string>
|
||||
<key>PowerMac10,2</key>
|
||||
<string>Mac Mini (Late 2005)</string>
|
||||
<key>PowerMac11,2</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac12,1</key>
|
||||
<string>iMac G5 (iSight)</string>
|
||||
<key>PowerMac2,1</key>
|
||||
<string>iMac G3 (Slot-loading CD-ROM)</string>
|
||||
<key>PowerMac2,2</key>
|
||||
@@ -198,6 +272,8 @@
|
||||
<string>iMac G4 (17-inch Flat Panel)</string>
|
||||
<key>PowerMac5,1</key>
|
||||
<string>Power Macintosh G4 Cube</string>
|
||||
<key>PowerMac5,2</key>
|
||||
<string>Power Mac G4 Cube</string>
|
||||
<key>PowerMac6,1</key>
|
||||
<string>iMac G4 (USB 2.0)</string>
|
||||
<key>PowerMac6,3</key>
|
||||
@@ -214,6 +290,14 @@
|
||||
<string>iMac G5 (Ambient Light Sensor)</string>
|
||||
<key>PowerMac9,1</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac10,1</key>
|
||||
<string>Mac Mini G4</string>
|
||||
<key>PowerMac10,2</key>
|
||||
<string>Mac Mini (Late 2005)</string>
|
||||
<key>PowerMac11,2</key>
|
||||
<string>Power Macintosh G5 (Late 2005)</string>
|
||||
<key>PowerMac12,1</key>
|
||||
<string>iMac G5 (iSight)</string>
|
||||
<key>RackMac1,1</key>
|
||||
<string>Xserve G4</string>
|
||||
<key>RackMac1,2</key>
|
||||
@@ -224,5 +308,7 @@
|
||||
<string>Xserve (Intel Xeon)</string>
|
||||
<key>Xserve2,1</key>
|
||||
<string>Xserve (January 2008 quad-core)</string>
|
||||
<key>Xserve3,1</key>
|
||||
<string>Xserve (early 2009)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -2,7 +2,6 @@
|
||||
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<channel>
|
||||
<title>Your Great App's Changelog</title>
|
||||
<link>http://you.com/app/appcast.xml</link>
|
||||
<description>Most recent changes with links to updates.</description>
|
||||
<language>en</language>
|
||||
<item>
|
||||
|
||||
|
After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,31 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.15.0"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "http://sparkle-project.org"
|
||||
s.documentation_url = "http://sparkle-project.org/documentation/"
|
||||
s.screenshot = "http://sparkle-project.org/images/screenshot-noshadow@2x.png"
|
||||
s.license = {
|
||||
:type => 'MIT',
|
||||
:file => 'LICENSE'
|
||||
}
|
||||
s.authors = {
|
||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||
'Kornel Lesiński' => 'pornel@pornel.net',
|
||||
'C.W. Betts' => 'computers57@hotmail.com',
|
||||
'Jake Petroules' => 'jake.petroules@petroules.com',
|
||||
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
|
||||
}
|
||||
|
||||
s.platform = :osx, '10.7'
|
||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||
|
||||
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||
s.vendored_frameworks = 'Sparkle.framework'
|
||||
s.xcconfig = {
|
||||
'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"',
|
||||
'LD_RUNPATH_SEARCH_PATHS' => '@loader_path/../Frameworks'
|
||||
}
|
||||
s.requires_arc = true
|
||||
end
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "14732BC51960F69300593899"
|
||||
BuildableName = "Distribution"
|
||||
BlueprintName = "Distribution"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "612279D80DB5470200AB99EA"
|
||||
BuildableName = "Sparkle Unit Tests.xctest"
|
||||
BlueprintName = "Sparkle Unit Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "14732BC51960F69300593899"
|
||||
BuildableName = "Distribution"
|
||||
BlueprintName = "Distribution"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "14732BC51960F69300593899"
|
||||
BuildableName = "Distribution"
|
||||
BlueprintName = "Distribution"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "14732BC51960F69300593899"
|
||||
BuildableName = "Distribution"
|
||||
BlueprintName = "Distribution"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "612279D80DB5470200AB99EA"
|
||||
BuildableName = "Sparkle Unit Tests.xctest"
|
||||
BlueprintName = "Sparkle Unit Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugXPCServices = "NO"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8DC2EF4F0486A6940098B216"
|
||||
BuildableName = "Sparkle.framework"
|
||||
BlueprintName = "Sparkle"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0800"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "726B2B5C1C645FC900388755"
|
||||
BuildableName = "UI Tests.xctest"
|
||||
BlueprintName = "UI Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
@@ -21,12 +21,14 @@
|
||||
<key>LSBackgroundOnly</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.6</string>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>LSUIElement</key>
|
||||
<string>1</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}.icns</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -3,222 +3,274 @@
|
||||
#import "SUHost.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUStatusController.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*!
|
||||
* Time this app uses to recheck if the parent has already died.
|
||||
*/
|
||||
static const NSTimeInterval SUParentQuitCheckInterval = .25;
|
||||
|
||||
@interface TerminationListener : NSObject
|
||||
|
||||
- (instancetype)initWithProcessId:(pid_t)pid;
|
||||
|
||||
@end
|
||||
|
||||
@interface TerminationListener ()
|
||||
|
||||
@property (nonatomic, assign) pid_t processIdentifier;
|
||||
@property (nonatomic, strong) NSTimer *watchdogTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
|
||||
@synthesize processIdentifier = _processIdentifier;
|
||||
@synthesize watchdogTimer = _watchdogTimer;
|
||||
|
||||
- (instancetype)initWithProcessId:(pid_t)pid
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.processIdentifier = pid;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cleanupWithCompletion:(void (^)(void))completionBlock
|
||||
{
|
||||
[self.watchdogTimer invalidate];
|
||||
completionBlock();
|
||||
}
|
||||
|
||||
- (void)startListeningWithCompletion:(void (^)(void))completionBlock
|
||||
{
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
if (alreadyTerminated)
|
||||
[self cleanupWithCompletion:completionBlock];
|
||||
else
|
||||
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:completionBlock repeats:YES];
|
||||
}
|
||||
|
||||
- (void)watchdog:(NSTimer *)timer
|
||||
{
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.processIdentifier]) {
|
||||
[self cleanupWithCompletion:timer.userInfo];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
* If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback.
|
||||
*/
|
||||
static const NSTimeInterval SUInstallationTimeLimit = 5;
|
||||
|
||||
/*!
|
||||
* Time this app uses to recheck if the parent has already died.
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
* This delay should be be high enough to increase the likelihood that our updated app will be launched up front,
|
||||
* but should be low enough so that the user doesn't ponder why the updater hasn't finished terminating yet
|
||||
*/
|
||||
static const NSTimeInterval SUParentQuitCheckInterval = .5;
|
||||
static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
|
||||
@interface TerminationListener : NSObject <SUInstallerDelegate>
|
||||
{
|
||||
const char *hostpath;
|
||||
const char *executablepath;
|
||||
pid_t parentprocessid;
|
||||
const char *folderpath;
|
||||
NSString *selfPath;
|
||||
NSString *installationPath;
|
||||
NSTimer *watchdogTimer;
|
||||
NSTimer *longInstallationTimer;
|
||||
SUHost *host;
|
||||
BOOL shouldRelaunch;
|
||||
BOOL shouldShowUI;
|
||||
}
|
||||
@interface AppInstaller : NSObject <NSApplicationDelegate>
|
||||
|
||||
- (void) parentHasQuit;
|
||||
|
||||
- (void) relaunch;
|
||||
- (void) install;
|
||||
|
||||
- (void) showAppIconInDock:(NSTimer *)aTimer;
|
||||
- (void) watchdog:(NSTimer *)aTimer;
|
||||
/*
|
||||
* hostPath - path to host (original) application
|
||||
* relaunchPath - path to what the host wants to relaunch (default is same as hostPath)
|
||||
* parentProcessId - process identifier of the host before launching us
|
||||
* updateFolderPath - path to update folder (i.e, temporary directory containing the new update)
|
||||
* shouldRelaunch - indicates if the new installed app should re-launched
|
||||
* shouldShowUI - indicates if we should show the status window when installing the update
|
||||
*/
|
||||
- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TerminationListener
|
||||
@interface AppInstaller ()
|
||||
|
||||
- (instancetype) initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath:(const char*)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString*)inSelfPath
|
||||
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||
@property (nonatomic, strong) SUStatusController *statusController;
|
||||
|
||||
@property (nonatomic, copy) NSString *updateFolderPath;
|
||||
@property (nonatomic, copy) NSString *hostPath;
|
||||
@property (nonatomic, copy) NSString *relaunchPath;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||
|
||||
@property (nonatomic, assign) BOOL isTerminating;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInstaller
|
||||
|
||||
@synthesize terminationListener = _terminationListener;
|
||||
@synthesize statusController = _statusController;
|
||||
@synthesize updateFolderPath = _updateFolderPath;
|
||||
@synthesize hostPath = _hostPath;
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@synthesize shouldShowUI = _shouldShowUI;
|
||||
@synthesize isTerminating = _isTerminating;
|
||||
|
||||
- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
hostpath = inhostpath;
|
||||
executablepath = execpath;
|
||||
parentprocessid = ppid;
|
||||
folderpath = infolderpath;
|
||||
selfPath = [inSelfPath retain];
|
||||
shouldRelaunch = relaunch;
|
||||
shouldShowUI = showUI;
|
||||
|
||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
||||
|
||||
if( alreadyTerminated )
|
||||
[self parentHasQuit];
|
||||
else
|
||||
watchdogTimer = [[NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES] retain];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[longInstallationTimer invalidate];
|
||||
[longInstallationTimer release];
|
||||
longInstallationTimer = nil;
|
||||
|
||||
[selfPath release];
|
||||
selfPath = nil;
|
||||
|
||||
[installationPath release];
|
||||
|
||||
[watchdogTimer release];
|
||||
watchdogTimer = nil;
|
||||
|
||||
[host release];
|
||||
host = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
-(void) parentHasQuit
|
||||
{
|
||||
[watchdogTimer invalidate];
|
||||
longInstallationTimer = [[NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
|
||||
target: self selector: @selector(showAppIconInDock:)
|
||||
userInfo:nil repeats:NO] retain];
|
||||
|
||||
if( folderpath )
|
||||
[self install];
|
||||
else
|
||||
[self relaunch];
|
||||
}
|
||||
|
||||
- (void)watchdog:(NSTimer *) __unused aTimer
|
||||
{
|
||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:parentprocessid]) {
|
||||
[self parentHasQuit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAppIconInDock:(NSTimer *) __unused aTimer
|
||||
{
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType( &psn, kProcessTransformToForegroundApplication );
|
||||
}
|
||||
|
||||
|
||||
- (void) relaunch __attribute__((noreturn))
|
||||
{
|
||||
if (shouldRelaunch)
|
||||
{
|
||||
NSString *appPath = nil;
|
||||
if( !folderpath || strcmp(executablepath, hostpath) != 0 )
|
||||
appPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:executablepath length:strlen(executablepath)];
|
||||
else
|
||||
appPath = installationPath;
|
||||
[[NSWorkspace sharedWorkspace] openFile: appPath];
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (folderpath)
|
||||
{
|
||||
NSError *theError = nil;
|
||||
if( ![SUPlainInstaller _removeFileAtPath: [SUInstaller updateFolder] error: &theError] )
|
||||
SULog( @"Couldn't remove update folder: %@.", theError );
|
||||
}
|
||||
[[NSFileManager defaultManager] removeItemAtPath: selfPath error: NULL];
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
self.hostPath = hostPath;
|
||||
self.relaunchPath = relaunchPath;
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessId:parentProcessId];
|
||||
self.updateFolderPath = updateFolderPath;
|
||||
self.shouldRelaunch = shouldRelaunch;
|
||||
self.shouldShowUI = shouldShowUI;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void) install
|
||||
- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification
|
||||
{
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: hostpath length:strlen(hostpath)]];
|
||||
host = [[SUHost alloc] initWithBundle: theBundle];
|
||||
installationPath = [[host installationPath] copy];
|
||||
[self.terminationListener startListeningWithCompletion:^{
|
||||
self.terminationListener = nil;
|
||||
|
||||
if (self.shouldShowUI) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.isTerminating) {
|
||||
// Show app icon in the dock
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[self install];
|
||||
}];
|
||||
}
|
||||
|
||||
if (shouldShowUI) {
|
||||
SUStatusController* statusCtl = [[SUStatusController alloc] initWithHost: host]; // We quit anyway after we've installed, so leak this for now.
|
||||
[statusCtl setButtonTitle: SULocalizedString(@"Cancel Update",@"") target: nil action: Nil isDefault: NO];
|
||||
[statusCtl beginActionWithTitle: SULocalizedString(@"Installing update...",@"")
|
||||
maxProgressValue: 0 statusText: @""];
|
||||
[statusCtl showWindow: self];
|
||||
[statusCtl release];
|
||||
- (void)install
|
||||
{
|
||||
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath];
|
||||
SUHost *host = [[SUHost alloc] initWithBundle:theBundle];
|
||||
NSString *installationPath = [[host installationPath] copy];
|
||||
|
||||
if (self.shouldShowUI) {
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:host];
|
||||
[self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
|
||||
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
|
||||
maxProgressValue: 0 statusText: @""];
|
||||
[self.statusController showWindow:self];
|
||||
}
|
||||
|
||||
[SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:folderpath length:strlen(folderpath)]
|
||||
|
||||
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
|
||||
SULog(@"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
|
||||
}
|
||||
|
||||
[SUInstaller installFromUpdateFolder:self.updateFolderPath
|
||||
overHost:host
|
||||
installationPath:installationPath
|
||||
delegate:self
|
||||
versionComparator:[SUStandardVersionComparator defaultComparator]];
|
||||
fileOperationToolPath:fileOperationToolPath
|
||||
versionComparator:[SUStandardVersionComparator defaultComparator]
|
||||
completionHandler:^(NSError *error) {
|
||||
if (error) {
|
||||
NSError *underlyingError = [error.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
|
||||
SULog(@"Installation Error: %@", error);
|
||||
if (self.shouldShowUI) {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
alert.messageText = @"";
|
||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||
[alert runModal];
|
||||
}
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
NSString *pathToRelaunch = nil;
|
||||
// If the installation path differs from the host path, we give higher precedence for it than
|
||||
// if the desired relaunch path differs from the host path
|
||||
if (![installationPath.pathComponents isEqualToArray:self.hostPath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.hostPath.pathComponents]) {
|
||||
pathToRelaunch = installationPath;
|
||||
} else {
|
||||
pathToRelaunch = self.relaunchPath;
|
||||
}
|
||||
[self cleanupAndTerminateWithPathToRelaunch:pathToRelaunch];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)installerFinishedForHost:(SUHost *) __unused aHost
|
||||
- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath
|
||||
{
|
||||
[self relaunch];
|
||||
}
|
||||
|
||||
- (void)installerForHost:(SUHost *) __unused host failedWithError:(NSError *)error __attribute__((noreturn))
|
||||
{
|
||||
if (shouldShowUI)
|
||||
NSRunAlertPanel( @"", @"%@", @"OK", @"", @"", [error localizedDescription] );
|
||||
exit(EXIT_FAILURE);
|
||||
self.isTerminating = YES;
|
||||
|
||||
dispatch_block_t cleanupAndExit = ^{
|
||||
NSError *theError = nil;
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:self.updateFolderPath error:&theError]) {
|
||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
||||
}
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL];
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
};
|
||||
|
||||
if (self.shouldRelaunch) {
|
||||
// The auto updater can terminate before the newly updated app is finished launching
|
||||
// If that happens, the OS may not make the updated app active and frontmost
|
||||
// (Or it does become frontmost, but the OS backgrounds it afterwards.. It's some kind of timing/activation issue that doesn't occur all the time)
|
||||
// The only remedy I've been able to find is waiting an arbitrary delay before exiting our application
|
||||
|
||||
// Don't use -launchApplication: because we may not be launching an application. Eg: it could be a system prefpane
|
||||
if (![[NSWorkspace sharedWorkspace] openFile:relaunchPath]) {
|
||||
SULog(@"Failed to launch %@", relaunchPath);
|
||||
}
|
||||
|
||||
[self.statusController close];
|
||||
|
||||
// Don't even think about hiding the app icon from the dock if we've already shown it
|
||||
// Transforming the app back to a background one has a backfiring effect, decreasing the likelihood
|
||||
// that the updated app will be brought up front
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUTerminationTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
cleanupAndExit();
|
||||
});
|
||||
} else {
|
||||
cleanupAndExit();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
int main(int __unused argc, const char __unused *argv[])
|
||||
{
|
||||
if (argc < 5 || argc > 7) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@autoreleasepool
|
||||
{
|
||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||
if (args.count < 5 || args.count > 7) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
NSApplication *application = [NSApplication sharedApplication];
|
||||
|
||||
@autoreleasepool {
|
||||
//ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
//TransformProcessType( &psn, kProcessTransformToForegroundApplication );
|
||||
BOOL shouldShowUI = (args.count > 6) ? [[args objectAtIndex:6] boolValue] : YES;
|
||||
if (shouldShowUI) {
|
||||
[application activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:[args objectAtIndex:1]
|
||||
relaunchPath:[args objectAtIndex:2]
|
||||
parentProcessId:[[args objectAtIndex:3] intValue]
|
||||
updateFolderPath:[args objectAtIndex:4]
|
||||
shouldRelaunch:(args.count > 5) ? [[args objectAtIndex:5] boolValue] : YES
|
||||
shouldShowUI:shouldShowUI];
|
||||
[application setDelegate:appInstaller];
|
||||
[application run];
|
||||
}
|
||||
|
||||
#if 0 // Cmdline tool
|
||||
NSString* selfPath = nil;
|
||||
if (argv[0][0] == '/') {
|
||||
selfPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])];
|
||||
}
|
||||
else
|
||||
{
|
||||
selfPath = [[NSFileManager defaultManager] currentDirectoryPath];
|
||||
selfPath = [selfPath stringByAppendingPathComponent: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])]];
|
||||
}
|
||||
#else
|
||||
NSString* selfPath = [[NSBundle mainBundle] bundlePath];
|
||||
#endif
|
||||
|
||||
BOOL shouldShowUI = (argc > 6) ? !!atoi(argv[6]) : YES;
|
||||
if (shouldShowUI)
|
||||
{
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
|
||||
}
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
[[[TerminationListener alloc] initWithHostPath: (argc > 1) ? argv[1] : NULL
|
||||
executablePath: (argc > 2) ? argv[2] : NULL
|
||||
parentProcessId: (argc > 3) ? atoi(argv[3]) : 0
|
||||
folderPath: (argc > 4) ? argv[4] : NULL
|
||||
shouldRelaunch: (argc > 5) ? !!atoi(argv[5]) : YES
|
||||
shouldShowUI: shouldShowUI
|
||||
selfPath: selfPath] autorelease];
|
||||
[[NSApplication sharedApplication] run];
|
||||
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// Sparkle.pch
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 7/23/08.
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#define SPARKLE_BUNDLE [NSBundle mainBundle]
|
||||
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
|
||||
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUConstants.h"
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/xcrun swift
|
||||
|
||||
import Foundation
|
||||
|
||||
func die(msg: String) {
|
||||
print("ERROR: \(msg)")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
extension NSXMLElement {
|
||||
convenience init(name: String, attributes: [String: String], stringValue string: String? = nil) {
|
||||
self.init(name: name, stringValue: string)
|
||||
setAttributesWithDictionary(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
let ud = NSUserDefaults.standardUserDefaults()
|
||||
let sparkleRoot = ud.objectForKey("root") as? String
|
||||
let htmlPath = ud.objectForKey("htmlPath") as? String
|
||||
if sparkleRoot == nil || htmlPath == nil {
|
||||
die("Missing arguments")
|
||||
}
|
||||
|
||||
let enStringsPath = sparkleRoot! + "/Sparkle/en.lproj/Sparkle.strings"
|
||||
let enStringsDict = NSDictionary(contentsOfFile: enStringsPath)
|
||||
if enStringsDict == nil {
|
||||
die("Invalid English strings")
|
||||
}
|
||||
let enStringsDictKeys = enStringsDict!.allKeys
|
||||
|
||||
let dirPath = NSString(string: sparkleRoot! + "/Sparkle")
|
||||
let dirContents = try! NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath as String)
|
||||
let css =
|
||||
"body { font-family: sans-serif; font-size: 10pt; }" +
|
||||
"h1 { font-size: 12pt; }" +
|
||||
".missing { background-color: #FFBABA; color: #D6010E; white-space: pre; }" +
|
||||
".unused { background-color: #BDE5F8; color: #00529B; white-space: pre; }" +
|
||||
".unlocalized { background-color: #FEEFB3; color: #9F6000; white-space: pre; }"
|
||||
var html = NSXMLDocument(rootElement: NSXMLElement(name: "html"))
|
||||
html.DTD = NSXMLDTD()
|
||||
html.DTD!.name = html.rootElement()!.name
|
||||
html.characterEncoding = "UTF-8"
|
||||
html.documentContentKind = NSXMLDocumentContentKind.XHTMLKind
|
||||
var body = NSXMLElement(name: "body")
|
||||
var head = NSXMLElement(name: "head")
|
||||
html.rootElement()!.addChild(head)
|
||||
html.rootElement()!.addChild(body)
|
||||
head.addChild(NSXMLElement(name: "meta", attributes: ["charset": html.characterEncoding!]))
|
||||
head.addChild(NSXMLElement(name: "title", stringValue: "Sparkle Localizations Report"))
|
||||
head.addChild(NSXMLElement(name: "style", stringValue: css))
|
||||
|
||||
let locale = NSLocale.currentLocale()
|
||||
for dirEntry in dirContents {
|
||||
if NSString(string: dirEntry).pathExtension != "lproj" || dirEntry == "en.lproj" {
|
||||
continue
|
||||
}
|
||||
|
||||
let lang = locale.displayNameForKey(NSLocaleLanguageCode, value: NSString(string: dirEntry).stringByDeletingPathExtension)
|
||||
body.addChild(NSXMLElement(name: "h1", stringValue: "\(dirEntry) (\(lang!))"))
|
||||
|
||||
let stringsPath = NSString(string: dirPath.stringByAppendingPathComponent(dirEntry)).stringByAppendingPathComponent("Sparkle.strings")
|
||||
let stringsDict = NSDictionary(contentsOfFile: stringsPath)
|
||||
if stringsDict == nil {
|
||||
die("Invalid strings file \(dirEntry)")
|
||||
continue
|
||||
}
|
||||
|
||||
var missing: [String] = []
|
||||
var unlocalized: [String] = []
|
||||
var unused: [String] = []
|
||||
|
||||
for key in enStringsDictKeys {
|
||||
let str = stringsDict?.objectForKey(key) as? String
|
||||
if str == nil {
|
||||
missing.append(key as! String)
|
||||
} else if let enStr = enStringsDict?.objectForKey(key) as? String {
|
||||
if enStr == str {
|
||||
unlocalized.append(key as! String)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let stringsDictKeys = stringsDict!.allKeys
|
||||
for key in stringsDictKeys {
|
||||
if enStringsDict?.objectForKey(key) == nil {
|
||||
unused.append(key as! String)
|
||||
}
|
||||
}
|
||||
|
||||
let sorter = { (s1: String, s2: String) -> Bool in
|
||||
return s1 < s2
|
||||
}
|
||||
missing.sortInPlace(sorter)
|
||||
unlocalized.sortInPlace(sorter)
|
||||
unused.sortInPlace(sorter)
|
||||
|
||||
let addRow = { (prefix: String, cssClass: String, key: String) -> Void in
|
||||
body.addChild(NSXMLElement(name: "span", attributes: ["class": cssClass], stringValue: [prefix, key].joinWithSeparator(" ") + "\n"))
|
||||
}
|
||||
|
||||
for key in missing {
|
||||
addRow("Missing", "missing", key)
|
||||
}
|
||||
for key in unlocalized {
|
||||
addRow("Unlocalized", "unlocalized", key)
|
||||
}
|
||||
for key in unused {
|
||||
addRow("Unused", "unused", key)
|
||||
}
|
||||
}
|
||||
|
||||
var err: NSError?
|
||||
if !html.XMLData.writeToFile(htmlPath!, atomically: true) {
|
||||
die("Can't write report: \(err)")
|
||||
}
|
||||
@@ -9,29 +9,23 @@
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
@protocol SUAppcastDelegate;
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
@class SUAppcastItem;
|
||||
@interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
{
|
||||
@private
|
||||
NSArray *items;
|
||||
NSString *userAgentString;
|
||||
id<SUAppcastDelegate> delegate;
|
||||
NSString *downloadFilename;
|
||||
NSURLDownload *download;
|
||||
}
|
||||
@property (assign) id<SUAppcastDelegate> delegate;
|
||||
@property (copy) NSString *userAgentString;
|
||||
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url;
|
||||
@property (copy) NSString *userAgentString;
|
||||
@property (copy) NSDictionary *httpHeaders;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||
|
||||
@property (readonly, copy) NSArray *items;
|
||||
@end
|
||||
|
||||
@protocol SUAppcastDelegate <NSObject>
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
|
||||
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -22,247 +22,307 @@
|
||||
@implementation NSXMLElement (SUAppcastExtensions)
|
||||
- (NSDictionary *)attributesAsDictionary
|
||||
{
|
||||
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
NSEnumerator *attributeEnum = [[self attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
dictionary[[attribute name]] = [attribute stringValue];
|
||||
}
|
||||
return dictionary;
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
NSString *attrName = [attribute name];
|
||||
if (!attrName) {
|
||||
continue;
|
||||
}
|
||||
NSString *attributeStringValue = [attribute stringValue];
|
||||
if (attributeStringValue != nil) {
|
||||
[dictionary setObject:attributeStringValue forKey:attrName];
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface SUAppcast () <NSURLDownloadDelegate>
|
||||
@property (strong) void (^completionBlock)(NSError *);
|
||||
@property (copy) NSString *downloadFilename;
|
||||
@property (retain) NSURLDownload *download;
|
||||
@property (strong) NSURLDownload *download;
|
||||
@property (copy) NSArray *items;
|
||||
- (void)reportError:(NSError *)error;
|
||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
|
||||
@end
|
||||
|
||||
@implementation SUAppcast
|
||||
|
||||
@synthesize downloadFilename;
|
||||
@synthesize delegate;
|
||||
@synthesize completionBlock;
|
||||
@synthesize userAgentString;
|
||||
@synthesize httpHeaders;
|
||||
@synthesize download;
|
||||
@synthesize items;
|
||||
|
||||
- (void)dealloc
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
|
||||
{
|
||||
self.items = nil;
|
||||
self.userAgentString = nil;
|
||||
self.downloadFilename = nil;
|
||||
self.download = nil;
|
||||
self.completionBlock = block;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
||||
if (userAgentString) {
|
||||
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
}
|
||||
if (self.userAgentString) {
|
||||
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||
}
|
||||
|
||||
self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease];
|
||||
if (self.httpHeaders) {
|
||||
for (NSString *key in self.httpHeaders) {
|
||||
id value = [self.httpHeaders objectForKey:key];
|
||||
[request setValue:value forHTTPHeaderField:key];
|
||||
}
|
||||
}
|
||||
|
||||
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
|
||||
|
||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
|
||||
{
|
||||
NSString* destinationFilename = NSTemporaryDirectory();
|
||||
NSString *destinationFilename = NSTemporaryDirectory();
|
||||
if (destinationFilename)
|
||||
{
|
||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
||||
[download setDestination:destinationFilename allowOverwrite:NO];
|
||||
}
|
||||
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
|
||||
[self.download setDestination:destinationFilename allowOverwrite:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload didCreateDestination:(NSString *)path
|
||||
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
|
||||
{
|
||||
self.downloadFilename = path;
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *) __unused aDownload
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
|
||||
{
|
||||
NSError *error = nil;
|
||||
NSError *error = nil;
|
||||
NSArray *appcastItems = [self parseAppcastItemsFromXMLFile:[NSURL fileURLWithPath:self.downloadFilename] error:&error];
|
||||
|
||||
NSXMLDocument *document = nil;
|
||||
BOOL failed = NO;
|
||||
NSArray *xmlItems = nil;
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
|
||||
if (downloadFilename)
|
||||
{
|
||||
NSUInteger options = 0;
|
||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
||||
document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:options error:&error] autorelease];
|
||||
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
self.downloadFilename = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = YES;
|
||||
}
|
||||
|
||||
if (nil == document)
|
||||
{
|
||||
failed = YES;
|
||||
if (appcastItems) {
|
||||
self.items = appcastItems;
|
||||
self.completionBlock(nil);
|
||||
self.completionBlock = nil;
|
||||
} else {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary
|
||||
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
|
||||
forKey: NSLocalizedDescriptionKey];
|
||||
if (error) {
|
||||
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
|
||||
}
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUAppcastParseError
|
||||
userInfo:userInfo]];
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlItems = [document nodesForXPath:@"/rss/channel/item" error:&error];
|
||||
if (nil == xmlItems)
|
||||
{
|
||||
failed = YES;
|
||||
}
|
||||
|
||||
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
|
||||
{
|
||||
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
|
||||
for (NSXMLNode *attribute in attributeEnum) {
|
||||
NSString *attrName = [self sparkleNamespacedNameOfNode:attribute];
|
||||
if (!attrName) {
|
||||
continue;
|
||||
}
|
||||
NSString *stringValue = [attribute stringValue];
|
||||
if (stringValue) {
|
||||
[dictionary setObject:stringValue forKey:attrName];
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
if (failed == NO)
|
||||
{
|
||||
-(NSString *)sparkleNamespacedNameOfNode:(NSXMLNode *)node {
|
||||
// XML namespace prefix is semantically meaningless, so compare namespace URI
|
||||
// NS URI isn't used to fetch anything, and must match exactly, so we look for http:// not https://
|
||||
if ([[node URI] isEqualToString:@"http://www.andymatuschak.org/xml-namespaces/sparkle"]) {
|
||||
NSString *localName = [node localName];
|
||||
assert(localName);
|
||||
return [@"sparkle:" stringByAppendingString:localName];
|
||||
} else {
|
||||
return [node name]; // Backwards compatibility
|
||||
}
|
||||
}
|
||||
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
|
||||
if (errorp) {
|
||||
*errorp = nil;
|
||||
}
|
||||
|
||||
while (failed == NO && (node = [nodeEnum nextObject]))
|
||||
{
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
if ([[node children] count])
|
||||
{
|
||||
node = [node childAtIndex:0];
|
||||
while (nil != node)
|
||||
{
|
||||
NSString *name = [node name];
|
||||
if (name)
|
||||
{
|
||||
NSMutableArray *nodes = nodesDict[name];
|
||||
if (nodes == nil)
|
||||
{
|
||||
nodes = [NSMutableArray array];
|
||||
nodesDict[name] = nodes;
|
||||
}
|
||||
[nodes addObject:node];
|
||||
if (!appcastFile) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
||||
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:appcastFile options:options error:errorp];
|
||||
if (nil == document) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSArray *xmlItems = [document nodesForXPath:@"/rss/channel/item" error:errorp];
|
||||
if (nil == xmlItems) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||
NSXMLNode *node;
|
||||
|
||||
while((node = [nodeEnum nextObject])) {
|
||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
|
||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||
if ([[node children] count]) {
|
||||
node = [node childAtIndex:0];
|
||||
while (nil != node) {
|
||||
NSString *name = [self sparkleNamespacedNameOfNode:node];
|
||||
if (name) {
|
||||
NSMutableArray *nodes = [nodesDict objectForKey:name];
|
||||
if (nodes == nil) {
|
||||
nodes = [NSMutableArray array];
|
||||
[nodesDict setObject:nodes forKey:name];
|
||||
}
|
||||
node = [node nextSibling];
|
||||
[nodes addObject:node];
|
||||
}
|
||||
node = [node nextSibling];
|
||||
}
|
||||
}
|
||||
|
||||
for (NSString *name in nodesDict) {
|
||||
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
|
||||
if ([name isEqualToString:SURSSElementEnclosure]) {
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||
[dict setObject:encDict forKey:name];
|
||||
}
|
||||
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||
// We don't want to parse and create a NSDate instance -
|
||||
// that's a risk we can avoid. We don't use the date anywhere other
|
||||
// than it being accessible from SUAppcastItem
|
||||
NSString *dateString = node.stringValue;
|
||||
if (dateString) {
|
||||
[dict setObject:dateString forKey:name];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:SURSSElementEnclosure]) {
|
||||
[deltas addObject:[self attributesOfNode:(NSXMLElement *)child]];
|
||||
}
|
||||
}
|
||||
[dict setObject:deltas forKey:name];
|
||||
}
|
||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||
NSMutableArray *tags = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
NSString *childName = child.name;
|
||||
if (childName) {
|
||||
[tags addObject:childName];
|
||||
}
|
||||
}
|
||||
[dict setObject:tags forKey:name];
|
||||
}
|
||||
else if (name != nil) {
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
[dict setObject:theValue forKey:name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (NSString *name in nodesDict)
|
||||
{
|
||||
node = [self bestNodeInNodes:nodesDict[name]];
|
||||
if ([name isEqualToString:@"enclosure"])
|
||||
{
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
||||
dict[@"enclosure"] = encDict;
|
||||
|
||||
}
|
||||
else if ([name isEqualToString:@"pubDate"])
|
||||
{
|
||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
||||
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
|
||||
if (date)
|
||||
dict[name] = date;
|
||||
}
|
||||
else if ([name isEqualToString:@"sparkle:deltas"])
|
||||
{
|
||||
NSMutableArray *deltas = [NSMutableArray array];
|
||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||
for (NSXMLNode *child in childEnum) {
|
||||
if ([[child name] isEqualToString:@"enclosure"])
|
||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
||||
}
|
||||
dict[@"deltas"] = deltas;
|
||||
}
|
||||
else if (name != nil)
|
||||
{
|
||||
// add all other values as strings
|
||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
if (theValue != nil) {
|
||||
dict[name] = theValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString] autorelease];
|
||||
if (anItem)
|
||||
{
|
||||
[appcastItems addObject:anItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
}
|
||||
[nodesDict removeAllObjects];
|
||||
[dict removeAllObjects];
|
||||
NSString *errString;
|
||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||
if (anItem) {
|
||||
[appcastItems addObject:anItem];
|
||||
}
|
||||
}
|
||||
else {
|
||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
||||
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUAppcastParseError
|
||||
userInfo:@{NSLocalizedDescriptionKey: errString}];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
self.items = appcastItems;
|
||||
|
||||
if ([appcastItems count])
|
||||
{
|
||||
NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO] autorelease];
|
||||
[appcastItems sortUsingDescriptors:@[sort]];
|
||||
self.items = appcastItems;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil)}]];
|
||||
}
|
||||
else if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
|
||||
{
|
||||
[delegate appcastDidFinishLoading:self];
|
||||
}
|
||||
return appcastItems;
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused aDownload didFailWithError:(NSError *)error
|
||||
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
||||
{
|
||||
if (downloadFilename)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:downloadFilename error:nil];
|
||||
}
|
||||
self.downloadFilename = nil;
|
||||
if (self.downloadFilename) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||
}
|
||||
self.downloadFilename = nil;
|
||||
|
||||
[self reportError:error];
|
||||
[self reportError:error];
|
||||
}
|
||||
|
||||
- (NSURLRequest *)download:(NSURLDownload *) __unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *) __unused redirectResponse
|
||||
- (NSURLRequest *)download:(NSURLDownload *)__unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)__unused redirectResponse
|
||||
{
|
||||
return request;
|
||||
return request;
|
||||
}
|
||||
|
||||
- (void)reportError:(NSError *)error
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
|
||||
{
|
||||
[delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
}
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||
NSUnderlyingErrorKey: error,
|
||||
}];
|
||||
|
||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
|
||||
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:userInfo]);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
|
||||
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes
|
||||
{
|
||||
// We use this method to pick out the localized version of a node when one's available.
|
||||
// We use this method to pick out the localized version of a node when one's available.
|
||||
if ([nodes count] == 1)
|
||||
return nodes[0];
|
||||
return [nodes objectAtIndex:0];
|
||||
else if ([nodes count] == 0)
|
||||
return nil;
|
||||
|
||||
NSMutableArray *languages = [NSMutableArray array];
|
||||
NSString *lang;
|
||||
NSUInteger i;
|
||||
for (NSXMLElement *node in nodes) {
|
||||
for (NSXMLElement *node in nodes) {
|
||||
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
||||
[languages addObject:(lang ? lang : @"")];
|
||||
}
|
||||
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
|
||||
lang = [[NSBundle preferredLocalizationsFromArray:languages] objectAtIndex:0];
|
||||
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
||||
if (i == NSNotFound) {
|
||||
if (i == NSNotFound) {
|
||||
i = 0;
|
||||
}
|
||||
return nodes[i];
|
||||
}
|
||||
return [nodes objectAtIndex:i];
|
||||
}
|
||||
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates {
|
||||
SUAppcast *other = [SUAppcast new];
|
||||
NSMutableArray *nonDeltaItems = [NSMutableArray new];
|
||||
|
||||
for(SUAppcastItem *item in self.items) {
|
||||
if (![item isDeltaUpdate]) [nonDeltaItems addObject:item];
|
||||
}
|
||||
|
||||
other.items = nonDeltaItems;
|
||||
return other;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,31 +9,39 @@
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
@interface SUAppcastItem : NSObject
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (retain, readonly) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (retain, readonly) NSURL *fileURL;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (retain, readonly) NSURL *infoURL; // UK 2007-08-31
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
- (NSURL *)infoURL; // UK 2007-08-31
|
||||
- (NSURL *)infoURL;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -16,22 +16,22 @@
|
||||
|
||||
@interface SUAppcastItem ()
|
||||
@property (copy, readwrite) NSString *title;
|
||||
@property (copy, readwrite) NSDate *date;
|
||||
@property (copy, readwrite) NSString *dateString;
|
||||
@property (copy, readwrite) NSString *itemDescription;
|
||||
@property (retain, readwrite) NSURL *releaseNotesURL;
|
||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@property (copy, readwrite) NSString *minimumSystemVersion;
|
||||
@property (copy, readwrite) NSString *maximumSystemVersion;
|
||||
@property (retain, readwrite) NSURL *fileURL;
|
||||
@property (strong, readwrite) NSURL *fileURL;
|
||||
@property (copy, readwrite) NSString *versionString;
|
||||
@property (copy, readwrite) NSString *displayVersionString;
|
||||
@property (copy, readwrite) NSDictionary *deltaUpdates;
|
||||
@property (retain, readwrite) NSURL *infoURL;
|
||||
@property (strong, readwrite) NSURL *infoURL;
|
||||
@property (readwrite, copy) NSDictionary *propertiesDictionary;
|
||||
@end
|
||||
|
||||
@implementation SUAppcastItem
|
||||
@synthesize date;
|
||||
@synthesize dateString;
|
||||
@synthesize deltaUpdates;
|
||||
@synthesize displayVersionString;
|
||||
@synthesize DSASignature;
|
||||
@@ -47,152 +47,150 @@
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
{
|
||||
return propertiesDictionary[@"enclosure"][@"sparkle:deltaFrom"] != nil;
|
||||
NSDictionary *rssElementEnclosure = [self.propertiesDictionary objectForKey:SURSSElementEnclosure];
|
||||
return [rssElementEnclosure objectForKey:SUAppcastAttributeDeltaFrom] != nil;
|
||||
}
|
||||
|
||||
- (BOOL)isCriticalUpdate
|
||||
{
|
||||
return [propertiesDictionary[@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
|
||||
return [[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||
}
|
||||
|
||||
- (instancetype) initWithDictionary:(NSDictionary *)dict
|
||||
- (BOOL)isInformationOnlyUpdate
|
||||
{
|
||||
return [self initWithDictionary:dict failureReason:nil];
|
||||
return self.infoURL && !self.fileURL;
|
||||
}
|
||||
|
||||
- (instancetype) initWithDictionary:(NSDictionary *)dict failureReason:(NSString**)error
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
id enclosure = dict[@"enclosure"];
|
||||
return [self initWithDictionary:dict failureReason:nil];
|
||||
}
|
||||
|
||||
// Try to find a version string.
|
||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
|
||||
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
|
||||
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
|
||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = enclosure[@"sparkle:version"];
|
||||
if( newVersion == nil )
|
||||
newVersion = dict[@"sparkle:version"]; // UK 2007-08-31 Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||
// then we remove the extension. Hopefully, this will be the version.
|
||||
NSArray *fileComponents = [enclosure[@"url"] componentsSeparatedByString:@"_"];
|
||||
if ([fileComponents count] > 1)
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSDictionary *enclosure = [dict objectForKey:SURSSElementEnclosure];
|
||||
|
||||
if(!newVersion )
|
||||
{
|
||||
if (error)
|
||||
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
// Try to find a version string.
|
||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||
// 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
|
||||
// 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
|
||||
// that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
|
||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
||||
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
|
||||
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||
NSString *newVersion = [enclosure objectForKey:SUAppcastAttributeVersion];
|
||||
if (newVersion == nil) {
|
||||
newVersion = [dict objectForKey:SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||
}
|
||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||
{
|
||||
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, [enclosure objectForKey:SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
|
||||
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = dict[@"title"];
|
||||
self.date = dict[@"pubDate"];
|
||||
self.itemDescription = dict[@"description"];
|
||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||
// then we remove the extension. Hopefully, this will be the version.
|
||||
NSArray *fileComponents = [[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
||||
if ([fileComponents count] > 1) {
|
||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||
}
|
||||
}
|
||||
|
||||
NSString* theInfoURL = dict[@"link"];
|
||||
if( theInfoURL )
|
||||
{
|
||||
if( ![theInfoURL isKindOfClass: [NSString class]] )
|
||||
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
|
||||
else
|
||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
if (!newVersion) {
|
||||
if (error) {
|
||||
*error = [NSString stringWithFormat:@"Feed item lacks %@ attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)", SUAppcastAttributeVersion];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
if( !enclosure && !theInfoURL )
|
||||
{
|
||||
if (error)
|
||||
*error = @"No enclosure in feed item";
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||
self.title = [dict objectForKey:SURSSElementTitle];
|
||||
self.dateString = [dict objectForKey:SURSSElementPubDate];
|
||||
self.itemDescription = [dict objectForKey:SURSSElementDescription];
|
||||
|
||||
NSString* enclosureURLString = enclosure[@"url"];
|
||||
if( !enclosureURLString && !theInfoURL )
|
||||
{
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
}
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
NSString *theInfoURL = [dict objectForKey:SURSSElementLink];
|
||||
if (theInfoURL) {
|
||||
if (![theInfoURL isKindOfClass:[NSString class]]) {
|
||||
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
} else {
|
||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
}
|
||||
|
||||
if( enclosureURLString ) {
|
||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = enclosure[@"sparkle:dsaSignature"];
|
||||
}
|
||||
// Need an info URL or an enclosure URL. Former to show "More Info"
|
||||
// page, latter to download & install:
|
||||
if (!enclosure && !theInfoURL) {
|
||||
if (error) {
|
||||
*error = @"No enclosure in feed item";
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"];
|
||||
self.maximumSystemVersion = dict[@"sparkle:maximumSystemVersion"];
|
||||
NSString *enclosureURLString = [enclosure objectForKey:SURSSAttributeURL];
|
||||
if (!enclosureURLString && !theInfoURL) {
|
||||
if (error) {
|
||||
*error = @"Feed item's enclosure lacks URL";
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"];
|
||||
if (nil == shortVersionString) {
|
||||
shortVersionString = dict[@"sparkle:shortVersionString"]; // fall back on the <item>
|
||||
}
|
||||
if (enclosureURLString) {
|
||||
// Sparkle used to always URL-encode, so for backwards compatibility spaces in URLs must be forgiven.
|
||||
NSString *fileURLString = [enclosureURLString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
|
||||
}
|
||||
|
||||
if (shortVersionString)
|
||||
self.displayVersionString = shortVersionString;
|
||||
else
|
||||
self.displayVersionString = [self versionString];
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion];
|
||||
self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion];
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
if (dict[@"sparkle:releaseNotesLink"])
|
||||
self.releaseNotesURL = [NSURL URLWithString:dict[@"sparkle:releaseNotesLink"]];
|
||||
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
else
|
||||
self.releaseNotesURL = nil;
|
||||
NSString *shortVersionString = [enclosure objectForKey:SUAppcastAttributeShortVersionString];
|
||||
if (nil == shortVersionString) {
|
||||
shortVersionString = [dict objectForKey:SUAppcastAttributeShortVersionString]; // fall back on the <item>
|
||||
}
|
||||
|
||||
if (dict[@"deltas"])
|
||||
{
|
||||
if (shortVersionString) {
|
||||
self.displayVersionString = shortVersionString;
|
||||
} else {
|
||||
self.displayVersionString = self.versionString;
|
||||
}
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
if (releaseNotesString) {
|
||||
NSURL *url = [NSURL URLWithString:releaseNotesString];
|
||||
if ([url isFileURL]) {
|
||||
SULog(@"Release notes with file:// URLs are not supported");
|
||||
} else {
|
||||
self.releaseNotesURL = url;
|
||||
}
|
||||
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
|
||||
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
} else {
|
||||
self.releaseNotesURL = nil;
|
||||
}
|
||||
|
||||
NSArray *deltaDictionaries = [dict objectForKey:SUAppcastElementDeltas];
|
||||
if (deltaDictionaries) {
|
||||
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
||||
NSArray *deltaDictionaries = dict[@"deltas"];
|
||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
[fakeAppCastDict removeObjectForKey:@"deltas"];
|
||||
fakeAppCastDict[@"enclosure"] = deltaDictionary;
|
||||
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
|
||||
[fakeAppCastDict release];
|
||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||
NSString *deltaFrom = [deltaDictionary objectForKey:SUAppcastAttributeDeltaFrom];
|
||||
if (!deltaFrom) continue;
|
||||
|
||||
deltas[deltaDictionary[@"sparkle:deltaFrom"]] = deltaItem;
|
||||
[deltaItem release];
|
||||
}
|
||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
|
||||
[fakeAppCastDict setObject:deltaDictionary forKey:SURSSElementEnclosure];
|
||||
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
|
||||
|
||||
[deltas setObject:deltaItem forKey:deltaFrom];
|
||||
}
|
||||
self.deltaUpdates = deltas;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.title = nil;
|
||||
self.date = nil;
|
||||
self.itemDescription = nil;
|
||||
self.releaseNotesURL = nil;
|
||||
self.DSASignature = nil;
|
||||
self.minimumSystemVersion = nil;
|
||||
self.fileURL = nil;
|
||||
self.versionString = nil;
|
||||
self.displayVersionString = nil;
|
||||
self.infoURL = nil;
|
||||
self.propertiesDictionary = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,27 +11,20 @@
|
||||
|
||||
#import "SUWindowController.h"
|
||||
|
||||
@protocol SUAutomaticUpdateAlertDelegate;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUInstallNowChoice,
|
||||
SUInstallLaterChoice,
|
||||
SUDoNotInstallChoice
|
||||
} SUAutomaticInstallationChoice;
|
||||
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
|
||||
SUInstallNowChoice,
|
||||
SUInstallLaterChoice,
|
||||
SUDoNotInstallChoice
|
||||
};
|
||||
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUAutomaticUpdateAlert : SUWindowController
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:(id<SUAutomaticUpdateAlertDelegate>)delegate;
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
|
||||
- (IBAction)installNow:sender;
|
||||
- (IBAction)installLater:sender;
|
||||
- (IBAction)doNotInstall:sender;
|
||||
|
||||
@end
|
||||
|
||||
@protocol SUAutomaticUpdateAlertDelegate <NSObject>
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -11,83 +11,78 @@
|
||||
#import "SUHost.h"
|
||||
|
||||
@interface SUAutomaticUpdateAlert ()
|
||||
@property (retain) SUAppcastItem *updateItem;
|
||||
@property (assign) id<SUAutomaticUpdateAlertDelegate> delegate;
|
||||
@property (retain) SUHost *host;
|
||||
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) SUHost *host;
|
||||
@end
|
||||
|
||||
@implementation SUAutomaticUpdateAlert
|
||||
@synthesize delegate;
|
||||
@synthesize host;
|
||||
@synthesize updateItem;
|
||||
@synthesize completionBlock;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:(id<SUAutomaticUpdateAlertDelegate>)del
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
|
||||
{
|
||||
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
|
||||
if (self)
|
||||
{
|
||||
self.updateItem = item;
|
||||
self.delegate = del;
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
[[self window] center];
|
||||
}
|
||||
return self;
|
||||
self = [super initWithWindowNibName:@"SUAutomaticUpdateAlert"];
|
||||
if (self) {
|
||||
self.updateItem = item;
|
||||
self.completionBlock = block;
|
||||
self.host = aHost;
|
||||
[self setShouldCascadeWindows:NO];
|
||||
[[self window] center];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
||||
|
||||
- (IBAction)installNow:(id)__unused sender
|
||||
{
|
||||
self.host = nil;
|
||||
self.updateItem = nil;
|
||||
[super dealloc];
|
||||
[self close];
|
||||
self.completionBlock(SUInstallNowChoice);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
|
||||
|
||||
- (IBAction)installNow:(id) __unused sender
|
||||
- (IBAction)installLater:(id)__unused sender
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallNowChoice];
|
||||
[self close];
|
||||
self.completionBlock(SUInstallLaterChoice);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
|
||||
- (IBAction)installLater:(id) __unused sender
|
||||
- (IBAction)doNotInstall:(id)__unused sender
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUInstallLaterChoice];
|
||||
[self close];
|
||||
self.completionBlock(SUDoNotInstallChoice);
|
||||
self.completionBlock = nil;
|
||||
}
|
||||
|
||||
- (IBAction)doNotInstall:(id) __unused sender
|
||||
- (NSImage *__nonnull)applicationIcon
|
||||
{
|
||||
[self close];
|
||||
[delegate automaticUpdateAlert:self finishedWithChoice:SUDoNotInstallChoice];
|
||||
return [self.host icon];
|
||||
}
|
||||
|
||||
- (NSImage *)applicationIcon
|
||||
- (NSString *__nonnull)titleText
|
||||
{
|
||||
return [host icon];
|
||||
}
|
||||
|
||||
- (NSString *)titleText
|
||||
{
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [host name]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ is ready to install!", nil), [self.host name]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)descriptionText
|
||||
{
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [host name], [updateItem displayVersionString]];
|
||||
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?", nil), [self.host name], [self.updateItem displayVersionString]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,7 @@
|
||||
#import "SUBasicUpdateDriver.h"
|
||||
#import "SUAutomaticUpdateAlert.h"
|
||||
|
||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUAutomaticUpdateAlertDelegate>
|
||||
{
|
||||
@private
|
||||
BOOL postponingInstallation, showErrors;
|
||||
BOOL willUpdateOnTermination;
|
||||
SUAutomaticUpdateAlert *alert;
|
||||
NSTimer *showUpdateAlertTimer;
|
||||
}
|
||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -15,39 +15,66 @@
|
||||
// If the user hasn't quit in a week, ask them if they want to relaunch to get the latest bits. It doesn't matter that this measure of "one day" is imprecise.
|
||||
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
|
||||
|
||||
@interface SUUpdateDriver ()
|
||||
|
||||
@property (getter=isInterruptible) BOOL interruptible;
|
||||
|
||||
@end
|
||||
|
||||
@interface SUAutomaticUpdateDriver ()
|
||||
|
||||
@property (assign) BOOL postponingInstallation;
|
||||
@property (assign) BOOL showErrors;
|
||||
@property (assign) BOOL willUpdateOnTermination;
|
||||
@property (assign) BOOL isTerminating;
|
||||
@property (strong) SUAutomaticUpdateAlert *alert;
|
||||
@property (strong) NSTimer *showUpdateAlertTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUAutomaticUpdateDriver
|
||||
|
||||
@synthesize postponingInstallation;
|
||||
@synthesize showErrors;
|
||||
@synthesize willUpdateOnTermination;
|
||||
@synthesize isTerminating;
|
||||
@synthesize alert;
|
||||
@synthesize showUpdateAlertTimer;
|
||||
|
||||
- (void)showUpdateAlert
|
||||
{
|
||||
isInterruptible = NO;
|
||||
alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self];
|
||||
self.interruptible = NO;
|
||||
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) {
|
||||
[self automaticUpdateAlertFinishedWithChoice:choice];
|
||||
}];
|
||||
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([host isBackgroundApplication])
|
||||
{
|
||||
[[alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
||||
// update prompt to behave like a normal window. Otherwise if the window were hidden
|
||||
// there may be no way for the application to be activated to make it visible again.
|
||||
if ([self.host isBackgroundApplication]) {
|
||||
[[self.alert window] setHidesOnDeactivate:NO];
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
if ([NSApp isActive])
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
if ([NSApp isActive])
|
||||
[[self.alert window] makeKeyAndOrderFront:self];
|
||||
else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *) __unused ua
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
|
||||
|
||||
// Sudden termination is available on 10.6+
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo disableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = YES;
|
||||
self.willUpdateOnTermination = YES;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||
{
|
||||
BOOL relaunch = YES;
|
||||
BOOL showUI = NO;
|
||||
@@ -57,112 +84,139 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
||||
[invocation setArgument:&showUI atIndex:3];
|
||||
[invocation setTarget:self];
|
||||
|
||||
[[updater delegate] updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation];
|
||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
||||
}
|
||||
|
||||
// If this is marked as a critical update, we'll prompt the user to install it right away.
|
||||
if ([updateItem isCriticalUpdate])
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
{
|
||||
[self showUpdateAlert];
|
||||
}
|
||||
else
|
||||
{
|
||||
showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain];
|
||||
self.showUpdateAlertTimer = [NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO];
|
||||
|
||||
// At this point the driver is idle, allow it to be interrupted for user-initiated update checks.
|
||||
isInterruptible = YES;
|
||||
self.interruptible = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopUpdatingOnTermination
|
||||
{
|
||||
if (willUpdateOnTermination)
|
||||
if (self.willUpdateOnTermination)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
|
||||
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil];
|
||||
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[processInfo enableSuddenTermination];
|
||||
|
||||
willUpdateOnTermination = NO;
|
||||
self.willUpdateOnTermination = NO;
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||
[[updater delegate] updater:updater didCancelInstallUpdateOnQuit:updateItem];
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)invalidateShowUpdateAlertTimer
|
||||
{
|
||||
[showUpdateAlertTimer invalidate];
|
||||
[showUpdateAlertTimer release];
|
||||
showUpdateAlertTimer = nil;
|
||||
[self.showUpdateAlertTimer invalidate];
|
||||
self.showUpdateAlertTimer = nil;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[alert release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
self.isTerminating = NO;
|
||||
[self stopUpdatingOnTermination];
|
||||
[self invalidateShowUpdateAlertTimer];
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *) __unused aNotification
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
|
||||
{
|
||||
[[alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
|
||||
[[self.alert window] makeKeyAndOrderFront:self];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||
}
|
||||
|
||||
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *) __unused aua finishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case SUInstallNowChoice:
|
||||
case SUInstallNowChoice:
|
||||
[self stopUpdatingOnTermination];
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
break;
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
break;
|
||||
|
||||
case SUInstallLaterChoice:
|
||||
postponingInstallation = YES;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
isInterruptible = YES;
|
||||
break;
|
||||
case SUInstallLaterChoice:
|
||||
self.postponingInstallation = YES;
|
||||
// We're already waiting on quit, just indicate that we're idle.
|
||||
self.interruptible = YES;
|
||||
break;
|
||||
|
||||
case SUDoNotInstallChoice:
|
||||
[host setObject:[updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
case SUDoNotInstallChoice:
|
||||
[self.host setObject:[self.updateItem versionString] forUserDefaultsKey:SUSkippedVersionKey];
|
||||
[self abortUpdate];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return postponingInstallation; }
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
if (relaunch) {
|
||||
if (relaunch) {
|
||||
[self stopUpdatingOnTermination];
|
||||
}
|
||||
}
|
||||
|
||||
showErrors = YES;
|
||||
self.showErrors = YES;
|
||||
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *) __unused note
|
||||
- (void)systemWillPowerOff:(NSNotification *)__unused note
|
||||
{
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil)
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)__unused note
|
||||
{
|
||||
// We don't want to terminate the app if the user or someone else initiated a termination
|
||||
// Use a property instead of passing an argument to installWithToolAndRelaunch:
|
||||
// because we give the delegate an invocation to our install methods and
|
||||
// this code was added later :|
|
||||
self.isTerminating = YES;
|
||||
|
||||
[self installWithToolAndRelaunch:NO];
|
||||
}
|
||||
|
||||
- (void)terminateApp
|
||||
{
|
||||
if (!self.isTerminating) {
|
||||
[super terminateApp];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if (showErrors)
|
||||
[super abortUpdateWithError:error];
|
||||
else
|
||||
[self abortUpdate];
|
||||
if (self.showErrors) {
|
||||
[super abortUpdateWithError:error];
|
||||
} else {
|
||||
// Call delegate separately here because otherwise it won't know we stopped.
|
||||
// Normally this gets called by the superclass
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
||||
[updaterDelegate updater:self.updater didAbortWithError:error];
|
||||
}
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -15,23 +15,19 @@
|
||||
#import "SUAppcast.h"
|
||||
|
||||
@class SUAppcastItem, SUHost;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver<NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate> {
|
||||
SUAppcastItem *updateItem;
|
||||
SUAppcastItem *nonDeltaUpdateItem;
|
||||
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate>
|
||||
|
||||
NSURLDownload *download;
|
||||
NSString *downloadPath;
|
||||
NSString *tempDir;
|
||||
|
||||
NSString *relaunchPath;
|
||||
}
|
||||
@property (strong, readonly) SUAppcastItem *updateItem;
|
||||
@property (strong, readonly) NSURLDownload *download;
|
||||
@property (copy, readonly) NSString *downloadPath;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||
- (void)didFindValidUpdate;
|
||||
- (void)didNotFindUpdate;
|
||||
|
||||
@@ -53,6 +49,7 @@
|
||||
|
||||
- (void)abortUpdate;
|
||||
- (void)abortUpdateWithError:(NSError *)error;
|
||||
- (void)terminateApp;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -9,70 +9,101 @@
|
||||
#import "SUBasicUpdateDriver.h"
|
||||
|
||||
#import "SUHost.h"
|
||||
#import "SUOperatingSystem.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPlainInstallerInternals.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUUpdater_Private.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#ifdef FINISH_INSTALL_TOOL_NAME
|
||||
// FINISH_INSTALL_TOOL_NAME expands to unquoted Autoupdate
|
||||
#define QUOTE_NS_STRING2(str) @"" #str
|
||||
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
|
||||
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
|
||||
#else
|
||||
#error FINISH_INSTALL_TOOL_NAME not defined
|
||||
#endif
|
||||
@interface SUBasicUpdateDriver ()
|
||||
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) NSURLDownload *download;
|
||||
@property (copy) NSString *downloadPath;
|
||||
|
||||
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
|
||||
@property (copy) NSString *tempDir;
|
||||
@property (copy) NSString *relaunchPath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUBasicUpdateDriver
|
||||
|
||||
@synthesize updateItem;
|
||||
@synthesize download;
|
||||
@synthesize downloadPath;
|
||||
|
||||
@synthesize nonDeltaUpdateItem;
|
||||
@synthesize tempDir;
|
||||
@synthesize relaunchPath;
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||
{
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
[super checkForUpdatesAtURL:URL host:aHost];
|
||||
if ([aHost isRunningOnReadOnlyVolume])
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]]}]];
|
||||
return;
|
||||
}
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]];
|
||||
return;
|
||||
}
|
||||
|
||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||
CFRetain(appcast); // We'll manage the appcast's memory ourselves so we don't have to make it an IV to support GC.
|
||||
[appcast release];
|
||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||
|
||||
[appcast setDelegate:self];
|
||||
[appcast setUserAgentString:[updater userAgentString]];
|
||||
[appcast fetchAppcastFromURL:URL];
|
||||
[appcast setUserAgentString:[self.updater userAgentString]];
|
||||
[appcast setHttpHeaders:[self.updater httpHeaders]];
|
||||
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
|
||||
if (error) {
|
||||
[self abortUpdateWithError:error];
|
||||
} else {
|
||||
[self appcastDidFinishLoading:appcast];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (id <SUVersionComparison>)versionComparator
|
||||
- (id<SUVersionComparison>)versionComparator
|
||||
{
|
||||
id <SUVersionComparison> comparator = nil;
|
||||
id<SUVersionComparison> comparator = nil;
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||
comparator = [[updater delegate] versionComparatorForUpdater:updater];
|
||||
}
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||
comparator = [[self.updater delegate] versionComparatorForUpdater:self.updater];
|
||||
}
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator) {
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
}
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator) {
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
}
|
||||
|
||||
return comparator;
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
SUAppcastItem *item = nil;
|
||||
for(SUAppcastItem *candidate in appcastItems) {
|
||||
if ([[self class] hostSupportsItem:candidate]) {
|
||||
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||
item = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item && deltaItem) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
|
||||
*deltaItem = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
||||
@@ -82,215 +113,371 @@
|
||||
|
||||
// Check minimum and maximum System Version
|
||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
|
||||
}
|
||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
|
||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
return minimumVersionOK && maximumVersionOK;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
{
|
||||
return [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||
}
|
||||
|
||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
||||
[[updater delegate] updater:updater didFinishLoadingAppcast:ac];
|
||||
}
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
|
||||
}
|
||||
|
||||
NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo];
|
||||
NSDictionary *userInfo = (ac != nil) ? @{ SUUpdaterAppcastNotificationKey: ac } : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
|
||||
|
||||
SUAppcastItem *item = nil;
|
||||
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:updater];
|
||||
// Now we have to find the best valid update in the appcast.
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||
{
|
||||
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||
if ([item isDeltaUpdate]) {
|
||||
self.nonDeltaUpdateItem = [[self.updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
|
||||
}
|
||||
}
|
||||
else // If not, we'll take care of it ourselves.
|
||||
{
|
||||
// Find the first update we can actually use.
|
||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
||||
do {
|
||||
item = [updateEnumerator nextObject];
|
||||
} while (item && ![self hostSupportsItem:item]);
|
||||
{
|
||||
// Find the best supported update
|
||||
SUAppcastItem *deltaUpdateItem = nil;
|
||||
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||
|
||||
if (item && deltaUpdateItem) {
|
||||
self.nonDeltaUpdateItem = item;
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
|
||||
if (binaryDeltaSupported()) {
|
||||
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[host version]];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
nonDeltaUpdateItem = [item retain];
|
||||
item = deltaUpdateItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateItem = [item retain];
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
if (updateItem == nil) { [self didNotFindUpdate]; return; }
|
||||
|
||||
if ([self itemContainsValidUpdate:updateItem])
|
||||
[self didFindValidUpdate];
|
||||
else
|
||||
[self didNotFindUpdate];
|
||||
}
|
||||
|
||||
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
|
||||
{
|
||||
if (ac) { CFRelease(ac); } // Remember that we're explicitly managing the memory of the appcast.
|
||||
[self abortUpdateWithError:error];
|
||||
if ([self itemContainsValidUpdate:item]) {
|
||||
self.updateItem = item;
|
||||
[self didFindValidUpdate];
|
||||
} else {
|
||||
self.updateItem = nil;
|
||||
[self didNotFindUpdate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didFindValidUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
|
||||
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
|
||||
NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo];
|
||||
[self downloadUpdate];
|
||||
assert(self.updateItem);
|
||||
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
||||
object:self.updater
|
||||
userInfo:@{ SUUpdaterAppcastItemNotificationKey: self.updateItem }];
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)didNotFindUpdate
|
||||
{
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[updater delegate] updaterDidNotFindUpdate:updater];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]]}]];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUNoUpdateError
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", "'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI)"), self.host.name]
|
||||
}]];
|
||||
}
|
||||
|
||||
- (NSString *)appCachePath
|
||||
{
|
||||
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||
NSString *cachePath = nil;
|
||||
if ([cachePaths count]) {
|
||||
cachePath = [cachePaths objectAtIndex:0];
|
||||
}
|
||||
if (!cachePath) {
|
||||
SULog(@"Failed to find user's cache directory! Using system default");
|
||||
cachePath = NSTemporaryDirectory();
|
||||
}
|
||||
|
||||
NSString *name = [self.host.bundle bundleIdentifier];
|
||||
if (!name) {
|
||||
name = [self.host name];
|
||||
}
|
||||
|
||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
||||
return cachePath;
|
||||
}
|
||||
|
||||
- (void)downloadUpdate
|
||||
{
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[updateItem fileURL]];
|
||||
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
// Clear cache directory so that downloads can't possibly accumulate inside
|
||||
NSString *appCachePath = [self appCachePath];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
|
||||
}
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
|
||||
[[self.updater delegate] updater:self.updater
|
||||
willDownloadUpdate:self.updateItem
|
||||
withRequest:request];
|
||||
}
|
||||
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||
{
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];
|
||||
|
||||
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
|
||||
int cnt=1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
|
||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
||||
|
||||
NSString *appCachePath = [self appCachePath];
|
||||
|
||||
self.tempDir = [appCachePath stringByAppendingPathComponent:downloadFileName];
|
||||
int cnt = 1;
|
||||
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
||||
{
|
||||
[tempDir release];
|
||||
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
|
||||
}
|
||||
self.tempDir = [appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
||||
}
|
||||
|
||||
// Create the temporary directory if necessary.
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:self.tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
if (!success)
|
||||
{
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.",tempDir]}]];
|
||||
}
|
||||
// Okay, something's really broken with this user's file structure.
|
||||
[self.download cancel];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", self.tempDir] }]];
|
||||
}
|
||||
|
||||
downloadPath = [[tempDir stringByAppendingPathComponent:name] retain];
|
||||
[download setDestination:downloadPath allowOverwrite:YES];
|
||||
self.downloadPath = [self.tempDir stringByAppendingPathComponent:name];
|
||||
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
||||
}
|
||||
|
||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
||||
/**
|
||||
* If the update is a package, then it must be signed using DSA. No other verification is done.
|
||||
*
|
||||
* If the update is a bundle, then it must meet any one of:
|
||||
*
|
||||
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
|
||||
*
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature
|
||||
{
|
||||
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:host];
|
||||
if (newBundlePath)
|
||||
{
|
||||
NSError *error = nil;
|
||||
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(@"Code signature check on update failed: %@", error);
|
||||
BOOL isPackage = NO;
|
||||
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
|
||||
if (installSourcePath == nil) {
|
||||
SULog(@"No suitable install is found in the update. The update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
// Modern packages are not distributed as bundles and are code signed differently than regular applications
|
||||
if (isPackage) {
|
||||
if (nil == publicDSAKey) {
|
||||
SULog(@"The existing app bundle does not have a DSA key, so it can't verify installer packages.");
|
||||
}
|
||||
|
||||
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
|
||||
if (!packageValidated) {
|
||||
SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
|
||||
}
|
||||
|
||||
return packageValidated;
|
||||
}
|
||||
|
||||
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
|
||||
if (newBundle == nil) {
|
||||
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
|
||||
// Downgrade in DSA security should not be possible
|
||||
if (publicDSAKey != nil && newPublicDSAKey == nil) {
|
||||
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
// However if the new and old DSA keys are the same, then this is a security measure.
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
||||
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
|
||||
|
||||
if (dsaKeysMatch) {
|
||||
NSError *error = nil;
|
||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
|
||||
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)downloadDidFinish:(NSURLDownload *) __unused d
|
||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||
{
|
||||
[self extractUpdate];
|
||||
assert(self.updateItem);
|
||||
|
||||
[self extractUpdate];
|
||||
}
|
||||
|
||||
- (void)download:(NSURLDownload *) __unused download didFailWithError:(NSError *)error
|
||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||
{
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||
if (!failingUrl) {
|
||||
failingUrl = [self.updateItem fileURL];
|
||||
}
|
||||
|
||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
||||
[[self.updater delegate] updater:self.updater
|
||||
failedToDownloadUpdate:self.updateItem
|
||||
error:error];
|
||||
}
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
||||
NSUnderlyingErrorKey: error,
|
||||
}];
|
||||
if (failingUrl) {
|
||||
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
||||
}
|
||||
|
||||
- (BOOL)download:(NSURLDownload *) __unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||
{
|
||||
// We don't want the download system to extract our gzips.
|
||||
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
||||
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
||||
// We don't want the download system to extract our gzips.
|
||||
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
|
||||
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
|
||||
}
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:downloadPath updatingHost:host];
|
||||
if (!unarchiver)
|
||||
{
|
||||
SULog(@"Sparkle Error: No valid unarchiver for %@!", downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
CFRetain(unarchiver); // Manage this memory manually so we don't have to make it an IV.
|
||||
[unarchiver setDelegate:self];
|
||||
[unarchiver start];
|
||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:self.updater.decryptionPassword];
|
||||
if (!unarchiver) {
|
||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
[self unarchiverDidFail:nil];
|
||||
return;
|
||||
}
|
||||
unarchiver.delegate = self;
|
||||
[unarchiver start];
|
||||
}
|
||||
|
||||
- (void)failedToApplyDeltaUpdate
|
||||
{
|
||||
// When a delta update fails to apply we fall back on updating via a full install.
|
||||
[updateItem release];
|
||||
updateItem = nonDeltaUpdateItem;
|
||||
nonDeltaUpdateItem = nil;
|
||||
// When a delta update fails to apply we fall back on updating via a full install.
|
||||
self.updateItem = self.nonDeltaUpdateItem;
|
||||
self.nonDeltaUpdateItem = nil;
|
||||
|
||||
[self downloadUpdate];
|
||||
[self downloadUpdate];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
|
||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
assert(self.updateItem);
|
||||
|
||||
[self installWithToolAndRelaunch:YES];
|
||||
}
|
||||
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)ua
|
||||
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
|
||||
{
|
||||
if (ua) { CFRelease(ua); }
|
||||
if ([self.updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([updateItem isDeltaUpdate]) {
|
||||
[self failedToApplyDeltaUpdate];
|
||||
return;
|
||||
}
|
||||
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil)}]];
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
|
||||
}
|
||||
|
||||
- (BOOL)shouldInstallSynchronously { return NO; }
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
// Creates intermediate directories up until targetPath if they don't already exist,
|
||||
// and removes the directory at targetPath if one already exists there
|
||||
- (BOOL)preparePathForRelaunchTool:(NSString *)targetPath error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
NSFileManager *fileManager = [[NSFileManager alloc] init];
|
||||
if ([fileManager fileExistsAtPath:targetPath]) {
|
||||
NSError *removeError = nil;
|
||||
if (![fileManager removeItemAtPath:targetPath error:&removeError]) {
|
||||
if (error != NULL) {
|
||||
*error = removeError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
NSError *createDirectoryError = nil;
|
||||
if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&createDirectoryError]) {
|
||||
if (error != NULL) {
|
||||
*error = createDirectoryError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||
{
|
||||
if (![self validateUpdateDownloadedToPath:downloadPath extractedToPath:tempDir DSASignature:[updateItem DSASignature] publicDSAKey:[host publicDSAKey]])
|
||||
assert(self.updateItem);
|
||||
|
||||
if (![self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature])
|
||||
{
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
@@ -298,9 +485,9 @@
|
||||
};
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (![updater mayUpdateAndRestart])
|
||||
if (![self.updater mayUpdateAndRestart])
|
||||
{
|
||||
[self abortUpdate];
|
||||
return;
|
||||
@@ -308,119 +495,155 @@
|
||||
|
||||
// Give the host app an opportunity to postpone the install and relaunch.
|
||||
static BOOL postponedOnce = NO;
|
||||
if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||
{
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
|
||||
[invocation setArgument:&relaunch atIndex:2];
|
||||
[invocation setTarget:self];
|
||||
postponedOnce = YES;
|
||||
if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) {
|
||||
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||
[[updater delegate] updater:updater willInstallUpdate:updateItem];
|
||||
}
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
|
||||
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
||||
}
|
||||
|
||||
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
|
||||
NSBundle *sparkleBundle = self.updater.sparkleBundle;
|
||||
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
|
||||
if (relaunchPathToCopy != nil)
|
||||
{
|
||||
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSError *error = nil;
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath: [targetPath stringByDeletingLastPathComponent] withIntermediateDirectories: YES attributes: @{} error: &error];
|
||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
||||
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
||||
NSString *relaunchCopyTargetPath = nil;
|
||||
NSError *error = nil;
|
||||
BOOL copiedRelaunchPath = NO;
|
||||
|
||||
if( [SUPlainInstaller copyPathWithAuthentication: relaunchPathToCopy overPath: targetPath temporaryName: nil error: &error] )
|
||||
relaunchPath = [targetPath retain];
|
||||
else
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]}]];
|
||||
}
|
||||
if (relaunchToolSourcePath) {
|
||||
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[[updater delegate] updaterWillRelaunchApplication:updater];
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
|
||||
{
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [host name]], NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath]}]];
|
||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
||||
NSURL *relaunchToolSourceURL = [NSURL fileURLWithPath:relaunchToolSourcePath];
|
||||
NSURL *relaunchCopyTargetURL = [NSURL fileURLWithPath:relaunchCopyTargetPath];
|
||||
|
||||
// We only need to run our copy of the app by spawning a task
|
||||
// Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs
|
||||
if ([self preparePathForRelaunchTool:relaunchCopyTargetPath error:&error] && [fileManager copyItemAtURL:relaunchToolSourceURL toURL:relaunchCopyTargetURL error:&error]) {
|
||||
copiedRelaunchPath = YES;
|
||||
|
||||
// We probably don't need to release the quarantine, but we'll do it just in case it's necessary.
|
||||
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
|
||||
SULog(@"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!copiedRelaunchPath) {
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@",
|
||||
relaunchToolSourcePath, relaunchCopyTargetPath, (error ? [error localizedDescription] : @"")],
|
||||
}]];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [host bundlePath];
|
||||
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
|
||||
}
|
||||
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
|
||||
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
tempDir,
|
||||
relaunch ? @"1" : @"0",
|
||||
showUI ? @"1" : @"0"]];
|
||||
self.relaunchPath = relaunchCopyTargetPath; // Set for backwards compatibility, in case any delegates modify it
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||
[updaterDelegate updaterWillRelaunchApplication:self.updater];
|
||||
|
||||
NSString *relaunchToolPath = [[NSBundle bundleWithPath:self.relaunchPath] executablePath];
|
||||
if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.relaunchPath]) {
|
||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@ and %@)", relaunchToolSourcePath, self.relaunchPath],
|
||||
}]];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *pathToRelaunch = [self.host bundlePath];
|
||||
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
|
||||
}
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||
pathToRelaunch,
|
||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||
self.tempDir,
|
||||
relaunch ? @"1" : @"0",
|
||||
showUI ? @"1" : @"0"]];
|
||||
[self terminateApp];
|
||||
}
|
||||
|
||||
// Note: this is overridden by the automatic update driver to not terminate in some cases
|
||||
- (void)terminateApp
|
||||
{
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
- (void)cleanUpDownload
|
||||
{
|
||||
if (tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
|
||||
{
|
||||
BOOL success = NO;
|
||||
NSError * error = nil;
|
||||
success = [[NSFileManager defaultManager] removeItemAtPath: tempDir error: &error]; // Clean up the copied relauncher
|
||||
if( !success )
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[tempDir stringByDeletingLastPathComponent] destination:@"" files:@[[tempDir lastPathComponent]] tag:NULL];
|
||||
}
|
||||
if (self.tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here.
|
||||
{
|
||||
BOOL success = NO;
|
||||
NSError *error = nil;
|
||||
success = [[NSFileManager defaultManager] removeItemAtPath:self.tempDir error:&error]; // Clean up the copied relauncher
|
||||
if (!success)
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[self.tempDir stringByDeletingLastPathComponent] destination:@"" files:@[[self.tempDir lastPathComponent]] tag:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
|
||||
{
|
||||
if (aHost != host) { return; }
|
||||
NSError * dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath: relaunchPath error: &dontThrow]; // Clean up the copied relauncher
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
|
||||
if (aHost != self.host) {
|
||||
return;
|
||||
}
|
||||
NSError *dontThrow = nil;
|
||||
[[NSFileManager defaultManager] removeItemAtPath:self.relaunchPath error:&dontThrow]; // Clean up the copied relauncher
|
||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil),
|
||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||
NSUnderlyingErrorKey: error,
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)abortUpdate
|
||||
{
|
||||
[[self retain] autorelease]; // In case the notification center was the last one holding on to us.
|
||||
[self cleanUpDownload];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super abortUpdate];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
self.updateItem = nil;
|
||||
[super abortUpdate];
|
||||
}
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||
SULog(@"Sparkle Error: %@", [error localizedDescription]);
|
||||
}
|
||||
if ([error localizedFailureReason]) {
|
||||
SULog(@"Sparkle Error (continued): %@", [error localizedFailureReason]);
|
||||
}
|
||||
if (download) {
|
||||
[download cancel];
|
||||
}
|
||||
[self abortUpdate];
|
||||
}
|
||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||
NSError *errorToDisplay = error;
|
||||
int finiteRecursion=5;
|
||||
do {
|
||||
SULog(@"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, [errorToDisplay.userInfo objectForKey:NSURLErrorFailingURLErrorKey]);
|
||||
errorToDisplay = [errorToDisplay.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||
} while(--finiteRecursion && errorToDisplay);
|
||||
}
|
||||
if (self.download) {
|
||||
[self.download cancel];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[updateItem release];
|
||||
[nonDeltaUpdateItem release];
|
||||
[download release];
|
||||
[downloadPath release];
|
||||
[tempDir release];
|
||||
[relaunchPath release];
|
||||
[super dealloc];
|
||||
// Notify host app that update has aborted
|
||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
||||
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
||||
[updaterDelegate updater:self.updater didAbortWithError:error];
|
||||
}
|
||||
|
||||
[self abortUpdate];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,6 @@
|
||||
#define SUBINARYDELTAAPPLY_H
|
||||
|
||||
@class NSString;
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile);
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error);
|
||||
|
||||
#endif
|
||||
@@ -10,62 +10,158 @@
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <bspatch.h>
|
||||
#include "bspatch.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
static void applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
|
||||
static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, 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]};
|
||||
bspatch(4, (char **)argv);
|
||||
BOOL success = (bspatch(4, argv) == 0);
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
return success;
|
||||
}
|
||||
|
||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile)
|
||||
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error)
|
||||
{
|
||||
xar_t x = xar_open([patchFile UTF8String], READ);
|
||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||
if (!x) {
|
||||
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile UTF8String]);
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to open %@. Giving up.", patchFile] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
|
||||
|
||||
NSString *expectedBeforeHash = nil;
|
||||
NSString *expectedAfterHash = nil;
|
||||
NSString *expectedBeforeHashv1 = nil;
|
||||
NSString *expectedAfterHashv1 = nil;
|
||||
|
||||
NSString *expectedNewBeforeHash = nil;
|
||||
NSString *expectedNewAfterHash = 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")) {
|
||||
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
||||
const char *value = 0;
|
||||
xar_subdoc_prop_get(subdoc, "before-sha1", &value);
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
expectedBeforeHash = @(value);
|
||||
|
||||
xar_subdoc_prop_get(subdoc, "after-sha1", &value);
|
||||
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
||||
|
||||
// available in version 2.0 or later
|
||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||
if (value)
|
||||
expectedAfterHash = @(value);
|
||||
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(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) {
|
||||
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 (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
|
||||
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
|
||||
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
|
||||
|
||||
if (!expectedBeforeHash || !expectedAfterHash) {
|
||||
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
|
||||
return 1;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Verifying source... ");
|
||||
NSString *beforeHash = hashOfTree(source);
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
|
||||
fprintf(stderr, "Verifying source...");
|
||||
}
|
||||
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
|
||||
if (!beforeHash) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![beforeHash isEqualToString:expectedBeforeHash]) {
|
||||
fprintf(stderr, "Source doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", expectedBeforeHash, beforeHash] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nCopying files... ");
|
||||
removeTree(destination);
|
||||
copyTree(source, destination);
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nCopying files...");
|
||||
}
|
||||
|
||||
if (!removeTree(destination)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
if (!copyTree(source, destination)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
|
||||
fprintf(stderr, "\nPatching... ");
|
||||
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)) {
|
||||
@@ -73,29 +169,116 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
NSString *sourceFilePath = [source stringByAppendingPathComponent:path];
|
||||
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
|
||||
|
||||
// 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", &value) || !xar_prop_get(file, "delete-then-extract", &value)) {
|
||||
removeTree(destinationFilePath);
|
||||
if (!xar_prop_get(file, "delete", &value))
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) ||
|
||||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||
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] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
removedFile = YES;
|
||||
}
|
||||
|
||||
if (!xar_prop_get(file, "binary-delta", &value))
|
||||
applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath);
|
||||
else
|
||||
xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]);
|
||||
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
|
||||
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, 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;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path 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) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
if (fileExisted) {
|
||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
|
||||
} else {
|
||||
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [path fileSystemRepresentation]);
|
||||
}
|
||||
}
|
||||
} else if (verbose && removedFile) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
||||
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
|
||||
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] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
xar_close(x);
|
||||
|
||||
fprintf(stderr, "\nVerifying destination... ");
|
||||
NSString *afterHash = hashOfTree(destination);
|
||||
|
||||
if (![afterHash isEqualToString:expectedAfterHash]) {
|
||||
fprintf(stderr, "Destination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
|
||||
removeTree(destination);
|
||||
return 1;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nVerifying destination...");
|
||||
}
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
|
||||
if (!afterHash) {
|
||||
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;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
return 0;
|
||||
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] }];
|
||||
}
|
||||
removeTree(destination);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
@@ -9,18 +9,76 @@
|
||||
#ifndef SUBINARYDELTACOMMON_H
|
||||
#define SUBINARYDELTACOMMON_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include <fts.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSData;
|
||||
#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 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
|
||||
#define VERBOSE_DIFFED "Diffed" // file is diffed when creating a patch
|
||||
#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 MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
|
||||
|
||||
// Each major version will be assigned a name of a color
|
||||
// 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
|
||||
};
|
||||
|
||||
// Only keep track of the latest minor version for each major version
|
||||
typedef NS_ENUM(uint16_t, SUBinaryDeltaMinorVersion)
|
||||
{
|
||||
SUAzureMinorVersion = 1,
|
||||
SUBeigeMinorVersion = 1,
|
||||
};
|
||||
|
||||
#define FIRST_DELTA_DIFF_MAJOR_VERSION SUAzureMajorVersion
|
||||
#define FIRST_DELTA_DIFF_MINOR_VERSION ((SUBinaryDeltaMinorVersion)0)
|
||||
|
||||
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
|
||||
|
||||
extern int binaryDeltaSupported(void);
|
||||
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
||||
extern NSData *hashOfFile(FTSENT *ent);
|
||||
extern NSData *hashOfFileContents(FTSENT *ent);
|
||||
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
|
||||
extern NSString *hashOfTree(NSString *path);
|
||||
extern void removeTree(NSString *path);
|
||||
extern void copyTree(NSString *source, NSString *dest);
|
||||
extern BOOL removeTree(NSString *path);
|
||||
extern BOOL copyTree(NSString *source, NSString *dest);
|
||||
extern BOOL modifyPermissions(NSString *path, mode_t desiredPermissions);
|
||||
extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
|
||||
NSString *temporaryFilename(NSString *base);
|
||||
NSString *temporaryDirectory(NSString *base);
|
||||
NSString *stringWithFileSystemRepresentation(const char*);
|
||||
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#import "SUFileManager.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <fcntl.h>
|
||||
@@ -17,13 +18,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
int binaryDeltaSupported(void)
|
||||
{
|
||||
// OS X 10.4 didn't include libxar, so we link against it weakly.
|
||||
// This checks whether libxar is available at runtime.
|
||||
return xar_close != 0;
|
||||
}
|
||||
|
||||
int compareFiles(const FTSENT **a, const FTSENT **b)
|
||||
{
|
||||
return strcoll((*a)->fts_name, (*b)->fts_name);
|
||||
@@ -39,23 +33,55 @@ NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
|
||||
}
|
||||
|
||||
NSString *stringWithFileSystemRepresentation(const char *input) {
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
return [fm stringWithFileSystemRepresentation:input length:strlen(input)];
|
||||
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
|
||||
}
|
||||
|
||||
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
||||
{
|
||||
switch (majorVersion) {
|
||||
case SUAzureMajorVersion:
|
||||
return SUAzureMinorVersion;
|
||||
case SUBeigeMajorVersion:
|
||||
return SUBeigeMinorVersion;
|
||||
}
|
||||
return (SUBinaryDeltaMinorVersion)0;
|
||||
}
|
||||
|
||||
NSString *temporaryFilename(NSString *base)
|
||||
{
|
||||
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
|
||||
const char *fsrepr = [template fileSystemRepresentation];
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
|
||||
|
||||
const size_t buffer_len = strlen(fsrepr) + 1;
|
||||
char *buffer = (char *)malloc(buffer_len);
|
||||
strlcpy(buffer, fsrepr, buffer_len);
|
||||
char *buffer = data.mutableBytes;
|
||||
int fd = mkstemp(buffer);
|
||||
if (fd == -1) {
|
||||
perror("mkstemp");
|
||||
return nil;
|
||||
}
|
||||
|
||||
// mkstemp() can't be used, beause it returns a file descriptor, and XAR API requires a filename
|
||||
NSString *ret = stringWithFileSystemRepresentation(mktemp(buffer));
|
||||
free(buffer);
|
||||
return ret;
|
||||
if (close(fd) != 0) {
|
||||
perror("close");
|
||||
return nil;
|
||||
}
|
||||
|
||||
return stringWithFileSystemRepresentation(buffer);
|
||||
}
|
||||
|
||||
NSString *temporaryDirectory(NSString *base)
|
||||
{
|
||||
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
|
||||
|
||||
char *buffer = data.mutableBytes;
|
||||
char *templateResult = mkdtemp(buffer);
|
||||
if (templateResult == NULL) {
|
||||
perror("mkdtemp");
|
||||
return nil;
|
||||
}
|
||||
|
||||
return stringWithFileSystemRepresentation(templateResult);
|
||||
}
|
||||
|
||||
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)
|
||||
@@ -67,62 +93,65 @@ static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t buffe
|
||||
CC_SHA1_Final(hash, &hashContext);
|
||||
}
|
||||
|
||||
static void _hashOfFile(unsigned char* hash, FTSENT *ent)
|
||||
static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
|
||||
{
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
char linkDestination[MAXPATHLEN + 1];
|
||||
ssize_t linkDestinationLength = readlink(ent->fts_path, linkDestination, MAXPATHLEN);
|
||||
if (linkDestinationLength < 0) {
|
||||
perror("readlink");
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent->fts_info == FTS_F) {
|
||||
} else if (ent->fts_info == FTS_F) {
|
||||
int fileDescriptor = open(ent->fts_path, O_RDONLY);
|
||||
if (fileDescriptor == -1) {
|
||||
perror("open");
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
ssize_t fileSize = ent->fts_statp->st_size;
|
||||
if (fileSize == 0) {
|
||||
_hashOfBuffer(hash, NULL, 0);
|
||||
close(fileDescriptor);
|
||||
return;
|
||||
} else {
|
||||
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
||||
if (buffer == (void*)-1) {
|
||||
close(fileDescriptor);
|
||||
perror("mmap");
|
||||
return NO;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, buffer, fileSize);
|
||||
munmap(buffer, (size_t)fileSize);
|
||||
}
|
||||
|
||||
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
||||
if (buffer == (void*)-1) {
|
||||
close(fileDescriptor);
|
||||
perror("mmap");
|
||||
return;
|
||||
}
|
||||
|
||||
_hashOfBuffer(hash, buffer, fileSize);
|
||||
munmap(buffer, (size_t)fileSize);
|
||||
close(fileDescriptor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent->fts_info == FTS_D)
|
||||
} else if (ent->fts_info == FTS_D) {
|
||||
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSData *hashOfFile(FTSENT *ent)
|
||||
NSData *hashOfFileContents(FTSENT *ent)
|
||||
{
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
_hashOfFile(fileHash, ent);
|
||||
if (!_hashOfFileContents(fileHash, ent)) {
|
||||
return nil;
|
||||
}
|
||||
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
|
||||
}
|
||||
|
||||
NSString *hashOfTree(NSString *path)
|
||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||
{
|
||||
const char *sourcePaths[] = {[path fileSystemRepresentation], 0};
|
||||
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
char pathBuffer[PATH_MAX] = {0};
|
||||
if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
char * const sourcePaths[] = {pathBuffer, 0};
|
||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return nil;
|
||||
@@ -133,16 +162,34 @@ NSString *hashOfTree(NSString *path)
|
||||
|
||||
FTSENT *ent = 0;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL)
|
||||
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)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (relativePath.length == 0)
|
||||
continue;
|
||||
|
||||
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
|
||||
_hashOfFile(fileHash, ent);
|
||||
if (!_hashOfFileContents(fileHash, ent)) {
|
||||
return nil;
|
||||
}
|
||||
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
|
||||
|
||||
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
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;
|
||||
|
||||
CC_SHA1_Update(&hashContext, &type, sizeof(type));
|
||||
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
|
||||
}
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
@@ -157,12 +204,41 @@ NSString *hashOfTree(NSString *path)
|
||||
return @(hexHash);
|
||||
}
|
||||
|
||||
void removeTree(NSString *path)
|
||||
extern NSString *hashOfTree(NSString *path)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
|
||||
return hashOfTreeWithVersion(path, LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
void copyTree(NSString *source, NSString *dest)
|
||||
BOOL removeTree(NSString *path)
|
||||
{
|
||||
[[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
// Don't use fileExistsForPath: because it will try to follow symbolic links
|
||||
if (![fileManager attributesOfItemAtPath:path error:nil]) {
|
||||
return YES;
|
||||
}
|
||||
return [fileManager removeItemAtPath:path error:nil];
|
||||
}
|
||||
|
||||
BOOL copyTree(NSString *source, NSString *dest)
|
||||
{
|
||||
return [[SUFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
|
||||
}
|
||||
|
||||
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil];
|
||||
if (!attributes) {
|
||||
return NO;
|
||||
}
|
||||
NSNumber *permissions = [attributes objectForKey:NSFilePosixPermissions];
|
||||
if (!permissions) {
|
||||
return NO;
|
||||
}
|
||||
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
||||
int (*changeModeFunc)(const char *, mode_t) = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
||||
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// SUBinaryDeltaCreate.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/9/15.
|
||||
// Copyright (c) 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUBINARYDELTACREATE_H
|
||||
#define SUBINARYDELTACREATE_H
|
||||
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
|
||||
@class NSString;
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,587 @@
|
||||
//
|
||||
// SUBinaryDeltaCreate.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/9/15.
|
||||
// Copyright (c) 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/xattr.h>
|
||||
#include <xar/xar.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;
|
||||
@end
|
||||
|
||||
@implementation CreateBinaryDeltaOperation
|
||||
@synthesize relativePath = _relativePath;
|
||||
@synthesize resultPath = _resultPath;
|
||||
@synthesize oldPermissions = _oldPermissions;
|
||||
@synthesize permissions = _permissions;
|
||||
@synthesize _fromPath = _fromPath;
|
||||
@synthesize _toPath = _toPath;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.relativePath = relativePath;
|
||||
self.oldPermissions = oldPermissions;
|
||||
self.permissions = permissions;
|
||||
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)main
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
self.resultPath = temporaryFile;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#define INFO_HASH_KEY @"hash"
|
||||
#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, INFO_TYPE_KEY: @(ent->fts_info), INFO_PERMISSIONS_KEY : @(permissions), INFO_SIZE_KEY: @(size)};
|
||||
}
|
||||
|
||||
static bool aclExists(const FTSENT *ent)
|
||||
{
|
||||
// macOS does not currently support ACLs for symlinks
|
||||
if (ent->fts_info == FTS_SL) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
acl_t acl = acl_get_link_np(ent->fts_path, ACL_TYPE_EXTENDED);
|
||||
if (acl != NULL) {
|
||||
acl_entry_t entry;
|
||||
int result = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry);
|
||||
assert(acl_free((void *)acl) == 0);
|
||||
return (result == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
|
||||
{
|
||||
const int options = XATTR_NOFOLLOW;
|
||||
ssize_t listSize = listxattr(ent->fts_path, NULL, 0, options);
|
||||
if (listSize == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *buffer = malloc((size_t)listSize);
|
||||
assert(buffer != NULL);
|
||||
|
||||
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
|
||||
assert(sizeBack == listSize);
|
||||
|
||||
size_t startCharacterIndex = 0;
|
||||
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
|
||||
if (buffer[characterIndex] == '\0') {
|
||||
char *attribute = &buffer[startCharacterIndex];
|
||||
size_t length = characterIndex - startCharacterIndex;
|
||||
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 ||
|
||||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 ||
|
||||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
|
||||
free(buffer);
|
||||
return true;
|
||||
}
|
||||
startCharacterIndex = characterIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static NSString *absolutePath(NSString *path)
|
||||
{
|
||||
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
||||
return [[url absoluteURL] path];
|
||||
}
|
||||
|
||||
static NSString *temporaryPatchFile(NSString *patchFile)
|
||||
{
|
||||
NSString *path = absolutePath(patchFile);
|
||||
NSString *directory = [path stringByDeletingLastPathComponent];
|
||||
NSString *file = [path lastPathComponent];
|
||||
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
|
||||
}
|
||||
|
||||
#define MIN_FILE_SIZE_FOR_CREATING_DELTA 4096
|
||||
|
||||
static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
unsigned long long fileSize = [newInfo[INFO_SIZE_KEY] unsignedLongLongValue];
|
||||
if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (!originalInfo) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
||||
// this is possible if just the permissions have changed
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL shouldDeleteThenExtract(NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error)
|
||||
{
|
||||
assert(source);
|
||||
assert(destination);
|
||||
assert(patchFile);
|
||||
assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||
|
||||
SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
||||
|
||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||
|
||||
char pathBuffer[PATH_MAX] = {0};
|
||||
if (![source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from source %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char *sourcePaths[] = {pathBuffer, 0};
|
||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on source: %@", @(strerror(errno))] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
||||
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
FTSENT *ent = 0;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *key = pathRelativeToDirectory(source, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info for file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
originalTreeState[key] = info;
|
||||
|
||||
if (aclExists(ent)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in before-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (codeSignatureExtendedAttributeExists(ent)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
|
||||
|
||||
if (!beforeHash) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", source] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in originalTreeState)
|
||||
{
|
||||
newTreeState[key] = [NSNull null];
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
pathBuffer[0] = 0;
|
||||
if (![destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from destination %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
sourcePaths[0] = pathBuffer;
|
||||
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on destination: %@", @(strerror(errno))] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *key = pathRelativeToDirectory(destination, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
if (!info) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info from file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs,
|
||||
// or in the case of permissions if the patch version is 1
|
||||
|
||||
// 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 = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
if (!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");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in after-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (codeSignatureExtendedAttributeExists(ent)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %@", @(ent->fts_path)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
|
||||
if ([info isEqual:oldInfo]) {
|
||||
[newTreeState removeObjectForKey:key];
|
||||
} else {
|
||||
newTreeState[key] = info;
|
||||
|
||||
if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
|
||||
NSArray *parentPathComponents = key.pathComponents;
|
||||
|
||||
for (NSString *childPath in originalTreeState) {
|
||||
NSArray *childPathComponents = childPath.pathComponents;
|
||||
if (childPathComponents.count > parentPathComponents.count &&
|
||||
[parentPathComponents isEqualToArray:[childPathComponents subarrayWithRange:NSMakeRange(0, parentPathComponents.count)]]) {
|
||||
[newTreeState removeObjectForKey:childPath];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
|
||||
if (!afterHash) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", destination] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nGenerating delta...");
|
||||
}
|
||||
|
||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
if (!x) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write to %@", temporaryFile] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
|
||||
|
||||
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];
|
||||
|
||||
// Sort the keys by preferring the ones from the original tree to appear first
|
||||
// We want to enforce deleting before extracting in the case paths differ only by case
|
||||
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingComparator:^NSComparisonResult(NSString *key1, NSString *key2) {
|
||||
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
|
||||
if (insensitiveCompareResult != NSOrderedSame) {
|
||||
return insensitiveCompareResult;
|
||||
}
|
||||
|
||||
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
|
||||
}];
|
||||
for (NSString* key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
|
||||
if ([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");
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *originalInfo = originalTreeState[key];
|
||||
NSDictionary *newInfo = newTreeState[key];
|
||||
if (shouldSkipDeltaCompression(originalInfo, newInfo)) {
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && 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", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [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");
|
||||
} else {
|
||||
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
}
|
||||
}
|
||||
|
||||
[deltaQueue waitUntilAllOperationsAreFinished];
|
||||
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
if (!resultPath) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch from source %@ and destination %@", operation.relativePath, resultPath] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
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 (verbose) {
|
||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xar_close(x);
|
||||
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||
unlink([temporaryFile fileSystemRepresentation]);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -6,273 +6,235 @@
|
||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||
//
|
||||
|
||||
#define _DARWIN_NO_64_BIT_INODE 1
|
||||
|
||||
#include "SUBinaryDeltaCommon.h"
|
||||
#include "SUBinaryDeltaApply.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#include "SUBinaryDeltaCreate.h"
|
||||
#import "SUBinaryDeltaCommon.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <xar/xar.h>
|
||||
|
||||
extern int bsdiff(int argc, const char **argv);
|
||||
#define VERBOSE_FLAG @"--verbose"
|
||||
#define VERSION_FLAG @"--version"
|
||||
|
||||
@interface CreateBinaryDeltaOperation : NSOperation
|
||||
@property (copy) NSString *relativePath;
|
||||
@property (retain) NSString *resultPath;
|
||||
@property (retain) NSString *_fromPath;
|
||||
@property (retain) NSString *_toPath;
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree;
|
||||
@end
|
||||
#define CREATE_COMMAND @"create"
|
||||
#define APPLY_COMMAND @"apply"
|
||||
#define VERSION_COMMAND @"version"
|
||||
#define VERSION_ALTERNATE_COMMAND @"--version"
|
||||
|
||||
@implementation CreateBinaryDeltaOperation
|
||||
@synthesize relativePath = _relativePath;
|
||||
@synthesize resultPath = _resultPath;
|
||||
@synthesize _fromPath = _fromPath;
|
||||
@synthesize _toPath = _toPath;
|
||||
|
||||
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree
|
||||
static void printUsage(NSString *programName)
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.relativePath = relativePath;
|
||||
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
|
||||
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
|
||||
}
|
||||
return self;
|
||||
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]);
|
||||
}
|
||||
|
||||
- (void)main
|
||||
static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||
{
|
||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||
const char *argv[] = {"/usr/bin/bsdiff", [_fromPath fileSystemRepresentation], [_toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
||||
int result = bsdiff(4, argv);
|
||||
if (!result)
|
||||
self.resultPath = temporaryFile;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
self.relativePath = nil;
|
||||
self.resultPath = nil;
|
||||
self._fromPath = nil;
|
||||
self._toPath = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static NSDictionary *infoForFile(FTSENT *ent)
|
||||
{
|
||||
NSData *hash = hashOfFile(ent);
|
||||
NSNumber *size = @0;
|
||||
if (ent->fts_info != FTS_D) {
|
||||
size = @(ent->fts_statp->st_size);
|
||||
}
|
||||
return @{@"hash": hash, @"type": @(ent->fts_info), @"size": size};
|
||||
}
|
||||
|
||||
static NSString *absolutePath(NSString *path)
|
||||
{
|
||||
NSURL *url = [[[NSURL alloc] initFileURLWithPath:path] autorelease];
|
||||
return [[url absoluteURL] path];
|
||||
}
|
||||
|
||||
static NSString *temporaryPatchFile(NSString *patchFile)
|
||||
{
|
||||
NSString *path = absolutePath(patchFile);
|
||||
NSString *directory = [path stringByDeletingLastPathComponent];
|
||||
NSString *file = [path lastPathComponent];
|
||||
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
|
||||
}
|
||||
|
||||
static BOOL shouldSkipDeltaCompression(NSString * __unused key, NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
unsigned long long fileSize = [newInfo[@"size"] unsignedLongLongValue];
|
||||
if (fileSize < 4096) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (!originalInfo) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if ([originalInfo[@"type"] unsignedShortValue] != [newInfo[@"type"] unsignedShortValue]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL shouldDeleteThenExtract(NSString * __unused key, NSDictionary* originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ([originalInfo[@"type"] unsignedShortValue] != [newInfo[@"type"] unsignedShortValue]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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[1] isDirectory:&isDirectory] || !isDirectory) {
|
||||
printUsage(programName);
|
||||
fprintf(stderr, "Error: after-tree must be a directory\n");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *createDiffError = nil;
|
||||
if (!createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose, &createDiffError)) {
|
||||
fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
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, &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;
|
||||
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
|
||||
|
||||
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 = (SUBinaryDeltaMinorVersion)[@(value) intValue];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
int main(int __unused argc, char __unused *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
if (argc != 5) {
|
||||
usage:
|
||||
fprintf(stderr, "Usage: BinaryDelta [create | apply] before-tree after-tree patch-file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NSString *command = @(argv[1]);
|
||||
NSString *oldPath = stringWithFileSystemRepresentation(argv[2]);
|
||||
NSString *newPath = stringWithFileSystemRepresentation(argv[3]);
|
||||
NSString *patchFile = stringWithFileSystemRepresentation(argv[4]);
|
||||
|
||||
if ([command isEqualToString:@"apply"]) {
|
||||
int result = applyBinaryDelta(oldPath, newPath, patchFile);
|
||||
return result;
|
||||
}
|
||||
if (![command isEqualToString:@"create"]) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||
|
||||
const char *sourcePaths[] = {[oldPath fileSystemRepresentation], 0};
|
||||
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||
NSString *programName = [args[0] lastPathComponent];
|
||||
|
||||
if (args.count < 2) {
|
||||
printUsage(programName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Processing %s...", [oldPath UTF8String]);
|
||||
FTSENT *ent = 0;
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *key = pathRelativeToDirectory(oldPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
originalTreeState[key] = info;
|
||||
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);
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *beforeHash = hashOfTree(oldPath);
|
||||
|
||||
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in originalTreeState)
|
||||
{
|
||||
newTreeState[key] = [NSNull null];
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nProcessing %s... ", [newPath UTF8String]);
|
||||
sourcePaths[0] = [newPath fileSystemRepresentation];
|
||||
fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||
if (!fts) {
|
||||
perror("fts_open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
while ((ent = fts_read(fts))) {
|
||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSString *key = pathRelativeToDirectory(newPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||
if (![key length]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *info = infoForFile(ent);
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
|
||||
if ([info isEqual:oldInfo])
|
||||
[newTreeState removeObjectForKey:key];
|
||||
else
|
||||
newTreeState[key] = info;
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
NSString *afterHash = hashOfTree(newPath);
|
||||
|
||||
fprintf(stderr, "\nGenerating delta... ");
|
||||
|
||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||
xar_subdoc_t attributes = xar_subdoc_new(x, "binary-delta-attributes");
|
||||
xar_subdoc_prop_set(attributes, "before-sha1", [beforeHash UTF8String]);
|
||||
xar_subdoc_prop_set(attributes, "after-sha1", [afterHash UTF8String]);
|
||||
|
||||
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
|
||||
NSMutableArray *deltaOperations = [NSMutableArray array];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wselector"
|
||||
// Xcode 5.1.1: compare: is clearly declared, must warn due to a compiler bug?
|
||||
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
#pragma clang diagnostic pop
|
||||
for (NSString* key in keys) {
|
||||
id value = [newTreeState valueForKey:key];
|
||||
|
||||
if ([value isEqual:[NSNull null]]) {
|
||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, "delete", "true");
|
||||
continue;
|
||||
}
|
||||
|
||||
NSDictionary *originalInfo = originalTreeState[key];
|
||||
NSDictionary *newInfo = newTreeState[key];
|
||||
if (shouldSkipDeltaCompression(key, originalInfo, newInfo)) {
|
||||
NSString *path = [newPath stringByAppendingPathComponent:key];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
if (shouldDeleteThenExtract(key, originalInfo, newInfo)) {
|
||||
xar_prop_set(newFile, "delete-then-extract", "true");
|
||||
}
|
||||
} else {
|
||||
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath];
|
||||
[deltaQueue addOperation:operation];
|
||||
[deltaOperations addObject:operation];
|
||||
[operation release];
|
||||
}
|
||||
}
|
||||
|
||||
[deltaQueue waitUntilAllOperationsAreFinished];
|
||||
[deltaQueue release];
|
||||
|
||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||
NSString *resultPath = [operation resultPath];
|
||||
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||
assert(newFile);
|
||||
xar_prop_set(newFile, "binary-delta", "true");
|
||||
unlink([resultPath fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
xar_close(x);
|
||||
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||
unlink([temporaryFile fileSystemRepresentation]);
|
||||
fprintf(stderr, "Done!\n");
|
||||
|
||||
return 0;
|
||||
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@@ -10,46 +10,86 @@
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaApply.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUHost.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUBinaryDeltaUnarchiver
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
// According to https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/MDImporters/Concepts/Troubleshooting.html
|
||||
// We should make sure mdimporter bundles have an up to date time in the event they were delta updated.
|
||||
// We used to invoke mdimport on the bundle but this is not a very good approach.
|
||||
// There's no need to do that for non-delta updates and for updates that contain no mdimporters.
|
||||
// Moreover, updating the timestamp on the mdimporter bundles is what developers have to do anyway when shipping their new update outside of Sparkle
|
||||
+ (void)updateSpotlightImportersAtBundlePath:(NSString *)targetPath
|
||||
{
|
||||
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||
// Only recurse if it's actually a directory. Don't recurse into a
|
||||
// root-level symbolic link.
|
||||
NSDictionary *rootAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:targetPath error:nil];
|
||||
NSString *rootType = [rootAttributes objectForKey:NSFileType];
|
||||
|
||||
if ([rootType isEqualToString:NSFileTypeDirectory]) {
|
||||
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||
// symbolic links, so no further type checks are needed.
|
||||
NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
|
||||
NSMutableArray *filesToUpdate = [[NSMutableArray alloc] init];
|
||||
for (NSURL *file in directoryEnumerator) {
|
||||
if ([file.pathExtension isEqualToString:@"mdimporter"]) {
|
||||
[filesToUpdate addObject:file];
|
||||
}
|
||||
}
|
||||
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
for (NSURL *file in filesToUpdate) {
|
||||
NSError *error = nil;
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:file error:&error]) {
|
||||
SULog(@"Error: During delta unarchiving, failed to touch %@", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applyBinaryDelta
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *sourcePath = [[updateHost bundle] bundlePath];
|
||||
NSString *targetPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
@autoreleasepool {
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
int result = applyBinaryDelta(sourcePath, targetPath, archivePath);
|
||||
if (!result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
}
|
||||
else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
}
|
||||
}
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError);
|
||||
if (success) {
|
||||
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
}
|
||||
else {
|
||||
SULog(@"Applying delta patch failed with error: %@", applyDiffError);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self applyBinaryDelta];
|
||||
});
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self applyBinaryDelta];
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,8 +12,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error;
|
||||
+ (BOOL)hostApplicationIsCodeSigned;
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -13,89 +13,148 @@
|
||||
|
||||
@implementation SUCodeSigningVerifier
|
||||
|
||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecRequirementRef requirement = NULL;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
SecCodeRef hostCode = NULL;
|
||||
SecStaticCodeRef oldCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to copy host code %d", result);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (result != 0) {
|
||||
SULog(@"Failed to copy designated requirement %d", result);
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||
// Aditionally, there are several reasons to stay away from deep verification and to prefer DSA signing the download archive instead.
|
||||
// See https://github.com/sparkle-project/Sparkle/pull/523#commitcomment-17549302 and https://github.com/sparkle-project/Sparkle/issues/543
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
CFStringRef requirementString = nil;
|
||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
||||
SULog(@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||
CFRelease(requirementString);
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
}
|
||||
|
||||
finally:
|
||||
if (oldCode) CFRelease(oldCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == noErr);
|
||||
}
|
||||
|
||||
NSBundle *newBundle = [NSBundle bundleWithPath:destinationPath];
|
||||
if (!newBundle) {
|
||||
SULog(@"Failed to load NSBundle for update");
|
||||
result = -1;
|
||||
goto finally;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
OSStatus result;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
CFErrorRef cfError = NULL;
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCreateWithPath((CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
|
||||
if (result != 0) {
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result != noErr) {
|
||||
SULog(@"Failed to get static code %d", result);
|
||||
goto finally;
|
||||
}
|
||||
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, (CFErrorRef *)error);
|
||||
if (result != 0 && error) {
|
||||
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not passed
|
||||
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||
|
||||
if (cfError) {
|
||||
NSError *tmpError = CFBridgingRelease(cfError);
|
||||
if (error) *error = tmpError;
|
||||
}
|
||||
|
||||
if (result != noErr) {
|
||||
if (result == errSecCSUnsigned) {
|
||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||
}
|
||||
if (result == errSecCSReqFailed) {
|
||||
CFStringRef requirementString = nil;
|
||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
||||
SULog(@"Failed requirement %@", requirementString);
|
||||
CFRelease(requirementString);
|
||||
}
|
||||
|
||||
[self logSigningInfoForCode:hostCode label:@"host info"];
|
||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||
}
|
||||
|
||||
[*error autorelease];
|
||||
}
|
||||
|
||||
|
||||
finally:
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (staticCode) CFRelease(staticCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
return (result == 0);
|
||||
return (result == noErr);
|
||||
}
|
||||
|
||||
static id valueOrNSNull(id value) {
|
||||
return value ? value : [NSNull null];
|
||||
}
|
||||
|
||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||
CFDictionaryRef signingInfo = nil;
|
||||
const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation;
|
||||
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||
NSDictionary* signingDict = (NSDictionary*)signingInfo;
|
||||
NSMutableDictionary* relevantInfo = [NSMutableDictionary dictionary];
|
||||
for (NSString* key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||
relevantInfo[key] = signingDict[key];
|
||||
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
|
||||
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
|
||||
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||
[relevantInfo setObject:valueOrNSNull([signingDict objectForKey:key]) forKey:key];
|
||||
}
|
||||
NSDictionary* infoPlist = signingDict[@"info-plist"];
|
||||
relevantInfo[@"version"] = infoPlist[@"CFBundleShortVersionString"];
|
||||
relevantInfo[@"build"] = infoPlist[@"CFBundleVersion"];
|
||||
CFRelease(signingInfo);
|
||||
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
|
||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
|
||||
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
|
||||
SULog(@"%@: %@", label, relevantInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)hostApplicationIsCodeSigned
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||
{
|
||||
OSStatus result;
|
||||
SecCodeRef hostCode = NULL;
|
||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
||||
if (result != 0) return NO;
|
||||
SecStaticCodeRef staticCode = NULL;
|
||||
|
||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
SecRequirementRef requirement = NULL;
|
||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
||||
if (hostCode) CFRelease(hostCode);
|
||||
if (requirement) CFRelease(requirement);
|
||||
result = SecCodeCopyDesignatedRequirement(staticCode, kSecCSDefaultFlags, &requirement);
|
||||
if (staticCode) {
|
||||
CFRelease(staticCode);
|
||||
}
|
||||
if (requirement) {
|
||||
CFRelease(requirement);
|
||||
}
|
||||
if (result == errSecCSUnsigned) {
|
||||
return NO;
|
||||
}
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,21 +10,16 @@
|
||||
#ifndef SUCONSTANTS_H
|
||||
#define SUCONSTANTS_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Preprocessor flags:
|
||||
// Misc:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// 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:
|
||||
#define PERMIT_AUTOMATED_DOWNGRADES 0
|
||||
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
||||
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
|
||||
|
||||
// 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":
|
||||
#define NORMALIZE_INSTALLED_APP_NAME 0
|
||||
|
||||
|
||||
#define TRY_TO_APPEND_VERSION_NUMBER 1
|
||||
extern NSString *const SUBundleIdentifier;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Notifications:
|
||||
@@ -48,40 +43,41 @@ extern NSString *const SUPublicDSAKeyFileKey;
|
||||
extern NSString *const SUAutomaticallyUpdateKey;
|
||||
extern NSString *const SUAllowsAutomaticUpdatesKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKey;
|
||||
extern NSString *const SUEnableAutomaticChecksKeyOld;
|
||||
extern NSString *const SUEnableSystemProfilingKey;
|
||||
extern NSString *const SUSendProfileInfoKey;
|
||||
extern NSString *const SULastProfileSubmitDateKey;
|
||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey;
|
||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
||||
extern NSString *const SUDefaultsDomainKey;
|
||||
extern NSString *const SUEnableJavaScriptKey;
|
||||
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
|
||||
extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER.")));
|
||||
extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES.")));
|
||||
extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME.")));
|
||||
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Errors:
|
||||
// Appcast keys::
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern NSString *const SUSparkleErrorDomain;
|
||||
// Appcast phase errors.
|
||||
extern OSStatus SUAppcastParseError;
|
||||
extern OSStatus SUNoUpdateError;
|
||||
extern OSStatus SUAppcastError;
|
||||
extern OSStatus SURunningFromDiskImageError;
|
||||
extern NSString *const SUAppcastAttributeDeltaFrom;
|
||||
extern NSString *const SUAppcastAttributeDSASignature;
|
||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||
extern NSString *const SUAppcastAttributeVersion;
|
||||
|
||||
// Downlaod phase errors.
|
||||
extern OSStatus SUTemporaryDirectoryError;
|
||||
extern NSString *const SUAppcastElementCriticalUpdate;
|
||||
extern NSString *const SUAppcastElementDeltas;
|
||||
extern NSString *const SUAppcastElementMinimumSystemVersion;
|
||||
extern NSString *const SUAppcastElementMaximumSystemVersion;
|
||||
extern NSString *const SUAppcastElementReleaseNotesLink;
|
||||
extern NSString *const SUAppcastElementTags;
|
||||
|
||||
// Extraction phase errors.
|
||||
extern OSStatus SUUnarchivingError;
|
||||
extern OSStatus SUSignatureError;
|
||||
extern NSString *const SURSSAttributeURL;
|
||||
|
||||
// Installation phase errors.
|
||||
extern OSStatus SUFileCopyFailure;
|
||||
extern OSStatus SUAuthenticationFailure;
|
||||
extern OSStatus SUMissingUpdateError;
|
||||
extern OSStatus SUMissingInstallerToolError;
|
||||
extern OSStatus SURelaunchError;
|
||||
extern OSStatus SUInstallationError;
|
||||
extern OSStatus SUDowngradeError;
|
||||
extern NSString *const SURSSElementDescription;
|
||||
extern NSString *const SURSSElementEnclosure;
|
||||
extern NSString *const SURSSElementLink;
|
||||
extern NSString *const SURSSElementPubDate;
|
||||
extern NSString *const SURSSElementTitle;
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,16 @@
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
||||
// Define some minimum intervals to avoid DoS-like checking attacks
|
||||
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
||||
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
||||
|
||||
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
|
||||
|
||||
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
|
||||
|
||||
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
|
||||
@@ -28,29 +38,36 @@ NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||
NSString *const SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup";
|
||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
||||
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
||||
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
||||
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
||||
|
||||
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
|
||||
OSStatus SUAppcastParseError = 1000;
|
||||
OSStatus SUNoUpdateError = 1001;
|
||||
OSStatus SUAppcastError = 1002;
|
||||
OSStatus SURunningFromDiskImageError = 1003;
|
||||
|
||||
OSStatus SUTemporaryDirectoryError = 2000;
|
||||
NSString *const SUAppendVersionNumberKey = @"SUAppendVersionNumber";
|
||||
NSString *const SUEnableAutomatedDowngradesKey = @"SUEnableAutomatedDowngrades";
|
||||
NSString *const SUNormalizeInstalledApplicationNameKey = @"SUNormalizeInstalledApplicationName";
|
||||
NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
|
||||
|
||||
OSStatus SUUnarchivingError = 3000;
|
||||
OSStatus SUSignatureError = 3001;
|
||||
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
||||
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||
|
||||
OSStatus SUFileCopyFailure = 4000;
|
||||
OSStatus SUAuthenticationFailure = 4001;
|
||||
OSStatus SUMissingUpdateError = 4002;
|
||||
OSStatus SUMissingInstallerToolError = 4003;
|
||||
OSStatus SURelaunchError = 4004;
|
||||
OSStatus SUInstallationError = 4005;
|
||||
OSStatus SUDowngradeError = 4006;
|
||||
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
||||
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
||||
NSString *const SUAppcastElementMinimumSystemVersion = @"sparkle:minimumSystemVersion";
|
||||
NSString *const SUAppcastElementMaximumSystemVersion = @"sparkle:maximumSystemVersion";
|
||||
NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
|
||||
NSString *const SUAppcastElementTags = @"sparkle:tags";
|
||||
|
||||
NSString *const SURSSAttributeURL = @"url";
|
||||
|
||||
NSString *const SURSSElementDescription = @"description";
|
||||
NSString *const SURSSElementEnclosure = @"enclosure";
|
||||
NSString *const SURSSElementLink = @"link";
|
||||
NSString *const SURSSElementPubDate = @"pubDate";
|
||||
NSString *const SURSSElementTitle = @"title";
|
||||
@@ -5,14 +5,33 @@
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -5,351 +5,161 @@
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUDSAVerifier.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SULog.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
|
||||
#include <Security/cssm.h>
|
||||
|
||||
/* CDSA Specific */
|
||||
static CSSM_CSP_HANDLE cdsaInit( void );
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle );
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey );
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key );
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature );
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes );
|
||||
|
||||
/* Helper Functions */
|
||||
static NSData *b64decode( NSString *str );
|
||||
static NSData *rawKeyData( NSString *str );
|
||||
|
||||
@implementation SUDSAVerifier
|
||||
#pragma mark -
|
||||
@implementation SUDSAVerifier {
|
||||
SecKeyRef _secKey;
|
||||
}
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
if ( !encodedSignature || !pkeyString || !path ) return NO;
|
||||
BOOL result = NO;
|
||||
NSData *pathData = nil, *sigData = nil;
|
||||
CFDataRef hashData = NULL;
|
||||
CSSM_KEY_PTR pubKey = cdsaCreateKey((CFDataRef)rawKeyData(pkeyString)); // Create the DSA key
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
if (!encodedSignature) {
|
||||
SULog(@"There is no DSA signature to check");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ( !pubKey ) return NO;
|
||||
if ( (cspHandle = cdsaInit()) == CSSM_INVALID_HANDLE ) goto validate_end; // Init CDSA
|
||||
if ( !cdsaVerifyKey(cspHandle, pubKey) ) goto validate_end; // Verify the key is valid
|
||||
if ( (pathData = [NSData dataWithContentsOfFile:path]) == nil ) goto validate_end; // File data
|
||||
if ( (hashData = cdsaCreateSHA1Digest(cspHandle, (CFDataRef)pathData)) == NULL ) goto validate_end; // Hash
|
||||
if (!path) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Remove any line feeds from end of signature
|
||||
// (Not likely needed, but the verify _can_ fail if there is, so...)
|
||||
if ( [encodedSignature characterAtIndex:[encodedSignature length] - 1] == '\n' ) {
|
||||
NSMutableString *sig = [[encodedSignature mutableCopy] autorelease];
|
||||
while ( [sig characterAtIndex:[sig length] - 1] == '\n' )
|
||||
[sig deleteCharactersInRange:NSMakeRange([sig length] - 1, 1)];
|
||||
encodedSignature = sig;
|
||||
}
|
||||
if ( (sigData = b64decode(encodedSignature)) == nil ) goto validate_end; // Decode signature
|
||||
SUDSAVerifier *verifier = [[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
// Verify the signature on the file
|
||||
result = cdsaVerifySignature( cspHandle, pubKey, hashData, (CFDataRef)sigData );
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
validate_end:
|
||||
cdsaReleaseKey( pubKey );
|
||||
cdsaRelease( cspHandle );
|
||||
if ( hashData ) CFRelease( hashData );
|
||||
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
NSData *signature = [[NSData alloc] initWithBase64Encoding:strippedSignature];
|
||||
return [verifier verifyFileAtPath:path signature:signature];
|
||||
}
|
||||
|
||||
return result;
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (!self || !data.length) {
|
||||
SULog(@"Could not read public DSA key");
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecExternalFormat format = kSecFormatOpenSSL;
|
||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||
CFArrayRef items = NULL;
|
||||
|
||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
|
||||
if (status != errSecSuccess || !items) {
|
||||
if (items) {
|
||||
CFRelease(items);
|
||||
}
|
||||
SULog(@"Public DSA key could not be imported: %d", status);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
|
||||
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
|
||||
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_secKey) {
|
||||
CFRelease(_secKey);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
|
||||
{
|
||||
if (!path.length) {
|
||||
return NO;
|
||||
}
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyStream:dataInputStream signature:signature];
|
||||
}
|
||||
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !signature) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
|
||||
__block SecTransformRef dataReadTransform = NULL;
|
||||
__block SecTransformRef dataDigestTransform = NULL;
|
||||
__block SecTransformRef dataVerifyTransform = NULL;
|
||||
__block CFErrorRef error = NULL;
|
||||
|
||||
BOOL (^cleanup)(void) = ^{
|
||||
if (group) CFRelease(group);
|
||||
if (dataReadTransform) CFRelease(dataReadTransform);
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
return NO;
|
||||
};
|
||||
|
||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||
if (!dataReadTransform) {
|
||||
SULog(@"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
|
||||
if (!dataDigestTransform) {
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(@"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(@"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||
if (error) {
|
||||
SULog(@"%@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||
if (error) {
|
||||
SULog(@"DSA signature verification failed: %@", error);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
if (!result.boolValue) {
|
||||
SULog(@"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
}
|
||||
|
||||
cleanup();
|
||||
return result.boolValue;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Misc Helper Functions
|
||||
#pragma mark -
|
||||
|
||||
static NSData *b64decode( NSString *str )
|
||||
{
|
||||
if ( !str ) return nil;
|
||||
NSMutableData *retval = nil;
|
||||
NSData *input = [str dataUsingEncoding:NSUTF8StringEncoding];
|
||||
UInt8 *ibuf = (UInt8 *)[input bytes], *buf = NULL, *a = NULL;
|
||||
size_t len = [input length], i = 0, j = 0, size = ((len + 3) / 4) * 3;
|
||||
static UInt8 table[256] = {
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 00-0F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 10-1F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,62,99,99,99,63, /* 20-2F */
|
||||
52,53,54,55,56,57,58,59,60,61,99,99,99,99,99,99, /* 30-3F */
|
||||
99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
|
||||
15,16,17,18,19,20,21,22,23,24,25,99,99,99,99,99, /* 50-5F */
|
||||
99,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
|
||||
41,42,43,44,45,46,47,48,49,50,51,99,99,99,99,99, /* 70-7F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 80-8F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* 90-9F */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* A0-AF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* B0-BF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* C0-CF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* D0-DF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99, /* E0-EF */
|
||||
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 /* F0-FF */
|
||||
};
|
||||
|
||||
retval = [NSMutableData dataWithLength:size];
|
||||
buf = [retval mutableBytes];
|
||||
|
||||
if ( (a = calloc(4, sizeof(UInt8))) == NULL ) return nil;
|
||||
|
||||
do {
|
||||
size_t ai = 0;
|
||||
a[0] = a[1] = a[2] = a[3] = 0;
|
||||
do {
|
||||
UInt8 d = table[ibuf[i++]];
|
||||
if ( d != 99 ) {
|
||||
a[ai] = d;
|
||||
ai++;
|
||||
if ( ai == 4 ) break;
|
||||
}
|
||||
} while ( i < len );
|
||||
if ( ai >= 2 ) buf[j+0] = (UInt8)((a[0] << 2) | (a[1] >> 4));
|
||||
if ( ai >= 3 ) buf[j+1] = (UInt8)((a[1] << 4) | (a[2] >> 2));
|
||||
if ( ai >= 4 ) buf[j+2] = (UInt8)((a[2] << 6) | (a[3] >> 0));
|
||||
j += ai-1;
|
||||
} while ( i < len );
|
||||
|
||||
free( a );
|
||||
if ( j < size ) [retval setLength:j];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static NSData *rawKeyData( NSString *key )
|
||||
{
|
||||
if ( (key == nil) || ([key length] == 0) ) return nil;
|
||||
NSMutableString *t = [[key mutableCopy] autorelease];
|
||||
|
||||
// Remove the PEM guards (if present)
|
||||
[t replaceOccurrencesOfString:@"-" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"BEGIN PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
[t replaceOccurrencesOfString:@"END PUBLIC KEY" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [t length])];
|
||||
|
||||
// Remove any line feeds from the beginning of the key
|
||||
while ( [t characterAtIndex:0] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange(0, 1)];
|
||||
}
|
||||
|
||||
// Remove any line feeds at the end of the key
|
||||
while ( [t characterAtIndex:[t length] - 1] == '\n' ) {
|
||||
[t deleteCharactersInRange:NSMakeRange([t length] - 1, 1)];
|
||||
}
|
||||
|
||||
// Remove whitespace around each line of the key.
|
||||
NSMutableArray *pkeyTrimmedLines = [NSMutableArray array];
|
||||
NSCharacterSet *whiteSet = [NSCharacterSet whitespaceCharacterSet];
|
||||
for (NSString *pkeyLine in [t componentsSeparatedByString:@"\n"])
|
||||
{
|
||||
[pkeyTrimmedLines addObject:[pkeyLine stringByTrimmingCharactersInSet:whiteSet]];
|
||||
}
|
||||
key = [pkeyTrimmedLines componentsJoinedByString:@"\n"]; // Put them back together.
|
||||
|
||||
// Base64 decode to return the raw key bits (DER format rather than PEM)
|
||||
return b64decode( key );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark CDSA
|
||||
#pragma mark -
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes );
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData );
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes );
|
||||
|
||||
/* Memory functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void *ref );
|
||||
static void su_free( void *ptr, void *ref );
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void *ref );
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void *ref );
|
||||
|
||||
/* Constants & Typedefs */
|
||||
static CSSM_VERSION vers = { 2, 0 };
|
||||
static const CSSM_GUID su_guid = { 'S', 'p', 'a', { 'r', 'k', 'l', 'e', 0, 0, 0, 0 } };
|
||||
static CSSM_BOOL cssmInited = CSSM_FALSE;
|
||||
|
||||
static CSSM_API_MEMORY_FUNCS SU_MemFuncs = {
|
||||
su_malloc,
|
||||
su_free,
|
||||
su_realloc,
|
||||
su_calloc,
|
||||
NULL
|
||||
};
|
||||
|
||||
static CSSM_CSP_HANDLE cdsaInit( void )
|
||||
{
|
||||
CSSM_CSP_HANDLE cspHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_RETURN crtn;
|
||||
|
||||
if ( !cssmInited ) {
|
||||
CSSM_PVC_MODE pvcPolicy = CSSM_PVC_NONE;
|
||||
crtn = CSSM_Init( &vers, CSSM_PRIVILEGE_SCOPE_NONE, &su_guid, CSSM_KEY_HIERARCHY_NONE, &pvcPolicy, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
cssmInited = CSSM_TRUE;
|
||||
}
|
||||
|
||||
crtn = CSSM_ModuleLoad( &gGuidAppleCSP, CSSM_KEY_HIERARCHY_NONE, NULL, NULL );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
crtn = CSSM_ModuleAttach( &gGuidAppleCSP, &vers, &SU_MemFuncs, 0, CSSM_SERVICE_CSP, 0, CSSM_KEY_HIERARCHY_NONE, NULL, 0, NULL, &cspHandle );
|
||||
if ( crtn ) return CSSM_INVALID_HANDLE;
|
||||
|
||||
return cspHandle;
|
||||
}
|
||||
|
||||
static void cdsaRelease( CSSM_CSP_HANDLE cspHandle )
|
||||
{
|
||||
if ( CSSM_ModuleDetach(cspHandle) != CSSM_OK ) return;
|
||||
CSSM_ModuleUnload( &gGuidAppleCSP, NULL, NULL );
|
||||
}
|
||||
|
||||
static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey )
|
||||
{
|
||||
CSSM_KEY_PTR retval = NULL;
|
||||
|
||||
if ( !rawKey || (CFDataGetLength(rawKey) == 0) ) return NULL;
|
||||
|
||||
if ( (retval = su_malloc(sizeof(CSSM_KEY), NULL)) == NULL ) return NULL;
|
||||
|
||||
if ( !su_copyBytesToData(&(retval->KeyData), (CSSM_SIZE)CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
|
||||
su_free( retval, NULL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSSM_KEYHEADER_PTR hdr = &(retval->KeyHeader);
|
||||
|
||||
memset( hdr, 0, sizeof(CSSM_KEYHEADER) );
|
||||
|
||||
hdr->HeaderVersion = CSSM_KEYHEADER_VERSION;
|
||||
hdr->CspId = su_guid;
|
||||
hdr->BlobType = CSSM_KEYBLOB_RAW;
|
||||
hdr->Format = CSSM_KEYBLOB_RAW_FORMAT_X509;
|
||||
hdr->AlgorithmId = CSSM_ALGID_DSA;
|
||||
hdr->KeyClass = CSSM_KEYCLASS_PUBLIC_KEY;
|
||||
hdr->KeyAttr = CSSM_KEYATTR_EXTRACTABLE;
|
||||
hdr->KeyUsage = CSSM_KEYUSE_ANY;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void cdsaReleaseKey( CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key ) {
|
||||
if ( key->KeyData.Data ) su_free( key->KeyData.Data, NULL );
|
||||
su_free( key, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL cdsaVerifyKey( CSSM_CSP_HANDLE cspHandle, CSSM_KEY_PTR key )
|
||||
{
|
||||
if ( key->KeyHeader.LogicalKeySizeInBits == 0 ) {
|
||||
CSSM_RETURN crtn;
|
||||
CSSM_KEY_SIZE keySize;
|
||||
|
||||
/* This will fail if the key isn't valid */
|
||||
crtn = CSSM_QueryKeySizeInBits( cspHandle, CSSM_INVALID_HANDLE, key, &keySize );
|
||||
if ( crtn ) return NO;
|
||||
key->KeyHeader.LogicalKeySizeInBits = keySize.LogicalKeySizeInBits;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL cdsaVerifySignature( CSSM_CSP_HANDLE cspHandle, const CSSM_KEY_PTR key, const CFDataRef msg, const CFDataRef signature )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR plain = su_createData( msg ), cipher = su_createData( signature );
|
||||
BOOL retval = NO;
|
||||
|
||||
if ( !plain || !cipher || (CSSM_CSP_CreateSignatureContext(cspHandle, CSSM_ALGID_SHA1WithDSA, NULL, key, &ccHandle) != CSSM_OK) )
|
||||
goto verify_end;
|
||||
|
||||
retval = ( CSSM_VerifyData(ccHandle, plain, 1, CSSM_ALGID_NONE, cipher) == CSSM_OK );
|
||||
|
||||
verify_end:
|
||||
su_freeData( plain, true );
|
||||
su_freeData( cipher, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CFDataRef cdsaCreateSHA1Digest( CSSM_CSP_HANDLE cspHandle, const CFDataRef bytes )
|
||||
{
|
||||
CSSM_CC_HANDLE ccHandle = CSSM_INVALID_HANDLE;
|
||||
CSSM_DATA_PTR data = su_createData( bytes ), dgst = su_createData( NULL );
|
||||
CFDataRef retval = NULL;
|
||||
|
||||
if ( !data || !dgst || (CSSM_CSP_CreateDigestContext(cspHandle, CSSM_ALGID_SHA1, &ccHandle) != CSSM_OK) )
|
||||
goto digest_end;
|
||||
|
||||
if ( CSSM_DigestData(ccHandle, data, 1, dgst) == CSSM_OK )
|
||||
retval = CFDataCreate( kCFAllocatorDefault, (const UInt8 *)dgst->Data, (CFIndex)dgst->Length );
|
||||
|
||||
digest_end:
|
||||
su_freeData( data, true );
|
||||
su_freeData( dgst, true );
|
||||
if ( ccHandle ) CSSM_DeleteContext( ccHandle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Memory Functions */
|
||||
static void *su_malloc( CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
static void su_free( void *ptr, void * __unused ref )
|
||||
{
|
||||
free( ptr );
|
||||
}
|
||||
|
||||
static void *su_realloc( void *ptr, CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
|
||||
static void *su_calloc( uint32 num, CSSM_SIZE size, void * __unused ref )
|
||||
{
|
||||
return calloc( num, size );
|
||||
}
|
||||
|
||||
/* Helper Functions */
|
||||
static CSSM_DATA_PTR su_createData( CFDataRef bytes )
|
||||
{
|
||||
CSSM_DATA_PTR data = su_malloc( sizeof(CSSM_DATA), NULL );
|
||||
if ( !data ) return NULL;
|
||||
data->Data = NULL;
|
||||
data->Length = 0;
|
||||
if ( bytes ) su_copyBytesToData( data, (CSSM_SIZE)CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
|
||||
return data;
|
||||
}
|
||||
|
||||
static void su_freeData( CSSM_DATA_PTR data, Boolean freeData )
|
||||
{
|
||||
if ( data ) {
|
||||
if ( freeData && data->Data ) su_free( data->Data, NULL );
|
||||
su_free( data, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
static Boolean su_copyBytesToData( CSSM_DATA_PTR data, CSSM_SIZE size, const uint8 *bytes )
|
||||
{
|
||||
Boolean retval = false;
|
||||
if ( size && bytes ) {
|
||||
if ( (data->Data = su_malloc(size, NULL)) ) {
|
||||
memcpy( data->Data, bytes, size );
|
||||
data->Length = size;
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUUnarchiver_Private.h"
|
||||
#import "NTSynchronousTask.h"
|
||||
#import "SULog.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
@@ -16,147 +15,187 @@
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMG
|
||||
{
|
||||
@autoreleasepool {
|
||||
[self extractDMGWithPassword:nil];
|
||||
}
|
||||
[self extractDMGWithPassword:nil];
|
||||
}
|
||||
}
|
||||
|
||||
// Called on a non-main thread.
|
||||
- (void)extractDMGWithPassword:(NSString *) __unused password
|
||||
- (void)extractDMGWithPassword:(NSString *)__unused password
|
||||
{
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
SULog(@"Extracting %@ as a DMG", archivePath);
|
||||
SULog(@"Extracting %@ as a DMG", self.archivePath);
|
||||
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
FSRef tmpRef;
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
FSRef tmpRef;
|
||||
NSFileManager *manager;
|
||||
NSError *error;
|
||||
NSArray *contents;
|
||||
// We have to declare these before a goto to prevent an error under ARC.
|
||||
// No, we cannot have them in the dispatch_async calls, as the goto "jump enters
|
||||
// lifetime of block which strongly captures a variable"
|
||||
dispatch_block_t delegateFailure = ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
};
|
||||
dispatch_block_t delegateSuccess = ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
};
|
||||
do
|
||||
{
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||
if (uuid)
|
||||
{
|
||||
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
||||
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
||||
if (uuidString)
|
||||
{
|
||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
||||
}
|
||||
CFRelease(uuid);
|
||||
}
|
||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
||||
}
|
||||
CFRelease(uuid);
|
||||
}
|
||||
}
|
||||
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
|
||||
while (noErr == FSPathMakeRefWithOptions((const UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
|
||||
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
NSArray* arguments = @[@"attach", archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
|
||||
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
if (self.decryptionPassword) {
|
||||
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
// From the hdiutil docs:
|
||||
// read a null-terminated passphrase from standard input
|
||||
//
|
||||
// Add the null terminator, then the newline
|
||||
[passwordData appendData:[NSData dataWithBytes:"\0" length:1]];
|
||||
[passwordData appendData:promptData];
|
||||
promptData = passwordData;
|
||||
|
||||
[arguments addObject:@"-stdinpass"];
|
||||
}
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
{
|
||||
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
|
||||
|
||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
||||
|
||||
taskResult = [task result];
|
||||
output = [[[task output] copy] autorelease];
|
||||
[task release];
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = @"/usr/bin/hdiutil";
|
||||
task.currentDirectoryPath = @"/";
|
||||
task.arguments = arguments;
|
||||
|
||||
NSPipe *inputPipe = [NSPipe pipe];
|
||||
NSPipe *outputPipe = [NSPipe pipe];
|
||||
|
||||
task.standardInput = inputPipe;
|
||||
task.standardOutput = outputPipe;
|
||||
|
||||
[task launch];
|
||||
|
||||
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||
[inputPipe.fileHandleForWriting closeFile];
|
||||
|
||||
// Read data to end *before* waiting until the task ends so we don't deadlock if the stdout buffer becomes full if we haven't consumed from it
|
||||
output = [outputPipe.fileHandleForReading readDataToEndOfFile];
|
||||
|
||||
[task waitUntilExit];
|
||||
taskResult = task.terminationStatus;
|
||||
}
|
||||
@catch (NSException *)
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
if (taskResult != 0)
|
||||
{
|
||||
NSString* resultStr = output ? [[[NSString alloc] initWithData: output encoding: NSUTF8StringEncoding] autorelease] : nil;
|
||||
SULog( @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr );
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
||||
SULog(@"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||
NSError *error = nil;
|
||||
NSArray *contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
// 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)
|
||||
{
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
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;
|
||||
}
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
|
||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||
{
|
||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfSuccess];
|
||||
});
|
||||
goto finally;
|
||||
dispatch_async(dispatch_get_main_queue(), delegateSuccess);
|
||||
goto finally;
|
||||
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self notifyDelegateOfFailure];
|
||||
});
|
||||
reportError:
|
||||
dispatch_async(dispatch_get_main_queue(), delegateFailure);
|
||||
|
||||
finally:
|
||||
if (mountedSuccessfully)
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
else
|
||||
SULog(@"Can't mount DMG %@",archivePath);
|
||||
}
|
||||
finally:
|
||||
if (mountedSuccessfully) {
|
||||
@try {
|
||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
||||
} @catch (NSException *exception) {
|
||||
SULog(@"Failed to unmount %@", mountPoint);
|
||||
SULog(@"Exception: %@", exception);
|
||||
}
|
||||
} else {
|
||||
SULog(@"Can't mount DMG %@", self.archivePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)start
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self extractDMG];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[self registerImplementation:self];
|
||||
[self registerImplementation:self];
|
||||
}
|
||||
|
||||
- (BOOL)isEncrypted:(NSData*)resultData
|
||||
- (BOOL)isEncrypted:(NSData *)resultData
|
||||
{
|
||||
BOOL result = NO;
|
||||
BOOL result = NO;
|
||||
if(resultData)
|
||||
{
|
||||
NSString *data = [[[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding] autorelease];
|
||||
NSString *data = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
|
||||
|
||||
if ((data != nil) && !NSEqualRanges([data rangeOfString:@"passphrase-count"], NSMakeRange(NSNotFound, 0)))
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// SUErrors.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by C.W. Betts on 10/13/14.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUERRORS_H
|
||||
#define SUERRORS_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
/**
|
||||
* Error domain used by Sparkle
|
||||
*/
|
||||
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
|
||||
|
||||
typedef NS_ENUM(OSStatus, SUError) {
|
||||
// Appcast phase errors.
|
||||
SUAppcastParseError = 1000,
|
||||
SUNoUpdateError = 1001,
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
SUDownloadError = 2001,
|
||||
|
||||
// Extraction phase errors.
|
||||
SUUnarchivingError = 3000,
|
||||
SUSignatureError = 3001,
|
||||
|
||||
// Installation phase errors.
|
||||
SUFileCopyFailure = 4000,
|
||||
SUAuthenticationFailure = 4001,
|
||||
SUMissingUpdateError = 4002,
|
||||
SUMissingInstallerToolError = 4003,
|
||||
SURelaunchError = 4004,
|
||||
SUInstallationError = 4005,
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCancelledError = 4007,
|
||||
|
||||
// System phase errors
|
||||
SUSystemPowerOffError = 5000
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// SUExport.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Jake Petroules on 2014-08-23.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUEXPORT_H
|
||||
#define SUEXPORT_H
|
||||
|
||||
#ifdef BUILDING_SPARKLE
|
||||
#define SU_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define SU_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// SUFileManager.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/18/15.
|
||||
// Copyright (c) 2015 zgcoder. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* A class used for performing file operations that may also perform authorization if allowed and if permission is denied when trying to
|
||||
* perform them normally as the running user. All operations on this class may be used on thread other than the main thread.
|
||||
* This class provides basic file operations and stays away from including much application-level logic.
|
||||
*/
|
||||
@interface SUFileManager : NSObject
|
||||
|
||||
/**
|
||||
* Creates a file manager that will not authorize for file operations
|
||||
* @return A new file manager instance
|
||||
*/
|
||||
+ (instancetype)defaultManager;
|
||||
|
||||
/**
|
||||
* Creates a file manager that allows authorizing for file operations
|
||||
* @param authorizationToolPath Specifies the path to the tool that can perform file operations and be run as root.
|
||||
* This tool will be invoked when read or write access is denied when attempting ordinary file operations. See the `fileop` tool included in Sparkle.
|
||||
* @return A new file manager instance
|
||||
*
|
||||
* This method just creates the file manager. It doesn't acquire authorization immediately or if it doesn't need to.
|
||||
*/
|
||||
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath;
|
||||
|
||||
/**
|
||||
* Returns a file manager that allows or disallows authorizing for file operations based on the current file manager
|
||||
* @return A file manager instance that can perform authorized operations if the current file manager has already performed them.
|
||||
* If the current file manager instance hasn't yet performed authorized operations, then neither can the instance returned by this method
|
||||
*
|
||||
* This may return a newly created file manager or re-use the existing file manager depending on the current authorization rights.
|
||||
*/
|
||||
- (instancetype)fileManagerByPreservingAuthorizationRights;
|
||||
|
||||
/**
|
||||
* Creates a temporary directory on the same volume as a provided URL
|
||||
* @param preferredName A name that may be used when creating the temporary directory. Note that in the uncommon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL
|
||||
* @param appropriateURL A URL to a directory that resides on the volume that the temporary directory will be created on. In the uncommon case, the temporary directory may be created inside this directory.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return A URL pointing to the newly created temporary directory, or nil with a populated error object if an error occurs.
|
||||
*
|
||||
* When moving an item from a source to a destination, it is desirable to create a temporary intermediate destination on the same volume as the destination to ensure
|
||||
* that the item will be moved, and not copied, from the intermediate point to the final destination. This ensures file atomicity.
|
||||
*/
|
||||
- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)appropriateURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Creates a directory at the target URL
|
||||
* @param targetURL A URL pointing to the directory to create. The item at this URL must not exist, and the parent directory of this URL must already exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was created successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is an atomic operation.
|
||||
*/
|
||||
- (BOOL)makeDirectoryAtURL:(NSURL *)targetURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Moves an item from a source to a destination
|
||||
* @param sourceURL A URL pointing to the item to move. The item at this URL must exist.
|
||||
* @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was moved successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* If sourceURL and destinationURL reside on the same volume, this operation will be an atomic move operation.
|
||||
* Otherwise this will be equivalent to a copy & remove which will be a nonatomic operation.
|
||||
*/
|
||||
- (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Copies an item from a source to a destination
|
||||
* @param sourceURL A URL pointing to the item to move. The item at this URL must exist.
|
||||
* @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was copied successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Moves an item at a specified URL to the running user's trash directory
|
||||
* @param url A URL pointing to the item to move to the trash. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was moved to the trash successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
*
|
||||
* This method has to locate the trash directory and uses an intermediate temporary directory before trashing the item.
|
||||
* A copy may have to be done if the url is not on the same volume as the running user's trash directory.
|
||||
* If a failure occurs in the middle of this operation, the item to remove may be lost forever or stuck in a temporary location.
|
||||
*
|
||||
* This is not an atomic operation, nor intended to be a recoverable operation if the worst comes to worst.
|
||||
*/
|
||||
- (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Removes an item at a URL
|
||||
* @param url A URL pointing to the item to remove. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the item was removed successfully, otherwise NO along with a populated error object
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Changes the owner and group IDs of an item at a specified target URL to match another URL
|
||||
* @param targetURL A URL pointing to the target item whose owner and group IDs to alter. This will be applied recursively if the item is a directory. The item at this URL must exist.
|
||||
* @param matchURL A URL pointing to the item whose owner and group IDs will be used for changing on the targetURL. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the target item's owner and group IDs have changed to match the origin's ones, otherwise NO along with a populated error object
|
||||
*
|
||||
* If the owner and group IDs match on the root items of targetURL and matchURL, this method stops and assumes that nothing needs to be done.
|
||||
* Otherwise this method recursively changes the IDs if the target is a directory. If an item in the directory is encountered that is unable to be changed,
|
||||
* then this method stops and returns NO.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Updates the modification and access time of an item at a specified target URL to the current time
|
||||
* @param targetURL A URL pointing to the target item whose modification and access time to update. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the target item's modification and access times have been updated, otherwise NO along with a populated error object
|
||||
*
|
||||
* This method updates the modification and access time of an item to the current time, ideal for letting the system know we installed a new file or
|
||||
* application.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Releases Apple's quarantine extended attribute from the item at the specified root URL
|
||||
* @param rootURL A URL pointing to the item to release from Apple's quarantine. This will be applied recursively if the item is a directory. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if all the items at the target could be released from quarantine, otherwise NO if any items couldn't along with a populated error object
|
||||
*
|
||||
* This method removes quarantine attributes from an item, ideally an application, so that when the user launches a new application themselves, they
|
||||
* don't have to witness the system dialog alerting them that they downloaded an application from the internet and asking if they want to continue.
|
||||
* Note that this may not exactly mimic the system behavior when a user opens an application for the first time (i.e, the xattr isn't deleted),
|
||||
* but this should be sufficient enough for our purposes.
|
||||
*
|
||||
* This method may return NO even if some items do get released from quarantine if the target URL is pointing to a directory.
|
||||
* Thus if an item cannot be released from quarantine, this method still continues on to the next enumerated item.
|
||||
*
|
||||
* This is not an atomic operation.
|
||||
*/
|
||||
- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error;
|
||||
|
||||
/**
|
||||
* Runs an installer package (pkg) in a headless mode using /usr/sbin/installer
|
||||
* @param packageURL A URL pointing to the package to execute. The item at this URL must exist.
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
|
||||
* @return YES if the installer ran the package successfully, otherwise NO with a populated error object
|
||||
*
|
||||
* This method uses the system wide installer tool to run the provided package. This process does not show any UI, except for
|
||||
* an initial authorization prompt if the calling process does not have root privileges. In other words, root privileges are required to use this method, and the file manager instance must have been created by allowing authorization.
|
||||
* An error can occur if the package is unable to be ran by the installer, or if the installer reports a non-zero exit status code.
|
||||
*/
|
||||
- (BOOL)executePackageAtURL:(NSURL *)packageURL error:(NSError **)error;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// SUGuidedPackageInstaller.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Graham Miln on 14/05/2010.
|
||||
// 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.
|
||||
|
||||
The installer package is installed using macOS's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
||||
|
||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
||||
|
||||
## To Do
|
||||
- Replace the use of `AuthorizationExecuteWithPrivilegesAndWait`. This method remains because it is well supported and tested. Ideally a helper tool or XPC would be used.
|
||||
*/
|
||||
|
||||
#ifndef SUGUIDEDPACKAGEINSTALLER_H
|
||||
#define SUGUIDEDPACKAGEINSTALLER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "Sparkle.h"
|
||||
#import "SUInstaller.h"
|
||||
|
||||
@interface SUGuidedPackageInstaller : SUInstaller
|
||||
|
||||
/*! Perform the guided installation */
|
||||
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// SUGuidedPackageInstaller.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Graham Miln on 14/05/2010.
|
||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
@implementation SUGuidedPackageInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
SUParameterAssert(packagePath);
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath];
|
||||
|
||||
NSError *error = nil;
|
||||
BOOL validInstallation = [fileManager executePackageAtURL:[NSURL fileURLWithPath:packagePath] error:&error];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self finishInstallationToPath:destinationPath
|
||||
withResult:validInstallation
|
||||
error:error
|
||||
completionHandler:completionHandler];
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -5,24 +5,27 @@
|
||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUpdater.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@interface SUHost : NSObject
|
||||
{
|
||||
@private
|
||||
NSString *defaultsDomain;
|
||||
BOOL usesStandardUserDefaults;
|
||||
}
|
||||
@property (retain, readonly) NSBundle *bundle;
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
typedef struct {
|
||||
NSInteger majorVersion;
|
||||
NSInteger minorVersion;
|
||||
NSInteger patchVersion;
|
||||
} NSOperatingSystemVersion;
|
||||
#endif
|
||||
|
||||
+ (NSString *)systemVersionString;
|
||||
@interface SUHost : NSObject
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||
@property (readonly, copy) NSString *bundlePath;
|
||||
@property (readonly, copy) NSString *appSupportPath;
|
||||
@property (readonly) BOOL allowsAutomaticUpdates;
|
||||
@property (readonly, copy) NSString *installationPath;
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
@@ -31,6 +34,7 @@
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (getter=isBackgroundApplication, readonly) BOOL backgroundApplication;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||
@property (readonly, copy) NSArray *systemProfile;
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
|
||||
@@ -11,240 +11,283 @@
|
||||
#import "SUSystemProfiler.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
#import "SUFileManager.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
||||
typedef struct {
|
||||
NSInteger majorVersion;
|
||||
NSInteger minorVersion;
|
||||
NSInteger patchVersion;
|
||||
} NSOperatingSystemVersion;
|
||||
@interface NSProcessInfo ()
|
||||
- (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUHost ()
|
||||
@property (retain, readwrite) NSBundle *bundle;
|
||||
|
||||
@property (strong, readwrite) NSBundle *bundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUHost
|
||||
|
||||
@synthesize bundle;
|
||||
@synthesize defaultsDomain;
|
||||
@synthesize usesStandardUserDefaults;
|
||||
|
||||
- (instancetype)initWithBundle:(NSBundle *)aBundle
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
if (aBundle == nil) aBundle = [NSBundle mainBundle];
|
||||
SUParameterAssert(aBundle);
|
||||
self.bundle = aBundle;
|
||||
if (![bundle bundleIdentifier]) {
|
||||
SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle);
|
||||
}
|
||||
if (![self.bundle bundleIdentifier]) {
|
||||
SULog(@"Error: the bundle being updated at %@ has no %@! This will cause preference read/write to not work properly.", self.bundle, kCFBundleIdentifierKey);
|
||||
}
|
||||
|
||||
defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain];
|
||||
if (!defaultsDomain) {
|
||||
defaultsDomain = [[bundle bundleIdentifier] retain];
|
||||
}
|
||||
self.defaultsDomain = [self.bundle objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
||||
if (!self.defaultsDomain) {
|
||||
self.defaultsDomain = [self.bundle bundleIdentifier];
|
||||
}
|
||||
|
||||
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
|
||||
usesStandardUserDefaults = [defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
|
||||
NSString *mainBundleIdentifier = NSBundle.mainBundle.bundleIdentifier;
|
||||
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:mainBundleIdentifier];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[defaultsDomain release];
|
||||
self.bundle = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
|
||||
|
||||
- (NSString *)bundlePath
|
||||
{
|
||||
return [bundle bundlePath];
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)appSupportPath
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
NSString *appSupportPath = nil;
|
||||
if (!appSupportPaths || [appSupportPaths count] == 0)
|
||||
{
|
||||
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
|
||||
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
|
||||
// Does the developer want us to disable automatic updates?
|
||||
NSNumber *developerAllowsAutomaticUpdates = [self objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
|
||||
if (developerAllowsAutomaticUpdates != nil && !developerAllowsAutomaticUpdates.boolValue) {
|
||||
return NO;
|
||||
}
|
||||
else {
|
||||
appSupportPath = appSupportPaths[0];
|
||||
}
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
|
||||
appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"];
|
||||
return appSupportPath;
|
||||
|
||||
// Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)?
|
||||
// Note it's very well possible to have the bundle be writable but not be able to write into the parent directory
|
||||
// And if the bundle isn't writable, but we can write into the parent directory, we will still need to authorize to replace it
|
||||
NSString *bundlePath = [self bundlePath];
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath.stringByDeletingLastPathComponent] || ![[NSFileManager defaultManager] isWritableFileAtPath:bundlePath]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Just because we have writability access does not mean we can set the correct owner/group silently
|
||||
// Test if we can set the owner/group on a temporarily created file
|
||||
// If we can, then we can probably perform an update without authorization
|
||||
// One place where this matters is if you copy and run an app from /tmp/
|
||||
|
||||
NSString *tempFilename = @"permission_test" ;
|
||||
|
||||
SUFileManager *suFileManager = [SUFileManager defaultManager];
|
||||
NSURL *tempDirectoryURL = [suFileManager makeTemporaryDirectoryWithPreferredName:tempFilename appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:NULL];
|
||||
|
||||
if (tempDirectoryURL == nil) {
|
||||
// I don't imagine this ever happening but in case it does, requesting authorization may be the better option
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSURL *tempFileURL = [tempDirectoryURL URLByAppendingPathComponent:tempFilename];
|
||||
|
||||
BOOL changeOwnerAndGroupSuccess =
|
||||
[[NSData data] writeToURL:tempFileURL atomically:NO] &&
|
||||
[suFileManager changeOwnerAndGroupOfItemAtRootURL:tempFileURL toMatchURL:self.bundle.bundleURL error:NULL];
|
||||
|
||||
[suFileManager removeItemAtURL:tempDirectoryURL error:NULL];
|
||||
|
||||
return changeOwnerAndGroupSuccess;
|
||||
}
|
||||
|
||||
- (NSString *)installationPath
|
||||
{
|
||||
#if NORMALIZE_INSTALLED_APP_NAME
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
#endif
|
||||
return [bundle bundlePath];
|
||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:normalizedAppPath]) {
|
||||
return normalizedAppPath;
|
||||
}
|
||||
}
|
||||
return [self.bundle bundlePath];
|
||||
}
|
||||
|
||||
- (NSString *)name
|
||||
- (NSString *__nonnull)name
|
||||
{
|
||||
NSString *name = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name) return name;
|
||||
NSString *name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:@"CFBundleName"];
|
||||
if (name) return name;
|
||||
// Allow host bundle to provide a custom name
|
||||
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[bundle bundlePath]] stringByDeletingPathExtension];
|
||||
name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||
if (name && name.length > 0) return name;
|
||||
|
||||
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
- (NSString *)version
|
||||
- (NSString *__nonnull)version
|
||||
{
|
||||
NSString *version = [bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
|
||||
return version;
|
||||
NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||
if (!version || [version isEqualToString:@""])
|
||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey];
|
||||
return version;
|
||||
}
|
||||
|
||||
- (NSString *)displayVersion
|
||||
- (NSString *__nonnull)displayVersion
|
||||
{
|
||||
NSString *shortVersionString = [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
return shortVersionString;
|
||||
else
|
||||
return [self version]; // Fall back on the normal version string.
|
||||
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
if (shortVersionString)
|
||||
return shortVersionString;
|
||||
else
|
||||
return [self version]; // Fall back on the normal version string.
|
||||
}
|
||||
|
||||
- (NSImage *)icon
|
||||
- (NSImage *__nonnull)icon
|
||||
{
|
||||
// Cache the application icon.
|
||||
NSString *iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
||||
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// the icon for the bundle. The filename you specify does not need to include the .icns
|
||||
// extension, although it may."
|
||||
//
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
|
||||
if (!iconPath) {
|
||||
iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil];
|
||||
}
|
||||
NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease];
|
||||
// Use a default icon if none is defined.
|
||||
if (!icon) {
|
||||
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);
|
||||
// Cache the application icon.
|
||||
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
||||
// According to the macOS docs, "CFBundleIconFile - This key identifies the file containing
|
||||
// the icon for the bundle. The filename you specify does not need to include the .icns
|
||||
// extension, although it may."
|
||||
//
|
||||
// However, if it *does* include the '.icns' the above method fails (tested on macOS 10.3.9) so we'll also try:
|
||||
if (!iconPath) {
|
||||
iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:nil];
|
||||
}
|
||||
NSImage *icon = [[NSImage alloc] initWithContentsOfFile:iconPath];
|
||||
// Use a default icon if none is defined.
|
||||
if (!icon) {
|
||||
BOOL isMainBundle = (self.bundle == [NSBundle mainBundle]);
|
||||
|
||||
NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||
}
|
||||
return icon;
|
||||
NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle;
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
- (BOOL)isRunningOnReadOnlyVolume
|
||||
{
|
||||
struct statfs statfs_info;
|
||||
statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY);
|
||||
struct statfs statfs_info;
|
||||
statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||
}
|
||||
|
||||
- (BOOL)isBackgroundApplication
|
||||
{
|
||||
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
|
||||
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
|
||||
}
|
||||
|
||||
- (NSString *)publicDSAKey
|
||||
- (NSString *__nullable)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
if (key) { return key; }
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
if (!keyFilename) { return nil; }
|
||||
NSError *ignoreErr = nil;
|
||||
return [NSString stringWithContentsOfFile:[bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error: &ignoreErr];
|
||||
// More likely, we've got a reference to a Resources file by filename:
|
||||
NSString *keyFilename = [self publicDSAKeyFileKey];
|
||||
if (!keyFilename) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *keyPath = [self.bundle pathForResource:keyFilename ofType:nil];
|
||||
if (!keyPath) {
|
||||
return nil;
|
||||
}
|
||||
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
||||
}
|
||||
|
||||
- (NSString * __nullable)publicDSAKeyFileKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
}
|
||||
|
||||
- (NSArray *)systemProfile
|
||||
{
|
||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
||||
}
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
return [bundle objectForInfoDictionaryKey:key];
|
||||
return [self.bundle objectForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
||||
{
|
||||
return [[self objectForInfoDictionaryKey:key] boolValue];
|
||||
return [[self objectForInfoDictionaryKey:key] boolValue];
|
||||
}
|
||||
|
||||
- (id)objectForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (!defaultName || !defaultsDomain) {
|
||||
if (!defaultName || !self.defaultsDomain) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
|
||||
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
|
||||
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
|
||||
if (usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
|
||||
}
|
||||
// Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
|
||||
// passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls
|
||||
// back to using NSUserDefaults, but only if the host bundle is the main bundle.
|
||||
if (self.usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
|
||||
}
|
||||
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
return CFBridgingRelease(obj);
|
||||
CFPropertyListRef obj = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||
return CFBridgingRelease(obj);
|
||||
}
|
||||
|
||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults)
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, value, (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)boolForUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
|
||||
}
|
||||
if (self.usesStandardUserDefaults) {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName];
|
||||
}
|
||||
|
||||
BOOL value;
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain);
|
||||
if (plr == NULL) {
|
||||
value = NO;
|
||||
BOOL value;
|
||||
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
|
||||
if (plr == NULL) {
|
||||
value = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
||||
CFRelease(plr);
|
||||
}
|
||||
return value;
|
||||
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
|
||||
CFRelease(plr);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
|
||||
{
|
||||
if (usesStandardUserDefaults)
|
||||
if (self.usesStandardUserDefaults)
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
|
||||
}
|
||||
else
|
||||
{
|
||||
CFPreferencesSetValue((CFStringRef)defaultName, (CFBooleanRef)@(value), (CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((CFStringRef)defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
|
||||
}
|
||||
}
|
||||
|
||||
- (id)objectForKey:(NSString *)key {
|
||||
@@ -255,21 +298,4 @@ typedef struct {
|
||||
return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
|
||||
}
|
||||
|
||||
+ (NSString *)systemVersionString
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // Present in 10.9 despite NS_AVAILABLE's claims
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wselector"
|
||||
// Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug?
|
||||
if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
return [NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"];
|
||||
}
|
||||
#endif
|
||||
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,21 +12,13 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@protocol SUInstallerDelegate;
|
||||
|
||||
@class SUHost;
|
||||
@interface SUInstaller : NSObject
|
||||
|
||||
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host;
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator;
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id<SUInstallerDelegate>)delegate;
|
||||
+ (NSString *)updateFolder;
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr;
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
@protocol SUInstallerDelegate <NSObject>
|
||||
- (void)installerFinishedForHost:(SUHost *)host;
|
||||
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -9,174 +9,133 @@
|
||||
#import "SUInstaller.h"
|
||||
#import "SUPlainInstaller.h"
|
||||
#import "SUPackageInstaller.h"
|
||||
#import "SUGuidedPackageInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SULog.h"
|
||||
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
static NSString* sUpdateFolder = nil;
|
||||
|
||||
+(NSString*) updateFolder
|
||||
{
|
||||
return sUpdateFolder;
|
||||
}
|
||||
|
||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||
{
|
||||
FSRef fileRef;
|
||||
OSStatus err = noErr;
|
||||
Boolean aliasFileFlag = false, folderFlag = false;
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
|
||||
if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef))
|
||||
err = coreFoundationUnknownErr;
|
||||
|
||||
if (noErr == err)
|
||||
err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag);
|
||||
|
||||
if (noErr == err)
|
||||
return !!(aliasFileFlag && folderFlag);
|
||||
else
|
||||
return NO;
|
||||
NSNumber *aliasFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
|
||||
NSNumber *directoryFlag = nil;
|
||||
[[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil];
|
||||
return aliasFlag.boolValue && directoryFlag.boolValue;
|
||||
}
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
||||
{
|
||||
SUParameterAssert(inUpdateFolder);
|
||||
SUParameterAssert(host);
|
||||
|
||||
// Search subdirectories for the application
|
||||
NSString *currentFile,
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
BOOL isPackage = NO;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath: inUpdateFolder];
|
||||
NSString *currentFile,
|
||||
*newAppDownloadPath = nil,
|
||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
NSString *fallbackPackagePath = nil;
|
||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
||||
|
||||
[sUpdateFolder release];
|
||||
sUpdateFolder = [inUpdateFolder retain];
|
||||
while ((currentFile = [dirEnum nextObject])) {
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
NSString *currentFilename = [currentFile lastPathComponent];
|
||||
NSString *currentExtension = [currentFile pathExtension];
|
||||
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
|
||||
if ([currentFilename isEqualToString:bundleFileName] ||
|
||||
[currentFilename isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
} else if ([currentExtension isEqualToString:@"pkg"] ||
|
||||
[currentExtension isEqualToString:@"mpkg"]) {
|
||||
if ([currentFilenameNoExtension isEqualToString:bundleFileNameNoExtension]) {
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
} else {
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
} 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]) {
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while ((currentFile = [dirEnum nextObject]))
|
||||
{
|
||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
|
||||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else if ([[currentFile pathExtension] isEqualToString:@"pkg"] ||
|
||||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
|
||||
{
|
||||
if ([[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
|
||||
fallbackPackagePath = currentPath;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try matching on bundle identifiers in case the user has changed the name of the host app
|
||||
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
|
||||
if(incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]])
|
||||
{
|
||||
isPackage = NO;
|
||||
newAppDownloadPath = currentPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Some DMGs have symlinks into /Applications! That's no good!
|
||||
if ([self isAliasFolderAtPath:currentPath])
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
|
||||
// Some DMGs have symlinks into /Applications! That's no good!
|
||||
if ([self isAliasFolderAtPath:currentPath])
|
||||
[dirEnum skipDescendents];
|
||||
}
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
|
||||
// We don't have a valid path. Try to use the fallback package.
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil) {
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = fallbackPackagePath;
|
||||
}
|
||||
|
||||
if (newAppDownloadPath == nil && fallbackPackagePath != nil)
|
||||
{
|
||||
isPackage = YES;
|
||||
newAppDownloadPath = fallbackPackagePath;
|
||||
}
|
||||
if (isPackage) {
|
||||
// foo.app -> foo.sparkle_guided.pkg or foo.sparkle_guided.mpkg
|
||||
if ([[[newAppDownloadPath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_guided"]) {
|
||||
isGuided = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (isPackagePtr) *isPackagePtr = isPackage;
|
||||
if (isPackagePtr)
|
||||
*isPackagePtr = isPackage;
|
||||
if (isGuidedPtr)
|
||||
*isGuidedPtr = isGuided;
|
||||
|
||||
if (!newAppDownloadPath) {
|
||||
SULog(@"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
|
||||
}
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *path = [self installSourcePathInUpdateFolder:updateFolder forHost:host isPackage:&isPackage];
|
||||
return isPackage ? nil : path;
|
||||
}
|
||||
BOOL isGuided = NO;
|
||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage isGuided:&isGuided];
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
|
||||
|
||||
if (newAppDownloadPath == nil)
|
||||
{
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] delegate:delegate];
|
||||
}
|
||||
else
|
||||
{
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class])performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate versionComparator:comparator];
|
||||
if (newAppDownloadPath == nil) {
|
||||
[self finishInstallationToPath:installationPath withResult:NO error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler];
|
||||
} else {
|
||||
if (isPackage && isGuided) {
|
||||
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
} else if (isPackage) {
|
||||
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
} else {
|
||||
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
||||
+ (void)finishInstallationToPath:(NSString *)__unused installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
||||
|
||||
SULog( @"mdimporting" );
|
||||
|
||||
NSTask *mdimport = [[[NSTask alloc] init] autorelease];
|
||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
||||
[mdimport setArguments:@[installationPath]];
|
||||
@try
|
||||
{
|
||||
[mdimport launch];
|
||||
[mdimport waitUntilExit];
|
||||
}
|
||||
@catch (NSException * launchException)
|
||||
{
|
||||
// No big deal.
|
||||
SULog(@"Sparkle Error: %@", [launchException description]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define SUNotifyDictHostKey @"SUNotifyDictHost"
|
||||
#define SUNotifyDictErrorKey @"SUNotifyDictError"
|
||||
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
|
||||
|
||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id<SUInstallerDelegate>)delegate
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
[self mdimportInstallationPath:installationPath];
|
||||
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[delegate installerFinishedForHost:host];
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[delegate installerForHost:host failedWithError:error];
|
||||
});
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completionHandler(nil);
|
||||
});
|
||||
} else {
|
||||
if (!error) {
|
||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:nil];
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completionHandler(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -12,7 +12,8 @@
|
||||
Your tech support will hug you if you tell them about this.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef SULOG_H
|
||||
#define SULOG_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Headers:
|
||||
@@ -25,7 +26,7 @@
|
||||
// Prototypes:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void );
|
||||
void SULog( NSString* format, ... ) NS_FORMAT_FUNCTION(1,2);
|
||||
|
||||
void SUClearLog(void);
|
||||
void SULog(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@
|
||||
// Constants:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log"
|
||||
static NSString *const SULogFilePath = @"~/Library/Logs/SparkleUpdateLog.log";
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -30,19 +30,15 @@
|
||||
//
|
||||
// TAKES:
|
||||
// sender - Object that sent this message, typically of type X.
|
||||
//
|
||||
// GIVES:
|
||||
// param - who owns the returned value?
|
||||
// result - same here.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SUClearLog( void )
|
||||
void SUClearLog(void)
|
||||
{
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"w");
|
||||
if( logfile )
|
||||
fclose(logfile);
|
||||
else
|
||||
NSLog(@"----- Sparkle Log -----");
|
||||
FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "w");
|
||||
if (logfile) {
|
||||
fclose(logfile);
|
||||
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,25 +52,27 @@ void SUClearLog( void )
|
||||
// ... - More parameters depending on format string's contents.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void SULog( NSString* format, ... )
|
||||
void SULog(NSString *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString* theStr = [[[NSString alloc] initWithFormat: format arguments: ap] autorelease];
|
||||
FILE* logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation],"a");
|
||||
if( !logfile )
|
||||
NSLog( @"%@",theStr );
|
||||
else
|
||||
{
|
||||
theStr = [NSString stringWithFormat: @"%@: %@", [NSDate date], theStr];
|
||||
NSData* theData = [theStr dataUsingEncoding: NSUTF8StringEncoding];
|
||||
char newlineChar = '\n';
|
||||
fwrite( [theData bytes], 1, [theData length], logfile );
|
||||
fwrite( &newlineChar, 1, 1, logfile ); // Append a newline.
|
||||
fclose( logfile );
|
||||
logfile = NULL;
|
||||
}
|
||||
va_end(ap);
|
||||
static BOOL loggedYet = NO;
|
||||
if (!loggedYet) {
|
||||
loggedYet = YES;
|
||||
SUClearLog();
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString *theStr = [[NSString alloc] initWithFormat:format arguments:ap];
|
||||
NSLog(@"Sparkle: %@", theStr);
|
||||
|
||||
FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "a");
|
||||
if (logfile) {
|
||||
theStr = [NSString stringWithFormat:@"%@: %@\n", [NSDate date], theStr];
|
||||
NSData *theData = [theStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
fwrite([theData bytes], 1, [theData length], logfile);
|
||||
fclose(logfile);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// SUOperatingSystem.h
|
||||
// Sparkle
|
||||
//
|
||||
// Copyright © 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SUOperatingSystem : NSObject
|
||||
|
||||
+ (NSOperatingSystemVersion)operatingSystemVersion;
|
||||
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version;
|
||||
+ (NSString *)systemVersionString;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// SUOperatingSystem.m
|
||||
// Sparkle
|
||||
//
|
||||
// Copyright © 2015 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUOperatingSystem.h"
|
||||
|
||||
@implementation SUOperatingSystem
|
||||
|
||||
+ (NSOperatingSystemVersion)operatingSystemVersion
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wselector"
|
||||
// Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug?
|
||||
if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
#pragma clang diagnostic pop
|
||||
{
|
||||
NSOperatingSystemVersion version = { 0, 0, 0 };
|
||||
NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil];
|
||||
NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"];
|
||||
assert(url != nil);
|
||||
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];
|
||||
NSArray *components = [ [dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."];
|
||||
version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0;
|
||||
version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0;
|
||||
version.patchVersion = components.count > 2 ? [ [components objectAtIndex:2] integerValue] : 0;
|
||||
return version;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
return [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version
|
||||
{
|
||||
const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion;
|
||||
if (systemVersion.majorVersion == version.majorVersion) {
|
||||
if (systemVersion.minorVersion == version.minorVersion) {
|
||||
return systemVersion.patchVersion >= version.patchVersion;
|
||||
}
|
||||
return systemVersion.minorVersion >= version.minorVersion;
|
||||
}
|
||||
return systemVersion.majorVersion >= version.majorVersion;
|
||||
}
|
||||
|
||||
+ (NSString *)systemVersionString
|
||||
{
|
||||
NSOperatingSystemVersion version = self.operatingSystemVersion;
|
||||
return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef SUPACKAGEINSTALLER_H
|
||||
#define SUPACKAGEINSTALLER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SUUpdater.h"
|
||||
|
||||
#import "SUAppcast.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@implementation SUPackageInstaller
|
||||
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)__unused comparator
|
||||
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host fileOperationToolPath:(NSString *)__unused fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
||||
{
|
||||
// Run installer using the "open" command to ensure it is launched in front of current application.
|
||||
// -W = wait until the app has quit.
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:command]) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find Apple's installer tool!" }];
|
||||
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
|
||||
[self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self finishInstallationToPath:installationPath withResult:YES host:host error:nil delegate:delegate];
|
||||
[self finishInstallationToPath:installationPath withResult:YES error:nil completionHandler:completionHandler];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||