Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0569c73391 | ||
|
|
36139c57bc | ||
|
|
b6b5c6d927 | ||
|
|
c7bf998913 | ||
|
|
1dd9d93090 | ||
|
|
ac8c37096e | ||
|
|
c86e825a5f | ||
|
|
40a777f5d9 | ||
|
|
3098afc90b | ||
|
|
3809da20bf | ||
|
|
c623480f72 | ||
|
|
72ee4aa2c6 | ||
|
|
e160f994b4 | ||
|
|
e7810c970b | ||
|
|
0a94a6ce88 | ||
|
|
e54748ac87 | ||
|
|
3b04c45ee9 | ||
|
|
792e13a067 | ||
|
|
83195a802e | ||
|
|
46d2a6aeab | ||
|
|
40347c0d43 | ||
|
|
e1f67cf8db | ||
|
|
5210e1d3ac | ||
|
|
f43c83688d | ||
|
|
83709f4b30 | ||
|
|
c0d4640508 | ||
|
|
c6fb841868 | ||
|
|
9a07c5125e | ||
|
|
fb6fe6d6da | ||
|
|
9318b9f896 | ||
|
|
d27c12f1fc | ||
|
|
016dad176e | ||
|
|
1f98f9eb36 | ||
|
|
6e51231966 | ||
|
|
dc1d83e904 | ||
|
|
9d966e68f0 | ||
|
|
03abfe2739 | ||
|
|
155816b609 | ||
|
|
313352fe26 | ||
|
|
67b1e08a45 | ||
|
|
21214e8623 | ||
|
|
ed16c5c2a0 | ||
|
|
0a869e87bf | ||
|
|
14c543ccb3 | ||
|
|
0fd0331464 | ||
|
|
0cba214f07 | ||
|
|
2a644672ca | ||
|
|
81e71844d6 | ||
|
|
e4821e0454 | ||
|
|
a97538f931 | ||
|
|
c61767f501 | ||
|
|
c0d45952a9 | ||
|
|
06629310e2 | ||
|
|
7e99561d9c | ||
|
|
5c71eebf59 | ||
|
|
5368dbfb41 | ||
|
|
0e978e3faf | ||
|
|
f9dfa3dd9d | ||
|
|
c104c1b27e | ||
|
|
7e7c97a09f | ||
|
|
a75ad96719 | ||
|
|
22f5d1f0f8 | ||
|
|
b9753cbd81 | ||
|
|
548ae6e2b6 | ||
|
|
db7f4acc83 | ||
|
|
942d70d3aa | ||
|
|
2ccac610f6 | ||
|
|
7a0d402a01 | ||
|
|
d070bca0b0 | ||
|
|
682f8f32c6 | ||
|
|
56db200f06 | ||
|
|
34179edd6d | ||
|
|
530f3a4a63 | ||
|
|
135d05b8b8 | ||
|
|
c56694382e | ||
|
|
a39023e95b | ||
|
|
282f0ae58e | ||
|
|
55e1a24431 | ||
|
|
9fa0519811 | ||
|
|
ecc72f834d | ||
|
|
c1488b0515 | ||
|
|
aa29a754e6 | ||
|
|
65bd11df8a | ||
|
|
397eb8a379 | ||
|
|
27c560b7d5 | ||
|
|
5121d74ad9 | ||
|
|
fbb040926e | ||
|
|
e2426784ac | ||
|
|
118c72e61c | ||
|
|
6f11c1ce02 | ||
|
|
d5f4c312ee | ||
|
|
9b3753f5d7 | ||
|
|
5dda7462c1 | ||
|
|
c059dc8ae8 | ||
|
|
6ca4b05cad | ||
|
|
d95f420360 | ||
|
|
7ae0e71b02 | ||
|
|
548908628f | ||
|
|
d40bdb615a | ||
|
|
b16d881808 | ||
|
|
392cb65716 | ||
|
|
6e01dd272f | ||
|
|
762d527463 | ||
|
|
07599c2ffd | ||
|
|
f795802d60 | ||
|
|
073ce22015 | ||
|
|
7ef468e8ea | ||
|
|
fc9b2b38fa | ||
|
|
717921cfa1 | ||
|
|
e621622c8b | ||
|
|
6902b80ab6 | ||
|
|
d44a122a21 | ||
|
|
0b6b6fe4ca | ||
|
|
f43b9f7f02 | ||
|
|
eafbb2cfad | ||
|
|
5c408f5019 | ||
|
|
9d35c819fd | ||
|
|
b9d113924e | ||
|
|
ee80a66896 | ||
|
|
187ae4fe57 | ||
|
|
ca4d51561e | ||
|
|
915c2047bf | ||
|
|
f172cd32a8 | ||
|
|
8481035fb9 | ||
|
|
7238c2aeb6 | ||
|
|
d9d62299be | ||
|
|
478bbf303b | ||
|
|
ee16e5ae55 | ||
|
|
d50e823b3d | ||
|
|
4636588e76 | ||
|
|
2be4dc11a0 | ||
|
|
6181c9276a | ||
|
|
49845d8246 | ||
|
|
8fa136c0a3 | ||
|
|
dc1151a5ff | ||
|
|
a920ecc197 | ||
|
|
271d504f6d | ||
|
|
9c0ccd4a57 | ||
|
|
266be254d2 | ||
|
|
efe93c492f | ||
|
|
74b09ad904 | ||
|
|
b9012aa8dc | ||
|
|
ae41185267 | ||
|
|
6634ed7d69 | ||
|
|
799ebdcf7d | ||
|
|
d911db7357 | ||
|
|
d2e1987ce3 | ||
|
|
2d1688c063 | ||
|
|
b56910f455 | ||
|
|
a3e96581b4 | ||
|
|
94423a10c9 | ||
|
|
b14c00136e | ||
|
|
ebf8d2105b | ||
|
|
14ac885ea0 | ||
|
|
355e239df9 | ||
|
|
e7ae7d5330 | ||
|
|
daaadf1c44 | ||
|
|
87064c9304 | ||
|
|
0af392f808 | ||
|
|
fb8ad9f75d | ||
|
|
b4210a85b9 | ||
|
|
091986b12f | ||
|
|
1ecb620986 | ||
|
|
21f3c8a157 | ||
|
|
468bcb9640 | ||
|
|
d38b29c858 | ||
|
|
e2b9fc7ffd | ||
|
|
f016cd8086 | ||
|
|
796967cf24 | ||
|
|
578e78876c | ||
|
|
2f438186d6 | ||
|
|
2c1820f2a9 | ||
|
|
a30eff3680 | ||
|
|
1a09baf0ed | ||
|
|
a1095ff29c | ||
|
|
51b3931485 | ||
|
|
1e3f5482d0 | ||
|
|
0a45be54c4 | ||
|
|
b5bc2a7374 | ||
|
|
3666b89add | ||
|
|
23f9e747c1 | ||
|
|
c77895066a | ||
|
|
c98017dbe2 | ||
|
|
657e3d47d0 | ||
|
|
4d34e4358a | ||
|
|
6fcd6beb84 | ||
|
|
98b3a9828a | ||
|
|
137b73af4e | ||
|
|
dd1bda5066 | ||
|
|
7bc7a90a09 | ||
|
|
91d13c7239 | ||
|
|
fd6ba1820a | ||
|
|
fb61777024 | ||
|
|
2519eb573f | ||
|
|
8a3338b078 | ||
|
|
b03ae0d765 | ||
|
|
97c652e3b0 | ||
|
|
301af71228 | ||
|
|
60d4f05743 | ||
|
|
464972126c | ||
|
|
c1392bc190 | ||
|
|
921aed0fae | ||
|
|
59d90e0bb1 | ||
|
|
e3fb6bb1a8 | ||
|
|
8103f5fd43 | ||
|
|
70f5681797 | ||
|
|
5ee02e954e | ||
|
|
23b2b49663 | ||
|
|
311ed493b4 | ||
|
|
9d8b3c0c36 | ||
|
|
f3f268388b | ||
|
|
8d0effe327 | ||
|
|
19455099ff | ||
|
|
6e754d7e4f | ||
|
|
ab6fa76303 | ||
|
|
93fc4b0151 | ||
|
|
021950a5b2 | ||
|
|
2ff0da4f15 | ||
|
|
945968a0ef | ||
|
|
1e4f126f7e | ||
|
|
f47115d81f | ||
|
|
49781561f3 | ||
|
|
1587dd1dc3 | ||
|
|
c0b9eaaa0e | ||
|
|
91ac90ffcf | ||
|
|
8375922755 | ||
|
|
9dec304f64 | ||
|
|
8acd915b7b | ||
|
|
eb36100388 | ||
|
|
fb22a01a08 | ||
|
|
9a32766aeb | ||
|
|
fc468771c1 | ||
|
|
42dbf94738 | ||
|
|
86a0ca3883 | ||
|
|
ddb53f330d | ||
|
|
9dbaae64f1 | ||
|
|
d2f4687333 | ||
|
|
143045d673 | ||
|
|
d67351cb62 | ||
|
|
07d2897250 | ||
|
|
625c942561 | ||
|
|
bb299d075b | ||
|
|
73229f84f7 | ||
|
|
8152516b7f | ||
|
|
96baf2b2ce | ||
|
|
ed5dca3423 | ||
|
|
3a5c620b60 | ||
|
|
23ae527b96 | ||
|
|
2268f96759 | ||
|
|
898e063b4f | ||
|
|
e8f88bf0f1 | ||
|
|
a3407a2dbf | ||
|
|
88933a1e65 | ||
|
|
c3d8e4bbc5 | ||
|
|
f70c2a15b1 | ||
|
|
4eb518de7e | ||
|
|
5b2ce958bd | ||
|
|
077c64419f | ||
|
|
1195d4b5d2 | ||
|
|
c7a7704f3b | ||
|
|
64af6d04c2 | ||
|
|
0af27ea783 | ||
|
|
c36413ce46 | ||
|
|
13b9081873 | ||
|
|
3dccca8044 | ||
|
|
e28c62244a | ||
|
|
fec76fee12 | ||
|
|
ed3eab64d2 | ||
|
|
ee257c4070 | ||
|
|
bfec7a82c0 | ||
|
|
4cd472abe6 | ||
|
|
39268a13e5 | ||
|
|
4864dfb5aa | ||
|
|
71125e3d16 | ||
|
|
779d16e5a7 | ||
|
|
ee2e7fb46b | ||
|
|
d350cf33e0 | ||
|
|
20be93e96b | ||
|
|
668e258cff | ||
|
|
20f90f1544 | ||
|
|
6dbb0d9988 | ||
|
|
f700c96e47 | ||
|
|
626d2c96f5 | ||
|
|
5db4e1505b | ||
|
|
115686cd07 | ||
|
|
e2fc8b4258 | ||
|
|
99f34299f1 | ||
|
|
fdf79bc3a6 | ||
|
|
eb810c7d8f | ||
|
|
38af7cd8cd | ||
|
|
09889d01b1 | ||
|
|
5f2ebb8edf | ||
|
|
ac4ef7d9a0 | ||
|
|
cc7c0ae052 | ||
|
|
b8dc5b3f3d | ||
|
|
43e96f7ee8 | ||
|
|
dbff23ea9d | ||
|
|
ed97e6cb75 | ||
|
|
492664c611 | ||
|
|
fdf07644d0 | ||
|
|
092feba9f9 | ||
|
|
91c813b6ab | ||
|
|
1ced9c428a | ||
|
|
16de00d81d | ||
|
|
3f637c9674 | ||
|
|
4a4dc3629f | ||
|
|
6437e0448a | ||
|
|
c77cd49036 | ||
|
|
9d7e4d676d | ||
|
|
1aa0ee8152 | ||
|
|
9944f2496c | ||
|
|
33907ec4ed | ||
|
|
7892e41b27 | ||
|
|
53983d9452 | ||
|
|
f3a151d473 | ||
|
|
bb624ffa59 | ||
|
|
2963f788e1 | ||
|
|
9017962ab9 | ||
|
|
dd0805c05b | ||
|
|
e4c3c29a85 | ||
|
|
be1e86174a | ||
|
|
8b56fba39b | ||
|
|
db232a263b | ||
|
|
4d952e9961 | ||
|
|
64fd27d918 | ||
|
|
666e86b0bb | ||
|
|
601b4a7a7f | ||
|
|
1316707136 | ||
|
|
e485baf8b8 | ||
|
|
d71fe4a17d | ||
|
|
f990f5fcfc | ||
|
|
07ac154e2e | ||
|
|
48eb25fbf3 | ||
|
|
914bf9e333 | ||
|
|
271b7a1daf | ||
|
|
c11c660f22 | ||
|
|
0e2fe68399 | ||
|
|
852965d824 | ||
|
|
e2c60be805 | ||
|
|
71e15f4b1d | ||
|
|
8a4e4aea2c | ||
|
|
8fea6670c2 | ||
|
|
19fcca11f0 | ||
|
|
fd082a93d4 | ||
|
|
b9e8830f60 | ||
|
|
8576eb7cad | ||
|
|
cf4c02f1b0 | ||
|
|
8e57ca9284 | ||
|
|
3c2f24c340 | ||
|
|
7a9ff3de48 | ||
|
|
a3d4d9fac4 | ||
|
|
a937fa0a17 | ||
|
|
99be33d83b | ||
|
|
0132377a2a | ||
|
|
7fdedad68e | ||
|
|
aa7c46ba4f | ||
|
|
d263bf4fd0 | ||
|
|
bdb3dd8c36 | ||
|
|
c8ff1c0453 | ||
|
|
bb40663d37 | ||
|
|
b8588543cf | ||
|
|
cc332de4d1 | ||
|
|
d6b1c7de54 | ||
|
|
3a3f46f2c1 | ||
|
|
1ae0999082 | ||
|
|
c265e3f7bf | ||
|
|
2faf8ccdd2 | ||
|
|
2f724659a7 | ||
|
|
8cca51d08b | ||
|
|
c9fa1142c9 | ||
|
|
445cc55794 | ||
|
|
013e60204d | ||
|
|
b8fecf1f36 | ||
|
|
b319fb50f9 | ||
|
|
698e737b56 | ||
|
|
0be862708f | ||
|
|
1c8d54166b | ||
|
|
77511c8f19 | ||
|
|
d9a3afb869 | ||
|
|
34a78d59fc | ||
|
|
b95008e248 | ||
|
|
317423ae78 | ||
|
|
27cb8e66fe | ||
|
|
28e8a1fdaf | ||
|
|
f43c284f14 | ||
|
|
cd3d7d9f98 | ||
|
|
864044e44e | ||
|
|
48f18d000c | ||
|
|
d0adc0af39 | ||
|
|
64d95bb36f | ||
|
|
a52cbc38a1 | ||
|
|
530a90cb73 | ||
|
|
168c769eb0 | ||
|
|
5b3577c14c | ||
|
|
b9c664687d | ||
|
|
2a3e88bf96 | ||
|
|
004ac3f9ae | ||
|
|
8a04cc726f | ||
|
|
9f2604b888 | ||
|
|
0171ab2d84 | ||
|
|
c3ffd7f739 | ||
|
|
91e929cbf9 | ||
|
|
9671f7f52d | ||
|
|
2668d18266 | ||
|
|
a4bdbb7ab3 | ||
|
|
a11b1209a9 | ||
|
|
625f229a65 | ||
|
|
0d52e27968 | ||
|
|
674b2238b8 | ||
|
|
4eb2e9af00 | ||
|
|
b64cee8055 | ||
|
|
3163b6a729 | ||
|
|
7b61cdd8f8 | ||
|
|
b29bbdd14b | ||
|
|
5b79151690 | ||
|
|
c315a66151 | ||
|
|
b1d7c3ade9 | ||
|
|
682de21978 | ||
|
|
b5b1e3d51d | ||
|
|
efd94e2de0 | ||
|
|
b3dbb5db1f | ||
|
|
b795f56842 | ||
|
|
c0bda0c372 | ||
|
|
2a693e62bf | ||
|
|
eb3d962526 | ||
|
|
f90700e830 | ||
|
|
2b7f61f2a2 | ||
|
|
ffa449742d | ||
|
|
b40a4eefde | ||
|
|
4e60a61036 | ||
|
|
b3835717ab | ||
|
|
e05b397a00 | ||
|
|
7c48061b85 | ||
|
|
03ca628eef | ||
|
|
7aad8d3586 | ||
|
|
1e89891577 | ||
|
|
dd77e6bc5d | ||
|
|
0fe520f95b | ||
|
|
a6e9c8aff6 | ||
|
|
70f6929ac7 | ||
|
|
a360e60f76 | ||
|
|
2c6941e975 | ||
|
|
2afc553e03 | ||
|
|
5ed9c2615c | ||
|
|
ca22a43e46 | ||
|
|
d157a6fb2a | ||
|
|
503faf49e1 | ||
|
|
45f597cd2a | ||
|
|
26fd1b168a | ||
|
|
a9a0fe54b8 | ||
|
|
1c976de2b7 | ||
|
|
00ea872b76 | ||
|
|
836c0848cc | ||
|
|
95372134c8 | ||
|
|
27ce4ee92c | ||
|
|
6889b9b080 | ||
|
|
c81d190908 | ||
|
|
06826d426d | ||
|
|
62afa6b9a9 | ||
|
|
14839e4ab5 | ||
|
|
58003a8501 | ||
|
|
698fa40647 | ||
|
|
5fe3ee1300 | ||
|
|
b83f4c30f2 | ||
|
|
75551e8d0a | ||
|
|
e3d89ec3db | ||
|
|
27f00c04b0 | ||
|
|
30a72a1bd6 | ||
|
|
bbe3d4a811 | ||
|
|
e83540a1e9 | ||
|
|
254ae41759 | ||
|
|
aa11a9e934 | ||
|
|
0abe9ad994 | ||
|
|
452ff64740 | ||
|
|
4b2c4a5823 | ||
|
|
db3c9cb9c5 | ||
|
|
68e7fb5caa | ||
|
|
8420abe5b9 | ||
|
|
5e90d987de | ||
|
|
a0716aac49 | ||
|
|
1659180864 | ||
|
|
d308707f09 | ||
|
|
916554046d | ||
|
|
47c1761137 | ||
|
|
4022b01041 | ||
|
|
558f3bb10e | ||
|
|
ccc2c7cb5d | ||
|
|
3ed092e764 | ||
|
|
3bdf4aab9b | ||
|
|
373a3b4227 | ||
|
|
c78a314385 | ||
|
|
533a0ecf17 | ||
|
|
155782708b | ||
|
|
b6c023fdea | ||
|
|
6351ee86b9 | ||
|
|
a4bd5443f3 | ||
|
|
3120b47404 | ||
|
|
2ae4e42561 | ||
|
|
5112748e1b | ||
|
|
1388639079 | ||
|
|
0bc66ab011 | ||
|
|
c98ef7c614 | ||
|
|
896a01cd40 | ||
|
|
4f88994cf0 | ||
|
|
93a5228f5b | ||
|
|
124d9a901f | ||
|
|
97c1a222ab | ||
|
|
35802dbb4d | ||
|
|
c848882778 | ||
|
|
374b8d6195 | ||
|
|
27c1b0f045 | ||
|
|
154aa1b0db | ||
|
|
658e5fcb9f | ||
|
|
292ba01dbf | ||
|
|
ff7966d96a | ||
|
|
9cf7437392 | ||
|
|
9f1884f100 | ||
|
|
8a208ce520 | ||
|
|
c850146ef6 | ||
|
|
ccf4f81ea0 | ||
|
|
3c957096c6 | ||
|
|
bc5ad0d919 | ||
|
|
9d06f5bc4d | ||
|
|
6818d1f180 | ||
|
|
ee72ec3dab | ||
|
|
9b74309eb5 | ||
|
|
948eccb169 | ||
|
|
ff342f1e5b | ||
|
|
a7af6fb82d | ||
|
|
d7e3b01bd6 | ||
|
|
117716da9e | ||
|
|
17da7b5fb8 | ||
|
|
545b8f2416 | ||
|
|
d1a62bba89 | ||
|
|
7ccf706a1d | ||
|
|
ef61691b34 | ||
|
|
a92c23bb26 | ||
|
|
21e4cc42cc | ||
|
|
abc307dc35 | ||
|
|
49e262e718 | ||
|
|
25be040bfc | ||
|
|
46c677ea57 | ||
|
|
165b772f8f | ||
|
|
bac2463ff2 | ||
|
|
c61b5d99a2 | ||
|
|
e54498dd35 | ||
|
|
9ca70a5157 | ||
|
|
f9b9184a39 | ||
|
|
b943af3b59 | ||
|
|
5afdc4f20e | ||
|
|
f85ac88595 | ||
|
|
e9e04e2cb4 | ||
|
|
114252dd09 | ||
|
|
2f41dec805 | ||
|
|
2ad01ad672 | ||
|
|
079666643d | ||
|
|
da370c0f2b | ||
|
|
b98026040f | ||
|
|
6d833143fe | ||
|
|
83578c1f38 | ||
|
|
2bc0b2a2b3 | ||
|
|
6af2fbfb6e | ||
|
|
999b265908 | ||
|
|
6599ba3a2d | ||
|
|
888f35c756 | ||
|
|
cc354cf8cf | ||
|
|
2b6ae33911 | ||
|
|
93a87a4dfd | ||
|
|
a7ff41b3ce | ||
|
|
6079739534 | ||
|
|
9822b4d2a1 | ||
|
|
03655cf8b2 | ||
|
|
32591954bc | ||
|
|
e17d4fc99f | ||
|
|
b746fc56bf | ||
|
|
831947ff55 | ||
|
|
e1002f0662 | ||
|
|
222fe94a05 | ||
|
|
aae9e12b8a | ||
|
|
dc0aca1d16 | ||
|
|
452aee0b83 | ||
|
|
73977c9aa5 | ||
|
|
f9731c92c1 | ||
|
|
88f308e2ae | ||
|
|
aa4cc6a7dc | ||
|
|
eead36eb47 | ||
|
|
39f17764e3 | ||
|
|
a9743f01fa | ||
|
|
e60baaeec8 | ||
|
|
9a32f6f21d | ||
|
|
175e84e618 | ||
|
|
2ff488c8c9 | ||
|
|
34652305ab | ||
|
|
bd3be288f2 | ||
|
|
00bcf21bc8 | ||
|
|
2c5d5fb40d | ||
|
|
394225a01a | ||
|
|
ff22549aa9 | ||
|
|
7c16bf8572 | ||
|
|
92c41cbb34 | ||
|
|
54747c24d1 | ||
|
|
d1a5aae242 | ||
|
|
d255967a73 | ||
|
|
637eaae9c7 | ||
|
|
926bdc8655 | ||
|
|
2ba0fa254f | ||
|
|
16c3534d40 | ||
|
|
3c436ce844 | ||
|
|
0b4488339d | ||
|
|
c0b73fe618 | ||
|
|
309aa157ab | ||
|
|
b79d717933 | ||
|
|
c78070c748 | ||
|
|
1159746505 | ||
|
|
b895d5af85 | ||
|
|
43f246d33f | ||
|
|
400014765a | ||
|
|
47c2bf31d4 | ||
|
|
f2cf1d8714 | ||
|
|
3d3372b485 | ||
|
|
964427eae5 | ||
|
|
3c583db3da | ||
|
|
f63e606600 | ||
|
|
2782b426d9 | ||
|
|
182652a231 | ||
|
|
ba73e52f09 | ||
|
|
5b469d702e | ||
|
|
758ed1dc38 | ||
|
|
0a840f11da | ||
|
|
9f674f6547 | ||
|
|
2e226f65ac | ||
|
|
06876e723f | ||
|
|
5d53d7277c | ||
|
|
d3aed95e39 | ||
|
|
4559b2bbf3 | ||
|
|
e6b39b6055 | ||
|
|
ea959cbd87 | ||
|
|
931424fa1b | ||
|
|
fd7628e658 | ||
|
|
8496bd030a | ||
|
|
8830ef5447 | ||
|
|
246130abec | ||
|
|
ec587ac7dc | ||
|
|
2205a8ab6b | ||
|
|
0cabab22be | ||
|
|
232fc61b90 | ||
|
|
1b0ca7b8ab | ||
|
|
531c012292 | ||
|
|
4187ec8655 | ||
|
|
333cbd9384 | ||
|
|
d302814f62 | ||
|
|
a746219a3f | ||
|
|
3e1c6da584 | ||
|
|
8a026f2f6e | ||
|
|
3c02940c7e | ||
|
|
abdeade019 | ||
|
|
99ac9eaf7c | ||
|
|
ee56cea7fd | ||
|
|
e1fa4804f9 | ||
|
|
b016cfb4b7 | ||
|
|
e447041337 | ||
|
|
147906f067 | ||
|
|
87702985dc | ||
|
|
f3e44d39ee | ||
|
|
59b94a2c7d | ||
|
|
c1f10ac7f0 | ||
|
|
0167c50b1d | ||
|
|
73c337b14e | ||
|
|
f625c4435c | ||
|
|
0418566e4c | ||
|
|
831e8fda9f | ||
|
|
f739101b4f | ||
|
|
d75856cfee | ||
|
|
973ef01be8 | ||
|
|
59d372222e | ||
|
|
70dcb05319 | ||
|
|
ce4dfe2507 | ||
|
|
01caea1611 | ||
|
|
7554daca65 | ||
|
|
7347631d34 | ||
|
|
d7b4d7c761 | ||
|
|
43442f8b9b | ||
|
|
93957e5183 | ||
|
|
e08422234b | ||
|
|
62f7b7aa0c | ||
|
|
b7073dc3ce | ||
|
|
d26f94fab1 | ||
|
|
ca86ce0a1c | ||
|
|
90b3e00e8d | ||
|
|
04d1f22d16 | ||
|
|
4d4bee73e3 | ||
|
|
b13ae2e972 | ||
|
|
1fdfb80fe4 | ||
|
|
dcd50d54e1 | ||
|
|
b165a419d5 | ||
|
|
dbae37bb5b | ||
|
|
d4b7a696af | ||
|
|
19876c5a56 | ||
|
|
9c8fb99184 | ||
|
|
5f88af7099 | ||
|
|
984c3dc0e1 | ||
|
|
9992fa28ed | ||
|
|
14fe42e7da | ||
|
|
0d9597c9a9 | ||
|
|
b3d8cf11f7 | ||
|
|
c7184c21da |
No files matched your search
@@ -28,6 +28,13 @@ Icon
|
|||||||
.Spotlight-V100
|
.Spotlight-V100
|
||||||
.Trashes
|
.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
|
# Directories potentially created on remote AFP share
|
||||||
.AppleDB
|
.AppleDB
|
||||||
.AppleDesktop
|
.AppleDesktop
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
language: objective-c
|
language: objective-c
|
||||||
|
osx_image: xcode8.2
|
||||||
|
before_install:
|
||||||
|
- brew update
|
||||||
script: make ci
|
script: make ci
|
||||||
@@ -1,8 +1,146 @@
|
|||||||
# 1.11.1
|
# 1.17.0
|
||||||
|
|
||||||
|
* Added Touch Bar support (Bi11)
|
||||||
|
* Upgraded SULog to use logging APIs that Apple provides built-in (Zorg)
|
||||||
|
* Skip buttons are disabled if the update is marked as critical (Kornel Lesiński)
|
||||||
|
* Background updates ask OS for lower-priority networking (Kornel Lesiński)
|
||||||
|
* Refactorings to sync with upcoming 2.0
|
||||||
|
* Added kqueue based termination listener (Zorg)
|
||||||
|
* Added AppKit prevention guards to modules that shouldn't import it (Zorg)
|
||||||
|
* Added Obj-C generics where applicable (Zorg)
|
||||||
|
* Made SUBundleIcon & SUApplicationInfo take SUHost, not NSBundle (Zorg)
|
||||||
|
* Improved -[SUHost objectForInfoDictionaryKey:] (Zorg)
|
||||||
|
* Detect and fail if any two-way dependencies exist in the project (Zorg)
|
||||||
|
* generate_appcast:
|
||||||
|
* fixed handling of multiple directories in an archive
|
||||||
|
* percent encode the filename used in the delta url (Brett Walker)
|
||||||
|
* Update Sparkle.strings (BR Lingo)
|
||||||
|
* Improved handling of non-ASCII names in delta archives (Kornel Lesiński)
|
||||||
|
* Don't touch Info.plist unless git version changes (Václav Slavík)
|
||||||
|
|
||||||
|
# 1.16.0
|
||||||
|
|
||||||
|
* Guided package installs are now the default for updating packages (Zorg)
|
||||||
|
- `pkg` installers won't show any UI. If you require the old behavior of showing a full installer window, rename the `*.pkg` file to `*.sparkle_interactive.pkg`
|
||||||
|
* Previous version of the app is now deleted instead of staying in the trash (Zorg)
|
||||||
|
* Added `generate_appcast` helper tool (Kornel Lesiński)
|
||||||
|
* Made manual check resume pending automatic updates instead of starting a new update (Kornel Lesiński)
|
||||||
|
* Started using `length` value from RSS if HTTP doesn't give one (Zorg)
|
||||||
|
* Hidden automatic updates checkbox for information only updates (Bi11)
|
||||||
|
* Added progressbar for DMG and binary delta extraction (Kornel Lesiński)
|
||||||
|
* Fixed showing of download status if we attempt a 2nd download (Zorg)
|
||||||
|
* Refactorings to sync with upcoming 2.0
|
||||||
|
* Decoupled and simplified installation code using protocols (Zorg)
|
||||||
|
* Added nullability annotations (Zorg)
|
||||||
|
* Allowed delegate methods that return an object to return nil (Zorg)
|
||||||
|
* Decreased responsibility of SUHost and moved code into other components (Zorg)
|
||||||
|
* Removed Sparkle.pch and many file #includes (Zorg)
|
||||||
|
|
||||||
|
# 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
|
* Don't install automatic updates when system is about to shut down
|
||||||
|
|
||||||
# 1.11.0
|
# 1.11.0 (Aug 24, 2015)
|
||||||
|
|
||||||
* Big improvements to code signing and DSA verification
|
* 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.
|
- 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.
|
||||||
@@ -20,7 +158,7 @@
|
|||||||
* Added logging of appcast/download URL on error (Kornel Lesiński)
|
* Added logging of appcast/download URL on error (Kornel Lesiński)
|
||||||
* More robust reading of Autoupdate.app path from Sparkle bundle
|
* More robust reading of Autoupdate.app path from Sparkle bundle
|
||||||
|
|
||||||
# 1.10.0
|
# 1.10.0 (Apr 26, 2015)
|
||||||
|
|
||||||
* Massive improvements to the BinaryDelta tool (Zorg)
|
* Massive improvements to the BinaryDelta tool (Zorg)
|
||||||
- Ability to track file permissions (Zorg)
|
- Ability to track file permissions (Zorg)
|
||||||
@@ -36,7 +174,7 @@
|
|||||||
* Stdout used for non error outputs (JDuquennoy)
|
* Stdout used for non error outputs (JDuquennoy)
|
||||||
* French locale update (Kent Sutherland)
|
* French locale update (Kent Sutherland)
|
||||||
|
|
||||||
# 1.9.0
|
# 1.9.0 (Jan 26, 2015)
|
||||||
|
|
||||||
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
|
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
|
||||||
* Make the error definitions public (C.W. Betts)
|
* Make the error definitions public (C.W. Betts)
|
||||||
@@ -46,7 +184,7 @@
|
|||||||
* Use Library/Caches rather than app support directory (Kornel Lesiński)
|
* 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)
|
* 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 crashes on 10.7 (Chris Campbell, Ger Teunis)
|
||||||
* Fixed Sparkle tags parsing (Tamás Lustyik)
|
* Fixed Sparkle tags parsing (Tamás Lustyik)
|
||||||
* SULog code cleanups (Kevin Wojniak)
|
* SULog code cleanups (Kevin Wojniak)
|
||||||
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
|
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
|
||||||
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
|
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
|
||||||
@@ -59,18 +197,18 @@
|
|||||||
* Turkish localization fixes (Emir)
|
* Turkish localization fixes (Emir)
|
||||||
* Proofing of Ukrainian localization (Vera Tkachenko)
|
* Proofing of Ukrainian localization (Vera Tkachenko)
|
||||||
|
|
||||||
# 1.8.0
|
# 1.8.0 (Jul 26, 2014)
|
||||||
|
|
||||||
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
|
* New SUDSAVerifier based on up-to-date macOS APIs (Zachary Waldowski)
|
||||||
* Detailed error log for failed signature checks (Kornel Lesiński)
|
* Detailed error log for failed signature checks (Kornel Lesiński)
|
||||||
* Converted Sparkle to ARC (C.W. Betts)
|
* Converted Sparkle to ARC (C.W. Betts)
|
||||||
* Converted ivars to properties. (Jake Petroules)
|
* Converted ivars to properties. (Jake Petroules)
|
||||||
* Cocoapod support (Xhacker Liu)
|
* Cocoapod support (Xhacker Liu)
|
||||||
* Quarantine removal on OS X 10.10 (C.W. Betts)
|
* Quarantine removal on macOS 10.10 (C.W. Betts)
|
||||||
* Updated Japanese localization (1024jp)
|
* Updated Japanese localization (1024jp)
|
||||||
* Added Greek localization
|
* Added Greek localization
|
||||||
|
|
||||||
# 1.7.1
|
# 1.7.1 (Jul 2, 2014)
|
||||||
|
|
||||||
* Removed option to install unverified updates (Kornel Lesiński)
|
* Removed option to install unverified updates (Kornel Lesiński)
|
||||||
* Added detailed log when code signing verification fails (Sam Deane)
|
* Added detailed log when code signing verification fails (Sam Deane)
|
||||||
@@ -87,7 +225,7 @@
|
|||||||
|
|
||||||
# 1.7.0
|
# 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)
|
* Removed use of deprecated functions (Zachary Waldowski)
|
||||||
* Switched to modern Obj-C runtime and new literals syntax
|
* Switched to modern Obj-C runtime and new literals syntax
|
||||||
* Removed pre-10.7 code. (C.W. Betts)
|
* Removed pre-10.7 code. (C.W. Betts)
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and
|
||||||
|
orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at kornel+sparkle@geekhood.net. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
// Common
|
// Common
|
||||||
|
|
||||||
SPARKLE_BUNDLE_IDENTIFIER = org.andymatuschak.Sparkle
|
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||||
|
SPARKLE_FILEOP_TOOL_NAME = fileop
|
||||||
|
|
||||||
SPARKLE_APPEND_VERSION_NUMBER = 1
|
SPARKLE_APPEND_VERSION_NUMBER = 1
|
||||||
|
|
||||||
@@ -15,15 +16,13 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
|
|||||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||||
|
|
||||||
SPARKLE_VERSION_MAJOR = 1
|
SPARKLE_VERSION_MAJOR = 1
|
||||||
SPARKLE_VERSION_MINOR = 11
|
SPARKLE_VERSION_MINOR = 17
|
||||||
SPARKLE_VERSION_PATCH = 1
|
SPARKLE_VERSION_PATCH = 0
|
||||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||||
|
|
||||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO
|
ALWAYS_SEARCH_USER_PATHS = NO
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES
|
ENABLE_STRICT_OBJC_MSGSEND = YES
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES
|
|
||||||
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
|
|
||||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||||
ARCHS = $(ARCHS_STANDARD)
|
ARCHS = $(ARCHS_STANDARD)
|
||||||
@@ -31,11 +30,15 @@ MACOSX_DEPLOYMENT_TARGET = 10.7
|
|||||||
PRODUCT_NAME = ${TARGET_NAME}
|
PRODUCT_NAME = ${TARGET_NAME}
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||||
|
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\"
|
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
|
||||||
|
|
||||||
CLANG_ENABLE_OBJC_ARC = YES
|
CLANG_ENABLE_OBJC_ARC = YES
|
||||||
|
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
COMBINE_HIDPI_IMAGES = NO;
|
||||||
|
|
||||||
// Enable warnings
|
// Enable warnings
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
|
||||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
|
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
|
||||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
|
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
|
||||||
@@ -50,7 +53,6 @@ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
|
|||||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
|
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
|
||||||
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
|
||||||
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
|
|
||||||
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
|
||||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES
|
CLANG_WARN_UNREACHABLE_CODE = YES
|
||||||
@@ -78,8 +80,12 @@ GCC_WARN_UNUSED_LABEL = YES
|
|||||||
GCC_WARN_UNUSED_PARAMETER = YES
|
GCC_WARN_UNUSED_PARAMETER = YES
|
||||||
GCC_WARN_UNUSED_VARIABLE = 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
|
// These should be removed once the conversion to ARC is complete
|
||||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||||
|
|
||||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
|
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#include "ConfigCommonDebug.xcconfig"
|
||||||
|
|
||||||
|
GCC_GENERATE_TEST_COVERAGE_FILES = YES
|
||||||
|
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
|
||||||
@@ -6,7 +6,6 @@ GCC_OPTIMIZATION_LEVEL = 0
|
|||||||
DEBUG_INFORMATION_FORMAT = dwarf
|
DEBUG_INFORMATION_FORMAT = dwarf
|
||||||
ENABLE_TESTABILITY = YES
|
ENABLE_TESTABILITY = YES
|
||||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||||
SPARKLE_EXTRA_DEBUG = -DDEBUG
|
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
|
||||||
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
|
|
||||||
ONLY_ACTIVE_ARCH = YES
|
ONLY_ACTIVE_ARCH = YES
|
||||||
COPY_PHASE_STRIP = NO
|
COPY_PHASE_STRIP = NO
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
GCC_OPTIMIZATION_LEVEL = s
|
GCC_OPTIMIZATION_LEVEL = s
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
|
||||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
|
||||||
DEAD_CODE_STRIPPING = YES
|
DEAD_CODE_STRIPPING = YES
|
||||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
GCC_TREAT_WARNINGS_AS_ERRORS = NO
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
GCC_WARN_UNINITIALIZED_AUTOS = YES
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// Fileop tool only
|
||||||
|
|
||||||
|
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
|
||||||
|
SKIP_INSTALL = YES
|
||||||
|
CLANG_ENABLE_MODULES = NO
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// Generate Appcast only
|
||||||
|
|
||||||
|
#include "ConfigSwift.xcconfig"
|
||||||
|
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = generate_appcast/Appcast-Bridging-Header.h
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||||
|
PRODUCT_NAME = generate_appcast
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Generate Appcast Debug
|
||||||
|
|
||||||
|
#include "ConfigGenerateAppcast.xcconfig"
|
||||||
|
#include "ConfigSwiftDebug.xcconfig"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Generate Appcast Release
|
||||||
|
|
||||||
|
#include "ConfigGenerateAppcast.xcconfig"
|
||||||
|
#include "ConfigSwiftRelease.xcconfig"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
SWIFT_VERSION = 3.0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
SWIFT_OPTIMIZATION_LEVEL = -Onone
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
SWIFT_OPTIMIZATION_LEVEL = -Owholemodule
|
||||||
@@ -3,6 +3,5 @@
|
|||||||
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
|
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
|
||||||
WRAPPER_EXTENSION = app
|
WRAPPER_EXTENSION = app
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
|
||||||
CLANG_ENABLE_OBJC_ARC = NO
|
|
||||||
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
|
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
|
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// UI Test only
|
||||||
|
|
||||||
|
#include "ConfigSwift.xcconfig"
|
||||||
|
|
||||||
|
INFOPLIST_FILE = UITests/UITests-Info.plist
|
||||||
|
WRAPPER_EXTENSION = xctest
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||||
|
|
||||||
|
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
||||||
|
|
||||||
|
TEST_TARGET_NAME = Sparkle Test App
|
||||||
|
USES_XCTRUNNER = YES
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#include "ConfigUITest.xcconfig"
|
||||||
|
|
||||||
|
GCC_GENERATE_TEST_COVERAGE_FILES = NO
|
||||||
|
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#include "ConfigUITest.xcconfig"
|
||||||
|
#include "ConfigSwiftDebug.xcconfig"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#include "ConfigUITest.xcconfig"
|
||||||
|
#include "ConfigSwiftRelease.xcconfig"
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// Unit Test only
|
// Unit Test only
|
||||||
|
|
||||||
|
#include "ConfigSwift.xcconfig"
|
||||||
|
|
||||||
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
|
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
|
||||||
WRAPPER_EXTENSION = xctest
|
WRAPPER_EXTENSION = xctest
|
||||||
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
|
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
|
||||||
@@ -7,3 +9,6 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO
|
|||||||
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
|
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
|
||||||
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
|
||||||
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
|
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 "ConfigUnitTest.xcconfig"
|
||||||
|
#include "ConfigSwiftDebug.xcconfig"
|
||||||
@@ -1 +1,2 @@
|
|||||||
#include "ConfigUnitTest.xcconfig"
|
#include "ConfigUnitTest.xcconfig"
|
||||||
|
#include "ConfigSwiftRelease.xcconfig"
|
||||||
@@ -2,6 +2,13 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ "$ACTION" = "" ] ; then
|
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 -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||||
|
|
||||||
@@ -9,6 +16,7 @@ if [ "$ACTION" = "" ] ; then
|
|||||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||||
|
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
|
|
||||||
@@ -16,6 +24,7 @@ if [ "$ACTION" = "" ] ; then
|
|||||||
# because missing dSYMs in a release build SHOULD trigger a build failure
|
# because missing dSYMs in a release build SHOULD trigger a build failure
|
||||||
if [ "$CONFIGURATION" = "Release" ] ; then
|
if [ "$CONFIGURATION" = "Release" ] ; then
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||||
|
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -13,16 +13,28 @@ if [ -z "$SRCROOT" ] || \
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the current Git master hash
|
version="$CURRENT_PROJECT_VERSION"
|
||||||
version=$(cd "$SRCROOT" ; git show-ref --abbrev heads/master | awk '{print $1}')
|
|
||||||
if [ -z "$version" ] ; then
|
# Get version in format 1.x.x-commits-hash
|
||||||
echo "$0: Can't find a Git hash!" 1>&2
|
gitversion=$( cd "$SRCROOT"; git describe --tags --match '[12].*' || true )
|
||||||
|
if [ -z "$gitversion" ] ; then
|
||||||
|
echo "$0: Can't find a Git hash!" 1>&2
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version="$CURRENT_PROJECT_VERSION git-$version"
|
# remove everything before the first "-" to keep the hash part only
|
||||||
|
versionsuffix=${gitversion#*-};
|
||||||
|
if [ "$versionsuffix" != "$gitversion" ]; then
|
||||||
|
version="$version $versionsuffix"
|
||||||
|
fi
|
||||||
|
|
||||||
# and use it to set the CFBundleShortVersionString value
|
# and use it to set the CFBundleShortVersionString value
|
||||||
export PATH="$PATH:/usr/libexec"
|
export PATH="$PATH:/usr/libexec"
|
||||||
PlistBuddy -c "Set :CFBundleShortVersionString '$version'" \
|
|
||||||
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
|
if [ -f "$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH" ] ; then
|
||||||
|
oldversion=$(PlistBuddy -c "Print :CFBundleShortVersionString" "$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH")
|
||||||
|
fi
|
||||||
|
if [ "$version" != "$oldversion" ] ; then
|
||||||
|
PlistBuddy -c "Set :CFBundleShortVersionString '$version'" \
|
||||||
|
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
|
||||||
|
fi
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
PROJECT_NAME = Sparkle
|
PROJECT_NAME = Sparkle
|
||||||
PROJECT_NUMBER = 1.7.1
|
PROJECT_NUMBER = 1.14.0
|
||||||
PROJECT_BRIEF = "A software update framework for OS X"
|
PROJECT_BRIEF = "A software update framework for macOS"
|
||||||
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
|
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
|
||||||
|
|
||||||
RECURSIVE = YES
|
RECURSIVE = YES
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
Copyright (c) 2006-2013 Andy Matuschak.
|
Copyright (c) 2006-2013 Andy Matuschak.
|
||||||
Copyright (c) 2009-2013 Elgato Systems GmbH.
|
Copyright (c) 2009-2013 Elgato Systems GmbH.
|
||||||
Copyright (c) 2011-2014 Kornel Lesiński.
|
Copyright (c) 2011-2014 Kornel Lesiński.
|
||||||
|
Copyright (c) 2015-2017 Mayur Pawashe.
|
||||||
Copyright (c) 2014 C.W. Betts.
|
Copyright (c) 2014 C.W. Betts.
|
||||||
Copyright (c) 2014 Petroules Corporation.
|
Copyright (c) 2014 Petroules Corporation.
|
||||||
Copyright (c) 2014 Big Nerd Ranch.
|
Copyright (c) 2014 Big Nerd Ranch.
|
||||||
|
|||||||
@@ -13,16 +13,31 @@ localizable-strings:
|
|||||||
release:
|
release:
|
||||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||||
|
cat Sparkle.podspec
|
||||||
|
@echo "Don't forget to update CocoaPods! pod trunk push"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
xcodebuild clean build
|
xcodebuild clean build
|
||||||
|
|
||||||
test:
|
test:
|
||||||
xcodebuild -scheme Distribution -configuration Debug test
|
xcodebuild -scheme Distribution -configuration Debug test
|
||||||
|
./objc_dep/objc_dep.py -t .
|
||||||
|
|
||||||
|
uitest:
|
||||||
|
xcodebuild -scheme UITests -configuration Debug test
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
for i in {7..11} ; do \
|
for i in {7..9} ; do \
|
||||||
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
|
||||||
xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test ; \
|
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \
|
||||||
fi ; \
|
fi ; \
|
||||||
done
|
done
|
||||||
|
for i in {10..12} ; 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,41 +1,45 @@
|
|||||||
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) <a href='https://app.ship.io/dashboard#/jobs/8814/history' target='_blank'><img src='https://app.ship.io/jobs/V3PoCLcN5ft5Pnq0/build_status.png' height='20' /></a>
|
# Sparkle [](https://travis-ci.org/sparkle-project/Sparkle) [](https://github.com/Carthage/Carthage) []() <a href="https://www.stackpath.com/?utm_source=sparkle-github&utm_medium=badge&utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
|
||||||
|
|
||||||
An easy-to-use software update framework for Cocoa developers.
|
Secure and reliable software update framework for Cocoa developers.
|
||||||
|
|
||||||
<img src="Resources/Screenshot.png" width="715" alt="Sparkle shows familiar update window with release notes">
|
<img src="Resources/Screenshot.png" width="732" alt="Sparkle shows familiar update window with release notes">
|
||||||
|
|
||||||
## Changes since 1.5b
|
|
||||||
|
|
||||||
* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+.
|
|
||||||
* Cleaned up and modernized code, using ARC and Autolayout.
|
|
||||||
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
|
|
||||||
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
|
||||||
* Ability to mark updates as critical.
|
|
||||||
* Progress and status notifications for the host app.
|
|
||||||
* 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
|
## Features
|
||||||
|
|
||||||
* True self-updating—the user can choose to automatically download and install all updates.
|
* Seamless. There's no mention of Sparkle; your icons and app name are used.
|
||||||
* Displays a detailed progress window to the user.
|
* Secure. Updates are verified using DSA signatures and Apple Code Signing.
|
||||||
* Supports authentication for installing in secure locations.
|
* Fast. Supports delta updates which only patch files that have changed.
|
||||||
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
|
* Easy to install. Sparkle requires no code in your app, and only needs static files on a web server.
|
||||||
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
|
|
||||||
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
|
|
||||||
* Displays release notes to the user via WebKit.
|
|
||||||
* Sparkle doesn't bug the user until second launch for better first impressions.
|
|
||||||
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
|
|
||||||
* Deep delegate support to make Sparkle work exactly as you need.
|
|
||||||
* Optionally sends system information to the server when checking for updates.
|
|
||||||
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
|
* Supports 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.
|
* Handles permissions, quarantine and automatically asks for authentication if needed.
|
||||||
|
* Uses RSS-based appcasts for release information. Appcasts are a de-facto standard supported by 3rd party update-tracking programs and websites.
|
||||||
|
* Sparkle stays hidden until second launch for better first impressions.
|
||||||
|
* Truly self-updating — the user can choose to automatically download and install all updates in the background.
|
||||||
|
|
||||||
## Developers
|
## Changes since 1.5b
|
||||||
|
|
||||||
Building Sparkle requires Xcode 5 or above.
|
* Compatibilty with macOS Sierra.
|
||||||
|
* Up-to-date with 10.12 SDK and Xcode 8 (supports macOS 10.7+).
|
||||||
|
* Important security fixes.
|
||||||
|
* Cleaned up and modernized code, using ARC and Autolayout.
|
||||||
|
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
|
||||||
|
* Upgraded and more reliable binary delta and code signing verification.
|
||||||
|
* Ability to mark updates as critical.
|
||||||
|
* Progress and status notifications for the host app.
|
||||||
|
|
||||||
### API
|
## Requirements
|
||||||
|
|
||||||
|
* Runtime: macOS 10.7 or greater
|
||||||
|
* Build: Xcode 7 and 10.8 SDK or greater
|
||||||
|
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
See [getting started guide](https://sparkle-project.org/documentation/). No code is necessary, but a bit of Xcode configuration is required.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### API symbols
|
||||||
|
|
||||||
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
|
||||||
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).
|
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).
|
||||||
@@ -45,3 +49,11 @@ If you are adding a symbol to the public API you must decorate the declaration w
|
|||||||
`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.
|
`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.
|
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"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "256x256",
|
"size" : "256x256",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_256x256@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "512x512",
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_512x512.png",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"idiom" : "mac",
|
|
||||||
"size" : "512x512",
|
"size" : "512x512",
|
||||||
|
"idiom" : "mac",
|
||||||
|
"filename" : "icon_512x512@2x.png",
|
||||||
"scale" : "2x"
|
"scale" : "2x"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 368 KiB |
@@ -16,6 +16,8 @@
|
|||||||
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
<string>iMac (Core 2 Duo, 17 inch, Combo Drive)</string>
|
||||||
<key>iMac6,1</key>
|
<key>iMac6,1</key>
|
||||||
<string>iMac (Core 2 Duo, 24 inch, SuperDrive)</string>
|
<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>
|
<key>iMac8,1</key>
|
||||||
<string>iMac (Core 2 Duo, 20 or 24 inch, Early 2008 )</string>
|
<string>iMac (Core 2 Duo, 20 or 24 inch, Early 2008 )</string>
|
||||||
<key>iMac9,1</key>
|
<key>iMac9,1</key>
|
||||||
@@ -25,7 +27,7 @@
|
|||||||
<key>iMac11,1</key>
|
<key>iMac11,1</key>
|
||||||
<string>iMac (Core i5 or i7, 27 inch Late 2009)</string>
|
<string>iMac (Core i5 or i7, 27 inch Late 2009)</string>
|
||||||
<key>iMac11,2</key>
|
<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>
|
<key>iMac11,3</key>
|
||||||
<string>iMac (Core i5 or i7, 27 inch Mid 2010)</string>
|
<string>iMac (Core i5 or i7, 27 inch Mid 2010)</string>
|
||||||
<key>iMac12,1</key>
|
<key>iMac12,1</key>
|
||||||
@@ -42,6 +44,16 @@
|
|||||||
<string>iMac (Core i5 or i7, 27 inch Late 2013)</string>
|
<string>iMac (Core i5 or i7, 27 inch Late 2013)</string>
|
||||||
<key>iMac14,3</key>
|
<key>iMac14,3</key>
|
||||||
<string>iMac (Core i5 or i7, 21.5 inch Late 2013)</string>
|
<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>
|
<key>MacBook1,1</key>
|
||||||
<string>MacBook (Core Duo)</string>
|
<string>MacBook (Core Duo)</string>
|
||||||
<key>MacBook2,1</key>
|
<key>MacBook2,1</key>
|
||||||
@@ -56,6 +68,8 @@
|
|||||||
<string>MacBook (Core 2 Duo, Late 2009, Unibody)</string>
|
<string>MacBook (Core 2 Duo, Late 2009, Unibody)</string>
|
||||||
<key>MacBook7,1</key>
|
<key>MacBook7,1</key>
|
||||||
<string>MacBook (Core 2 Duo, Mid 2010, White)</string>
|
<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>
|
<key>MacBookAir1,1</key>
|
||||||
<string>MacBook Air (Core 2 Duo, 13 inch, Early 2008)</string>
|
<string>MacBook Air (Core 2 Duo, 13 inch, Early 2008)</string>
|
||||||
<key>MacBookAir2,1</key>
|
<key>MacBookAir2,1</key>
|
||||||
@@ -76,6 +90,10 @@
|
|||||||
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014)</string>
|
<string>MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014)</string>
|
||||||
<key>MacBookAir6,2</key>
|
<key>MacBookAir6,2</key>
|
||||||
<string>MacBook Air (Core i5 or i7, 13 inch, Mid 2013 or Early 2014)</string>
|
<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>
|
<key>MacBookPro1,1</key>
|
||||||
<string>MacBook Pro Core Duo (15-inch)</string>
|
<string>MacBook Pro Core Duo (15-inch)</string>
|
||||||
<key>MacBookPro1,2</key>
|
<key>MacBookPro1,2</key>
|
||||||
@@ -90,8 +108,70 @@
|
|||||||
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
<string>MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo)</string>
|
||||||
<key>MacBookPro4,1</key>
|
<key>MacBookPro4,1</key>
|
||||||
<string>MacBook Pro (Core 2 Duo Feb 2008)</string>
|
<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>
|
<key>Macmini1,1</key>
|
||||||
<string>Mac Mini (Core Solo/Duo)</string>
|
<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>
|
<key>MacPro1,1</key>
|
||||||
<string>Mac Pro (four-core)</string>
|
<string>Mac Pro (four-core)</string>
|
||||||
<key>MacPro2,1</key>
|
<key>MacPro2,1</key>
|
||||||
@@ -101,7 +181,9 @@
|
|||||||
<key>MacPro4,1</key>
|
<key>MacPro4,1</key>
|
||||||
<string>Mac Pro (March 2009)</string>
|
<string>Mac Pro (March 2009)</string>
|
||||||
<key>MacPro5,1</key>
|
<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>
|
<key>PowerBook1,1</key>
|
||||||
<string>PowerBook G3</string>
|
<string>PowerBook G3</string>
|
||||||
<key>PowerBook2,1</key>
|
<key>PowerBook2,1</key>
|
||||||
@@ -164,14 +246,6 @@
|
|||||||
<string>Power Macintosh G3 (Blue & White)</string>
|
<string>Power Macintosh G3 (Blue & White)</string>
|
||||||
<key>PowerMac1,2</key>
|
<key>PowerMac1,2</key>
|
||||||
<string>Power Macintosh G4 (PCI Graphics)</string>
|
<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>
|
<key>PowerMac2,1</key>
|
||||||
<string>iMac G3 (Slot-loading CD-ROM)</string>
|
<string>iMac G3 (Slot-loading CD-ROM)</string>
|
||||||
<key>PowerMac2,2</key>
|
<key>PowerMac2,2</key>
|
||||||
@@ -198,6 +272,8 @@
|
|||||||
<string>iMac G4 (17-inch Flat Panel)</string>
|
<string>iMac G4 (17-inch Flat Panel)</string>
|
||||||
<key>PowerMac5,1</key>
|
<key>PowerMac5,1</key>
|
||||||
<string>Power Macintosh G4 Cube</string>
|
<string>Power Macintosh G4 Cube</string>
|
||||||
|
<key>PowerMac5,2</key>
|
||||||
|
<string>Power Mac G4 Cube</string>
|
||||||
<key>PowerMac6,1</key>
|
<key>PowerMac6,1</key>
|
||||||
<string>iMac G4 (USB 2.0)</string>
|
<string>iMac G4 (USB 2.0)</string>
|
||||||
<key>PowerMac6,3</key>
|
<key>PowerMac6,3</key>
|
||||||
@@ -214,6 +290,14 @@
|
|||||||
<string>iMac G5 (Ambient Light Sensor)</string>
|
<string>iMac G5 (Ambient Light Sensor)</string>
|
||||||
<key>PowerMac9,1</key>
|
<key>PowerMac9,1</key>
|
||||||
<string>Power Macintosh G5 (Late 2005)</string>
|
<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>
|
<key>RackMac1,1</key>
|
||||||
<string>Xserve G4</string>
|
<string>Xserve G4</string>
|
||||||
<key>RackMac1,2</key>
|
<key>RackMac1,2</key>
|
||||||
@@ -224,5 +308,7 @@
|
|||||||
<string>Xserve (Intel Xeon)</string>
|
<string>Xserve (Intel Xeon)</string>
|
||||||
<key>Xserve2,1</key>
|
<key>Xserve2,1</key>
|
||||||
<string>Xserve (January 2008 quad-core)</string>
|
<string>Xserve (January 2008 quad-core)</string>
|
||||||
|
<key>Xserve3,1</key>
|
||||||
|
<string>Xserve (early 2009)</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</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/">
|
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
<channel>
|
<channel>
|
||||||
<title>Your Great App's Changelog</title>
|
<title>Your Great App's Changelog</title>
|
||||||
<link>http://you.com/app/appcast.xml</link>
|
|
||||||
<description>Most recent changes with links to updates.</description>
|
<description>Most recent changes with links to updates.</description>
|
||||||
<language>en</language>
|
<language>en</language>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,26 +1,32 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Sparkle"
|
s.name = "Sparkle"
|
||||||
s.version = "1.11.0"
|
s.version = "1.17.0"
|
||||||
s.summary = "A software update framework for OS X"
|
s.summary = "A software update framework for macOS"
|
||||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||||
s.homepage = "http://sparkle-project.org"
|
s.homepage = "http://sparkle-project.org"
|
||||||
|
s.documentation_url = "http://sparkle-project.org/documentation/"
|
||||||
|
s.screenshot = "http://sparkle-project.org/images/screenshot-noshadow@2x.png"
|
||||||
s.license = {
|
s.license = {
|
||||||
:type => 'MIT',
|
:type => 'MIT',
|
||||||
:file => 'LICENSE'
|
:file => 'LICENSE'
|
||||||
}
|
}
|
||||||
s.authors = {
|
s.authors = {
|
||||||
'Andy Matuschak' => 'andy@andymatuschak.org',
|
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
|
||||||
'Kornel Lesiński' => 'pornel@pornel.net',
|
'Kornel Lesiński' => 'pornel@pornel.net',
|
||||||
'C.W. Betts' => 'computers57@hotmail.com',
|
|
||||||
'Jake Petroules' => 'jake.petroules@petroules.com',
|
'Jake Petroules' => 'jake.petroules@petroules.com',
|
||||||
|
'C.W. Betts' => 'computers57@hotmail.com',
|
||||||
|
'Andy Matuschak' => 'andy@andymatuschak.org',
|
||||||
}
|
}
|
||||||
|
|
||||||
s.platform = :osx, '10.7'
|
s.platform = :osx, '10.7'
|
||||||
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
|
||||||
|
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||||
|
|
||||||
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
|
||||||
s.vendored_framework = 'Sparkle.framework'
|
s.vendored_frameworks = 'Sparkle.framework'
|
||||||
s.resources = 'Sparkle.framework'
|
s.xcconfig = {
|
||||||
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
|
'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"',
|
||||||
|
'LD_RUNPATH_SEARCH_PATHS' => '@loader_path/../Frameworks'
|
||||||
|
}
|
||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0700"
|
LastUpgradeVersion = "0830"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
</BuildAction>
|
</BuildAction>
|
||||||
<TestAction
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
buildConfiguration = "Debug">
|
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
@@ -52,11 +52,11 @@
|
|||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = ""
|
selectedDebuggerIdentifier = ""
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Debug"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
@@ -74,10 +74,10 @@
|
|||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
savedToolIdentifier = ""
|
savedToolIdentifier = ""
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
debugDocumentVersioning = "YES">
|
||||||
<MacroExpansion>
|
<MacroExpansion>
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0700"
|
LastUpgradeVersion = "0830"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
</BuildAction>
|
</BuildAction>
|
||||||
<TestAction
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
buildConfiguration = "Debug">
|
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
@@ -52,11 +52,11 @@
|
|||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = ""
|
selectedDebuggerIdentifier = ""
|
||||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Debug"
|
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugXPCServices = "NO"
|
debugXPCServices = "NO"
|
||||||
@@ -75,10 +75,10 @@
|
|||||||
</AdditionalOptions>
|
</AdditionalOptions>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
savedToolIdentifier = ""
|
savedToolIdentifier = ""
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Release"
|
|
||||||
debugDocumentVersioning = "YES">
|
debugDocumentVersioning = "YES">
|
||||||
<MacroExpansion>
|
<MacroExpansion>
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0830"
|
||||||
|
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>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0830"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5AA96C541E0AE0DB00CA4346"
|
||||||
|
BuildableName = "generate_appcast"
|
||||||
|
BlueprintName = "generate_appcast"
|
||||||
|
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5AA96C541E0AE0DB00CA4346"
|
||||||
|
BuildableName = "generate_appcast"
|
||||||
|
BlueprintName = "generate_appcast"
|
||||||
|
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5AA96C541E0AE0DB00CA4346"
|
||||||
|
BuildableName = "generate_appcast"
|
||||||
|
BlueprintName = "generate_appcast"
|
||||||
|
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<CommandLineArguments>
|
||||||
|
</CommandLineArguments>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "5AA96C541E0AE0DB00CA4346"
|
||||||
|
BuildableName = "generate_appcast"
|
||||||
|
BlueprintName = "generate_appcast"
|
||||||
|
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// AppKitPrevention.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 1/17/17.
|
||||||
|
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
// #include (not #import) this header to prevent AppKit from being imported
|
||||||
|
// Note this should be your LAST #include in your implementation file
|
||||||
|
|
||||||
|
// If this error is triggered, you can have Xcode indicate to you which source file including this header caused the issue
|
||||||
|
|
||||||
|
// One may wonder for certain targets where AppKit is banned completely, why just not link AppKit instead.
|
||||||
|
// Well, Xcode has thing called auto-linking that I don't trust very much.
|
||||||
|
// Even after trying to disable the setting, I've had targets able to link to AppKit without AppKit being specified in the list of linked libraries.
|
||||||
|
|
||||||
|
#ifdef _APPKITDEFINES_H
|
||||||
|
#error This is a core or daemon-safe module and should NOT import AppKit
|
||||||
|
#endif
|
||||||
@@ -28,5 +28,7 @@
|
|||||||
<string>MainMenu</string>
|
<string>MainMenu</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>NSApplication</string>
|
<string>NSApplication</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}.icns</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
#import <AppKit/AppKit.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "SULocalizations.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
#import "SUInstaller.h"
|
#import "SUInstaller.h"
|
||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
#import "SUStandardVersionComparator.h"
|
#import "SUStandardVersionComparator.h"
|
||||||
#import "SUStatusController.h"
|
#import "SUStatusController.h"
|
||||||
#import "SUPlainInstallerInternals.h"
|
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
#import "SUInstallerProtocol.h"
|
||||||
|
#import "TerminationListener.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -14,169 +17,213 @@
|
|||||||
static const NSTimeInterval SUInstallationTimeLimit = 5;
|
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 = .25;
|
static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||||
|
|
||||||
@interface TerminationListener : NSObject
|
@interface AppInstaller : NSObject <NSApplicationDelegate>
|
||||||
|
|
||||||
@property (copy) NSString *hostpath;
|
/*
|
||||||
@property (copy) NSString *executablepath;
|
* hostPath - path to host (original) application
|
||||||
@property (assign) pid_t parentprocessid;
|
* relaunchPath - path to what the host wants to relaunch (default is same as hostPath)
|
||||||
@property (copy) NSString *folderpath;
|
* parentProcessId - process identifier of the host before launching us
|
||||||
|
* updateFolderPath - path to update folder (i.e, temporary directory containing the new update)
|
||||||
@property (copy) NSString *selfPath;
|
* shouldRelaunch - indicates if the new installed app should re-launched
|
||||||
@property (copy) NSString *installationPath;
|
* shouldShowUI - indicates if we should show the status window when installing the update
|
||||||
@property (strong) NSTimer *watchdogTimer;
|
*/
|
||||||
@property (strong) NSTimer *longInstallationTimer;
|
- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI;
|
||||||
@property (strong) SUHost *host;
|
|
||||||
@property (assign) BOOL shouldRelaunch;
|
|
||||||
@property (assign) BOOL shouldShowUI;
|
|
||||||
@property (strong) SUStatusController *statusController;
|
|
||||||
|
|
||||||
- (void)parentHasQuit;
|
|
||||||
|
|
||||||
- (void)relaunch;
|
|
||||||
- (void)install;
|
|
||||||
|
|
||||||
- (void)showAppIconInDock:(NSTimer *)aTimer;
|
|
||||||
- (void)watchdog:(NSTimer *)aTimer;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation TerminationListener
|
@interface AppInstaller ()
|
||||||
|
|
||||||
@synthesize hostpath;
|
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||||
@synthesize executablepath;
|
@property (nonatomic, strong) SUStatusController *statusController;
|
||||||
@synthesize parentprocessid;
|
|
||||||
@synthesize folderpath;
|
|
||||||
|
|
||||||
@synthesize selfPath;
|
@property (nonatomic, copy) NSString *updateFolderPath;
|
||||||
@synthesize installationPath;
|
@property (nonatomic, copy) NSString *hostPath;
|
||||||
@synthesize watchdogTimer;
|
@property (nonatomic, copy) NSString *relaunchPath;
|
||||||
@synthesize longInstallationTimer;
|
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||||
@synthesize host;
|
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||||
@synthesize shouldRelaunch;
|
|
||||||
@synthesize shouldShowUI;
|
|
||||||
@synthesize statusController;
|
|
||||||
|
|
||||||
- (instancetype)initWithHostPath:(NSString *)inhostpath executablePath:(NSString *)execpath parentProcessId:(pid_t)ppid folderPath:(NSString *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
|
@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])) {
|
if (!(self = [super init])) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hostpath = inhostpath;
|
self.hostPath = hostPath;
|
||||||
self.executablepath = execpath;
|
self.relaunchPath = relaunchPath;
|
||||||
self.parentprocessid = ppid;
|
SULog(SULogLevelDefault, @"PID to listen: %d", parentProcessId);
|
||||||
self.folderpath = infolderpath;
|
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:@(parentProcessId)];
|
||||||
self.selfPath = inSelfPath;
|
self.updateFolderPath = updateFolderPath;
|
||||||
self.shouldRelaunch = relaunch;
|
self.shouldRelaunch = shouldRelaunch;
|
||||||
self.shouldShowUI = showUI;
|
self.shouldShowUI = shouldShowUI;
|
||||||
|
|
||||||
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
|
|
||||||
|
|
||||||
if (alreadyTerminated)
|
|
||||||
[self parentHasQuit];
|
|
||||||
else
|
|
||||||
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification
|
||||||
- (void)dealloc
|
|
||||||
{
|
{
|
||||||
[self.longInstallationTimer invalidate];
|
[self.terminationListener startListeningWithCompletion:^(BOOL terminationSuccess) {
|
||||||
[self.statusController close];
|
self.terminationListener = nil;
|
||||||
}
|
|
||||||
|
if (!terminationSuccess) {
|
||||||
|
SULog(SULogLevelError, @"Failed to listen for application termination");
|
||||||
- (void)parentHasQuit
|
// Continue on with the installation anyway?
|
||||||
{
|
}
|
||||||
[self.watchdogTimer invalidate];
|
|
||||||
self.longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit
|
if (self.shouldShowUI) {
|
||||||
target: self selector: @selector(showAppIconInDock:)
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
userInfo:nil repeats:NO];
|
if (!self.isTerminating) {
|
||||||
|
// Show app icon in the dock
|
||||||
if (self.folderpath)
|
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||||
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[self install];
|
[self install];
|
||||||
else
|
}];
|
||||||
[self relaunch];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)watchdog:(NSTimer *)__unused aTimer
|
- (void)showError:(NSError *)error
|
||||||
{
|
{
|
||||||
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.parentprocessid]) {
|
if (self.shouldShowUI) {
|
||||||
[self parentHasQuit];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
|
alert.messageText = @"";
|
||||||
|
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
||||||
|
[alert runModal];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)showAppIconInDock:(NSTimer *)__unused aTimer
|
|
||||||
{
|
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)relaunch __attribute__((noreturn))
|
|
||||||
{
|
|
||||||
if (self.shouldRelaunch)
|
|
||||||
{
|
|
||||||
NSString *appPath = nil;
|
|
||||||
if (!self.folderpath || ![self.executablepath isEqualToString:self.hostpath])
|
|
||||||
appPath = self.executablepath;
|
|
||||||
else
|
|
||||||
appPath = self.installationPath;
|
|
||||||
[[NSWorkspace sharedWorkspace] openFile:appPath];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self.folderpath)
|
|
||||||
{
|
|
||||||
NSError *theError = nil;
|
|
||||||
if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError])
|
|
||||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
|
||||||
}
|
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL];
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)install
|
- (void)install
|
||||||
{
|
{
|
||||||
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostpath];
|
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath];
|
||||||
self.host = [[SUHost alloc] initWithBundle:theBundle];
|
SUHost *host = [[SUHost alloc] initWithBundle:theBundle];
|
||||||
self.installationPath = [[self.host installationPath] copy];
|
|
||||||
|
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
|
||||||
if (self.shouldShowUI) {
|
|
||||||
SUStatusController *statusCtl = [[SUStatusController alloc] initWithHost:self.host]; // We quit anyway after we've installed, so leak this for now.
|
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
|
||||||
[statusCtl setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
|
SULog(SULogLevelError, @"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
|
||||||
[statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
|
|
||||||
maxProgressValue: 0 statusText: @""];
|
|
||||||
[statusCtl showWindow:self];
|
|
||||||
|
|
||||||
[self.statusController close]; // If there's an existing status controller, close it before we release our strong reference to it.
|
|
||||||
self.statusController = statusCtl; // Keep a strong reference to the status controller, or else it might get prematurely deallocated.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSError *retrieveInstallerError = nil;
|
||||||
|
id<SUInstallerProtocol> installer = [SUInstaller installerForHost:host fileOperationToolPath:fileOperationToolPath updateDirectory:self.updateFolderPath error:&retrieveInstallerError];
|
||||||
|
if (installer == nil) {
|
||||||
|
SULog(SULogLevelError, @"Retrieved Installer Error: %@", retrieveInstallerError);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.shouldShowUI && [installer canInstallSilently]) {
|
||||||
|
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:100 statusText: @""];
|
||||||
|
[self.statusController showWindow:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
NSError *initialInstallationError = nil;
|
||||||
|
if (![installer performInitialInstallation:&initialInstallationError]) {
|
||||||
|
SULog(SULogLevelError, @"Failed to perform initial installation with error: %@", initialInstallationError);
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self showError:initialInstallationError];
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void(^progressBlock)(double) = ^(double progress){
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^(){
|
||||||
|
self.statusController.progressValue = progress * 100.0;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
[SUInstaller installFromUpdateFolder:self.folderpath
|
NSError *finalInstallationError = nil;
|
||||||
overHost:self.host
|
if (![installer performFinalInstallationProgressBlock:progressBlock error:&finalInstallationError]) {
|
||||||
installationPath:self.installationPath
|
NSError *underlyingError = [finalInstallationError.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||||
versionComparator:[SUStandardVersionComparator defaultComparator]
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
completionHandler:^(NSError *error) {
|
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
|
||||||
if (error) {
|
SULog(SULogLevelError, @"Failed to perform final installation Error: %@", finalInstallationError);
|
||||||
if (self.shouldShowUI) {
|
[self showError:finalInstallationError];
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
}
|
||||||
alert.messageText = @"";
|
exit(EXIT_FAILURE);
|
||||||
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
|
});
|
||||||
[alert runModal];
|
return;
|
||||||
}
|
}
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
} else {
|
NSString *installationPath = [installer installationPath];
|
||||||
[self relaunch];
|
|
||||||
}
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
}];
|
NSString *pathToRelaunch = nil;
|
||||||
|
// If the relaunch path is the same as the host bundle path, use the installation path from the installer which may be normalized
|
||||||
|
// Otherwise use the requested relaunch path in all other cases
|
||||||
|
if ([self.relaunchPath.pathComponents isEqualToArray:host.bundlePath.pathComponents]) {
|
||||||
|
pathToRelaunch = installationPath;
|
||||||
|
} else {
|
||||||
|
pathToRelaunch = self.relaunchPath;
|
||||||
|
}
|
||||||
|
[self cleanupAndTerminateWithPathToRelaunch:pathToRelaunch];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath
|
||||||
|
{
|
||||||
|
self.isTerminating = YES;
|
||||||
|
|
||||||
|
dispatch_block_t cleanupAndExit = ^{
|
||||||
|
NSError *theError = nil;
|
||||||
|
if (![[NSFileManager defaultManager] removeItemAtPath:self.updateFolderPath error:&theError]) {
|
||||||
|
SULog(SULogLevelError, @"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(SULogLevelError, @"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
|
@end
|
||||||
@@ -189,24 +236,22 @@ int main(int __unused argc, const char __unused *argv[])
|
|||||||
if (args.count < 5 || args.count > 7) {
|
if (args.count < 5 || args.count > 7) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSApplication *application = [NSApplication sharedApplication];
|
||||||
|
|
||||||
BOOL shouldShowUI = (args.count > 6) ? [args[6] boolValue] : YES;
|
BOOL shouldShowUI = (args.count > 6) ? [[args objectAtIndex:6] boolValue] : YES;
|
||||||
if (shouldShowUI) {
|
if (shouldShowUI) {
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
[application activateIgnoringOtherApps:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:[args objectAtIndex:1]
|
||||||
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:args[1]
|
relaunchPath:[args objectAtIndex:2]
|
||||||
executablePath:args[2]
|
parentProcessId:[[args objectAtIndex:3] intValue]
|
||||||
parentProcessId:[args[3] intValue]
|
updateFolderPath:[args objectAtIndex:4]
|
||||||
folderPath:args[4]
|
shouldRelaunch:(args.count > 5) ? [[args objectAtIndex:5] boolValue] : YES
|
||||||
shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES
|
shouldShowUI:shouldShowUI];
|
||||||
shouldShowUI:shouldShowUI
|
[application setDelegate:appInstaller];
|
||||||
selfPath:[[NSBundle mainBundle] bundlePath]];
|
[application run];
|
||||||
|
|
||||||
[[NSApplication sharedApplication] run];
|
|
||||||
// Ensure termListen is not deallocated by ARC before caling -[NSApplication run]
|
|
||||||
[termListen class];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// TerminationListener.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 3/7/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface TerminationListener : NSObject
|
||||||
|
|
||||||
|
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) BOOL terminated;
|
||||||
|
|
||||||
|
// If the process identifier provided was nil, then the completion block will invoke immediately with a YES success
|
||||||
|
- (void)startListeningWithCompletion:(void (^)(BOOL success))completionBlock;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
//
|
||||||
|
// TerminationListener.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 3/7/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "TerminationListener.h"
|
||||||
|
#import "SULog.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/event.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface TerminationListener ()
|
||||||
|
|
||||||
|
@property (nonatomic, readonly, nullable) NSNumber *processIdentifier;
|
||||||
|
@property (nonatomic) BOOL watchedTermination;
|
||||||
|
@property (nonatomic, copy) void (^completionBlock)(BOOL);
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation TerminationListener
|
||||||
|
|
||||||
|
@synthesize completionBlock = _completionBlock;
|
||||||
|
@synthesize processIdentifier = _processIdentifier;
|
||||||
|
@synthesize watchedTermination = _watchedTermination;
|
||||||
|
|
||||||
|
- (instancetype)initWithProcessIdentifier:(NSNumber * _Nullable)processIdentifier
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_processIdentifier = processIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)terminated
|
||||||
|
{
|
||||||
|
return (self.watchedTermination || self.processIdentifier == nil) ? YES : (kill(self.processIdentifier.intValue, 0) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)invokeCompletionWithSuccess:(BOOL)success
|
||||||
|
{
|
||||||
|
if (self.completionBlock != nil) {
|
||||||
|
self.completionBlock(success);
|
||||||
|
self.completionBlock = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startListeningWithCompletion:(void (^)(BOOL))completionBlock
|
||||||
|
{
|
||||||
|
self.completionBlock = completionBlock;
|
||||||
|
|
||||||
|
if (self.processIdentifier == nil) {
|
||||||
|
[self invokeCompletionWithSuccess:YES];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use kqueues to determine when the process will terminate
|
||||||
|
// As described in https://developer.apple.com/library/mac/technotes/tn2050/_index.html#//apple_ref/doc/uid/DTS10003081-CH1-SUBSECTION10
|
||||||
|
// By using kqueues, we can stay away from using AppKit in case we ever decide to abandon it
|
||||||
|
|
||||||
|
pid_t processIdentifier = self.processIdentifier.intValue;
|
||||||
|
int queue = kqueue();
|
||||||
|
if (queue == -1) {
|
||||||
|
SULog(SULogLevelError, @"Failed to create kqueue() due to error %d: %@", errno, @(strerror(errno)));
|
||||||
|
[self invokeCompletionWithSuccess:NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct kevent changes;
|
||||||
|
EV_SET(&changes, processIdentifier, EVFILT_PROC, EV_ADD | EV_RECEIPT, NOTE_EXIT, 0, NULL);
|
||||||
|
|
||||||
|
if (kevent(queue, &changes, 1, &changes, 1, NULL) == -1) {
|
||||||
|
SULog(SULogLevelError, @"Failed to invoke kevent() due to error %d: %@", errno, @(strerror(errno)));
|
||||||
|
[self invokeCompletionWithSuccess:NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We will assume this terminationListener will never be deallocated
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||||
|
CFFileDescriptorContext context = { 0, (void *)CFBridgingRetain(self), NULL, NULL, NULL };
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
CFFileDescriptorRef noteExitKQueueRef = CFFileDescriptorCreate(NULL, queue, true, noteExitKQueueCallback, &context);
|
||||||
|
if (noteExitKQueueRef == NULL) {
|
||||||
|
SULog(SULogLevelError, @"Failed to create file descriptor via CFFileDescriptorCreate()");
|
||||||
|
CFRelease((__bridge CFTypeRef)(self));
|
||||||
|
[self invokeCompletionWithSuccess:NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRunLoopSourceRef runLoopSource = CFFileDescriptorCreateRunLoopSource(NULL, noteExitKQueueRef, 0);
|
||||||
|
if (runLoopSource == NULL) {
|
||||||
|
SULog(SULogLevelError, @"Failed to create runLoopSource via CFFileDescriptorCreateRunLoopSource()");
|
||||||
|
CFRelease((__bridge CFTypeRef)(self));
|
||||||
|
[self invokeCompletionWithSuccess:NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode);
|
||||||
|
CFRelease(runLoopSource);
|
||||||
|
|
||||||
|
CFFileDescriptorEnableCallBacks(noteExitKQueueRef, kCFFileDescriptorReadCallBack);
|
||||||
|
|
||||||
|
// Make sure we didn't set the listener callback to a dead PID
|
||||||
|
// If we did, we could hang forever. To avoid this, we check if the process has terminated *after* we set up the callback
|
||||||
|
// If we tried to do this check before setting the callback, we could run into an issue where the process can terminate after our check
|
||||||
|
// but before setting the callback
|
||||||
|
if ([self terminated]) {
|
||||||
|
[self invokeCompletionWithSuccess:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unused callBackTypes, void *info)
|
||||||
|
{
|
||||||
|
struct kevent event;
|
||||||
|
kevent(CFFileDescriptorGetNativeDescriptor(file), NULL, 0, &event, 1, NULL);
|
||||||
|
|
||||||
|
TerminationListener *self = CFBridgingRelease(info);
|
||||||
|
self.watchedTermination = YES;
|
||||||
|
[self invokeCompletionWithSuccess:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#!/usr/bin/xcrun swift
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
func die(_ msg: String) {
|
||||||
|
print("ERROR: \(msg)")
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
extension XMLElement {
|
||||||
|
convenience init(name: String, attributes: [String: String], stringValue string: String? = nil) {
|
||||||
|
self.init(name: name, stringValue: string)
|
||||||
|
setAttributesWith(attributes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let ud = UserDefaults.standard
|
||||||
|
let sparkleRoot = ud.object(forKey: "root") as? String
|
||||||
|
let htmlPath = ud.object(forKey: "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! FileManager.default.contentsOfDirectory(atPath: 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 = XMLDocument(rootElement: XMLElement(name: "html"))
|
||||||
|
html.dtd = XMLDTD()
|
||||||
|
html.dtd!.name = html.rootElement()!.name
|
||||||
|
html.characterEncoding = "UTF-8"
|
||||||
|
html.documentContentKind = XMLDocument.ContentKind.xhtml
|
||||||
|
var body = XMLElement(name: "body")
|
||||||
|
var head = XMLElement(name: "head")
|
||||||
|
html.rootElement()!.addChild(head)
|
||||||
|
html.rootElement()!.addChild(body)
|
||||||
|
head.addChild(XMLElement(name: "meta", attributes: ["charset": html.characterEncoding!]))
|
||||||
|
head.addChild(XMLElement(name: "title", stringValue: "Sparkle Localizations Report"))
|
||||||
|
head.addChild(XMLElement(name: "style", stringValue: css))
|
||||||
|
|
||||||
|
let locale = Locale.current
|
||||||
|
for dirEntry in dirContents {
|
||||||
|
if NSString(string: dirEntry).pathExtension != "lproj" || dirEntry == "en.lproj" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
let lang = (locale as NSLocale).displayName(forKey: NSLocale.Key.languageCode, value: NSString(string: dirEntry).deletingPathExtension)
|
||||||
|
body.addChild(XMLElement(name: "h1", stringValue: "\(dirEntry) (\(lang!))"))
|
||||||
|
|
||||||
|
let stringsPath = NSString(string: dirPath.appendingPathComponent(dirEntry)).appendingPathComponent("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?.object(forKey: key) as? String
|
||||||
|
if str == nil {
|
||||||
|
missing.append(key as! String)
|
||||||
|
} else if let enStr = enStringsDict?.object(forKey: key) as? String {
|
||||||
|
if enStr == str {
|
||||||
|
unlocalized.append(key as! String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let stringsDictKeys = stringsDict!.allKeys
|
||||||
|
for key in stringsDictKeys {
|
||||||
|
if enStringsDict?.object(forKey: key) == nil {
|
||||||
|
unused.append(key as! String)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sorter = { (s1: String, s2: String) -> Bool in
|
||||||
|
return s1 < s2
|
||||||
|
}
|
||||||
|
missing.sort(by: sorter)
|
||||||
|
unlocalized.sort(by: sorter)
|
||||||
|
unused.sort(by: sorter)
|
||||||
|
|
||||||
|
let addRow = { (prefix: String, cssClass: String, key: String) -> Void in
|
||||||
|
body.addChild(XMLElement(name: "span", attributes: ["class": cssClass], stringValue: [prefix, key].joined(separator: " ") + "\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 !((try? html.xmlData.write(to: URL(fileURLWithPath: htmlPath!), options: [.atomic])) != nil) {
|
||||||
|
die("Can't write report: \(err!)")
|
||||||
|
}
|
||||||
@@ -9,18 +9,32 @@
|
|||||||
#ifndef SUAPPCAST_H
|
#ifndef SUAPPCAST_H
|
||||||
#define SUAPPCAST_H
|
#define SUAPPCAST_H
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
#import "SUExport.h"
|
#import "SUExport.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class SUAppcastItem;
|
@class SUAppcastItem;
|
||||||
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||||
|
|
||||||
@property (copy) NSString *userAgentString;
|
@property (copy, nullable) NSString *userAgentString;
|
||||||
@property (copy) NSDictionary *httpHeaders;
|
|
||||||
|
|
||||||
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
|
#if __has_feature(objc_generics)
|
||||||
|
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||||
|
#else
|
||||||
|
@property (copy, nullable) NSDictionary *httpHeaders;
|
||||||
|
#endif
|
||||||
|
|
||||||
@property (readonly, copy) NSArray *items;
|
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
|
||||||
|
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||||
|
|
||||||
|
@property (readonly, copy, nullable) NSArray *items;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "SUUpdater.h"
|
|
||||||
|
|
||||||
#import "SUAppcast.h"
|
#import "SUAppcast.h"
|
||||||
#import "SUAppcastItem.h"
|
#import "SUAppcastItem.h"
|
||||||
#import "SUVersionComparisonProtocol.h"
|
|
||||||
#import "SUAppcast.h"
|
|
||||||
#import "SUConstants.h"
|
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
#import "SULocalizations.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@interface NSXMLElement (SUAppcastExtensions)
|
@interface NSXMLElement (SUAppcastExtensions)
|
||||||
@property (readonly, copy) NSDictionary *attributesAsDictionary;
|
@property (readonly, copy) NSDictionary *attributesAsDictionary;
|
||||||
@@ -30,7 +30,10 @@
|
|||||||
if (!attrName) {
|
if (!attrName) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dictionary[attrName] = [attribute stringValue];
|
NSString *attributeStringValue = [attribute stringValue];
|
||||||
|
if (attributeStringValue != nil) {
|
||||||
|
[dictionary setObject:attributeStringValue forKey:attrName];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
@@ -54,18 +57,22 @@
|
|||||||
@synthesize download;
|
@synthesize download;
|
||||||
@synthesize items;
|
@synthesize items;
|
||||||
|
|
||||||
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
|
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)background completionBlock:(void (^)(NSError *))block
|
||||||
{
|
{
|
||||||
self.completionBlock = block;
|
self.completionBlock = block;
|
||||||
|
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
|
||||||
|
if (background) {
|
||||||
|
request.networkServiceType = NSURLNetworkServiceTypeBackground;
|
||||||
|
}
|
||||||
|
|
||||||
if (self.userAgentString) {
|
if (self.userAgentString) {
|
||||||
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
|
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.httpHeaders) {
|
if (self.httpHeaders) {
|
||||||
for (NSString *key in self.httpHeaders) {
|
for (NSString *key in self.httpHeaders) {
|
||||||
id value = [self.httpHeaders objectForKey:key];
|
NSString *value = [self.httpHeaders objectForKey:key];
|
||||||
[request setValue:value forHTTPHeaderField:key];
|
[request setValue:value forHTTPHeaderField:key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,147 +100,166 @@
|
|||||||
- (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;
|
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
||||||
BOOL failed = NO;
|
self.downloadFilename = nil;
|
||||||
NSArray *xmlItems = nil;
|
|
||||||
NSMutableArray *appcastItems = [NSMutableArray array];
|
|
||||||
|
|
||||||
if (self.downloadFilename)
|
if (appcastItems) {
|
||||||
{
|
self.items = appcastItems;
|
||||||
NSUInteger options = 0;
|
self.completionBlock(nil);
|
||||||
options = NSXMLNodeLoadExternalEntitiesSameOriginOnly;
|
self.completionBlock = nil;
|
||||||
document = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:self.downloadFilename] options:options error:&error];
|
} else {
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
|
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
|
||||||
self.downloadFilename = nil;
|
forKey: NSLocalizedDescriptionKey];
|
||||||
}
|
if (error) {
|
||||||
else
|
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
|
||||||
{
|
}
|
||||||
failed = YES;
|
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||||
|
code:SUAppcastParseError
|
||||||
|
userInfo:userInfo]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nil == document)
|
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
|
||||||
{
|
{
|
||||||
failed = YES;
|
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
|
||||||
}
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
else
|
|
||||||
{
|
for (NSXMLNode *attribute in attributeEnum) {
|
||||||
xmlItems = [document nodesForXPath:@"/rss/channel/item" error:&error];
|
NSString *attrName = [self sparkleNamespacedNameOfNode:attribute];
|
||||||
if (nil == xmlItems)
|
if (!attrName) {
|
||||||
{
|
continue;
|
||||||
failed = YES;
|
}
|
||||||
|
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];
|
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
|
||||||
NSXMLNode *node;
|
if (errorp) {
|
||||||
|
*errorp = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!appcastFile) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
|
||||||
|
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:appcastFile options:options error:errorp];
|
||||||
|
if (nil == document) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSArray *xmlItems = [document nodesForXPath:@"/rss/channel/item" error:errorp];
|
||||||
|
if (nil == xmlItems) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSMutableArray *appcastItems = [NSMutableArray array];
|
||||||
|
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
|
||||||
|
NSXMLNode *node;
|
||||||
|
|
||||||
|
while((node = [nodeEnum nextObject])) {
|
||||||
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
|
||||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
while (failed == NO && (node = [nodeEnum nextObject]))
|
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
||||||
{
|
if ([[node children] count]) {
|
||||||
// First, we'll "index" all the first-level children of this appcast item so we can pick them out by language later.
|
node = [node childAtIndex:0];
|
||||||
if ([[node children] count])
|
while (nil != node) {
|
||||||
{
|
NSString *name = [self sparkleNamespacedNameOfNode:node];
|
||||||
node = [node childAtIndex:0];
|
if (name) {
|
||||||
while (nil != node)
|
NSMutableArray *nodes = [nodesDict objectForKey:name];
|
||||||
{
|
if (nodes == nil) {
|
||||||
NSString *name = [node name];
|
nodes = [NSMutableArray array];
|
||||||
if (name)
|
[nodesDict setObject:nodes forKey:name];
|
||||||
{
|
|
||||||
NSMutableArray *nodes = nodesDict[name];
|
|
||||||
if (nodes == nil)
|
|
||||||
{
|
|
||||||
nodes = [NSMutableArray array];
|
|
||||||
nodesDict[name] = nodes;
|
|
||||||
}
|
|
||||||
[nodes addObject:node];
|
|
||||||
}
|
}
|
||||||
node = [node nextSibling];
|
[nodes addObject:node];
|
||||||
}
|
}
|
||||||
|
node = [node nextSibling];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (NSString *name in nodesDict)
|
for (NSString *name in nodesDict) {
|
||||||
{
|
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
|
||||||
node = [self bestNodeInNodes:nodesDict[name]];
|
if ([name isEqualToString:SURSSElementEnclosure]) {
|
||||||
if ([name isEqualToString:SURSSElementEnclosure])
|
// enclosure is flattened as a separate dictionary for some reason
|
||||||
{
|
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||||
// enclosure is flattened as a separate dictionary for some reason
|
[dict setObject:encDict forKey:name];
|
||||||
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
|
|
||||||
dict[name] = encDict;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if ([name isEqualToString:SURSSElementPubDate])
|
|
||||||
{
|
|
||||||
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
|
|
||||||
NSString *string = node.stringValue;
|
|
||||||
if (string) {
|
|
||||||
NSDate *date = [NSDate dateWithNaturalLanguageString:string];
|
|
||||||
if (date)
|
|
||||||
dict[name] = date;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ([name isEqualToString:SUAppcastElementDeltas])
|
|
||||||
{
|
|
||||||
NSMutableArray *deltas = [NSMutableArray array];
|
|
||||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
|
||||||
for (NSXMLNode *child in childEnum) {
|
|
||||||
if ([[child name] isEqualToString:SURSSElementEnclosure])
|
|
||||||
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
|
|
||||||
}
|
|
||||||
dict[name] = deltas;
|
|
||||||
}
|
|
||||||
else if ([name isEqualToString:SUAppcastElementTags]) {
|
|
||||||
NSMutableArray *tags = [NSMutableArray array];
|
|
||||||
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
|
||||||
for (NSXMLNode *child in childEnum) {
|
|
||||||
NSString *childName = child.name;
|
|
||||||
if (childName)
|
|
||||||
[tags addObject:childName];
|
|
||||||
}
|
|
||||||
dict[name] = tags;
|
|
||||||
}
|
|
||||||
else if (name != nil)
|
|
||||||
{
|
|
||||||
// add all other values as strings
|
|
||||||
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
||||||
if (theValue != nil) {
|
|
||||||
dict[name] = theValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *errString;
|
|
||||||
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
|
||||||
if (anItem)
|
|
||||||
{
|
|
||||||
[appcastItems addObject:anItem];
|
|
||||||
}
|
}
|
||||||
else
|
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||||
{
|
// We don't want to parse and create a NSDate instance -
|
||||||
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
|
// that's a risk we can avoid. We don't use the date anywhere other
|
||||||
|
// than it being accessible from SUAppcastItem
|
||||||
|
NSString *dateString = node.stringValue;
|
||||||
|
if (dateString) {
|
||||||
|
[dict setObject:dateString forKey:name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ([name isEqualToString:SUAppcastElementDeltas]) {
|
||||||
|
NSMutableArray *deltas = [NSMutableArray array];
|
||||||
|
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||||
|
for (NSXMLNode *child in childEnum) {
|
||||||
|
if ([[child name] isEqualToString:SURSSElementEnclosure]) {
|
||||||
|
[deltas addObject:[self attributesOfNode:(NSXMLElement *)child]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[dict setObject:deltas forKey:name];
|
||||||
|
}
|
||||||
|
else if ([name isEqualToString:SUAppcastElementTags]) {
|
||||||
|
NSMutableArray *tags = [NSMutableArray array];
|
||||||
|
NSEnumerator *childEnum = [[node children] objectEnumerator];
|
||||||
|
for (NSXMLNode *child in childEnum) {
|
||||||
|
NSString *childName = child.name;
|
||||||
|
if (childName) {
|
||||||
|
[tags addObject:childName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[dict setObject:tags forKey:name];
|
||||||
}
|
}
|
||||||
[nodesDict removeAllObjects];
|
else if (name != nil) {
|
||||||
[dict removeAllObjects];
|
// add all other values as strings
|
||||||
|
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||||
|
if (theValue != nil) {
|
||||||
|
[dict setObject:theValue forKey:name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *errString;
|
||||||
|
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
|
||||||
|
if (anItem) {
|
||||||
|
[appcastItems addObject:anItem];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SULog(SULogLevelError, @"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]) {
|
return appcastItems;
|
||||||
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
|
|
||||||
[appcastItems sortUsingDescriptors:@[sort]];
|
|
||||||
self.items = appcastItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failed) {
|
|
||||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil) }]];
|
|
||||||
} else {
|
|
||||||
self.completionBlock(nil);
|
|
||||||
self.completionBlock = nil;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
|
||||||
@@ -253,14 +279,18 @@
|
|||||||
|
|
||||||
- (void)reportError:(NSError *)error
|
- (void)reportError:(NSError *)error
|
||||||
{
|
{
|
||||||
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||||
|
|
||||||
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{
|
|
||||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
|
||||||
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
|
||||||
NSUnderlyingErrorKey: error,
|
NSUnderlyingErrorKey: error,
|
||||||
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
|
}];
|
||||||
}]);
|
|
||||||
|
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||||
|
if (failingUrl) {
|
||||||
|
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:userInfo]);
|
||||||
self.completionBlock = nil;
|
self.completionBlock = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +298,7 @@
|
|||||||
{
|
{
|
||||||
// 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)
|
if ([nodes count] == 1)
|
||||||
return nodes[0];
|
return [nodes objectAtIndex:0];
|
||||||
else if ([nodes count] == 0)
|
else if ([nodes count] == 0)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
@@ -279,12 +309,24 @@
|
|||||||
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
lang = [[node attributeForName:@"xml:lang"] stringValue];
|
||||||
[languages addObject:(lang ? lang : @"")];
|
[languages addObject:(lang ? lang : @"")];
|
||||||
}
|
}
|
||||||
lang = [NSBundle preferredLocalizationsFromArray:languages][0];
|
lang = [[NSBundle preferredLocalizationsFromArray:languages] objectAtIndex:0];
|
||||||
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")];
|
||||||
if (i == NSNotFound) {
|
if (i == NSNotFound) {
|
||||||
i = 0;
|
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
|
@end
|
||||||
@@ -9,18 +9,23 @@
|
|||||||
#ifndef SUAPPCASTITEM_H
|
#ifndef SUAPPCASTITEM_H
|
||||||
#define SUAPPCASTITEM_H
|
#define SUAPPCASTITEM_H
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
#import "SUExport.h"
|
#import "SUExport.h"
|
||||||
|
|
||||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||||
@property (copy, readonly) NSString *title;
|
@property (copy, readonly) NSString *title;
|
||||||
@property (copy, readonly) NSDate *date;
|
@property (copy, readonly) NSString *dateString;
|
||||||
@property (copy, readonly) NSString *itemDescription;
|
@property (copy, readonly) NSString *itemDescription;
|
||||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||||
@property (copy, readonly) NSString *DSASignature;
|
@property (copy, readonly) NSString *DSASignature;
|
||||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||||
@property (strong, readonly) NSURL *fileURL;
|
@property (strong, readonly) NSURL *fileURL;
|
||||||
|
@property (nonatomic, readonly) uint64_t contentLength;
|
||||||
@property (copy, readonly) NSString *versionString;
|
@property (copy, readonly) NSString *versionString;
|
||||||
@property (copy, readonly) NSString *displayVersionString;
|
@property (copy, readonly) NSString *displayVersionString;
|
||||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||||
@@ -32,6 +37,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
|
|||||||
|
|
||||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||||
|
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||||
|
|
||||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||||
|
|||||||
@@ -6,17 +6,16 @@
|
|||||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "SUUpdater.h"
|
|
||||||
|
|
||||||
#import "SUAppcast.h"
|
|
||||||
#import "SUAppcastItem.h"
|
|
||||||
#import "SUVersionComparisonProtocol.h"
|
|
||||||
#import "SUAppcastItem.h"
|
#import "SUAppcastItem.h"
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
#import "SUConstants.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@interface SUAppcastItem ()
|
@interface SUAppcastItem ()
|
||||||
@property (copy, readwrite) NSString *title;
|
@property (copy, readwrite) NSString *title;
|
||||||
@property (copy, readwrite) NSDate *date;
|
@property (copy, readwrite) NSString *dateString;
|
||||||
@property (copy, readwrite) NSString *itemDescription;
|
@property (copy, readwrite) NSString *itemDescription;
|
||||||
@property (strong, readwrite) NSURL *releaseNotesURL;
|
@property (strong, readwrite) NSURL *releaseNotesURL;
|
||||||
@property (copy, readwrite) NSString *DSASignature;
|
@property (copy, readwrite) NSString *DSASignature;
|
||||||
@@ -31,11 +30,12 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUAppcastItem
|
@implementation SUAppcastItem
|
||||||
@synthesize date;
|
@synthesize dateString;
|
||||||
@synthesize deltaUpdates;
|
@synthesize deltaUpdates;
|
||||||
@synthesize displayVersionString;
|
@synthesize displayVersionString;
|
||||||
@synthesize DSASignature;
|
@synthesize DSASignature;
|
||||||
@synthesize fileURL;
|
@synthesize fileURL;
|
||||||
|
@synthesize contentLength = _contentLength;
|
||||||
@synthesize infoURL;
|
@synthesize infoURL;
|
||||||
@synthesize itemDescription;
|
@synthesize itemDescription;
|
||||||
@synthesize maximumSystemVersion;
|
@synthesize maximumSystemVersion;
|
||||||
@@ -47,12 +47,18 @@
|
|||||||
|
|
||||||
- (BOOL)isDeltaUpdate
|
- (BOOL)isDeltaUpdate
|
||||||
{
|
{
|
||||||
return self.propertiesDictionary[SURSSElementEnclosure][SUAppcastAttributeDeltaFrom] != nil;
|
NSDictionary *rssElementEnclosure = [self.propertiesDictionary objectForKey:SURSSElementEnclosure];
|
||||||
|
return [rssElementEnclosure objectForKey:SUAppcastAttributeDeltaFrom] != nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isCriticalUpdate
|
- (BOOL)isCriticalUpdate
|
||||||
{
|
{
|
||||||
return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
return [[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isInformationOnlyUpdate
|
||||||
|
{
|
||||||
|
return self.infoURL && !self.fileURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithDictionary:(NSDictionary *)dict
|
- (instancetype)initWithDictionary:(NSDictionary *)dict
|
||||||
@@ -64,7 +70,7 @@
|
|||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
id enclosure = dict[SURSSElementEnclosure];
|
NSDictionary *enclosure = [dict objectForKey:SURSSElementEnclosure];
|
||||||
|
|
||||||
// Try to find a version string.
|
// Try to find a version string.
|
||||||
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
|
||||||
@@ -74,17 +80,17 @@
|
|||||||
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
|
// 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.
|
// 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.
|
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
|
||||||
NSString *newVersion = enclosure[SUAppcastAttributeVersion];
|
NSString *newVersion = [enclosure objectForKey:SUAppcastAttributeVersion];
|
||||||
if (newVersion == nil) {
|
if (newVersion == nil) {
|
||||||
newVersion = dict[SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
newVersion = [dict objectForKey:SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
|
||||||
}
|
}
|
||||||
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
if (newVersion == nil) // no sparkle:version attribute anywhere?
|
||||||
{
|
{
|
||||||
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, enclosure[SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
|
SULog(SULogLevelError, @"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, [enclosure objectForKey:SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
|
||||||
|
|
||||||
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
// Separate the url by underscores and take the last component, as that'll be closest to the end,
|
||||||
// then we remove the extension. Hopefully, this will be the version.
|
// then we remove the extension. Hopefully, this will be the version.
|
||||||
NSArray *fileComponents = [enclosure[SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
NSArray *fileComponents = [[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
|
||||||
if ([fileComponents count] > 1) {
|
if ([fileComponents count] > 1) {
|
||||||
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
|
||||||
}
|
}
|
||||||
@@ -98,14 +104,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
|
||||||
self.title = dict[SURSSElementTitle];
|
self.title = [dict objectForKey:SURSSElementTitle];
|
||||||
self.date = dict[SURSSElementPubDate];
|
self.dateString = [dict objectForKey:SURSSElementPubDate];
|
||||||
self.itemDescription = dict[SURSSElementDescription];
|
self.itemDescription = [dict objectForKey:SURSSElementDescription];
|
||||||
|
|
||||||
NSString *theInfoURL = dict[SURSSElementLink];
|
NSString *theInfoURL = [dict objectForKey:SURSSElementLink];
|
||||||
if (theInfoURL) {
|
if (theInfoURL) {
|
||||||
if (![theInfoURL isKindOfClass:[NSString class]]) {
|
if (![theInfoURL isKindOfClass:[NSString class]]) {
|
||||||
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
SULog(SULogLevelError, @"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||||
} else {
|
} else {
|
||||||
self.infoURL = [NSURL URLWithString:theInfoURL];
|
self.infoURL = [NSURL URLWithString:theInfoURL];
|
||||||
}
|
}
|
||||||
@@ -120,29 +126,39 @@
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *enclosureURLString = enclosure[SURSSAttributeURL];
|
NSString *enclosureURLString = [enclosure objectForKey:SURSSAttributeURL];
|
||||||
if (!enclosureURLString && !theInfoURL) {
|
if (!enclosureURLString && !theInfoURL) {
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = @"Feed item's enclosure lacks URL";
|
*error = @"Feed item's enclosure lacks URL";
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enclosureURLString) {
|
||||||
|
NSString *enclosureLengthString = [enclosure objectForKey:SURSSAttributeLength];
|
||||||
|
long long contentLength = 0;
|
||||||
|
if (enclosureLengthString != nil) {
|
||||||
|
contentLength = [enclosureLengthString longLongValue];
|
||||||
|
}
|
||||||
|
_contentLength = (contentLength > 0) ? (uint64_t)contentLength : 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (enclosureURLString) {
|
if (enclosureURLString) {
|
||||||
NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
// Sparkle used to always URL-encode, so for backwards compatibility spaces in URLs must be forgiven.
|
||||||
|
NSString *fileURLString = [enclosureURLString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
|
||||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||||
}
|
}
|
||||||
if (enclosure) {
|
if (enclosure) {
|
||||||
self.DSASignature = enclosure[SUAppcastAttributeDSASignature];
|
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.versionString = newVersion;
|
self.versionString = newVersion;
|
||||||
self.minimumSystemVersion = dict[SUAppcastElementMinimumSystemVersion];
|
self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion];
|
||||||
self.maximumSystemVersion = dict[SUAppcastElementMaximumSystemVersion];
|
self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion];
|
||||||
|
|
||||||
NSString *shortVersionString = enclosure[SUAppcastAttributeShortVersionString];
|
NSString *shortVersionString = [enclosure objectForKey:SUAppcastAttributeShortVersionString];
|
||||||
if (nil == shortVersionString) {
|
if (nil == shortVersionString) {
|
||||||
shortVersionString = dict[SUAppcastAttributeShortVersionString]; // fall back on the <item>
|
shortVersionString = [dict objectForKey:SUAppcastAttributeShortVersionString]; // fall back on the <item>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shortVersionString) {
|
if (shortVersionString) {
|
||||||
@@ -152,28 +168,33 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the appropriate release notes URL.
|
// Find the appropriate release notes URL.
|
||||||
NSString *releaseNotesString = dict[SUAppcastElementReleaseNotesLink];
|
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||||
if (releaseNotesString) {
|
if (releaseNotesString) {
|
||||||
self.releaseNotesURL = [NSURL URLWithString:releaseNotesString];
|
NSURL *url = [NSURL URLWithString:releaseNotesString];
|
||||||
|
if ([url isFileURL]) {
|
||||||
|
SULog(SULogLevelError, @"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.
|
} 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];
|
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||||
} else {
|
} else {
|
||||||
self.releaseNotesURL = nil;
|
self.releaseNotesURL = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *deltaDictionaries = dict[SUAppcastElementDeltas];
|
NSArray *deltaDictionaries = [dict objectForKey:SUAppcastElementDeltas];
|
||||||
if (deltaDictionaries) {
|
if (deltaDictionaries) {
|
||||||
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
|
||||||
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
for (NSDictionary *deltaDictionary in deltaDictionaries) {
|
||||||
NSString *deltaFrom = deltaDictionary[SUAppcastAttributeDeltaFrom];
|
NSString *deltaFrom = [deltaDictionary objectForKey:SUAppcastAttributeDeltaFrom];
|
||||||
if (!deltaFrom) continue;
|
if (!deltaFrom) continue;
|
||||||
|
|
||||||
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
|
||||||
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
|
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
|
||||||
fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary;
|
[fakeAppCastDict setObject:deltaDictionary forKey:SURSSElementEnclosure];
|
||||||
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
|
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
|
||||||
|
|
||||||
deltas[deltaFrom] = deltaItem;
|
[deltas setObject:deltaItem forKey:deltaFrom];
|
||||||
}
|
}
|
||||||
self.deltaUpdates = deltas;
|
self.deltaUpdates = deltas;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// SUApplicationInfo.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 2/28/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class SUHost;
|
||||||
|
|
||||||
|
@interface SUApplicationInfo : NSObject
|
||||||
|
|
||||||
|
+ (BOOL)isBackgroundApplication:(NSApplication *)application;
|
||||||
|
|
||||||
|
+ (NSImage *)bestIconForHost:(SUHost *)host;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// SUApplicationInfo.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 2/28/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SUApplicationInfo.h"
|
||||||
|
#import "SUBundleIcon.h"
|
||||||
|
#import "SUHost.h"
|
||||||
|
|
||||||
|
@implementation SUApplicationInfo
|
||||||
|
|
||||||
|
+ (BOOL)isBackgroundApplication:(NSApplication *)application
|
||||||
|
{
|
||||||
|
return (application.activationPolicy == NSApplicationActivationPolicyAccessory);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSImage *)bestIconForHost:(SUHost *)host
|
||||||
|
{
|
||||||
|
NSURL *iconURL = [SUBundleIcon iconURLForHost:host];
|
||||||
|
|
||||||
|
NSImage *icon = (iconURL == nil) ? nil : [[NSImage alloc] initWithContentsOfURL:iconURL];
|
||||||
|
// Use a default icon if none is defined.
|
||||||
|
if (!icon) {
|
||||||
|
// this asumption may not be correct (eg. even though we're not the main bundle, it could be still be a regular app)
|
||||||
|
// but still better than nothing if no icon was included
|
||||||
|
BOOL isMainBundle = [host.bundle isEqualTo:[NSBundle mainBundle]];
|
||||||
|
|
||||||
|
NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle;
|
||||||
|
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef SUAUTOMATICUPDATEALERT_H
|
#ifndef SUAUTOMATICUPDATEALERT_H
|
||||||
#define SUAUTOMATICUPDATEALERT_H
|
#define SUAUTOMATICUPDATEALERT_H
|
||||||
|
|
||||||
#import "SUWindowController.h"
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
|
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
|
||||||
SUInstallNowChoice,
|
SUInstallNowChoice,
|
||||||
@@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@class SUAppcastItem, SUHost;
|
@class SUAppcastItem, SUHost;
|
||||||
@interface SUAutomaticUpdateAlert : SUWindowController
|
@interface SUAutomaticUpdateAlert : NSWindowController
|
||||||
|
|
||||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
|
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
|
||||||
- (IBAction)installNow:sender;
|
- (IBAction)installNow:sender;
|
||||||
|
|||||||
@@ -7,19 +7,32 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "SUAutomaticUpdateAlert.h"
|
#import "SUAutomaticUpdateAlert.h"
|
||||||
|
#import "SULocalizations.h"
|
||||||
|
#import "SUAppcastItem.h"
|
||||||
|
#import "SUApplicationInfo.h"
|
||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
|
#import "SUTouchBarForwardDeclarations.h"
|
||||||
|
#import "SUTouchBarButtonGroup.h"
|
||||||
|
|
||||||
@interface SUAutomaticUpdateAlert ()
|
static NSString *const SUAutomaticUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDENTIFIER ".SUAutomaticUpdateAlert";
|
||||||
|
|
||||||
|
@interface SUAutomaticUpdateAlert () <NSTouchBarDelegate>
|
||||||
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
|
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
|
||||||
@property (strong) SUAppcastItem *updateItem;
|
@property (strong) SUAppcastItem *updateItem;
|
||||||
@property (strong) SUHost *host;
|
@property (strong) SUHost *host;
|
||||||
|
|
||||||
|
@property (weak) IBOutlet NSButton *skipButton;
|
||||||
|
@property (weak) IBOutlet NSButton *laterButton;
|
||||||
|
@property (weak) IBOutlet NSButton *installButton;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUAutomaticUpdateAlert
|
@implementation SUAutomaticUpdateAlert
|
||||||
@synthesize host;
|
@synthesize host;
|
||||||
@synthesize updateItem;
|
@synthesize updateItem;
|
||||||
@synthesize completionBlock;
|
@synthesize completionBlock;
|
||||||
|
@synthesize skipButton;
|
||||||
|
@synthesize laterButton;
|
||||||
|
@synthesize installButton;
|
||||||
|
|
||||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
|
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
|
||||||
{
|
{
|
||||||
@@ -29,12 +42,13 @@
|
|||||||
self.completionBlock = block;
|
self.completionBlock = block;
|
||||||
self.host = aHost;
|
self.host = aHost;
|
||||||
[self setShouldCascadeWindows:NO];
|
[self setShouldCascadeWindows:NO];
|
||||||
|
|
||||||
[[self window] center];
|
[[self window] center];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
|
- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
|
||||||
|
|
||||||
- (IBAction)installNow:(id)__unused sender
|
- (IBAction)installNow:(id)__unused sender
|
||||||
{
|
{
|
||||||
@@ -57,9 +71,17 @@
|
|||||||
self.completionBlock = nil;
|
self.completionBlock = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)windowDidLoad
|
||||||
|
{
|
||||||
|
if ([self.updateItem isCriticalUpdate]) {
|
||||||
|
self.skipButton.enabled = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSImage *__nonnull)applicationIcon
|
- (NSImage *__nonnull)applicationIcon
|
||||||
{
|
{
|
||||||
return [self.host icon];
|
return [SUApplicationInfo bestIconForHost:self.host];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)titleText
|
- (NSString *__nonnull)titleText
|
||||||
@@ -86,4 +108,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSTouchBar *)makeTouchBar
|
||||||
|
{
|
||||||
|
NSTouchBar *touchBar = [[NSClassFromString(@"NSTouchBar") alloc] init];
|
||||||
|
touchBar.defaultItemIdentifiers = @[SUAutomaticUpdateAlertTouchBarIndentifier,];
|
||||||
|
touchBar.principalItemIdentifier = SUAutomaticUpdateAlertTouchBarIndentifier;
|
||||||
|
touchBar.delegate = self;
|
||||||
|
return touchBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTouchBarItem *)touchBar:(NSTouchBar * __unused)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||||
|
{
|
||||||
|
if ([identifier isEqualToString:SUAutomaticUpdateAlertTouchBarIndentifier]) {
|
||||||
|
NSCustomTouchBarItem* item = [(NSCustomTouchBarItem *)[NSClassFromString(@"NSCustomTouchBarItem") alloc] initWithIdentifier:identifier];
|
||||||
|
item.viewController = [[SUTouchBarButtonGroup alloc] initByReferencingButtons:@[self.installButton, self.laterButton, self.skipButton]];
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -9,11 +9,9 @@
|
|||||||
#ifndef SUAUTOMATICUPDATEDRIVER_H
|
#ifndef SUAUTOMATICUPDATEDRIVER_H
|
||||||
#define SUAUTOMATICUPDATEDRIVER_H
|
#define SUAUTOMATICUPDATEDRIVER_H
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import "SUBasicUpdateDriver.h"
|
#import "SUBasicUpdateDriver.h"
|
||||||
#import "SUAutomaticUpdateAlert.h"
|
|
||||||
|
|
||||||
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
|
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,15 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "SUAutomaticUpdateDriver.h"
|
#import "SUAutomaticUpdateDriver.h"
|
||||||
|
#import "SUUpdaterPrivate.h"
|
||||||
|
#import "SUUpdaterDelegate.h"
|
||||||
|
#import "SULocalizations.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
#import "SUAutomaticUpdateAlert.h"
|
#import "SUAutomaticUpdateAlert.h"
|
||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
|
#import "SUAppcastItem.h"
|
||||||
|
#import "SUApplicationInfo.h"
|
||||||
|
|
||||||
// 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.
|
// 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;
|
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
|
||||||
@@ -26,6 +31,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
@property (assign) BOOL postponingInstallation;
|
@property (assign) BOOL postponingInstallation;
|
||||||
@property (assign) BOOL showErrors;
|
@property (assign) BOOL showErrors;
|
||||||
@property (assign) BOOL willUpdateOnTermination;
|
@property (assign) BOOL willUpdateOnTermination;
|
||||||
|
@property (assign) BOOL isTerminating;
|
||||||
@property (strong) SUAutomaticUpdateAlert *alert;
|
@property (strong) SUAutomaticUpdateAlert *alert;
|
||||||
@property (strong) NSTimer *showUpdateAlertTimer;
|
@property (strong) NSTimer *showUpdateAlertTimer;
|
||||||
|
|
||||||
@@ -36,12 +42,19 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
@synthesize postponingInstallation;
|
@synthesize postponingInstallation;
|
||||||
@synthesize showErrors;
|
@synthesize showErrors;
|
||||||
@synthesize willUpdateOnTermination;
|
@synthesize willUpdateOnTermination;
|
||||||
|
@synthesize isTerminating;
|
||||||
@synthesize alert;
|
@synthesize alert;
|
||||||
@synthesize showUpdateAlertTimer;
|
@synthesize showUpdateAlertTimer;
|
||||||
|
|
||||||
- (void)showUpdateAlert
|
- (void)showUpdateAlert
|
||||||
{
|
{
|
||||||
self.interruptible = NO;
|
self.interruptible = NO;
|
||||||
|
[self invalidateShowUpdateAlertTimer];
|
||||||
|
|
||||||
|
if (self.alert) {
|
||||||
|
[self.alert close];
|
||||||
|
}
|
||||||
|
|
||||||
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) {
|
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) {
|
||||||
[self automaticUpdateAlertFinishedWithChoice:choice];
|
[self automaticUpdateAlertFinishedWithChoice:choice];
|
||||||
}];
|
}];
|
||||||
@@ -49,7 +62,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
// If the app is a menubar app or the like, we need to focus it first and alter the
|
// 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
|
// 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.
|
// there may be no way for the application to be activated to make it visible again.
|
||||||
if ([self.host isBackgroundApplication]) {
|
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
|
||||||
[[self.alert window] setHidesOnDeactivate:NO];
|
[[self.alert window] setHidesOnDeactivate:NO];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
}
|
}
|
||||||
@@ -60,7 +73,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
- (void)unarchiverDidFinish:(id)__unused ua
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
|
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
|
||||||
@@ -71,7 +84,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
self.willUpdateOnTermination = YES;
|
self.willUpdateOnTermination = YES;
|
||||||
|
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)])
|
||||||
{
|
{
|
||||||
BOOL relaunch = YES;
|
BOOL relaunch = YES;
|
||||||
@@ -81,7 +95,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
[invocation setArgument:&relaunch atIndex:2];
|
[invocation setArgument:&relaunch atIndex:2];
|
||||||
[invocation setArgument:&showUI atIndex:3];
|
[invocation setArgument:&showUI atIndex:3];
|
||||||
[invocation setTarget:self];
|
[invocation setTarget:self];
|
||||||
|
|
||||||
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +113,18 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL)resumeUpdateInteractively {
|
||||||
|
if ([self isInterruptible]) {
|
||||||
|
[self showUpdateAlert];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
-(BOOL)downloadsUpdatesInBackground {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)stopUpdatingOnTermination
|
- (void)stopUpdatingOnTermination
|
||||||
{
|
{
|
||||||
if (self.willUpdateOnTermination)
|
if (self.willUpdateOnTermination)
|
||||||
@@ -111,7 +137,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
self.willUpdateOnTermination = NO;
|
self.willUpdateOnTermination = NO;
|
||||||
|
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)])
|
||||||
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
|
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
|
||||||
}
|
}
|
||||||
@@ -131,6 +158,9 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
- (void)abortUpdate
|
- (void)abortUpdate
|
||||||
{
|
{
|
||||||
|
[self.alert close];
|
||||||
|
|
||||||
|
self.isTerminating = NO;
|
||||||
[self stopUpdatingOnTermination];
|
[self stopUpdatingOnTermination];
|
||||||
[self invalidateShowUpdateAlertTimer];
|
[self invalidateShowUpdateAlertTimer];
|
||||||
[super abortUpdate];
|
[super abortUpdate];
|
||||||
@@ -144,6 +174,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
|
||||||
{
|
{
|
||||||
|
self.alert = nil;
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case SUInstallNowChoice:
|
case SUInstallNowChoice:
|
||||||
@@ -153,8 +184,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
case SUInstallLaterChoice:
|
case SUInstallLaterChoice:
|
||||||
self.postponingInstallation = YES;
|
self.postponingInstallation = YES;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
|
|
||||||
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
|
|
||||||
// We're already waiting on quit, just indicate that we're idle.
|
// We're already waiting on quit, just indicate that we're idle.
|
||||||
self.interruptible = YES;
|
self.interruptible = YES;
|
||||||
break;
|
break;
|
||||||
@@ -166,6 +195,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||||
{
|
{
|
||||||
if (relaunch) {
|
if (relaunch) {
|
||||||
@@ -185,9 +215,22 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
|
|
||||||
- (void)applicationWillTerminate:(NSNotification *)__unused note
|
- (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];
|
[self installWithToolAndRelaunch:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)terminateApp
|
||||||
|
{
|
||||||
|
if (!self.isTerminating) {
|
||||||
|
[super terminateApp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)abortUpdateWithError:(NSError *)error
|
- (void)abortUpdateWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
if (self.showErrors) {
|
if (self.showErrors) {
|
||||||
@@ -195,7 +238,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
|
|||||||
} else {
|
} else {
|
||||||
// Call delegate separately here because otherwise it won't know we stopped.
|
// Call delegate separately here because otherwise it won't know we stopped.
|
||||||
// Normally this gets called by the superclass
|
// Normally this gets called by the superclass
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
||||||
[updaterDelegate updater:self.updater didAbortWithError:error];
|
[updaterDelegate updater:self.updater didAbortWithError:error];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,10 @@
|
|||||||
#ifndef SUBASICUPDATEDRIVER_H
|
#ifndef SUBASICUPDATEDRIVER_H
|
||||||
#define SUBASICUPDATEDRIVER_H
|
#define SUBASICUPDATEDRIVER_H
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import "SUUpdateDriver.h"
|
#import "SUUpdateDriver.h"
|
||||||
#import "SUUnarchiver.h"
|
|
||||||
#import "SUAppcast.h"
|
|
||||||
|
|
||||||
@class SUAppcastItem, SUHost;
|
@class SUAppcast, SUAppcastItem, SUHost;
|
||||||
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate>
|
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate>
|
||||||
|
|
||||||
@property (strong, readonly) SUAppcastItem *updateItem;
|
@property (strong, readonly) SUAppcastItem *updateItem;
|
||||||
@property (strong, readonly) NSURLDownload *download;
|
@property (strong, readonly) NSURLDownload *download;
|
||||||
@@ -24,7 +21,7 @@
|
|||||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
|
||||||
|
|
||||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
|
||||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
|
||||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
|
||||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
|
||||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
|
||||||
@@ -37,10 +34,12 @@
|
|||||||
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error;
|
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error;
|
||||||
|
|
||||||
- (void)extractUpdate;
|
- (void)extractUpdate;
|
||||||
- (void)unarchiverDidFinish:(SUUnarchiver *)ua;
|
|
||||||
- (void)unarchiverDidFail:(SUUnarchiver *)ua;
|
|
||||||
- (void)failedToApplyDeltaUpdate;
|
- (void)failedToApplyDeltaUpdate;
|
||||||
|
|
||||||
|
// Needed to preserve compatibility to subclasses, even though our unarchiver code uses blocks now
|
||||||
|
- (void)unarchiver:(id)ua extractedProgress:(double)progress;
|
||||||
|
- (void)unarchiverDidFinish:(id)ua;
|
||||||
|
|
||||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
|
- (void)installWithToolAndRelaunch:(BOOL)relaunch;
|
||||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
|
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI;
|
||||||
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
|
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
|
||||||
|
|||||||
@@ -8,18 +8,22 @@
|
|||||||
|
|
||||||
#import "SUBasicUpdateDriver.h"
|
#import "SUBasicUpdateDriver.h"
|
||||||
|
|
||||||
|
#import "SUUnarchiverProtocol.h"
|
||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
#import "SUDSAVerifier.h"
|
#import "SUOperatingSystem.h"
|
||||||
#import "SUInstaller.h"
|
|
||||||
#import "SUStandardVersionComparator.h"
|
#import "SUStandardVersionComparator.h"
|
||||||
#import "SUUnarchiver.h"
|
#import "SUUnarchiver.h"
|
||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
#import "SUPlainInstaller.h"
|
|
||||||
#import "SUPlainInstallerInternals.h"
|
|
||||||
#import "SUBinaryDeltaCommon.h"
|
#import "SUBinaryDeltaCommon.h"
|
||||||
#import "SUCodeSigningVerifier.h"
|
#import "SUUpdaterPrivate.h"
|
||||||
#import "SUUpdater_Private.h"
|
#import "SUUpdaterDelegate.h"
|
||||||
|
#import "SUFileManager.h"
|
||||||
|
#import "SUUpdateValidator.h"
|
||||||
|
#import "SULocalizations.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
#import "SUAppcast.h"
|
||||||
|
#import "SUAppcastItem.h"
|
||||||
|
|
||||||
@interface SUBasicUpdateDriver ()
|
@interface SUBasicUpdateDriver ()
|
||||||
|
|
||||||
@@ -31,6 +35,8 @@
|
|||||||
@property (copy) NSString *tempDir;
|
@property (copy) NSString *tempDir;
|
||||||
@property (copy) NSString *relaunchPath;
|
@property (copy) NSString *relaunchPath;
|
||||||
|
|
||||||
|
@property (nonatomic) SUUpdateValidator *updateValidator;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUBasicUpdateDriver
|
@implementation SUBasicUpdateDriver
|
||||||
@@ -43,6 +49,8 @@
|
|||||||
@synthesize tempDir;
|
@synthesize tempDir;
|
||||||
@synthesize relaunchPath;
|
@synthesize relaunchPath;
|
||||||
|
|
||||||
|
@synthesize updateValidator = _updateValidator;
|
||||||
|
|
||||||
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
|
||||||
{
|
{
|
||||||
[super checkForUpdatesAtURL:URL host:aHost];
|
[super checkForUpdatesAtURL:URL host:aHost];
|
||||||
@@ -54,9 +62,10 @@
|
|||||||
|
|
||||||
SUAppcast *appcast = [[SUAppcast alloc] init];
|
SUAppcast *appcast = [[SUAppcast alloc] init];
|
||||||
|
|
||||||
[appcast setUserAgentString:[self.updater userAgentString]];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
[appcast setHttpHeaders:[self.updater httpHeaders]];
|
[appcast setUserAgentString:[updater userAgentString]];
|
||||||
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
|
[appcast setHttpHeaders:[updater httpHeaders]];
|
||||||
|
[appcast fetchAppcastFromURL:URL inBackground:self.downloadsAppcastInBackground completionBlock:^(NSError *error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
[self abortUpdateWithError:error];
|
[self abortUpdateWithError:error];
|
||||||
} else {
|
} else {
|
||||||
@@ -68,44 +77,68 @@
|
|||||||
- (id<SUVersionComparison>)versionComparator
|
- (id<SUVersionComparison>)versionComparator
|
||||||
{
|
{
|
||||||
id<SUVersionComparison> comparator = nil;
|
id<SUVersionComparison> comparator = nil;
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
// Give the delegate a chance to provide a custom version comparator
|
// Give the delegate a chance to provide a custom version comparator
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
|
||||||
comparator = [[self.updater delegate] versionComparatorForUpdater:self.updater];
|
comparator = [[updater delegate] versionComparatorForUpdater:self.updater];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't get a comparator from the delegate, use the default comparator
|
// If we don't get a comparator from the delegate, use the default comparator
|
||||||
if (!comparator) {
|
if (!comparator) {
|
||||||
comparator = [SUStandardVersionComparator defaultComparator];
|
comparator = [[SUStandardVersionComparator alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
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:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
SUAppcastItem *item = nil;
|
||||||
|
for(SUAppcastItem *candidate in appcastItems) {
|
||||||
|
if ([[self class] hostSupportsItem:candidate]) {
|
||||||
|
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||||
|
item = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item && deltaItem) {
|
||||||
|
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||||
|
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
|
||||||
|
*deltaItem = deltaUpdateItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||||
{
|
{
|
||||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
|
||||||
|
|
||||||
BOOL minimumVersionOK = TRUE;
|
BOOL minimumVersionOK = TRUE;
|
||||||
BOOL maximumVersionOK = TRUE;
|
BOOL maximumVersionOK = TRUE;
|
||||||
|
|
||||||
|
id<SUVersionComparison> versionComparator = [[SUStandardVersionComparator alloc] init];
|
||||||
|
|
||||||
// Check minimum and maximum System Version
|
// Check minimum and maximum System Version
|
||||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||||
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending;
|
minimumVersionOK = [versionComparator compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
|
||||||
}
|
}
|
||||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||||
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending;
|
maximumVersionOK = [versionComparator compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||||
}
|
}
|
||||||
|
|
||||||
return minimumVersionOK && maximumVersionOK;
|
return minimumVersionOK && maximumVersionOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||||
|
{
|
||||||
|
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||||
{
|
{
|
||||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||||
@@ -115,35 +148,40 @@
|
|||||||
|
|
||||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||||
{
|
{
|
||||||
return ui && [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
- (void)appcastDidFinishLoading:(SUAppcast *)ac
|
||||||
{
|
{
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
[[self.updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
|
if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
|
||||||
|
[[updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary *userInfo = (ac != nil) ? @{ SUUpdaterAppcastNotificationKey: ac } : nil;
|
NSDictionary *userInfo = @{ SUUpdaterAppcastNotificationKey: ac };
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo];
|
||||||
|
|
||||||
SUAppcastItem *item = nil;
|
SUAppcastItem *item = nil;
|
||||||
|
|
||||||
// Now we have to find the best valid update in the appcast.
|
// 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?
|
if ([[updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
|
||||||
{
|
{
|
||||||
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
item = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
|
||||||
}
|
}
|
||||||
else // If not, we'll take care of it ourselves.
|
|
||||||
|
if (item != nil) // Does the delegate want to handle it?
|
||||||
{
|
{
|
||||||
// Find the first update we can actually use.
|
if ([item isDeltaUpdate]) {
|
||||||
NSEnumerator *updateEnumerator = [[ac items] objectEnumerator];
|
self.nonDeltaUpdateItem = [[updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
|
||||||
do {
|
}
|
||||||
item = [updateEnumerator nextObject];
|
}
|
||||||
} while (item && ![self hostSupportsItem:item]);
|
else // If not, we'll take care of it ourselves.
|
||||||
|
{
|
||||||
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]];
|
// Find the best supported update
|
||||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
SUAppcastItem *deltaUpdateItem = nil;
|
||||||
|
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||||
|
|
||||||
|
if (item && deltaUpdateItem) {
|
||||||
self.nonDeltaUpdateItem = item;
|
self.nonDeltaUpdateItem = item;
|
||||||
item = deltaUpdateItem;
|
item = deltaUpdateItem;
|
||||||
}
|
}
|
||||||
@@ -161,9 +199,11 @@
|
|||||||
- (void)didFindValidUpdate
|
- (void)didFindValidUpdate
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
|
||||||
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
[[updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
|
||||||
@@ -174,8 +214,10 @@
|
|||||||
|
|
||||||
- (void)didNotFindUpdate
|
- (void)didNotFindUpdate
|
||||||
{
|
{
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
|
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
|
||||||
|
[[updater delegate] updaterDidNotFindUpdate:self.updater];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
|
||||||
@@ -187,12 +229,46 @@
|
|||||||
}]];
|
}]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)appCachePath
|
||||||
|
{
|
||||||
|
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||||
|
NSString *cachePath = nil;
|
||||||
|
if ([cachePaths count]) {
|
||||||
|
cachePath = [cachePaths objectAtIndex:0];
|
||||||
|
}
|
||||||
|
if (!cachePath) {
|
||||||
|
SULog(SULogLevelError, @"Failed to find user's cache directory! Using system default");
|
||||||
|
cachePath = NSTemporaryDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *name = [self.host.bundle bundleIdentifier];
|
||||||
|
if (!name) {
|
||||||
|
name = [self.host name];
|
||||||
|
}
|
||||||
|
|
||||||
|
cachePath = [cachePath stringByAppendingPathComponent:name];
|
||||||
|
cachePath = [cachePath stringByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER];
|
||||||
|
return cachePath;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)downloadUpdate
|
- (void)downloadUpdate
|
||||||
{
|
{
|
||||||
|
// Clear cache directory so that downloads can't possibly accumulate inside
|
||||||
|
NSString *appCachePath = [self appCachePath];
|
||||||
|
if ([[NSFileManager defaultManager] fileExistsAtPath:appCachePath]) {
|
||||||
|
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
|
||||||
|
}
|
||||||
|
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
|
||||||
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
if (self.downloadsUpdatesInBackground) {
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
|
request.networkServiceType = NSURLNetworkServiceTypeBackground;
|
||||||
[[self.updater delegate] updater:self.updater
|
}
|
||||||
|
|
||||||
|
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
|
||||||
|
[[updater delegate] updater:self.updater
|
||||||
willDownloadUpdate:self.updateItem
|
willDownloadUpdate:self.updateItem
|
||||||
withRequest:request];
|
withRequest:request];
|
||||||
}
|
}
|
||||||
@@ -202,13 +278,14 @@
|
|||||||
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
|
||||||
{
|
{
|
||||||
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
|
||||||
|
|
||||||
|
NSString *appCachePath = [self appCachePath];
|
||||||
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:downloadFileName];
|
|
||||||
|
self.tempDir = [appCachePath stringByAppendingPathComponent:downloadFileName];
|
||||||
int cnt = 1;
|
int cnt = 1;
|
||||||
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
|
||||||
{
|
{
|
||||||
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
self.tempDir = [appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the temporary directory if necessary.
|
// Create the temporary directory if necessary.
|
||||||
@@ -224,83 +301,6 @@
|
|||||||
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
[self.download setDestination:self.downloadPath allowOverwrite:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If the update is a package, then it must be signed using DSA. No other verification is done.
|
|
||||||
*
|
|
||||||
* If the update is a bundle, then it must meet any one of:
|
|
||||||
*
|
|
||||||
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
|
|
||||||
*
|
|
||||||
* * old and new Code Signing identity are the same and valid
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
|
|
||||||
{
|
|
||||||
BOOL isPackage = NO;
|
|
||||||
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
|
|
||||||
if (installSourcePath == nil) {
|
|
||||||
SULog(@"No suitable install is found in the update. The update will be rejected.");
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modern packages are not distributed as bundles and are code signed differently than regular applications
|
|
||||||
if (isPackage) {
|
|
||||||
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
|
||||||
|
|
||||||
if (!packageValidated) {
|
|
||||||
SULog(@"DSA signature validation of the package failed. The update will be rejected.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return packageValidated;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
|
|
||||||
if (newBundle == nil) {
|
|
||||||
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
|
||||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
|
||||||
|
|
||||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
|
||||||
|
|
||||||
if (newPublicDSAKey != nil) {
|
|
||||||
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
|
||||||
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
|
||||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath];
|
|
||||||
|
|
||||||
if (dsaKeysMatch) {
|
|
||||||
NSError *error = nil;
|
|
||||||
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) {
|
|
||||||
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
|
|
||||||
|
|
||||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
|
||||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
|
||||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
|
||||||
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSError *error = nil;
|
|
||||||
if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) {
|
|
||||||
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
- (void)downloadDidFinish:(NSURLDownload *)__unused d
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
@@ -310,22 +310,28 @@
|
|||||||
|
|
||||||
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
|
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
|
||||||
if (!failingUrl) {
|
if (!failingUrl) {
|
||||||
failingUrl = [self.updateItem fileURL];
|
failingUrl = [self.updateItem fileURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
[[self.updater delegate] updater:self.updater
|
|
||||||
|
if ([[updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
|
||||||
|
[[updater delegate] updater:self.updater
|
||||||
failedToDownloadUpdate:self.updateItem
|
failedToDownloadUpdate:self.updateItem
|
||||||
error:error];
|
error:error];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
|
||||||
NSUnderlyingErrorKey: error,
|
NSUnderlyingErrorKey: error,
|
||||||
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
|
}];
|
||||||
}]];
|
if (failingUrl) {
|
||||||
|
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
|
||||||
@@ -337,14 +343,38 @@
|
|||||||
|
|
||||||
- (void)extractUpdate
|
- (void)extractUpdate
|
||||||
{
|
{
|
||||||
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath]];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||||
|
|
||||||
|
BOOL success;
|
||||||
if (!unarchiver) {
|
if (!unarchiver) {
|
||||||
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
|
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||||
[self unarchiverDidFail:nil];
|
|
||||||
return;
|
success = NO;
|
||||||
|
} else {
|
||||||
|
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
|
||||||
|
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated];
|
||||||
|
|
||||||
|
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
|
||||||
|
|
||||||
|
success = self.updateValidator.canValidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
|
||||||
|
[self unarchiverDidFailWithError:reason];
|
||||||
|
} else {
|
||||||
|
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
|
||||||
|
if (err) {
|
||||||
|
[self unarchiverDidFailWithError:err];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[self unarchiverDidFinish:nil];
|
||||||
|
} progressBlock:^(double progress) {
|
||||||
|
[self unarchiver:nil extractedProgress:progress];
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
unarchiver.delegate = self;
|
|
||||||
[unarchiver start];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)failedToApplyDeltaUpdate
|
- (void)failedToApplyDeltaUpdate
|
||||||
@@ -356,21 +386,30 @@
|
|||||||
[self downloadUpdate];
|
[self downloadUpdate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
|
// By default does nothing, can be overridden
|
||||||
|
- (void)unarchiver:(id)__unused ua extractedProgress:(double)__unused progress
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note this method can be overridden (and is)
|
||||||
|
- (void)unarchiverDidFinish:(id)__unused ua
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
|
||||||
[self installWithToolAndRelaunch:YES];
|
[self installWithToolAndRelaunch:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
|
- (void)unarchiverDidFailWithError:(NSError *)err
|
||||||
{
|
{
|
||||||
|
// No longer needed
|
||||||
|
self.updateValidator = nil;
|
||||||
|
|
||||||
if ([self.updateItem isDeltaUpdate]) {
|
if ([self.updateItem isDeltaUpdate]) {
|
||||||
[self failedToApplyDeltaUpdate];
|
[self failedToApplyDeltaUpdate];
|
||||||
return;
|
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:err];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||||
@@ -379,29 +418,62 @@
|
|||||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
[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;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)mayUpdateAndRestart
|
||||||
|
{
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
return (!updater.delegate || ![updater.delegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [updater.delegate updaterShouldRelaunchApplication:self.updater]);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
|
||||||
{
|
{
|
||||||
assert(self.updateItem);
|
assert(self.updateItem);
|
||||||
|
assert(self.updateValidator);
|
||||||
if (![self validateUpdateDownloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature publicDSAKey:self.host.publicDSAKey])
|
|
||||||
{
|
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
||||||
|
if (!validationCheckSuccess) {
|
||||||
NSDictionary *userInfo = @{
|
NSDictionary *userInfo = @{
|
||||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||||
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
|
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
|
||||||
};
|
};
|
||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
|
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![self.updater mayUpdateAndRestart])
|
if (![self mayUpdateAndRestart])
|
||||||
{
|
{
|
||||||
[self abortUpdate];
|
[self abortUpdate];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give the host app an opportunity to postpone the install and relaunch.
|
// Give the host app an opportunity to postpone the install and relaunch.
|
||||||
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
static BOOL postponedOnce = NO;
|
static BOOL postponedOnce = NO;
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
|
||||||
{
|
{
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
|
||||||
@@ -419,28 +491,48 @@
|
|||||||
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSBundle *sparkleBundle = self.updater.sparkleBundle;
|
NSBundle *sparkleBundle = updater.sparkleBundle;
|
||||||
|
|
||||||
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
|
||||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
||||||
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
|
||||||
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
|
||||||
if (relaunchPathToCopy != nil) {
|
NSString *relaunchCopyTargetPath = nil;
|
||||||
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
NSError *error = nil;
|
||||||
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
|
BOOL copiedRelaunchPath = NO;
|
||||||
NSError *error = nil;
|
|
||||||
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];
|
if (relaunchToolSourcePath) {
|
||||||
|
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
|
||||||
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
|
|
||||||
self.relaunchPath = targetPath;
|
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||||
} else {
|
|
||||||
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
NSURL *relaunchToolSourceURL = [NSURL fileURLWithPath:relaunchToolSourcePath];
|
||||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
NSURL *relaunchCopyTargetURL = [NSURL fileURLWithPath:relaunchCopyTargetPath];
|
||||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
|
|
||||||
}]];
|
// 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(SULogLevelError, @"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!copiedRelaunchPath) {
|
||||||
|
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
|
||||||
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||||
|
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@",
|
||||||
|
relaunchToolSourcePath, relaunchCopyTargetPath, (error ? [error localizedDescription] : @"")],
|
||||||
|
}]];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.relaunchPath = relaunchCopyTargetPath; // Set for backwards compatibility, in case any delegates modify it
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
|
||||||
[updaterDelegate updaterWillRelaunchApplication:self.updater];
|
[updaterDelegate updaterWillRelaunchApplication:self.updater];
|
||||||
@@ -450,16 +542,19 @@
|
|||||||
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
|
// 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:@{
|
[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]],
|
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
|
||||||
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]
|
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@ and %@)", relaunchToolSourcePath, self.relaunchPath],
|
||||||
}]];
|
}]];
|
||||||
// We intentionally don't abandon the update here so that the host won't initiate another.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *pathToRelaunch = [self.host bundlePath];
|
NSString *pathToRelaunch = [self.host bundlePath];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
|
||||||
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
|
NSString *delegateRelaunchPath = [updaterDelegate pathToRelaunchForUpdater:self.updater];
|
||||||
|
if (delegateRelaunchPath != nil) {
|
||||||
|
pathToRelaunch = delegateRelaunchPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
|
||||||
pathToRelaunch,
|
pathToRelaunch,
|
||||||
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
|
||||||
@@ -469,6 +564,7 @@
|
|||||||
[self terminateApp];
|
[self terminateApp];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: this is overridden by the automatic update driver to not terminate in some cases
|
||||||
- (void)terminateApp
|
- (void)terminateApp
|
||||||
{
|
{
|
||||||
[NSApp terminate:self];
|
[NSApp terminate:self];
|
||||||
@@ -511,14 +607,20 @@
|
|||||||
- (void)abortUpdateWithError:(NSError *)error
|
- (void)abortUpdateWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
|
||||||
SULog(@"Error: %@ %@ (URL %@)", error.localizedDescription, error.localizedFailureReason, error.userInfo[NSURLErrorFailingURLErrorKey]);
|
NSError *errorToDisplay = error;
|
||||||
|
int finiteRecursion=5;
|
||||||
|
do {
|
||||||
|
SULog(SULogLevelError, @"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, [errorToDisplay.userInfo objectForKey:NSURLErrorFailingURLErrorKey]);
|
||||||
|
errorToDisplay = [errorToDisplay.userInfo objectForKey:NSUnderlyingErrorKey];
|
||||||
|
} while(--finiteRecursion && errorToDisplay);
|
||||||
}
|
}
|
||||||
if (self.download) {
|
if (self.download) {
|
||||||
[self.download cancel];
|
[self.download cancel];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify host app that update has aborted
|
// Notify host app that update has aborted
|
||||||
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
|
id<SUUpdaterPrivate> updater = self.updater;
|
||||||
|
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
|
||||||
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
|
||||||
[updaterDelegate updater:self.updater didAbortWithError:error];
|
[updaterDelegate updater:self.updater didAbortWithError:error];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
#ifndef SUBINARYDELTAAPPLY_H
|
#ifndef SUBINARYDELTAAPPLY_H
|
||||||
#define SUBINARYDELTAAPPLY_H
|
#define SUBINARYDELTAAPPLY_H
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@class NSString;
|
@class NSString;
|
||||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose);
|
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double), NSError * __autoreleasing *error);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -15,119 +15,160 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <xar/xar.h>
|
#include <xar/xar.h>
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
static BOOL 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");
|
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
|
||||||
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
|
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
|
||||||
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
|
const char *argv[] = { "/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation] };
|
||||||
BOOL success = (bspatch(4, argv) == 0);
|
BOOL success = (bspatch(4, argv) == 0);
|
||||||
unlink([patchFile fileSystemRepresentation]);
|
unlink([patchFile fileSystemRepresentation]);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose)
|
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
|
||||||
{
|
{
|
||||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||||
if (!x) {
|
if (!x) {
|
||||||
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile fileSystemRepresentation]);
|
if (error != NULL) {
|
||||||
return 1;
|
*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;
|
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||||
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
|
int minorDiffVersion = 0;
|
||||||
|
|
||||||
NSString *expectedBeforeHashv1 = nil;
|
NSString *expectedBeforeHashv1 = nil;
|
||||||
NSString *expectedAfterHashv1 = nil;
|
NSString *expectedAfterHashv1 = nil;
|
||||||
|
|
||||||
NSString *expectedNewBeforeHash = nil;
|
NSString *expectedNewBeforeHash = nil;
|
||||||
NSString *expectedNewAfterHash = nil;
|
NSString *expectedNewAfterHash = nil;
|
||||||
|
|
||||||
|
progressCallback(0/6.0);
|
||||||
|
|
||||||
xar_subdoc_t subdoc;
|
xar_subdoc_t subdoc;
|
||||||
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||||
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
||||||
const char *value = 0;
|
const char *value = 0;
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
|
minorDiffVersion = [@(value) intValue];
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
|
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
expectedNewBeforeHash = @(value);
|
expectedNewBeforeHash = @(value);
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
|
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
expectedNewAfterHash = @(value);
|
expectedNewAfterHash = @(value);
|
||||||
|
|
||||||
// only available in version 1.0
|
// only available in version 1.0
|
||||||
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_OLD_KEY, &value);
|
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_OLD_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
expectedBeforeHashv1 = @(value);
|
expectedBeforeHashv1 = @(value);
|
||||||
|
|
||||||
// only available in version 1.0
|
// only available in version 1.0
|
||||||
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_OLD_KEY, &value);
|
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_OLD_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
expectedAfterHashv1 = @(value);
|
expectedAfterHashv1 = @(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||||
fprintf(stderr, "Unable to identify diff-version %u in delta. Giving up.\n", majorDiffVersion);
|
if (error != NULL) {
|
||||||
return 1;
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.", majorDiffVersion] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
||||||
fprintf(stderr, "A later version is needed to apply this patch (on major version %u, but patch requests version %u).\n", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion);
|
if (error != NULL) {
|
||||||
return 1;
|
*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);
|
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||||
|
|
||||||
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
|
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
|
||||||
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
|
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
|
||||||
|
|
||||||
if (!expectedBeforeHash || !expectedAfterHash) {
|
if (!expectedBeforeHash || !expectedAfterHash) {
|
||||||
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
|
if (error != NULL) {
|
||||||
return 1;
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
|
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
|
||||||
fprintf(stderr, "Verifying source...");
|
fprintf(stderr, "Verifying source...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressCallback(1/6.0);
|
||||||
|
|
||||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
|
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
|
||||||
if (!beforeHash) {
|
if (!beforeHash) {
|
||||||
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [source fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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]) {
|
if (![beforeHash isEqualToString:expectedBeforeHash]) {
|
||||||
fprintf(stderr, "\nSource doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
|
if (verbose) {
|
||||||
return 1;
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", expectedBeforeHash, beforeHash] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nCopying files...");
|
fprintf(stderr, "\nCopying files...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressCallback(2/6.0);
|
||||||
|
|
||||||
if (!removeTree(destination)) {
|
if (!removeTree(destination)) {
|
||||||
fprintf(stderr, "\nFailed to remove %s\n", [destination fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressCallback(3/6.0);
|
||||||
|
|
||||||
if (!copyTree(source, destination)) {
|
if (!copyTree(source, destination)) {
|
||||||
fprintf(stderr, "\nFailed to copy %s to %s\n", [source fileSystemRepresentation], [destination fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressCallback(4/6.0);
|
||||||
|
|
||||||
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@@ -144,13 +185,17 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
|||||||
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
|
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
|
||||||
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
|
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
|
||||||
BOOL removedFile = NO;
|
BOOL removedFile = NO;
|
||||||
|
|
||||||
const char *value;
|
const char *value;
|
||||||
if (!xar_prop_get(file, DELETE_KEY, &value) ||
|
if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
|
||||||
if (!removeTree(destinationFilePath)) {
|
if (!removeTree(destinationFilePath)) {
|
||||||
fprintf(stderr, "\n%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_OLD_KEY, [destination fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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 (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@@ -158,27 +203,36 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
removedFile = YES;
|
removedFile = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
|
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
|
||||||
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) {
|
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) {
|
||||||
fprintf(stderr, "\nUnable to patch %s to destination %s\n", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
|
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) ||
|
} 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
|
||||||
(!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 (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) {
|
||||||
fprintf(stderr, "\nUnable to extract file to %s\n", [destinationFilePath fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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 (verbose) {
|
||||||
if (fileExisted) {
|
if (fileExisted) {
|
||||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
|
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
|
||||||
@@ -189,14 +243,19 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
|||||||
} else if (verbose && removedFile) {
|
} else if (verbose && removedFile) {
|
||||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
||||||
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
|
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
|
||||||
if (!modifyPermissions(destinationFilePath, mode)) {
|
if (!modifyPermissions(destinationFilePath, mode)) {
|
||||||
fprintf(stderr, "\nUnable to modify permissions (%s) on file %s\n", value, [destinationFilePath fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
|
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
|
||||||
}
|
}
|
||||||
@@ -204,23 +263,37 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
|||||||
}
|
}
|
||||||
xar_close(x);
|
xar_close(x);
|
||||||
|
|
||||||
|
progressCallback(5/6.0);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nVerifying destination...");
|
fprintf(stderr, "\nVerifying destination...");
|
||||||
}
|
}
|
||||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
|
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
|
||||||
if (!afterHash) {
|
if (!afterHash) {
|
||||||
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [destination fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", destination] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![afterHash isEqualToString:expectedAfterHash]) {
|
if (![afterHash isEqualToString:expectedAfterHash]) {
|
||||||
fprintf(stderr, "\nDestination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
|
if (verbose) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", expectedAfterHash, afterHash] }];
|
||||||
|
}
|
||||||
removeTree(destination);
|
removeTree(destination);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressCallback(6/6.0);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nDone!\n");
|
fprintf(stderr, "\nDone!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -57,16 +57,7 @@ typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
|
|||||||
SUBeigeMajorVersion = 2
|
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_MAJOR_VERSION SUAzureMajorVersion
|
||||||
#define FIRST_DELTA_DIFF_MINOR_VERSION ((SUBinaryDeltaMinorVersion)0)
|
|
||||||
|
|
||||||
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
|
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
|
||||||
|
|
||||||
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
extern int compareFiles(const FTSENT **a, const FTSENT **b);
|
||||||
@@ -80,5 +71,5 @@ extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
|
|||||||
NSString *temporaryFilename(NSString *base);
|
NSString *temporaryFilename(NSString *base);
|
||||||
NSString *temporaryDirectory(NSString *base);
|
NSString *temporaryDirectory(NSString *base);
|
||||||
NSString *stringWithFileSystemRepresentation(const char*);
|
NSString *stringWithFileSystemRepresentation(const char*);
|
||||||
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
|
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
|
||||||
#endif
|
#endif
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "SUBinaryDeltaCommon.h"
|
#include "SUBinaryDeltaCommon.h"
|
||||||
|
#import "SUFileManager.h"
|
||||||
#include <CommonCrypto/CommonDigest.h>
|
#include <CommonCrypto/CommonDigest.h>
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <xar/xar.h>
|
#include <xar/xar.h>
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
int compareFiles(const FTSENT **a, const FTSENT **b)
|
int compareFiles(const FTSENT **a, const FTSENT **b)
|
||||||
{
|
{
|
||||||
return strcoll((*a)->fts_name, (*b)->fts_name);
|
return strcoll((*a)->fts_name, (*b)->fts_name);
|
||||||
@@ -31,19 +34,20 @@ NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *stringWithFileSystemRepresentation(const char *input) {
|
NSString *stringWithFileSystemRepresentation(const char *input)
|
||||||
|
{
|
||||||
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
|
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
|
||||||
{
|
{
|
||||||
switch (majorVersion) {
|
switch (majorVersion) {
|
||||||
case SUAzureMajorVersion:
|
case SUAzureMajorVersion:
|
||||||
return SUAzureMinorVersion;
|
return 1;
|
||||||
case SUBeigeMajorVersion:
|
case SUBeigeMajorVersion:
|
||||||
return SUBeigeMinorVersion;
|
return 2;
|
||||||
}
|
}
|
||||||
return (SUBinaryDeltaMinorVersion)0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *temporaryFilename(NSString *base)
|
NSString *temporaryFilename(NSString *base)
|
||||||
@@ -72,18 +76,18 @@ NSString *temporaryDirectory(NSString *base)
|
|||||||
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
|
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
|
||||||
NSMutableData *data = [NSMutableData data];
|
NSMutableData *data = [NSMutableData data];
|
||||||
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
|
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
|
||||||
|
|
||||||
char *buffer = data.mutableBytes;
|
char *buffer = data.mutableBytes;
|
||||||
char *templateResult = mkdtemp(buffer);
|
char *templateResult = mkdtemp(buffer);
|
||||||
if (templateResult == NULL) {
|
if (templateResult == NULL) {
|
||||||
perror("mkdtemp");
|
perror("mkdtemp");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringWithFileSystemRepresentation(templateResult);
|
return stringWithFileSystemRepresentation(templateResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)
|
static void _hashOfBuffer(unsigned char *hash, const char *buffer, ssize_t bufferLength)
|
||||||
{
|
{
|
||||||
assert(bufferLength >= 0 && bufferLength <= UINT32_MAX);
|
assert(bufferLength >= 0 && bufferLength <= UINT32_MAX);
|
||||||
CC_SHA1_CTX hashContext;
|
CC_SHA1_CTX hashContext;
|
||||||
@@ -92,7 +96,7 @@ static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t buffe
|
|||||||
CC_SHA1_Final(hash, &hashContext);
|
CC_SHA1_Final(hash, &hashContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
|
static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
|
||||||
{
|
{
|
||||||
if (ent->fts_info == FTS_SL) {
|
if (ent->fts_info == FTS_SL) {
|
||||||
char linkDestination[MAXPATHLEN + 1];
|
char linkDestination[MAXPATHLEN + 1];
|
||||||
@@ -115,12 +119,12 @@ static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
|
|||||||
_hashOfBuffer(hash, NULL, 0);
|
_hashOfBuffer(hash, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
|
||||||
if (buffer == (void*)-1) {
|
if (buffer == (void *)-1) {
|
||||||
close(fileDescriptor);
|
close(fileDescriptor);
|
||||||
perror("mmap");
|
perror("mmap");
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hashOfBuffer(hash, buffer, fileSize);
|
_hashOfBuffer(hash, buffer, fileSize);
|
||||||
munmap(buffer, (size_t)fileSize);
|
munmap(buffer, (size_t)fileSize);
|
||||||
}
|
}
|
||||||
@@ -144,10 +148,12 @@ NSData *hashOfFileContents(FTSENT *ent)
|
|||||||
|
|
||||||
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
||||||
{
|
{
|
||||||
char pathBuffer[PATH_MAX] = {0};
|
char pathBuffer[PATH_MAX] = { 0 };
|
||||||
[path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
char * const sourcePaths[] = {pathBuffer, 0};
|
char *const sourcePaths[] = { pathBuffer, 0 };
|
||||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||||
if (!fts) {
|
if (!fts) {
|
||||||
perror("fts_open");
|
perror("fts_open");
|
||||||
@@ -157,16 +163,19 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
|||||||
CC_SHA1_CTX hashContext;
|
CC_SHA1_CTX hashContext;
|
||||||
CC_SHA1_Init(&hashContext);
|
CC_SHA1_Init(&hashContext);
|
||||||
|
|
||||||
|
// Ensure the path uses filesystem-specific Unicode normalization #1017
|
||||||
|
NSString *normalizedPath = stringWithFileSystemRepresentation(pathBuffer);
|
||||||
|
|
||||||
FTSENT *ent = 0;
|
FTSENT *ent = 0;
|
||||||
while ((ent = fts_read(fts))) {
|
while ((ent = fts_read(fts))) {
|
||||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
|
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ent->fts_info == FTS_D && !MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
if (ent->fts_info == FTS_D && !MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
|
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
|
||||||
if (relativePath.length == 0)
|
if (relativePath.length == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -178,12 +187,12 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
|
|||||||
|
|
||||||
const char *relativePathBytes = [relativePath fileSystemRepresentation];
|
const char *relativePathBytes = [relativePath fileSystemRepresentation];
|
||||||
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
|
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
|
||||||
|
|
||||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||||
uint16_t mode = ent->fts_statp->st_mode;
|
uint16_t mode = ent->fts_statp->st_mode;
|
||||||
uint16_t type = ent->fts_info;
|
uint16_t type = ent->fts_info;
|
||||||
uint16_t permissions = mode & PERMISSION_FLAGS;
|
uint16_t permissions = mode & PERMISSION_FLAGS;
|
||||||
|
|
||||||
CC_SHA1_Update(&hashContext, &type, sizeof(type));
|
CC_SHA1_Update(&hashContext, &type, sizeof(type));
|
||||||
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
|
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
|
||||||
}
|
}
|
||||||
@@ -218,7 +227,7 @@ BOOL removeTree(NSString *path)
|
|||||||
|
|
||||||
BOOL copyTree(NSString *source, NSString *dest)
|
BOOL copyTree(NSString *source, NSString *dest)
|
||||||
{
|
{
|
||||||
return [[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
|
return [[SUFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
||||||
@@ -228,12 +237,12 @@ BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
|
|||||||
if (!attributes) {
|
if (!attributes) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
NSNumber *permissions = attributes[NSFilePosixPermissions];
|
NSNumber *permissions = [attributes objectForKey:NSFilePosixPermissions];
|
||||||
if (!permissions) {
|
if (!permissions) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
|
||||||
int (*changeModeFunc)(const char *, mode_t) = [attributes[NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
int (*changeModeFunc)(const char *, mode_t) = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
|
||||||
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,6 @@
|
|||||||
#import "SUBinaryDeltaCommon.h"
|
#import "SUBinaryDeltaCommon.h"
|
||||||
|
|
||||||
@class NSString;
|
@class NSString;
|
||||||
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose);
|
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
#include <xar/xar.h>
|
#include <xar/xar.h>
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
extern int bsdiff(int argc, const char **argv);
|
extern int bsdiff(int argc, const char **argv);
|
||||||
|
|
||||||
@interface CreateBinaryDeltaOperation : NSOperation
|
@interface CreateBinaryDeltaOperation : NSOperation
|
||||||
@@ -56,7 +58,7 @@ extern int bsdiff(int argc, const char **argv);
|
|||||||
- (void)main
|
- (void)main
|
||||||
{
|
{
|
||||||
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
|
||||||
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
|
const char *argv[] = { "/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
|
||||||
int result = bsdiff(4, argv);
|
int result = bsdiff(4, argv);
|
||||||
if (!result)
|
if (!result)
|
||||||
self.resultPath = temporaryFile;
|
self.resultPath = temporaryFile;
|
||||||
@@ -75,23 +77,26 @@ static NSDictionary *infoForFile(FTSENT *ent)
|
|||||||
if (!hash) {
|
if (!hash) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
|
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
|
||||||
|
|
||||||
assert(ent->fts_statp != NULL);
|
assert(ent->fts_statp != NULL);
|
||||||
|
|
||||||
mode_t permissions = ent->fts_statp->st_mode & PERMISSION_FLAGS;
|
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)};
|
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)
|
static bool aclExists(const FTSENT *ent)
|
||||||
{
|
{
|
||||||
// OS X does not currently support ACLs for symlinks
|
// macOS does not currently support ACLs for symlinks
|
||||||
if (ent->fts_info == FTS_SL) {
|
if (ent->fts_info == FTS_SL) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
acl_t acl = acl_get_link_np(ent->fts_path, ACL_TYPE_EXTENDED);
|
acl_t acl = acl_get_link_np(ent->fts_path, ACL_TYPE_EXTENDED);
|
||||||
if (acl != NULL) {
|
if (acl != NULL) {
|
||||||
acl_entry_t entry;
|
acl_entry_t entry;
|
||||||
@@ -109,28 +114,26 @@ static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
|
|||||||
if (listSize == -1) {
|
if (listSize == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *buffer = malloc((size_t)listSize);
|
char *buffer = malloc((size_t)listSize);
|
||||||
assert(buffer != NULL);
|
assert(buffer != NULL);
|
||||||
|
|
||||||
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
|
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
|
||||||
assert(sizeBack == listSize);
|
assert(sizeBack == listSize);
|
||||||
|
|
||||||
size_t startCharacterIndex = 0;
|
size_t startCharacterIndex = 0;
|
||||||
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
|
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
|
||||||
if (buffer[characterIndex] == '\0') {
|
if (buffer[characterIndex] == '\0') {
|
||||||
char *attribute = &buffer[startCharacterIndex];
|
char *attribute = &buffer[startCharacterIndex];
|
||||||
size_t length = characterIndex - startCharacterIndex;
|
size_t length = characterIndex - startCharacterIndex;
|
||||||
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 ||
|
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) {
|
||||||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 ||
|
|
||||||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
startCharacterIndex = characterIndex + 1;
|
startCharacterIndex = characterIndex + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -138,7 +141,7 @@ static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
|
|||||||
static NSString *absolutePath(NSString *path)
|
static NSString *absolutePath(NSString *path)
|
||||||
{
|
{
|
||||||
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
|
||||||
return [[url absoluteURL] path];
|
return [[url absoluteURL] path];
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSString *temporaryPatchFile(NSString *patchFile)
|
static NSString *temporaryPatchFile(NSString *patchFile)
|
||||||
@@ -151,7 +154,7 @@ static NSString *temporaryPatchFile(NSString *patchFile)
|
|||||||
|
|
||||||
#define MIN_FILE_SIZE_FOR_CREATING_DELTA 4096
|
#define MIN_FILE_SIZE_FOR_CREATING_DELTA 4096
|
||||||
|
|
||||||
static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary *newInfo)
|
static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary *newInfo)
|
||||||
{
|
{
|
||||||
unsigned long long fileSize = [newInfo[INFO_SIZE_KEY] unsignedLongLongValue];
|
unsigned long long fileSize = [newInfo[INFO_SIZE_KEY] unsignedLongLongValue];
|
||||||
if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) {
|
if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) {
|
||||||
@@ -165,7 +168,7 @@ static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary
|
|||||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
||||||
// this is possible if just the permissions have changed
|
// this is possible if just the permissions have changed
|
||||||
return YES;
|
return YES;
|
||||||
@@ -174,7 +177,7 @@ static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL shouldDeleteThenExtract(NSDictionary* originalInfo, NSDictionary *newInfo)
|
static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *newInfo)
|
||||||
{
|
{
|
||||||
if (!originalInfo) {
|
if (!originalInfo) {
|
||||||
return NO;
|
return NO;
|
||||||
@@ -192,15 +195,15 @@ static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newIn
|
|||||||
if (!originalInfo) {
|
if (!originalInfo) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,49 +212,51 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne
|
|||||||
if (!originalInfo) {
|
if (!originalInfo) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
|
if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose)
|
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError *__autoreleasing *error)
|
||||||
{
|
{
|
||||||
if (majorVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
assert(source);
|
||||||
fprintf(stderr, "Version provided (%u) is not valid\n", majorVersion);
|
assert(destination);
|
||||||
return 1;
|
assert(patchFile);
|
||||||
}
|
assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION);
|
||||||
|
|
||||||
if (majorVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
int minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
||||||
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", majorVersion);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion);
|
|
||||||
|
|
||||||
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
char pathBuffer[PATH_MAX] = {0};
|
char pathBuffer[PATH_MAX] = { 0 };
|
||||||
[source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
if (![source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from source %@", source] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
char *sourcePaths[] = {pathBuffer, 0};
|
char *sourcePaths[] = { pathBuffer, 0 };
|
||||||
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||||
if (!fts) {
|
if (!fts) {
|
||||||
perror("fts_open");
|
if (error != NULL) {
|
||||||
return 1;
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on source: %@", @(strerror(errno))] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
||||||
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
|
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FTSENT *ent = 0;
|
FTSENT *ent = 0;
|
||||||
while ((ent = fts_read(fts))) {
|
while ((ent = fts_read(fts))) {
|
||||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||||
@@ -265,33 +270,52 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
|
|
||||||
NSDictionary *info = infoForFile(ent);
|
NSDictionary *info = infoForFile(ent);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
fprintf(stderr, "\nFailed to retrieve info for file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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;
|
originalTreeState[key] = info;
|
||||||
|
|
||||||
if (aclExists(ent)) {
|
if (aclExists(ent)) {
|
||||||
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in before-tree on file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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 (codeSignatureExtendedAttributeExists(ent)) {
|
||||||
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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);
|
fts_close(fts);
|
||||||
|
|
||||||
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
|
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
|
||||||
|
|
||||||
if (!beforeHash) {
|
if (!beforeHash) {
|
||||||
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [source fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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];
|
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
|
||||||
for (NSString *key in originalTreeState)
|
for (NSString *key in originalTreeState) {
|
||||||
{
|
|
||||||
newTreeState[key] = [NSNull null];
|
newTreeState[key] = [NSNull null];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,16 +324,25 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
}
|
}
|
||||||
|
|
||||||
pathBuffer[0] = 0;
|
pathBuffer[0] = 0;
|
||||||
[destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
if (![destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
|
||||||
|
if (verbose) {
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from destination %@", destination] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
sourcePaths[0] = pathBuffer;
|
sourcePaths[0] = pathBuffer;
|
||||||
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
|
||||||
if (!fts) {
|
if (!fts) {
|
||||||
perror("fts_open");
|
if (error != NULL) {
|
||||||
return 1;
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on destination: %@", @(strerror(errno))] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while ((ent = fts_read(fts))) {
|
while ((ent = fts_read(fts))) {
|
||||||
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
|
||||||
continue;
|
continue;
|
||||||
@@ -322,39 +355,59 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
|
|
||||||
NSDictionary *info = infoForFile(ent);
|
NSDictionary *info = infoForFile(ent);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
fprintf(stderr, "\nFailed to retrieve info from file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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,
|
// 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
|
// 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
|
// 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
|
// inside an application, and since we don't preserve extended attribitutes anyway
|
||||||
|
|
||||||
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||||
if (!IS_VALID_PERMISSIONS(permissions)) {
|
if (!IS_VALID_PERMISSIONS(permissions)) {
|
||||||
fprintf(stderr, "\nInvalid file permissions after-tree on file %s\nOnly permissions with modes 0755 and 0644 are supported\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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 (aclExists(ent)) {
|
||||||
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in after-tree on file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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 (codeSignatureExtendedAttributeExists(ent)) {
|
||||||
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %s\n", ent->fts_path);
|
if (verbose) {
|
||||||
return 1;
|
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];
|
NSDictionary *oldInfo = originalTreeState[key];
|
||||||
|
|
||||||
if ([info isEqual:oldInfo]) {
|
if ([info isEqual:oldInfo]) {
|
||||||
[newTreeState removeObjectForKey:key];
|
[newTreeState removeObjectForKey:key];
|
||||||
} else {
|
} else {
|
||||||
newTreeState[key] = info;
|
newTreeState[key] = info;
|
||||||
|
|
||||||
if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
|
if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
|
||||||
NSArray *parentPathComponents = key.pathComponents;
|
NSArray *parentPathComponents = key.pathComponents;
|
||||||
|
|
||||||
@@ -372,29 +425,42 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
|
|
||||||
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
|
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
|
||||||
if (!afterHash) {
|
if (!afterHash) {
|
||||||
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [destination fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nGenerating delta...");
|
fprintf(stderr, "\nGenerating delta...");
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
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_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
|
||||||
|
|
||||||
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
|
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, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", majorVersion] UTF8String]);
|
||||||
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", minorVersion] 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
|
// Version 1 patches don't have a major or minor version field, so we need to differentiate between the hash keys
|
||||||
const char *beforeHashKey =
|
const char *beforeHashKey = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? BEFORE_TREE_SHA1_KEY : BEFORE_TREE_SHA1_OLD_KEY;
|
||||||
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;
|
||||||
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, beforeHashKey, [beforeHash UTF8String]);
|
||||||
xar_subdoc_prop_set(attributes, afterHashKey, [afterHash UTF8String]);
|
xar_subdoc_prop_set(attributes, afterHashKey, [afterHash UTF8String]);
|
||||||
|
|
||||||
@@ -404,21 +470,21 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
// Sort the keys by preferring the ones from the original tree to appear first
|
// 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
|
// 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) {
|
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingComparator:^NSComparisonResult(NSString *key1, NSString *key2) {
|
||||||
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
|
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
|
||||||
if (insensitiveCompareResult != NSOrderedSame) {
|
if (insensitiveCompareResult != NSOrderedSame) {
|
||||||
return insensitiveCompareResult;
|
return insensitiveCompareResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
|
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
|
||||||
}];
|
}];
|
||||||
for (NSString* key in keys) {
|
for (NSString *key in keys) {
|
||||||
id value = [newTreeState valueForKey:key];
|
id value = [newTreeState valueForKey:key];
|
||||||
|
|
||||||
if ([value isEqual:[NSNull null]]) {
|
if ([value isEqual:[NSNull null]]) {
|
||||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||||
assert(newFile);
|
assert(newFile);
|
||||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
|
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
@@ -433,7 +499,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
|
||||||
assert(newFile);
|
assert(newFile);
|
||||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
|
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
|
||||||
|
|
||||||
if (verbose) {
|
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]);
|
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
|
||||||
}
|
}
|
||||||
@@ -442,7 +508,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
NSString *path = [destination stringByAppendingPathComponent:key];
|
NSString *path = [destination stringByAppendingPathComponent:key];
|
||||||
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
|
||||||
assert(newFile);
|
assert(newFile);
|
||||||
|
|
||||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||||
@@ -450,11 +516,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
|
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||||
xar_prop_set(newFile, EXTRACT_KEY, "true");
|
xar_prop_set(newFile, EXTRACT_KEY, "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
if (originalInfo) {
|
if (originalInfo) {
|
||||||
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
|
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
|
||||||
@@ -479,22 +545,27 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
|
||||||
NSString *resultPath = [operation resultPath];
|
NSString *resultPath = [operation resultPath];
|
||||||
if (!resultPath) {
|
if (!resultPath) {
|
||||||
fprintf(stderr, "\nFailed to create patch from source %s and destination %s\n", [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
if (verbose) {
|
||||||
return 1;
|
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) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
|
||||||
assert(newFile);
|
assert(newFile);
|
||||||
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
|
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
|
||||||
unlink([resultPath fileSystemRepresentation]);
|
unlink([resultPath fileSystemRepresentation]);
|
||||||
|
|
||||||
if (operation.permissions) {
|
if (operation.permissions) {
|
||||||
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
|
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
|
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
|
||||||
}
|
}
|
||||||
@@ -506,10 +577,10 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
|||||||
unlink([patchFile fileSystemRepresentation]);
|
unlink([patchFile fileSystemRepresentation]);
|
||||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||||
unlink([temporaryFile fileSystemRepresentation]);
|
unlink([temporaryFile fileSystemRepresentation]);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "\nDone!\n");
|
fprintf(stderr, "\nDone!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return YES;
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
#define VERSION_COMMAND @"version"
|
#define VERSION_COMMAND @"version"
|
||||||
#define VERSION_ALTERNATE_COMMAND @"--version"
|
#define VERSION_ALTERNATE_COMMAND @"--version"
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
static void printUsage(NSString *programName)
|
static void printUsage(NSString *programName)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
@@ -28,13 +30,13 @@ static void printUsage(NSString *programName)
|
|||||||
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int runCreateCommand(NSString *programName, NSArray *args)
|
static BOOL runCreateCommand(NSString *programName, NSArray *args)
|
||||||
{
|
{
|
||||||
if (args.count < 3 || args.count > 5) {
|
if (args.count < 3 || args.count > 5) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSUInteger numberOflagsFound = 0;
|
NSUInteger numberOflagsFound = 0;
|
||||||
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
|
||||||
NSUInteger versionIndex = NSNotFound;
|
NSUInteger versionIndex = NSNotFound;
|
||||||
@@ -44,113 +46,139 @@ static int runCreateCommand(NSString *programName, NSArray *args)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verboseIndex != NSNotFound) {
|
if (verboseIndex != NSNotFound) {
|
||||||
++numberOflagsFound;
|
++numberOflagsFound;
|
||||||
}
|
}
|
||||||
if (versionIndex != NSNotFound) {
|
if (versionIndex != NSNotFound) {
|
||||||
++numberOflagsFound;
|
++numberOflagsFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.count - numberOflagsFound < 3) {
|
if (args.count - numberOflagsFound < 3) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL verbose = (verboseIndex != NSNotFound);
|
BOOL verbose = (verboseIndex != NSNotFound);
|
||||||
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
|
||||||
|
|
||||||
NSArray *versionComponents = nil;
|
NSArray *versionComponents = nil;
|
||||||
if (versionField) {
|
if (versionField) {
|
||||||
versionComponents = [versionField componentsSeparatedByString:@"="];
|
versionComponents = [versionField componentsSeparatedByString:@"="];
|
||||||
if (versionComponents.count != 2) {
|
if (versionComponents.count != 2) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBinaryDeltaMajorVersion patchVersion =
|
SUBinaryDeltaMajorVersion patchVersion =
|
||||||
!versionComponents ?
|
!versionComponents ?
|
||||||
LATEST_DELTA_DIFF_MAJOR_VERSION :
|
LATEST_DELTA_DIFF_MAJOR_VERSION :
|
||||||
(SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided
|
(SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided
|
||||||
|
|
||||||
|
if (patchVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
|
||||||
|
fprintf(stderr, "Version provided (%u) is not valid\n", patchVersion);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
|
||||||
|
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", patchVersion);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||||
for (NSString *argument in args) {
|
for (NSString *argument in args) {
|
||||||
if (![argument hasPrefix:VERSION_FLAG] && ![argument isEqualToString:VERBOSE_FLAG]) {
|
if (![argument hasPrefix:VERSION_FLAG] && ![argument isEqualToString:VERBOSE_FLAG]) {
|
||||||
[fileArgs addObject:argument];
|
[fileArgs addObject:argument];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileArgs.count != 3) {
|
if (fileArgs.count != 3) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString *sourcePath = fileArgs[0];
|
||||||
|
NSString *destPath = fileArgs[1];
|
||||||
|
NSString *patchPath = fileArgs[2];
|
||||||
|
|
||||||
BOOL isDirectory;
|
BOOL isDirectory;
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
|
if (![[NSFileManager defaultManager] fileExistsAtPath:sourcePath isDirectory:&isDirectory] || !isDirectory) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
fprintf(stderr, "Error: before-tree must be a directory\n");
|
fprintf(stderr, "Error: before-tree must be a directory\n");
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[1] isDirectory:&isDirectory] || !isDirectory) {
|
if (![[NSFileManager defaultManager] fileExistsAtPath:destPath isDirectory:&isDirectory] || !isDirectory) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
fprintf(stderr, "Error: after-tree must be a directory\n");
|
fprintf(stderr, "Error: after-tree must be a directory\n");
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose);
|
NSError *createDiffError = nil;
|
||||||
|
if (!createBinaryDelta(sourcePath, destPath, patchPath, patchVersion, verbose, &createDiffError)) {
|
||||||
|
fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int runApplyCommand(NSString *programName, NSArray *args)
|
static BOOL runApplyCommand(NSString *programName, NSArray *args)
|
||||||
{
|
{
|
||||||
if (args.count < 3 || args.count > 4) {
|
if (args.count < 3 || args.count > 4) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL verbose = [args containsObject:VERBOSE_FLAG];
|
BOOL verbose = [args containsObject:VERBOSE_FLAG];
|
||||||
|
|
||||||
if (args.count == 4 && !verbose) {
|
if (args.count == 4 && !verbose) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableArray *fileArgs = [NSMutableArray array];
|
NSMutableArray *fileArgs = [NSMutableArray array];
|
||||||
for (NSString *argument in args) {
|
for (NSString *argument in args) {
|
||||||
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
if (![argument isEqualToString:VERBOSE_FLAG]) {
|
||||||
[fileArgs addObject:argument];
|
[fileArgs addObject:argument];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileArgs.count != 3) {
|
if (fileArgs.count != 3) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL isDirectory;
|
BOOL isDirectory;
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
|
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
fprintf(stderr, "Error: before-tree must be a directory\n");
|
fprintf(stderr, "Error: before-tree must be a directory\n");
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) {
|
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory);
|
fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose);
|
NSError *applyDiffError = nil;
|
||||||
|
if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, ^(__unused double x){}, &applyDiffError)) {
|
||||||
|
fprintf(stderr, "%s\n", [applyDiffError.localizedDescription UTF8String]);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int runVersionCommand(NSString *programName, NSArray *args)
|
static BOOL runVersionCommand(NSString *programName, NSArray *args)
|
||||||
{
|
{
|
||||||
if (args.count > 1) {
|
if (args.count > 1) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.count == 0) {
|
if (args.count == 0) {
|
||||||
fprintf(stdout, "%u.%u\n", LATEST_DELTA_DIFF_MAJOR_VERSION, latestMinorVersionForMajorVersion(LATEST_DELTA_DIFF_MAJOR_VERSION));
|
fprintf(stdout, "%u.%u\n", LATEST_DELTA_DIFF_MAJOR_VERSION, latestMinorVersionForMajorVersion(LATEST_DELTA_DIFF_MAJOR_VERSION));
|
||||||
} else {
|
} else {
|
||||||
@@ -158,33 +186,33 @@ static int runVersionCommand(NSString *programName, NSArray *args)
|
|||||||
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
|
||||||
if (!x) {
|
if (!x) {
|
||||||
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
|
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
|
||||||
return 1;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
|
||||||
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
|
int minorDiffVersion = 0;
|
||||||
|
|
||||||
xar_subdoc_t subdoc;
|
xar_subdoc_t subdoc;
|
||||||
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
|
||||||
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
|
||||||
const char *value = 0;
|
const char *value = 0;
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
|
||||||
|
|
||||||
// available in version 2.0 or later
|
// available in version 2.0 or later
|
||||||
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
|
||||||
if (value)
|
if (value)
|
||||||
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
|
minorDiffVersion = [@(value) intValue];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
|
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int __unused argc, char __unused *argv[])
|
int main(int __unused argc, char __unused *argv[])
|
||||||
@@ -192,7 +220,7 @@ int main(int __unused argc, char __unused *argv[])
|
|||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
NSArray *args = [[NSProcessInfo processInfo] arguments];
|
||||||
NSString *programName = [args[0] lastPathComponent];
|
NSString *programName = [args[0] lastPathComponent];
|
||||||
|
|
||||||
if (args.count < 2) {
|
if (args.count < 2) {
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -200,8 +228,8 @@ int main(int __unused argc, char __unused *argv[])
|
|||||||
|
|
||||||
NSString *command = args[1];
|
NSString *command = args[1];
|
||||||
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
|
||||||
|
|
||||||
int result;
|
BOOL result;
|
||||||
if ([command isEqualToString:CREATE_COMMAND]) {
|
if ([command isEqualToString:CREATE_COMMAND]) {
|
||||||
result = runCreateCommand(programName, commandArguments);
|
result = runCreateCommand(programName, commandArguments);
|
||||||
} else if ([command isEqualToString:APPLY_COMMAND]) {
|
} else if ([command isEqualToString:APPLY_COMMAND]) {
|
||||||
@@ -209,10 +237,10 @@ int main(int __unused argc, char __unused *argv[])
|
|||||||
} else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) {
|
} else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) {
|
||||||
result = runVersionCommand(programName, commandArguments);
|
result = runVersionCommand(programName, commandArguments);
|
||||||
} else {
|
} else {
|
||||||
result = 1;
|
result = NO;
|
||||||
printUsage(programName);
|
printUsage(programName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,11 +9,17 @@
|
|||||||
#ifndef SUBINARYDELTAUNARCHIVER_H
|
#ifndef SUBINARYDELTAUNARCHIVER_H
|
||||||
#define SUBINARYDELTAUNARCHIVER_H
|
#define SUBINARYDELTAUNARCHIVER_H
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SUUnarchiver.h"
|
#import "SUUnarchiverProtocol.h"
|
||||||
|
|
||||||
@interface SUBinaryDeltaUnarchiver : SUUnarchiver
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||||
|
|
||||||
|
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,50 +6,113 @@
|
|||||||
// Copyright 2009 Mark Rowe. All rights reserved.
|
// Copyright 2009 Mark Rowe. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "SUBinaryDeltaCommon.h"
|
|
||||||
#import "SUBinaryDeltaUnarchiver.h"
|
#import "SUBinaryDeltaUnarchiver.h"
|
||||||
|
#import "SUUnarchiverNotifier.h"
|
||||||
|
#import "SUBinaryDeltaCommon.h"
|
||||||
#import "SUBinaryDeltaApply.h"
|
#import "SUBinaryDeltaApply.h"
|
||||||
#import "SUUnarchiver_Private.h"
|
#import "SULog.h"
|
||||||
#import "SUHost.h"
|
#import "SUFileManager.h"
|
||||||
#import "NTSynchronousTask.h"
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface SUBinaryDeltaUnarchiver ()
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||||
|
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation SUBinaryDeltaUnarchiver
|
@implementation SUBinaryDeltaUnarchiver
|
||||||
|
|
||||||
|
@synthesize archivePath = _archivePath;
|
||||||
|
@synthesize updateHostBundlePath = _updateHostBundlePath;
|
||||||
|
|
||||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||||
{
|
{
|
||||||
return [[path pathExtension] isEqualToString:@"delta"];
|
return [[path pathExtension] isEqualToString:@"delta"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyBinaryDelta
|
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
return YES;
|
||||||
NSString *sourcePath = self.updateHostBundlePath;
|
|
||||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
|
||||||
|
|
||||||
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO);
|
|
||||||
if (!result) {
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self notifyDelegateOfSuccess];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self notifyDelegateOfFailure];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)start
|
// 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
|
||||||
{
|
{
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
|
||||||
[self applyBinaryDelta];
|
// 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(SULogLevelError, @"Error: During delta unarchiving, failed to touch %@", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)load
|
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath
|
||||||
{
|
{
|
||||||
[self registerImplementation:self];
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_archivePath = [archivePath copy];
|
||||||
|
_updateHostBundlePath = [updateHostBundlePath copy];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
@autoreleasepool {
|
||||||
|
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
|
||||||
|
[self extractDeltaWithNotifier:notifier];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||||
|
{
|
||||||
|
NSString *sourcePath = self.updateHostBundlePath;
|
||||||
|
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||||
|
|
||||||
|
NSError *applyDiffError = nil;
|
||||||
|
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){
|
||||||
|
[notifier notifyProgress:progress];
|
||||||
|
|
||||||
|
}, &applyDiffError);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
|
||||||
|
[notifier notifySuccess];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[notifier notifyFailureWithError:applyDiffError];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// SUBundleIcon.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 7/24/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@class SUHost;
|
||||||
|
|
||||||
|
@interface SUBundleIcon : NSObject
|
||||||
|
|
||||||
|
+ (NSURL * _Nullable)iconURLForHost:(SUHost *)host;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// SUBundleIcon.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 7/24/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SUBundleIcon.h"
|
||||||
|
#import "SUHost.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@implementation SUBundleIcon
|
||||||
|
|
||||||
|
// Note: To obtain the most current bundle icon file from the Info dictionary, this should take a SUHost, not a NSBundle
|
||||||
|
+ (NSURL *)iconURLForHost:(SUHost *)host
|
||||||
|
{
|
||||||
|
NSString *resource = [host objectForInfoDictionaryKey:@"CFBundleIconFile"];
|
||||||
|
if (resource == nil || ![resource isKindOfClass:[NSString class]]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSURL *iconURL = [host.bundle URLForResource:resource withExtension:@"icns"];
|
||||||
|
|
||||||
|
// The resource could already be containing the path extension, so try again without the extra extension
|
||||||
|
if (iconURL == nil) {
|
||||||
|
iconURL = [host.bundle URLForResource:resource withExtension:nil];
|
||||||
|
}
|
||||||
|
return iconURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -12,10 +12,9 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface SUCodeSigningVerifier : NSObject
|
@interface SUCodeSigningVerifier : NSObject
|
||||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
|
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||||
+ (BOOL)hostApplicationIsCodeSigned;
|
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -11,120 +11,107 @@
|
|||||||
#import "SUCodeSigningVerifier.h"
|
#import "SUCodeSigningVerifier.h"
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@implementation SUCodeSigningVerifier
|
@implementation SUCodeSigningVerifier
|
||||||
|
|
||||||
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
OSStatus result;
|
OSStatus result;
|
||||||
SecRequirementRef requirement = NULL;
|
SecRequirementRef requirement = NULL;
|
||||||
SecStaticCodeRef staticCode = NULL;
|
SecStaticCodeRef staticCode = NULL;
|
||||||
SecCodeRef hostCode = NULL;
|
SecStaticCodeRef oldCode = NULL;
|
||||||
NSBundle *newBundle;
|
|
||||||
CFErrorRef cfError = NULL;
|
CFErrorRef cfError = NULL;
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = nil;
|
*error = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
|
||||||
|
if (result == errSecCSUnsigned) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
SULog(@"Failed to copy host code %d", result);
|
SULog(SULogLevelError, @"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
|
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
|
||||||
if (!newBundle) {
|
|
||||||
SULog(@"Failed to load NSBundle for update");
|
|
||||||
result = -1;
|
|
||||||
goto finally;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
|
||||||
if (result != noErr) {
|
|
||||||
SULog(@"Failed to get static code %d", result);
|
|
||||||
goto finally;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
// 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
|
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
||||||
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
|
// Aditionally, there are several reasons to stay away from deep verification and to prefer DSA signing the download archive instead.
|
||||||
|
// See https://github.com/sparkle-project/Sparkle/pull/523#commitcomment-17549302 and https://github.com/sparkle-project/Sparkle/issues/543
|
||||||
|
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
|
||||||
|
|
||||||
if (cfError) {
|
if (cfError) {
|
||||||
NSError *tmpError = CFBridgingRelease(cfError);
|
NSError *tmpError = CFBridgingRelease(cfError);
|
||||||
if (error) *error = tmpError;
|
if (error) *error = tmpError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
if (result == errSecCSUnsigned) {
|
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.");
|
SULog(SULogLevelError, @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
|
||||||
}
|
}
|
||||||
if (result == errSecCSReqFailed) {
|
if (result == errSecCSReqFailed) {
|
||||||
CFStringRef requirementString = nil;
|
CFStringRef requirementString = nil;
|
||||||
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
|
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);
|
SULog(SULogLevelError, @"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
|
||||||
CFRelease(requirementString);
|
CFRelease(requirementString);
|
||||||
}
|
}
|
||||||
|
|
||||||
[self logSigningInfoForCode:hostCode label:@"host info"];
|
[self logSigningInfoForCode:oldCode label:@"old info"];
|
||||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if (hostCode) CFRelease(hostCode);
|
if (oldCode) CFRelease(oldCode);
|
||||||
if (staticCode) CFRelease(staticCode);
|
if (staticCode) CFRelease(staticCode);
|
||||||
if (requirement) CFRelease(requirement);
|
if (requirement) CFRelease(requirement);
|
||||||
return (result == noErr);
|
return (result == noErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
|
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
|
||||||
{
|
{
|
||||||
OSStatus result;
|
OSStatus result;
|
||||||
SecStaticCodeRef staticCode = NULL;
|
SecStaticCodeRef staticCode = NULL;
|
||||||
NSBundle *newBundle;
|
|
||||||
CFErrorRef cfError = NULL;
|
CFErrorRef cfError = NULL;
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = nil;
|
*error = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||||
if (!newBundle) {
|
|
||||||
SULog(@"Failed to load NSBundle");
|
|
||||||
result = -1;
|
|
||||||
goto finally;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
SULog(@"Failed to get static code %d", result);
|
SULog(SULogLevelError, @"Failed to get static code %d", result);
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
|
// See in -codeSignatureAtBundleURL:matchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not passed
|
||||||
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
|
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
|
||||||
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
|
|
||||||
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
|
||||||
|
|
||||||
if (cfError) {
|
if (cfError) {
|
||||||
NSError *tmpError = CFBridgingRelease(cfError);
|
NSError *tmpError = CFBridgingRelease(cfError);
|
||||||
if (error) *error = tmpError;
|
if (error) *error = tmpError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
if (result == errSecCSUnsigned) {
|
if (result == errSecCSUnsigned) {
|
||||||
SULog(@"Error: The app is not signed using Apple Code Signing. %@", applicationPath);
|
SULog(SULogLevelError, @"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
|
||||||
}
|
}
|
||||||
if (result == errSecCSReqFailed) {
|
if (result == errSecCSReqFailed) {
|
||||||
[self logSigningInfoForCode:staticCode label:@"new info"];
|
[self logSigningInfoForCode:staticCode label:@"new info"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if (staticCode) CFRelease(staticCode);
|
if (staticCode) CFRelease(staticCode);
|
||||||
return (result == noErr);
|
return (result == noErr);
|
||||||
@@ -136,49 +123,28 @@ static id valueOrNSNull(id value) {
|
|||||||
|
|
||||||
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
|
||||||
CFDictionaryRef signingInfo = nil;
|
CFDictionaryRef signingInfo = nil;
|
||||||
const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation;
|
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
|
||||||
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
|
||||||
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
|
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
|
||||||
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
|
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
|
||||||
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
|
||||||
relevantInfo[key] = valueOrNSNull(signingDict[key]);
|
[relevantInfo setObject:valueOrNSNull([signingDict objectForKey:key]) forKey:key];
|
||||||
}
|
}
|
||||||
NSDictionary *infoPlist = signingDict[@"info-plist"];
|
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
|
||||||
relevantInfo[@"version"] = valueOrNSNull(infoPlist[@"CFBundleShortVersionString"]);
|
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
|
||||||
relevantInfo[@"build"] = valueOrNSNull(infoPlist[(__bridge NSString *)kCFBundleVersionKey]);
|
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
|
||||||
SULog(@"%@: %@", label, relevantInfo);
|
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)hostApplicationIsCodeSigned
|
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
|
||||||
{
|
|
||||||
OSStatus result;
|
|
||||||
SecCodeRef hostCode = NULL;
|
|
||||||
result = SecCodeCopySelf(kSecCSDefaultFlags, &hostCode);
|
|
||||||
if (result != 0) return NO;
|
|
||||||
|
|
||||||
SecRequirementRef requirement = NULL;
|
|
||||||
result = SecCodeCopyDesignatedRequirement(hostCode, kSecCSDefaultFlags, &requirement);
|
|
||||||
if (hostCode) CFRelease(hostCode);
|
|
||||||
if (requirement) CFRelease(requirement);
|
|
||||||
return (result == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath
|
|
||||||
{
|
{
|
||||||
OSStatus result;
|
OSStatus result;
|
||||||
SecStaticCodeRef staticCode = NULL;
|
SecStaticCodeRef staticCode = NULL;
|
||||||
NSBundle *newBundle;
|
|
||||||
|
|
||||||
newBundle = [NSBundle bundleWithPath:applicationPath];
|
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
|
||||||
if (!newBundle) {
|
|
||||||
SULog(@"Failed to load NSBundle");
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
|
|
||||||
if (result == errSecCSUnsigned) {
|
if (result == errSecCSUnsigned) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecRequirementRef requirement = NULL;
|
SecRequirementRef requirement = NULL;
|
||||||
@@ -190,7 +156,7 @@ static id valueOrNSNull(id value) {
|
|||||||
CFRelease(requirement);
|
CFRelease(requirement);
|
||||||
}
|
}
|
||||||
if (result == errSecCSUnsigned) {
|
if (result == errSecCSUnsigned) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
return (result == 0);
|
return (result == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ extern NSString *const SUPublicDSAKeyFileKey;
|
|||||||
extern NSString *const SUAutomaticallyUpdateKey;
|
extern NSString *const SUAutomaticallyUpdateKey;
|
||||||
extern NSString *const SUAllowsAutomaticUpdatesKey;
|
extern NSString *const SUAllowsAutomaticUpdatesKey;
|
||||||
extern NSString *const SUEnableAutomaticChecksKey;
|
extern NSString *const SUEnableAutomaticChecksKey;
|
||||||
extern NSString *const SUEnableAutomaticChecksKeyOld;
|
|
||||||
extern NSString *const SUEnableSystemProfilingKey;
|
extern NSString *const SUEnableSystemProfilingKey;
|
||||||
extern NSString *const SUSendProfileInfoKey;
|
extern NSString *const SUSendProfileInfoKey;
|
||||||
extern NSString *const SULastProfileSubmitDateKey;
|
extern NSString *const SULastProfileSubmitDateKey;
|
||||||
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
extern NSString *const SUPromptUserOnFirstLaunchKey;
|
||||||
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
extern NSString *const SUKeepDownloadOnFailedInstallKey;
|
||||||
extern NSString *const SUDefaultsDomainKey;
|
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 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 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 SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES.")));
|
||||||
@@ -73,6 +73,7 @@ extern NSString *const SUAppcastElementReleaseNotesLink;
|
|||||||
extern NSString *const SUAppcastElementTags;
|
extern NSString *const SUAppcastElementTags;
|
||||||
|
|
||||||
extern NSString *const SURSSAttributeURL;
|
extern NSString *const SURSSAttributeURL;
|
||||||
|
extern NSString *const SURSSAttributeLength;
|
||||||
|
|
||||||
extern NSString *const SURSSElementDescription;
|
extern NSString *const SURSSElementDescription;
|
||||||
extern NSString *const SURSSElementEnclosure;
|
extern NSString *const SURSSElementEnclosure;
|
||||||
|
|||||||
@@ -6,17 +6,15 @@
|
|||||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "SUUpdater.h"
|
|
||||||
|
|
||||||
#import "SUAppcast.h"
|
|
||||||
#import "SUAppcastItem.h"
|
|
||||||
#import "SUVersionComparisonProtocol.h"
|
|
||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
// Define some minimum intervals to avoid DoS-like checking attacks
|
// Define some minimum intervals to avoid DoS-like checking attacks
|
||||||
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
||||||
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
||||||
@@ -38,10 +36,10 @@ NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
|||||||
NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
|
||||||
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
|
||||||
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
|
||||||
NSString *const SUEnableAutomaticChecksKeyOld = @"SUCheckAtStartup";
|
|
||||||
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
|
||||||
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
|
||||||
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
|
||||||
|
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
|
||||||
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
|
||||||
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
|
||||||
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
|
||||||
@@ -65,6 +63,7 @@ NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
|
|||||||
NSString *const SUAppcastElementTags = @"sparkle:tags";
|
NSString *const SUAppcastElementTags = @"sparkle:tags";
|
||||||
|
|
||||||
NSString *const SURSSAttributeURL = @"url";
|
NSString *const SURSSAttributeURL = @"url";
|
||||||
|
NSString *const SURSSAttributeLength = @"length";
|
||||||
|
|
||||||
NSString *const SURSSElementDescription = @"description";
|
NSString *const SURSSElementDescription = @"description";
|
||||||
NSString *const SURSSElementEnclosure = @"enclosure";
|
NSString *const SURSSElementEnclosure = @"enclosure";
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
#include <CommonCrypto/CommonDigest.h>
|
#include <CommonCrypto/CommonDigest.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@implementation SUDSAVerifier {
|
@implementation SUDSAVerifier {
|
||||||
SecKeyRef _secKey;
|
SecKeyRef _secKey;
|
||||||
}
|
}
|
||||||
@@ -23,7 +26,7 @@
|
|||||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||||
{
|
{
|
||||||
if (!encodedSignature) {
|
if (!encodedSignature) {
|
||||||
SULog(@"There is no DSA signature to check");
|
SULog(SULogLevelError, @"There is no DSA signature to check");
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +50,7 @@
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
if (!self || !data.length) {
|
if (!self || !data.length) {
|
||||||
SULog(@"Could not read public DSA key");
|
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,17 +58,23 @@
|
|||||||
SecExternalItemType itemType = kSecItemTypePublicKey;
|
SecExternalItemType itemType = kSecItemTypePublicKey;
|
||||||
CFArrayRef items = NULL;
|
CFArrayRef items = NULL;
|
||||||
|
|
||||||
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, 0, NULL, NULL, &items);
|
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
|
||||||
if (status != errSecSuccess || !items) {
|
if (status != errSecSuccess || !items) {
|
||||||
if (items) {
|
if (items) {
|
||||||
CFRelease(items);
|
CFRelease(items);
|
||||||
}
|
}
|
||||||
SULog(@"Public DSA key could not be imported: %d", status);
|
SULog(SULogLevelError, @"Public DSA key could not be imported: %d", status);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
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));
|
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease(items);
|
CFRelease(items);
|
||||||
@@ -112,7 +121,7 @@
|
|||||||
|
|
||||||
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
|
||||||
if (!dataReadTransform) {
|
if (!dataReadTransform) {
|
||||||
SULog(@"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
SULog(SULogLevelError, @"File containing update archive could not be read (failed to create SecTransform for input stream)");
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,30 +135,30 @@
|
|||||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
if (!dataVerifyTransform || error) {
|
if (!dataVerifyTransform || error) {
|
||||||
SULog(@"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
SULog(@"%@", error);
|
SULog(SULogLevelError, @"%@", error);
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
SULog(@"%@", error);
|
SULog(SULogLevelError, @"%@", error);
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
|
||||||
if (error) {
|
if (error) {
|
||||||
SULog(@"DSA signature verification failed: %@", error);
|
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.boolValue) {
|
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.");
|
SULog(SULogLevelError, @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|||||||
@@ -9,11 +9,17 @@
|
|||||||
#ifndef SUDISKIMAGEUNARCHIVER_H
|
#ifndef SUDISKIMAGEUNARCHIVER_H
|
||||||
#define SUDISKIMAGEUNARCHIVER_H
|
#define SUDISKIMAGEUNARCHIVER_H
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SUUnarchiver.h"
|
#import "SUUnarchiverProtocol.h"
|
||||||
|
|
||||||
@interface SUDiskImageUnarchiver : SUUnarchiver
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||||
|
|
||||||
|
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -7,162 +7,200 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "SUDiskImageUnarchiver.h"
|
#import "SUDiskImageUnarchiver.h"
|
||||||
#import "SUUnarchiver_Private.h"
|
#import "SUUnarchiverNotifier.h"
|
||||||
#import "NTSynchronousTask.h"
|
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
#include <CoreServices/CoreServices.h>
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
@interface SUDiskImageUnarchiver ()
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||||
|
@property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation SUDiskImageUnarchiver
|
@implementation SUDiskImageUnarchiver
|
||||||
|
|
||||||
|
@synthesize archivePath = _archivePath;
|
||||||
|
@synthesize decryptionPassword = _decryptionPassword;
|
||||||
|
|
||||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||||
{
|
{
|
||||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on a non-main thread.
|
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||||
- (void)extractDMG
|
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
return NO;
|
||||||
[self extractDMGWithPassword:nil];
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_archivePath = [archivePath copy];
|
||||||
|
_decryptionPassword = [decryptionPassword copy];
|
||||||
}
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
|
||||||
|
[self extractDMGWithNotifier:notifier];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on a non-main thread.
|
// Called on a non-main thread.
|
||||||
- (void)extractDMGWithPassword:(NSString *)__unused password
|
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
BOOL mountedSuccessfully = NO;
|
BOOL mountedSuccessfully = NO;
|
||||||
|
|
||||||
SULog(@"Extracting %@ as a DMG", self.archivePath);
|
|
||||||
|
|
||||||
// get a unique mount point path
|
// get a unique mount point path
|
||||||
NSString *mountPoint = nil;
|
NSString *mountPoint = nil;
|
||||||
FSRef tmpRef;
|
|
||||||
NSFileManager *manager;
|
NSFileManager *manager;
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSArray *contents;
|
NSArray *contents;
|
||||||
// We have to declare these before a goto to prevent an error under ARC.
|
do
|
||||||
// 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,
|
// Using NSUUID would make creating UUIDs be done in Cocoa,
|
||||||
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
|
||||||
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
CFUUIDRef uuid = CFUUIDCreate(NULL);
|
||||||
if (uuid)
|
if (uuid)
|
||||||
{
|
{
|
||||||
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
|
||||||
if (uuidString)
|
if (uuidString)
|
||||||
{
|
{
|
||||||
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
mountPoint = [@"/Volumes" stringByAppendingPathComponent:uuidString];
|
||||||
}
|
}
|
||||||
CFRelease(uuid);
|
CFRelease(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (noErr == FSPathMakeRefWithOptions((const UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
|
// Note: this check does not follow symbolic links, which is what we want
|
||||||
|
while ([[NSURL fileURLWithPath:mountPoint] checkResourceIsReachableAndReturnError:NULL]);
|
||||||
|
|
||||||
NSData *promptData = nil;
|
NSData *promptData = nil;
|
||||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||||
|
|
||||||
NSArray *arguments = @[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"];
|
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||||
|
|
||||||
|
if (self.decryptionPassword) {
|
||||||
|
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||||
|
// From the hdiutil docs:
|
||||||
|
// read a null-terminated passphrase from standard input
|
||||||
|
//
|
||||||
|
// Add the null terminator, then the newline
|
||||||
|
[passwordData appendData:[NSData dataWithBytes:"\0" length:1]];
|
||||||
|
[passwordData appendData:promptData];
|
||||||
|
promptData = passwordData;
|
||||||
|
|
||||||
|
[arguments addObject:@"-stdinpass"];
|
||||||
|
}
|
||||||
|
|
||||||
NSData *output = nil;
|
NSData *output = nil;
|
||||||
NSInteger taskResult = -1;
|
NSInteger taskResult = -1;
|
||||||
@try
|
@try
|
||||||
{
|
{
|
||||||
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
|
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];
|
||||||
|
|
||||||
|
[notifier notifyProgress:0.125];
|
||||||
|
|
||||||
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
|
[inputPipe.fileHandleForWriting writeData:promptData];
|
||||||
|
[inputPipe.fileHandleForWriting closeFile];
|
||||||
taskResult = [task result];
|
|
||||||
output = [[task output] copy];
|
// 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 *)
|
@catch (NSException *)
|
||||||
{
|
{
|
||||||
goto reportError;
|
goto reportError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[notifier notifyProgress:0.5];
|
||||||
|
|
||||||
if (taskResult != 0)
|
if (taskResult != 0)
|
||||||
{
|
{
|
||||||
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
|
||||||
SULog(@"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
SULog(SULogLevelError, @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
|
||||||
goto reportError;
|
goto reportError;
|
||||||
}
|
}
|
||||||
mountedSuccessfully = YES;
|
mountedSuccessfully = YES;
|
||||||
|
|
||||||
// Now that we've mounted it, we need to copy out its contents.
|
// Now that we've mounted it, we need to copy out its contents.
|
||||||
manager = [[NSFileManager alloc] init];
|
manager = [[NSFileManager alloc] init];
|
||||||
contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
SULog(@"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
SULog(SULogLevelError, @"Couldn't enumerate contents of archive mounted at %@: %@", mountPoint, error);
|
||||||
goto reportError;
|
goto reportError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double itemsCopied = 0;
|
||||||
|
double totalItems = [contents count];
|
||||||
|
|
||||||
for (NSString *item in contents)
|
for (NSString *item in contents)
|
||||||
{
|
{
|
||||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||||
|
|
||||||
// We skip any files in the DMG which are not readable.
|
// We skip any files in the DMG which are not readable.
|
||||||
if (![manager isReadableFileAtPath:fromPath]) {
|
if (![manager isReadableFileAtPath:fromPath]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
itemsCopied += 1.0;
|
||||||
|
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||||
|
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||||
|
|
||||||
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
|
||||||
{
|
{
|
||||||
SULog(@"Couldn't copy item: %@ : %@", error, error.userInfo ? error.userInfo : @"");
|
|
||||||
goto reportError;
|
goto reportError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), delegateSuccess);
|
[notifier notifySuccess];
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
reportError:
|
reportError:
|
||||||
dispatch_async(dispatch_get_main_queue(), delegateFailure);
|
[notifier notifyFailureWithError:error];
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if (mountedSuccessfully)
|
if (mountedSuccessfully) {
|
||||||
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
|
NSTask *task = [[NSTask alloc] init];
|
||||||
else
|
task.launchPath = @"/usr/bin/hdiutil";
|
||||||
SULog(@"Can't mount DMG %@", self.archivePath);
|
task.arguments = @[@"detach", mountPoint, @"-force"];
|
||||||
}
|
task.standardOutput = [NSPipe pipe];
|
||||||
}
|
task.standardError = [NSPipe pipe];
|
||||||
|
|
||||||
- (void)start
|
@try {
|
||||||
{
|
[task launch];
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
} @catch (NSException *exception) {
|
||||||
[self extractDMG];
|
SULog(SULogLevelError, @"Failed to unmount %@", mountPoint);
|
||||||
});
|
SULog(SULogLevelError, @"Exception: %@", exception);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
+ (void)load
|
SULog(SULogLevelError, @"Can't mount DMG %@", self.archivePath);
|
||||||
{
|
|
||||||
[self registerImplementation:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isEncrypted:(NSData *)resultData
|
|
||||||
{
|
|
||||||
BOOL result = NO;
|
|
||||||
if(resultData)
|
|
||||||
{
|
|
||||||
NSString *data = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
|
|
||||||
|
|
||||||
if ((data != nil) && !NSEqualRanges([data rangeOfString:@"passphrase-count"], NSMakeRange(NSNotFound, 0)))
|
|
||||||
{
|
|
||||||
result = YES;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.archivePath]; }
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -9,7 +9,11 @@
|
|||||||
#ifndef SUERRORS_H
|
#ifndef SUERRORS_H
|
||||||
#define SUERRORS_H
|
#define SUERRORS_H
|
||||||
|
|
||||||
|
#if __has_feature(modules)
|
||||||
|
@import Foundation;
|
||||||
|
#else
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#endif
|
||||||
#import "SUExport.h"
|
#import "SUExport.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,10 +27,11 @@ typedef NS_ENUM(OSStatus, SUError) {
|
|||||||
SUNoUpdateError = 1001,
|
SUNoUpdateError = 1001,
|
||||||
SUAppcastError = 1002,
|
SUAppcastError = 1002,
|
||||||
SURunningFromDiskImageError = 1003,
|
SURunningFromDiskImageError = 1003,
|
||||||
|
|
||||||
// Downlaod phase errors.
|
// Download phase errors.
|
||||||
SUTemporaryDirectoryError = 2000,
|
SUTemporaryDirectoryError = 2000,
|
||||||
|
SUDownloadError = 2001,
|
||||||
|
|
||||||
// Extraction phase errors.
|
// Extraction phase errors.
|
||||||
SUUnarchivingError = 3000,
|
SUUnarchivingError = 3000,
|
||||||
SUSignatureError = 3001,
|
SUSignatureError = 3001,
|
||||||
@@ -39,6 +44,7 @@ typedef NS_ENUM(OSStatus, SUError) {
|
|||||||
SURelaunchError = 4004,
|
SURelaunchError = 4004,
|
||||||
SUInstallationError = 4005,
|
SUInstallationError = 4005,
|
||||||
SUDowngradeError = 4006,
|
SUDowngradeError = 4006,
|
||||||
|
SUInstallationCancelledError = 4007,
|
||||||
|
|
||||||
// System phase errors
|
// System phase errors
|
||||||
SUSystemPowerOffError = 5000
|
SUSystemPowerOffError = 5000
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
//
|
||||||
|
// SUFileManager.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 7/18/15.
|
||||||
|
// Copyright (c) 2015 zgcoder. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
- (nullable NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)appropriateURL error:(NSError *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 *_Nullable*_Nullable)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 progressBlock Callback that takes double value (0..1 range) notifying how far the installation has progressed
|
||||||
|
* @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 progressBlock:(nullable void(^)(double))progressBlock error:(NSError *_Nullable*_Nullable)error;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -0,0 +1,991 @@
|
|||||||
|
//
|
||||||
|
// SUFileManager.m
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 7/18/15.
|
||||||
|
// Copyright (c) 2015 zgcoder. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "SUFileManager.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
#import "SUOperatingSystem.h"
|
||||||
|
#import "SUFileOperationConstants.h"
|
||||||
|
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
#include <sys/errno.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
|
static char SUAppleQuarantineIdentifier[] = "com.apple.quarantine";
|
||||||
|
|
||||||
|
static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"URL of the file (%@) cannot be represented as a file path", url.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
OSStatus makeResult = FSPathMakeRefWithOptions((const UInt8 *)path, kFSPathMakeRefDoNotFollowLeafSymlink, ref, NULL);
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
if (makeResult != noErr) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:makeResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create file system reference for %@", url.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used to indicate if the type of NSError requires us to attempt to peform the same operation again except with authentication
|
||||||
|
// To be safe, both read and write permission denied's are included because Cocoa's error methods are not very well documented
|
||||||
|
// and at least one case is caused from lack of read permissions (-[NSURL setResourceValue:forKey:error:])
|
||||||
|
#define NS_HAS_PERMISSION_ERROR(error) (error.code == NSFileReadNoPermissionError || error.code == NSFileWriteNoPermissionError)
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
// Use direct access because it's easier, clearer, and faster
|
||||||
|
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||||
|
|
||||||
|
@implementation SUFileManager
|
||||||
|
{
|
||||||
|
AuthorizationRef _auth;
|
||||||
|
NSFileManager *_fileManager;
|
||||||
|
NSString *_authorizationToolPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithAuthorizationToolPath:(NSString *)authorizationToolPath
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_fileManager = [[NSFileManager alloc] init];
|
||||||
|
_authorizationToolPath = [authorizationToolPath copy];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)defaultManager
|
||||||
|
{
|
||||||
|
return [[self alloc] initWithAuthorizationToolPath:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath
|
||||||
|
{
|
||||||
|
return [[self alloc] initWithAuthorizationToolPath:authorizationToolPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)fileManagerByPreservingAuthorizationRights
|
||||||
|
{
|
||||||
|
// Check if we don't allow authorization, or that we haven't needed to authorize yet, to create or re-use a
|
||||||
|
// file manager instance with these restrictions
|
||||||
|
return (_authorizationToolPath != nil && _auth != NULL) ? self : [SUFileManager defaultManager];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acquires an authorization reference with root privileges which is intended to be used for authorized file operations
|
||||||
|
- (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
// No need to continue if we already acquired an authorization reference
|
||||||
|
if (_auth != NULL) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_authorizationToolPath == nil) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Unable to grant authorization to perform action because it is explicitly turned off" }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth);
|
||||||
|
if (createStatus != errAuthorizationSuccess) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d.", createStatus] }];
|
||||||
|
}
|
||||||
|
_auth = NULL;
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthorizationItem rightItems[] = {
|
||||||
|
// The right that allows us to run tools as root user
|
||||||
|
{.name = kAuthorizationRightExecute, .valueLength = 0, .value = NULL, .flags = 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthorizationRights rights = {
|
||||||
|
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||||
|
.items = rightItems
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthorizationFlags flags =
|
||||||
|
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||||
|
|
||||||
|
// This will test if we can gain authorization for running utlities as root
|
||||||
|
OSStatus copyStatus = AuthorizationCopyRights(_auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||||
|
if (copyStatus != errAuthorizationSuccess) {
|
||||||
|
if (error != NULL) {
|
||||||
|
if (copyStatus == errAuthorizationCanceled) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationCancelledError userInfo:@{ NSLocalizedDescriptionKey: @"Authorization access was cancelled by the user." }];
|
||||||
|
} else {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed granting authorization rights with status code %d.", copyStatus] }];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
||||||
|
_auth = NULL;
|
||||||
|
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_authorizeAndExecuteCommand:(char *)command sourcePath:(char *)sourcePath destinationPath:(char *)destinationPath error:(NSError * __autoreleasing *)error {
|
||||||
|
return [self _authorizeAndExecuteCommand:command sourcePath:sourcePath destinationPath:destinationPath lineCallback:nil error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_authorizeAndExecuteCommand:(char *)command sourcePath:(char *)sourcePath destinationPath:(char *)destinationPath lineCallback:(void(^)(NSString*))lineCallback error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
NSError *acquireError = nil;
|
||||||
|
if (![self _acquireAuthorizationWithError:&acquireError]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = acquireError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *arguments[] = { command, sourcePath, destinationPath, NULL };
|
||||||
|
|
||||||
|
char toolPath[PATH_MAX] = {0};
|
||||||
|
if (![_authorizationToolPath getFileSystemRepresentation:toolPath maxLength:sizeof(toolPath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Authorization tool (%@) cannot be represented as a valid file name.", _authorizationToolPath.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *pipe = NULL;
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
OSStatus runStatus = AuthorizationExecuteWithPrivileges(_auth, toolPath, kAuthorizationFlagDefaults, arguments, &pipe);
|
||||||
|
if (runStatus != errAuthorizationSuccess) {
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to run authorization tool %s (%d).", toolPath, (int)runStatus] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pidData = 0;
|
||||||
|
if (fread(&pidData, sizeof(pidData), 1, pipe) < 1) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:@"Failed to retrieve authorized executable process identifier." }];
|
||||||
|
}
|
||||||
|
fclose(pipe);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineCallback) {
|
||||||
|
NSFileHandle *pipeHandle = [[NSFileHandle alloc] initWithFileDescriptor:fileno(pipe) closeOnDealloc:NO];
|
||||||
|
[self parseLines:pipeHandle lineCallback:lineCallback];
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t childPid = (int32_t)CFSwapInt32LittleToHost(pidData);
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
pid_t waitResult;
|
||||||
|
do {
|
||||||
|
waitResult = waitpid(childPid, &status, 0);
|
||||||
|
} while (waitResult == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
fclose(pipe);
|
||||||
|
|
||||||
|
if (waitResult == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to execute authorized executable with result %d and status (%d, %d, %d).", waitResult, status, WIFEXITED(status), WEXITSTATUS(status)] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)parseLines:(NSFileHandle *)pipeHandle lineCallback:(void(^)(NSString *))lineCallback {
|
||||||
|
__block NSMutableData *line = [NSMutableData new];
|
||||||
|
pipeHandle.readabilityHandler = ^(NSFileHandle *handle){
|
||||||
|
NSData *data = handle.availableData;
|
||||||
|
NSUInteger length = data.length;
|
||||||
|
if (!length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const char *bytes = data.bytes;
|
||||||
|
for(NSUInteger i = 0; i < length; i++) {
|
||||||
|
if (bytes[i] == '\n') {
|
||||||
|
NSData *dataToEOL = [data subdataWithRange:NSMakeRange(0, i)];
|
||||||
|
[line appendData:dataToEOL];
|
||||||
|
NSString *fullLine = [[NSString alloc] initWithData:line encoding:NSUTF8StringEncoding];
|
||||||
|
lineCallback(fullLine);
|
||||||
|
line = [[data subdataWithRange:NSMakeRange(i+1, length-i-1)] mutableCopy];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
if (_auth != NULL) {
|
||||||
|
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -[NSFileManager attributesOfItemAtPath:error:] won't follow symbolic links
|
||||||
|
|
||||||
|
- (BOOL)_itemExistsAtURL:(NSURL *)fileURL
|
||||||
|
{
|
||||||
|
NSString *path = fileURL.path;
|
||||||
|
if (path == nil) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return [_fileManager attributesOfItemAtPath:path error:NULL] != nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory
|
||||||
|
{
|
||||||
|
NSString *path = fileURL.path;
|
||||||
|
if (path == nil) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSDictionary *attributes = [_fileManager attributesOfItemAtPath:path error:NULL];
|
||||||
|
if (attributes == nil) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDirectory != NULL) {
|
||||||
|
*isDirectory = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeDirectory];
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrapper around getxattr()
|
||||||
|
- (ssize_t)_getXAttr:(const char *)name fromFile:(NSString *)file options:(int)options
|
||||||
|
{
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
errno = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getxattr(path, name, NULL, 0, 0, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrapper around removexattr()
|
||||||
|
- (int)_removeXAttr:(const char *)attr fromFile:(NSString *)file options:(int)options
|
||||||
|
{
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
errno = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return removexattr(path, attr, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define XATTR_UTILITY_PATH "/usr/bin/xattr"
|
||||||
|
// Recursively remove an xattr at a specified root URL with authentication
|
||||||
|
- (BOOL)_removeQuarantineWithAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
// Because this is a system utility, it's fine to follow the symbolic link if one exists
|
||||||
|
if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"xattr utility does not exist on this system." }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![rootURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to remove (%@) cannot be represented as a valid file name.", rootURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveQuarantineCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
|
if (!success && error != NULL) {
|
||||||
|
*error = executeError;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:rootURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove quarantine because %@ does not exist.", rootURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL (^releasingQuarantineRequiredAuthentication)(NSURL *, BOOL *, BOOL *) = ^(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) {
|
||||||
|
BOOL removedQuarantine = NO;
|
||||||
|
BOOL attemptedAuthentication = NO;
|
||||||
|
|
||||||
|
if (quarantineRetrieval(fileURL)) {
|
||||||
|
NSError *removalError = nil;
|
||||||
|
if (quarantineRemoval(fileURL, &removalError)) {
|
||||||
|
removedQuarantine = YES;
|
||||||
|
} else {
|
||||||
|
if (isAccessError(removalError)) {
|
||||||
|
removedQuarantine = [self _removeQuarantineWithAuthenticationAtRootURL:rootURL error:error];
|
||||||
|
attemptedAuthentication = YES;
|
||||||
|
} else {
|
||||||
|
if (success != NULL) {
|
||||||
|
// Make sure we haven't already run into an error
|
||||||
|
if (*success && error != NULL) {
|
||||||
|
*error = removalError;
|
||||||
|
}
|
||||||
|
// Fail, but still try to release other items from quarantine
|
||||||
|
*success = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (didReleaseQuarantine != NULL) {
|
||||||
|
*didReleaseQuarantine = removedQuarantine;
|
||||||
|
}
|
||||||
|
|
||||||
|
return attemptedAuthentication;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOL success = YES;
|
||||||
|
|
||||||
|
BOOL releasedRootQuarantine = NO;
|
||||||
|
if (releasingQuarantineRequiredAuthentication(rootURL, &releasedRootQuarantine, &success)) {
|
||||||
|
return releasedRootQuarantine;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only recurse if it's actually a directory. Don't recurse into a
|
||||||
|
// root-level symbolic link.
|
||||||
|
NSString *rootURLPath = rootURL.path;
|
||||||
|
NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURLPath error:nil];
|
||||||
|
NSString *rootType = [rootAttributes objectForKey:NSFileType]; // 10.7 can't subscript this
|
||||||
|
|
||||||
|
if ([rootType isEqualToString:NSFileTypeDirectory]) {
|
||||||
|
// The NSDirectoryEnumerator will avoid recursing into any contained
|
||||||
|
// symbolic links, so no further type checks are needed.
|
||||||
|
NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||||
|
|
||||||
|
for (NSURL *file in directoryEnumerator) {
|
||||||
|
BOOL releasedQuarantine = NO;
|
||||||
|
if (releasingQuarantineRequiredAuthentication(file, &releasedQuarantine, &success)) {
|
||||||
|
return releasedQuarantine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Removes the directory tree rooted at |root| from the file quarantine.
|
||||||
|
// The quarantine was introduced on macOS 10.5 and is described at:
|
||||||
|
//
|
||||||
|
// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html#apple_ref/doc/uid/TP40001369-DontLinkElementID_2
|
||||||
|
//
|
||||||
|
// If |root| is not a directory, then it alone is removed from the quarantine.
|
||||||
|
// Symbolic links, including |root| if it is a symbolic link, will not be
|
||||||
|
// traversed.
|
||||||
|
|
||||||
|
// Ordinarily, the quarantine is managed by calling LSSetItemAttribute
|
||||||
|
// to set the kLSItemQuarantineProperties attribute to a dictionary specifying
|
||||||
|
// the quarantine properties to be applied. However, it does not appear to be
|
||||||
|
// possible to remove an item from the quarantine directly through any public
|
||||||
|
// Launch Services calls. Instead, this method takes advantage of the fact
|
||||||
|
// that the quarantine is implemented in part by setting an extended attribute,
|
||||||
|
// "com.apple.quarantine", on affected files. Removing this attribute is
|
||||||
|
// sufficient to remove files from the quarantine.
|
||||||
|
|
||||||
|
// This works by removing the quarantine extended attribute for every file we come across.
|
||||||
|
// We used to have code similar to the method below that used -[NSURL getResourceValue:forKey:error:] and -[NSURL setResourceValue:forKey:error:]
|
||||||
|
// However, those methods *really suck* - you can't rely on the return value from getting the resource value and if you set the resource value
|
||||||
|
// when the key isn't present, errors are spewed out to the console
|
||||||
|
- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
static const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||||
|
|
||||||
|
return
|
||||||
|
[self
|
||||||
|
_releaseItemFromQuarantineAtRootURL:rootURL
|
||||||
|
withQuarantineRetrieval:^BOOL(NSURL *fileURL) {
|
||||||
|
return ([self _getXAttr:SUAppleQuarantineIdentifier fromFile:fileURL.path options:removeXAttrOptions] >= 0);
|
||||||
|
}
|
||||||
|
quarantineRemoval:^BOOL(NSURL *fileURL, NSError * __autoreleasing *removalError) {
|
||||||
|
BOOL removedQuarantine = ([self _removeXAttr:SUAppleQuarantineIdentifier fromFile:fileURL.path options:removeXAttrOptions] == 0);
|
||||||
|
if (!removedQuarantine && removalError != NULL) {
|
||||||
|
*removalError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", fileURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return removedQuarantine;
|
||||||
|
}
|
||||||
|
isAccessError:^BOOL(NSError *removalError) {
|
||||||
|
return (removalError.code == EACCES);
|
||||||
|
}
|
||||||
|
error:error];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copies an item from one location to another
|
||||||
|
* This intentionally does *not* use copyfile() or any API that uses it such as NSFileManager's copy item method
|
||||||
|
* This is because copyfile() can fail to copy symbolic links from one network mount to another, which will affect copying apps
|
||||||
|
* This failure occurs because the system may think symbolic links on a SMB mount are zero bytes in size
|
||||||
|
* For more info, see bug reports at http://openradar.appspot.com/radar?id=4925873463492608
|
||||||
|
* and http://openradar.appspot.com/radar?id=5024037222744064
|
||||||
|
*/
|
||||||
|
- (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:sourceURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to copy (%@) does not exist.", sourceURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![self _itemExistsAtURL:destinationURL.URLByDeletingLastPathComponent]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to copy into (%@) does not exist.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([self _itemExistsAtURL:destinationURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to copy to (%@) already exists.", destinationURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSRef sourceRef;
|
||||||
|
if (!SUMakeRefFromURL(sourceURL, &sourceRef, error)) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSRef destinationParentRef;
|
||||||
|
if (!SUMakeRefFromURL(destinationURL.URLByDeletingLastPathComponent, &destinationParentRef, error)) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
OSStatus copyResult = FSCopyObjectSync(&sourceRef, &destinationParentRef, (__bridge CFStringRef)(destinationURL.lastPathComponent), NULL, kFSFileOperationDefaultOptions);
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
if (copyResult == noErr) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: I have received afpAccessDenied error in testing even when not copying from/to an AFP mount,
|
||||||
|
// when the error should have been a normal permission denied one
|
||||||
|
if (copyResult != permErr && copyResult != afpAccessDenied) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:copyResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy file (%@)", sourceURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sourcePath[PATH_MAX] = {0};
|
||||||
|
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination to copy file to (%@) cannot be represented as a valid file name.", sourceURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char destinationPath[PATH_MAX] = {0};
|
||||||
|
if (![destinationURL.path getFileSystemRepresentation:destinationPath maxLength:sizeof(destinationPath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination to copy file to (%@) cannot be represented as a valid file name.", destinationURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
if (![self _authorizeAndExecuteCommand:SUFileOpCopyCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = executeError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the volume ID that a particular url resides on
|
||||||
|
* The url must point to a file that exists
|
||||||
|
* There is no cocoa equivalent for obtaining the volume ID
|
||||||
|
* Although NSURLVolumeURLForRemountingKey exists as a resource key for NSURL,
|
||||||
|
* that will not return a URL if the mount is not re-mountable and I otherwise don't trust the API
|
||||||
|
*/
|
||||||
|
- (BOOL)_getVolumeID:(FSVolumeRefNum *)volumeID ofItemAtURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
FSRef pathRef;
|
||||||
|
if (!SUMakeRefFromURL(url, &pathRef, NULL)) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSCatalogInfo catalogInfo;
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
OSErr catalogError = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL);
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
if (catalogError != noErr) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (volumeID != NULL) {
|
||||||
|
*volumeID = catalogInfo.volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:sourceURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSURL *destinationURLParent = destinationURL.URLByDeletingLastPathComponent;
|
||||||
|
if (![self _itemExistsAtURL:destinationURLParent]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to move into (%@) does not exist.", destinationURLParent.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([self _itemExistsAtURL:destinationURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the source and destination are on different volumes, we should not do a move;
|
||||||
|
// from my experience a move may fail when moving particular files from
|
||||||
|
// one network mount to another one. This is possibly related to the fact that
|
||||||
|
// moving a file will try to preserve ownership but copying won't
|
||||||
|
|
||||||
|
FSVolumeRefNum sourceVolume = 0;
|
||||||
|
BOOL foundSourceVolume = [self _getVolumeID:&sourceVolume ofItemAtURL:sourceURL];
|
||||||
|
|
||||||
|
FSVolumeRefNum destinationVolume = 0;
|
||||||
|
BOOL foundDestinationVolume = [self _getVolumeID:&destinationVolume ofItemAtURL:destinationURLParent];
|
||||||
|
|
||||||
|
if (foundSourceVolume && foundDestinationVolume && sourceVolume != destinationVolume) {
|
||||||
|
return ([self copyItemAtURL:sourceURL toURL:destinationURL error:error] && [self removeItemAtURL:sourceURL error:error]);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *moveError = nil;
|
||||||
|
if ([_fileManager moveItemAtURL:sourceURL toURL:destinationURL error:&moveError]) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NS_HAS_PERMISSION_ERROR(moveError)) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = moveError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sourcePath[PATH_MAX] = {0};
|
||||||
|
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to move (%@) cannot be represented as a valid file name.", sourceURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char destinationPath[PATH_MAX] = {0};
|
||||||
|
if (![destinationURL.path getFileSystemRepresentation:destinationPath maxLength:sizeof(destinationPath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination (%@) cannot be represented as a valid file name.", destinationURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
if (![self _authorizeAndExecuteCommand:SUFileOpMoveCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authorized file move for %@.", sourceURL.lastPathComponent];
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)_changeOwnerAndGroupOfItemAtURL:(NSURL *)targetURL ownerID:(NSNumber *)ownerID groupID:(NSNumber *)groupID needsAuth:(BOOL *)needsAuth error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![targetURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to change owner & group (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fileDescriptor = open(path, O_RDONLY | O_SYMLINK);
|
||||||
|
if (fileDescriptor == -1) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open file descriptor to %@", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We use fchown instead of chown because the latter can follow symbolic links
|
||||||
|
BOOL success = fchown(fileDescriptor, ownerID.unsignedIntValue, groupID.unsignedIntValue) == 0;
|
||||||
|
close(fileDescriptor);
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
if (errno == EPERM) {
|
||||||
|
if (needsAuth != NULL) {
|
||||||
|
*needsAuth = YES;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group for %@ with owner ID %u and group ID %u.", targetURL.path.lastPathComponent, ownerID.unsignedIntValue, groupID.unsignedIntValue] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
BOOL isTargetADirectory = NO;
|
||||||
|
if (![self _itemExistsAtURL:targetURL isDirectory:&isTargetADirectory]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group IDs because %@ does not exist.", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![self _itemExistsAtURL:matchURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to match owner & group IDs because %@ does not exist.", matchURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *matchFileAttributesError = nil;
|
||||||
|
NSString *matchURLPath = matchURL.path;
|
||||||
|
NSDictionary *matchFileAttributes = [_fileManager attributesOfItemAtPath:matchURLPath error:&matchFileAttributesError];
|
||||||
|
if (matchFileAttributes == nil) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = matchFileAttributesError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *targetFileAttributesError = nil;
|
||||||
|
NSString *targetURLPath = targetURL.path;
|
||||||
|
NSDictionary *targetFileAttributes = [_fileManager attributesOfItemAtPath:targetURLPath error:&targetFileAttributesError];
|
||||||
|
if (targetFileAttributes == nil) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = targetFileAttributesError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSNumber *ownerID = [matchFileAttributes objectForKey:NSFileOwnerAccountID];
|
||||||
|
if (ownerID == nil) {
|
||||||
|
// shouldn't be possible to error here, but just in case
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID could not be read from %@.", matchURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSNumber *groupID = [matchFileAttributes objectForKey:NSFileGroupOwnerAccountID];
|
||||||
|
if (groupID == nil) {
|
||||||
|
// shouldn't be possible to error here, but just in case
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Group ID could not be read from %@.", matchURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSNumber *targetOwnerID = [targetFileAttributes objectForKey:NSFileOwnerAccountID];
|
||||||
|
NSNumber *targetGroupID = [targetFileAttributes objectForKey:NSFileGroupOwnerAccountID];
|
||||||
|
|
||||||
|
if ((targetOwnerID != nil && [ownerID isEqualToNumber:targetOwnerID]) && (targetGroupID != nil && [groupID isEqualToNumber:targetGroupID])) {
|
||||||
|
// Assume they're the same even if we don't check every file recursively
|
||||||
|
// Speeds up the common case
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL needsAuth = NO;
|
||||||
|
|
||||||
|
if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID needsAuth:&needsAuth error:error]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTargetADirectory) {
|
||||||
|
NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||||
|
for (NSURL *url in directoryEnumerator) {
|
||||||
|
if (![self _changeOwnerAndGroupOfItemAtURL:url ownerID:ownerID groupID:groupID needsAuth:&needsAuth error:error]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needsAuth) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!needsAuth) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
char targetPath[PATH_MAX] = {0};
|
||||||
|
if (![targetURL.path getFileSystemRepresentation:targetPath maxLength:sizeof(targetPath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Target file (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char matchPath[PATH_MAX] = {0};
|
||||||
|
if (![matchURLPath getFileSystemRepresentation:matchPath maxLength:sizeof(matchPath)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Match file (%@) cannot be represented as a valid file name.", matchURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpChangeOwnerAndGroupCommand sourcePath:targetPath destinationPath:matchPath error:&executeError];
|
||||||
|
if (!success && error != NULL) {
|
||||||
|
NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner & group on %@ to match %@ with authorization.", targetURL.path.lastPathComponent, matchURLPath.lastPathComponent];
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /usr/bin/touch can be used to update an application, as described in:
|
||||||
|
// https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html
|
||||||
|
// The document says LSRegisterURL() can be used as well but this hasn't worked out well for me in practice
|
||||||
|
// Anyway, updating the modification time of the application is important because the system will be aware a new version of your app is available,
|
||||||
|
// Finder will report the correct file size and other metadata for it, URL schemes your app may register will be updated, etc.
|
||||||
|
// Behind the scenes, touch calls to utimes() which is what we use here - unless we need to authenticate
|
||||||
|
- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:targetURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to update modification & access time because %@ does not exist.", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![targetURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to update modification & access time (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fileDescriptor = open(path, O_RDONLY | O_SYMLINK);
|
||||||
|
if (fileDescriptor == -1) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to open file descriptor to %@", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using futimes() because utimes() follows symbolic links
|
||||||
|
BOOL updatedTime = (futimes(fileDescriptor, NULL) == 0);
|
||||||
|
|
||||||
|
close(fileDescriptor);
|
||||||
|
|
||||||
|
if (updatedTime) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errno != EACCES) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to update modification & access time for %@", targetURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpUpdateModificationAndAccessTimeCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
|
if (!success && error != NULL) {
|
||||||
|
NSString *errorMessage = [NSString stringWithFormat:@"Failed to update modification & access time on %@ with authorization.", targetURL.path.lastPathComponent];
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates a directory at the item pointed by url
|
||||||
|
// An item cannot already exist at the url, but the parent must be a directory that exists
|
||||||
|
- (BOOL)makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if ([self _itemExistsAtURL:url]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because file %@ already exists.", url.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSURL *parentURL = [url URLByDeletingLastPathComponent];
|
||||||
|
BOOL isParentADirectory = NO;
|
||||||
|
if (![self _itemExistsAtURL:parentURL isDirectory:&isParentADirectory] || !isParentADirectory) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because parent directory %@ does not exist.", parentURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *createDirectoryError = nil;
|
||||||
|
if ([_fileManager createDirectoryAtURL:url withIntermediateDirectories:NO attributes:nil error:&createDirectoryError]) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NS_HAS_PERMISSION_ERROR(createDirectoryError)) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = createDirectoryError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Directory to create (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpMakeDirectoryCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
|
if (!success) {
|
||||||
|
if (error != NULL) {
|
||||||
|
NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authorization.", url.path.lastPathComponent];
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)directoryURL error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
NSError *tempError = nil;
|
||||||
|
NSURL *tempURL = [_fileManager URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask appropriateForURL:directoryURL create:YES error:&tempError];
|
||||||
|
|
||||||
|
if (tempURL != nil) {
|
||||||
|
return tempURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is pretty unlikely in my testing we will get here, but just in case we do, we should create a directory inside
|
||||||
|
// the directory pointed by directoryURL, using the preferredName
|
||||||
|
|
||||||
|
NSURL *desiredURL = [directoryURL URLByAppendingPathComponent:preferredName];
|
||||||
|
NSUInteger tagIndex = 1;
|
||||||
|
while ([self _itemExistsAtURL:desiredURL] && tagIndex <= 9999) {
|
||||||
|
desiredURL = [directoryURL URLByAppendingPathComponent:[preferredName stringByAppendingFormat:@" (%lu)", (unsigned long)++tagIndex]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [self makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:url]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file %@ because it does not exist.", url.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *removeError = nil;
|
||||||
|
if ([_fileManager removeItemAtURL:url error:&removeError]) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NS_HAS_PERMISSION_ERROR(removeError)) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = removeError;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to remove (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||||
|
|
||||||
|
if (!success && error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent], NSUnderlyingErrorKey: executeError }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlike other methods, authorization is required to execute this method successfully
|
||||||
|
- (BOOL)executePackageAtURL:(NSURL *)packageURL progressBlock:(void(^)(double))progressBlock error:(NSError * __autoreleasing *)error
|
||||||
|
{
|
||||||
|
if (![self _itemExistsAtURL:packageURL]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to execute package %@ because the file does not exist.", packageURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[PATH_MAX] = {0};
|
||||||
|
if (![packageURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||||
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Package to execute (%@) cannot be represented as a valid file name.", packageURL.path.lastPathComponent] }];
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSError *executeError = nil;
|
||||||
|
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpInstallCommand sourcePath:path destinationPath:NULL lineCallback:^(NSString *line){
|
||||||
|
if ([line hasPrefix:@"installer:%"]) {
|
||||||
|
progressBlock([[line substringFromIndex:11] doubleValue]/100.0);
|
||||||
|
}
|
||||||
|
} error:&executeError];
|
||||||
|
|
||||||
|
if (!success && error != NULL) {
|
||||||
|
NSString* errorMessage = @"Failed to execute package installer.";
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError}];
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma clang diagnostic pop
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
|
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
|
||||||
|
|
||||||
The installer package is installed using Mac OS X's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
The installer package is installed using macOS's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
|
||||||
|
|
||||||
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
|
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.
|
||||||
|
|
||||||
@@ -19,17 +19,15 @@ A guided installation can be started by applications other than the application
|
|||||||
- Replace the use of `AuthorizationExecuteWithPrivilegesAndWait`. This method remains because it is well supported and tested. Ideally a helper tool or XPC would be used.
|
- 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 <Foundation/Foundation.h>
|
||||||
#import "Sparkle.h"
|
#import "SUInstallerProtocol.h"
|
||||||
#import "SUInstaller.h"
|
|
||||||
|
|
||||||
@interface SUGuidedPackageInstaller : SUInstaller
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface SUGuidedPackageInstaller : NSObject <SUInstallerProtocol>
|
||||||
|
|
||||||
|
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath;
|
||||||
|
|
||||||
/*! Perform the guided installation */
|
|
||||||
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -6,139 +6,52 @@
|
|||||||
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <sys/stat.h>
|
|
||||||
#import <Security/Security.h>
|
|
||||||
|
|
||||||
#import "SUGuidedPackageInstaller.h"
|
#import "SUGuidedPackageInstaller.h"
|
||||||
|
#import "SUFileManager.h"
|
||||||
|
|
||||||
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments)
|
|
||||||
{
|
|
||||||
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
|
|
||||||
BOOL returnValue = YES;
|
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
/* AuthorizationExecuteWithPrivileges used to support 10.4+; should be replaced with XPC or external process */
|
|
||||||
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
{
|
|
||||||
int status = 0;
|
|
||||||
pid_t pid = wait(&status);
|
|
||||||
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
|
||||||
returnValue = NO;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
returnValue = NO;
|
|
||||||
|
|
||||||
signal(SIGCHLD, oldSigChildHandler);
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
|
@interface SUGuidedPackageInstaller ()
|
||||||
{
|
|
||||||
SUParameterAssert(executablePath);
|
@property (nonatomic, readonly, copy) NSString *packagePath;
|
||||||
|
@property (nonatomic, readonly, copy) NSString *installationPath;
|
||||||
// Get authorization using advice in Apple's Technical Q&A1172
|
@property (nonatomic, readonly, copy) NSString *fileOperationToolPath;
|
||||||
|
|
||||||
// ...create authorization without specific rights
|
|
||||||
AuthorizationRef auth = NULL;
|
|
||||||
OSStatus validAuth = AuthorizationCreate(NULL,
|
|
||||||
kAuthorizationEmptyEnvironment,
|
|
||||||
kAuthorizationFlagDefaults,
|
|
||||||
&auth);
|
|
||||||
// ...then extend authorization with desired rights
|
|
||||||
if ((validAuth == errAuthorizationSuccess) &&
|
|
||||||
(auth != NULL))
|
|
||||||
{
|
|
||||||
char executableFileSystemRepresentation[PATH_MAX];
|
|
||||||
[executablePath getFileSystemRepresentation:executableFileSystemRepresentation maxLength:sizeof(executableFileSystemRepresentation)];
|
|
||||||
|
|
||||||
// Prepare a right allowing script to execute with privileges
|
|
||||||
AuthorizationItem right = {
|
|
||||||
.name = kAuthorizationRightExecute,
|
|
||||||
.value = executableFileSystemRepresentation,
|
|
||||||
.valueLength = strlen(executableFileSystemRepresentation),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Package up the single right
|
|
||||||
AuthorizationRights rights;
|
|
||||||
memset(&rights,0,sizeof(rights));
|
|
||||||
rights.count = 1;
|
|
||||||
rights.items = &right;
|
|
||||||
|
|
||||||
// Extend rights to run script
|
|
||||||
validAuth = AuthorizationCopyRights(auth,
|
|
||||||
&rights,
|
|
||||||
kAuthorizationEmptyEnvironment,
|
|
||||||
(AuthorizationFlags)
|
|
||||||
(kAuthorizationFlagPreAuthorize |
|
|
||||||
kAuthorizationFlagExtendRights |
|
|
||||||
kAuthorizationFlagInteractionAllowed),
|
|
||||||
NULL);
|
|
||||||
if (validAuth != errAuthorizationSuccess)
|
|
||||||
{
|
|
||||||
// Error, clean up authorization
|
|
||||||
(void) AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
|
||||||
auth = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return auth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SUGuidedPackageInstaller
|
@implementation SUGuidedPackageInstaller
|
||||||
|
|
||||||
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
|
@synthesize packagePath = _packagePath;
|
||||||
|
@synthesize installationPath = _installationPath;
|
||||||
|
@synthesize fileOperationToolPath = _fileOperationToolPath;
|
||||||
|
|
||||||
|
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath
|
||||||
{
|
{
|
||||||
SUParameterAssert(packagePath);
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
_packagePath = [packagePath copy];
|
||||||
|
_installationPath = [installationPath copy];
|
||||||
|
_fileOperationToolPath = [fileOperationToolPath copy];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
- (BOOL)performInitialInstallation:(NSError * __autoreleasing *)__unused error
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
// Preflight
|
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))progressBlock error:(NSError * __autoreleasing *)error
|
||||||
NSString* installerPath = @"/usr/sbin/installer"; // Mac OS X 10.2+ command line installer tool
|
{
|
||||||
NSError* error = nil;
|
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:self.fileOperationToolPath];
|
||||||
|
|
||||||
|
return [fileManager executePackageAtURL:[NSURL fileURLWithPath:self.packagePath] progressBlock:progressBlock error:error];
|
||||||
|
}
|
||||||
|
|
||||||
// Create authorization for installer executable
|
- (BOOL)canInstallSilently
|
||||||
BOOL validInstallation = NO;
|
{
|
||||||
AuthorizationRef auth = [self authorizationForExecutable:installerPath];
|
return YES;
|
||||||
if (auth != NULL)
|
|
||||||
{
|
|
||||||
char pathBuffer[PATH_MAX] = {0};
|
|
||||||
[packagePath getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
|
|
||||||
|
|
||||||
// Permission was granted to execute the installer with privileges
|
|
||||||
char * const arguments[] = {
|
|
||||||
"-pkg",
|
|
||||||
pathBuffer,
|
|
||||||
"-target",
|
|
||||||
"/",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
validInstallation = AuthorizationExecuteWithPrivilegesAndWait(auth,
|
|
||||||
[installerPath fileSystemRepresentation],
|
|
||||||
kAuthorizationFlagDefaults,
|
|
||||||
arguments);
|
|
||||||
// TODO: wait for communications pipe to close via fileno & CFSocketCreateWithNative
|
|
||||||
AuthorizationFree(auth,kAuthorizationFlagDefaults);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Script authorization denied."];
|
|
||||||
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self finishInstallationToPath:destinationPath
|
|
||||||
withResult:validInstallation
|
|
||||||
error:error
|
|
||||||
completionHandler:completionHandler];
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -6,29 +6,19 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SUUpdater.h"
|
|
||||||
#import "SUAppcast.h"
|
|
||||||
#import "SUAppcastItem.h"
|
|
||||||
#import "SUVersionComparisonProtocol.h"
|
|
||||||
|
|
||||||
@interface SUHost : NSObject
|
@interface SUHost : NSObject
|
||||||
|
|
||||||
@property (strong, readonly) NSBundle *bundle;
|
@property (strong, readonly) NSBundle *bundle;
|
||||||
|
|
||||||
+ (NSString *)systemVersionString;
|
|
||||||
|
|
||||||
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
- (instancetype)initWithBundle:(NSBundle *)aBundle;
|
||||||
@property (readonly, copy) NSString *bundlePath;
|
@property (readonly, copy) NSString *bundlePath;
|
||||||
@property (readonly, copy) NSString *appCachePath;
|
|
||||||
@property (readonly, copy) NSString *installationPath;
|
|
||||||
@property (readonly, copy) NSString *name;
|
@property (readonly, copy) NSString *name;
|
||||||
@property (readonly, copy) NSString *version;
|
@property (readonly, copy) NSString *version;
|
||||||
@property (readonly, copy) NSString *displayVersion;
|
@property (readonly, copy) NSString *displayVersion;
|
||||||
@property (readonly, copy) NSImage *icon;
|
|
||||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||||
@property (getter=isBackgroundApplication, readonly) BOOL backgroundApplication;
|
|
||||||
@property (readonly, copy) NSString *publicDSAKey;
|
@property (readonly, copy) NSString *publicDSAKey;
|
||||||
@property (readonly, copy) NSArray *systemProfile;
|
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||||
|
|
||||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key;
|
- (BOOL)boolForInfoDictionaryKey:(NSString *)key;
|
||||||
|
|||||||
@@ -8,24 +8,22 @@
|
|||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
|
|
||||||
#import "SUConstants.h"
|
#import "SUConstants.h"
|
||||||
#import "SUSystemProfiler.h"
|
|
||||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
|
|
||||||
typedef struct {
|
#include "AppKitPrevention.h"
|
||||||
NSInteger majorVersion;
|
|
||||||
NSInteger minorVersion;
|
// This class should not rely on AppKit and should also be process independent
|
||||||
NSInteger patchVersion;
|
// For example, it should not have code that tests writabilty to somewhere on disk,
|
||||||
} NSOperatingSystemVersion;
|
// as that may depend on the privileges of the process owner. Or code that depends on
|
||||||
@interface NSProcessInfo ()
|
// if the process is sandboxed or not; eg: finding the user's caches directory. Or code that depends
|
||||||
- (NSOperatingSystemVersion)operatingSystemVersion;
|
// on compilation flags and if other files exist relative to the host bundle.
|
||||||
@end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@interface SUHost ()
|
@interface SUHost ()
|
||||||
|
|
||||||
@property (strong, readwrite) NSBundle *bundle;
|
@property (strong, readwrite) NSBundle *bundle;
|
||||||
|
@property (nonatomic, readonly) BOOL isMainBundle;
|
||||||
@property (copy) NSString *defaultsDomain;
|
@property (copy) NSString *defaultsDomain;
|
||||||
@property (assign) BOOL usesStandardUserDefaults;
|
@property (assign) BOOL usesStandardUserDefaults;
|
||||||
|
|
||||||
@@ -34,6 +32,7 @@ typedef struct {
|
|||||||
@implementation SUHost
|
@implementation SUHost
|
||||||
|
|
||||||
@synthesize bundle;
|
@synthesize bundle;
|
||||||
|
@synthesize isMainBundle = _isMainBundle;
|
||||||
@synthesize defaultsDomain;
|
@synthesize defaultsDomain;
|
||||||
@synthesize usesStandardUserDefaults;
|
@synthesize usesStandardUserDefaults;
|
||||||
|
|
||||||
@@ -41,13 +40,15 @@ typedef struct {
|
|||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
SUParameterAssert(aBundle);
|
NSParameterAssert(aBundle);
|
||||||
self.bundle = aBundle;
|
self.bundle = aBundle;
|
||||||
if (![self.bundle bundleIdentifier]) {
|
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);
|
SULog(SULogLevelError, @"Error: the bundle being updated at %@ has no %@! This will cause preference read/write to not work properly.", self.bundle, kCFBundleIdentifierKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isMainBundle = [aBundle isEqualTo:[NSBundle mainBundle]];
|
||||||
|
|
||||||
self.defaultsDomain = [self.bundle objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
self.defaultsDomain = [self objectForInfoDictionaryKey:SUDefaultsDomainKey];
|
||||||
if (!self.defaultsDomain) {
|
if (!self.defaultsDomain) {
|
||||||
self.defaultsDomain = [self.bundle bundleIdentifier];
|
self.defaultsDomain = [self.bundle bundleIdentifier];
|
||||||
}
|
}
|
||||||
@@ -60,67 +61,33 @@ typedef struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self bundlePath], [self installationPath]]; }
|
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self bundlePath]]; }
|
||||||
|
|
||||||
- (NSString *)bundlePath
|
- (NSString *)bundlePath
|
||||||
{
|
{
|
||||||
return [self.bundle bundlePath];
|
return [self.bundle bundlePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)appCachePath
|
|
||||||
{
|
|
||||||
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
||||||
NSString *cachePath = nil;
|
|
||||||
if ([cachePaths count]) {
|
|
||||||
cachePath = cachePaths[0];
|
|
||||||
}
|
|
||||||
if (!cachePath) {
|
|
||||||
SULog(@"Failed to find user's cache directory! Using system default");
|
|
||||||
cachePath = NSTemporaryDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *name = [self.bundle bundleIdentifier];
|
|
||||||
if (!name) {
|
|
||||||
name = [self name];
|
|
||||||
}
|
|
||||||
|
|
||||||
cachePath = [cachePath stringByAppendingPathComponent:name];
|
|
||||||
cachePath = [cachePath stringByAppendingPathComponent:@"Sparkle"];
|
|
||||||
return cachePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)installationPath
|
|
||||||
{
|
|
||||||
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
|
||||||
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
|
||||||
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
|
|
||||||
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) {
|
|
||||||
return normalizedAppPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [self.bundle bundlePath];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *__nonnull)name
|
- (NSString *__nonnull)name
|
||||||
{
|
{
|
||||||
NSString *name;
|
NSString *name;
|
||||||
|
|
||||||
// Allow host bundle to provide a custom name
|
// Allow host bundle to provide a custom name
|
||||||
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
|
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
|
||||||
if (name) return name;
|
if (name && name.length > 0) return name;
|
||||||
|
|
||||||
name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||||
if (name) return name;
|
if (name && name.length > 0) return name;
|
||||||
|
|
||||||
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
|
||||||
if (name) return name;
|
if (name && name.length > 0) return name;
|
||||||
|
|
||||||
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
|
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nonnull)version
|
- (NSString *__nonnull)version
|
||||||
{
|
{
|
||||||
NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
NSString *version = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
|
||||||
if (!version || [version isEqualToString:@""])
|
if (!version || [version isEqualToString:@""])
|
||||||
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey];
|
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey];
|
||||||
return version;
|
return version;
|
||||||
@@ -128,58 +95,30 @@ typedef struct {
|
|||||||
|
|
||||||
- (NSString *__nonnull)displayVersion
|
- (NSString *__nonnull)displayVersion
|
||||||
{
|
{
|
||||||
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
NSString *shortVersionString = [self objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||||
if (shortVersionString)
|
if (shortVersionString)
|
||||||
return shortVersionString;
|
return shortVersionString;
|
||||||
else
|
else
|
||||||
return [self version]; // Fall back on the normal version string.
|
return [self version]; // Fall back on the normal version string.
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImage *__nonnull)icon
|
|
||||||
{
|
|
||||||
// Cache the application icon.
|
|
||||||
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
|
|
||||||
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
|
|
||||||
// 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 = [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 ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle;
|
|
||||||
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isRunningOnReadOnlyVolume
|
- (BOOL)isRunningOnReadOnlyVolume
|
||||||
{
|
{
|
||||||
struct statfs statfs_info;
|
struct statfs statfs_info;
|
||||||
statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info);
|
||||||
return (statfs_info.f_flags & MNT_RDONLY);
|
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isBackgroundApplication
|
|
||||||
{
|
|
||||||
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *__nullable)publicDSAKey
|
- (NSString *__nullable)publicDSAKey
|
||||||
{
|
{
|
||||||
// Maybe the key is just a string in the Info.plist.
|
// Maybe the key is just a string in the Info.plist.
|
||||||
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
|
||||||
if (key) {
|
if (key) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// More likely, we've got a reference to a Resources file by filename:
|
// More likely, we've got a reference to a Resources file by filename:
|
||||||
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
NSString *keyFilename = [self publicDSAKeyFileKey];
|
||||||
if (!keyFilename) {
|
if (!keyFilename) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@@ -191,14 +130,28 @@ typedef struct {
|
|||||||
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)systemProfile
|
- (NSString * __nullable)publicDSAKeyFileKey
|
||||||
{
|
{
|
||||||
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
|
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)objectForInfoDictionaryKey:(NSString *)key
|
- (id)objectForInfoDictionaryKey:(NSString *)key
|
||||||
{
|
{
|
||||||
return [self.bundle objectForInfoDictionaryKey:key];
|
if (self.isMainBundle) {
|
||||||
|
// Common fast path - if we're updating the main bundle, that means our updater and host bundle's lifetime is the same
|
||||||
|
// If the bundle happens to be updated or change, that means our updater process needs to be terminated first to do it safely
|
||||||
|
// Thus we can rely on the cached Info dictionary
|
||||||
|
return [self.bundle objectForInfoDictionaryKey:key];
|
||||||
|
} else {
|
||||||
|
// Slow path - if we're updating another bundle, we should read in the most up to date Info dictionary because
|
||||||
|
// the bundle can be replaced externally or even by us.
|
||||||
|
// This is the easiest way to read the Info dictionary values *correctly* despite some performance loss.
|
||||||
|
// A mutable method to reload the Info dictionary at certain points and have it cached at other points is challenging to do correctly.
|
||||||
|
CFDictionaryRef cfInfoDictionary = CFBundleCopyInfoDictionaryInDirectory((CFURLRef)self.bundle.bundleURL);
|
||||||
|
NSDictionary *infoDictionary = CFBridgingRelease(cfInfoDictionary);
|
||||||
|
|
||||||
|
return [infoDictionary objectForKey:key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
- (BOOL)boolForInfoDictionaryKey:(NSString *)key
|
||||||
@@ -223,6 +176,7 @@ typedef struct {
|
|||||||
return CFBridgingRelease(obj);
|
return CFBridgingRelease(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note this handles nil being passed for defaultName, in which case the user default will be removed
|
||||||
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName
|
- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName
|
||||||
{
|
{
|
||||||
if (self.usesStandardUserDefaults)
|
if (self.usesStandardUserDefaults)
|
||||||
@@ -276,21 +230,4 @@ typedef struct {
|
|||||||
return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key];
|
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
|
@end
|
||||||
@@ -6,20 +6,21 @@
|
|||||||
// Copyright 2008 Andy Matuschak. All rights reserved.
|
// Copyright 2008 Andy Matuschak. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SUINSTALLER_H
|
#import <Foundation/Foundation.h>
|
||||||
#define SUINSTALLER_H
|
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import "SUVersionComparisonProtocol.h"
|
#import "SUVersionComparisonProtocol.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class SUHost;
|
@class SUHost;
|
||||||
|
|
||||||
|
@protocol SUInstallerProtocol;
|
||||||
|
|
||||||
@interface SUInstaller : NSObject
|
@interface SUInstaller : NSObject
|
||||||
|
|
||||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr;
|
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath updateDirectory:(NSString *)updateDirectory error:(NSError **)error;
|
||||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
|
|
||||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
|
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr;
|
||||||
+ (NSString *)updateFolder;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
NS_ASSUME_NONNULL_END
|
||||||
@@ -7,45 +7,32 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "SUInstaller.h"
|
#import "SUInstaller.h"
|
||||||
|
#import "SUInstallerProtocol.h"
|
||||||
#import "SUPlainInstaller.h"
|
#import "SUPlainInstaller.h"
|
||||||
#import "SUPackageInstaller.h"
|
#import "SUPackageInstaller.h"
|
||||||
#import "SUGuidedPackageInstaller.h"
|
#import "SUGuidedPackageInstaller.h"
|
||||||
#import "SUHost.h"
|
#import "SUHost.h"
|
||||||
#import "SUConstants.h"
|
|
||||||
#import "SULog.h"
|
#import "SULog.h"
|
||||||
|
#import "SUErrors.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "AppKitPrevention.h"
|
||||||
|
|
||||||
@implementation SUInstaller
|
@implementation SUInstaller
|
||||||
|
|
||||||
static NSString *sUpdateFolder = nil;
|
|
||||||
|
|
||||||
+ (NSString *)updateFolder
|
|
||||||
{
|
|
||||||
return sUpdateFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
+ (BOOL)isAliasFolderAtPath:(NSString *)path
|
||||||
{
|
{
|
||||||
FSRef fileRef;
|
NSNumber *aliasFlag = nil;
|
||||||
OSStatus err = noErr;
|
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
|
||||||
Boolean aliasFileFlag = false, folderFlag = false;
|
NSNumber *directoryFlag = nil;
|
||||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
[[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil];
|
||||||
|
return aliasFlag.boolValue && directoryFlag.boolValue;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
|
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr
|
||||||
{
|
{
|
||||||
SUParameterAssert(inUpdateFolder);
|
NSParameterAssert(inUpdateFolder);
|
||||||
SUParameterAssert(host);
|
NSParameterAssert(host);
|
||||||
|
|
||||||
// Search subdirectories for the application
|
// Search subdirectories for the application
|
||||||
NSString *currentFile,
|
NSString *currentFile,
|
||||||
@@ -53,13 +40,11 @@ static NSString *sUpdateFolder = nil;
|
|||||||
*bundleFileName = [[host bundlePath] lastPathComponent],
|
*bundleFileName = [[host bundlePath] lastPathComponent],
|
||||||
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
|
||||||
BOOL isPackage = NO;
|
BOOL isPackage = NO;
|
||||||
BOOL isGuided = NO;
|
BOOL isGuided = YES;
|
||||||
NSString *fallbackPackagePath = nil;
|
NSString *fallbackPackagePath = nil;
|
||||||
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
|
||||||
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
|
||||||
|
|
||||||
sUpdateFolder = inUpdateFolder;
|
|
||||||
|
|
||||||
while ((currentFile = [dirEnum nextObject])) {
|
while ((currentFile = [dirEnum nextObject])) {
|
||||||
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
|
||||||
NSString *currentFilename = [currentFile lastPathComponent];
|
NSString *currentFilename = [currentFile lastPathComponent];
|
||||||
@@ -105,9 +90,12 @@ static NSString *sUpdateFolder = nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPackage) {
|
if (isPackage) {
|
||||||
// foo.app -> foo.sparkle_guided.pkg or foo.sparkle_guided.mpkg
|
// Guided (or now "normal") installs used to be opt-in (i.e, Sparkle would detect foo.sparkle_guided.pkg or foo.sparkle_guided.mpkg),
|
||||||
if ([[[newAppDownloadPath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_guided"]) {
|
// but to get an interactive (or "unguided") install, the developer now must opt-out of guided installations.
|
||||||
isGuided = YES;
|
|
||||||
|
// foo.app -> foo.sparkle_interactive.pkg or foo.sparkle_interactive.mpkg
|
||||||
|
if ([[[newAppDownloadPath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_interactive"]) {
|
||||||
|
isGuided = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,65 +105,59 @@ static NSString *sUpdateFolder = nil;
|
|||||||
*isGuidedPtr = isGuided;
|
*isGuidedPtr = isGuided;
|
||||||
|
|
||||||
if (!newAppDownloadPath) {
|
if (!newAppDownloadPath) {
|
||||||
SULog(@"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
|
SULog(SULogLevelError, @"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
|
||||||
}
|
}
|
||||||
return newAppDownloadPath;
|
return newAppDownloadPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
|
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath updateDirectory:(NSString *)updateDirectory error:(NSError * __autoreleasing *)error
|
||||||
{
|
{
|
||||||
BOOL isPackage = NO;
|
BOOL isPackage = NO;
|
||||||
BOOL isGuided = NO;
|
BOOL isGuided = NO;
|
||||||
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage isGuided:&isGuided];
|
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host isPackage:&isPackage isGuided:&isGuided];
|
||||||
|
|
||||||
if (newAppDownloadPath == nil) {
|
if (newDownloadPath == 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];
|
if (error != NULL) {
|
||||||
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }];
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
id <SUInstallerProtocol> installer;
|
||||||
|
if (isPackage && isGuided) {
|
||||||
|
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath installationPath:host.bundlePath fileOperationToolPath:fileOperationToolPath];
|
||||||
|
} else if (isPackage) {
|
||||||
|
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath installationPath:host.bundlePath];
|
||||||
} else {
|
} else {
|
||||||
if (isPackage && isGuided) {
|
NSString *normalizedInstallationPath = nil;
|
||||||
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
|
||||||
} else if (isPackage) {
|
normalizedInstallationPath = [self normalizedInstallationPathForHost:host];
|
||||||
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
}
|
||||||
|
|
||||||
|
// If we have a normalized path, we'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
|
||||||
|
// Otherwise if there's no normalized path (the more likely case), we'll just use the host bundle's path
|
||||||
|
NSString *installationPath;
|
||||||
|
if (normalizedInstallationPath != nil && ![[NSFileManager defaultManager] fileExistsAtPath:normalizedInstallationPath]) {
|
||||||
|
installationPath = normalizedInstallationPath;
|
||||||
} else {
|
} else {
|
||||||
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
|
installationPath = host.bundlePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
installer = [[SUPlainInstaller alloc] initWithHost:host bundlePath:newDownloadPath installationPath:installationPath fileOperationToolPath:fileOperationToolPath];
|
||||||
}
|
}
|
||||||
|
return installer;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)mdimportInstallationPath:(NSString *)installationPath
|
+ (NSString *)normalizedInstallationPathForHost:(SUHost *)host
|
||||||
{
|
{
|
||||||
// *** GETS CALLED ON NON-MAIN THREAD!
|
NSBundle *bundle = host.bundle;
|
||||||
|
assert(bundle != nil);
|
||||||
|
|
||||||
|
NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]];
|
||||||
|
|
||||||
SULog(@"mdimporting");
|
// Roundtrip string through fileSystemRepresentation to ensure it uses filesystem's Unicode normalization
|
||||||
|
// rather than arbitrary Unicode form from Info.plist - #1017
|
||||||
NSTask *mdimport = [[NSTask alloc] init];
|
return [NSString stringWithUTF8String:[normalizedAppPath fileSystemRepresentation]];
|
||||||
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
|
|
||||||
[mdimport setArguments:@[installationPath]];
|
|
||||||
@try {
|
|
||||||
[mdimport launch];
|
|
||||||
[mdimport waitUntilExit];
|
|
||||||
}
|
|
||||||
@catch (NSException *launchException)
|
|
||||||
{
|
|
||||||
// No big deal.
|
|
||||||
SULog(@"Error: %@", [launchException description]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
|
|
||||||
{
|
|
||||||
if (result) {
|
|
||||||
[self mdimportInstallationPath:installationPath];
|
|
||||||
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
|
@end
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// SUInstallerProtocol.h
|
||||||
|
// Sparkle
|
||||||
|
//
|
||||||
|
// Created by Mayur Pawashe on 12/26/16.
|
||||||
|
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@protocol SUInstallerProtocol <NSObject>
|
||||||
|
|
||||||
|
// Any installation work can be done prior to user application being terminated and relaunched
|
||||||
|
// Currently this is invoked after the user application is terminated, but this may change in the future.
|
||||||
|
// No UI should occur during this stage (i.e, do not show package installer apps, etc..)
|
||||||
|
// Should be able to be called from non-main thread
|
||||||
|
- (BOOL)performInitialInstallation:(NSError **)error;
|
||||||
|
|
||||||
|
// Any installation work after the user application has been terminated. This is where the final installation work can be done.
|
||||||
|
// After this stage is done, the user application may be relaunched.
|
||||||
|
// Should be able to be called from non-main thread
|
||||||
|
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))cb error:(NSError **)error;
|
||||||
|
|
||||||
|
// Indicates whether or not this installer can install the update silently in the background, without hindering the user
|
||||||
|
// Should be thread safe
|
||||||
|
- (BOOL)canInstallSilently;
|
||||||
|
|
||||||
|
// The destination and installation path of the bundle being updated
|
||||||
|
// Should be thread safe
|
||||||
|
- (NSString *)installationPath;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||