Compare commits

..
580 Commits
Author SHA1 Message Date
Kenneth Johnsen 962878b843 Fix missing Danish translations in Sparkle.strings 2020-02-03 17:23:52 +00:00
pteeson 9d8909c38d Remove .h files from Build Rules for bsdiff and ed25519 (#1538)
On branch VendorBuildPhasesFix
Changes to be committed:
	modified:   Sparkle.xcodeproj/project.pbxproj

Building the Sparkle framework produced 10 Warnings caused by .h files
being added to the Build Rules Compile Sources. Thanks to tip from
Stackoverflow https://stackoverflow.com/questions/6509600/

"Click on your project, and check that this file is not present in the
tab Build Phases. Normally no header files should stay here.
Clean and build it again, it should work!"

It does work.
2020-01-25 12:25:04 +00:00
BR Lingo 99a00a2c17 Update Sparkle.strings (#1531) 2019-12-31 11:01:10 +00:00
Kornel 1d2b74e39d Merge pull request #1527 from quinntaylor/hoist-SWIFT_VERSION-4.2
Hoist `SWIFT_VERSION = 4.2` setting up to ConfigSwift.xcconfig, remove unnecessary target overrides.
2019-12-17 00:05:43 +00:00
Kornel b097e64b56 Merge pull request #1526 from quinntaylor/array-generics
Added array generics to fix warnings, and fixed typo in variable name…
2019-12-17 00:05:19 +00:00
Kornel 28a245dd53 Merge pull request #1525 from quinntaylor/Turkish-strings-missing-quote
Fixed missing quote in Turkish strings file, caused by PR #1516.
2019-12-17 00:04:41 +00:00
Quinn Taylor 4eabf002c5 Hoist SWIFT_VERSION = 4.2 setting up to ConfigSwift.xcconfig, remove unnecessary target overrides. 2019-12-16 10:53:29 -05:00
Quinn Taylor ae4af4d61f Added array generics to fix warnings, and fixed typo in variable name when parsing BinaryDelta command-line arg flags. 2019-12-16 09:40:17 -05:00
Quinn Taylor dd9c7d0e1c Fixed missing quote in Turkish strings file, caused by PR #1516. 2019-12-16 09:18:48 -05:00
Kornel 7ab8823757 Bump 2019-12-15 21:40:47 +00:00
Kornel dd287029db Fix second bold sentence in read-only update alert dialog. (#15… (#1516)
Fix second bold sentence in read-only update alert dialog. (#1515)
2019-12-15 17:07:51 +00:00
Quinn Taylor 6ec6007091 Fix second bold sentence in read-only update alert dialog. (#1515)
• Updated error dialog code in SUBasicUpdateDriver, and created a local variable to reuse `[aHost name]`.
• Updated content of Sparkle.strings files, splitting existing affected translations into 2 chunks each.
• Fixed the Catalan translation, which was using an old string key.
• Removed a few unnecessary comments in the Polish translation.
2019-12-14 13:28:40 -05:00
Kornel 985be854c4 Merge pull request #1520 from jakob/update-readme-1.x
Update README for Sparkle 1.x
2019-12-14 16:51:18 +00:00
Kornel 8129cc1c03 Merge pull request #1519 from jakob/issue-templates
Separate issue templates for Sparkle 1.x and 2.x
2019-12-14 16:49:44 +00:00
Jakob dddba708d2 Add prominent note about Sparkle 2.x to README 2019-12-14 15:39:14 +01:00
Jakob 2596a54935 Add link to 2.x branch 2019-12-14 15:38:57 +01:00
Jakob 794a90a5e2 Add 1.x version number to README title 2019-12-14 15:38:26 +01:00
Jakob 9e7c3463e0 Add Issue templates for Sparkle 1.x and 2.x 2019-12-14 15:23:25 +01:00
CoreCode ed40ef1267 update PR #1512 again to fix compilation issues (#1518)
* Update SUPlainInstaller.m
2019-12-13 16:35:10 +00:00
CoreCode b9a4917f81 Update for PR #1512 to correctly support 10.7 and 10.8 (#1514)
* Update SUPlainInstaller.m

Try to preserve Finder tags while updating apps

* Update SUPlainInstaller.m
2019-12-12 11:06:00 +00:00
CoreCode 1081dcdda1 Update SUPlainInstaller.m (#1512)
Try to preserve Finder tags while updating apps
2019-12-11 19:11:28 +00:00
Frank Chiarulli Jr 3a497ddcbd fix spelling (#1508) 2019-12-04 00:05:09 +00:00
Alec Larson 8f6c7ccdeb feat: properly compare versions with commit SHA (#1504) 2019-11-22 15:12:19 +00:00
Alik Vovkotrub 0e9d96a303 Support generating appcast with localizations (#1499)
* 1205 generate_appcast support localized Release Notes
2019-11-12 16:43:38 +00:00
marchyang 531b767c0b feat: sign_update support key argument 2019-10-18 12:36:17 +01:00
Kenneth Johnsen 0cfedd4516 Hide "Skip..." and "Remind..." buttons. (#1480)
Show/Hide skip/later buttons based on whether update is critical / automatic updates enabled.

The skip-button is now hidden for critical updates, and the later-button is hidden if automatic updates are disabled.
Note that the user can still choose to just close the window by clicking the red dot at the top of the window.
2019-10-15 14:04:31 +01:00
Kornel 8f01babdd3 Merge pull request #1485 from bitigchi/patch-1
Update Sparkle.strings
2019-10-09 21:06:54 +01:00
Emir Sarı 5dab9c40ab Update Sparkle.strings
Added some missed translation.
2019-10-09 18:48:33 +03:00
Kornel Lesiński f2dd8fe371 Move BR locale files to correct location 2019-10-09 00:08:38 +01:00
Kornel 5d0e5dd407 Terminology Update for BR (#1484)
Terminology Update for BR
2019-10-09 00:05:44 +01:00
BR Lingo 39fb433131 Add files via upload 2019-10-08 17:40:49 -04:00
BR Lingo e68a2621ed Merge pull request #3 from sparkle-project/master
Commits from original
2019-10-08 17:28:32 -04:00
Kornel cb6545d601 Merge pull request #1483 from qwertyyb/master
fix public key doesn't match problem
2019-10-08 18:43:33 +01:00
marchyang 6dbbf08654 fix public key dont match problem when use generate_appcast with -s <private_key> <folder> arguments 2019-10-08 19:43:20 +08:00
Kornel d5222353e6 Merge pull request #1458 from BitShift-Tech/appcast-generation-file-extention
SUFeedUrl generate appcast file extension (let fix)
2019-08-21 10:57:45 +01:00
Tom Vos 2657a41d55 Update ArchiveItem.swift
feedURl was a let and therefore not assignable
2019-08-21 11:16:06 +02:00
Kornel 08d3ff747d Merge pull request #1454
SUFeedUrl generate appcast file extension
2019-08-21 09:58:08 +01:00
Tom Vos fedb22e224 Update ArchiveItem.swift
The *ing methods didn't alter the value, they provided a new value which was not assigned to anything.
2019-08-21 10:20:37 +02:00
Kornel 8293c3c6ae Merge pull request #1457 from LeoNatan/master
Fix incorrect and inconsistent selectors and delegate methods
2019-08-20 02:58:35 +01:00
Leo Natan 181f813b01 Fix incorrect and inconsistent selectors and delegate methods. 2019-08-20 04:12:33 +03:00
Kornel a10a974609 Merge pull request #1456 from webjib/patch-1
Update Sparkle.strings
2019-08-19 14:38:39 +01:00
Jean-Baptiste f8572f79cb Update Sparkle.strings
Issue #1429
https://github.com/sparkle-project/Sparkle/issues/1429
2019-08-19 15:18:14 +02:00
Kornel 2b54753090 add delegate userDidSkipThisVersion (#1409)
add delegate userDidSkipThisVersion
2019-08-14 09:40:01 +01:00
bono yusuke 2db2fffab9 Update SUUIBasedUpdateDriver.m 2019-08-14 17:12:16 +09:00
Tom Vos 035bfc4919 Fix typo 2019-08-13 12:18:42 +02:00
Tom Vos 48fc202f36 Processed requested changes
Instead of using find and replace, use the correct methods on URL to change the file name and extention.
2019-08-13 12:17:12 +02:00
Tom Vos 28ff3069ff Update ArchiveItem.swift
When the SUFeedURL extention is "php", replace filename.php with appcast.xml in generate_appcast
2019-08-13 09:45:10 +02:00
Kornel 795ce1278d Merge pull request #1445 from fujisoft/patch-1
Update Japanese localization #1429
2019-08-03 15:48:27 +01:00
fujisoft 6ac853271d Update Japanese localization
#1429
2019-08-03 13:38:13 +09:00
Kornel 7e5e91888f Merge pull request #1444 from jfenton-tsc/fix/normalize-should-respect-specified-bundle-name
check if SUBundleName is set before normalizing
2019-08-03 00:00:55 +01:00
Jake Fenton b0d29ae798 check if SUBundleName is set before normalizing
When changing the name of an app, there's a couple things to do in order
to ensure auto-updates still work:

1. set SUBundle Name. This basically tells Sparkle "ey, expect an app
of {SUBundleName}.(app|pkg) instead of the normal name."
2. set `SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME` in
commonConfig.xccconfig to reset the name of the app.

in (2), we always used the host's bundle name, instead of checking to
see if SUBundleName was set, which means normalization doesn't work as
expected during app name changes.
2019-08-02 09:29:12 -04:00
Kornel 09bbf9fdc6 Merge pull request #1443 from gotow/master
In 'newer than latest' alert, show displayVersionString instead of versionString
2019-08-02 10:49:28 +01:00
gotow f2bd7ea2b2 Update SUUIBasedUpdateDriver.m 2019-08-01 22:35:28 -06:00
Kornel 35deefdc0c Merge pull request #1439 from whakkee/master
cast to NSInteger to get rid of warning on Xcode 11
2019-07-14 21:19:51 +01:00
Marga Keuvelaar 3e53979236 cast to NSInteger to get rid of warning on Xcode 11 2019-07-12 21:53:29 +02:00
Kornel f8971098be Reset timers after computer sleep (#1437)
Update SUUpdater.m
2019-07-09 18:45:13 +01:00
CoreCode efd1840f35 Update SUUpdater.m 2019-07-08 20:51:16 +02:00
Kornel 17dbdf98e1 Merge pull request #1435 from Yakuhzi/master
Support providing private key as argument
2019-07-05 22:59:20 +02:00
Yakuhzi 79f110a17b Support providing private key as argument 2019-07-05 13:12:11 +02:00
Kornel 5ab0baf84c Merge pull request #1431 from vitu/master
BR update of new string on Sparkle.strings
2019-07-02 11:39:22 +01:00
BR Lingo 578dac0ad7 BR update of new string on Sparkle.strings
Translation for string added by CoreCode.
2019-06-30 02:56:55 -04:00
BR Lingo 920b5bac5e Merge pull request #2 from sparkle-project/master
Update from original repo
2019-06-30 02:45:09 -04:00
Kornel 9ae7224a47 Changelog 2019-06-29 14:41:52 +01:00
Kornel 685be61bc3 Use recommended locale names 2019-06-29 14:41:06 +01:00
Kornel 9be76d3d5a Build with hardened runtime 2019-06-29 14:41:06 +01:00
Kornel fc1960966a Update Sparkle.strings 2019-06-29 14:00:36 +01:00
Kornel 7248e40fda Fix issue #1411 (#1427)
Fix issue #1411
2019-06-28 18:32:20 +01:00
Julian Mayer b8d37346a6 Add translations for new string 2019-06-28 15:07:30 +02:00
CoreCode 2769221117 Update SUBasicUpdateDriver.h 2019-06-27 17:22:12 +02:00
CoreCode 6317a6c74f Update SUBasicUpdateDriver.m 2019-06-27 17:21:50 +02:00
CoreCode f785c7177c Update SUUIBasedUpdateDriver.m
Provide fix for issue #1411
2019-06-27 17:19:03 +02:00
Kornel cd78595c63 Move header copies for bsdiff and ed25519 into a Copy Files build phase (#1421)
Move header copies for bsdiff and ed25519 into a Copy Files build phase
2019-06-17 23:56:40 +01:00
Tony Arnold 4fd2a7b15f Move header copies for bsdiff and ed25519 into a Copy Files build phase
Headers build phases do not work correctly with static library targets when archiving in Xcode. Delete this phase, add a Copy Files build phase to your library, and use it to export your header files.

Reference TN2215: https://developer.apple.com/library/archive/technotes/tn2215/_index.html#//apple_ref/doc/uid/DTS40011221-CH1-PROJ

Fixes #1420
2019-06-16 15:36:54 +10:00
Kornel 186bbb83d5 Merge pull request #1413 from tonyarnold/minor-fixes
Minor fixes
2019-05-28 14:15:13 +01:00
Tony Arnold 0cc8a2f16a Fix a spelling mistake in the submodule comments 2019-05-28 22:55:11 +10:00
Tony Arnold 0eb1caeec5 Rename “Third Party” Xcode group to “Vendor” to match underlying folder name 2019-05-28 22:54:03 +10:00
Tony Arnold 7138663f86 Separate the bsdiff sources into a new static library, and use them in targets 2019-05-28 22:53:26 +10:00
Tony Arnold b767285be0 Separate the ed25519 sources into a new static library 2019-05-28 22:45:53 +10:00
Tony Arnold 5886c2b9b9 Move ed25519 dependency to the Vendor directory 2019-05-28 22:20:58 +10:00
BobZombie f9b534a6b6 add delegate userDidSkipThisVersion 2019-05-17 17:15:41 +09:00
vojtakonarik 5a586d393a Correction of Czech localization inconsistency (#1403)
* Update Sparkle.strings
2019-05-05 00:11:47 +01:00
Michael Buckley b3cc7aed8a Annotate SUHost for nullability 2019-04-22 21:50:20 +01:00
Kornel deb8ea8cc1 Merge pull request #1396 from fumoboy007/pretty-print
Use `XMLNode.Options.nodePrettyPrint` in `generate_appcast` instead of trying to add whitespace manually
2019-04-21 19:09:52 +01:00
fumoboy007 4a3cc18dc3 Use XMLNode.Options.nodePrettyPrint in generate_appcast instead of trying to add whitespace manually 2019-04-20 21:28:45 -07:00
Kornel 75404f6d83 Merge pull request #1392 from panicinc/app-translocation-fix
Improved error when running from translocated location
2019-04-18 20:20:57 +01:00
Michael Buckley 954ed60ecb Improved error when running from translocated location 2019-04-17 20:51:59 -07:00
Kornel ecb5257b2b Update README.markdown 2019-04-14 14:34:04 +01:00
Fabian Jäger fb18c1e542 Phased rollout interval is an appcast item attribute and not its own element (#1385)
* phased rollout interval is an appcast item attribute and not its own element

* add basic test for getting phased rollout interval from appcast item
2019-04-02 15:26:35 +01:00
Fabian Jäger 99f5573619 Allow updating to previous versions if newest appcast item is blocked due to phased rollout (#1384)
The current version of phased rollouts would not find other valid items if the latest one is not ready yet based on the phased rollout group. This PR changes this behavior by using the system's rollout group when finding valid appcast items.
2019-03-29 19:36:29 +00:00
Kornel Lesiński 1edfcaba71 Ignore non-standard permissions in delta updates instead of failing the build
Fixes #1383
2019-03-29 00:06:55 +00:00
Kornel Lesiński fc3221c5d2 Squashed commit of the following:
commit 89a8f1a8b3
Author: Emir Sarı <emirsari@gmail.com>
Date:   Thu Mar 21 20:35:02 2019 -0700

    Fixed capitalization

commit ad0582a89e
Author: Emir Sarı <emirsari@gmail.com>
Date:   Thu Mar 21 17:28:53 2019 -0700

    Fix for changed string

commit 77016c7dff
Author: Emir Sarı <emirsari@gmail.com>
Date:   Thu Mar 21 17:23:21 2019 -0700

    Improvements

    Improvements and layout fixes
2019-03-22 12:06:52 +00:00
Fabian Jäger 26db6982b3 Allow to configure update groups for updating in phases (#1381) 2019-03-20 12:45:48 +00:00
Kornel f550b92f72 Merge pull request #1377 from hofman/master
Fix ed25519 and UITest group paths in project
2019-03-14 11:38:35 +00:00
Christiaan Hofman 5f5fe1b5f9 Fix path for UITests group in project 2019-03-14 11:19:37 +01:00
Christiaan Hofman 6027f2852a fix path for ed5519 group in project 2019-03-14 11:14:12 +01:00
Kornel 60c2f16c9d Merge pull request #1376 from hofman/master
Use AVAILABLE macro to allow compiling with Xcode 8
2019-03-13 23:28:30 +00:00
hofman 5ae7fa7212 Use SUAVAILABLE macro in SPUURLRequest.m 2019-03-13 23:06:25 +01:00
hofman 614b2cc1f3 Use SUAVAILABLE macro in SPUDownloadData.m 2019-03-13 23:04:55 +01:00
hofman 6500bf8c2f Use SUAVAILABLE macro in SUUpdateAlert.m 2019-03-13 23:03:10 +01:00
hofman 3e060d4a7b Use SUAvailable.m in SUStatusController.m 2019-03-13 22:59:53 +01:00
hofman 5286371cb7 Use SUAVAILABLE macro in SUUpdater.m 2019-03-13 22:57:54 +01:00
hofman 2a802447a3 Use SUAVAILABLE macro in SUBasicUpdateDriver.m 2019-03-13 22:55:27 +01:00
hofman c40b42deb1 Use SUAVAILABLE macro in SUAppcast.m 2019-03-13 22:53:32 +01:00
hofman 5d9f41142b Define a macro for @available to have a workaround for Xcode 8 2019-03-13 22:51:14 +01:00
Kornel d540c6a1b9 Merge pull request #1375 from hofman/master
Add -cleanup to -downloadDidUpdate:
2019-03-13 20:47:12 +00:00
hofman e63bcbc047 Add -cleanup to -downloadDidUpdate: 2019-03-13 21:07:22 +01:00
Kornel 4f65e14ee8 Update README.markdown 2019-03-11 14:03:23 +00:00
Kornel fdca1ce6cf Bump 2019-03-10 12:07:53 +00:00
Kornel c3255ed3a7 Merge pull request #1363 from gnachman/gentleRemindersPR
Add delegate methods to suppress update alert.
2019-03-09 23:03:29 +00:00
George Nachman 9b6346516e Pass item to updaterShouldShowUpdateAlertForScheduledUpdate delegate method 2019-03-09 14:58:08 -08:00
Nate Weaver e1f13ebcad Disambiguate signing error messages. 2019-03-03 02:17:24 +00:00
nivekkagicom 420be06ba0 fix warnings when using modules (#1244) 2019-03-02 16:25:15 +00:00
Kornel c7beba948d Add issue templates 2019-02-24 17:35:21 +00:00
Kornel 639b6df47b Merge pull request #1367 from Mailbutler/master
Block-based alternatives to NSInvocation-based delegate methods
2019-02-24 17:05:10 +00:00
Fabian Jäger c9a9cba167 block-based alternatives to NSInvocation-based delegate methods 2019-02-24 16:25:31 +01:00
George Nachman 9f01fd303c Add delegate methods to suppress update alert.
Some applications may prefer to show their own unobtrusive
notification that an update is available when using the
scheduled update driver. This commit adds new delegate
methods to enable that behavior. The delegate may suppress
the alert; if the alert is shown, the delegate is informed
when the user is not interested in a particular update so
they can remove their own notification.
2019-02-21 22:19:31 -08:00
Kornel 1ff1577108 Bump 2019-02-11 14:15:20 +00:00
Kornel 74f2ea540e Merge pull request #1358 from barijaona/smallimages
Losslessly reduced the size of PNG
2019-02-05 02:00:32 +00:00
Barijaona Ramaholimihaso 2652be32f7 Losslessly reduced the size of PNG
By use of OxiPNG, PNGOUT and zopflipng.
Initially submitted by Sveinbjorn Thordarson (@sveinbjornt) at
ViennaRSS/vienna-rss#1237.
2019-02-05 04:46:18 +03:00
Kornel 5118f2b27f Merge pull request #1353 from core-code/master
fix #1352
2019-01-30 15:41:34 +00:00
Julian Mayer b97b60b611 fix 2019-01-30 15:02:13 +01:00
Julian Mayer 3c793482c8 #1352 2019-01-30 13:31:07 +01:00
Kornel 89b4bcde61 Merge pull request #1351 from Wevah/master
Use contentsOfDirectory(at:...) instead of atPath:....
2019-01-26 20:48:12 +00:00
Nate Weaver 3690dd028a Use contentsOfDirectory(at:...) instead of atPath:..., and rename apps to bundles. 2019-01-26 10:59:19 -06:00
Kornel 52e2ef88eb Merge pull request #1350 from Wevah/generate-appcast-bundle-check
Check for all bundles instead of just apps.
2019-01-25 15:41:08 +00:00
Nate Weaver d81633a7d3 Check for all bundles instead of just apps. 2019-01-24 11:49:24 -06:00
Kornel a9e20c7d0a Merge pull request #1347 from pNre/master
Check that effectiveAppearance is being observed before calling removeObserver
2019-01-18 15:21:37 +00:00
Kornel 03a9f57704 Check that effectiveAppearance is being observed before calling removeObserver 2019-01-18 15:58:43 +01:00
Kornel 2f8df626d7 Merge pull request #1340 from kant/patch-1
Semantic issue on #151. Fix typo on paragraph #149
2019-01-12 13:32:52 +00:00
Kornel f5cb6988ed Merge pull request #1341 from kant/patch-2
Fixed typo on string #021
2019-01-12 13:32:20 +00:00
Darío Hereñú 2bfab80998 Fixed typo on string #021 2019-01-12 08:41:46 -03:00
Darío Hereñú 4fa2a37798 Semantic issue on #151. Fix typo on paragraph #149 2019-01-12 08:37:30 -03:00
Kornel 888a7f48a6 Formatting 2018-12-23 11:53:21 +00:00
Kornel 82726c4386 Make it clear that quarantine error is only a warning 2018-12-23 11:53:13 +00:00
Kornel a5b23cdbee Bump 2018-12-18 21:59:38 +00:00
Kornel b19120f5cd Allow EdDSA for delta updates, too 2018-12-16 03:03:23 +00:00
Kornel 4b0a037685 Merge pull request #1331 from ProsoftEngineering/fix-xcode-10-warnings
Fix xcode 10 warnings
2018-12-13 21:05:20 +00:00
Brian Bergstrand 8dadd0003e Fix DEBUG -Wundef warning 2018-12-13 14:39:24 -06:00
Brian Bergstrand 457319f217 Suppress 'direct-ivar-access' warning for property ivar 2018-12-13 14:36:28 -06:00
Kornel 0480b9bb25 Merge pull request #1329 from Bi11/master
Fix release note web view's contextual menu
2018-12-13 19:23:21 +00:00
Bi11 4390eb9eb2 Fix release note web view's contextual menu
Code added in 8ff6c147f2 does not take effect nowadays due to missing assignment of UIDelegate.
2018-12-14 03:05:41 +08:00
Kornel f5c8314c88 Merge pull request #1328 from Bi11/dark-mode
Fix release note WebView's appearance in dark mode
2018-12-13 13:51:25 +00:00
Bi11 1b209e6726 Add a test link in test app 2018-12-13 17:35:49 +08:00
Bi11 a4373e4e0f Fix release note WebView's appearance in dark mode
Referenced commits:
502378553e (PR #1280)
7e351b52c7 (PR #1288)
2018-12-13 17:35:49 +08:00
Kornel d430c33bf4 Merge pull request #1325 from Bi11/master
Fix compile of TestApplication
2018-12-11 02:07:32 +00:00
Bi11 7ef4635d8c Fix compile of TestApplication 2018-12-11 04:16:10 +08:00
Kornel deb4be7a1b Bump 2018-12-10 12:48:46 +00:00
Kornel 5f1bc6b612 Sign appcast tools 2018-12-10 12:47:28 +00:00
Kornel 1cde8110df Explain error 25308 2018-12-10 12:45:40 +00:00
Kornel 1926b7bfa6 1.21.0 2018-11-25 16:01:20 +00:00
Kornel f80907fa2c Check if public key is configured correctly 2018-11-25 15:54:14 +00:00
Kornel 091a86f672 Merge pull request #1317 from HofiOne/2-tiny-issues
2 tiny fixes
2018-11-20 12:50:04 +00:00
Hofi 208b0dc49a 2 tiny fixes
- bogus debug build warning fixed
- fixed docs build warning message to prevent execution of  embedded shell script line
2018-11-20 05:55:17 +01:00
Kornel 5acf3989d2 Make legacy script use a smaller DSA key that macOS still supports
Sizes below 2048 get SHA-1.
2018-11-13 13:36:35 +00:00
Kornel Lesiński 5529a3610d Troubleshooting help 2018-11-12 19:38:17 +00:00
milotype 920ff7f83f Croatian localization added 2018-11-10 18:07:07 +00:00
Kornel 5ff1488f0c Bump 2018-10-31 01:00:16 +00:00
Kornel c0c1c51d8d Ignore symlink permissions in binary deltas
Fixes #1301
2018-10-31 01:00:16 +00:00
Kornel 5139179487 Refactored signature check logic 2018-10-31 01:00:16 +00:00
Kornel f50cbce0e8 Add EdDSA files to tests 2018-10-31 01:00:16 +00:00
Kornel 14f1d3520a Update signing self-check to look for EdDSA 2018-10-31 01:00:16 +00:00
Kornel 9c4729ed4a Use EdDSA keys in test app 2018-10-31 01:00:16 +00:00
Kornel f04a61e159 Sparkle version in logs 2018-10-31 00:50:41 +00:00
Kornel 80d8758fc2 Merge pull request #1302 from elgatosf/master
SPUDownloaderSession leaked because the NSURLSession wasn’t invalidated
2018-10-30 02:38:34 +00:00
Michael Ehrmann 081301d590 SPUDownloaderSession leaked because the NSURLSession wasn’t invalidated 2018-10-29 17:52:48 +01:00
Kornel 397370297b Update README.markdown 2018-09-30 01:01:16 +09:00
Kornel b30dcd979f EdDSA spelling 2018-09-17 13:44:05 +01:00
Kornel ee123edd74 Changelog 2018-09-16 21:12:11 +01:00
Kornel 984625cc7e Build new scripts 2018-09-16 20:55:32 +01:00
Kornel 7b6e7957c6 sign_update tool 2018-09-16 20:55:32 +01:00
Kornel 2815514c23 Bump 2018-09-16 20:55:32 +01:00
Kornel 49eaa4c5cc Objc bugs 2018-09-16 15:57:19 +01:00
Kornel 09bcee7280 Don't re-create unnecessary delta files 2018-09-16 15:19:43 +01:00
Kornel 49ea08b284 Sort project file 2018-09-16 15:07:53 +01:00
Kornel f9dc70ade2 Use proper Caches directory 2018-09-16 15:07:46 +01:00
Kornel 6fb3eee91b Constants for element names 2018-09-16 11:23:27 +01:00
Kornel 19be83b15f Emit edSignature in the appcast 2018-09-16 11:19:28 +01:00
Kornel d90529ccaa Fixed check for supported signatures 2018-09-16 11:19:15 +01:00
Kornel 623b7b6bda ed25519 keys in generate_* tools 2018-09-16 00:40:42 +01:00
Kornel 65bcb3815e Deprecate old DSA scripts 2018-09-16 00:40:42 +01:00
Kornel d5cd95e0ef ed25519 signature verification 2018-09-16 00:40:42 +01:00
Kornel b9150d2938 Rename method 2018-09-16 00:40:42 +01:00
Kornel 1006326157 Make SecKeyRef as needed 2018-09-16 00:40:42 +01:00
Kornel 68856e074b Ed25519 public key in Info.plist 2018-09-16 00:40:42 +01:00
Kornel a86bdb2fa8 ed25519 submodule 2018-09-16 00:40:42 +01:00
Kornel 92e00baafb Don't perform heavy work in constructor 2018-09-15 17:04:05 +01:00
Kornel 98ea3e3d57 Rename 2018-09-15 17:04:05 +01:00
Kornel c094a38231 Wrapper for public keys 2018-09-15 15:54:08 +01:00
Kornel 6df898f9b7 Use signatures object 2018-09-15 15:54:08 +01:00
Kornel 7f51a4e344 Read ed25519 signature from appcast 2018-09-15 15:54:08 +01:00
Kornel 8ad1f57672 SUSignatures 2018-09-15 15:54:08 +01:00
Kornel 8b88183c7d Merge pull request #1278 from tempelmann/master-origin
Make "sign_update" work on pre-10.13 system
2018-08-19 14:45:43 +01:00
Thomas Tempelmann d036d3e3ae Make "sign_update" work on pre-10.13 system by checking the OpenSSL version, using the older "-dss1" digest option again in that case. See ticket 1227 and commit 0cb0b2f 2018-08-19 15:28:03 +02:00
Kornel 8b13eb5dcf Merge pull request #1270 from shayr1/patch-1
Fixed some typos
2018-07-18 18:55:20 +01:00
Shay ba5b7341fa Fixed some typos
Fixed typos in the following keys:
"An error occurred during installation. Please try again later."
"An error occurred in retrieving update information. Please try again later."
Added missing key that fell back to English:
"Cancel Update" = "בטל עדכון"; (Inside alert when using a button to let user check for updates)
2018-07-18 19:16:05 +03:00
Kornel e1d4b19ce7 Bump 2018-07-17 16:37:50 +01:00
sagecook 360c2ce7a9 Fix binary delta creation on network drives
Closes  #1156
2018-07-17 16:33:58 +01:00
Kornel f9740292d4 Merge pull request #1261 from kenohori/master
New Spanish localisation
2018-06-28 12:55:05 +02:00
Ken Arroyo Ohori 558be04121 New Spanish localisation 2018-06-27 21:22:56 -05:00
Kornel b426426905 Merge pull request #1257 from LeoNatan/master
Fix compilation issues on Xcode 10 with new build system
2018-06-20 16:04:39 +01:00
Leo Natan 75835a5874 Fix compilation issues on Xcode 10 with new build system 2018-06-20 15:29:50 +03:00
Kornel 50c12d1c2b Bump 2018-06-19 22:36:19 +01:00
Kornel e452b7f6ba Merge pull request #1251 from ksuther/objc-messaging-id-fixes
Silence Xcode 10 "Messaging unqualified id" warnings by specifying types
2018-06-14 21:56:05 +03:00
Kent Sutherland 3034eca85b Updated readme to indicate that the 10.11 SDK is required to compile
Xcode 7 was released with 10.11, the reference to the 10.8 SDK is out of date.
2018-06-14 20:31:58 +02:00
Kent Sutherland 9ae41fe4ab Explicitly specify types to silence "Messaging unqualified id" warning that's new in Xcode 10.
Removed __has_feature(objc_generics) check and use generisc to help silence the warnings.
2018-06-14 20:31:20 +02:00
Kornel 7d931e22d7 Merge pull request #1249 from JasonLPollack/update-finnish
Updated Finnish language resources
2018-06-14 18:57:56 +03:00
Jason Pollack b303ee312b Updated Finnish language resources 2018-06-14 10:05:31 -04:00
BR Lingo 9453761aef Merge pull request #1 from sparkle-project/master
Hey, self. Please let me in.
2018-06-09 00:38:49 -04:00
Kornel d19c98a877 Merge pull request #1245 from grahammiln/master
Remove executable bit on distributed source files.
2018-06-04 12:32:30 +01:00
Graham Miln 7a4caad5fe Remove executable bit on distributed source files. 2018-06-04 08:27:05 +02:00
Kornel 8f546c93f4 Merge pull request #1237 from ProsoftEngineering/spudownloadersession-main
#1236: SPUDownloaderSession main thread
2018-05-25 22:04:08 +01:00
Brian Bergstrand 1c4bcda012 Fix potential hang with dispatch_sync to main thread 2018-05-25 14:32:57 -05:00
Brian Bergstrand a18282ec79 Deliver SPUDownloaderSession delegate messages on the main queue
This is the behavior of SPDownloaderDeprecated.

Github #1236
2018-05-25 14:32:57 -05:00
Kornel 8a8ce49a23 Merge pull request #1235 from sunwenli/sunwenli
add tips for user to install doxygen
2018-05-25 12:22:32 +01:00
sunwenli 2561af8270 add tips for user to install doxygen 2018-05-25 17:12:11 +08:00
Kornel 035ad6a277 Merge pull request #1234 from horcs/add-delegate-callback-to-track-update-events
delegate callbacks for fininshed download and extraction related events
2018-05-22 17:08:25 +01:00
Csaba Horony 9cbae0edb6 add delegate callbacks for fininshed download and extraction related events 2018-05-22 10:07:50 +02:00
Kornel 3bbf84e332 Merge pull request #1230 from tamasprezi/private-key-from-keychain
Support for getting the private key from keychain for signing deltas
2018-05-13 23:22:14 +01:00
Tamás Lustyik a582d46096 Restored legacy CLI for backward compatibility 2018-05-13 21:33:03 +02:00
Tamás Lustyik 3f3ace055d Fixed index out of bounds 2018-05-13 17:28:29 +02:00
Tamás Lustyik 886e4b2c81 More complex argument parsing to support both inputs 2018-05-13 16:28:05 +02:00
Tamás Lustyik a418d8fe64 Function to load the private key directly from the keychain 2018-05-13 16:04:48 +02:00
Tamás Lustyik b48e80aa27 Minor naming improvement 2018-05-13 15:50:46 +02:00
Kornel a19dfb2be0 Bump 2018-04-29 13:36:22 +01:00
Kornel 7394593743 Explain why auth is requested
It can't be SULog, because it's not linked in tool using SUFileManager
2018-04-29 13:34:28 +01:00
Kornel 4973c0143f Whitespace 2018-04-29 13:34:06 +01:00
Kornel c171f381d4 Merge pull request #1222 from zyves72/master
French translation for critical update
2018-04-26 14:39:02 +01:00
zyves72 dde4a0aae2 Add files via upload
Translation
2018-04-26 14:53:59 +02:00
Kornel d5a1ba44ff Don't check for updates if Do Not Disturb is on 2018-04-24 04:20:51 +01:00
Kornel 0d03b4006d Merge pull request #1216 from mallexxx/master
Fix closeCheckingWindow called from background thread
2018-04-20 16:33:12 +01:00
Alexey Martemyanov 25993d0776 Fix closeCheckingWindow called from background thread 2018-04-20 22:22:16 +07:00
Kornel 276707b3da Merge pull request #1212 from sunuslee/master
expose CodesigningVerifier, add codesign info api
2018-04-17 17:51:24 +01:00
Kornel 23e88737ec Merge pull request #1211 from horcs/hungarian-localization
Hungarian localization
2018-04-16 20:54:34 +01:00
Csaba Horony d400a53ebd add missing hungarian translation 2018-04-16 13:40:34 +02:00
sunuslee f39b07fd59 expose CodesigningVerifier, add codesign info api
Signed-off-by: sunuslee <sunuslee@gmail.com>
2018-04-16 10:08:31 +08:00
Csaba Horony 5bc8f3e535 Hungarian localization 2018-04-13 10:56:17 +02:00
Csaba Horony 503a292084 added localization files for Hungarian translation 2018-04-13 10:55:50 +02:00
Karl Moskowski d60b16f633 Ensure cocoapods is installed before performing the release “sanity check” (#860) 2018-04-06 01:35:34 +01:00
Kornel de3e73b589 Merge pull request #1201 from DaveWoodCom/master
Silence some Xcode warnings
2018-03-26 12:32:08 +01:00
Dave Wood ad863775db Silence ‘This block declaration is not a prototype’ Xcode warning 2018-03-25 23:05:37 -04:00
Dave Wood 79511c982a Silence ‘decodeObjectOfClass:forKey: is only available on macOS 10.8’ Xcode warnings, similar to commit ea94969188 2018-03-25 23:05:25 -04:00
Kornel 189ed9d315 Merge pull request #1172 from nivekkagicom/fix_warnings
silence 10.9 availability and other warnings and use modules when available
2018-03-19 20:11:27 +00:00
Kornel ea94969188 10.7 compatibility 2018-03-18 13:52:13 +00:00
Kornel 57731f44d7 Avoid invalid use of main thread
Fixes #1189
2018-03-18 13:41:08 +00:00
Kornel 2a0514c93b Update wording of read-only error 2018-03-18 13:37:46 +00:00
Adrian Thomas 467e1495c0 Improve 'read-only' error message (#1192)
* Improver read-only error message German

Updated the "read-only volume" error to reflect the real-world scenarios users run into.
It's almost never a CD, it's nearly always running from ~/Downloads or the .dmg if you still ship your app that way.
2018-03-18 13:34:19 +00:00
Kornel Lesiński 8ac254951a "all" target 2018-03-18 13:27:56 +00:00
Kornel c83c9221f7 Hidden verbose flag 2018-03-18 13:27:45 +00:00
Kornel b46315df9c Outdated comment 2018-03-18 13:27:43 +00:00
Kornel 9c505dee2f Merge pull request #1181 from vitu/master
Amend to avoid gender issue
2018-02-02 17:22:50 +00:00
BR Lingo 2ed7402367 Amend to avoid gender issue
Amend to avoid gender issue

Victor committed
a01979c
1 changed file
Instead of addressing the user, which might cause gender issues, string has been adapted to include “app” (masculine, in accordance with Apple's terminology).

Would translate back as “The app is up-to-date!”
2018-02-02 10:51:47 -05:00
Kornel 3afa47b092 Changelog 2018-01-29 23:03:33 +00:00
Kornel 874d6bce36 Bump 2018-01-29 22:55:32 +00:00
B. Kevin Hardman 51a335b3fd move Xcode 9.2 automatic changes from project to xcconfig files 2018-01-18 11:19:50 -05:00
B. Kevin Hardman 578bb9ecb8 Bring project up to Xcode 9.2 settings 2018-01-18 08:02:18 -05:00
B. Kevin Hardman 76e8838eb3 silence 10.9 availability and other warnings and use modules when available 2018-01-18 07:37:26 -05:00
Kornel 0a101b7902 Merge pull request #1167 from sparkle-project/mainthread
Ensure UI is changed only on the main thread
2018-01-09 00:18:36 +00:00
Kornel 865dd2e187 Ensure UI is changed only on the main thread 2017-12-29 19:27:56 +00:00
Kornel 083bd9b453 nil checks 2017-12-29 19:26:56 +00:00
Kornel b48bc4dcac Merge pull request #1165 from Deadpikle/feature/spudownloader
[WIP] Port SPUDownloader to 1.x w/NSURLSession & NSURLDownload
2017-12-29 17:47:45 +00:00
Deadpikle bb6203f40a Fix typo in expectation description 2017-12-28 22:41:22 -05:00
Deadpikle 25204a66e0 Finish tests for persistent download 2017-12-28 22:35:27 -05:00
Deadpikle c886947f55 Set NSOperationQueue op count to 1 2017-12-28 22:34:43 -05:00
Deadpikle f0460033ba Remove commented out code 2017-12-28 21:58:42 -05:00
Deadpikle 1a71456ed9 Slight refactor of temp download test 2017-12-28 21:50:46 -05:00
Deadpikle e7cdbfc45e Add tests for temp SPUDownloader dl 2017-12-28 21:40:31 -05:00
Deadpikle 8b5c8b5cdf Fix SUAppcast tests 2017-12-28 15:52:47 -05:00
Deadpikle a7af48f0d1 Refactor cache clearing & errors to super 2017-12-24 09:38:04 -05:00
Deadpikle 03e28780d9 Fix AppKitPrevention not being included 2017-12-21 09:35:06 -05:00
Deadpikle 5b1c76db26 Fix a few header comments 2017-12-20 13:22:47 -05:00
Deadpikle 703e611eb5 Remove a bunch of warnings 2017-12-20 13:01:44 -05:00
Deadpikle 6ee88124ad SUAppcast now uses SPUDownloader 2017-12-20 12:58:45 -05:00
Deadpikle 1cc5f230a5 Check OS version before creating downloader 2017-12-20 12:40:48 -05:00
Deadpikle 429f950434 Only send back error if non-nil 2017-12-20 12:40:37 -05:00
Deadpikle 7df50ccfd3 Download path should be full path 2017-12-20 12:25:42 -05:00
Deadpikle 9c301bfbf3 Drivers now use SPUDownloader 2017-12-20 12:11:49 -05:00
Deadpikle 8a0474d644 Continue refactor of downloader to two classes 2017-12-20 11:43:13 -05:00
Deadpikle dc85d63861 Refactor download NSURLSession to a child class 2017-12-20 11:14:02 -05:00
Deadpikle dc8e8b775a Remove unnecessary delegate name in header 2017-12-20 11:13:41 -05:00
Deadpikle ecb608bb40 Bring 2.0 files for SPUDownloader to 1.x 2017-12-20 10:48:51 -05:00
Kornel c3e546d7f8 Merge pull request #1154 from 1024jp/updateJapanese
Update Japanese localization
2017-11-25 13:50:32 +00:00
1024jp 2477a92b0f Update Japanese localization 2017-11-25 15:34:15 +09:00
Kornel 7f0bc6a244 Merge pull request #1141 from stefanhp/patch-1
Update Sparkle.strings
2017-10-21 22:28:44 +01:00
Stefan Paychère 68f62e5955 Update Sparkle.strings
Translation of "Description text for SUUpdateAlert when the update informational with no download."
2017-10-21 20:29:51 +02:00
Kornel 0cb0b2f2c7 Update for newer OpenSSL 2017-10-10 12:26:01 +01:00
Kornel b590722aad Merge pull request #1135 from jkbullard/fix-frequent-polling
Fix #1061 & #835: Sparkle clients polling too frequently
2017-10-05 15:43:24 +01:00
Jonathan Bullard 10f831fce8 Move [NSDate date] to be after willChangeValueForKey
Per comment by Pornel
2017-10-05 09:36:31 -04:00
Jonathan Bullard a2ecdd2744 Fix #1061 & #835: Sparkle clients polling too frequently
The SULastCheckTimeKey preference (a/k/a "default"), which is stored
in ~/Library/Preferences/….plist, was used to store the date of the
last update check.

That causes a problem if the storage is read-only (for example, if the
.plist file is “locked” (has the uchg or schg flag set) or if the
SULastCheckTimeKey key "exists in a domain that precedes the
application domain the search list"). The date would never be modified,
and the old date would cause a new update check to be queued at the end
of an update check. If application or bundle was up-to-date, or the
user had chosen to skip the update that was available, this would cause
update checks to happen as often as the computer and network would
allow, many times each second.

The new code uses an instance variable to store the value. The variable
is initially loaded from the “SULastCheckTimeKey” preference, and each
time the variable is modified its new value is stored to that
preference. However, the variable, not the preference, is used when
calculating whether enough time has passed since the last update check
to warrant another check. The variable will always (after the first
update check) have the "correct" value, and update checks will not be
done more frequently than desired.
2017-10-05 08:57:04 -04:00
Kornel ec7f55d173 Handle SecTransformExecute errors
Fixes #1129
2017-09-27 18:45:52 +02:00
Kornel ddfc4089d2 Merge pull request #1126 from ksuther/touchbar-warnings
Silence Touch Bar availability warnings on Xcode 9
2017-09-18 23:06:08 +01:00
Kent Sutherland 80c34526e8 Silence Touch Bar availability warnings on Xcode 9 by using API_AVAILABLE.
Disable gnu-zero-variadic-macro-arguments to prevent warnings from use of API_AVAILABLE.
2017-09-18 12:17:58 -05:00
Kornel 0c3994c571 Merge pull request #1124 from dfuhrmann/xcode-7-macOS-10.11-compatibility
Restore Xcode 7 and macOS 10.11 SDK compatibility
2017-09-11 14:19:31 +01:00
David Fuhrmann fbda90ad64 Sparkle: Convert all xib files to Xcode 7 format
Only this format can be opened with Xcode 7. The previously used
Xcode 8 format only opens and compiles with Xcode 8.
2017-09-11 11:24:10 +02:00
David Fuhrmann 40750b6f24 Sparkle: Add 10.11 SDK compatibility for touch bar declarations
Those annotations are not available in 10.11 SDK yet.
2017-09-11 11:23:48 +02:00
David Fuhrmann a7ba0bea6e Sparkle: Add backwards compatibility with 10.11 SDK for logging
10.11 SDK does not contain the os_log API yet. Code is modified
in such a way that it compiles with older SDKs, and falls back
to the old implementation even if it runs on 10.12.
2017-09-11 11:22:27 +02:00
Kornel 558cfd2153 Bump 2017-08-14 13:19:03 +01:00
Kornel 94074e2bdc Merge pull request #1111 from sparkle-project/swift4
Update to Xcode 9/Swift 4
2017-08-14 13:02:21 +01:00
Kornel 56065fcf95 Merge pull request #1119 from 1024jp/patch-1
Update Xcode version for Travis CI
2017-08-14 12:46:30 +01:00
1024jp f24189e848 Update Xcode version for Travis CI 2017-08-14 18:05:49 +09:00
Kornel 65b12a2be1 Merge pull request #1116 from fujisoft/patch-3
Workaround for timing issue of termination detection.

Not sure if that is correct.
2017-08-11 19:03:05 +01:00
fujisoft 900de556a8 Fix for the timing issue of termination detection. 2017-08-08 11:12:47 +09:00
App Tyrant 7c8ff2b969 Add optional updaterDidRelaunchApplication: method on SUUpdaterDelegate (#1115)
* Added updaterDidRelaunchApplication: delegate method.

* Removed isUpdaterRelaunching property.

* Revert SUHost.
2017-08-08 00:21:51 +01:00
Kornel 43b4472d3c Better error message 2017-08-01 15:55:25 +01:00
Kornel 260170f372 Warning 2017-08-01 15:54:52 +01:00
Kornel ea85fc6442 Update to Xcode 9/Swift 4 2017-07-27 16:42:44 +01:00
Kornel a52604a264 Revert "Ensure UI code always runs on the main thread"
This reverts commit 423ee5a9d6.
2017-07-20 13:20:20 +01:00
Kornel 39d6c616b0 Merge pull request #1051 from sparkle-project/mainalert
Ensure UI code always runs on the main thread
2017-07-16 21:03:20 +01:00
Kornel 043ad0464a Merge pull request #1098 from Eitot/dutch
Update Dutch localization for informal style and changed terminology
2017-06-24 22:19:09 +01:00
Kornel d99339cf08 Merge pull request #1097 from Eitot/german
Update German localization for informal style and changed terminology
2017-06-24 22:11:16 +01:00
Eitot c541f95036 Update German localization with some terminology changes
Apple uses the term "Update" instead of "Aktualisierung" and
"laden" instead of "herunterladen".
2017-06-23 10:00:05 +02:00
Eitot e678ffb3ca Update German localization for informal style
This is the style in Apple's localizations in macOS Sierra.
Also makes some slight changes to wording.
2017-06-23 09:59:48 +02:00
Eitot 070ea362a2 Update Dutch localization for informal style
This is the style in Apple's localizations in macOS Sierra.
2017-06-23 09:57:55 +02:00
Eitot c4db636d0b Update Dutch localization with some style changes
This reflects Apple's localizations a bit better.
2017-06-23 09:57:49 +02:00
Kornel 7e9f05865a Merge pull request #1094 from keith/ks/cocoapods-bin
Include bin files in CocoaPods installation
2017-06-19 10:24:38 +01:00
Keith Smiley 3c14c950ef Include bin files in CocoaPods installation
This updates the podspec to include the bin scripts in Pods directory
when using CocoaPods. This way users don't also have to download the
Sparkle repo out of band to sign releases.
2017-06-18 20:33:24 -07:00
Kornel 4438b69b50 Simplified check 2017-06-07 23:56:45 +01:00
Kornel 6d0c734c26 Rename OSX macOS 2017-06-07 23:55:34 +01:00
Kornel e8805e0563 Merge pull request #1089 from Memphiz/add_osx_attribute
Add support for the sparkle:os attribute in the enclosure tag
2017-06-07 23:51:10 +01:00
Memphiz 193036b2c4 [BasicUpdateDriver] - extend hostSupportsItem method to also check the sparkle:os attribute from the enclosure element to decide if an update item is valid for the host 2017-06-07 22:11:08 +02:00
Memphiz 33bf6732ea [AppcastItem] - parse and save the sparkle:os attribute of the enclosure element and add isOsxUpdate method to item class 2017-06-07 22:10:56 +02:00
Kornel e94fb63ff0 Merge pull request #1087 from 1024jp/japanese
Updated Japanese translation to reflect change on 55be13c
2017-06-04 15:12:32 +01:00
Kornel 84e5925578 Merge pull request #1086 from vitu/master
Updated translation to reflect change on 55be13c
2017-06-04 15:11:51 +01:00
1024jp bb83e9a0da Updated Japanese translation to reflect change on 55be13c 2017-06-04 10:55:45 +09:00
Victor 26d4d75c36 Updated translation to reflect change on “Update error message to mention temp folders rather than optical drives”. 2017-06-03 20:23:14 -04:00
Kornel fe5737f0b6 Changelog 2017-06-02 12:21:08 +01:00
Kornel ac49a3b5b6 Merge pull request #1081 from sparkle-project/autoname
Prepend app name to Autoupdate.app name
2017-06-02 12:01:22 +01:00
Kornel cbeaeb29ec Merge pull request #1084 from ksuther/nil-progress-block
Don't assume that the progress block exists (the parameter is nullable)
2017-06-02 04:14:22 +01:00
Kent Sutherland d0a6c699da Don't assume that the progress block exists (the parameter is nullable) 2017-06-01 16:55:52 -05:00
Kornel 84b7e5e22f Prepend app name to Autoupdate.app name 2017-05-27 11:38:19 +01:00
Kornel 61774b3f7d Error message tweak 2017-05-27 11:37:06 +01:00
Kornel 55be13ca6f Update error message to mention temp folders rather than optical drives
Finder is required to remove quarantine from downloaded apps
2017-05-20 17:09:56 +01:00
Kornel fc48e5e4df 1.18.0 2017-05-18 21:54:56 +01:00
Kornel bfada07a2c Log more errors 2017-05-18 21:48:51 +01:00
Kornel 4f965660f3 Merge pull request #1072 from sparkle-project/autoerror
Unify handling of aborted updates
2017-05-03 16:51:06 +01:00
Kornel a2764158d6 Unify handling of aborted updates 2017-05-03 12:34:28 +01:00
Kornel 60727bffa5 Log key read failure 2017-04-24 18:05:13 +01:00
Kornel 715163fe0d Formatting 2017-04-24 18:05:13 +01:00
Kornel 629c42d62d Merge pull request #1050 from sparkle-project/genapp
generate_appcast improvements
2017-04-14 21:28:07 +02:00
Kornel 3e45211bbe Escape + as well 2017-03-31 15:15:22 +01:00
Kornel 89acca1318 Escape profile URLs better
Fixes #1059
2017-03-31 11:08:03 +01:00
Kornel Lesiński 4bc2e6e891 %s is deliberate in this format string
Fixes #1053
2017-03-24 12:00:12 +00:00
Kornel Lesiński 405c9fd9a1 Unused 2017-03-24 12:00:12 +00:00
Kornel 9232316b19 Merge pull request #1052 from sparkle-project/scheme
Make generate_appcast available as a shared scheme
2017-03-24 11:05:33 +00:00
Kornel Lesiński 0569c73391 Make generate_appcast available as a shared scheme
#1049
2017-03-17 09:27:00 +00:00
Kornel Lesiński 423ee5a9d6 Ensure UI code always runs on the main thread 2017-03-15 21:31:11 +00:00
Kornel Lesiński ac042821d8 Special case for .tar.gz extension 2017-03-15 18:42:08 +00:00
Kornel Lesiński 36139c57bc Shush Xcode 2017-03-15 18:42:08 +00:00
Kornel Lesiński 662e84400a Inline release notes if they don't look like a standalone HTML document 2017-03-15 18:42:08 +00:00
Kornel Lesiński b6b5c6d927 Link straight to docs from the readme 2017-03-15 18:42:08 +00:00
Kornel Lesiński 1683d2de34 Simplify release notes link check 2017-03-15 18:42:08 +00:00
Kornel Lesiński 615a08bc32 Feed formatting 2017-03-15 18:42:08 +00:00
Kornel c7bf998913 Merge pull request #1016 from sparkle-project/installprogress
Report installation progress from Installer
2017-03-12 14:39:43 +00:00
Kornel 1dd9d93090 Merge pull request #1046 from digitalmoksha/master
generate_appcast: if an .html file exists of the same name, create the releaseNotesLink
2017-03-11 11:31:58 +00:00
Brett Walker ac8c37096e ignore .html files when scanning for archives 2017-03-11 12:09:53 +01:00
Kornel c86e825a5f Merge pull request #1048 from vitu/master
Missing strings translation.
2017-03-09 17:03:57 +00:00
vitu 40a777f5d9 Missing strings translation. 2017-03-09 11:58:52 -05:00
Kornel Lesiński 3098afc90b Updated swift 2017-03-09 13:32:05 +00:00
Kornel Lesiński 3809da20bf Warn against abusing installUpdatesIfAvailable 2017-03-09 13:13:29 +00:00
Brett Walker c623480f72 when generating the appcast, if an .html file exists of the same name as
the archive, then it will be linked in as the releaseNotesLink
2017-03-08 10:57:59 +01:00
Kornel Lesiński 72ee4aa2c6 Revert "Fix pt_BR translations"
This reverts commit 83195a802e.
2017-03-08 00:36:46 +00:00
Kornel Lesiński e160f994b4 Revert "Fix pt_BR translations (#1039)"
This reverts commit 3b04c45ee9.
2017-03-08 00:36:40 +00:00
Kornel e7810c970b Merge pull request #1044 from 1024jp/fixJapanese
Fix Japanse localization
2017-03-01 10:39:35 +00:00
1024jp 0a94a6ce88 Fix Japanse localization
Generalize message to user as the previous setence was more like "Anonymous system profile information is used to help **our company** plan future development work."
2017-02-28 13:54:47 +09:00
Kornel Lesiński e54748ac87 Add more info to auth tool run failure 2017-02-26 18:03:42 +00:00
fujisoft 3b04c45ee9 Fix pt_BR translations (#1039)
* Fix pt_BR translations
2017-02-20 10:22:15 +00:00
Kornel 792e13a067 Merge pull request #1038 from fujisoft/patch-1
Fix pt_BR translations
2017-02-19 16:09:37 +00:00
fujisoft 83195a802e Fix pt_BR translations
"Translation Error Correction"
It must have a faithful consistency to the translation terminologies of Apple Inc.
2017-02-20 00:50:36 +09:00
Kornel 46d2a6aeab Merge pull request #1036 from gnachman/preventAccidentalInstalls
Disable the keyboard shortcut for the install button for scheduled updates to avoid accidental installs.
2017-02-16 17:21:55 +00:00
George Nachman 40347c0d43 Disable the keyboard shortcut for the install button for scheduled updates to avoid accidental installs. 2017-02-13 19:41:02 -08:00
Kornel e1f67cf8db Merge pull request #1034 from digitalmoksha/master
added `sparkle:shortVersionString` to the enclosure, #1032
2017-02-10 21:39:00 +00:00
Brett Walker 5210e1d3ac added sparkle:shortVersionString to the enclosure, #1032 2017-02-10 16:53:30 +01:00
Kornel Lesiński f43c83688d Changelog 2017-02-09 00:04:10 +00:00
Kornel 83709f4b30 Merge pull request #1028 from digitalmoksha/master
percent encode the filename used in the delta url, for #995
2017-02-08 22:27:17 +00:00
Brett Walker c0d4640508 percent encode the filename used in the delta url 2017-02-08 22:40:37 +01:00
Kornel c6fb841868 Merge pull request #1026 from zorgiepoo/coupling-ci
Detect and fail if any two-way dependencies exist in the project
2017-02-06 16:22:59 +00:00
Zorg 9a07c5125e Detect and fail if any two-way dependencies exist in the project
While this may or may not be perfect, this should improve code quality by preventing new code that is introduced that creates tight coupling. This test is performed when make test is executed.

I avoided retrieving objc_dep in a way that make test would require an internet connection. I also added the executable bit to the objc_dep script, and a source.txt file indicating where the source came from.
2017-02-06 08:27:10 -05:00
Kornel fb6fe6d6da Merge pull request #1025 from vitu/master
Terminology consistency update.
2017-02-06 10:22:21 +00:00
BR Lingo 9318b9f896 Update Sparkle.strings
Terminology consistency update.
2017-02-06 01:18:26 -05:00
BR Lingo d27c12f1fc Update Sparkle.strings
Terminology consistency update.
2017-02-06 01:15:22 -05:00
Kornel 016dad176e Merge pull request #1024 from vslavik/faster-noop-builds
Don't touch Info.plist unless git version changes
2017-02-05 21:31:45 +00:00
Václav Slavík 1f98f9eb36 Don't touch Info.plist unless git version changes
PlistBuddy always touches its output file, even if the value written is
identical to the value already there. In such case, Xcode sees
Info.plist as modified, therefore sees the entire target as modified and
re-runs potentially expensive operations like copying frameworks or
signing.

Avoid unnecessary build operations by checking the previous
CFBundleShortVersionString if Info.plist already exists and only
updating it if necessary.
2017-02-05 18:29:22 +01:00
Kornel 6e51231966 Merge pull request #1021 from zorgiepoo/copyright
Add my name to LICENSE
2017-02-02 08:54:51 +00:00
Zorg dc1d83e904 Add my name to LICENSE 2017-02-01 23:56:17 -05:00
Kornel Lesiński 9d966e68f0 Merge remote-tracking branch 'origin/1.16.x'
* origin/1.16.x:
  Fix #1020
2017-01-28 12:15:28 +00:00
Kornel Lesiński 03abfe2739 Fix #1020 2017-01-28 12:10:03 +00:00
Kornel Lesiński 155816b609 Formatting 2017-01-28 12:07:10 +00:00
Kornel 313352fe26 Merge pull request #1018 from sparkle-project/filesystemnormalization
fileSystemRepresentation normalization
2017-01-28 12:06:32 +00:00
Kornel Lesiński 67b1e08a45 Delta minor version fix 2017-01-28 11:31:08 +00:00
Kornel Lesiński 21214e8623 Simplify minor delta version down to int
+ minor version bump
2017-01-28 11:08:53 +00:00
Kornel Lesiński ed16c5c2a0 Use the same fileSystemRepresentation function for both parts of the path 2017-01-27 18:37:35 +00:00
Kornel Lesiński 0a869e87bf Make normalizedInstallationPathForHost also normalize Unicode 2017-01-27 18:34:56 +00:00
Kornel Lesiński 14c543ccb3 Test with non-ASCII names 2017-01-27 18:17:05 +00:00
Kornel Lesiński 0fd0331464 Typo 2017-01-27 18:04:43 +00:00
Kornel Lesiński 0cba214f07 1.17.0 2017-01-24 14:07:32 +00:00
Kornel Lesiński 2a644672ca Report installer progress 2017-01-24 13:46:21 +00:00
Kornel Lesiński 81e71844d6 Report plain install progress 2017-01-24 13:46:01 +00:00
Kornel Lesiński e4821e0454 Ability to report installation progress 2017-01-24 13:45:50 +00:00
Kornel a97538f931 Merge pull request #1014 from zorgiepoo/fix-unarchive-temp-removal
Don't remove the temporary unarchive directory in unit tests
2017-01-23 09:48:22 +00:00
Zorg c61767f501 Don't remove the temporary unarchive directory in unit tests
This should fix a potential bug where the unit tests try to unarchive a file that does not exist.
2017-01-22 22:02:45 -05:00
Kornel Lesiński c0d45952a9 Removed unimportant changelog entry 2017-01-23 01:21:31 +00:00
Kornel Lesiński 06629310e2 Updated changelog 2017-01-22 18:40:39 +00:00
Kornel 7e99561d9c Merge pull request #1010 from zorgiepoo/termination-autoupdate
Termination autoupdate
2017-01-20 13:56:05 +00:00
Zorg 5c71eebf59 Remove nonsense logging I had for debugging purposes 2017-01-19 23:28:56 -05:00
Zorg 5368dbfb41 Merge branch '1.17.x' into termination-autoupdate 2017-01-19 23:22:27 -05:00
Zorg 0e978e3faf Add kqueue based termination listener
Note this termination listener is not polling or timer based and will work on processes that aren't GUI applications.
2017-01-19 23:21:26 -05:00
Kornel f9dfa3dd9d Merge pull request #1006 from sparkle-project/subsystem
Use app-independent subsystem identifier
2017-01-18 22:33:22 +00:00
Kornel Lesiński c104c1b27e Fix facility identifier 2017-01-18 22:31:03 +00:00
Kornel Lesiński 7e7c97a09f Use app-independent subsystem identifier 2017-01-18 19:01:45 +00:00
Kornel a75ad96719 Merge pull request #1005 from Bi11/touchbar
Update button outlets for all xib files
2017-01-18 12:32:03 +00:00
Bi11 22f5d1f0f8 Update button outlets for all xib 2017-01-18 15:45:00 +08:00
Kornel b9753cbd81 Merge pull request #1003 from Bi11/touchbar
Add forward declaration for Xcode7
2017-01-17 22:53:21 +00:00
Bi11 548ae6e2b6 Change SDK checking macro to match existing code base 2017-01-18 05:34:37 +08:00
Bi11 db7f4acc83 Add forward declaration for Xcode7 2017-01-18 05:06:09 +08:00
Bi11 942d70d3aa Suppress partial availability warning on line level 2017-01-18 04:53:37 +08:00
Kornel Lesiński 2ccac610f6 Added declaration for Xcode 7 2017-01-17 20:38:22 +00:00
Kornel Lesiński 7a0d402a01 Merge remote-tracking branch 'origin/master' into 1.17.x
* origin/master:
  Explain why I'm not relying on the compiler to throw linkage errors
  Add AppKitPrevention header to reduce redundancy.
  Add AppKit prevention guards to modules that shouldn't import it
  Add Obj-C generics where applicable
  Adds test cases for "sparkle:criticalUpdate" tag. (#999)
2017-01-17 19:39:48 +00:00
Kornel Lesiński d070bca0b0 Sort project file 2017-01-17 19:38:02 +00:00
Kornel 682f8f32c6 Merge pull request #1002 from Bi11/touchbar
Add touch bar build support for Xcode 8.0 and earlier
2017-01-17 19:36:28 +00:00
Bi11 56db200f06 Add touch bar build support for Xcode 8.0 and earlier 2017-01-18 01:44:16 +08:00
Kornel 34179edd6d Merge pull request #1001 from zorgiepoo/appkit-prevention
Add AppKit prevention guards to modules that shouldn't import it
2017-01-17 13:09:38 +00:00
Zorg 530f3a4a63 Explain why I'm not relying on the compiler to throw linkage errors 2017-01-17 07:17:14 -05:00
Zorg 135d05b8b8 Add AppKitPrevention header to reduce redundancy.
Note this header should be included last in implementation files, which is why I added extra padding.
2017-01-17 07:08:29 -05:00
Zorg c56694382e Add AppKit prevention guards to modules that shouldn't import it 2017-01-16 21:17:25 -05:00
Kornel a39023e95b Merge pull request #1000 from zorgiepoo/generics
Add Obj-C generics where applicable
2017-01-17 00:58:20 +00:00
Zorg 282f0ae58e Add Obj-C generics where applicable
In headers that are exported, we test to see if generic support is available.
2017-01-16 18:09:04 -05:00
Kornel Lesiński 55e1a24431 Formatting 2017-01-16 22:25:37 +00:00
Kornel Lesiński 9fa0519811 Comments 2017-01-16 22:07:55 +00:00
Kornel ecc72f834d Merge pull request #987 from Bi11/touchbar
Add Touch Bar Support
2017-01-16 12:12:47 +00:00
Thomas Tempelmann c1488b0515 Adds test cases for "sparkle:criticalUpdate" tag. (#999)
* Adds a test case for the "criticalUpdate" appcast tag (not as a XCTest but simply as an assert inside the test app, because I was lazy and am working on an older Xcode version that does not support the currently needed swift version for the XCTest in SUAppcastTest.swift).

* Tests the "criticalUpdate" appcast tag, using the proper XCTest swift class. I haven't tested this, though, due to the lack of the needed Xcode version.

* Test case for Appcast now checks all 4 items for the correct "criticalUpdate" state.

* Adds a test case for the "criticalUpdate" appcast tag (not as a XCTest but simply as an assert inside the test app, because I was lazy and am working on an older Xcode version that does not support the currently needed swift version for the XCTest in SUAppcastTest.swift). (reverted from commit 3ce1c9790b)
2017-01-16 00:02:32 +00:00
Bi11 aa29a754e6 Merge branch '1.17.x' into touchbar 2017-01-13 21:30:09 +08:00
Bi11 65bd11df8a Use NSView’s designated initializer 2017-01-13 20:33:41 +08:00
Kornel Lesiński 397eb8a379 Merge remote-tracking branch 'origin/master' into 1.17.x
* origin/master:
  Proper fix for #995
2017-01-13 01:03:21 +00:00
Kornel Lesiński 27c560b7d5 Proper fix for #995 2017-01-13 01:02:55 +00:00
Kornel Lesiński 5121d74ad9 Merge remote-tracking branch 'origin/master' into 1.17.x
* origin/master:
  Fix URL/path confusion
  Add 10.12 as SDK to run in Makefile and use Xcode 8.2 for Travis
2017-01-13 00:45:50 +00:00
Kornel Lesiński fbb040926e Fix URL/path confusion
Fixes #995
2017-01-13 00:44:41 +00:00
Bi11 e2426784ac Add constrains to set touch bar buttons width equally 2017-01-13 01:35:09 +08:00
Bi11 118c72e61c Add touch bar button group view to replace NSGroupTouchBarItem 2017-01-13 01:22:33 +08:00
Bi11 6f11c1ce02 Set up touch bar in each window controller 2017-01-12 03:44:01 +08:00
Bi11 d5f4c312ee Keep consistent coding style 2017-01-11 23:11:02 +08:00
Kornel 9b3753f5d7 Merge pull request #990 from sparkle-project/bgnet
Tell OS when networking happens without UI
2017-01-11 04:45:24 +00:00
Bi11 5dda7462c1 Merge sparkle-project/master into touchbar 2017-01-11 02:20:28 +08:00
Bi11 c059dc8ae8 remove hardcoded array capacity 2017-01-11 02:07:48 +08:00
Bi11 6ca4b05cad Change touch bar identifier prefix to sparkle bundle identifier 2017-01-11 01:57:16 +08:00
Bi11 d95f420360 Set touch bar default button directly instead of changing its keyEquivalent 2017-01-11 00:44:15 +08:00
Bi11 7ae0e71b02 Fix compile issue with older SDK < 10.12.2 2017-01-11 00:42:03 +08:00
Kornel 548908628f Merge pull request #991 from zorgiepoo/upgrade-ci
Add 10.12 as SDK to run in Makefile and use Xcode 8.2 for Travis
2017-01-10 13:07:39 +00:00
Zorg d40bdb615a Add 10.12 as SDK to run in Makefile and use Xcode 8.2 for Travis 2017-01-10 06:40:35 -05:00
Bi11 b16d881808 Fix default button on touch bar 2017-01-10 18:44:48 +08:00
Kornel Lesiński 392cb65716 Tell OS when networking happens without UI 2017-01-10 02:37:00 +00:00
Bi11 6e01dd272f Use outlets instead of iterating through subviews 2017-01-10 08:34:25 +08:00
Bi11 762d527463 Merge branch 1.17.x into touchbar 2017-01-10 07:43:35 +08:00
Bi11 07599c2ffd Bind enabled and title for touch bar buttons by default 2017-01-10 07:34:52 +08:00
Bi11 f795802d60 Use NSTouchBarDelegate to avoid subclassing NSTouchBar 2017-01-10 07:22:44 +08:00
Kornel 073ce22015 Merge pull request #988 from zorgiepoo/host-info-dict
Re-read SUHost Info dictionary when necessary
2017-01-08 21:38:28 +00:00
Zorg 7ef468e8ea Use -[SUHost objectForInfoDictionaryKey:] in couple more places 2017-01-08 15:47:44 -05:00
Zorg fc9b2b38fa Make SUBundleIcon & SUApplicationInfo take SUHost, not NSBundle
When we retrieve the "CFBundleIconFile" key from the Info dictionary, we should rely on SUHost's method of obtaining that value now.
2017-01-08 15:36:30 -05:00
Kornel 717921cfa1 Merge pull request #977 from sparkle-project/skipcrit
Disable skip button if update is critical
2017-01-08 11:44:09 +00:00
Kornel e621622c8b Merge pull request #983 from zorgiepoo/logging
Upgrade SULog to use logging APIs that Apple provides built in
2017-01-08 11:43:44 +00:00
Bi11 6902b80ab6 Fix UITests multiple matches issue introduced in touch bar 2017-01-08 15:23:26 +08:00
Bi11 d44a122a21 Add Touch Bar support 2017-01-08 15:17:47 +08:00
Zorg 0b6b6fe4ca Improve -[SUHost objectForInfoDictionaryKey:]
We use the cached host bundle if the host bundle is equal to the main bundle.
Otherwise we read in the latest Info dictionary every time.

The cached case is the most common case. The odd case (updating other bundles) is less common. Thus we have better performance for the common case, and we retain correct code in both cases.

Also we invoke our own implementation of -objectForInfoDictionaryKey: rather than NSBundle's implementation in a few places.
2017-01-07 23:52:56 -05:00
Kornel f43b9f7f02 Merge pull request #982 from sparkle-project/genapp
Workaround for bugs in NSXMLDocument prefix handling
2017-01-07 22:07:56 +00:00
Kornel Lesiński eafbb2cfad Copy debug symbols for generate_appcast 2017-01-07 21:57:39 +00:00
Kornel 5c408f5019 Merge pull request #984 from zorgiepoo/appcast-nonnil
The SUAppcast * is not going to be nil here; fixes analyzer warning
2017-01-07 17:43:46 +00:00
Zorg 9d35c819fd The SUAppcast * is not going to be nil here; fixes analyzer warning 2017-01-07 11:26:53 -05:00
Zorg b9d113924e Upgrade SULog to use logging APIs that Apple provides built in
With this change, we ensure distinct per-app, per-process logging.
Note that the global file ~/Library/Logs/SparkleUpdateLog.log is no longer written into.

On 10.12 and above, SULog uses the os_log APIs. You may want to use log(1) to view logs in addition to Console.app. See the WWDC video on the new logging API and how the Console app has changed.

On older systems, this uses ASL (Apple System Log).

We don't want to reinvent logging, or rely on 3rd party libraries, thus we use what the system provides to us.

Two logging levels were added: Default and Error. The code documents their intended purpose. Now when you call SULog you must make a decision which level to use rather than rely on an implicit level.
2017-01-07 11:02:11 -05:00
Kornel Lesiński ee80a66896 Don't try to preserve namespace prefixes, because Apple's serializer is buggy
filed as rdar 29901669
2017-01-06 16:29:29 +00:00
Kornel Lesiński 187ae4fe57 Verify that the XML is serialized properly 2017-01-06 16:29:29 +00:00
Kornel Lesiński ca4d51561e Silence too-verbose delta 2017-01-06 16:29:29 +00:00
Kornel Lesiński 915c2047bf Fix accuracy of error message 2017-01-06 16:29:29 +00:00
Kornel f172cd32a8 Merge pull request #980 from sparkle-project/features
Updated README
2017-01-06 10:31:49 +00:00
Kornel Lesiński 8481035fb9 No server-side logic is a plus 2017-01-05 22:50:26 +00:00
Kornel Lesiński 7238c2aeb6 Updated README 2017-01-05 22:35:20 +00:00
Kornel Lesiński d9d62299be Disable Skip if the update is critical
Fixes #976
2017-01-04 15:23:47 +00:00
Kornel Lesiński 478bbf303b XIB churn 2017-01-04 15:23:47 +00:00
Kornel Lesiński ee16e5ae55 1.16.0a2 2017-01-04 13:59:17 +00:00
Kornel d50e823b3d Merge pull request #972 from sparkle-project/misc
Misc
2017-01-04 00:07:29 +00:00
Kornel 4636588e76 Merge pull request #973 from sparkle-project/nothrowaway
Resume pending automatic update when possible
2017-01-04 00:07:10 +00:00
Kornel Lesiński 2be4dc11a0 Resume pending automatic update when possible
Fixes #970
2017-01-03 17:44:40 +00:00
Kornel Lesiński 6181c9276a Close alert on abort 2017-01-03 17:42:18 +00:00
Kornel Lesiński 49845d8246 Re-init alert when called again
A lazy way to bring it to front
2017-01-03 17:42:18 +00:00
Kornel Lesiński 8fa136c0a3 Invalidate timer when auto-update window is shown
In case it's shown manually, not by the timer
2017-01-03 17:42:18 +00:00
Kornel Lesiński dc1151a5ff Null warning 2017-01-03 16:13:15 +00:00
Kornel a920ecc197 Merge pull request #964 from zorgiepoo/guided-default
Make guided package installs the default for updating packages
2017-01-02 20:40:39 +00:00
Kornel Lesiński 271d504f6d Expose magic numbers 2017-01-01 14:14:25 +00:00
Kornel Lesiński 9c0ccd4a57 Put latest version first to make wildcard filename matching easier 2017-01-01 14:14:25 +00:00
Kornel 266be254d2 Merge pull request #967 from zorgiepoo/length-fallback
Fallback to the appcast's length value if HTTP doesn't give us one
2017-01-01 15:12:44 +01:00
Kornel efe93c492f Merge pull request #968 from Bi11/info-only
Hide automatic updates checkbox for information only updates
2016-12-31 19:45:46 +01:00
Kornel 74b09ad904 Merge pull request #966 from zorgiepoo/update-podspec-file
Update pod spec file so that `make release` works
2016-12-31 19:44:05 +01:00
Kornel b9012aa8dc Merge pull request #965 from zorgiepoo/unarchiver-test-no-ivar
Remove instance variables from SUUnarchiverTest.swift
2016-12-31 19:43:05 +01:00
Kornel ae41185267 Merge pull request #963 from zorgiepoo/remove-old-app
Remove the old app/bundle instead of moving it to the trash
2016-12-31 18:29:08 +01:00
Bi11 6634ed7d69 Hide automatic updates checkbox for information only updates 2016-12-31 23:37:53 +08:00
Zorg 799ebdcf7d Fallback to the appcast's length value if HTTP doesn't give us one 2016-12-29 14:08:14 -05:00
Zorg d911db7357 Update pod spec file so that make release works 2016-12-29 11:15:22 -05:00
Zorg d2e1987ce3 Remove instance variables from SUUnarchiverTest.swift
I have been receiving unarchiver test errors lately (after the unarchiver blocks changes) somewhat rarely (it's very hard to reproduce) when running all the tests locally. Thus, hoping this change may make a difference.
2016-12-28 23:44:31 -05:00
Zorg 2d1688c063 Make guided package installs the default for updating packages
Interactive package installs now need to be opted into (foo.sparkle_interactive.pkg or foo.sparkle_interactive.mpkg)

The website documentation may need to be updated later, and this should be noted as an important point in the change log.
2016-12-28 23:15:22 -05:00
Zorg b56910f455 Remove the old app/bundle instead of moving it to the trash
Fixes #827
2016-12-28 22:01:00 -05:00
Kornel Lesiński a3e96581b4 We're not testing with old Xcode, so we can't promise that compatibility 2016-12-27 22:44:01 +01:00
Kornel Lesiński 94423a10c9 Sorted project file 2016-12-27 21:25:52 +01:00
Kornel Lesiński b14c00136e Changelog 2016-12-27 21:23:15 +01:00
Kornel ebf8d2105b Merge pull request #953 from zorgiepoo/gen-appcast-xcconfig
Add xcconfig file for generate_appcast target
2016-12-27 20:53:53 +01:00
Zorg 14ac885ea0 Add ConfigGenerateAppcastDebug.xcconfig 2016-12-27 11:13:32 -05:00
Zorg 355e239df9 Add xcconfig file for generate_appcast target
Also remove swift configurations from Common config files, and change swift optimization from fast to whole module.
2016-12-27 11:01:25 -05:00
Kornel Lesiński e7ae7d5330 Version bump 2016-12-27 15:32:43 +01:00
Kornel daaadf1c44 Merge pull request #946 from sparkle-project/appcast
Tool to generate appcasts automatically
2016-12-27 15:31:30 +01:00
Kornel 87064c9304 Merge pull request #952 from zorgiepoo/small-changes
Small changes
2016-12-27 14:21:33 +01:00
Zorg 0af392f808 Remove SUWindowController.m because it wasn't really being used 2016-12-26 22:51:55 -05:00
Zorg fb8ad9f75d Enhance SUUpdatePermissionPrompt by using a reply block
Also add SUUpdatePermissionResponse class which matches the response class from my fork.
2016-12-26 22:42:58 -05:00
Zorg b4210a85b9 Add and use normal initializer for SUStandardVersionComparator 2016-12-26 21:23:30 -05:00
Kornel 091986b12f Merge pull request #951 from zorgiepoo/installer-protocol
Decouple and simplify installation code using protocols
2016-12-27 00:48:57 +01:00
Zorg 1ecb620986 Decouple and simplify installation code using protocols
This also fixes a bug where the status window would stay visible during interactive (non-guided) package installations.
2016-12-26 17:59:32 -05:00
Kornel 21f3c8a157 Merge pull request #950 from zorgiepoo/updater-delegation
Updater delegation
2016-12-26 15:44:58 +01:00
Zorg 468bcb9640 Remove typecasting self.updater to id 2016-12-26 09:20:52 -05:00
Kornel Lesiński d38b29c858 Use more precise version for deltas to avoid filename clashes 2016-12-26 14:32:26 +01:00
Kornel Lesiński e2b9fc7ffd Fix path 2016-12-26 14:26:03 +01:00
Zorg f016cd8086 Add nullability annotations to SUUpdaterDelegate.h 2016-12-25 18:45:49 -05:00
Zorg 796967cf24 Allow delegate methods that return an object to return nil
Returning nil from these delegate methods is equivalent to not implementing the delegate method. The caller should be able to make this kind of decision when implementing an optional delegate method.
2016-12-25 18:41:38 -05:00
Zorg 578e78876c Separate SUUpdater delegate methods into different file
Also create SUUpdaterPrivate protocol to expose as little as possible to the internal update drivers. Ideally this would be minimized and not even exist at all, but I don't want to make the architectural and potential backwards-incompatible changes required to do that.
2016-12-25 18:25:42 -05:00
Kornel 2f438186d6 Merge pull request #949 from zorgiepoo/decouple-host
Decrease responsibility of SUHost and move code into other components
2016-12-24 14:22:56 +01:00
Zorg 2c1820f2a9 Decrease responsibility of SUHost and move code into other components 2016-12-23 22:21:19 -05:00
Kornel a30eff3680 Merge pull request #947 from zorgiepoo/remove-deps
Remove Sparkle.pch and many file #includes
2016-12-24 00:06:56 +01:00
Zorg 1a09baf0ed Remove Sparkle.pch and many file #includes
This eliminates many dependencies that don't need to exist.
2016-12-23 16:13:35 -05:00
Kornel Lesiński a1095ff29c Null fix 2016-12-23 20:00:45 +01:00
Kornel Lesiński 51b3931485 Simpler suffix check 2016-12-23 19:59:48 +01:00
Kornel Lesiński 1e3f5482d0 Additional files 2016-12-23 19:26:30 +01:00
Kornel Lesiński 0a45be54c4 Appcast helper tool 2016-12-23 19:22:13 +01:00
Kornel b5bc2a7374 Merge pull request #940 from sparkle-project/nulz
Nulz
2016-12-23 18:56:57 +01:00
Kornel 3666b89add Merge pull request #933 from sparkle-project/statevars
Minor tweaks
2016-12-23 18:56:06 +01:00
Kornel 23f9e747c1 Merge pull request #942 from zorgiepoo/unarchiver-protocol
Unarchiver protocol
2016-12-23 18:54:25 +01:00
Kornel Lesiński c77895066a Appropriate deployment target for test app xib 2016-12-23 17:01:16 +01:00
Kornel Lesiński c98017dbe2 Fixed binary delta tool 2016-12-23 16:33:12 +01:00
Kornel Lesiński 657e3d47d0 Removed unnecessary nullability 2016-12-23 16:25:09 +01:00
Kornel 4d34e4358a Merge pull request #943 from zorgiepoo/improve-tests
Improve tests
2016-12-22 23:32:19 +01:00
Zorg 6fcd6beb84 Fix UI tests from not working when update alert automatically shows 2016-12-22 12:18:31 -05:00
Zorg 98b3a9828a Use localhost instead of 0.0.0.0. Latter doesn't work when offline. 2016-12-22 12:17:45 -05:00
Zorg 137b73af4e Fix subclass compatibility and update schedule unarchiving behavior 2016-12-21 16:39:33 -05:00
Zorg dd1bda5066 Some error reason is better than no reason 2016-12-21 16:14:25 -05:00
Zorg 7bc7a90a09 Fix UI update scheduler not prompting for install & relaunch 2016-12-21 15:59:13 -05:00
Zorg 91d13c7239 Merge branch 'master' into unarchiver-protocol 2016-12-21 15:53:41 -05:00
Zorg fd6ba1820a Merge branch 'master' into unarchiver-protocol 2016-12-21 15:39:38 -05:00
Kornel fb61777024 Merge pull request #941 from sparkle-project/unarch
Error handling test + fix
2016-12-21 19:18:23 +01:00
Kornel Lesiński 2519eb573f Test unarchiving failure 2016-12-21 18:06:22 +01:00
Kornel Lesiński 8a3338b078 Extracted function 2016-12-21 18:06:22 +01:00
Kornel Lesiński b03ae0d765 Moved assert 2016-12-21 18:06:19 +01:00
Kornel Lesiński 97c652e3b0 Fixed method name 2016-12-21 17:42:38 +01:00
Kornel 301af71228 Merge pull request #938 from sparkle-project/unarch
Unarchiving blocks
2016-12-21 17:07:19 +01:00
Zorg 60d4f05743 Add SUUnarchiverProtocol & remove runtime registration of unarchivers 2016-12-21 11:07:03 -05:00
Kornel Lesiński 464972126c Unwrap early 2016-12-21 16:44:04 +01:00
Kornel Lesiński c1392bc190 Nullability 2016-12-21 16:44:04 +01:00
Kornel Lesiński 921aed0fae Temp vars 2016-12-21 16:44:04 +01:00
Kornel Lesiński 59d90e0bb1 Basic binary delta progress 2016-12-21 15:23:41 +01:00
Kornel Lesiński e3fb6bb1a8 Report DMG extraction progress 2016-12-21 15:23:41 +01:00
Kornel Lesiński 8103f5fd43 Replaced progress delegate with a block 2016-12-21 15:23:40 +01:00
Kornel Lesiński 70f5681797 Use completion block for unarchiving 2016-12-21 15:22:59 +01:00
Kornel Lesiński 5ee02e954e Renamed callbacks 2016-12-21 15:22:59 +01:00
Kornel Lesiński 23b2b49663 Ability to report specific unarchiving error 2016-12-21 15:22:59 +01:00
Kornel Lesiński 311ed493b4 Unused 2016-12-21 15:22:59 +01:00
Kornel Lesiński 9d8b3c0c36 DRY async dispatch of unarchiver notifications 2016-12-21 15:22:59 +01:00
Kornel Lesiński f3f268388b Nullability declarations 2016-12-21 15:22:57 +01:00
Kornel 8d0effe327 Merge pull request #934 from sparkle-project/msg
Less alarming error message
2016-12-17 23:51:34 +01:00
Kornel Lesiński 19455099ff Formatting 2016-12-10 16:15:02 +00:00
Kornel Lesiński 6e754d7e4f Use return instead of state variable 2016-12-10 16:15:02 +00:00
Kornel Lesiński ab6fa76303 Xcode 8 now 2016-12-10 12:04:26 +00:00
Kornel Lesiński 93fc4b0151 Highlight Sierra compat 2016-12-10 12:03:58 +00:00
Kornel Lesiński 021950a5b2 Less alarming error message 2016-12-10 11:59:47 +00:00
Kornel 2ff0da4f15 Merge pull request #881 from zorgiepoo/separate-validation
Separate validation
2016-12-04 13:35:07 +00:00
Kornel Lesiński 945968a0ef Reminder 2016-12-04 12:19:25 +00:00
Kornel Lesiński 1e4f126f7e Podspec version bump 2016-12-04 12:18:11 +00:00
Kornel Lesiński f47115d81f Version bump 2016-12-04 12:14:24 +00:00
Kornel Lesiński 49781561f3 Cocoapods fudge 2016-12-04 12:10:27 +00:00
Zorg 1587dd1dc3 Refactor pre & post update validation into its own class 2016-12-03 15:37:00 -05:00
Zorg c0b9eaaa0e s/requiresValidationBeforUnarchiving/unsafeIfArchiveIsNotValidated/ 2016-12-03 11:06:10 -05:00
Kornel 91ac90ffcf Merge pull request #928 from sparkle-project/script
Fix #926
2016-12-03 00:05:09 +00:00
Kornel Lesiński 8375922755 Fix #926 2016-12-02 21:10:37 +00:00
Zorg 9a32766aeb Merge branch 'master' into separate-validation 2016-11-11 23:35:28 -05:00
Zorg 898e063b4f Remove unnecessary 'return;' 2016-09-04 18:38:08 -04:00
Zorg e8f88bf0f1 Merge branch 'master' into separate-validation 2016-09-04 18:37:14 -04:00
Zorg 5b2ce958bd Merge branch 'master' into separate-validation 2016-09-03 23:27:16 -04:00
Zorg e28c62244a Re-show download status if we attempt a 2nd download
This fixes a bug where the status would stay at "Extracting update" after validation from the 1st delta patch failed, and it continued on to a full download.
2016-09-01 23:19:58 -04:00
Zorg fec76fee12 Validate binary delta patches before unarchiving
Also keep package and bundle validation separate.
2016-09-01 23:14:26 -04:00
341 changed files with 11912 additions and 4459 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
---
name: Other issues
about: Found a bug? Want to implement a new feature?
title: ''
labels: '1.x'
assignees: ''
---
+10
View File
@@ -0,0 +1,10 @@
---
name: Other issues related to Sparkle 2.x
about: Found a bug? Want to implement a new feature?
title: ''
labels: '2.x'
assignees: ''
---
@@ -0,0 +1,34 @@
---
name: Sparkle 1.x doesn't work in my app
about: Problems with integration, unexpected errors
title: ''
labels: '1.x'
assignees: ''
---
<!--
The answer to your issue is probably already in Console.app on your computer.
Please use Console.app and search for Sparkle.
Please try troubleshooting steps:
https://github.com/sparkle-project/Sparkle#troubleshooting
-->
### Description of the problem
### Do you use Sandboxing in your app?
### Version of `Sparkle.framework` in the latest version of your app
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
### Sparkle's output from Console.app
```
```
### Steps to reproduce the behavior
@@ -0,0 +1,34 @@
---
name: Sparkle 2.x doesn't work in my app
about: Problems with using the beta version of Sparkle 2
title: ''
labels: '2.x'
assignees: ''
---
<!--
The answer to your issue is probably already in Console.app on your computer.
Please use Console.app and search for Sparkle.
Please try troubleshooting steps:
https://github.com/sparkle-project/Sparkle#troubleshooting
-->
### Description of the problem
### Do you use Sandboxing in your app?
### Version of `Sparkle.framework` in the latest version of your app
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
### Sparkle's output from Console.app
```
```
### Steps to reproduce the behavior
+3
View File
@@ -0,0 +1,3 @@
[submodule "Vendor/ed25519"]
path = Vendor/ed25519
url = https://github.com/orlp/ed25519
+1 -1
View File
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8
osx_image: xcode9
before_install:
- brew update
script: make ci
+158
View File
@@ -1,3 +1,161 @@
# 1.23.0
* Support generating appcast with localizations (#1499) (Alik Vovkotrub)
* Support versions with git commit SHA (#1504) (Alec Larson)
* Hide "Skip..." and "Remind..." buttons when they're not relevant (#1480) (Kenneth Johnsen)
* Preserve Finder tags while updating apps (#1512) (CoreCode)
* Read-only update alert dialog formatting improvements (#1515) (Quinn Taylor)
* Check if `SUBundleName` is set before normalizing (Jake Fenton)
* `NSInteger` cast warning on Xcode 11 (Marga Keuvelaar)
* Correct appcast file extension (Tom Vos)
* Update Sparkle.strings (Emir Sarı)
* Fix spelling (#1508) (Frank Chiarulli Jr)
# 1.22.0
* Enabled "Hardened Runtime" build option for Apple's notarization requirement
* Add delegate methods to suppress update alerts (George Nachman)
* Improved error when running from translocated location (Michael Buckley)
* Add phased rollout feature (#1381) (Fabian Jäger)
* Ignore non-standard permissions in delta updates instead of failing the build (Kornel Lesiński)
* Notify user when installed version is newer than the latest in the appcast (CoreCode)
* Reset timers after computer sleep (CoreCode)
* Block-based alternatives to `NSInvocation`-based delegate methods (Fabian Jäger)
* Add delegate `userDidSkipThisVersion` (BobZombie, Leo Natan, bono yusuke)
* Pass item to updaterShouldShowUpdateAlertForScheduledUpdate delegate method (George Nachman)
* Support providing private key as argument in `generate_appcast` (Yakuhzi, marchyang)
* Separate the ed25519 sources into a new static library (Tony Arnold)
* Disambiguate signing error messages (Nate Weaver)
* Use `XMLNode.Options.nodePrettyPrint` in `generate_appcast` instead of trying to add whitespace manually (fumoboy007)
* Annotate SUHost for nullability (Michael Buckley)
* Use SUAVAILABLE macro (Christiaan Hofman)
* Fix warnings when using modules (nivekkagicom)
* Correction of Czech localization inconsistency (#1403) (vojtakonarik)
* BR locale fix (BR Lingo)
* Update Japanese localization (fujisoft)
* French Sparkle.strings (Jean-Baptiste)
# 1.21.3
* Losslessly reduced the size of PNG (Barijaona Ramaholimihaso)
* Catch exceptions from subcommands (Julian Mayer)
* `generate_appcast` can sign any bundles instead of just apps (Nate Weaver)
* Check that effectiveAppearance is being observed before calling removeObserver (Pierluigi)
# 1.21.2
* Allow EdDSA for delta updates, too (Kornel)
* Warning fixes (Brian Bergstrand)
* Improvements to release notes view context menu and dark mode (Bi11)
# 1.21.0
* Added support EdDSA (ed25519) signatures (Kornel)
* DSA signatures are considered outdated, and Apple's `Security.framework` only supports weaker SHA-1-based DSA.
* Both old DSA and new EdDSA are still supported (and one app can use both), but new applications should use EdDSA only, and we recommend migrating away from DSA signatures.
* `generate_keys` is now a Swift tool that stores EdDSA private keys in the Keychain
* Existing apps can continue using their old DSA keys, but we've dropped support for generation of old DSA keys
* `sign_update` is now a Swift tool that signs using EdDSA from private keys in the Keychain
* The old DSA-based signing script has been moved to `bin/old_dsa_scripts`
* The old DSA-based signing script has been fixed to work on pre-10.13 systems (Thomas Tempelmann)
* `generate_appcast` has been updated to support EdDSA signatures
* It can sign both DSA (if `dsa_priv.pem` file is specified) and EdDSA (from Keychain)
* The tool now uses Caches directory and doesn't generate unnecessary delta files
* Fixed verification of delta updates on filesystems that change permissions of symlinks
* Fixed `NSURLSession` leak (Michael Ehrmann)
# 1.20.0
* `generate_appcast` option to read private key directly from the keychain (Tamás Lustyik)
* Add delegate callbacks for fininshed download and extraction related events (Csaba Horony)
* Don't check for updates if Do Not Disturb is on (Kornel)
* Expose `CodesigningVerifier`, add codesign info API (sunuslee)
* Threading fixes:
* Fix potential hang with `dispatch_sync` to main thread (Brian Bergstrand)
* Fix closeCheckingWindow called from background thread (Alexey Martemyanov)
* Improve 'read-only' error message (#1192) (Adrian Thomas)
* New Spanish localisation (Ken Arroyo Ohori)
* Updated Finnish language resources (Jason Pollack)
* Hungarian localization (Csaba Horony)
* Log more information about authentication requests (Kornel)
* Explicitly specify types to silence "Messaging unqualified id" warning that's new in Xcode 10. Removed __has_feature(objc_generics) check and use generisc to help silence the warnings. (Kent Sutherland)
* Fix binary delta creation on network drives (sagecook)
* Fix compilation issues on Xcode 10 with new build system (Leo Natan)
# 1.19.0
* Refactoring of downloader code to avoid deprecated methods (Deadpikle)
* Changes to which methods run on the main thread.
Note: some delegate methods may be called on non-main thread now. (Kornel)
* Update Japanese localization (1024jp)
* Update Sparkle.strings (Stefan Paychère)
* Fix Sparkle clients polling too frequently (Jonathan Bullard)
* Handle SecTransformExecute errors (Kornel)
* Silence Touch Bar availability warnings on Xcode 9 by using API_AVAILABLE. Disable gnu-zero-variadic-macro-arguments to prevent warnings from use of API_AVAILABLE. (Kent Sutherland)
* 10.11 SDK compatibility (David Fuhrmann)
# 1.18.1
* Add optional updaterDidRelaunchApplication: method on SUUpdaterDelegate (#1115) (App Tyrant)
* Implemented sparkle:os attribute as documented (Memphiz)
* Additional termination detection in case kpoll fails. (fujisoft)
* Included bin files in CocoaPods installation (Keith Smiley)
* Updated Dutch localization (Eitot)
* Updated German localization (Eitot)
* Updated Japanese translation (1024jp)
* Updated Portuguese translation (Victor)
* Updated to Xcode 9/Swift 4
# 1.18.0
* Name of the host app is used in authorization prompt (the `SPARKLE_RELAUNCH_TOOL_NAME` setting is now obsolete)
* More detailed progress bar for package installers (Kornel Lesiński)
* Disabled the keyboard shortcut for the install button for scheduled updates to avoid accidental installs. (George Nachman)
* generate_appcast tool adds release notes if there's an .html file with the same base name as the archive (Brett Walker)
* Added `sparkle:shortVersionString` to the enclosure, #1032 (Brett Walker)
* Fixed Japanese localization (1024jp)
* Fixed escaping of system profile URLs
* Added more logging in various failure cases (Kornel Lesiński)
* Better error message for quarantined apps that can't be updated
# 1.17.0
* 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
+3 -4
View File
@@ -16,15 +16,13 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 15
SPARKLE_VERSION_MINOR = 23
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
ALWAYS_SEARCH_USER_PATHS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
@@ -34,6 +32,7 @@ PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034id
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
ENABLE_HARDENED_RUNTIME = YES;
CLANG_ENABLE_OBJC_ARC = YES
GCC_ENABLE_PASCAL_STRINGS = NO
GCC_NO_COMMON_BLOCKS = YES;
@@ -90,4 +89,4 @@ CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments $(WARNING_CFLAGS_EXTRA)
@@ -1,4 +1,10 @@
#include "ConfigCommonDebug.xcconfig"
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_GENERATE_TEST_COVERAGE_FILES = YES
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
+6 -1
View File
@@ -2,8 +2,13 @@
// Debug only
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_OPTIMIZATION_LEVEL = 0
SWIFT_OPTIMIZATION_LEVEL = -Onone
DEBUG_INFORMATION_FORMAT = dwarf
ENABLE_TESTABILITY = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
+6 -1
View File
@@ -2,8 +2,13 @@
// Release only
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_OPTIMIZATION_LEVEL = s
SWIFT_OPTIMIZATION_LEVEL = -Ofast
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
@@ -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,7 @@
// Generate Appcast only
#include "ConfigSwift.xcconfig"
SWIFT_OBJC_BRIDGING_HEADER = generate_keys/Bridging-Header.h
MACOSX_DEPLOYMENT_TARGET = 10.11
PRODUCT_NAME = generate_keys
@@ -0,0 +1,4 @@
// Generate Appcast Debug
#include "ConfigGenerateKeys.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
@@ -0,0 +1,4 @@
// Generate Appcast Release
#include "ConfigGenerateKeys.xcconfig"
#include "ConfigSwiftRelease.xcconfig"
+2 -1
View File
@@ -1 +1,2 @@
SWIFT_VERSION = 3.0
SWIFT_VERSION = 4.2
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
+1 -1
View File
@@ -1 +1 @@
SWIFT_OPTIMIZATION_LEVEL = -Ofast
SWIFT_OPTIMIZATION_LEVEL = -Owholemodule
+3
View File
@@ -0,0 +1,3 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
#include "bsdiff-Shared.xcconfig"
+3
View File
@@ -0,0 +1,3 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
#include "bsdiff-Shared.xcconfig"
+14
View File
@@ -0,0 +1,14 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
// Deployment
SKIP_INSTALL = YES
// Packaging
EXECUTABLE_PREFIX = lib
PRODUCT_NAME = $(TARGET_NAME)
// Search Paths
ALWAYS_SEARCH_USER_PATHS = NO
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
WARNING_CFLAGS = $(inherited) -Wno-comma
+3
View File
@@ -0,0 +1,3 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
#include "ed25519-Shared.xcconfig"
+3
View File
@@ -0,0 +1,3 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
#include "ed25519-Shared.xcconfig"
+14
View File
@@ -0,0 +1,14 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
// Deployment
SKIP_INSTALL = YES
// Packaging
EXECUTABLE_PREFIX = lib
PRODUCT_NAME = $(TARGET_NAME)
// Search Paths
ALWAYS_SEARCH_USER_PATHS = NO
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
WARNING_CFLAGS = $(inherited) -Wno-cast-qual -Wno-conversion -Wno-sign-conversion
+13 -5
View File
@@ -2,11 +2,13 @@
set -e
if [ "$ACTION" = "" ] ; then
# Sanity check that the Podspec version matches the Sparkle version
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
exit 1
# If using cocoapods, sanity check that the Podspec version matches the Sparkle version
if [ -x "$(command -v pod)" ]; then
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
exit 1
fi
fi
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
@@ -16,6 +18,9 @@ if [ "$ACTION" = "" ] ; then
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
@@ -23,6 +28,9 @@ if [ "$ACTION" = "" ] ; then
# because missing dSYMs in a release build SHOULD trigger a build failure
if [ "$CONFIGURATION" = "Release" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
fi
+9 -3
View File
@@ -16,7 +16,7 @@ fi
version="$CURRENT_PROJECT_VERSION"
# Get version in format 1.x.x-commits-hash
gitversion=$(cd "$SRCROOT" ; git describe --tags --match '[12].*')
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
@@ -30,5 +30,11 @@ fi
# and use it to set the CFBundleShortVersionString value
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
View File
@@ -5,6 +5,7 @@ if [ "$ACTION" = "" ] ; then
doxygen Documentation/Doxyfile
else
echo "warning: Doxygen not found in PATH"
echo "open Terminal and type this command 'brew install doxygen' then click 'enter/return' key. finally build this target again"
fi
elif [ "$ACTION" = "clean" ] ; then
rm -rf "$SRCROOT/Documentation/html"
+1
View File
@@ -1,6 +1,7 @@
Copyright (c) 2006-2013 Andy Matuschak.
Copyright (c) 2009-2013 Elgato Systems GmbH.
Copyright (c) 2011-2014 Kornel Lesiński.
Copyright (c) 2015-2017 Mayur Pawashe.
Copyright (c) 2014 C.W. Betts.
Copyright (c) 2014 Petroules Corporation.
Copyright (c) 2014 Big Nerd Ranch.
+5 -2
View File
@@ -1,5 +1,7 @@
.PHONY: all localizable-strings release build test ci
all: build
ifndef BUILDDIR
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
endif
@@ -14,13 +16,14 @@ release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
cat Sparkle.podspec
@echo "Don't forget to update CocoaPods!"
@echo "Don't forget to update CocoaPods! pod trunk push"
build:
xcodebuild clean build
test:
xcodebuild -scheme Distribution -configuration Debug test
./objc_dep/objc_dep.py -t .
uitest:
xcodebuild -scheme UITests -configuration Debug test
@@ -31,7 +34,7 @@ ci:
( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \
fi ; \
done
for i in {10..11} ; do \
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 ; \
+39 -28
View File
@@ -1,54 +1,65 @@
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?maxAge=2592000)]() <a href="https://www.stackpath.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-StackPath-orange.svg" alt="sponsored by: StackPath"></a>
# Sparkle 1.x [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?maxAge=2592000)]() <a href="https://www.stackpath.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;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="732" alt="Sparkle shows familiar update window with release notes">
## Changes since 1.5b
* Up-to-date with 10.11 SDK and Xcode 7. Supports macOS 10.7+.
* Important security fixes.
* Cleaned up and modernized code, using ARC and Autolayout.
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
* Ability to mark updates as critical.
* Progress and status notifications for the host app.
* Name of finish_installation.app can be configured to match your app's name.
* Upgraded and more reliable binary delta and code signing verification.
This branch is the production ready, battle-tested version of Sparkle used by thousands of Mac apps.
The upcoming Sparkle 2 (currently in beta) can be found in the [2.x branch](https://github.com/sparkle-project/Sparkle/tree/2.x).
## Features
* Seamless integration—there's no mention of Sparkle; your icons and app name are used.
* True self-updating—the user can choose to automatically download and install all updates.
* Displays a detailed progress window to the user.
* Supports authentication for installing in secure locations.
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
* Uses RSS-based appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
* Displays release notes to the user via WebKit.
* Sparkle doesn't bug the user until second launch for better first impressions.
* Deep delegate support to make Sparkle work exactly as you need.
* Optionally sends system information to the server when checking for updates.
* Seamless. There's no mention of Sparkle; your icons and app name are used.
* Secure. Updates are verified using EdDSA signatures and Apple Code Signing.
* Fast. Supports delta updates which only patch files that have changed.
* Easy to install. Sparkle requires no code in your app, and only needs static files on a web server.
* 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.
* 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.
* Ability to mark updates as critical.
* Progress and status notifications for the host app.
## Requirements
* Runtime: macOS 10.7 or greater
* Build: Xcode 5 and 10.8 SDK or greater
* Build: Xcode 9 and 10.11 SDK or greater
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
* No sandboxing. Sparkle 1.x can't update sandboxed apps. [Sparkle 2.x](https://github.com/sparkle-project/Sparkle/tree/2.x) can.
## API
## Usage
See [getting started guide](https://sparkle-project.org/documentation/). No code is necessary, but a bit of Xcode configuration is required.
## Development
This repository uses git submodules, and will not build unless you clone recursively. Also, GitHub-provided ZIP/tar archives are broken due to GitHub not supporting git submodules properly.
git clone --recursive https://github.com/sparkle-project/Sparkle
### Troubleshooting
* Please check **Console.app**. Sparkle prints detailed information there about all problems it encounters. It often also suggests solutions to the problems, so please read Sparkle's log messages carefully.
* Use the `generate_appcast` tool which creates appcast files, correct signatures, and delta updates automatically.
* Make sure the URL specified in [`SUFeedURL`](https://sparkle-project.org/documentation/customization/) is valid (typos/404s are a common error!), and that it uses modern TLS ([test it](https://www.ssllabs.com/ssltest/)).
* Delete your app's preferences (in `~/Library/Preferences/<your bundle id>`) if you've set another feed URL programmatically via Sparkle's Objective-C interface.
### API symbols
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples).
## Building the distribution package
### Building the distribution package
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed.
Alternatively, build the Distribution scheme in the Xcode UI.
## Code of Conduct
### Code of Conduct
We pledge to have an open and welcoming environment. See our [Code of Conduct](CODE_OF_CONDUCT.md).
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 B

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 KiB

After

Width:  |  Height:  |  Size: 176 KiB

+3
View File
@@ -10,6 +10,7 @@
http://you.com/app/2.0.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
@@ -20,6 +21,7 @@
http://you.com/app/1.5.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
@@ -31,6 +33,7 @@
http://you.com/app/1.4.html
</sparkle:releaseNotesLink>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 100 KiB

+7 -5
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.15.0"
s.version = "1.22.0"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -11,16 +11,18 @@ Pod::Spec.new do |s|
:file => 'LICENSE'
}
s.authors = {
'Andy Matuschak' => 'andy@andymatuschak.org',
'Kornel Lesiński' => 'pornel@pornel.net',
'C.W. Betts' => 'computers57@hotmail.com',
'Jake Petroules' => 'jake.petroules@petroules.com',
'Mayur Pawashe' => 'zorgiepoo@gmail.com',
'Kornel Lesiński' => 'pornel@pornel.net',
'Jake Petroules' => 'jake.petroules@petroules.com',
'C.W. Betts' => 'computers57@hotmail.com',
'Andy Matuschak' => 'andy@andymatuschak.org',
}
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.preserve_paths = 'bin/*'
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_frameworks = 'Sparkle.framework'
s.xcconfig = {
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -10,6 +10,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -30,6 +31,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
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"
language = ""
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"
language = ""
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>
<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>
+20
View File
@@ -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
+86 -104
View File
@@ -1,70 +1,16 @@
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
#import "SULocalizations.h"
#import "SUErrors.h"
#import "SUInstaller.h"
#import "SUHost.h"
#import "SUStandardVersionComparator.h"
#import "SUStatusController.h"
#import "SULog.h"
#import "SUInstallerProtocol.h"
#import "TerminationListener.h"
#include <unistd.h>
/*!
* Time this app uses to recheck if the parent has already died.
*/
static const NSTimeInterval SUParentQuitCheckInterval = .25;
@interface TerminationListener : NSObject
- (instancetype)initWithProcessId:(pid_t)pid;
@end
@interface TerminationListener ()
@property (nonatomic, assign) pid_t processIdentifier;
@property (nonatomic, strong) NSTimer *watchdogTimer;
@end
@implementation TerminationListener
@synthesize processIdentifier = _processIdentifier;
@synthesize watchdogTimer = _watchdogTimer;
- (instancetype)initWithProcessId:(pid_t)pid
{
if (!(self = [super init])) {
return nil;
}
self.processIdentifier = pid;
return self;
}
- (void)cleanupWithCompletion:(void (^)(void))completionBlock
{
[self.watchdogTimer invalidate];
completionBlock();
}
- (void)startListeningWithCompletion:(void (^)(void))completionBlock
{
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
if (alreadyTerminated)
[self cleanupWithCompletion:completionBlock];
else
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:completionBlock repeats:YES];
}
- (void)watchdog:(NSTimer *)timer
{
if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.processIdentifier]) {
[self cleanupWithCompletion:timer.userInfo];
}
}
@end
/*!
* If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback.
*/
@@ -125,7 +71,8 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
self.hostPath = hostPath;
self.relaunchPath = relaunchPath;
self.terminationListener = [[TerminationListener alloc] initWithProcessId:parentProcessId];
SULog(SULogLevelDefault, @"PID to listen: %d", parentProcessId);
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:@(parentProcessId)];
self.updateFolderPath = updateFolderPath;
self.shouldRelaunch = shouldRelaunch;
self.shouldShowUI = shouldShowUI;
@@ -135,8 +82,13 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification
{
[self.terminationListener startListeningWithCompletion:^{
[self.terminationListener startListeningWithCompletion:^(BOOL terminationSuccess) {
self.terminationListener = nil;
if (!terminationSuccess) {
SULog(SULogLevelError, @"Failed to listen for application termination");
// Continue on with the installation anyway?
}
if (self.shouldShowUI) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -152,56 +104,86 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
}];
}
- (void)showError:(NSError *)error
{
if (self.shouldShowUI) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
}
}
- (void)install
{
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath];
SUHost *host = [[SUHost alloc] initWithBundle:theBundle];
NSString *installationPath = [[host installationPath] copy];
if (self.shouldShowUI) {
self.statusController = [[SUStatusController alloc] initWithHost:host];
[self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO];
[self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
maxProgressValue: 0 statusText: @""];
[self.statusController showWindow:self];
}
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
SULog(@"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
SULog(SULogLevelError, @"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
}
[SUInstaller installFromUpdateFolder:self.updateFolderPath
overHost:host
installationPath:installationPath
fileOperationToolPath:fileOperationToolPath
versionComparator:[SUStandardVersionComparator defaultComparator]
completionHandler:^(NSError *error) {
if (error) {
NSError *underlyingError = [error.userInfo objectForKey:NSUnderlyingErrorKey];
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
SULog(@"Installation Error: %@", error);
if (self.shouldShowUI) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
}
}
exit(EXIT_FAILURE);
} else {
NSString *pathToRelaunch = nil;
// If the installation path differs from the host path, we give higher precedence for it than
// if the desired relaunch path differs from the host path
if (![installationPath.pathComponents isEqualToArray:self.hostPath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.hostPath.pathComponents]) {
pathToRelaunch = installationPath;
} else {
pathToRelaunch = self.relaunchPath;
}
[self cleanupAndTerminateWithPathToRelaunch:pathToRelaunch];
}
}];
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;
});
};
NSError *finalInstallationError = nil;
if (![installer performFinalInstallationProgressBlock:progressBlock error:&finalInstallationError]) {
NSError *underlyingError = [finalInstallationError.userInfo objectForKey:NSUnderlyingErrorKey];
dispatch_async(dispatch_get_main_queue(), ^{
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
SULog(SULogLevelError, @"Failed to perform final installation Error: %@", finalInstallationError);
[self showError:finalInstallationError];
}
exit(EXIT_FAILURE);
});
return;
}
NSString *installationPath = [installer installationPath];
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
@@ -211,7 +193,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
dispatch_block_t cleanupAndExit = ^{
NSError *theError = nil;
if (![[NSFileManager defaultManager] removeItemAtPath:self.updateFolderPath error:&theError]) {
SULog(@"Couldn't remove update folder: %@.", theError);
SULog(SULogLevelError, @"Couldn't remove update folder: %@.", theError);
}
[[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL];
@@ -227,7 +209,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
// Don't use -launchApplication: because we may not be launching an application. Eg: it could be a system prefpane
if (![[NSWorkspace sharedWorkspace] openFile:relaunchPath]) {
SULog(@"Failed to launch %@", relaunchPath);
SULog(SULogLevelError, @"Failed to launch %@", relaunchPath);
}
[self.statusController close];
@@ -250,7 +232,7 @@ int main(int __unused argc, const char __unused *argv[])
{
@autoreleasepool
{
NSArray *args = [[NSProcessInfo processInfo] arguments];
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
if (args.count < 5 || args.count > 7) {
return EXIT_FAILURE;
}
+24
View File
@@ -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
+136
View File
@@ -0,0 +1,136 @@
//
// 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];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if ([self terminated]) {
[self invokeCompletionWithSuccess:YES];
}
});
}
static void noteExitKQueueCallback(CFFileDescriptorRef file, CFOptionFlags __unused callBackTypes, void *info)
{
struct kevent event;
kevent(CFFileDescriptorGetNativeDescriptor(file), NULL, 0, &event, 1, NULL);
TerminationListener *self = CFBridgingRelease(info);
self.watchedTermination = YES;
[self invokeCompletionWithSuccess:YES];
}
@end
Vendored Executable → Regular
+29 -29
View File
@@ -2,21 +2,21 @@
import Foundation
func die(msg: String) {
func die(_ msg: String) {
print("ERROR: \(msg)")
exit(1)
}
extension NSXMLElement {
extension XMLElement {
convenience init(name: String, attributes: [String: String], stringValue string: String? = nil) {
self.init(name: name, stringValue: string)
setAttributesWithDictionary(attributes)
setAttributesWith(attributes)
}
}
let ud = NSUserDefaults.standardUserDefaults()
let sparkleRoot = ud.objectForKey("root") as? String
let htmlPath = ud.objectForKey("htmlPath") as? String
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")
}
@@ -29,36 +29,36 @@ if enStringsDict == nil {
let enStringsDictKeys = enStringsDict!.allKeys
let dirPath = NSString(string: sparkleRoot! + "/Sparkle")
let dirContents = try! NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath as String)
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 = NSXMLDocument(rootElement: NSXMLElement(name: "html"))
html.DTD = NSXMLDTD()
html.DTD!.name = html.rootElement()!.name
var html = XMLDocument(rootElement: XMLElement(name: "html"))
html.dtd = XMLDTD()
html.dtd!.name = html.rootElement()!.name
html.characterEncoding = "UTF-8"
html.documentContentKind = NSXMLDocumentContentKind.XHTMLKind
var body = NSXMLElement(name: "body")
var head = NSXMLElement(name: "head")
html.documentContentKind = XMLDocument.ContentKind.xhtml
var body = XMLElement(name: "body")
var head = XMLElement(name: "head")
html.rootElement()!.addChild(head)
html.rootElement()!.addChild(body)
head.addChild(NSXMLElement(name: "meta", attributes: ["charset": html.characterEncoding!]))
head.addChild(NSXMLElement(name: "title", stringValue: "Sparkle Localizations Report"))
head.addChild(NSXMLElement(name: "style", stringValue: css))
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 = NSLocale.currentLocale()
let locale = Locale.current
for dirEntry in dirContents {
if NSString(string: dirEntry).pathExtension != "lproj" || dirEntry == "en.lproj" {
continue
}
let lang = locale.displayNameForKey(NSLocaleLanguageCode, value: NSString(string: dirEntry).stringByDeletingPathExtension)
body.addChild(NSXMLElement(name: "h1", stringValue: "\(dirEntry) (\(lang!))"))
let 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.stringByAppendingPathComponent(dirEntry)).stringByAppendingPathComponent("Sparkle.strings")
let stringsPath = NSString(string: dirPath.appendingPathComponent(dirEntry)).appendingPathComponent("Sparkle.strings")
let stringsDict = NSDictionary(contentsOfFile: stringsPath)
if stringsDict == nil {
die("Invalid strings file \(dirEntry)")
@@ -70,10 +70,10 @@ for dirEntry in dirContents {
var unused: [String] = []
for key in enStringsDictKeys {
let str = stringsDict?.objectForKey(key) as? String
let str = stringsDict?.object(forKey: key) as? String
if str == nil {
missing.append(key as! String)
} else if let enStr = enStringsDict?.objectForKey(key) as? String {
} else if let enStr = enStringsDict?.object(forKey: key) as? String {
if enStr == str {
unlocalized.append(key as! String)
}
@@ -82,7 +82,7 @@ for dirEntry in dirContents {
let stringsDictKeys = stringsDict!.allKeys
for key in stringsDictKeys {
if enStringsDict?.objectForKey(key) == nil {
if enStringsDict?.object(forKey: key) == nil {
unused.append(key as! String)
}
}
@@ -90,12 +90,12 @@ for dirEntry in dirContents {
let sorter = { (s1: String, s2: String) -> Bool in
return s1 < s2
}
missing.sortInPlace(sorter)
unlocalized.sortInPlace(sorter)
unused.sortInPlace(sorter)
missing.sort(by: sorter)
unlocalized.sort(by: sorter)
unused.sort(by: sorter)
let addRow = { (prefix: String, cssClass: String, key: String) -> Void in
body.addChild(NSXMLElement(name: "span", attributes: ["class": cssClass], stringValue: [prefix, key].joinWithSeparator(" ") + "\n"))
body.addChild(XMLElement(name: "span", attributes: ["class": cssClass], stringValue: [prefix, key].joined(separator: " ") + "\n"))
}
for key in missing {
@@ -110,6 +110,6 @@ for dirEntry in dirContents {
}
var err: NSError?
if !html.XMLData.writeToFile(htmlPath!, atomically: true) {
die("Can't write report: \(err)")
if !((try? html.xmlData.write(to: URL(fileURLWithPath: htmlPath!), options: [.atomic])) != nil) {
die("Can't write report: \(err!)")
}
+9
View File
@@ -0,0 +1,9 @@
html {
color: #FFFFFFD8;
}
:link {
color: #419CFF;
}
:link:active {
color: #FF1919;
}
+43
View File
@@ -0,0 +1,43 @@
//
// SPUDownloadData.h
// Sparkle
//
// Created by Mayur Pawashe on 8/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
/*!
* A class for containing downloaded data along with some information about it.
*/
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
/*!
* The raw data that was downloaded.
*/
@property (nonatomic, readonly) NSData *data;
/*!
* The IANA charset encoding name if available. Eg: "utf-8"
*/
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
/*!
* The MIME type if available. Eg: "text/plain"
*/
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
@end
NS_ASSUME_NONNULL_END
+75
View File
@@ -0,0 +1,75 @@
//
// SPUDownloadData.m
// Sparkle
//
// Created by Mayur Pawashe on 8/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUDownloadData.h"
#import "SUOperatingSystem.h"
#include "AppKitPrevention.h"
static NSString *SPUDownloadDataKey = @"SPUDownloadData";
static NSString *SPUDownloadTextEncodingKey = @"SPUDownloadTextEncoding";
static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
@implementation SPUDownloadData
@synthesize data = _data;
@synthesize textEncodingName = _textEncodingName;
@synthesize MIMEType = _MIMEType;
+ (BOOL)supportsSecureCoding
{
return YES;
}
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString *)MIMEType
{
self = [super init];
if (self != nil) {
_data = data;
_textEncodingName = textEncodingName;
_MIMEType = MIMEType;
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.data forKey:SPUDownloadDataKey];
if (self.textEncodingName != nil) {
[coder encodeObject:self.textEncodingName forKey:SPUDownloadTextEncodingKey];
}
if (self.MIMEType != nil) {
[coder encodeObject:self.MIMEType forKey:SPUDownloadMIMETypeKey];
}
}
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
{
if (SUAVAILABLE(10, 8)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUDownloadDataKey];
if (data == nil) {
return nil;
}
NSString *textEncodingName = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadTextEncodingKey];
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadMIMETypeKey];
#pragma clang diagnostic pop
return [self initWithData:data textEncodingName:textEncodingName MIMEType:MIMEType];
} else {
abort(); // Not used on 10.7
}
}
@end
+25
View File
@@ -0,0 +1,25 @@
//
// SPUDownloader.h
// Downloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloaderProtocol.h"
@protocol SPUDownloaderDelegate;
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
// Due to XPC remote object reasons, this delegate is strongly referenced
// Invoke cleanup when done with this instance
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate;
@end
+118
View File
@@ -0,0 +1,118 @@
//
// SPUDownloader.m
// Downloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUDownloader.h"
#import "SPUDownloaderDelegate.h"
#import "SPULocalCacheDirectory.h"
#import "SPUURLRequest.h"
#import "SPUDownloadData.h"
#import "SUErrors.h"
#import "SPUDownloader_Private.h"
#include "AppKitPrevention.h"
@interface SPUDownloader ()
@end
@implementation SPUDownloader
@synthesize delegate = _delegate;
@synthesize bundleIdentifier = _bundleIdentifier;
@synthesize desiredFilename = _desiredFilename;
@synthesize downloadFilename = _downloadFilename;
@synthesize disabledAutomaticTermination = _disabledAutomaticTermination;
@synthesize mode = _mode;
@synthesize receivedExpectedBytes = _receivedExpectedBytes;
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate
{
self = [super init];
if (self != nil) {
_delegate = delegate;
}
return self;
}
// Don't implement dealloc - make the client call cleanup, which is the only way to remove the reference cycle from the delegate anyway
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)__unused request bundleIdentifier:(NSString *)__unused bundleIdentifier desiredFilename:(NSString *)__unused desiredFilename
{
}
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)__unused request
{
}
- (void)enableAutomaticTermination
{
if (self.disabledAutomaticTermination) {
[[NSProcessInfo processInfo] enableAutomaticTermination:SUDownloadingReason];
self.disabledAutomaticTermination = NO;
}
}
- (void)cleanup
{
[self enableAutomaticTermination];
self.delegate = nil;
if (self.mode == SPUDownloadModeTemporary && self.downloadFilename != nil)
{
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:NULL];
self.downloadFilename = nil;
}
}
- (void)cancel
{
}
- (void)downloadDidFinish
{
}
-(void)downloadDidFinishWithData:(SPUDownloadData*)data
{
switch (self.mode) {
case SPUDownloadModeTemporary:
if (data != nil) {
[self.delegate downloaderDidFinishWithTemporaryDownloadData:data];
} else {
[self.delegate downloaderDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to read temporary downloaded data from %@", self.downloadFilename]}]];
}
break;
case SPUDownloadModePersistent:
[self.delegate downloaderDidFinishWithTemporaryDownloadData:nil];
break;
}
}
-(NSString*)getAndCleanTempDirectory
{
NSString *rootPersistentDownloadCachePath = [[SPULocalCacheDirectory cachePathForBundleIdentifier:self.bundleIdentifier] stringByAppendingPathComponent:@"PersistentDownloads"];
[SPULocalCacheDirectory removeOldItemsInDirectory:rootPersistentDownloadCachePath];
NSString *tempDir = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:rootPersistentDownloadCachePath];
if (tempDir == nil) {
// Okay, something's really broken with this user's file structure.
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", tempDir] }];
[self.delegate downloaderDidFailWithError:error];
[self cancel];
}
return tempDir;
}
@end
+38
View File
@@ -0,0 +1,38 @@
//
// SPUDownloaderDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUDownloadData;
@protocol SPUDownloaderDelegate <NSObject>
// This is only invoked for persistent downloads
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
- (void)downloaderDidFailWithError:(NSError *)error;
@end
NS_ASSUME_NONNULL_END
+13
View File
@@ -0,0 +1,13 @@
//
// SPUDownloaderDeprecated.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#import "SPUDownloader.h"
@interface SPUDownloaderDeprecated : SPUDownloader <SPUDownloaderProtocol>
@end
+168
View File
@@ -0,0 +1,168 @@
//
// SPUDownloaderDeprecated.m
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#import "SPUDownloaderDeprecated.h"
#import "SPUURLRequest.h"
#import "SPUDownloader_Private.h"
#import "SPUDownloadData.h"
#import "SPULocalCacheDirectory.h"
#import "SUErrors.h"
#include "AppKitPrevention.h"
@interface SPUDownloaderDeprecated () <NSURLDownloadDelegate>
@property (nonatomic) NSURLDownload *download;
@property (nonatomic) NSURLResponse *response;
@end
@implementation SPUDownloaderDeprecated
@synthesize download = _download;
@synthesize response = _response;
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModePersistent;
self.desiredFilename = desiredFilename;
self.bundleIdentifier = bundleIdentifier;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
}
});
}
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModeTemporary;
self.download = [[NSURLDownload alloc] initWithRequest:request.request delegate:self];
}
});
}
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
{
if (self.mode == SPUDownloadModeTemporary) {
// Files downloaded in temporary mode should not last for very long,
// so it's ideal to place them in a system temporary directory
NSString *destinationFilename = NSTemporaryDirectory();
if (destinationFilename) {
destinationFilename = [destinationFilename stringByAppendingPathComponent:name];
[self.download setDestination:destinationFilename allowOverwrite:NO];
}
} else {
NSString *tempDir = [super getAndCleanTempDirectory];
if (tempDir != nil) {
NSString *downloadFileName = self.desiredFilename;
NSString *downloadFileNameDirectory = [tempDir stringByAppendingPathComponent:downloadFileName];
NSError *createError = nil;
if (![[NSFileManager defaultManager] createDirectoryAtPath:downloadFileNameDirectory withIntermediateDirectories:NO attributes:nil error:&createError]) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a download file name %@ directory inside temporary directory for the update download at %@.", downloadFileName, downloadFileNameDirectory] }];
[self.delegate downloaderDidFailWithError:error];
} else {
[self.download setDestination:[downloadFileNameDirectory stringByAppendingPathComponent:name] allowOverwrite:YES];
[self.delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
}
}
}
}
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
{
self.downloadFilename = path;
}
- (void)download:(NSURLDownload *)__unused download didReceiveResponse:(NSURLResponse *)response
{
self.response = response;
if (self.mode == SPUDownloadModePersistent) {
// It might be tempting to send over the response object instead of the expected content length but this isn't a good idea
// For one, we are only ever concerned about the expected content length
// Another reason is that NSURLResponse doesn't support NSSecureCoding in older OS releases (eg: 10.8), which cause issues with XPC
[self.delegate downloaderDidReceiveExpectedContentLength:response.expectedContentLength];
}
}
- (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length
{
if (self.mode == SPUDownloadModePersistent) {
[self.delegate downloaderDidReceiveDataOfLength:length];
}
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
{
[self downloadDidFinish];
[self cleanup];
}
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
{
self.download = nil;
[self.delegate downloaderDidFailWithError:error];
[self cleanup];
}
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
{
// We don't want the download system to extract our gzips for persistent downloads
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
return (self.mode == SPUDownloadModeTemporary || [encodingType rangeOfString:@"gzip"].location == NSNotFound);
}
- (void)downloadDidFinish
{
assert(self.response != nil);
assert(self.downloadFilename != nil);
SPUDownloadData *downloadData = nil;
if (self.mode == SPUDownloadModeTemporary) {
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
if (data != nil) {
downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:self.response.textEncodingName MIMEType:self.response.MIMEType];
}
}
self.download = nil;
[super downloadDidFinishWithData:downloadData];
}
-(void)cleanup
{
[self.download cancel];
self.download = nil;
self.response = nil;
[super cleanup];
}
- (void)cancel
{
[self cleanup];
}
@end
+34
View File
@@ -0,0 +1,34 @@
//
// SPUDownloaderProtocol.h
// PersistentDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUURLRequest;
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
@protocol SPUDownloaderProtocol
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
- (void)downloadDidFinish;
- (void)cleanup;
- (void)cancel;
@end
NS_ASSUME_NONNULL_END
+20
View File
@@ -0,0 +1,20 @@
//
// SPUDownloaderSession.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloader.h"
#import "SPUDownloaderProtocol.h"
NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0)
@interface SPUDownloaderSession : SPUDownloader <SPUDownloaderProtocol>
@end
+167
View File
@@ -0,0 +1,167 @@
//
// SPUDownloaderSession.m
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#import "SPUDownloaderSession.h"
#import "SPUURLRequest.h"
#import "SPUDownloader_Private.h"
#import "SPULocalCacheDirectory.h"
#import "SUErrors.h"
#import "SPUDownloadData.h"
#include "AppKitPrevention.h"
@interface SPUDownloaderSession () <NSURLSessionDelegate>
@property (nonatomic) NSURLSession *downloadSession;
@property (nonatomic) NSURLSessionDownloadTask *download;
@end
@implementation SPUDownloaderSession
@synthesize downloadSession = _downloadSession;
@synthesize download = _download;
- (void)startDownloadWithRequest:(SPUURLRequest *)request
{
NSOperationQueue *queue = [NSOperationQueue mainQueue];
self.downloadSession = [NSURLSession
sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
delegate:self
delegateQueue:queue];
self.download = [self.downloadSession downloadTaskWithRequest:request.request];
[self.download resume];
}
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModePersistent;
self.desiredFilename = desiredFilename;
self.bundleIdentifier = bundleIdentifier;
[self startDownloadWithRequest:request];
}
});
}
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.download == nil && self.delegate != nil) {
// Prevent service from automatically terminating while downloading the update asynchronously without any reply blocks
[[NSProcessInfo processInfo] disableAutomaticTermination:SUDownloadingReason];
self.disabledAutomaticTermination = YES;
self.mode = SPUDownloadModeTemporary;
[self startDownloadWithRequest:request];
}
});
}
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)__unused downloadTask didFinishDownloadingToURL:(NSURL *)location
{
if (self.mode == SPUDownloadModeTemporary) {
self.downloadFilename = location.path;
[self downloadDidFinish]; // file is already in a system temp dir
} else {
NSString *tempDir = [super getAndCleanTempDirectory];
if (tempDir != nil) {
NSString *downloadFileName = self.desiredFilename;
NSString *downloadFileNameDirectory = [tempDir stringByAppendingPathComponent:downloadFileName];
NSError *createError = nil;
if (![[NSFileManager defaultManager] createDirectoryAtPath:downloadFileNameDirectory withIntermediateDirectories:NO attributes:nil error:&createError]) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a download file name %@ directory inside temporary directory for the update download at %@.", downloadFileName, downloadFileNameDirectory] }];
[self.delegate downloaderDidFailWithError:error];
} else {
NSString *name = self.download.response.suggestedFilename;
if (!name) {
name = location.lastPathComponent; // This likely contains nothing useful to identify the file (e.g. CFNetworkDownload_87LVIz.tmp)
}
NSString *toPath = [downloadFileNameDirectory stringByAppendingPathComponent:name];
NSString *fromPath = location.path; // suppress moveItemAtPath: non-null warning
NSError *error = nil;
if ([[NSFileManager defaultManager] moveItemAtPath:fromPath toPath:toPath error:&error]) {
self.downloadFilename = toPath;
[self.delegate downloaderDidSetDestinationName:name temporaryDirectory:downloadFileNameDirectory];
[self downloadDidFinish];
} else {
[self.delegate downloaderDidFailWithError:error];
}
}
}
}
}
- (void)URLSession:(NSURLSession *)__unused session downloadTask:(NSURLSessionDownloadTask *)__unused downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)__unused totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{
if (self.mode == SPUDownloadModePersistent && totalBytesExpectedToWrite > 0 && !self.receivedExpectedBytes) {
self.receivedExpectedBytes = YES;
[self.delegate downloaderDidReceiveExpectedContentLength:totalBytesExpectedToWrite];
}
if (self.mode == SPUDownloadModePersistent && bytesWritten >= 0) {
[self.delegate downloaderDidReceiveDataOfLength:(uint64_t)bytesWritten];
}
}
- (void)URLSession:(NSURLSession *)__unused session task:(NSURLSessionTask *)__unused task didCompleteWithError:(NSError *)error
{
self.download = nil;
if (error) {
[self.delegate downloaderDidFailWithError:error];
}
[self cleanup];
}
- (void)downloadDidFinish
{
assert(self.downloadFilename != nil);
SPUDownloadData *downloadData = nil;
if (self.mode == SPUDownloadModeTemporary) {
NSData *data = [NSData dataWithContentsOfFile:self.downloadFilename];
if (data != nil) {
NSURLResponse *response = self.download.response;
assert(response != nil);
downloadData = [[SPUDownloadData alloc] initWithData:data textEncodingName:response.textEncodingName MIMEType:response.MIMEType];
}
}
self.download = nil;
[super downloadDidFinishWithData:downloadData];
}
-(void)cleanup
{
[self.download cancel];
[self.downloadSession invalidateAndCancel];
self.download = nil;
self.downloadSession = nil;
[super cleanup];
}
- (void)cancel
{
[self cleanup];
}
// NSURLDownload has a [downlaod:shouldDecodeSourceDataOfMIMEType:] to determine if the data should be decoded.
// This does not exist for NSURLSessionDownloadTask and appears unnecessary. Data tasks will decode data, but not download tasks.
@end
+41
View File
@@ -0,0 +1,41 @@
//
// SPUDownloader_Private.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#ifndef SPUDownloader_Private_h
#define SPUDownloader_Private_h
#import "SPUDownloaderDelegate.h"
typedef NS_ENUM(NSUInteger, SPUDownloadMode)
{
SPUDownloadModePersistent,
SPUDownloadModeTemporary
};
static NSString *SUDownloadingReason = @"Downloading update related file";
@interface SPUDownloader ()
// Delegate is intentionally strongly referenced; see header
@property (nonatomic) id <SPUDownloaderDelegate> delegate;
@property (nonatomic, copy) NSString *bundleIdentifier;
@property (nonatomic, copy) NSString *desiredFilename;
@property (nonatomic, copy) NSString *downloadFilename;
@property (nonatomic) BOOL disabledAutomaticTermination;
@property (nonatomic) SPUDownloadMode mode;
@property (nonatomic) BOOL receivedExpectedBytes;
// returns temp directory location if successful; if not successful,
// returns nil after sending error message to client and canceling download
-(NSString*)getAndCleanTempDirectory;
-(void)downloadDidFinishWithData:(SPUDownloadData*)data;
@end
#endif /* SPUDownloader_Private_h */
+35
View File
@@ -0,0 +1,35 @@
//
// SULocalCacheDirectory.h
// Sparkle
//
// Created by Mayur Pawashe on 6/23/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface SPULocalCacheDirectory : NSObject
// Returns a path to a suitable cache directory to create specifically for Sparkle
// Intermediate directories to this path may not exist yet
// This path may depend on the type of running process,
// such that sandboxed vs non-sandboxed processes could yield different paths
// The caller should create a subdirectory from the path that is returned here so they don't have files that
// conflict with other callers. Once that subdirectory name is decided, the caller can remove old items inside it (using +removeOldItemsInDirectory:)
// and then create a unique temporary directory inside it (using +createUniqueDirectoryInDirectory:)
+ (NSString *)cachePathForBundleIdentifier:(NSString *)bundleIdentifier;
// Remove old files inside a directory
// A caller may want to invoke this on a directory they own rather than remove and re-create an entire directory
// This does nothing if the supplied directory does not exist yet
+ (void)removeOldItemsInDirectory:(NSString *)directory;
// Create a unique directory inside a parent directory
// The parent directory doesn't have to exist yet. If it doesn't exist, intermediate directories will be created.
+ (NSString * _Nullable)createUniqueDirectoryInDirectory:(NSString *)directory;
@end
NS_ASSUME_NONNULL_END
+80
View File
@@ -0,0 +1,80 @@
//
// SULocalCacheDirectory.m
// Sparkle
//
// Created by Mayur Pawashe on 6/23/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPULocalCacheDirectory.h"
#import "SULog.h"
#include "AppKitPrevention.h"
static NSTimeInterval OLD_ITEM_DELETION_INTERVAL = 86400 * 10; // 10 days
@implementation SPULocalCacheDirectory
// It is important to note this may return a different path whether invoked from a sanboxed vs non-sandboxed process, or from a different user
// For this reason, this method should not be a part of SUHost because its behavior depends on what kind of process it's being invoked from
+ (NSString *)cachePathForBundleIdentifier:(NSString *)bundleIdentifier
{
NSURL *cacheURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:NULL];
assert(cacheURL != nil);
NSString *resultPath = [[[cacheURL URLByAppendingPathComponent:bundleIdentifier] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER] path];
assert(resultPath != nil);
return resultPath;
}
+ (void)removeOldItemsInDirectory:(NSString *)directory
{
NSMutableArray<NSString *> *filePathsToRemove = [NSMutableArray array];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:directory]) {
NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:directory];
NSDate *currentDate = [NSDate date];
for (NSString *filename in directoryEnumerator)
{
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:[directory stringByAppendingPathComponent:filename] error:NULL];
if (fileAttributes != nil)
{
NSDate *lastModificationDate = [fileAttributes objectForKey:NSFileModificationDate];
if ([currentDate timeIntervalSinceDate:lastModificationDate] >= OLD_ITEM_DELETION_INTERVAL)
{
[filePathsToRemove addObject:[directory stringByAppendingPathComponent:filename]];
}
}
[directoryEnumerator skipDescendants];
}
for (NSString *filename in filePathsToRemove)
{
[fileManager removeItemAtPath:filename error:NULL];
}
}
}
+ (NSString * _Nullable)createUniqueDirectoryInDirectory:(NSString *)directory
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *createError = nil;
if (![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:&createError]) {
SULog(SULogLevelError, @"Failed to create directory with intermediate components at %@ with error %@", directory, createError);
return nil;
}
NSString *templateString = [directory stringByAppendingPathComponent:@"XXXXXXXXX"];
char buffer[PATH_MAX] = {0};
if ([templateString getFileSystemRepresentation:buffer maxLength:sizeof(buffer)]) {
if (mkdtemp(buffer) != NULL) {
return [[NSString alloc] initWithUTF8String:buffer];
}
}
return nil;
}
@end
+35
View File
@@ -0,0 +1,35 @@
//
// SPUURLRequest.h
// Sparkle
//
// Created by Mayur Pawashe on 5/19/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
// A class that wraps NSURLRequest and implements NSSecureCoding
// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8
// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not
@interface SPUURLRequest : NSObject <NSSecureCoding>
// Creates a new URL request
// Only these properties are currently tracked:
// * URL
// * Cache policy
// * Timeout interval
// * HTTP header fields
// * networkServiceType
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request;
@property (nonatomic, readonly) NSURLRequest *request;
@end
NS_ASSUME_NONNULL_END
+102
View File
@@ -0,0 +1,102 @@
//
// SPUURLRequest.m
// Sparkle
//
// Created by Mayur Pawashe on 5/19/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUURLRequest.h"
#import "SUOperatingSystem.h"
#include "AppKitPrevention.h"
static NSString *SPUURLRequestURLKey = @"SPUURLRequestURL";
static NSString *SPUURLRequestCachePolicyKey = @"SPUURLRequestCachePolicy";
static NSString *SPUURLRequestTimeoutIntervalKey = @"SPUURLRequestTimeoutInterval";
static NSString *SPUURLRequestHttpHeaderFieldsKey = @"SPUURLRequestHttpHeaderFields";
static NSString *SPUURLRequestNetworkServiceTypeKey = @"SPUURLRequestNetworkServiceType";
@interface SPUURLRequest ()
@property (nonatomic, readonly) NSURL *url;
@property (nonatomic, readonly) NSURLRequestCachePolicy cachePolicy;
@property (nonatomic, readonly) NSTimeInterval timeoutInterval;
@property (nonatomic, readonly, nullable) NSDictionary<NSString *, NSString *> *httpHeaderFields;
@property (nonatomic, readonly) NSURLRequestNetworkServiceType networkServiceType;
@end
@implementation SPUURLRequest
@synthesize url = _url;
@synthesize cachePolicy = _cachePolicy;
@synthesize timeoutInterval = _timeoutInterval;
@synthesize httpHeaderFields = _httpHeaderFields;
@synthesize networkServiceType = _networkServiceType;
- (instancetype)initWithURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)cachePolicy timeoutInterval:(NSTimeInterval)timeoutInterval httpHeaderFields:(NSDictionary<NSString *, NSString *> *)httpHeaderFields networkServiceType:(NSURLRequestNetworkServiceType)networkServiceType
{
self = [super init];
if (self != nil) {
_url = url;
_cachePolicy = cachePolicy;
_timeoutInterval = timeoutInterval;
_httpHeaderFields = httpHeaderFields;
_networkServiceType = networkServiceType;
}
return self;
}
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request
{
return [(SPUURLRequest *)[[self class] alloc] initWithURL:request.URL cachePolicy:request.cachePolicy timeoutInterval:request.timeoutInterval httpHeaderFields:request.allHTTPHeaderFields networkServiceType:request.networkServiceType];
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:self.url forKey:SPUURLRequestURLKey];
[coder encodeInteger:(NSInteger)self.cachePolicy forKey:SPUURLRequestCachePolicyKey];
[coder encodeDouble:self.timeoutInterval forKey:SPUURLRequestTimeoutIntervalKey];
[coder encodeInteger:(NSInteger)self.networkServiceType forKey:SPUURLRequestNetworkServiceTypeKey];
if (self.httpHeaderFields != nil) {
[coder encodeObject:self.httpHeaderFields forKey:SPUURLRequestHttpHeaderFieldsKey];
}
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
if (SUAVAILABLE(10, 8)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
NSURL *url = [decoder decodeObjectOfClass:[NSURL class] forKey:SPUURLRequestURLKey];
NSURLRequestCachePolicy cachePolicy = (NSURLRequestCachePolicy)[decoder decodeIntegerForKey:SPUURLRequestCachePolicyKey];
NSTimeInterval timeoutInterval = [decoder decodeDoubleForKey:SPUURLRequestTimeoutIntervalKey];
NSDictionary<NSString *, NSString *> *httpHeaderFields = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:SPUURLRequestHttpHeaderFieldsKey];
#pragma clang diagnostic pop
NSURLRequestNetworkServiceType networkServiceType = (NSURLRequestNetworkServiceType)[decoder decodeIntegerForKey:SPUURLRequestNetworkServiceTypeKey];
return [self initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval httpHeaderFields:httpHeaderFields networkServiceType:networkServiceType];
} else {
abort(); // Not used on 10.7
}
}
- (NSURLRequest *)request
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.url cachePolicy:self.cachePolicy timeoutInterval:self.timeoutInterval];
if (self.httpHeaderFields != nil) {
request.allHTTPHeaderFields = self.httpHeaderFields;
}
request.networkServiceType = self.networkServiceType;
return [request copy];
}
@end
+9 -5
View File
@@ -16,16 +16,20 @@
#endif
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem;
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
SU_EXPORT @interface SUAppcast : NSObject
@property (copy) NSString *userAgentString;
@property (copy) NSDictionary *httpHeaders;
@property (copy, nullable) NSString *userAgentString;
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
- (SUAppcast *)copyWithoutDeltaUpdates;
@property (readonly, copy) NSArray *items;
@property (readonly, copy, nullable) NSArray *items;
@end
NS_ASSUME_NONNULL_END
#endif
+83 -58
View File
@@ -6,14 +6,20 @@
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcast.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SULocalizations.h"
#import "SUErrors.h"
#import "SPUURLRequest.h"
#import "SUOperatingSystem.h"
#import "SPUDownloadData.h"
#import "SPUDownloaderDelegate.h"
#import "SPUDownloaderDeprecated.h"
#import "SPUDownloaderSession.h"
#include "AppKitPrevention.h"
@interface NSXMLElement (SUAppcastExtensions)
@property (readonly, copy) NSDictionary *attributesAsDictionary;
@@ -39,85 +45,114 @@
}
@end
@interface SUAppcast () <NSURLDownloadDelegate>
@interface SUAppcast () <SPUDownloaderDelegate>
@property (strong) void (^completionBlock)(NSError *);
@property (copy) NSString *downloadFilename;
@property (strong) NSURLDownload *download;
@property (strong) SPUDownloader *download;
@property (copy) NSArray *items;
- (void)reportError:(NSError *)error;
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes;
@end
@implementation SUAppcast
@synthesize downloadFilename;
@synthesize completionBlock;
@synthesize userAgentString;
@synthesize httpHeaders;
@synthesize download;
@synthesize items;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)background completionBlock:(void (^)(NSError *))block
{
self.completionBlock = block;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
if (background) {
request.networkServiceType = NSURLNetworkServiceTypeBackground;
}
if (self.userAgentString) {
[request setValue:self.userAgentString forHTTPHeaderField:@"User-Agent"];
}
if (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:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
- (void)download:(NSURLDownload *)__unused aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
{
NSString *destinationFilename = NSTemporaryDirectory();
if (destinationFilename)
{
destinationFilename = [destinationFilename stringByAppendingPathComponent:filename];
[self.download setDestination:destinationFilename allowOverwrite:NO];
if (SUAVAILABLE(10, 9)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
#pragma clang diagnostic pop
}
else {
self.download = [[SPUDownloaderDeprecated alloc] initWithDelegate:self];
}
SPUURLRequest *urlRequest = [SPUURLRequest URLRequestWithRequest:request];
[self.download startTemporaryDownloadWithRequest:urlRequest];
}
- (void)download:(NSURLDownload *)__unused aDownload didCreateDestination:(NSString *)path
- (void)downloaderDidSetDestinationName:(NSString *)__unused destinationName temporaryDirectory:(NSString *)__unused temporaryDirectory
{
self.downloadFilename = path;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused aDownload
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
{
NSError *error = nil;
NSArray *appcastItems = [self parseAppcastItemsFromXMLFile:[NSURL fileURLWithPath:self.downloadFilename] error:&error];
}
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
self.downloadFilename = nil;
- (void)downloaderDidReceiveDataOfLength:(uint64_t)__unused length
{
}
if (appcastItems) {
self.items = appcastItems;
self.completionBlock(nil);
self.completionBlock = nil;
} else {
NSMutableDictionary *userInfo = [NSMutableDictionary
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
forKey: NSLocalizedDescriptionKey];
if (error) {
[userInfo setObject:error forKey:NSUnderlyingErrorKey];
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData
{
if (downloadData != nil) {
NSError *parseError = nil;
NSArray *appcastItems = [self parseAppcastItemsFromXMLData:downloadData.data error:&parseError];
if (appcastItems != nil) {
self.items = appcastItems;
self.completionBlock(nil);
self.completionBlock = nil;
} else {
NSMutableDictionary *userInfo = [NSMutableDictionary
dictionaryWithObject: SULocalizedString(@"An error occurred while parsing the update feed.", nil)
forKey: NSLocalizedDescriptionKey];
if (parseError != nil) {
[userInfo setObject:parseError forKey:NSUnderlyingErrorKey];
}
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
code:SUAppcastParseError
userInfo:userInfo]];
}
} else {
SULog(SULogLevelError, @"Temp data download is null in SUAppcast");
NSDictionary *userInfo = [NSDictionary
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
forKey: NSLocalizedDescriptionKey];
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
code:SUAppcastParseError
code:SUDownloadError
userInfo:userInfo]];
}
}
- (void)downloaderDidFailWithError:(NSError *)error
{
SULog(SULogLevelError, @"Encountered download feed error: %@", error);
[self reportError:error];
}
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
{
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
@@ -148,17 +183,22 @@
}
}
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastURL error:(NSError *__autoreleasing*)errorp {
NSData *data = [NSData dataWithContentsOfURL:appcastURL];
return [self parseAppcastItemsFromXMLData:data error:errorp];
}
-(NSArray *)parseAppcastItemsFromXMLData:(NSData *)appcastData error:(NSError *__autoreleasing*)errorp {
if (errorp) {
*errorp = nil;
}
if (!appcastFile) {
if (!appcastData) {
return nil;
}
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:appcastFile options:options error:errorp];
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:appcastData options:options error:errorp];
if (nil == document) {
return nil;
}
@@ -245,7 +285,7 @@
[appcastItems addObject:anItem];
}
else {
SULog(@"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
SULog(SULogLevelError, @"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
code:SUAppcastParseError
userInfo:@{NSLocalizedDescriptionKey: errString}];
@@ -258,21 +298,6 @@
return appcastItems;
}
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
{
if (self.downloadFilename) {
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
}
self.downloadFilename = nil;
[self reportError:error];
}
- (NSURLRequest *)download:(NSURLDownload *)__unused aDownload willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)__unused redirectResponse
{
return request;
}
- (void)reportError:(NSError *)error
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
+7 -1
View File
@@ -15,20 +15,25 @@
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@class SUSignatures;
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
@property (copy, readonly) NSString *dateString;
@property (copy, readonly) NSDate *date;
@property (copy, readonly) NSString *itemDescription;
@property (strong, readonly) NSURL *releaseNotesURL;
@property (copy, readonly) NSString *DSASignature;
@property (strong, readonly) SUSignatures *signatures;
@property (copy, readonly) NSString *minimumSystemVersion;
@property (copy, readonly) NSString *maximumSystemVersion;
@property (strong, readonly) NSURL *fileURL;
@property (nonatomic, readonly) uint64_t contentLength;
@property (copy, readonly) NSString *versionString;
@property (copy, readonly) NSString *osString;
@property (copy, readonly) NSString *displayVersionString;
@property (copy, readonly) NSDictionary *deltaUpdates;
@property (strong, readonly) NSURL *infoURL;
@property (copy, readonly) NSNumber* phasedRolloutInterval;
// Initializes with data from a dictionary provided by the RSS class.
- (instancetype)initWithDictionary:(NSDictionary *)dict;
@@ -36,6 +41,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
+49 -13
View File
@@ -6,36 +6,38 @@
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUAppcastItem.h"
#import "SULog.h"
#import "SUConstants.h"
#import "SUSignatures.h"
#include "AppKitPrevention.h"
@interface SUAppcastItem ()
@property (copy, readwrite) NSString *title;
@property (copy, readwrite) NSString *dateString;
@property (copy, readwrite) NSString *itemDescription;
@property (strong, readwrite) NSURL *releaseNotesURL;
@property (copy, readwrite) NSString *DSASignature;
@property (strong, readwrite) SUSignatures *signatures;
@property (copy, readwrite) NSString *minimumSystemVersion;
@property (copy, readwrite) NSString *maximumSystemVersion;
@property (strong, readwrite) NSURL *fileURL;
@property (copy, readwrite) NSString *versionString;
@property (copy, readwrite) NSString *osString;
@property (copy, readwrite) NSString *displayVersionString;
@property (copy, readwrite) NSDictionary *deltaUpdates;
@property (strong, readwrite) NSURL *infoURL;
@property (readwrite, copy) NSDictionary *propertiesDictionary;
@property (copy, readwrite) NSNumber* phasedRolloutInterval;
@end
@implementation SUAppcastItem
@synthesize dateString;
@synthesize deltaUpdates;
@synthesize displayVersionString;
@synthesize DSASignature;
@synthesize signatures;
@synthesize fileURL;
@synthesize contentLength = _contentLength;
@synthesize infoURL;
@synthesize itemDescription;
@synthesize maximumSystemVersion;
@@ -43,7 +45,9 @@
@synthesize releaseNotesURL;
@synthesize title;
@synthesize versionString;
@synthesize osString;
@synthesize propertiesDictionary;
@synthesize phasedRolloutInterval;
- (BOOL)isDeltaUpdate
{
@@ -53,7 +57,24 @@
- (BOOL)isCriticalUpdate
{
return [[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
return [(NSArray *)[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
}
- (BOOL)isMacOsUpdate
{
return self.osString == nil || [self.osString isEqualToString:SUAppcastAttributeValueMacOS];
}
- (NSDate*)date {
if(self.dateString == nil) {
return nil;
}
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
dateFormatter.dateFormat = @"E, dd MMM yyyy HH:mm:ss Z";
return [dateFormatter dateFromString:self.dateString];
}
- (BOOL)isInformationOnlyUpdate
@@ -86,11 +107,11 @@
}
if (newVersion == nil) // no sparkle:version attribute anywhere?
{
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, [enclosure objectForKey:SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
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,
// then we remove the extension. Hopefully, this will be the version.
NSArray *fileComponents = [[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
NSArray<NSString *> *fileComponents = [(NSString *)[enclosure objectForKey:SURSSAttributeURL] componentsSeparatedByString:@"_"];
if ([fileComponents count] > 1) {
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
}
@@ -111,7 +132,7 @@
NSString *theInfoURL = [dict objectForKey:SURSSElementLink];
if (theInfoURL) {
if (![theInfoURL isKindOfClass:[NSString class]]) {
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
SULog(SULogLevelError, @"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
} else {
self.infoURL = [NSURL URLWithString:theInfoURL];
}
@@ -133,6 +154,15 @@
}
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) {
// Sparkle used to always URL-encode, so for backwards compatibility spaces in URLs must be forgiven.
@@ -140,7 +170,8 @@
self.fileURL = [NSURL URLWithString:fileURLString];
}
if (enclosure) {
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
self.signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:[enclosure objectForKey:SUAppcastAttributeEDSignature]];
self.osString = [enclosure objectForKey:SUAppcastAttributeOsType];
}
self.versionString = newVersion;
@@ -158,12 +189,17 @@
self.displayVersionString = self.versionString;
}
NSString* enclosureRolloutIntervalString = [enclosure objectForKey:SUAppcastAttributePhasedRolloutInterval];
if(enclosureRolloutIntervalString) {
self.phasedRolloutInterval = @(enclosureRolloutIntervalString.integerValue);
}
// Find the appropriate release notes URL.
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
if (releaseNotesString) {
NSURL *url = [NSURL URLWithString:releaseNotesString];
if ([url isFileURL]) {
SULog(@"Release notes with file:// URLs are not supported");
SULog(SULogLevelError, @"Release notes with file:// URLs are not supported");
} else {
self.releaseNotesURL = url;
}
+23
View File
@@ -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
+37
View File
@@ -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
+2 -2
View File
@@ -9,7 +9,7 @@
#ifndef SUAUTOMATICUPDATEALERT_H
#define SUAUTOMATICUPDATEALERT_H
#import "SUWindowController.h"
#import <Cocoa/Cocoa.h>
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
SUInstallNowChoice,
@@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
};
@class SUAppcastItem, SUHost;
@interface SUAutomaticUpdateAlert : SUWindowController
@interface SUAutomaticUpdateAlert : NSWindowController
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
- (IBAction)installNow:sender;
+45 -4
View File
@@ -7,19 +7,32 @@
//
#import "SUAutomaticUpdateAlert.h"
#import "SULocalizations.h"
#import "SUAppcastItem.h"
#import "SUApplicationInfo.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) SUAppcastItem *updateItem;
@property (strong) SUHost *host;
@property (weak) IBOutlet NSButton *skipButton;
@property (weak) IBOutlet NSButton *laterButton;
@property (weak) IBOutlet NSButton *installButton;
@end
@implementation SUAutomaticUpdateAlert
@synthesize host;
@synthesize updateItem;
@synthesize completionBlock;
@synthesize skipButton;
@synthesize laterButton;
@synthesize installButton;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
{
@@ -29,12 +42,13 @@
self.completionBlock = block;
self.host = aHost;
[self setShouldCascadeWindows:NO];
[[self window] center];
}
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
{
@@ -57,9 +71,17 @@
self.completionBlock = nil;
}
- (void)windowDidLoad
{
if ([self.updateItem isCriticalUpdate]) {
self.skipButton.enabled = NO;
}
}
- (NSImage *__nonnull)applicationIcon
{
return [self.host icon];
return [SUApplicationInfo bestIconForHost:self.host];
}
- (NSString *__nonnull)titleText
@@ -86,4 +108,23 @@
}
}
- (NSTouchBar *)makeTouchBar
{
NSTouchBar *touchBar = [(NSTouchBar *)[NSClassFromString(@"NSTouchBar") alloc] init];
touchBar.defaultItemIdentifiers = @[SUAutomaticUpdateAlertTouchBarIndentifier,];
touchBar.principalItemIdentifier = SUAutomaticUpdateAlertTouchBarIndentifier;
touchBar.delegate = self;
return touchBar;
}
- (NSTouchBarItem *)touchBar:(NSTouchBar * __unused)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier API_AVAILABLE(macos(10.12.2))
{
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
+1 -3
View File
@@ -9,11 +9,9 @@
#ifndef SUAUTOMATICUPDATEDRIVER_H
#define SUAUTOMATICUPDATEDRIVER_H
#import <Cocoa/Cocoa.h>
#import "SUBasicUpdateDriver.h"
#import "SUAutomaticUpdateAlert.h"
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver
@end
+40 -25
View File
@@ -7,10 +7,15 @@
//
#import "SUAutomaticUpdateDriver.h"
#import "SUUpdaterPrivate.h"
#import "SUUpdaterDelegate.h"
#import "SULocalizations.h"
#import "SUErrors.h"
#import "SUAutomaticUpdateAlert.h"
#import "SUHost.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.
static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 24 * 7;
@@ -24,7 +29,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
@interface SUAutomaticUpdateDriver ()
@property (assign) BOOL postponingInstallation;
@property (assign) BOOL showErrors;
@property (assign) BOOL willUpdateOnTermination;
@property (assign) BOOL isTerminating;
@property (strong) SUAutomaticUpdateAlert *alert;
@@ -35,7 +39,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
@implementation SUAutomaticUpdateDriver
@synthesize postponingInstallation;
@synthesize showErrors;
@synthesize willUpdateOnTermination;
@synthesize isTerminating;
@synthesize alert;
@@ -44,6 +47,12 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)showUpdateAlert
{
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 automaticUpdateAlertFinishedWithChoice:choice];
}];
@@ -51,7 +60,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
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([self.host isBackgroundApplication]) {
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
[[self.alert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
@@ -62,7 +71,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[[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];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
@@ -73,7 +82,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
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:)])
{
BOOL relaunch = YES;
@@ -83,9 +93,15 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[invocation setArgument:&relaunch atIndex:2];
[invocation setArgument:&showUI atIndex:3];
[invocation setTarget:self];
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationInvocation:invocation];
}
else if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationBlock:)])
{
[updaterDelegate updater:self.updater willInstallUpdateOnQuit:self.updateItem immediateInstallationBlock:^{
[self installWithToolAndRelaunch:YES displayingUserInterface:NO];
}];
}
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([self.updateItem isCriticalUpdate])
@@ -101,6 +117,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
{
if (self.willUpdateOnTermination)
@@ -113,7 +141,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
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:)])
[updaterDelegate updater:self.updater didCancelInstallUpdateOnQuit:self.updateItem];
}
@@ -133,6 +162,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)abortUpdate
{
[self.alert close];
self.isTerminating = NO;
[self stopUpdatingOnTermination];
[self invalidateShowUpdateAlertTimer];
@@ -147,6 +178,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
{
self.alert = nil;
switch (choice)
{
case SUInstallNowChoice:
@@ -174,7 +206,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[self stopUpdatingOnTermination];
}
self.showErrors = YES;
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
}
@@ -203,20 +234,4 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
}
}
- (void)abortUpdateWithError:(NSError *)error
{
if (self.showErrors) {
[super abortUpdateWithError:error];
} else {
// Call delegate separately here because otherwise it won't know we stopped.
// Normally this gets called by the superclass
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
[updaterDelegate updater:self.updater didAbortWithError:error];
}
[self abortUpdate];
}
}
@end
+18 -12
View File
@@ -9,22 +9,23 @@
#ifndef SUBASICUPDATEDRIVER_H
#define SUBASICUPDATEDRIVER_H
#import <Cocoa/Cocoa.h>
#import "SUUpdateDriver.h"
#import "SUUnarchiver.h"
#import "SUAppcast.h"
#import "SPUDownloader.h"
#import "SPUDownloaderDelegate.h"
@class SUAppcastItem, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate>
@class SUAppcast, SUAppcastItem, SUHost, SPUDownloadData;
@interface SUBasicUpdateDriver : SUUpdateDriver <SPUDownloaderDelegate>
@property (strong, readonly) SUAppcastItem *updateItem;
@property (strong, readonly) NSURLDownload *download;
@property (strong, readonly) SUAppcastItem *latestAppcastItem;
@property (assign, readonly) NSComparisonResult latestAppcastItemComparisonResult;
@property (strong, readonly) SPUDownloader *download;
@property (copy, readonly) NSString *downloadPath;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
@@ -32,15 +33,20 @@
- (void)didNotFindUpdate;
- (void)downloadUpdate;
- (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSString *)name;
- (void)downloadDidFinish:(NSURLDownload *)d;
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error;
// SPUDownloaderDelegate
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData *)downloadData;
- (void)downloaderDidFailWithError:(NSError *)error;
- (void)extractUpdate;
- (void)unarchiverDidFinish:(SUUnarchiver *)ua;
- (void)unarchiverDidFail:(SUUnarchiver *)ua;
- (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 displayingUserInterface:(BOOL)showUI;
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
+268 -211
View File
@@ -8,34 +8,49 @@
#import "SUBasicUpdateDriver.h"
#import "SUUnarchiverProtocol.h"
#import "SUHost.h"
#import "SUOperatingSystem.h"
#import "SUDSAVerifier.h"
#import "SUInstaller.h"
#import "SUStandardVersionComparator.h"
#import "SUUnarchiver.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUBinaryDeltaCommon.h"
#import "SUCodeSigningVerifier.h"
#import "SUUpdater_Private.h"
#import "SUUpdaterPrivate.h"
#import "SUUpdaterDelegate.h"
#import "SUFileManager.h"
#import "SUUpdateValidator.h"
#import "SULocalizations.h"
#import "SUErrors.h"
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SPUURLRequest.h"
#import "SPUDownloaderDeprecated.h"
#import "SPUDownloaderSession.h"
@interface SUBasicUpdateDriver ()
@property (strong) SUAppcastItem *updateItem;
@property (strong) NSURLDownload *download;
@property (strong) SUAppcastItem *latestAppcastItem;
@property (assign) NSComparisonResult latestAppcastItemComparisonResult;
@property (strong) SPUDownloader *download;
@property (copy) NSString *downloadPath;
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
@property (copy) NSString *tempDir;
@property (copy) NSString *relaunchPath;
@property (nonatomic) SUUpdateValidator *updateValidator;
@end
@implementation SUBasicUpdateDriver
@synthesize updateItem;
@synthesize latestAppcastItem;
@synthesize latestAppcastItemComparisonResult;
@synthesize download;
@synthesize downloadPath;
@@ -43,20 +58,31 @@
@synthesize tempDir;
@synthesize relaunchPath;
@synthesize updateValidator = _updateValidator;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
if ([aHost isRunningOnReadOnlyVolume])
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again.", nil), [aHost name]] }]];
NSString *hostName = [aHost name];
if ([aHost isRunningTranslocated])
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningTranslocated userInfo:@{ NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"Quit %1$@, move it into your Applications folder, relaunch it from there and try again.", nil), hostName], NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can’t be updated if it’s running from the location it was downloaded to.", nil), hostName], }]];
}
else
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated, because it was opened from a read-only or a temporary location.", nil), hostName], NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.", nil), hostName] }]];
}
return;
}
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setUserAgentString:[self.updater userAgentString]];
[appcast setHttpHeaders:[self.updater httpHeaders]];
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
id<SUUpdaterPrivate> updater = self.updater;
[appcast setUserAgentString:[updater userAgentString]];
[appcast setHttpHeaders:[updater httpHeaders]];
[appcast fetchAppcastFromURL:URL inBackground:self.downloadsAppcastInBackground completionBlock:^(NSError *error) {
if (error) {
[self abortUpdateWithError:error];
} else {
@@ -68,58 +94,75 @@
- (id<SUVersionComparison>)versionComparator
{
id<SUVersionComparison> comparator = nil;
id<SUUpdaterPrivate> updater = self.updater;
// Give the delegate a chance to provide a custom version comparator
if ([[self.updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [[self.updater delegate] versionComparatorForUpdater:self.updater];
if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) {
comparator = [[updater delegate] versionComparatorForUpdater:self.updater];
}
// If we don't get a comparator from the delegate, use the default comparator
if (!comparator) {
comparator = [SUStandardVersionComparator defaultComparator];
comparator = [[SUStandardVersionComparator alloc] init];
}
return comparator;
}
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
// This method is only used for testing
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator {
SUBasicUpdateDriver* basicUpdateDriver = [[SUBasicUpdateDriver alloc] initWithUpdater:(id<SUUpdaterPrivate>)[SUUpdater sharedUpdater]];
return [basicUpdateDriver bestItemFromAppcastItems:appcastItems getDeltaItem:deltaItem withHostVersion:hostVersion comparator:comparator];
}
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
{
SUAppcastItem *item = nil;
for(SUAppcastItem *candidate in appcastItems) {
if ([[self class] hostSupportsItem:candidate]) {
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
if ([self hostSupportsItem:candidate]) {
if (
!item || (
[item.date compare:candidate.date] == NSOrderedAscending &&
[comparator compareVersion:item.versionString toVersion:candidate.versionString] != NSOrderedDescending
)
) {
item = candidate;
}
}
}
if (item && deltaItem) {
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
if (deltaUpdateItem && [[self class] hostSupportsItem:deltaUpdateItem]) {
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
*deltaItem = deltaUpdateItem;
}
}
return item;
}
+ (BOOL)hostSupportsItem:(SUAppcastItem *)ui
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
{
BOOL osOK = [ui isMacOsUpdate];
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) { return YES; }
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) {
return osOK;
}
BOOL minimumVersionOK = TRUE;
BOOL maximumVersionOK = TRUE;
id<SUVersionComparison> versionComparator = [[SUStandardVersionComparator alloc] init];
// Check minimum and maximum System Version
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
minimumVersionOK = [versionComparator compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
}
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
maximumVersionOK = [versionComparator compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
}
return minimumVersionOK && maximumVersionOK;
return minimumVersionOK && maximumVersionOK && osOK;
}
- (BOOL)isItemNewer:(SUAppcastItem *)ui
@@ -136,46 +179,55 @@
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
return ui && [[self class] hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
return ui && [self hostSupportsItem:ui] && [self isItemNewer:ui] && ![self itemContainsSkippedVersion:ui];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) {
[[self.updater delegate] updater:self.updater didFinishLoadingAppcast:ac];
id<SUUpdaterPrivate> updater = self.updater;
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];
SUAppcastItem *item = nil;
// 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 = [[updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
}
if (item != nil) // Does the delegate want to handle it?
{
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater];
if ([item isDeltaUpdate]) {
self.nonDeltaUpdateItem = [[self.updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
self.nonDeltaUpdateItem = [[updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater];
}
}
else // If not, we'll take care of it ourselves.
}
else // If not, we'll take care of it ourselves.
{
// Find the best supported update
SUAppcastItem *deltaUpdateItem = nil;
item = [[self class] bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
item = [self bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
if (item && deltaUpdateItem) {
self.nonDeltaUpdateItem = item;
item = deltaUpdateItem;
}
}
self.latestAppcastItem = item;
self.latestAppcastItemComparisonResult = [[self versionComparator] compareVersion:[self.host version] toVersion:[item versionString]];
if ([self itemContainsValidUpdate:item]) {
self.updateItem = item;
[self didFindValidUpdate];
[self performSelectorOnMainThread:@selector(didFindValidUpdate) withObject:nil waitUntilDone:NO];
} else {
self.updateItem = nil;
[self didNotFindUpdate];
[self performSelectorOnMainThread:@selector(didNotFindUpdate) withObject:nil waitUntilDone:NO];
}
}
@@ -183,8 +235,10 @@
{
assert(self.updateItem);
if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
id<SUUpdaterPrivate> updater = self.updater;
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) {
[[updater delegate] updater:self.updater didFindValidUpdate:self.updateItem];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
@@ -195,8 +249,10 @@
- (void)didNotFindUpdate
{
if ([[self.updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
id<SUUpdaterPrivate> updater = self.updater;
if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) {
[[updater delegate] updaterDidNotFindUpdate:self.updater];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
@@ -216,15 +272,15 @@
cachePath = [cachePaths objectAtIndex:0];
}
if (!cachePath) {
SULog(@"Failed to find user's cache directory! Using system default");
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;
@@ -232,164 +288,91 @@
- (void)downloadUpdate
{
NSString *bundleIdentifier = self.host.bundle.bundleIdentifier;
assert(bundleIdentifier != nil);
// 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]];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[[self.updater delegate] updater:self.updater
if (self.downloadsUpdatesInBackground) {
request.networkServiceType = NSURLNetworkServiceTypeBackground;
}
[request setValue:[updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([[updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[[updater delegate] updater:self.updater
willDownloadUpdate:self.updateItem
withRequest:request];
}
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
if (SUAVAILABLE(10, 9)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
self.download = [[SPUDownloaderSession alloc] initWithDelegate:self];
#pragma clang diagnostic pop
}
else {
self.download = [[SPUDownloaderDeprecated alloc] initWithDelegate:self];
}
SPUURLRequest *urlRequest = [SPUURLRequest URLRequestWithRequest:request];
NSString *desiredFilename = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
[self.download startPersistentDownloadWithRequest:urlRequest bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename];
}
- (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory
{
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
NSString *appCachePath = [self appCachePath];
self.tempDir = [appCachePath stringByAppendingPathComponent:downloadFileName];
int cnt = 1;
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
{
self.tempDir = [appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
}
// Create the temporary directory if necessary.
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:self.tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
if (!success)
{
// Okay, something's really broken with this user's file structure.
[self.download cancel];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUTemporaryDirectoryError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Can't make a temporary directory for the update download at %@.", self.tempDir] }]];
}
self.downloadPath = [self.tempDir stringByAppendingPathComponent:name];
[self.download setDestination:self.downloadPath allowOverwrite:YES];
self.tempDir = temporaryDirectory;
self.downloadPath = [temporaryDirectory stringByAppendingPathComponent:destinationName];
}
/**
* If the update is a package, then it must be signed using DSA. No other verification is done.
*
* If the update is a bundle, then it must meet any one of:
*
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
*
* * old and new Code Signing identity are the same and valid
*
*/
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
{
BOOL isPackage = NO;
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
if (installSourcePath == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
return NO;
}
NSString *publicDSAKey = host.publicDSAKey;
// Modern packages are not distributed as bundles and are code signed differently than regular applications
if (isPackage) {
if (nil == publicDSAKey) {
SULog(@"The existing app bundle does not have a DSA key, so it can't verify installer packages.");
}
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
if (!packageValidated) {
SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
}
return packageValidated;
}
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
if (newBundle == nil) {
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
return NO;
}
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
NSString *newPublicDSAKey = newHost.publicDSAKey;
// Downgrade in DSA security should not be possible
if (publicDSAKey != nil && newPublicDSAKey == nil) {
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
return NO;
}
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
// However if the new and old DSA keys are the same, then this is a security measure.
if (newPublicDSAKey != nil) {
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
return NO;
}
}
BOOL updateIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:newHost.bundle.bundleURL];
if (dsaKeysMatch) {
NSError *error = nil;
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
return NO;
}
} else {
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
if (!hostIsCodeSigned || !updateIsCodeSigned) {
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
return NO;
}
NSError *error = nil;
if (![SUCodeSigningVerifier codeSignatureAtBundleURL:host.bundle.bundleURL matchesSignatureAtBundleURL:newHost.bundle.bundleURL error:&error]) {
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
return NO;
}
}
return YES;
// don't need to do anything here as there's no GUI with this driver (there can be with child classes)
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
- (void)downloaderDidReceiveDataOfLength:(uint64_t)__unused length
{
// don't need do anything here as there's no GUI with this driver (there can be with child classes)
}
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)__unused downloadData
{
// finished. downloadData should be nil as this was a permanent download
assert(self.updateItem);
id<SUUpdaterPrivate> updater = self.updater;
if ([[updater delegate] respondsToSelector:@selector(updater:didDownloadUpdate:)]) {
[[updater delegate] updater:self.updater didDownloadUpdate:self.updateItem];
}
[self extractUpdate];
}
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
- (void)downloaderDidFailWithError:(NSError *)error
{
NSURL *failingUrl = [error.userInfo objectForKey:NSURLErrorFailingURLErrorKey];
if (!failingUrl) {
failingUrl = [self.updateItem fileURL];
}
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[[self.updater delegate] updater:self.updater
failedToDownloadUpdate:self.updateItem
error:error];
id<SUUpdaterPrivate> updater = self.updater;
if ([[updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[[updater delegate] updater:self.updater
failedToDownloadUpdate:self.updateItem
error:error];
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
}];
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
}];
if (failingUrl) {
[userInfo setObject:failingUrl forKey:NSURLErrorFailingURLErrorKey];
}
@@ -397,23 +380,49 @@
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo]];
}
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
{
// We don't want the download system to extract our gzips.
// Note that we use a substring matching here instead of direct comparison because the docs say "application/gzip" but the system *uses* "application/x-gzip". This is a documentation bug.
return ([encodingType rangeOfString:@"gzip"].location == NSNotFound);
}
- (void)extractUpdate
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:self.updater.decryptionPassword];
id<SUUpdaterPrivate> updater = self.updater;
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
BOOL success = NO;
if (!unarchiver) {
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
[self unarchiverDidFail:nil];
return;
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
} else {
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
if (needsPrevalidation) {
success = [self.updateValidator validateDownloadPath];
} else {
success = YES;
}
}
if (!success) {
NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}];
[self unarchiverDidFailWithError:reason];
} else {
if ([[updater delegate] respondsToSelector:@selector(updater:willExtractUpdate:)]) {
[[updater delegate] updater:self.updater willExtractUpdate:self.updateItem];
}
[unarchiver unarchiveWithCompletionBlock:^(NSError *err){
if (err) {
[self unarchiverDidFailWithError:err];
return;
}
if ([[updater delegate] respondsToSelector:@selector(updater:didExtractUpdate:)]) {
[[updater delegate] updater:self.updater didExtractUpdate:self.updateItem];
}
[self performSelectorOnMainThread:@selector(unarchiverDidFinish:) withObject:nil waitUntilDone:NO];
} progressBlock:^(double progress) {
[self unarchiver:nil extractedProgress:progress];
}];
}
unarchiver.delegate = self;
[unarchiver start];
}
- (void)failedToApplyDeltaUpdate
@@ -425,21 +434,30 @@
[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);
[self installWithToolAndRelaunch:YES];
}
- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua
- (void)unarchiverDidFailWithError:(NSError *)err
{
// No longer needed
self.updateValidator = nil;
if ([self.updateItem isDeltaUpdate]) {
[self failedToApplyDeltaUpdate];
return;
}
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
[self abortUpdateWithError:err];
}
- (void)installWithToolAndRelaunch:(BOOL)relaunch
@@ -473,58 +491,90 @@
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
{
assert(self.updateItem);
assert(self.updateValidator);
if (![self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature])
{
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
if (!validationCheckSuccess) {
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
};
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil),
};
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]];
return;
}
if (![self.updater mayUpdateAndRestart])
if (![self mayUpdateAndRestart])
{
[self abortUpdate];
return;
}
// Give the host app an opportunity to postpone the install and relaunch.
id<SUUpdaterPrivate> updater = self.updater;
static BOOL postponedOnce = NO;
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setTarget:self];
postponedOnce = YES;
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
return;
id<SUUpdaterDelegate> updaterDelegate = [updater delegate];
if (!postponedOnce) {
if ([updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setTarget:self];
postponedOnce = YES;
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
return;
}
} else if ([updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:)]) {
postponedOnce = YES;
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem]) {
return;
}
}
}
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
NSBundle *sparkleBundle = self.updater.sparkleBundle;
NSBundle *sparkleBundle = updater.sparkleBundle;
if (!sparkleBundle) {
SULog(SULogLevelError, @"Sparkle bundle is gone?");
return;
}
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
NSString *const relaunchToolSourceName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolSourceName ofType:@"app"];
NSString *relaunchCopyTargetPath = nil;
NSError *error = nil;
BOOL copiedRelaunchPath = NO;
if (!relaunchToolSourceName || ![relaunchToolSourceName length]) {
SULog(SULogLevelError, @"SPARKLE_RELAUNCH_TOOL_NAME not configued");
}
if (!relaunchToolSourcePath) {
SULog(SULogLevelError, @"Sparkle.framework is damaged. %@ is missing", relaunchToolSourceName);
}
if (relaunchToolSourcePath) {
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
NSString *hostBundleBaseName = [[self.host.bundlePath lastPathComponent] stringByDeletingPathExtension];
if (!hostBundleBaseName) {
SULog(SULogLevelError, @"Unable to get bundlePath");
hostBundleBaseName = @"Sparkle";
}
NSString *relaunchCopyBaseName = [NSString stringWithFormat:@"%@ (Autoupdate).app", hostBundleBaseName];
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:relaunchCopyBaseName];
SUFileManager *fileManager = [SUFileManager defaultManager];
@@ -540,7 +590,7 @@
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
NSError *quarantineError = nil;
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
SULog(@"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
SULog(SULogLevelDefault, @"Warning: could not remove quarantine metadata from %@: %@. This may not be a problem, the update process will continue.", relaunchCopyTargetPath, quarantineError);
}
}
}
@@ -571,9 +621,15 @@
NSString *pathToRelaunch = [self.host bundlePath];
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
NSString *delegateRelaunchPath = [updaterDelegate pathToRelaunchForUpdater:self.updater];
if (delegateRelaunchPath != nil) {
pathToRelaunch = delegateRelaunchPath;
}
}
//Set relaunching flag.
[self.host setBool:YES forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
@@ -629,7 +685,7 @@
NSError *errorToDisplay = error;
int finiteRecursion=5;
do {
SULog(@"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, [errorToDisplay.userInfo objectForKey:NSURLErrorFailingURLErrorKey]);
SULog(SULogLevelError, @"Error: %@ %@ (URL %@)", errorToDisplay.localizedDescription, errorToDisplay.localizedFailureReason, [errorToDisplay.userInfo objectForKey:NSURLErrorFailingURLErrorKey]);
errorToDisplay = [errorToDisplay.userInfo objectForKey:NSUnderlyingErrorKey];
} while(--finiteRecursion && errorToDisplay);
}
@@ -638,7 +694,8 @@
}
// 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:)]) {
[updaterDelegate updater:self.updater didAbortWithError:error];
}
+3 -1
View File
@@ -9,7 +9,9 @@
#ifndef SUBINARYDELTAAPPLY_H
#define SUBINARYDELTAAPPLY_H
#import <Foundation/Foundation.h>
@class NSString;
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error);
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double), NSError * __autoreleasing *error);
#endif
+46 -31
View File
@@ -15,17 +15,19 @@
#include <stdlib.h>
#include <xar/xar.h>
#include "AppKitPrevention.h"
static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
{
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
const char *argv[] = { "/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation] };
BOOL success = (bspatch(4, argv) == 0);
unlink([patchFile fileSystemRepresentation]);
return success;
}
BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error)
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);
if (!x) {
@@ -34,69 +36,71 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
int minorDiffVersion = 0;
NSString *expectedBeforeHashv1 = nil;
NSString *expectedAfterHashv1 = nil;
NSString *expectedNewBeforeHash = nil;
NSString *expectedNewAfterHash = nil;
progressCallback(0/6.0);
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
const char *value = 0;
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
if (value)
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
if (value)
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
minorDiffVersion = [@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
if (value)
expectedNewBeforeHash = @(value);
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
if (value)
expectedNewAfterHash = @(value);
// only available in version 1.0
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_OLD_KEY, &value);
if (value)
expectedBeforeHashv1 = @(value);
// only available in version 1.0
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_OLD_KEY, &value);
if (value)
expectedAfterHashv1 = @(value);
}
}
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.", majorDiffVersion] }];
}
return NO;
}
if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion] }];
}
return NO;
}
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
@@ -111,7 +115,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
fprintf(stderr, "Verifying source...");
}
progressCallback(1/6.0);
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
if (!beforeHash) {
if (verbose) {
@@ -136,7 +142,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
if (verbose) {
fprintf(stderr, "\nCopying files...");
}
progressCallback(2/6.0);
if (!removeTree(destination)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -146,6 +154,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
progressCallback(3/6.0);
if (!copyTree(source, destination)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -155,7 +166,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
progressCallback(4/6.0);
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
if (verbose) {
@@ -172,10 +185,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
BOOL removedFile = NO;
const char *value;
if (!xar_prop_get(file, DELETE_KEY, &value) ||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
if (!removeTree(destinationFilePath)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -191,7 +203,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
continue;
}
removedFile = YES;
}
@@ -205,13 +217,12 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
if (verbose) {
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
}
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) ||
(!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) || (!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) {
if (verbose) {
fprintf(stderr, "\n");
@@ -221,7 +232,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
if (verbose) {
if (fileExisted) {
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
@@ -232,7 +243,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
} else if (verbose && removedFile) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
}
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
if (!modifyPermissions(destinationFilePath, mode)) {
@@ -244,7 +255,7 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
return NO;
}
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
}
@@ -252,6 +263,8 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
xar_close(x);
progressCallback(5/6.0);
if (verbose) {
fprintf(stderr, "\nVerifying destination...");
}
@@ -277,6 +290,8 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
return NO;
}
progressCallback(6/6.0);
if (verbose) {
fprintf(stderr, "\nDone!\n");
}
+1 -10
View File
@@ -57,16 +57,7 @@ typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
SUBeigeMajorVersion = 2
};
// Only keep track of the latest minor version for each major version
typedef NS_ENUM(uint16_t, SUBinaryDeltaMinorVersion)
{
SUAzureMinorVersion = 1,
SUBeigeMinorVersion = 1,
};
#define FIRST_DELTA_DIFF_MAJOR_VERSION SUAzureMajorVersion
#define FIRST_DELTA_DIFF_MINOR_VERSION ((SUBinaryDeltaMinorVersion)0)
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
extern int compareFiles(const FTSENT **a, const FTSENT **b);
@@ -80,5 +71,5 @@ extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
NSString *temporaryFilename(NSString *base);
NSString *temporaryDirectory(NSString *base);
NSString *stringWithFileSystemRepresentation(const char*);
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
#endif
+30 -19
View File
@@ -18,6 +18,8 @@
#include <sys/stat.h>
#include <xar/xar.h>
#include "AppKitPrevention.h"
int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll((*a)->fts_name, (*b)->fts_name);
@@ -32,19 +34,20 @@ NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
return path;
}
NSString *stringWithFileSystemRepresentation(const char *input) {
NSString *stringWithFileSystemRepresentation(const char *input)
{
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
}
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
int latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
{
switch (majorVersion) {
case SUAzureMajorVersion:
return SUAzureMinorVersion;
return 1;
case SUBeigeMajorVersion:
return SUBeigeMinorVersion;
return 2;
}
return (SUBinaryDeltaMinorVersion)0;
return 0;
}
NSString *temporaryFilename(NSString *base)
@@ -73,18 +76,18 @@ NSString *temporaryDirectory(NSString *base)
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
NSMutableData *data = [NSMutableData data];
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
char *buffer = data.mutableBytes;
char *templateResult = mkdtemp(buffer);
if (templateResult == NULL) {
perror("mkdtemp");
return nil;
}
return stringWithFileSystemRepresentation(templateResult);
}
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)
static void _hashOfBuffer(unsigned char *hash, const char *buffer, ssize_t bufferLength)
{
assert(bufferLength >= 0 && bufferLength <= UINT32_MAX);
CC_SHA1_CTX hashContext;
@@ -93,7 +96,7 @@ static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t buffe
CC_SHA1_Final(hash, &hashContext);
}
static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent)
{
if (ent->fts_info == FTS_SL) {
char linkDestination[MAXPATHLEN + 1];
@@ -116,12 +119,12 @@ static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
_hashOfBuffer(hash, NULL, 0);
} else {
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);
perror("mmap");
return NO;
}
_hashOfBuffer(hash, buffer, fileSize);
munmap(buffer, (size_t)fileSize);
}
@@ -145,12 +148,12 @@ NSData *hashOfFileContents(FTSENT *ent)
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
{
char pathBuffer[PATH_MAX] = {0};
char pathBuffer[PATH_MAX] = { 0 };
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);
if (!fts) {
perror("fts_open");
@@ -160,16 +163,19 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
// Ensure the path uses filesystem-specific Unicode normalization #1017
NSString *normalizedPath = stringWithFileSystemRepresentation(pathBuffer);
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
continue;
if (ent->fts_info == FTS_D && !MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
continue;
}
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
if (relativePath.length == 0)
continue;
@@ -181,12 +187,17 @@ NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
const char *relativePathBytes = [relativePath fileSystemRepresentation];
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
uint16_t mode = ent->fts_statp->st_mode;
// permission of symlinks is irrelevant and can't be changed.
// hardcoding a value helps avoid differences between filesystems.
if (ent->fts_info == FTS_SL) {
mode = 0755;
}
uint16_t type = ent->fts_info;
uint16_t permissions = mode & PERMISSION_FLAGS;
CC_SHA1_Update(&hashContext, &type, sizeof(type));
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
}
@@ -236,7 +247,7 @@ BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
return NO;
}
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
int (*changeModeFunc)(const char *, mode_t) = [[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
int (*changeModeFunc)(const char *, mode_t) = [(NSString *)[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
return NO;
}
+97 -83
View File
@@ -21,6 +21,8 @@
#include <sys/xattr.h>
#include <xar/xar.h>
#include "AppKitPrevention.h"
extern int bsdiff(int argc, const char **argv);
@interface CreateBinaryDeltaOperation : NSOperation
@@ -56,7 +58,7 @@ extern int bsdiff(int argc, const char **argv);
- (void)main
{
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
const char *argv[] = { "/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation] };
int result = bsdiff(4, argv);
if (!result)
self.resultPath = temporaryFile;
@@ -75,14 +77,26 @@ static NSDictionary *infoForFile(FTSENT *ent)
if (!hash) {
return nil;
}
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
assert(ent->fts_statp != NULL);
mode_t permissions = ent->fts_statp->st_mode & PERMISSION_FLAGS;
return @{INFO_HASH_KEY: hash, INFO_TYPE_KEY: @(ent->fts_info), INFO_PERMISSIONS_KEY : @(permissions), INFO_SIZE_KEY: @(size)};
return @{ INFO_HASH_KEY: hash,
INFO_TYPE_KEY: @(ent->fts_info),
INFO_PERMISSIONS_KEY: @(permissions),
INFO_SIZE_KEY: @(size) };
}
static bool isSymLink(const FTSENT *ent)
{
if (ent->fts_info == FTS_SL)
{
return (true);
}
return false;
}
static bool aclExists(const FTSENT *ent)
@@ -91,7 +105,7 @@ static bool aclExists(const FTSENT *ent)
if (ent->fts_info == FTS_SL) {
return NO;
}
acl_t acl = acl_get_link_np(ent->fts_path, ACL_TYPE_EXTENDED);
if (acl != NULL) {
acl_entry_t entry;
@@ -109,28 +123,26 @@ static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
if (listSize == -1) {
return false;
}
char *buffer = malloc((size_t)listSize);
assert(buffer != NULL);
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
assert(sizeBack == listSize);
size_t startCharacterIndex = 0;
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
if (buffer[characterIndex] == '\0') {
char *attribute = &buffer[startCharacterIndex];
size_t length = characterIndex - startCharacterIndex;
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 || strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 || strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
free(buffer);
return true;
}
startCharacterIndex = characterIndex + 1;
}
}
free(buffer);
return false;
}
@@ -138,7 +150,7 @@ static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
static NSString *absolutePath(NSString *path)
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
return [[url absoluteURL] path];
return [[url absoluteURL] path];
}
static NSString *temporaryPatchFile(NSString *patchFile)
@@ -151,7 +163,7 @@ static NSString *temporaryPatchFile(NSString *patchFile)
#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];
if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) {
@@ -165,7 +177,7 @@ static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return YES;
}
if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
// this is possible if just the permissions have changed
return YES;
@@ -174,7 +186,7 @@ static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary
return NO;
}
static BOOL shouldDeleteThenExtract(NSDictionary* originalInfo, NSDictionary *newInfo)
static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
@@ -192,15 +204,15 @@ static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newIn
if (!originalInfo) {
return NO;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return NO;
}
if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
return NO;
}
return YES;
}
@@ -209,30 +221,30 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne
if (!originalInfo) {
return NO;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return NO;
}
if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
return NO;
}
return YES;
}
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error)
BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError *__autoreleasing *error)
{
assert(source);
assert(destination);
assert(patchFile);
assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION);
SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion);
int minorVersion = latestMinorVersionForMajorVersion(majorVersion);
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
char pathBuffer[PATH_MAX] = {0};
char pathBuffer[PATH_MAX] = { 0 };
if (![source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from source %@", source] }];
@@ -240,7 +252,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
return NO;
}
char *sourcePaths[] = {pathBuffer, 0};
char *sourcePaths[] = { pathBuffer, 0 };
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
if (error != NULL) {
@@ -251,9 +263,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
if (verbose) {
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
fprintf(stderr, "Processing source, %s...", [source fileSystemRepresentation]);
}
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
@@ -276,7 +288,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
return NO;
}
originalTreeState[key] = info;
if (aclExists(ent)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -286,7 +298,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
if (codeSignatureExtendedAttributeExists(ent)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -298,7 +310,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
}
fts_close(fts);
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
if (!beforeHash) {
@@ -312,13 +324,12 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
for (NSString *key in originalTreeState)
{
for (NSString *key in originalTreeState) {
newTreeState[key] = [NSNull null];
}
if (verbose) {
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
fprintf(stderr, "\nProcessing destination, %s...", [destination fileSystemRepresentation]);
}
pathBuffer[0] = 0;
@@ -331,7 +342,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
sourcePaths[0] = pathBuffer;
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
@@ -341,7 +352,6 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
return NO;
}
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
@@ -362,24 +372,21 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
// We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs,
// or in the case of permissions if the patch version is 1
// We should also not allow files with code signed extended attributes since Apple doesn't recommend inserting these
// inside an application, and since we don't preserve extended attribitutes anyway
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
if (!IS_VALID_PERMISSIONS(permissions)) {
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
permissions = 0755;
if (verbose) {
fprintf(stderr, "\n");
fprintf(stderr, "\nwarning: file permissions %o of '%s' won't be preserved in the delta update (only permissions with modes 0755 and 0644 are supported).\n", permissions & PERMISSION_FLAGS, ent->fts_path);
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Invalid file permissions after-tree on file %@ (only permissions with modes 0755 and 0644 are supported)", @(ent->fts_path)] }];
}
return NO;
}
if (aclExists(ent)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -389,7 +396,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
if (codeSignatureExtendedAttributeExists(ent)) {
if (verbose) {
fprintf(stderr, "\n");
@@ -399,14 +406,14 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
NSDictionary *oldInfo = originalTreeState[key];
if ([info isEqual:oldInfo]) {
[newTreeState removeObjectForKey:key];
} else {
newTreeState[key] = info;
if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
NSArray *parentPathComponents = key.pathComponents;
@@ -432,12 +439,15 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
if (verbose) {
fprintf(stderr, "\nGenerating delta...");
}
NSString *temporaryFile = temporaryPatchFile(patchFile);
if (verbose) {
fprintf(stderr, "\nWriting to temporary file %s...", [temporaryFile fileSystemRepresentation]);
}
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
if (!x) {
if (verbose) {
@@ -448,20 +458,18 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
xar_subdoc_prop_set(attributes, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", majorVersion] UTF8String]);
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", minorVersion] UTF8String]);
// Version 1 patches don't have a major or minor version field, so we need to differentiate between the hash keys
const char *beforeHashKey =
MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? BEFORE_TREE_SHA1_KEY : BEFORE_TREE_SHA1_OLD_KEY;
const char *afterHashKey =
MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? AFTER_TREE_SHA1_KEY : AFTER_TREE_SHA1_OLD_KEY;
const char *beforeHashKey = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? BEFORE_TREE_SHA1_KEY : BEFORE_TREE_SHA1_OLD_KEY;
const char *afterHashKey = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? AFTER_TREE_SHA1_KEY : AFTER_TREE_SHA1_OLD_KEY;
xar_subdoc_prop_set(attributes, beforeHashKey, [beforeHash UTF8String]);
xar_subdoc_prop_set(attributes, afterHashKey, [afterHash UTF8String]);
@@ -471,21 +479,21 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
// Sort the keys by preferring the ones from the original tree to appear first
// We want to enforce deleting before extracting in the case paths differ only by case
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingComparator:^NSComparisonResult(NSString *key1, NSString *key2) {
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
if (insensitiveCompareResult != NSOrderedSame) {
return insensitiveCompareResult;
}
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
if (insensitiveCompareResult != NSOrderedSame) {
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];
if ([value isEqual:[NSNull null]]) {
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, DELETE_KEY, "true");
if (verbose) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
}
@@ -500,7 +508,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
}
@@ -509,7 +517,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
NSString *path = [destination stringByAppendingPathComponent:key];
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
assert(newFile);
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
xar_prop_set(newFile, DELETE_KEY, "true");
@@ -517,11 +525,11 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
}
}
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
xar_prop_set(newFile, EXTRACT_KEY, "true");
}
if (verbose) {
if (originalInfo) {
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
@@ -554,19 +562,19 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
}
return NO;
}
if (verbose) {
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
}
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
assert(newFile);
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
unlink([resultPath fileSystemRepresentation]);
if (operation.permissions) {
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
}
@@ -575,13 +583,19 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
xar_close(x);
unlink([patchFile fileSystemRepresentation]);
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
unlink([temporaryFile fileSystemRepresentation]);
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
[filemgr removeItemAtPath: patchFile error: NULL];
if ([filemgr moveItemAtPath: temporaryFile toPath: patchFile error: NULL] != YES)
{
if (verbose) {
fprintf(stderr, "Failed to move temporary file, %s, to %s!\n", [temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
}
return NO;
}
if (verbose) {
fprintf(stderr, "\nDone!\n");
}
return YES;
}
+54 -48
View File
@@ -20,6 +20,8 @@
#define VERSION_COMMAND @"version"
#define VERSION_ALTERNATE_COMMAND @"--version"
#include "AppKitPrevention.h"
static void printUsage(NSString *programName)
{
fprintf(stderr, "Usage:\n");
@@ -28,14 +30,14 @@ static void printUsage(NSString *programName)
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
}
static BOOL runCreateCommand(NSString *programName, NSArray *args)
static BOOL runCreateCommand(NSString *programName, NSArray<NSString *> *args)
{
if (args.count < 3 || args.count > 5) {
printUsage(programName);
return NO;
}
NSUInteger numberOflagsFound = 0;
NSUInteger numberOfFlagsFound = 0;
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
NSUInteger versionIndex = NSNotFound;
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
@@ -44,23 +46,23 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
break;
}
}
if (verboseIndex != NSNotFound) {
++numberOflagsFound;
++numberOfFlagsFound;
}
if (versionIndex != NSNotFound) {
++numberOflagsFound;
++numberOfFlagsFound;
}
if (args.count - numberOflagsFound < 3) {
if (args.count - numberOfFlagsFound < 3) {
printUsage(programName);
return NO;
}
BOOL verbose = (verboseIndex != NSNotFound);
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
NSArray *versionComponents = nil;
NSArray<NSString *> *versionComponents = nil;
if (versionField) {
versionComponents = [versionField componentsSeparatedByString:@"="];
if (versionComponents.count != 2) {
@@ -68,17 +70,17 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
return NO;
}
}
SUBinaryDeltaMajorVersion patchVersion =
!versionComponents ?
LATEST_DELTA_DIFF_MAJOR_VERSION :
(SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided
if (patchVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "Version provided (%u) is not valid\n", patchVersion);
return NO;
}
if (patchVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", patchVersion);
return NO;
@@ -90,89 +92,93 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args)
[fileArgs addObject:argument];
}
}
if (fileArgs.count != 3) {
printUsage(programName);
return NO;
}
NSString *sourcePath = fileArgs[0];
NSString *destPath = fileArgs[1];
NSString *patchPath = fileArgs[2];
BOOL isDirectory;
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
if (![[NSFileManager defaultManager] fileExistsAtPath:sourcePath isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: before-tree must be a directory\n");
return NO;
}
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[1] isDirectory:&isDirectory] || !isDirectory) {
if (![[NSFileManager defaultManager] fileExistsAtPath:destPath isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: after-tree must be a directory\n");
return NO;
}
NSError *createDiffError = nil;
if (!createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose, &createDiffError)) {
if (!createBinaryDelta(sourcePath, destPath, patchPath, patchVersion, verbose, &createDiffError)) {
fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]);
return NO;
}
return YES;
}
static BOOL runApplyCommand(NSString *programName, NSArray *args)
static BOOL runApplyCommand(NSString *programName, NSArray<NSString *> *args)
{
if (args.count < 3 || args.count > 4) {
printUsage(programName);
return NO;
}
BOOL verbose = [args containsObject:VERBOSE_FLAG];
if (args.count == 4 && !verbose) {
printUsage(programName);
return NO;
}
NSMutableArray *fileArgs = [NSMutableArray array];
NSMutableArray<NSString *> *fileArgs = [NSMutableArray array];
for (NSString *argument in args) {
if (![argument isEqualToString:VERBOSE_FLAG]) {
[fileArgs addObject:argument];
}
}
if (fileArgs.count != 3) {
printUsage(programName);
return NO;
}
BOOL isDirectory;
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: before-tree must be a directory\n");
return NO;
}
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory);
return NO;
}
NSError *applyDiffError = nil;
if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, &applyDiffError)) {
if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, ^(__unused double x){}, &applyDiffError)) {
fprintf(stderr, "%s\n", [applyDiffError.localizedDescription UTF8String]);
return NO;
}
return YES;
}
static BOOL runVersionCommand(NSString *programName, NSArray *args)
static BOOL runVersionCommand(NSString *programName, NSArray<NSString *> *args)
{
if (args.count > 1) {
printUsage(programName);
return NO;
}
if (args.count == 0) {
fprintf(stdout, "%u.%u\n", LATEST_DELTA_DIFF_MAJOR_VERSION, latestMinorVersionForMajorVersion(LATEST_DELTA_DIFF_MAJOR_VERSION));
} else {
@@ -182,47 +188,47 @@ static BOOL runVersionCommand(NSString *programName, NSArray *args)
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
return NO;
}
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
int minorDiffVersion = 0;
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
const char *value = 0;
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
if (value)
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
if (value)
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
minorDiffVersion = [@(value) intValue];
}
}
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
}
return YES;
}
int main(int __unused argc, char __unused *argv[])
{
@autoreleasepool {
NSArray *args = [[NSProcessInfo processInfo] arguments];
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
NSString *programName = [args[0] lastPathComponent];
if (args.count < 2) {
printUsage(programName);
return 1;
}
NSString *command = args[1];
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
NSArray<NSString *> *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
BOOL result;
if ([command isEqualToString:CREATE_COMMAND]) {
result = runCreateCommand(programName, commandArguments);
@@ -234,7 +240,7 @@ int main(int __unused argc, char __unused *argv[])
result = NO;
printUsage(programName);
}
return result ? 0 : 1;
}
}
+9 -3
View File
@@ -9,11 +9,17 @@
#ifndef SUBINARYDELTAUNARCHIVER_H
#define SUBINARYDELTAUNARCHIVER_H
#import <Cocoa/Cocoa.h>
#import "SUUnarchiver.h"
#import <Foundation/Foundation.h>
#import "SUUnarchiverProtocol.h"
@interface SUBinaryDeltaUnarchiver : SUUnarchiver
NS_ASSUME_NONNULL_BEGIN
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
@end
NS_ASSUME_NONNULL_END
#endif
+52 -29
View File
@@ -6,21 +6,38 @@
// Copyright 2009 Mark Rowe. All rights reserved.
//
#import "SUBinaryDeltaCommon.h"
#import "SUBinaryDeltaUnarchiver.h"
#import "SUUnarchiverNotifier.h"
#import "SUBinaryDeltaCommon.h"
#import "SUBinaryDeltaApply.h"
#import "SUUnarchiver_Private.h"
#import "SUFileManager.h"
#import "SUHost.h"
#import "SULog.h"
#import "SUFileManager.h"
#include "AppKitPrevention.h"
@interface SUBinaryDeltaUnarchiver ()
@property (nonatomic, copy, readonly) NSString *archivePath;
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
@end
@implementation SUBinaryDeltaUnarchiver
@synthesize archivePath = _archivePath;
@synthesize updateHostBundlePath = _updateHostBundlePath;
+ (BOOL)canUnarchivePath:(NSString *)path
{
return [[path pathExtension] isEqualToString:@"delta"];
}
+ (BOOL)mustValidateBeforeExtraction
{
return YES;
}
// According to https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/MDImporters/Concepts/Troubleshooting.html
// We should make sure mdimporter bundles have an up to date time in the event they were delta updated.
// We used to invoke mdimport on the bundle but this is not a very good approach.
@@ -50,46 +67,52 @@
for (NSURL *file in filesToUpdate) {
NSError *error = nil;
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:file error:&error]) {
SULog(@"Error: During delta unarchiving, failed to touch %@", error);
SULog(SULogLevelError, @"Error: During delta unarchiving, failed to touch %@", error);
}
}
}
}
- (void)applyBinaryDelta
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath
{
@autoreleasepool {
NSString *sourcePath = self.updateHostBundlePath;
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
NSError *applyDiffError = nil;
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError);
if (success) {
[[self class] updateSpotlightImportersAtBundlePath:targetPath];
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
});
}
else {
SULog(@"Applying delta patch failed with error: %@", applyDiffError);
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfFailure];
});
}
self = [super init];
if (self != nil) {
_archivePath = [archivePath copy];
_updateHostBundlePath = [updateHostBundlePath copy];
}
return self;
}
- (void)start
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self applyBinaryDelta];
@autoreleasepool {
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
[self extractDeltaWithNotifier:notifier];
}
});
}
+ (void)load
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
{
[self registerImplementation:self];
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
+21
View File
@@ -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
+34
View File
@@ -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
+7 -1
View File
@@ -9,12 +9,18 @@
#ifndef SUCODESIGNINGVERIFIER_H
#define SUCODESIGNINGVERIFIER_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@interface SUCodeSigningVerifier : NSObject
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath;
@end
#endif
+32 -8
View File
@@ -11,6 +11,9 @@
#import "SUCodeSigningVerifier.h"
#import "SULog.h"
#include "AppKitPrevention.h"
@implementation SUCodeSigningVerifier
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundleURL matchesSignatureAtBundleURL:(NSURL *)newBundleURL error:(NSError *__autoreleasing *)error
@@ -31,13 +34,13 @@
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
if (result != noErr) {
SULog(@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
SULog(SULogLevelError, @"Failed to copy designated requirement. Code Signing OSStatus code: %d", result);
goto finally;
}
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
SULog(@"Failed to get static code %d", result);
SULog(SULogLevelError, @"Failed to get static code %d", result);
goto finally;
}
@@ -55,12 +58,12 @@
if (result != noErr) {
if (result == errSecCSUnsigned) {
SULog(@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.");
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) {
CFStringRef requirementString = nil;
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
SULog(@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString);
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);
}
@@ -87,7 +90,7 @@ finally:
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
SULog(@"Failed to get static code %d", result);
SULog(SULogLevelError, @"Failed to get static code %d", result);
goto finally;
}
@@ -102,7 +105,7 @@ finally:
if (result != noErr) {
if (result == errSecCSUnsigned) {
SULog(@"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
SULog(SULogLevelError, @"Error: The app is not signed using Apple Code Signing. %@", bundleURL);
}
if (result == errSecCSReqFailed) {
[self logSigningInfoForCode:staticCode label:@"new info"];
@@ -118,7 +121,22 @@ static id valueOrNSNull(id value) {
return value ? value : [NSNull null];
}
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath {
NSDictionary *info = nil;
SecStaticCodeRef code = NULL;
OSStatus result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundlePath, kSecCSDefaultFlags, &code);
if (result != noErr) {
SULog(SULogLevelError, @"Failed to get static code %d", result);
goto finally;
}
info = [self codeSignatureInfoForCode:code];
finally:
if (code) CFRelease(code);
return info;
}
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code {
CFDictionaryRef signingInfo = nil;
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
@@ -130,8 +148,14 @@ static id valueOrNSNull(id value) {
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
SULog(@"%@: %@", label, relevantInfo);
return [relevantInfo copy];
}
return nil;
}
+ (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label {
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
}
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
+12 -1
View File
@@ -21,6 +21,8 @@ extern const NSTimeInterval SUDefaultUpdateCheckInterval;
extern NSString *const SUBundleIdentifier;
extern NSString *const SUAppcastAttributeValueMacOS;
// -----------------------------------------------------------------------------
// Notifications:
// -----------------------------------------------------------------------------
@@ -33,11 +35,14 @@ extern NSString *const SUTechnicalErrorInformationKey;
extern NSString *const SUFeedURLKey;
extern NSString *const SUHasLaunchedBeforeKey;
extern NSString *const SUUpdateRelaunchingMarkerKey;
extern NSString *const SUShowReleaseNotesKey;
extern NSString *const SUSkippedVersionKey;
extern NSString *const SUScheduledCheckIntervalKey;
extern NSString *const SULastCheckTimeKey;
extern NSString *const SUExpectsDSASignatureKey;
extern NSString *const SUExpectsEDSignatureKey;
extern NSString *const SUPublicEDKeyKey;
extern NSString *const SUPublicDSAKeyKey;
extern NSString *const SUPublicDSAKeyFileKey;
extern NSString *const SUAutomaticallyUpdateKey;
@@ -45,9 +50,9 @@ extern NSString *const SUAllowsAutomaticUpdatesKey;
extern NSString *const SUEnableAutomaticChecksKey;
extern NSString *const SUEnableSystemProfilingKey;
extern NSString *const SUSendProfileInfoKey;
extern NSString *const SUUpdateGroupIdentifierKey;
extern NSString *const SULastProfileSubmitDateKey;
extern NSString *const SUPromptUserOnFirstLaunchKey;
extern NSString *const SUKeepDownloadOnFailedInstallKey;
extern NSString *const SUDefaultsDomainKey;
extern NSString *const SUEnableJavaScriptKey;
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
@@ -62,8 +67,11 @@ extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key
extern NSString *const SUAppcastAttributeDeltaFrom;
extern NSString *const SUAppcastAttributeDSASignature;
extern NSString *const SUAppcastAttributeEDSignature;
extern NSString *const SUAppcastAttributeShortVersionString;
extern NSString *const SUAppcastAttributeVersion;
extern NSString *const SUAppcastAttributeOsType;
extern NSString *const SUAppcastAttributePhasedRolloutInterval;
extern NSString *const SUAppcastElementCriticalUpdate;
extern NSString *const SUAppcastElementDeltas;
@@ -73,6 +81,7 @@ extern NSString *const SUAppcastElementReleaseNotesLink;
extern NSString *const SUAppcastElementTags;
extern NSString *const SURSSAttributeURL;
extern NSString *const SURSSAttributeLength;
extern NSString *const SURSSElementDescription;
extern NSString *const SURSSElementEnclosure;
@@ -80,4 +89,6 @@ extern NSString *const SURSSElementLink;
extern NSString *const SURSSElementPubDate;
extern NSString *const SURSSElementTitle;
extern NSString *const SUXMLLanguage;
#endif
+15 -6
View File
@@ -6,32 +6,35 @@
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUConstants.h"
#import "SUErrors.h"
#ifndef DEBUG
#define DEBUG 0
#endif
#include "AppKitPrevention.h"
// Define some minimum intervals to avoid DoS-like checking attacks
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
NSString *const SUAppcastAttributeValueMacOS = @"macos";
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
NSString *const SUUpdateRelaunchingMarkerKey = @"SUUpdateRelaunchingMarker";
NSString *const SUFeedURLKey = @"SUFeedURL";
NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes";
NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
NSString *const SUExpectsEDSignatureKey = @"SUExpectsEDSignatureKey";
NSString *const SUPublicEDKeyKey = @"SUPublicEDKey";
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
@@ -39,11 +42,11 @@ NSString *const SUAllowsAutomaticUpdatesKey = @"SUAllowsAutomaticUpdates";
NSString *const SUEnableSystemProfilingKey = @"SUEnableSystemProfiling";
NSString *const SUEnableAutomaticChecksKey = @"SUEnableAutomaticChecks";
NSString *const SUSendProfileInfoKey = @"SUSendProfileInfo";
NSString *const SUUpdateGroupIdentifierKey = @"SUUpdateGroupIdentifier";
NSString *const SULastProfileSubmitDateKey = @"SULastProfileSubmissionDate";
NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
NSString *const SUEnableJavaScriptKey = @"SUEnableJavaScript";
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
@@ -54,8 +57,11 @@ NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
NSString *const SUAppcastAttributeEDSignature = @"sparkle:edSignature";
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
NSString *const SUAppcastAttributeOsType = @"sparkle:os";
NSString *const SUAppcastAttributePhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
@@ -65,9 +71,12 @@ NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
NSString *const SUAppcastElementTags = @"sparkle:tags";
NSString *const SURSSAttributeURL = @"url";
NSString *const SURSSAttributeLength = @"length";
NSString *const SURSSElementDescription = @"description";
NSString *const SURSSElementEnclosure = @"enclosure";
NSString *const SURSSElementLink = @"link";
NSString *const SURSSElementPubDate = @"pubDate";
NSString *const SURSSElementTitle = @"title";
NSString *const SUXMLLanguage = @"xml:lang";
-37
View File
@@ -1,37 +0,0 @@
//
// SUDSAVerifier.h
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
// Includes code by Zach Waldowski on 10/18/13.
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
//
// Includes code from Plop by Mark Hamlin.
// Copyright 2011 Mark Hamlin. Licensed under BSD.
//
#ifndef SUDSAVERIFIER_H
#define SUDSAVERIFIER_H
#import <Foundation/Foundation.h>
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
@interface NSData (SUDSAVerifier)
- (id)initWithBase64Encoding:(NSString *)base64String;
@end
#endif
@interface SUDSAVerifier : NSObject
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
- (instancetype)initWithPublicKeyData:(NSData *)data;
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
@end
#endif
-165
View File
@@ -1,165 +0,0 @@
//
// SUDSAVerifier.m
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
// Includes code by Zach Waldowski on 10/18/13.
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
//
// Includes code from Plop by Mark Hamlin.
// Copyright 2011 Mark Hamlin. Licensed under BSD.
//
#import "SUDSAVerifier.h"
#import "SULog.h"
#include <CommonCrypto/CommonDigest.h>
@implementation SUDSAVerifier {
SecKeyRef _secKey;
}
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
{
if (!encodedSignature) {
SULog(@"There is no DSA signature to check");
return NO;
}
if (!path) {
return NO;
}
SUDSAVerifier *verifier = [[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
if (!verifier) {
return NO;
}
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
NSData *signature = [[NSData alloc] initWithBase64Encoding:strippedSignature];
return [verifier verifyFileAtPath:path signature:signature];
}
- (instancetype)initWithPublicKeyData:(NSData *)data
{
self = [super init];
if (!self || !data.length) {
SULog(@"Could not read public DSA key");
return nil;
}
SecExternalFormat format = kSecFormatOpenSSL;
SecExternalItemType itemType = kSecItemTypePublicKey;
CFArrayRef items = NULL;
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
if (status != errSecSuccess || !items) {
if (items) {
CFRelease(items);
}
SULog(@"Public DSA key could not be imported: %d", status);
return nil;
}
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
#pragma clang diagnostic pop
}
CFRelease(items);
return self;
}
- (void)dealloc
{
if (_secKey) {
CFRelease(_secKey);
}
}
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
{
if (!path.length) {
return NO;
}
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
return [self verifyStream:dataInputStream signature:signature];
}
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
{
if (!stream || !signature) {
return NO;
}
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
__block SecTransformRef dataReadTransform = NULL;
__block SecTransformRef dataDigestTransform = NULL;
__block SecTransformRef dataVerifyTransform = NULL;
__block CFErrorRef error = NULL;
BOOL (^cleanup)(void) = ^{
if (group) CFRelease(group);
if (dataReadTransform) CFRelease(dataReadTransform);
if (dataDigestTransform) CFRelease(dataDigestTransform);
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
if (error) CFRelease(error);
return NO;
};
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
if (!dataReadTransform) {
SULog(@"File containing update archive could not be read (failed to create SecTransform for input stream)");
return cleanup();
}
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
if (!dataDigestTransform) {
return cleanup();
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
#pragma clang diagnostic pop
if (!dataVerifyTransform || error) {
SULog(@"Could not understand format of the signature: %@; Signature data: %@", error, signature);
return cleanup();
}
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
if (error) {
SULog(@"%@", error);
return cleanup();
}
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
if (error) {
SULog(@"%@", error);
return cleanup();
}
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
if (error) {
SULog(@"DSA signature verification failed: %@", error);
return cleanup();
}
if (!result.boolValue) {
SULog(@"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
}
cleanup();
return result.boolValue;
}
@end
+9 -3
View File
@@ -9,11 +9,17 @@
#ifndef SUDISKIMAGEUNARCHIVER_H
#define SUDISKIMAGEUNARCHIVER_H
#import <Cocoa/Cocoa.h>
#import "SUUnarchiver.h"
#import <Foundation/Foundation.h>
#import "SUUnarchiverProtocol.h"
@interface SUDiskImageUnarchiver : SUUnarchiver
NS_ASSUME_NONNULL_BEGIN
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
@end
NS_ASSUME_NONNULL_END
#endif
Loaded 100 of 341 files, more files were not shown because too many files have changed in this diff. Show more