Compare commits

...
322 Commits
Author SHA1 Message Date
Kornel Lesiński 72618a0d3a 1.11.1 2015-11-09 00:33:29 +00:00
Zorg 66a11b83f0 Don't install automatic updates if the system might shut off 2015-11-08 23:43:12 +00:00
Kornel Lesiński 57101a1c5b Updated changelog 2015-07-24 00:19:47 +01:00
Kornel 382b04fe4a Merge pull request #574 from sparkle-project/unbundle
Don’t keep important settings in Sparkle’s Info.plist
2015-07-24 00:11:02 +01:00
Kornel Lesiński 07c773ace2 Move sparkleBundle from SUHost to SUUpdater 2015-07-23 11:28:20 +01:00
Kornel Lesiński a85a48c59a Don’t keep important settings in Sparkle’s Info.plist 2015-07-22 14:34:24 +01:00
Kornel cf17fff3fc Merge pull request #573 from sparkle-project/bundleid
Use bundleForClass instead of finding bundle by ID
2015-07-22 11:44:36 +01:00
Kornel Lesiński 4cc1702093 Use bundleForClass instead of finding bundle by ID
It should prevent confusion when multiple copies of Sparkle are available

Fixes #571
2015-07-22 10:37:34 +01:00
Kornel Lesiński 86fdb0c2ac Version bump 2015-07-16 23:27:50 +01:00
Kornel Lesiński 3e7c7fe249 Updated readme 2015-07-16 23:26:49 +01:00
Kornel Lesiński ce21e1b7e7 Updated changelog 2015-07-16 23:22:28 +01:00
Kornel Lesiński e9fa7c3d4a Verify relaunchToolPath is not nil
#571
2015-07-13 07:03:50 +01:00
Jake Petroules ceee82c4b1 Ignore stderr from xcrun. 2015-07-09 18:18:43 -07:00
Jake Petroules 7c39af9c99 Let CI test as many SDKs as are available. 2015-07-09 18:16:36 -07:00
Jake Petroules e086125cb8 Fix image height on GitHub. 2015-07-09 17:57:43 -07:00
Jake Petroules 5e6acc824e Add ship.io badge, which lets us prove that the build works on Xcode 5. 2015-07-09 17:48:17 -07:00
Jake Petroules ae27726b3b Rename continuous integration Makefile target to the more general 'ci'. 2015-07-09 17:40:51 -07:00
Jake Petroules 83f6dd3052 Guard some test cases for use on Xcode 6+ only. 2015-07-09 17:38:14 -07:00
Jake Petroules fb9b4a4f35 Fix nullability warnings. 2015-07-09 17:27:31 -07:00
Jake Petroules 6d7f95d912 Fix const warnings for both Xcode 6 and 7. 2015-07-09 17:16:06 -07:00
Jake Petroules 46249cc49f Turn on more warnings. 2015-07-09 17:16:06 -07:00
Jake Petroules 51712d2322 Fix a bunch of warnings so Xcode 5 still compiles cleanly. 2015-07-09 17:16:06 -07:00
Jake Petroules 24898ad60d Fix warnings in sais. These have been sent upstream as well. 2015-07-09 17:16:06 -07:00
Kornel cf9edce775 Merge pull request #569 from vokal/master
Add delegate methods for pre-download and immediately post-failed-download.
2015-07-08 01:13:45 +01:00
designatednerd 2387feeb7c Merge pull request #1 from vokal-isaac/master
Add delegate methods for pre-download and immediately post-failed-download.
2015-07-07 12:46:32 -05:00
Isaac Greenspan 363a41234d Indent new documenting comments to match existing ones. 2015-07-07 12:44:14 -05:00
Isaac Greenspan 06573e4b81 Add delegate methods for pre-download and immediately post-failed-download. 2015-07-07 12:35:49 -05:00
Kornel e702246bb5 Merge pull request #540 from zorgiepoo/code-sign-xattr
BinaryDelta Code Signed Extended Attributes Validation
2015-07-06 09:49:29 +01:00
Kornel 78c14cc574 Merge pull request #568 from xhacker/fix-default-font
Fix Lucida Grande is always used for release notes
2015-07-06 09:46:29 +01:00
LIU Dongyuan / 柳东原 976e83159f Fix Lucida Grande is always used for release notes
Use "-apple-system-font" to use system default font.
2015-07-05 21:32:07 -07:00
Kornel d7e532d268 Merge pull request #565 from sparkle-project/errtxt
More verbose error message when DSA keys don't match
2015-07-05 12:45:24 +01:00
Kornel Lesiński 33ef8ca2b4 Clarify that DSA is for archives and Apple Code Signing is for apps 2015-07-05 12:44:45 +01:00
Kornel e5e560e751 Merge pull request #566 from zorgiepoo/bundle-nil-check
Don't use main bundle if passed in bundle is nil
2015-07-03 14:46:17 +01:00
Kornel 4e33285068 Merge pull request #567 from savoirfairelinux/master
builddir: use predefined BUILDDIR
2015-07-02 17:09:59 +01:00
Alexandre Lision 313f4a497d builddir: use predefined BUILDDIR
This commit allows user to control where Sparkle will be build
2015-07-02 11:38:06 -04:00
Zorg ddb67d1c84 Added assert to make sure bundle isn't nil 2015-07-01 22:00:29 -04:00
Kornel Lesiński 99dedafc67 Fixed condition 2015-07-01 09:54:46 +01:00
Zorg 0b7e343a56 Don't use main bundle if passed in bundle is nil 2015-07-01 00:35:27 -04:00
Kornel Lesiński cd4da94cb9 GitHub pages don't support HTTPS for custom domains 2015-07-01 00:35:08 +01:00
Kornel 882fecea6b Merge pull request #564 from zorgiepoo/fixtestapp
Add public DSA file to updated test app
2015-07-01 00:34:33 +01:00
Kornel Lesiński efdf9d4421 More verbose error message when DSA keys don't match 2015-07-01 00:30:35 +01:00
Zorg 33c2eb89c9 Add public DSA file to updated test app 2015-06-30 18:42:29 -04:00
Kornel dc1cd3a259 Merge pull request #563 from kainjow/master
Fix NSAlert deprecations
2015-06-29 17:28:47 +01:00
Kevin Wojniak 11eaa3e092 Replace deprecated alertWithMessageText 2015-06-29 08:45:08 -07:00
Kevin Wojniak 4adb53dc51 Replace deprecated NSRunAlertPanel 2015-06-29 08:39:06 -07:00
Kornel d0cc3b63b4 Merge pull request #538 from zorgiepoo/verifying-update
Only check if new path is code signed
2015-06-29 12:11:56 +01:00
Jake Petroules 2aefacb7f2 Merge pull request #561 from sparkle-project/null
Nullability
2015-06-29 02:41:40 -07:00
Kornel Lesiński 3f433561d4 Hide __nonnull from Xcode 6 2015-06-29 10:10:18 +01:00
Kornel Lesiński 7bb0c69f76 Nullability 2015-06-29 10:03:31 +01:00
Kornel Lesiński 2c7ad5bc29 Const/casts 2015-06-29 10:03:31 +01:00
Kornel Lesiński 7ebb603ab7 Null checks 2015-06-29 10:03:31 +01:00
Kornel Lesiński 7b9e1fb431 Safer initialization 2015-06-28 22:50:50 +01:00
Kornel Lesiński 9f23c4f11e Comments 2015-06-28 22:50:36 +01:00
Kornel ce2a721a73 Merge pull request #560 from ksuther/pt-BR-warning-fix
pt-BR warning fix
2015-06-25 12:55:39 +01:00
Kent Sutherland eebadf5230 Fixed a warning about the window being offscreen (introduced from the pt-BR localization update). 2015-06-24 19:07:10 -04:00
Jake Petroules 51b62de4cb Fix some warnings. 2015-06-13 02:30:13 -07:00
Jake Petroules 4643becaff Upgrade settings. 2015-06-13 02:22:20 -07:00
Jake Petroules 4bbfac11aa Fix build with < 10.9 SDK. 2015-06-06 09:23:26 -07:00
Jake Petroules 0f4f7c3509 Fix build with < 10.10 SDK. 2015-06-06 08:40:17 -07:00
Jake Petroules 91af4db0c0 Update Podspec for 1.10.0. 2015-06-06 08:35:07 -07:00
Jake Petroules 21a894cd63 Fix warnings in unit test. 2015-06-06 08:35:07 -07:00
Jake Petroules e8035cc912 Silence warnings in third party code. 2015-06-06 08:35:07 -07:00
Jake Petroules 342aec164d Comment problematic clang-format property. 2015-06-06 08:35:07 -07:00
Kornel 517f7862ab Merge pull request #534 from zorgiepoo/app-update-validation
Improved app update validation
2015-06-06 11:53:41 +01:00
Zorg 6ca90a8c11 Clarification that DSA keys differ or are absent 2015-06-05 22:22:05 -04:00
Zorg a7e8e2aad5 Validate with the new public DSA key, not the old one 2015-06-05 21:59:32 -04:00
Zorg e9e5791e51 s/Pubic/Public/ 2015-06-05 21:46:52 -04:00
Zorg 7c705e5fff Remove redundant check that SUDSAVerifier does 2015-06-05 21:39:57 -04:00
Zorg b1d887264f Fix package validation from previous commit
Modern packages aren't distributed as bundles, and we wouldn't be able to obtain a "new" public DSA key from an update
2015-06-05 21:37:09 -04:00
Zorg da06dc80d6 Rely on code signing and the DSA key in the new app
Instead of relying on whether the DSA signature is provided in the appcast (which we can't trust), we rely on detecting if the public key in the new and old app differ. If they differ, then the code signatures from both apps must match. The idea is that code signing is reliable in being able to tell that the Info.plist and public DSA files came from the developer and are intact. This still allows a developer to lose access to their DSA private key, or to their Apple code signature, and be able to push new updates (as long as they didn't lose access to both). The new change, however, is that if the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed.
2015-06-05 18:57:36 -04:00
Kornel 2ed2f3def3 Merge pull request #554 from MaddTheSane/headers
Import the Foundation umbrella header in all the public headers.
2015-06-05 00:04:12 +01:00
C.W. Betts 3292c4ea10 Import the Foundation umbrella header in all the public headers.
This should prevent any undefined declaration warnings.
2015-06-04 11:13:48 -06:00
Kornel Lesiński fbc7a7fbf7 Log URL on appcast error 2015-05-27 19:16:55 +01:00
Kornel Lesiński 4733fe7785 Log URL on download error 2015-05-27 19:16:54 +01:00
Victor Figueiredo 8585d06bb5 pt-BR localization update 2015-05-21 00:27:57 +01:00
Kornel 4d111b96e4 Merge pull request #541 from zorgiepoo/unable-quarantine-fix
Only remove quarantine with -[NSURL setResourceValue:] when it's present
2015-05-10 02:15:54 +02:00
Zorg 0557a5ba5c Only remove quarantine with setResourceValue: when it's present
This should stop "Unable to quarantine: 93" messages from showing up in the console. Fixes issue #452
2015-05-08 23:55:23 -04:00
Zorg 61d43f860a Add tests for aborting on code signed xattr's 2015-05-05 22:04:18 -04:00
Zorg 4dd4548be4 Added comment on why code-signed xattr is not diff'ed 2015-05-05 21:47:23 -04:00
Zorg 9c3ef30f4c Diff'ing code-signed xattr's should actually not be supported
According to Apple's code signing document: https://developer.apple.com/library/mac/technotes/tn2206/_index.html
They don't recommend storing signed non-Mach-O files inside an app. They'd prefer script files for example to be in Resources directory and be unsigned.
2015-05-05 21:13:01 -04:00
Zorg 585194908e Bumping minor diff version 2015-05-05 20:32:16 -04:00
Zorg 330c733958 Don't forget to free the buffer 2015-05-05 20:25:42 -04:00
Zorg 4c782a67ed Abort if code signed xattr exists anywhere
Code signatures on non-mach-o files is not currently supported, but I'd like to implement this eventually.
2015-05-05 20:22:02 -04:00
Zorg 3a304123d9 Renaming newBundlePath to installSourcePath 2015-05-04 23:15:17 -04:00
Zorg 87da4cc0f2 Distinguish between install path found and update being a package 2015-05-04 22:49:57 -04:00
Kornel 12f29384ea Merge pull request #539 from vslavik/fix-incomplete-implementation-warning
Fix appcastDidFinishLoading: incomplete implementation warning
2015-05-04 15:13:32 +02:00
Václav Slavík 253f7c1023 Fix appcastDidFinishLoading: incomplete implementation warning
appcastDidFinishLoading: was declared in SUUIBasedUpdateDriver, but
defined and used in SUUIBasedUpdateDriver. Move the declaration back to
the base class where it belongs.
2015-05-04 14:34:49 +02:00
Zorg 65bfa1ccf2 Only check if new path is code signed
If the original app is signed, and the update is not, this is actually fine if the DSA validation goes through. And this may be desirable for people that don't want to pay cash to code sign their application anymore.
2015-05-03 20:06:41 -04:00
Kornel Lesiński f19038e5fe Add test cases 2015-05-02 23:16:58 +02:00
Kornel Lesiński 619e4a60a2 Fixed test name 2015-05-02 22:49:55 +02:00
Kornel 6e92311aaa Merge pull request #537 from antonc27/master
Fix for crash while applying delta update
2015-04-29 18:41:57 +01:00
antonc27 7d7aeb9f65 - Fix for crash while applying delta update 2015-04-29 17:54:58 +02:00
Jake Petroules ae3d04660e Merge pull request #535 from tonyarnold/hotfix/foundation-import
Properly import Foundation to fix errors when building as a module
2015-04-27 18:36:31 -07:00
Tony Arnold 2068da1cf9 Properly import Foundationto fix errors when building as a module 2015-04-28 09:40:54 +10:00
Zorg 19fdb9276d Only do DSA verification if public key is available 2015-04-27 19:18:21 -04:00
Zorg f55d2a4439 Host app needn't be signed to verify signature of updated app 2015-04-26 16:28:17 -04:00
Zorg 28ea47f796 Improved app update validation. See discussion in issue #441
If an invalid DSA or invalid code signature is provided, the update will fail, regardless if one of these requirements is valid. The logic before is that the update will succeed if either a valid DSA or matched code signature is provided.
This still allows a code signature to change, be added, or be removed, as long as the DSA and the code signature (if provided) is valid. If no DSA is provided, then this is not possible, and the code signature from the host and update app must match.
2015-04-26 13:58:40 -04:00
Kornel Lesiński 9646b0b790 Optimized images 2015-04-26 00:31:02 +01:00
Kornel Lesiński afb524a46a Yosemite screenshot 2015-04-26 00:22:57 +01:00
Kornel Lesiński 56ac1c931b Preserve underlying errors 2015-04-25 21:37:08 +01:00
Jake Petroules 3a788e9546 Merge pull request #532 from sparkle-project/guidedinstall
Simpler guided install opt-in
2015-04-25 13:20:33 -07:00
Jake Petroules 0b2f37beb9 Merge pull request #533 from sparkle-project/dedelegate
De-delegate
2015-04-25 13:12:20 -07:00
Kornel Lesiński 353a5635e1 Removed appcast delegate 2015-04-25 21:08:44 +01:00
Kornel Lesiński 35dfed44de Removed update alert delegate 2015-04-25 20:37:01 +01:00
Kornel Lesiński 3680b0bb67 Removed automatic update alert delegate 2015-04-25 20:36:59 +01:00
Kornel Lesiński 209d6db3a1 Test guided installation 2015-04-25 12:44:21 +01:00
Kornel Lesiński bb7af6145f Removed unused arg 2015-04-25 12:42:11 +01:00
Kornel Lesiński 77fd19a134 Use completion block instead of a delegate 2015-04-25 12:41:09 +01:00
Kornel Lesiński 38a70c61c4 Use package.sparkle_guided.pkg instead of .sparkle_guided.plist indirection 2015-04-25 12:38:32 +01:00
Jake Petroules d2fd67ac84 Merge pull request #529 from sparkle-project/testsymbols
Expose Sparkle symbols to unit test app
2015-04-24 18:42:40 -07:00
Kornel Lesiński f911c29bf0 Expose Sparkle symbols to unit test app 2015-04-24 10:59:25 +01:00
Kornel Lesiński 63052aa3d1 Cache strings 2015-04-24 01:22:36 +01:00
Kornel Lesiński eb28fe7ebd Updated changelog 2015-04-24 00:35:20 +01:00
Kornel Lesiński 06c6a3b7f2 Use Cocoa to pipe to unarchivers 2015-04-23 01:37:13 +01:00
Kornel Lesiński d4843c90e8 Don't tie unarchiver to host 2015-04-23 01:21:37 +01:00
Kornel Lesiński 5ba0b2d656 Test unarchiver 2015-04-23 01:20:12 +01:00
Kornel Lesiński 482301aa0d Sorted xcodeproj 2015-04-23 01:06:05 +01:00
Kornel 87dfb72484 Merge pull request #523 from iwankerl/verify-final-code-signature
Verify final code signature for issue #441
2015-04-22 23:52:04 +01:00
Kornel Lesiński ea07f716b8 Revert "Register update with Launch Services; see #508"
This reverts commit a7d11f88c7.

Fixes #525
2015-04-22 23:46:27 +01:00
Kornel Lesiński e7786dde97 Travis :sadpanda:
Revert "CodeSignOnCopy in a parent project won't sign Autoupdate.app, so codesign by default"

This reverts commit 836c6ef09e.
2015-04-22 23:43:38 +01:00
Kornel Lesiński b02a65974d One-off post-update test app 2015-04-22 23:37:20 +01:00
Kornel Lesiński 6017c982c5 Silence warning (code is OK) 2015-04-22 23:27:47 +01:00
Kornel Lesiński 836c6ef09e CodeSignOnCopy in a parent project won't sign Autoupdate.app, so codesign by default 2015-04-22 23:22:00 +01:00
Kornel ab4a058ac4 Merge pull request #527 from zorgiepoo/binary-diff-verbose
BinaryDelta Verbosity/Improved Logging
2015-04-20 01:20:57 +01:00
Zorg da9e48cf29 Added comment why -[NSFileManager fileExistsAtPath:] is not used 2015-04-19 19:23:00 -04:00
Zorg 08aed29870 Fix tests from not compiling 2015-04-19 18:48:22 -04:00
Zorg f31921e775 Re-format BinaryDelta create usage slightly 2015-04-19 18:18:55 -04:00
Zorg 578ba9adaf Removing ()'s in Adding file log 2015-04-19 18:08:06 -04:00
Zorg efac6b053d Improved command line argument parsing 2015-04-19 18:02:28 -04:00
Zorg e978cb0a3a Update BinaryDelta formatting for creating/applying logs 2015-04-19 17:29:51 -04:00
Zorg b780b476c6 Add version command for BinaryDelta and for patches 2015-04-19 15:53:36 -04:00
Zorg ba75b79a97 Fix verbose & version flag parsing 2015-04-19 15:22:00 -04:00
Zorg f9043aa0e6 Added verbose logging to the files being applied/created
Files can be Added, Removed, Replaced, have a new permissions Mode, or changed via a Delta patch
2015-04-19 14:04:59 -04:00
Kornel 5890ec6cfe Merge pull request #519 from ProsoftEngineering/suppress-deprecated-warning
Suppress AuthorizationExecuteWithPrivileges deprecated warning
2015-04-19 15:30:49 +01:00
Zorg fef73cc297 Added verbose option to BinaryDelta
Everything is now printed to stderr now, now that we have a verbose option. Printing to same stream avoids out-of-order messages
2015-04-19 03:40:54 -04:00
Kornel c7a8d5d42a Merge pull request #524 from zorgiepoo/binary-delta-permissions
Binary delta Improvements
2015-04-19 00:31:53 +01:00
Zorg 9e9fef0d51 Add an extract property for creating/applying binary diffs
Before, an extract was assumed if nothing else matched. This can get quite confusing when adding new properties, so we shouldn't treat any property to be handled if nothing else was handled.
2015-04-18 17:59:52 -04:00
Kornel 509df736bc Merge pull request #526 from zorgiepoo/arc-autoupdate-release
Ensure termListen is not deallocated before -[NSRunningApplication run]
2015-04-18 18:47:28 +01:00
Zorg 063056e193 Ensure termListen is not deallocated before -[NSRunningApplication run]
Related: Issue #441
I have no evidence that this is the cause of the issue, but from what we do know from the crash logs submitted, it looks like Sparkle crashes or errors on the main thread. It also looks like it might be from an object release rather than copying (which is done on a different thread) being the issue (see issue #417 also). I'm leaning towards this being an issue after the project was converted to ARC.
2015-04-18 13:14:57 -04:00
Kornel Lesiński d1908b1645 Unused 2015-04-18 18:00:44 +01:00
Kornel Lesiński 06a1ab8787 Formatting 2015-04-18 18:00:44 +01:00
Zorg cd478a4c48 Fixing unused variable warnings 2015-04-17 19:07:36 -04:00
Zorg acbd622369 Add tests for invalid patch version inputs 2015-04-17 19:03:21 -04:00
Zorg 817bbc46b1 Add a test to make sure old patches still work 2015-04-17 18:52:42 -04:00
Zorg dbc9123dce Use SUBinaryDeltaMajorVersion instead of uint16_t for this cast 2015-04-17 18:40:08 -04:00
Zorg c2cb3094af Use after-tree instead of before-tree here. Oops. 2015-04-17 18:38:44 -04:00
Zorg 65931f6277 First delta minor version should now be 0 2015-04-17 17:55:32 -04:00
Zorg 0f6697214d Increase minor version for version 1 patches
Since BinaryDelta can still create patches for older versions, and since I've made fixes recently even for version 1 patches, we should increment this counter.
2015-04-17 17:53:05 -04:00
Zorg 3c78139ec8 Use enums for major/minor versions instead of #defines
This should be more typesafe
2015-04-17 17:50:21 -04:00
Zorg 5c921de24f Removing couple of unused variables 2015-04-17 17:20:54 -04:00
Zorg a715babce3 Create #defines for diff properties 2015-04-17 16:32:38 -04:00
Zorg fd68e649db Clarifying which BinaryDiff fields are available when 2015-04-17 15:14:51 -04:00
Zorg 186cfa8486 New patches will now be at major version 2
This will break backwards compatibility with version 1 patches, which generated tree hashes differently and did not handle applying permission changes in some cases.
A version flag is also added to BinaryDelta create for creating patches an older version of BinaryDelta apply can handle. This is only meant for transition purposes.
2015-04-17 14:53:54 -04:00
Zorg c5bc6fe95b s/executablePermissions/permissions/ 2015-04-17 02:29:27 -04:00
Zorg 285cd3063f Fix removeTree not working for symbolic links and added tests
I accidently broke this a few commits ago where I inserted a return value for it
2015-04-17 02:28:03 -04:00
Zorg 8a4f4677bd Add detection for ACLs and fail if they are present
Applications probably shouldn't contain ACLs for files inside their bundle. Dealing with these could be complicated, so we should just reject them.
2015-04-17 01:35:17 -04:00
Isaac Wankerl 57122a40e6 Back out of using the kSecCSCheckNestedCode flag.
This is less secure, but should enable the code to work with older code signatures.
2015-04-15 14:26:53 -05:00
Zorg e2fca42f6c Add error checking to a removeTree call 2015-04-15 00:09:32 -04:00
Zorg 443a6064b3 Add test with no files in before/after trees 2015-04-14 01:48:50 -04:00
Zorg 86754e0537 Adding another test case for empty directories 2015-04-14 01:47:01 -04:00
Zorg 78a940fcf4 Add tests for symlink permissions 2015-04-14 01:46:24 -04:00
Zorg 4029788163 Use lchmod for symlinks; fixes not being able to modify them 2015-04-14 01:44:19 -04:00
Zorg 16cd57b8eb Use XCTFail where appropriate 2015-04-14 00:36:30 -04:00
Zorg a5687d9c1d Track all Unix permissions
Rationale: given a before-hash and an after-hash, there should only be one way to create the diff file. It was possible to violate this before, if we let a file differ in a permission bit that wasn't executable.
2015-04-14 00:12:12 -04:00
Zorg e93888ad3f Add more permissions tests with directories and files 2015-04-14 00:09:03 -04:00
Zorg 7aaf002651 Track directories in binary delta hashes
This code was intended to track directories from the start, but it looks like it never did.
2015-04-13 20:41:10 -04:00
Isaac Wankerl 742648a166 Check the code signature of installed app in the SUPlainInstaller.
This should help prevent situations like issue #441 where Sparkle
creates broken app bundles.  In this case, the update will just report
as a failure instead of succeeding.
2015-04-13 15:48:17 -05:00
Isaac Wankerl c1f9fcb456 Add SUCodeSigningVerifier unit tests.
There's a zipped up sample app in the unit test target.  This gets unzipped to
a temporary folder and there are three versions of it: the original which is not
code signed at all, another with a valid code signature, and a third which
has had one of its resources removed after code signing to make it invalid.
2015-04-13 15:27:59 -05:00
Isaac Wankerl 47d56a5485 Use the bundleURL instead of executableURL with SecStaticCodeCreateWithPath()
The API docs say "For bundles, pass a URL to the root directory of the bundle…
If you pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized."
2015-04-13 12:55:20 -05:00
Isaac Wankerl 498ed027dd Perform a deep code signature verification with kSecCSCheckNestedCode 2015-04-13 12:51:20 -05:00
Isaac Wankerl 31d03b314d Add +[SUCodeSigningVerifier codeSignatureIsValidAtPath:error:]
Let's you check the validity of an arbitrary code signed app.
2015-04-13 11:47:34 -05:00
Isaac Wankerl 8bbe487c86 Refactor +[SUCodeSigningVerifier codeSignatureIsValidAtPath:error:] to +[SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:error:]
Explains more clearly what the method does.
2015-04-13 11:31:34 -05:00
Isaac Wankerl 4d6eeb363c Add +[SUCodeSigningVerifier applicationAtPathIsCodeSigned:]
Tests whether a particular app is code signed or not.  It does not verify the signature.
2015-04-13 11:25:44 -05:00
Zorg 419b6aabef Extracting files should take priority over changing permissions
Fixes a bug where permissions would change but a new (small) file would not be updated
2015-04-13 00:05:46 -04:00
Zorg 54522aa725 Reworked diffing file permissions
My initial attempt did not work correctly for directories that differed in permissions (since it removed them and all the files inside them). We are now setting a property for permission changes which can happen when a binary diff is created, or when it is skipped. Still have to figure out how backwards compatibility is going to work now..
2015-04-12 23:21:40 -04:00
Zorg d374d99e51 Only allow 0755 and 0644 permissions in after-tree 2015-04-12 19:57:40 -04:00
Zorg 33de6ed878 Don't think _DARWIN_NO_64_BIT_INODE is needed 2015-04-12 16:30:17 -04:00
Zorg 0c40d99740 Added invalid source test for BinaryDelta 2015-04-12 15:55:28 -04:00
Zorg bcab57d8f5 Handle exec. file changes, versioning, more error handling
BinaryDelta can now create proper diffs in the case if a non-executable file becomes an executable file, or vise versa. Currently for simplicit
y and backward-compatibility we delete then extract if an executable difference is found, rather than creating a diff. Files that contain an executable difference are unlikely to be large anyway.

We also change the tree hash function so it can track executable permission differences on files. It also now tracks file types so it is less collision-resistant for example in the case where a regular file becoming a symlink could have resulted in the same hash. Because the tree hash function changed, major & minor versioning to the format was introduced. Older minor versions remain compatible, but older major versions do not. In this case, we've only bumped the minor version. In this case, older versions can apply a patch created by a newer version, and newer versions can apply a patch created by an older version.

More error handling is now checked, some code improvements were made, and some adjustments were made to the tests with regard to the changes above.
2015-04-12 14:46:26 -04:00
Kornel 2ca0a739e5 Merge pull request #522 from zorgiepoo/binary-delta-tests
Binary delta tests
2015-04-11 16:13:02 +01:00
Zorg 9895f123a7 Comments changes to SUBinaryDeltaTest.m 2015-04-11 00:40:50 -04:00
Zorg 87dfe0a4ed Adding BinaryDelta creating/applying tests 2015-04-11 00:13:27 -04:00
Zorg 08434edf79 Move creating diffs into separate source file
Since a function for creating diffs is now exposed, this should make testing easier
This is also consistent with applying diffs being in a separate source file from the delta tool as well
2015-04-09 21:39:11 -04:00
Kornel 695e05eba4 Merge pull request #520 from ProsoftEngineering/xcode-63-update
Xcode 6.3 update
2015-04-09 23:58:59 +01:00
Brian Bergstrand b9a8adba73 Suppress Xcode 6.3 -Wcstring-format-directive warning
New warning fires for every NS/CF string format function.
2015-04-09 14:29:32 -05:00
Brian Bergstrand 91f504ed9f Update to Xcode 6.3 2015-04-09 14:27:48 -05:00
Brian Bergstrand 6033bd4228 Suppress AuthorizationExecuteWithPrivileges deprecated warning 2015-04-09 13:56:53 -05:00
Kornel 3de3b11523 Merge pull request #518 from zorgiepoo/binary-delta-stdout
Use stdout for Binary delta info messages
2015-04-09 00:36:25 +01:00
Zorg 707f86a2f4 Patch BinaryDeltaApply to use stdout for info messages too
See issue #516
2015-04-07 21:51:26 -04:00
JDuquennoy e9817380d2 Stdout used for non error outputs 2015-04-07 21:45:20 -04:00
Kornel 21999e4a75 Merge pull request #515 from zorgiepoo/bsdiff-sais
Change bsdiff's suffix sort algorithm to sais. Fixes #132
2015-04-05 23:28:14 +01:00
Zorg 616cc70775 Change bsdiff's suffix sort algorithm to sais. Fixes #132
Although #132 is marked as closed, the issue is still real. bsdiff can crash or hang when creating diffs on some files. In particular, bsdiff hangs/crashes in its recursive split function.

As you can see from:
http://stackoverflow.com/a/20305493/871119
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664

bsdiff 4.3 uses qsufsort for its suffix sorting algorithm, which has a bug causing the hanging/crashing. Our solution is to change the algorithm to use sais for suffix sorting:
https://sites.google.com/site/yuta256/sais

Notes:
*I had to change sais_index_type #define from int to off_t in sais.h/c and in some other places, to eliminate all warnings. Compiles cleanly with clang's -Weverything
*sais is claimed to be more efficient than other algorithms including qsufsort. If a more efficient (and stable) algorithm comes out, we may be able to swap it out in the future.
2015-04-05 15:01:49 -04:00
Kornel 09d98932d9 Merge pull request #513 from zorgiepoo/binary-delta-case-issue
Fix BinaryDelta failing on filenames changing case
2015-04-04 23:37:48 +01:00
Kornel 3b8513546e Merge pull request #514 from zorgiepoo/binary-delta-dir-change-issue
Fix BinaryDelta sometimes failing when a dir becomes a dir link
2015-04-04 23:37:36 +01:00
Zorg 5589a604b8 Use child/parent names with paths for better clarity 2015-04-04 16:44:36 -04:00
Zorg 44b027a178 Fix BinaryDelta sometimes failing when a dir becomes a dir link
This can occur in the following case:
--
original_tree:
	A/
	Current/
		B
new_tree:
	A/
		B
	Current -> A/
--
Because symbolic links are not followed, Current/B can be marked as deleted. If A/B is added before the deletion, then A will end up as an empty directory.
Our fix is to remove all subpaths of a file when it changes from a directory to another type of file. This should also decrease the size of the diff even in harmless cases such as when a directory changes into a regular file.
2015-04-04 13:29:29 -04:00
Zorg 2dfc8494d7 Fix BinaryDelta failing on filenames changing case
When a filename changes case, make sure we have the file deleted in the old tree before being extracted into the new one.
Note that we don't try creating a diff if a file is renamed with a different case, just like we don't track file names changing in other ways.
See issue #474
2015-04-03 17:45:43 -04:00
Kornel 729087f696 Merge pull request #511 from grahammiln/imageoptim
Crunching image size with ImageOptim
2015-04-01 17:15:31 +01:00
Graham Miln 7656128c55 Crunching image size with ImageOptim 2015-04-01 17:21:00 +02:00
Kornel 5fe670ce05 Merge pull request #510 from grahammiln/remove-cast
Removing redundate `NSString` cast; see #509
2015-04-01 15:34:54 +01:00
Graham Miln d700b69072 Removing redundate NSString cast; see #590 2015-04-01 16:23:29 +02:00
Kornel ddde2822fa Merge pull request #509 from grahammiln/launch-services
Register update with Launch Services; see #508
2015-04-01 11:20:16 +01:00
Graham Miln a7d11f88c7 Register update with Launch Services; see #508 2015-04-01 11:16:46 +02:00
Kornel e7ed4aa32f Merge pull request #492 from ksuther/french-change
Changed French string for automatically install updates checkbox
2015-03-12 17:06:20 +00:00
Kent Sutherland 090285ec7e Changed French string for automatically install updates as suggested by a French user:
« Automatiquement » before the two verbs is a little akward, not incorrect but unusual. And « à l’avenir » (« in the future » is really not necessary, usually they don’t mention it.
2015-03-12 11:43:15 -04:00
Jake Petroules bc99dbd560 Merge pull request #491 from MaddTheSane/xCode63someFix
Remove binaryDeltaSupported…
2015-02-25 22:47:47 -08:00
Jake Petroules fbd90763f9 Merge pull request #490 from MaddTheSane/modulesToXcconfig
Move the module build settings out of Xcode.
2015-02-25 22:46:53 -08:00
C.W. Betts f88439923f Fix some issues discovered when building on Xcode 6.3:
Remove binaryDeltaSupported, as libxar is no longer weak-linked.
2015-02-25 22:17:23 -07:00
C.W. Betts 8f4ab3eb56 Move the module build settings out of Xcode.
Because all of the other build settings are in the xcconfig files.
2015-02-25 21:51:09 -07:00
Kornel f216ef7a13 Merge pull request #489 from mgunneras/http-headers
Ability to add custom http headers to appcast request
2015-02-26 01:10:55 +00:00
Mattias Gunneras 1db20c4882 Bugfix for setting headers properly, not just key-value pairs on the class 2015-02-25 10:56:56 -05:00
Mattias Gunneras 0a6de47783 Added ability to inject custom http headers in appcast request 2015-02-25 09:42:31 -05:00
Kornel 2a1760a5a9 Merge pull request #482 from sparkle-project/hasLaunched
Always set hasLaunchedBefore
2015-02-08 11:10:47 +00:00
Kornel 65238c35a9 Merge pull request #472 from millerdev/fix-invalid-parameter
Fix invalid parameter error on check for updates
2015-02-08 11:10:32 +00:00
Kornel 5e4e904efd Merge pull request #469 from kainjow/master
Add ability for host bundle to specify a custom name
2015-02-08 11:07:55 +00:00
Kornel 4d6d766a21 Merge pull request #377 from grahammiln/guided-pkg-install
Added headless guided package installation
2015-02-08 11:04:14 +00:00
Kornel 2cb531066c Merge pull request #483 from stel/patch-1
Update podspec for 1.9.0
2015-01-27 08:40:59 +00:00
Dmitry Obukhov e41fbdee49 Update podspec for 1.9.0 2015-01-27 10:52:54 +03:00
Kornel Lesiński c2672cf89c Always set hasLaunchedBefore
Fixes #475
2015-01-25 11:00:23 +00:00
Kornel Lesiński 6146b0a002 Version bump 2015-01-25 10:54:43 +00:00
Kornel ce22598d13 Merge pull request #481 from MaddTheSane/useModules
Have Sparkle build a framework module.
2015-01-22 16:45:20 +00:00
C.W. Betts c067f7a13b Have Sparkle build a framework module. 2015-01-20 14:57:07 -07:00
Kornel Lesiński 89c21b3acd Updated changelog 2015-01-15 09:54:06 +00:00
Kornel Lesiński 2adadf56e1 Explicit @synthesize 2015-01-15 09:41:00 +00:00
Kornel 57530564a6 Merge pull request #446 from tonyarnold/skip-install
Skip installing the framework by default — fixes #419
2015-01-15 09:30:25 +00:00
Kornel 3bebcfdd68 Merge pull request #476 from greenbuffo/master
Fix Autoupdate.app crash on 10.7 (issue #441)
2015-01-14 23:12:36 +00:00
Chris Campbell b5fc2be113 Fix Autoupdate.app crash on 10.7 (issue #441)
Autoupdate.app can crash in the middle of installing an update, leaving
the user with a broken application. The crash is caused by the status
window’s controller (SUStatusController) being prematurely deallocated
before the window is closed. This change prevents such a crash by
keeping a strong reference to the SUStatusController in
TerminationListener.
2015-01-14 11:42:33 -05:00
Daniel Miller a8d96e0dce Fix invalid parameter error on check for updates
reason: Invalid parameter not satisfying: windowNibPath

See https://github.com/sparkle-project/Sparkle/issues/237#issuecomment-11618894
2014-12-31 00:17:46 -05:00
Kornel 6dc6240fab Merge pull request #471 from GerTeunis/master
Using a weak id delegate property will crash during instantiation of NIB on OS X 10.7
2014-12-28 21:05:36 +00:00
Ger Teunis 4aecd9056b Using a weak id delegate will crash during instantiation of NIB on OS X 10.7 2014-12-27 14:05:09 +01:00
Kevin Wojniak 979ab661de Add ability for host bundle to specify a custom name 2014-12-23 08:47:11 -08:00
Kornel fbd20b7084 Merge pull request #442 from sparkle-project/cachedir
Use Library/Caches rather than app support directory
2014-12-23 11:30:38 +00:00
Kornel d695893329 Merge pull request #465 from bitigchi/patch-1
Capital Case Correction
2014-12-22 20:55:48 +00:00
Kornel 8443f88bb2 Merge pull request #466 from bitigchi/patch-2
Small fixes
2014-12-22 20:55:35 +00:00
Kornel acb1568708 Merge pull request #467 from bitigchi/patch-3
Small fixes
2014-12-22 20:55:24 +00:00
Kornel 51581fd3f5 Merge pull request #468 from bitigchi/patch-4
Context fixes
2014-12-22 20:53:47 +00:00
Emir 15b2d6256f Context fixes
Fixed poor spelling and context issues.
2014-12-22 21:08:25 +02:00
Emir 5d2fd5ca6d Small fixes
Capitalisation and context fixes
2014-12-22 21:01:54 +02:00
Emir 6f0e194705 Small fixes
Capitalisation and context fixes
2014-12-22 20:58:33 +02:00
Emir 4f4800bf26 Capital Case Correction
Turkish-lang specific capitalisation correction.
2014-12-22 20:55:16 +02:00
Kornel 1d3d15d5c1 Merge pull request #461 from kylef/lzma
Add support for lzma compressed tarballs
2014-11-23 12:22:36 +00:00
Kyle Fuller f139ccc5e7 Add support for lzma compressed tarballs 2014-11-22 17:16:30 +01:00
Jake Petroules 760a1589ba Merge pull request #456 from vslavik/defer-SUClearLog
Don't call SUClearLog() unless logging something
2014-11-16 11:45:12 -08:00
Václav Slavík b9f987382c Don't call SUClearLog() unless logging something
Don't delete the log file and log app name to it when only checking for
updates - this is something done frequently, on many apps' startup.
Instead, clear the log before writing the first entry to it, so that it
stays untouched if there's nothing to add to it.

Log the application name before the first "real" log entry, instead of
doing it unconditionally every time checkForUpdatesWithDriver: is called.
2014-11-16 17:00:36 +01:00
Jake Petroules 313b146b8e Merge pull request #448 from ivira/master
Proofing of Ukrainian localization.
2014-11-02 11:04:28 -08:00
Jake Petroules 3676feef94 Merge pull request #449 from orzFly/patch-1
Fix a repeated string in Traditional Chinese
2014-11-02 11:01:22 -08:00
Yeechan Lu 7157782c4c Fix a repeated string in Traditional Chinese 2014-11-03 01:22:48 +08:00
Vera Tkachenko f803d31274 Proofing of Ukrainian localization. 2014-11-02 11:36:14 +02:00
Tony Arnold f996ad8e04 Skip installing the framework by default — fixes #419 2014-10-31 13:26:54 +11:00
Jake Petroules 91166ca7ea Merge pull request #445 from tonyarnold/fix-xcode-6.1-warnings
Update LastUpgradeCheck within xcschemes and pbjproject to 0610 for Xcode 6.1
2014-10-30 00:20:08 -07:00
Tony Arnold e1a6467792 Fix warnings under Xcode 6.1 relating the SUUpdateAlert XIB 2014-10-30 12:30:10 +11:00
Tony Arnold 152ed05389 Update LastUpgradeCheck within xcschemes and pbjproject to 0610 for Xcode 6.1 2014-10-30 12:24:53 +11:00
Kornel df57ff045d Merge pull request #444 from kainjow/master
Removed some pragmas
2014-10-27 22:22:30 +00:00
Kevin Wojniak c5868c6eea Removed useless sole pragma mark 2014-10-27 13:55:41 -07:00
Kevin Wojniak ebcbb71e8c Removed outdated SUClearLog comment 2014-10-27 13:54:59 -07:00
Kevin Wojniak a90b075eec Removed use of pragma once in SULog to be consistent with the other headers 2014-10-27 13:54:14 -07:00
Kevin Wojniak f7629eb044 Changed NSSortDescriptor key input to allow for removal of pragma 2014-10-27 13:52:03 -07:00
Kevin Wojniak f1132002b9 Removed pragma which disabled a warning that is no longer shown in Xcode 6.1 2014-10-27 13:51:05 -07:00
Kornel Lesiński 82674cfa9b Use Library/Caches rather than app support directory
Fixes #146
2014-10-20 23:49:33 +01:00
Kornel 096180e879 Merge pull request #439 from erik999/master
Fixed Swedish translations
2014-10-16 13:16:16 +01:00
Erik Vikström be7e968834 Fixing Swedish translations
See https://github.com/sparkle-project/Sparkle/issues/436
2014-10-16 08:59:51 +02:00
Kornel 7fcd8be9d2 Merge pull request #437 from MaddTheSane/exportErrors
Make the error definitions public
2014-10-14 11:57:36 +01:00
C.W. Betts 85f1815d8b Make the error definitions public 2014-10-13 18:24:32 -06:00
Kornel bb5e302980 Merge pull request #434 from codyrobbins/master
Changed a straight apostrophe into a curly one
2014-10-08 01:51:55 -04:00
Cody Robbins 814028cb83 Changed a straight apostrophe into a curly one
Changed the apostrophe in the title of the ‘Don’t Check’ button on the update permissions prompt dialog from a straight one to a curly one.
2014-10-07 14:28:52 -04:00
Kornel 7e1b47976d Merge pull request #432 from yetamrra/master
Add delegate method for errors
2014-10-04 13:38:42 -10:00
Benjamin Gordon feae8bf7b3 Call delegate didAbort in other drivers when showErrors is false. 2014-10-04 16:25:34 -06:00
Benjamin Gordon 7a6d4bd380 Added SUUpdater delegate method for failures. 2014-10-04 16:18:49 -06:00
Kornel 3f9e50d10f Merge pull request #426 from alfwatt/master
Check for a modal window being onscreen before trying to put up the Spar...
2014-09-23 19:30:52 -07:00
Kornel Lesiński ba407a84b9 Updated changelog 2014-09-23 18:57:43 -07:00
Alf Watt 86429ecd50 Check for a modal window being onscreen before trying to put up the Sparkle prompt. 2014-09-23 18:57:10 -07:00
Jake Petroules 0344e2d5fa Add screenshot to README showing Sparkle in action. 2014-09-06 21:51:47 -04:00
Jake Petroules 46f2c07587 Add instructions to the README for building release packages. 2014-08-27 22:15:12 -04:00
Jake Petroules 1690bfa9bd Fix package building for Debug configuration. 2014-08-27 22:03:22 -04:00
Jake Petroules 19c6098d30 Share the distribution scheme and configure it to run tests.
This way, we don't rely on automatic scheme creation in Travis, nor do
we have to update the Makefile for Travis if we want to add an
additional test target to the project.

Also, Travis should now build all targets (including BinaryDelta and
Sparkle Test App), giving us better build coverage.
2014-08-27 21:52:40 -04:00
Jake Petroules ecf602f589 Avoid hardcoded file paths. 2014-08-27 21:37:47 -04:00
Jake Petroules 49721abdaa Add ARM support to the system profiler as OS X might later run on it. 2014-08-27 21:19:09 -04:00
Jake Petroules d7ef18ec91 Use string constants in system profiler. 2014-08-27 21:11:45 -04:00
Jake Petroules 89081ca030 Eliminate a few more string constants. 2014-08-27 20:53:38 -04:00
Jake Petroules 8d74807b23 Use string constants for RSS element and attribute names. 2014-08-27 20:53:27 -04:00
Jake Petroules f72bd52e87 Fix minor spelling error. 2014-08-27 20:48:58 -04:00
Jake Petroules 771a4c9b6b Rename Sparkle appcast keys to make clear elements vs attributes. 2014-08-27 20:08:57 -04:00
Jake Petroules 945a82e9f0 Prefer string constants to strings. 2014-08-27 19:58:10 -04:00
Jake Petroules a4c5e78794 Merge branch 'tamasprezi-tags_fix' 2014-08-27 19:49:39 -04:00
Tamás Lustyik 25cda72d66 Fixed Sparkle tags parsing 2014-08-27 19:49:03 -04:00
Kornel d3c6bd0250 Merge pull request #414 from sparkle-project/visibility
Only export public symbols.
2014-08-26 10:22:21 +01:00
Jake Petroules aa88b40b24 Only export public symbols. 2014-08-25 18:58:12 -04:00
Jake Petroules c87ab4b9c1 Merge pull request #399 from MaddTheSane/errEnum
Have Sparkle’s error codes be defined using NS_ENUM.
2014-08-23 20:41:23 -04:00
Jake Petroules 352aa18377 Merge branch 'kainjow-master' 2014-08-23 20:35:15 -04:00
Jake Petroules 6638b7f9c4 Merge branch 'master' of https://github.com/kainjow/Sparkle into kainjow-master
Conflicts:
	Sparkle/SUUpdater.h
2014-08-23 20:34:49 -04:00
Jake Petroules ec5b2a22c8 Make sure CFBundleVersion is a semantic version number.
CFBundleShortVersionString is now used to embed the Git rev info instead.
2014-08-23 18:03:12 -04:00
Jake Petroules c926aa48f5 Spaces to tabs in Info.plist 2014-08-23 16:44:40 -04:00
Jake Petroules c839ccf916 BinaryDelta: avoid crash with bad paths. 2014-08-23 01:04:41 -04:00
Jake Petroules 0171677513 Fix Clang static analyzer warning.
Closes #385
2014-08-22 23:13:44 -04:00
Jake Petroules 3314d9e3a5 Add Sparkle Appcast attributes as constants. 2014-08-22 22:31:39 -04:00
Jake Petroules 2d33875017 Prefer named constants where available. 2014-08-22 22:04:59 -04:00
Jake Petroules 0ff409a3d9 Improve formatting in license file.
Use a more standard header and fix line length.
2014-08-22 21:50:35 -04:00
Jake Petroules e89d3a7e15 Clean up Autoupdate.m a bit. 2014-08-22 21:37:00 -04:00
Jake Petroules bce54912ee Remove dead code.
Does nothing, not needed.
2014-08-22 21:10:24 -04:00
Jake Petroules 0851dc9a67 Fix regression in SULocalizedString macro. 2014-08-22 20:39:56 -04:00
Jake Petroules bfaeffc8f9 Simplify code path. 2014-08-21 19:53:38 -04:00
Jake Petroules 223436a6b7 Silence direct ivar access warning. 2014-08-21 19:38:21 -04:00
Jake Petroules 8db491ade0 Further reduce macro usage. 2014-08-21 19:25:53 -04:00
Jake Petroules b774241f25 Use Info.plist keys instead of macros.
This helps ensure that all code paths are compiled during development, reducing the chance of build errors (especially in CI). Additionally, developers can change these values without having to rebuild Sparkle (but it is still safe because modifying the plist will break the code-signing seal).
2014-08-21 19:12:29 -04:00
Jake Petroules bb743d80e0 Reduce duplication and macros. 2014-08-21 18:41:16 -04:00
Jake Petroules 888c3d4797 Copy Autoupdate.app in a separate phase. 2014-08-21 18:12:46 -04:00
Jake Petroules 54de8d1f2a Properly set install names and rpaths for targets. 2014-08-21 17:52:35 -04:00
Jake Petroules 68dff7ac81 Keep settings in xcconfig, remove unnecessary ones. 2014-08-21 17:17:58 -04:00
Jake Petroules 83032dc7ac Use proper variables in shell scripts. 2014-08-21 17:14:48 -04:00
Jake Petroules 2820b36d7e Silence warnings in XCTest framework. 2014-08-21 17:01:44 -04:00
Jake Petroules 2a7b94bc9d Add CodeSignOnCopy, RemoveHeadersOnCopy attributes. 2014-08-21 17:01:27 -04:00
Jake Petroules c393d58fe5 Update podspec for v1.8. 2014-08-21 16:46:04 -04:00
Kevin Wojniak 8d8cc35c96 Use standard Denial-of-Service acronym. 2014-08-04 09:17:41 -07:00
C.W. Betts 69bfc27960 Retain binary compatibility with older versions of Sparkle. 2014-08-02 12:38:53 -06:00
C.W. Betts d2ebc47c1e Have Sparkle’s error codes be defined using NS_ENUM.
This has the benefit of setting their size/type (OSStatus), and more usable with Swift.
2014-07-29 20:03:10 -06:00
Kornel Lesiński ee73e4c3e9 Code formatting 2014-07-29 02:05:22 +01:00
Kornel Lesiński 8ecbb25274 Warn when version is missing 2014-07-29 02:05:12 +01:00
Jake Petroules e437b720a4 Merge pull request #398 from MaddTheSane/nsEnumedEnums
Change enums to NS_ENUMs
2014-07-26 17:00:00 -04:00
C.W. Betts b8e28910ba Change SUCharacterType to an NSInteger. 2014-07-26 14:50:49 -06:00
C.W. Betts 852b6e0976 Change ints in NS_ENUMs to NSIntegers. 2014-07-26 11:12:59 -06:00
C.W. Betts b7eb5403ff Replace typedef enums with typedef NS_ENUM.
For one thing, it make Swift happier. Also, we don’t have to worry about what size/type the value is.
2014-07-26 11:03:18 -06:00
grahammiln 21657c9fb1 Added headless guided package installation
Added headless guided installation of pkg and mpkg files. Ported to
using ARC
and inlined documentation. The use of
`AuthorizationExecuteWithPrivileges` should be replaced with an XPC or
assistive external process in a future update. See
https://github.com/sparkle-project/Sparkle/issues/348
2014-07-13 16:53:45 +02:00
151 changed files with 5362 additions and 1447 deletions

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
#DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: foreach,Q_FOREACH
#ForEachMacros: foreach,Q_FOREACH
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
+1 -1
View File
@@ -1,2 +1,2 @@
language: objective-c
script: make travis
script: make ci
+61
View File
@@ -1,3 +1,64 @@
# 1.11.1
* Don't install automatic updates when system is about to shut down
# 1.11.0
* Big improvements to code signing and DSA verification
- Sparkle now checks not only whether an update is correctly signed, but also whether the updated version will be able to verify future updates. Updates now must either use DSA keys correctly, or not try to use them at all. Same goes for Apple Code Signing.
- Rely on code signing and the DSA key in the new app instead of appcast. If the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed. (Zorg)
* More verbose error message when DSA keys don't match (Kornel Lesiński)
* Added delegate methods for pre-download and immediately post-failed-download (Isaac Greenspan)
* Fix Lucida Grande is always used for release notes (LIU Dongyuan / 柳东原)
* Only remove quarantine with setResourceValue: when it's present. Fixes "Unable to quarantine: 93" messages from showing up in the console. (Zorg)
* Fixed const and nullability warnings (Jake Petroules, Kornel Lesiński)
* Replaced deprecated NSRunAlertPanel/alertWithMessageText (Kevin Wojniak)
* Imported the Foundation umbrella header in all the public headers (C.W. Betts)
* pt-BR localization update (Victor Figueiredo)
* Reject unsupported code-signing xattrs in binary delta (Zorg)
* Fixed crash while applying delta update (antonc27)
* Added logging of appcast/download URL on error (Kornel Lesiński)
* More robust reading of Autoupdate.app path from Sparkle bundle
# 1.10.0
* Massive improvements to the BinaryDelta tool (Zorg)
- Ability to track file permissions (Zorg)
- Nicely formatted log output (Zorg)
- Numerous bug fixes in handling of symlinks, empty directories, case-insensitive names, etc. (Zorg)
- Refactored and modernized code (Zorg)
- libxar is no longer weak-linked (C.W. Betts)
* Double-check the code signature of the the app after installation (Isaac Wankerl)
* Added headless guided package installation (Graham Miln)
* Added ability to inject custom HTTP headers in appcast request (Mattias Gunneras)
* Changes to make unarching more reliable (Zorg, Kornel Lesiński)
* Have Sparkle build a framework module (C.W. Betts)
* Stdout used for non error outputs (JDuquennoy)
* French locale update (Kent Sutherland)
# 1.9.0
* Added SUUpdater delegate method for failures. (Benjamin Gordon)
* Make the error definitions public (C.W. Betts)
* Add support for lzma compressed tarballs (Kyle Fuller)
* Back to SKIP_INSTALL=YES by default (Tony Arnold)
* Properly set install names and rpaths for targets (Jake Petroules)
* Use Library/Caches rather than app support directory (Kornel Lesiński)
* Check for a modal window being onscreen before trying to put up the Sparkle prompt (Alf Watt)
* Fixed crashes on 10.7 (Chris Campbell, Ger Teunis)
* Fixed Sparkle tags parsing (Tamás Lustyik)
* SULog code cleanups (Kevin Wojniak)
* Make sure CFBundleVersion is a semantic version number. (Jake Petroules)
* Replace typedef enums with typedef NS_ENUM to make Swift happier (C.W. Betts)
* Fix warnings under Xcode 6.1 relating the SUUpdateAlert XIB (Tony Arnold)
* Prefer string constants to strings (Jake Petroules)
* Use Info.plist keys instead of macros (Jake Petroules)
* Only export public symbols. (Jake Petroules)
* BinaryDelta: avoid crash with bad paths (Jake Petroules)
* Fixing Swedish translations (Erik Vikström)
* Turkish localization fixes (Emir)
* Proofing of Ukrainian localization (Vera Tkachenko)
# 1.8.0
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
@@ -1,4 +1 @@
// BinaryDelta tool only
PRODUCT_NAME = BinaryDelta
GCC_PREFIX_HEADER =
+29 -6
View File
@@ -1,27 +1,47 @@
// Common
FINISH_INSTALL_TOOL_NAME = Autoupdate
SPARKLE_BUNDLE_IDENTIFIER = org.andymatuschak.Sparkle
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
SPARKLE_APPEND_VERSION_NUMBER = 1
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
// if your app has a downgrade function or URL handler, turn this on
SPARKLE_AUTOMATED_DOWNGRADES = 0
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
// following on to always reset the name back to "MyApp":
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 8
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION_MINOR = 11
SPARKLE_VERSION_PATCH = 1
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
ALWAYS_SEARCH_USER_PATHS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 10.7
PRODUCT_NAME = ${TARGET_NAME}
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\"
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)
CLANG_ENABLE_OBJC_ARC = YES
// Enable warnings
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ENABLE_MODULES = YES
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_ASSIGN_ENUM = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
@@ -33,6 +53,9 @@ CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
@@ -59,4 +82,4 @@ GCC_WARN_UNUSED_VARIABLE = YES
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak $(WARNING_CFLAGS_EXTRA)
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
@@ -4,6 +4,7 @@
GCC_OPTIMIZATION_LEVEL = 0
DEBUG_INFORMATION_FORMAT = dwarf
ENABLE_TESTABILITY = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
SPARKLE_EXTRA_DEBUG = -DDEBUG
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
+5 -4
View File
@@ -1,12 +1,13 @@
// Framework only
INSTALL_PATH = @loader_path/../Frameworks
DYLIB_INSTALL_NAME_BASE = @rpath
DYLIB_COMPATIBILITY_VERSION = 1.6
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
PRODUCT_NAME = Sparkle
WRAPPER_EXTENSION = framework
FRAMEWORK_VERSION = A
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
SKIP_INSTALL = YES
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
SKIP_INSTALL = YES
DEFINES_MODULE = YES
PRODUCT_BUNDLE_IDENTIFIER = ${SPARKLE_BUNDLE_IDENTIFIER}
@@ -1,2 +1,4 @@
#include "ConfigFramework.xcconfig"
// Unit tests need access to non-public classes
GCC_SYMBOLS_PRIVATE_EXTERN = NO
+2 -2
View File
@@ -1,8 +1,8 @@
// Relaunch Tool only
INFOPLIST_FILE = Sparkle/Autoupdate/Autoupdate-Info.plist
PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
SKIP_INSTALL = YES
GCC_PREFIX_HEADER = Sparkle/Autoupdate/Autoupdate.pch
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_MODULES = NO
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
+2 -1
View File
@@ -1,7 +1,8 @@
// Test Application only
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
PRODUCT_NAME = Sparkle Test App
WRAPPER_EXTENSION = app
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_OBJC_ARC = NO
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
+4 -1
View File
@@ -1,6 +1,9 @@
// Unit Test only
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
PRODUCT_NAME = Sparkle Unit Tests
WRAPPER_EXTENSION = xctest
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
GCC_SYMBOLS_PRIVATE_EXTERN = NO
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
+8 -3
View File
@@ -9,11 +9,16 @@ 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 -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
# because missing dSYMs in a release build SHOULD trigger a build failure
if [ "$CONFIGURATION" = "Release" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
fi
cd "$CONFIGURATION_BUILD_DIR/staging"
# Sorted file list groups similar files together, which improves tar compression
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
set -e
if ! which -s git ; then
exit 0
fi
if [ -z "$SRCROOT" ] || \
[ -z "$BUILT_PRODUCTS_DIR" ] || \
[ -z "$INFOPLIST_PATH" ] || \
[ -z "$CURRENT_PROJECT_VERSION" ]; then
echo "$0: Must be run from Xcode!" 1>&2
exit 1
fi
# Get the current Git master hash
version=$(cd "$SRCROOT" ; git show-ref --abbrev heads/master | awk '{print $1}')
if [ -z "$version" ] ; then
echo "$0: Can't find a Git hash!" 1>&2
exit 0
fi
version="$CURRENT_PROJECT_VERSION git-$version"
# and use it to set the CFBundleShortVersionString value
export PATH="$PATH:/usr/libexec"
PlistBuddy -c "Set :CFBundleShortVersionString '$version'" \
"$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
+14 -8
View File
@@ -1,9 +1,9 @@
© 2006-2013 Andy Matuschak
© 2009-2013 Elgato Systems GmbH.
© 2011-2014 Kornel Lesiński
© 2014 C.W. Betts
© 2014 Petroules Corporation, Sparkle Project contributors
© 2014 Big Nerd Ranch
Copyright (c) 2006-2013 Andy Matuschak.
Copyright (c) 2009-2013 Elgato Systems GmbH.
Copyright (c) 2011-2014 Kornel Lesiński.
Copyright (c) 2014 C.W. Betts.
Copyright (c) 2014 Petroules Corporation.
Copyright (c) 2014 Big Nerd Ranch.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -27,8 +27,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EXTERNAL LICENSES
=================
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>: © 2003-2005 Colin Percival.
SUDSAVerifier.m: © 2011 Mark Hamlin.
bspatch.c and bsdiff.c, from bsdiff 4.3 <http://www.daemonology.net/bsdiff/>:
Copyright (c) 2003-2005 Colin Percival.
sais.c and sais.c, from sais-lite (2010/08/07) <https://sites.google.com/site/yuta256/sais>:
Copyright (c) 2008-2010 Yuta Mori.
SUDSAVerifier.m:
Copyright (c) 2011 Mark Hamlin.
All rights reserved.
+12 -5
View File
@@ -1,6 +1,8 @@
.PHONY: all localizable-strings release build test travis
.PHONY: all localizable-strings release build test ci
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
ifndef BUILDDIR
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
endif
localizable-strings:
rm -f Sparkle/en.lproj/Sparkle.strings
@@ -9,13 +11,18 @@ localizable-strings:
rm Sparkle/en.lproj/Localizable.strings
release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)"
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
build:
xcodebuild clean build
test:
xcodebuild -target 'Sparkle Unit Tests' -scheme 'Sparkle' test
xcodebuild -scheme Distribution -configuration Debug test
travis: test
ci:
for i in {7..11} ; do \
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test ; \
fi ; \
done
+22 -5
View File
@@ -1,24 +1,26 @@
# Sparkle <img src="Resources/Sparkle.png" width=48 height=48 alt=""/>
is an easy-to-use software update framework for Cocoa developers.
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) <a href='https://app.ship.io/dashboard#/jobs/8814/history' target='_blank'><img src='https://app.ship.io/jobs/V3PoCLcN5ft5Pnq0/build_status.png' height='20' /></a>
[![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle)
An easy-to-use software update framework for Cocoa developers.
<img src="Resources/Screenshot.png" width="715" alt="Sparkle shows familiar update window with release notes">
## Changes since 1.5b
* Up-to-date with 10.10 SDK and Xcode 6. Supports OS X 10.7+.
* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+.
* Cleaned up and modernized code, using ARC and Autolayout.
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
* Ability to mark updates as critical.
* Progress and status notifications for the host app.
* Name of finish_installation.app can be configured to match your app's name.
* Upgraded and more reliable binary delta and code signing verification.
## Features
* 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.
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
* Displays release notes to the user via WebKit.
@@ -28,3 +30,18 @@ is an easy-to-use software update framework for Cocoa developers.
* Optionally sends system information to the server when checking for updates.
* Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products.
* Supports branches due to minimum OS version requirements.
## Developers
Building Sparkle requires Xcode 5 or above.
### API
Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default.
If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples).
### Building the distribution package
`cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed.
Alternatively, build the Distribution scheme in the Xcode UI.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 11 KiB

+6 -6
View File
@@ -1,9 +1,9 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.7.1"
s.version = "1.11.0"
s.summary = "A software update framework for OS X"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "https://github.com/sparkle-project/Sparkle"
s.homepage = "http://sparkle-project.org"
s.license = {
:type => 'MIT',
:file => 'LICENSE'
@@ -15,12 +15,12 @@ Pod::Spec.new do |s|
'Jake Petroules' => 'jake.petroules@petroules.com',
}
s.platform = :osx
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.zip" }
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.public_header_files = 'Sparkle.framework/Headers/*.h'
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_framework = 'Sparkle.framework'
s.resources = 'Sparkle.framework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
s.requires_arc = false
s.requires_arc = true
end
+161 -62
View File
@@ -27,6 +27,16 @@
/* Begin PBXBuildFile section */
1420DF50196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
1420DF51196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
142E0E0019A6954400E4312B /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
142E0E0219A6A14700E4312B /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
142E0E0419A6A26F00E4312B /* Autoupdate.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55C14BB7136EEF1500649790 /* Autoupdate.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */; };
14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; };
14652F7D19A9726700959E44 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E00FD68CC7005AE3F6 /* SUBinaryDeltaApply.m */; };
14652F7E19A9728A00959E44 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
14652F8019A9740F00959E44 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
14652F8219A9746000959E44 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
14652F8419A978C200959E44 /* SUExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 14652F8319A9759F00959E44 /* SUExport.h */; settings = {ATTRIBUTES = (Public, ); }; };
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */; };
14732BD019610A0D00593899 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
14732BD119610A1200593899 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
@@ -37,7 +47,8 @@
14950071195FCE3D00BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
14950072195FCE4B00BC5B5B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
14950073195FCE4E00BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
14950075195FDF5900BC5B5B /* SUUpdaterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */; };
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */ = {isa = PBXBuildFile; fileRef = 14958C6B19AEBC530061B14F /* signed-test-file.txt */; };
14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */ = {isa = PBXBuildFile; fileRef = 14958C6C19AEBC610061B14F /* test-pubkey.pem */; };
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14BD3136EEFCE00649790 /* Autoupdate.m */; };
55C14BD9136EF00C00649790 /* SUStatus.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55C14BD8136EF00C00649790 /* SUStatus.xib */; };
@@ -51,7 +62,6 @@
55C14F08136EF6DB00649790 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
55C14F0C136EF6EA00649790 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; };
55C14F0D136EF6F200649790 /* SUInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5000DAE88B40026945C /* SUInstaller.m */; };
55C14F0F136EF73600649790 /* Autoupdate.pch in Headers */ = {isa = PBXBuildFile; fileRef = 55C14F0E136EF73600649790 /* Autoupdate.pch */; };
55C14F20136EF84300649790 /* SUStatusController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6196CFE409C71ADE000DC222 /* SUStatusController.m */; };
55C14F21136EF84D00649790 /* SUPlainInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5040DAE8AB80026945C /* SUPlainInstaller.m */; };
55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A225A30D1C4AC000430CCD /* SUStandardVersionComparator.m */; };
@@ -59,12 +69,15 @@
55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */; };
55C14F2A136EF9A900649790 /* SUWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61180BC90D64138900B4E0D1 /* SUWindowController.m */; };
55C14F32136EFC2400649790 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55C14F31136EFC2400649790 /* SystemConfiguration.framework */; };
55C14F3B136EFCB300649790 /* Autoupdate.app in Resources */ = {isa = PBXBuildFile; fileRef = 55C14BB7136EEF1500649790 /* Autoupdate.app */; };
55C14F7E136F005000649790 /* SUPlainInstallerInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */; };
55C14F9A136F045400649790 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
55C14FC7136F05E100649790 /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; };
55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 55E6F33219EC9F6C00005E76 /* SUErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
5AF6C1E51AE86A410014A3AB /* SUPipedUnarchiverTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */; };
5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C1E81AE86E270014A3AB /* test archive.zip */; };
5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */; };
5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; };
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; };
5D06E8D80FD68C8E005AE3F6 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */; };
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
@@ -95,18 +108,16 @@
61180BCB0D64138900B4E0D1 /* SUWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61180BC90D64138900B4E0D1 /* SUWindowController.m */; };
6120721209CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */; settings = {ATTRIBUTES = (); }; };
6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */; };
61227A160DB548B800AB99EA /* SUVersionComparisonTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */; };
61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */; settings = {ATTRIBUTES = (); }; };
61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
61299A4A09CA2DD000B7442F /* SUPlainInstallerInternals.h in Headers */ = {isa = PBXBuildFile; fileRef = 6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */; settings = {ATTRIBUTES = (); }; };
61299A5C09CA6D4500B7442F /* SUConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A5B09CA6D4500B7442F /* SUConstants.h */; settings = {ATTRIBUTES = (); }; };
61299A6009CA6EB100B7442F /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
61299A8D09CA790200B7442F /* SUUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A8B09CA790200B7442F /* SUUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
61299A8D09CA790200B7442F /* SUUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A8B09CA790200B7442F /* SUUnarchiver.h */; settings = {ATTRIBUTES = (Private, ); }; };
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A8C09CA790200B7442F /* SUUnarchiver.m */; };
61299B3609CB04E000B7442F /* Sparkle.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299B3509CB04E000B7442F /* Sparkle.h */; settings = {ATTRIBUTES = (Public, ); }; };
612DCBAF0D488BC60015DBEA /* SUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */; settings = {ATTRIBUTES = (); }; };
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */ = {isa = PBXBuildFile; fileRef = 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */; };
61407C390A4099050009F71F /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; };
6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6158A1C4137904B300487EC1 /* SUUpdater_Private.h */; };
615AE3D00D64DC40001CA7BD /* SUModelTranslation.plist in Resources */ = {isa = PBXBuildFile; fileRef = 615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */; };
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */; settings = {ATTRIBUTES = (); }; };
@@ -156,6 +167,20 @@
61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; };
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; };
7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; };
72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; };
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; };
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; };
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; };
F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -253,13 +278,33 @@
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
142E0E0119A6A13300E4312B /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
142E0E0219A6A14700E4312B /* Sparkle.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
142E0E0319A6A24100E4312B /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 12;
files = (
142E0E0419A6A26F00E4312B /* Autoupdate.app in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
61B5FB4D09C4E9FA00B25A18 /* Copy Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
61407C390A4099050009F71F /* Sparkle.framework in Copy Frameworks */,
142E0E0019A6954400E4312B /* Sparkle.framework in Copy Frameworks */,
);
name = "Copy Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -280,6 +325,10 @@
1420DF4D196247B500203BB0 /* build-docs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-docs.sh"; sourceTree = "<group>"; };
1420DF4E196247B500203BB0 /* Doxyfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
1420DF4F196247F900203BB0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaTest.m; sourceTree = "<group>"; };
14652F7919A93E5F00959E44 /* set-git-version-info.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-git-version-info.sh"; sourceTree = "<group>"; };
14652F8319A9759F00959E44 /* SUExport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUExport.h; sourceTree = "<group>"; };
146EC84E19A68CF8004A50C5 /* Sparkle.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Sparkle.podspec; sourceTree = SOURCE_ROOT; };
14732BB1195FF6B700593899 /* .clang-format */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".clang-format"; sourceTree = SOURCE_ROOT; };
14732BB91960EEEE00593899 /* SampleAppcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = SampleAppcast.xml; sourceTree = "<group>"; };
14732BBA1960EF7100593899 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGELOG; sourceTree = SOURCE_ROOT; };
@@ -290,7 +339,9 @@
14732BC41960F3FF00593899 /* sign_update.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update.sh; sourceTree = "<group>"; };
14732BC91960F70A00593899 /* make-release-package.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "make-release-package.sh"; sourceTree = "<group>"; };
14732BD219610A1800593899 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdaterTest.m; path = Tests/SUUpdaterTest.m; sourceTree = "<group>"; usesTabs = 0; };
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdaterTest.m; sourceTree = "<group>"; usesTabs = 0; };
14958C6B19AEBC530061B14F /* signed-test-file.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "signed-test-file.txt"; sourceTree = "<group>"; };
14958C6C19AEBC610061B14F /* test-pubkey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "test-pubkey.pem"; sourceTree = "<group>"; };
3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = "<group>"; };
4607BEA21948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Sparkle.strings; sourceTree = "<group>"; };
4607BEA31948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUAutomaticUpdateAlert.xib; sourceTree = "<group>"; };
@@ -361,10 +412,14 @@
55C14C18136EF2C700649790 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = zh_TW; path = zh_TW.lproj/SUUpdatePermissionPrompt.xib; sourceTree = "<group>"; };
55C14F04136EF6DB00649790 /* SULog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULog.h; sourceTree = "<group>"; };
55C14F05136EF6DB00649790 /* SULog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SULog.m; sourceTree = "<group>"; };
55C14F0E136EF73600649790 /* Autoupdate.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autoupdate.pch; sourceTree = "<group>"; };
55C14F31136EFC2400649790 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
55E6F33219EC9F6C00005E76 /* SUErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUErrors.h; sourceTree = "<group>"; };
5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = "<group>"; };
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUDSAVerifierTest.m; path = Tests/SUDSAVerifierTest.m; sourceTree = "<group>"; };
5AF6C1E81AE86E270014A3AB /* test archive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "test archive.zip"; sourceTree = "<group>"; };
5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPipedUnarchiverTest.m; sourceTree = "<group>"; };
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = "<group>"; };
5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.sparkle_guided.pkg; sourceTree = "<group>"; };
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifierTest.m; sourceTree = "<group>"; };
5D06E8D00FD68C7C005AE3F6 /* BinaryDelta */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = BinaryDelta; sourceTree = BUILT_PRODUCTS_DIR; };
5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */ = {isa = PBXFileReference; comments = "-Wno-shorten-64-to-32"; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bsdiff.c; sourceTree = "<group>"; };
5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bspatch.c; sourceTree = "<group>"; };
@@ -404,8 +459,8 @@
6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateAlert.h; sourceTree = "<group>"; };
6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateAlert.m; sourceTree = "<group>"; };
612279D90DB5470200AB99EA /* Sparkle Unit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Sparkle Unit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "SparkleTests-Info.plist"; path = "Tests/SparkleTests-Info.plist"; sourceTree = "<group>"; };
61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUVersionComparisonTest.m; path = Tests/SUVersionComparisonTest.m; sourceTree = "<group>"; };
612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SparkleTests-Info.plist"; sourceTree = "<group>"; };
61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUVersionComparisonTest.m; sourceTree = "<group>"; };
6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPlainInstallerInternals.h; sourceTree = "<group>"; };
61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDSAVerifier.h; sourceTree = "<group>"; };
61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifier.m; sourceTree = "<group>"; };
@@ -494,8 +549,16 @@
61F614540E24A12D009F47E7 /* it */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Sparkle.strings; sourceTree = "<group>"; };
61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBasicUpdateDriver.h; sourceTree = "<group>"; };
61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBasicUpdateDriver.m; sourceTree = "<group>"; };
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = "<group>"; };
7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = "<group>"; };
767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGuidedPackageInstaller.h; sourceTree = "<group>"; };
767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCodeSigningVerifierTest.m; sourceTree = "<group>"; };
F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SparkleTestCodeSignApp.zip; sourceTree = "<group>"; };
FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkDebug.xcconfig; sourceTree = "<group>"; };
FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigTestAppDebug.xcconfig; sourceTree = "<group>"; };
FA1941CC0D94A70100DD942E /* ConfigCommonRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigCommonRelease.xcconfig; sourceTree = "<group>"; };
@@ -535,7 +598,6 @@
5D1AF58B0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */,
5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */,
5D1AF59A0FD767E50065DB48 /* libz.dylib in Frameworks */,
5D06E8D80FD68C8E005AE3F6 /* Sparkle.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -545,6 +607,9 @@
files = (
14732BD119610A1200593899 /* AppKit.framework in Frameworks */,
14732BD019610A0D00593899 /* Foundation.framework in Frameworks */,
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */,
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */,
14652F8019A9740F00959E44 /* Security.framework in Frameworks */,
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */,
14732BD319610A1800593899 /* XCTest.framework in Frameworks */,
);
@@ -665,6 +730,8 @@
5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */,
5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */,
611142E810FB1BE5009810AA /* bspatch.h */,
7223E7611AD1AEFF008E3161 /* sais.c */,
7223E7621AD1AEFF008E3161 /* sais.h */,
);
path = bsdiff;
sourceTree = "<group>";
@@ -717,12 +784,23 @@
path = Sparkle;
sourceTree = "<group>";
};
14958C7019AEBE350061B14F /* Resources */ = {
isa = PBXGroup;
children = (
14958C6B19AEBC530061B14F /* signed-test-file.txt */,
F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */,
5AF6C1E81AE86E270014A3AB /* test archive.zip */,
14958C6C19AEBC610061B14F /* test-pubkey.pem */,
5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */,
);
path = Resources;
sourceTree = "<group>";
};
55C14BD5136EEFD000649790 /* Autoupdate */ = {
isa = PBXGroup;
children = (
55C14BB9136EEF1500649790 /* Autoupdate-Info.plist */,
55C14BD3136EEFCE00649790 /* Autoupdate.m */,
55C14F0E136EF73600649790 /* Autoupdate.pch */,
);
path = Autoupdate;
sourceTree = "<group>";
@@ -734,6 +812,8 @@
5D06E8E00FD68CC7005AE3F6 /* SUBinaryDeltaApply.m */,
5D06E8E10FD68CC7005AE3F6 /* SUBinaryDeltaCommon.h */,
5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */,
7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */,
7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */,
5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */,
5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */,
5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */,
@@ -759,12 +839,17 @@
61227A100DB5484000AB99EA /* Tests */ = {
isa = PBXGroup;
children = (
14958C7019AEBE350061B14F /* Resources */,
612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */,
142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */,
F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */,
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */,
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */,
5AF6C1EA1AE870A90014A3AB /* SUPipedUnarchiverTest.m */,
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */,
61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */,
);
name = Tests;
path = Tests;
sourceTree = "<group>";
};
61299B3909CB055000B7442F /* Appcast Support */ = {
@@ -804,6 +889,8 @@
618FA6DB0DB485440026945C /* Installation */ = {
isa = PBXGroup;
children = (
767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */,
767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */,
618FA4FF0DAE88B40026945C /* SUInstaller.h */,
618FA5000DAE88B40026945C /* SUInstaller.m */,
618FA5200DAE8E8A0026945C /* SUPackageInstaller.h */,
@@ -823,6 +910,8 @@
61CFB3280E385186007A1735 /* Sparkle.pch */,
61299A5B09CA6D4500B7442F /* SUConstants.h */,
61299A5F09CA6EB100B7442F /* SUConstants.m */,
55E6F33219EC9F6C00005E76 /* SUErrors.h */,
14652F8319A9759F00959E44 /* SUExport.h */,
61EF67580E25C5B400F754E0 /* SUHost.h */,
61EF67550E25B58D00F754E0 /* SUHost.m */,
55C14F04136EF6DB00649790 /* SULog.h */,
@@ -835,10 +924,10 @@
61B5F91D09C4CF7F00B25A18 /* Test Application */ = {
isa = PBXGroup;
children = (
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */,
61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */,
61B5F92409C4CFC900B25A18 /* main.m */,
61B5F92C09C4CFD800B25A18 /* MainMenu.xib */,
14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */,
61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */,
);
name = "Test Application";
@@ -912,6 +1001,8 @@
FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */,
FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */,
14732BC91960F70A00593899 /* make-release-package.sh */,
14652F7919A93E5F00959E44 /* set-git-version-info.sh */,
146EC84E19A68CF8004A50C5 /* Sparkle.podspec */,
);
path = Configurations;
sourceTree = "<group>";
@@ -923,7 +1014,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
55C14F0F136EF73600649790 /* Autoupdate.pch in Headers */,
611142E910FB1BE5009810AA /* bspatch.h in Headers */,
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */,
61299B3609CB04E000B7442F /* Sparkle.h in Headers */,
@@ -938,6 +1028,9 @@
61299A5C09CA6D4500B7442F /* SUConstants.h in Headers */,
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */,
61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */,
55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */,
14652F8419A978C200959E44 /* SUExport.h in Headers */,
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */,
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */,
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */,
55C14F06136EF6DB00649790 /* SULog.h in Headers */,
@@ -1010,6 +1103,7 @@
55C14BB3136EEF1500649790 /* Resources */,
55C14BB4136EEF1500649790 /* Sources */,
55C14BB5136EEF1500649790 /* Frameworks */,
14652F7B19A945D600959E44 /* Run Script: Set Git Version Info */,
);
buildRules = (
);
@@ -1026,7 +1120,6 @@
buildPhases = (
5D06E8CD0FD68C7C005AE3F6 /* Sources */,
5D06E8CE0FD68C7C005AE3F6 /* Frameworks */,
5D06E90D0FD68DA3005AE3F6 /* Fix Install Name */,
);
buildRules = (
);
@@ -1042,9 +1135,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 612279DD0DB5470300AB99EA /* Build configuration list for PBXNativeTarget "Sparkle Unit Tests" */;
buildPhases = (
612279D40DB5470200AB99EA /* Resources */,
612279D50DB5470200AB99EA /* Sources */,
612279D60DB5470200AB99EA /* Frameworks */,
14958C6D19AEBC890061B14F /* Resources */,
142E0E0119A6A13300E4312B /* CopyFiles */,
612279D70DB5470200AB99EA /* ShellScript */,
);
buildRules = (
@@ -1082,9 +1176,10 @@
buildPhases = (
8DC2EF500486A6940098B216 /* Headers */,
8DC2EF520486A6940098B216 /* Resources */,
142E0E0319A6A24100E4312B /* CopyFiles */,
8DC2EF540486A6940098B216 /* Sources */,
8DC2EF560486A6940098B216 /* Frameworks */,
6131B1910DDCDE32005215F0 /* Run Script: Set git Version Info */,
6131B1910DDCDE32005215F0 /* Run Script: Set Git Version Info */,
6195D4B40E40505A00D41A50 /* Run Script: Link fr_CA to fr */,
61E31A85103299750051D188 /* Run Script: Link pt to pt_BR */,
);
@@ -1106,7 +1201,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = SU;
LastUpgradeCheck = 0600;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Sparkle Project";
TargetAttributes = {
612279D80DB5470200AB99EA = {
@@ -1179,6 +1274,18 @@
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
14958C6D19AEBC890061B14F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */,
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */,
5AF6C1E91AE86E270014A3AB /* test archive.zip in Resources */,
14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */,
5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
55C14BB3136EEF1500649790 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1189,21 +1296,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
612279D40DB5470200AB99EA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
61B5F8FE09C4CEE200B25A18 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */,
1420DF50196247F900203BB0 /* Images.xcassets in Resources */,
61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */,
61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */,
14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1211,7 +1311,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
55C14F3B136EFCB300649790 /* Autoupdate.app in Resources */,
61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */,
55C14BEE136EF20D00649790 /* SUAutomaticUpdateAlert.xib in Resources */,
615AE3D00D64DC40001CA7BD /* SUModelTranslation.plist in Resources */,
@@ -1224,20 +1323,20 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
5D06E90D0FD68DA3005AE3F6 /* Fix Install Name */ = {
14652F7B19A945D600959E44 /* Run Script: Set Git Version Info */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Fix Install Name";
name = "Run Script: Set Git Version Info";
outputPaths = (
"$(CONFIGURATION_BUILD_DIR)/BinaryDelta",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "install_name_tool -change \"@loader_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle\" \"@loader_path/Sparkle.framework/Versions/A/Sparkle\" \"${CONFIGURATION_BUILD_DIR}/BinaryDelta\"";
shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\"";
showEnvVarsInLog = 0;
};
612279D70DB5470200AB99EA /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -1253,19 +1352,19 @@
shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
showEnvVarsInLog = 0;
};
6131B1910DDCDE32005215F0 /* Run Script: Set git Version Info */ = {
6131B1910DDCDE32005215F0 /* Run Script: Set Git Version Info */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
);
name = "Run Script: Set git Version Info";
name = "Run Script: Set Git Version Info";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env ruby";
shellScript = "# Xcode auto-versioning script for Subversion\n# by Axel Andersson, modified by Daniel Jalkut to add\n# \"--revision HEAD\" to the svn info line, which allows\n# the latest revision to always be used.\n\nif ENV[\"BUILT_PRODUCTS_DIR\"].nil?\n\tSTDERR.print \"#{$0}: Must be run from Xcode!\"\n\texit(1)\nend\n\n# Get the current Git master hash and use it to set the CFBundleVersion value\nENV[\"PATH\"] = \"/bin:/sw/bin:/usr/local/git/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/opt/local/bin\"\nexit(0) if `type git` == \"\"\nrev = `/usr/bin/env git show-ref --abbrev heads/master`\ninfo = \"#{ENV[\"BUILT_PRODUCTS_DIR\"]}/#{ENV[\"WRAPPER_NAME\"]}/Resources/Info.plist\"\nversion = rev.split(\" \")[0]\n\nif version.nil?\n\tSTDERR.print \"#{$0}: Can't find a Git hash!\"\n\texit(0)\nend\n\ninfo_contents = File.read(info)\nif info_contents.nil?\n\tSTDERR.print \"#{$0}: Can't read in the Info.plist file!\"\n\texit(1)\nend\n\ninfo_contents.sub!(/([\\t ]+<key>CFBundleVersion<\\/key>\\n[\\t ]+<string>).*?(<\\/string>)/, '\\1' + version + '\\2')\nSTDERR.print info_contents\nf = File.open(info, \"w\")\nf.write(info_contents)\nf.close";
shellPath = /bin/sh;
shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\"";
showEnvVarsInLog = 0;
};
6195D4B40E40505A00D41A50 /* Run Script: Link fr_CA to fr */ = {
@@ -1274,15 +1373,15 @@
files = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(WRAPPER_NAME)/Resources/fr.lproj",
"$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/fr.lproj",
);
name = "Run Script: Link fr_CA to fr";
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(WRAPPER_NAME)/Resources/fr_CA.lproj",
"$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/fr_CA.lproj",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env sh";
shellScript = "ln -sfh \"fr.lproj\" \"$BUILT_PRODUCTS_DIR/$WRAPPER_NAME/Resources/fr_CA.lproj\"";
shellScript = "ln -sfh \"fr.lproj\" \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/fr_CA.lproj\"";
showEnvVarsInLog = 0;
};
61E31A85103299750051D188 /* Run Script: Link pt to pt_BR */ = {
@@ -1291,15 +1390,15 @@
files = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(WRAPPER_NAME)/Resources/pt_BR.lproj",
"$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/pt_BR.lproj",
);
name = "Run Script: Link pt to pt_BR";
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(WRAPPER_NAME)/Resources/pt.lproj",
"$(BUILT_PRODUCTS_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/pt.lproj",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/usr/bin/env sh";
shellScript = "ln -sfh \"pt_BR.lproj\" \"$BUILT_PRODUCTS_DIR/$WRAPPER_NAME/Resources/pt.lproj\"";
shellScript = "ln -sfh \"pt_BR.lproj\" \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/pt.lproj\"";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -1310,7 +1409,9 @@
buildActionMask = 2147483647;
files = (
55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */,
F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */,
55C14F00136EF6B700649790 /* SUConstants.m in Sources */,
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */,
55C14F0C136EF6EA00649790 /* SUHost.m in Sources */,
55C14F0D136EF6F200649790 /* SUInstaller.m in Sources */,
55C14F08136EF6DB00649790 /* SULog.m in Sources */,
@@ -1329,6 +1430,11 @@
buildActionMask = 2147483647;
files = (
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */,
14652F7E19A9728A00959E44 /* bspatch.c in Sources */,
7223E7631AD1AEFF008E3161 /* sais.c in Sources */,
14652F7D19A9726700959E44 /* SUBinaryDeltaApply.m in Sources */,
14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */,
7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */,
5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1337,9 +1443,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */,
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */,
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */,
72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */,
142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */,
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */,
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */,
14950075195FDF5900BC5B5B /* SUUpdaterTest.m in Sources */,
61227A160DB548B800AB99EA /* SUVersionComparisonTest.m in Sources */,
5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */,
14652F8219A9746000959E44 /* SULog.m in Sources */,
5AF6C1E51AE86A410014A3AB /* SUPipedUnarchiverTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1369,6 +1482,7 @@
61299A6009CA6EB100B7442F /* SUConstants.m in Sources */,
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */,
61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */,
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */,
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
618FA5020DAE88B40026945C /* SUInstaller.m in Sources */,
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
@@ -1645,14 +1759,12 @@
14950061195FB89500BC5B5B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
14950062195FB89500BC5B5B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
@@ -1674,7 +1786,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */;
buildSettings = {
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
@@ -1717,12 +1828,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Sparkle.framework/Versions/A/Sparkle";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Debug;
};
@@ -1730,12 +1835,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Sparkle.framework/Versions/A/Sparkle";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Release;
};
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "612279D80DB5470200AB99EA"
BuildableName = "Sparkle Unit Tests.xctest"
BlueprintName = "Sparkle Unit Tests"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14732BC51960F69300593899"
BuildableName = "Distribution"
BlueprintName = "Distribution"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
@@ -48,6 +48,8 @@
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
@@ -58,6 +60,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugXPCServices = "NO"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
+55 -65
View File
@@ -18,12 +18,12 @@ static const NSTimeInterval SUInstallationTimeLimit = 5;
*/
static const NSTimeInterval SUParentQuitCheckInterval = .25;
@interface TerminationListener : NSObject <SUInstallerDelegate>
@interface TerminationListener : NSObject
@property (assign) const char *hostpath;
@property (assign) const char *executablepath;
@property (copy) NSString *hostpath;
@property (copy) NSString *executablepath;
@property (assign) pid_t parentprocessid;
@property (assign) const char *folderpath;
@property (copy) NSString *folderpath;
@property (copy) NSString *selfPath;
@property (copy) NSString *installationPath;
@@ -32,6 +32,7 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
@property (strong) SUHost *host;
@property (assign) BOOL shouldRelaunch;
@property (assign) BOOL shouldShowUI;
@property (strong) SUStatusController *statusController;
- (void)parentHasQuit;
@@ -57,27 +58,28 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
@synthesize host;
@synthesize shouldRelaunch;
@synthesize shouldShowUI;
@synthesize statusController;
- (instancetype)initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath:(const char *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
- (instancetype)initWithHostPath:(NSString *)inhostpath executablePath:(NSString *)execpath parentProcessId:(pid_t)ppid folderPath:(NSString *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath
{
if (!(self = [super init])) {
return nil;
}
hostpath = inhostpath;
executablepath = execpath;
parentprocessid = ppid;
folderpath = infolderpath;
selfPath = inSelfPath;
shouldRelaunch = relaunch;
shouldShowUI = showUI;
self.hostpath = inhostpath;
self.executablepath = execpath;
self.parentprocessid = ppid;
self.folderpath = infolderpath;
self.selfPath = inSelfPath;
self.shouldRelaunch = relaunch;
self.shouldShowUI = showUI;
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
if (alreadyTerminated)
[self parentHasQuit];
else
watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES];
return self;
}
@@ -85,7 +87,8 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
- (void)dealloc
{
[longInstallationTimer invalidate];
[self.longInstallationTimer invalidate];
[self.statusController close];
}
@@ -121,8 +124,8 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
if (self.shouldRelaunch)
{
NSString *appPath = nil;
if (!self.folderpath || strcmp(self.executablepath, self.hostpath) != 0)
appPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.executablepath length:strlen(self.executablepath)];
if (!self.folderpath || ![self.executablepath isEqualToString:self.hostpath])
appPath = self.executablepath;
else
appPath = self.installationPath;
[[NSWorkspace sharedWorkspace] openFile:appPath];
@@ -142,7 +145,7 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
- (void)install
{
NSBundle *theBundle = [NSBundle bundleWithPath:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.hostpath length:strlen(self.hostpath)]];
NSBundle *theBundle = [NSBundle bundleWithPath:self.hostpath];
self.host = [[SUHost alloc] initWithBundle:theBundle];
self.installationPath = [[self.host installationPath] copy];
@@ -152,71 +155,58 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
[statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"")
maxProgressValue: 0 statusText: @""];
[statusCtl showWindow:self];
[self.statusController close]; // If there's an existing status controller, close it before we release our strong reference to it.
self.statusController = statusCtl; // Keep a strong reference to the status controller, or else it might get prematurely deallocated.
}
[SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:self.folderpath length:strlen(self.folderpath)]
[SUInstaller installFromUpdateFolder:self.folderpath
overHost:self.host
installationPath:self.installationPath
delegate:self
versionComparator:[SUStandardVersionComparator defaultComparator]];
}
- (void)installerFinishedForHost:(SUHost *)__unused aHost
{
[self relaunch];
}
- (void)installerForHost:(SUHost *)__unused host failedWithError:(NSError *)error __attribute__((noreturn))
{
if (self.shouldShowUI)
NSRunAlertPanel(@"", @"%@", @"OK", @"", @"", [error localizedDescription]);
exit(EXIT_FAILURE);
versionComparator:[SUStandardVersionComparator defaultComparator]
completionHandler:^(NSError *error) {
if (error) {
if (self.shouldShowUI) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
}
exit(EXIT_FAILURE);
} else {
[self relaunch];
}
}];
}
@end
int main(int argc, const char *argv[])
int main(int __unused argc, const char __unused *argv[])
{
if (argc < 5 || argc > 7) {
return EXIT_FAILURE;
}
@autoreleasepool
{
NSArray *args = [[NSProcessInfo processInfo] arguments];
if (args.count < 5 || args.count > 7) {
return EXIT_FAILURE;
}
@autoreleasepool {
//ProcessSerialNumber psn = { 0, kCurrentProcess };
//TransformProcessType( &psn, kProcessTransformToForegroundApplication );
#if 0 // Cmdline tool
NSString* selfPath = nil;
if (argv[0][0] == '/') {
selfPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])];
}
else
{
selfPath = [[NSFileManager defaultManager] currentDirectoryPath];
selfPath = [selfPath stringByAppendingPathComponent: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])]];
}
#else
NSString *selfPath = [[NSBundle mainBundle] bundlePath];
#endif
BOOL shouldShowUI = (argc > 6) ? !!atoi(argv[6]) : YES;
if (shouldShowUI)
{
BOOL shouldShowUI = (args.count > 6) ? [args[6] boolValue] : YES;
if (shouldShowUI) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
[NSApplication sharedApplication];
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:(argc > 1) ? argv[1] : NULL
executablePath:(argc > 2) ? argv[2] : NULL
parentProcessId:(argc > 3) ? atoi(argv[3]) : 0
folderPath:(argc > 4) ? argv[4] : NULL
shouldRelaunch:(argc > 5) ? !!atoi(argv[5]) : YES
TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:args[1]
executablePath:args[2]
parentProcessId:[args[3] intValue]
folderPath:args[4]
shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES
shouldShowUI:shouldShowUI
selfPath:selfPath];
selfPath:[[NSBundle mainBundle] bundlePath]];
[termListen class];
[[NSApplication sharedApplication] run];
// Ensure termListen is not deallocated by ARC before caling -[NSApplication run]
[termListen class];
}
return EXIT_SUCCESS;
-16
View File
@@ -1,16 +0,0 @@
//
// Sparkle.pch
// Sparkle
//
// Created by Andy Matuschak on 7/23/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#define SPARKLE_BUNDLE [NSBundle mainBundle]
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#import "SUConstants.h"
#endif
+5 -9
View File
@@ -9,22 +9,18 @@
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
@protocol SUAppcastDelegate;
#import <Foundation/Foundation.h>
#import "SUExport.h"
@class SUAppcastItem;
@interface SUAppcast : NSObject <NSURLDownloadDelegate>
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
@property (weak) id<SUAppcastDelegate> delegate;
@property (copy) NSString *userAgentString;
@property (copy) NSDictionary *httpHeaders;
- (void)fetchAppcastFromURL:(NSURL *)url;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
@property (readonly, copy) NSArray *items;
@end
@protocol SUAppcastDelegate <NSObject>
- (void)appcastDidFinishLoading:(SUAppcast *)appcast;
- (void)appcast:(SUAppcast *)appcast failedToLoadWithError:(NSError *)error;
@end
#endif
+55 -26
View File
@@ -26,13 +26,18 @@
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSXMLNode *attribute in attributeEnum) {
dictionary[[attribute name]] = [attribute stringValue];
NSString *attrName = [attribute name];
if (!attrName) {
continue;
}
dictionary[attrName] = [attribute stringValue];
}
return dictionary;
}
@end
@interface SUAppcast () <NSURLDownloadDelegate>
@property (strong) void (^completionBlock)(NSError *);
@property (copy) NSString *downloadFilename;
@property (strong) NSURLDownload *download;
@property (copy) NSArray *items;
@@ -43,18 +48,28 @@
@implementation SUAppcast
@synthesize downloadFilename;
@synthesize delegate;
@synthesize completionBlock;
@synthesize userAgentString;
@synthesize httpHeaders;
@synthesize download;
@synthesize items;
- (void)fetchAppcastFromURL:(NSURL *)url
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))block
{
self.completionBlock = block;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
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];
[request setValue:value forHTTPHeaderField:key];
}
}
[request setValue:@"application/rss+xml,*/*;q=0.1" forHTTPHeaderField:@"Accept"];
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
@@ -145,30 +160,43 @@
for (NSString *name in nodesDict)
{
node = [self bestNodeInNodes:nodesDict[name]];
if ([name isEqualToString:@"enclosure"])
if ([name isEqualToString:SURSSElementEnclosure])
{
// enclosure is flattened as a separate dictionary for some reason
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
dict[@"enclosure"] = encDict;
dict[name] = encDict;
}
else if ([name isEqualToString:@"pubDate"])
else if ([name isEqualToString:SURSSElementPubDate])
{
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
if (date)
dict[name] = date;
NSString *string = node.stringValue;
if (string) {
NSDate *date = [NSDate dateWithNaturalLanguageString:string];
if (date)
dict[name] = date;
}
}
else if ([name isEqualToString:@"sparkle:deltas"])
else if ([name isEqualToString:SUAppcastElementDeltas])
{
NSMutableArray *deltas = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
if ([[child name] isEqualToString:@"enclosure"])
if ([[child name] isEqualToString:SURSSElementEnclosure])
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
}
dict[@"deltas"] = deltas;
dict[name] = deltas;
}
else if ([name isEqualToString:SUAppcastElementTags]) {
NSMutableArray *tags = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
NSString *childName = child.name;
if (childName)
[tags addObject:childName];
}
dict[name] = tags;
}
else if (name != nil)
{
// add all other values as strings
@@ -194,27 +222,23 @@
}
}
if ([appcastItems count])
{
if ([appcastItems count]) {
NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
[appcastItems sortUsingDescriptors:@[sort]];
self.items = appcastItems;
}
if (failed)
{
if (failed) {
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while parsing the update feed.", nil) }]];
}
else if ([self.delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
{
[self.delegate appcastDidFinishLoading:self];
} else {
self.completionBlock(nil);
self.completionBlock = nil;
}
}
- (void)download:(NSURLDownload *)__unused aDownload didFailWithError:(NSError *)error
{
if (self.downloadFilename)
{
if (self.downloadFilename) {
[[NSFileManager defaultManager] removeItemAtPath:self.downloadFilename error:nil];
}
self.downloadFilename = nil;
@@ -229,10 +253,15 @@
- (void)reportError:(NSError *)error
{
if ([self.delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
{
[self.delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
}
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
}]);
self.completionBlock = nil;
}
- (NSXMLNode *)bestNodeInNodes:(NSArray *)nodes
+4 -1
View File
@@ -9,7 +9,10 @@
#ifndef SUAPPCASTITEM_H
#define SUAPPCASTITEM_H
@interface SUAppcastItem : NSObject
#import <Foundation/Foundation.h>
#import "SUExport.h"
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
@property (copy, readonly) NSDate *date;
@property (copy, readonly) NSString *itemDescription;
+56 -49
View File
@@ -47,12 +47,12 @@
- (BOOL)isDeltaUpdate
{
return self.propertiesDictionary[@"enclosure"][@"sparkle:deltaFrom"] != nil;
return self.propertiesDictionary[SURSSElementEnclosure][SUAppcastAttributeDeltaFrom] != nil;
}
- (BOOL)isCriticalUpdate
{
return [self.propertiesDictionary[@"sparkle:tags"] containsObject:@"sparkle:criticalUpdate"];
return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict
@@ -63,9 +63,8 @@
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error
{
self = [super init];
if (self)
{
id enclosure = dict[@"enclosure"];
if (self) {
id enclosure = dict[SURSSElementEnclosure];
// Try to find a version string.
// Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
@@ -75,51 +74,54 @@
// underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
// The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
// Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
NSString *newVersion = enclosure[@"sparkle:version"];
if (newVersion == nil)
newVersion = dict[@"sparkle:version"]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
NSString *newVersion = enclosure[SUAppcastAttributeVersion];
if (newVersion == nil) {
newVersion = dict[SUAppcastAttributeVersion]; // Get version from the item, in case it's a download-less item (i.e. paid upgrade).
}
if (newVersion == nil) // no sparkle:version attribute anywhere?
{
SULog(@"warning: <%@> for URL '%@' is missing %@ attribute. Version comparison may be unreliable. Please always specify %@", SURSSElementEnclosure, enclosure[SURSSAttributeURL], SUAppcastAttributeVersion, SUAppcastAttributeVersion);
// Separate the url by underscores and take the last component, as that'll be closest to the end,
// then we remove the extension. Hopefully, this will be the version.
NSArray *fileComponents = [enclosure[@"url"] componentsSeparatedByString:@"_"];
if ([fileComponents count] > 1)
NSArray *fileComponents = [enclosure[SURSSAttributeURL] componentsSeparatedByString:@"_"];
if ([fileComponents count] > 1) {
newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
}
}
if(!newVersion )
{
if (error)
*error = @"Feed item lacks sparkle:version attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)";
if (!newVersion) {
if (error) {
*error = [NSString stringWithFormat:@"Feed item lacks %@ attribute, and version couldn't be deduced from file name (would have used last component of a file name like AppName_1.3.4.zip)", SUAppcastAttributeVersion];
}
return nil;
}
propertiesDictionary = [[NSMutableDictionary alloc] initWithDictionary:dict];
self.title = dict[@"title"];
self.date = dict[@"pubDate"];
self.itemDescription = dict[@"description"];
self.title = dict[SURSSElementTitle];
self.date = dict[SURSSElementPubDate];
self.itemDescription = dict[SURSSElementDescription];
NSString *theInfoURL = dict[@"link"];
if( theInfoURL )
{
if (![theInfoURL isKindOfClass:[NSString class]])
SULog(@"SUAppcastItem -initWithDictionary: Info URL is not of valid type.");
else
NSString *theInfoURL = dict[SURSSElementLink];
if (theInfoURL) {
if (![theInfoURL isKindOfClass:[NSString class]]) {
SULog(@"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
} else {
self.infoURL = [NSURL URLWithString:theInfoURL];
}
}
// Need an info URL or an enclosure URL. Former to show "More Info"
// page, latter to download & install:
if( !enclosure && !theInfoURL )
{
if (error)
if (!enclosure && !theInfoURL) {
if (error) {
*error = @"No enclosure in feed item";
}
return nil;
}
NSString *enclosureURLString = enclosure[@"url"];
if( !enclosureURLString && !theInfoURL )
{
NSString *enclosureURLString = enclosure[SURSSAttributeURL];
if (!enclosureURLString && !theInfoURL) {
if (error) {
*error = @"Feed item's enclosure lacks URL";
}
@@ -131,42 +133,47 @@
self.fileURL = [NSURL URLWithString:fileURLString];
}
if (enclosure) {
self.DSASignature = enclosure[@"sparkle:dsaSignature"];
self.DSASignature = enclosure[SUAppcastAttributeDSASignature];
}
self.versionString = newVersion;
self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"];
self.maximumSystemVersion = dict[@"sparkle:maximumSystemVersion"];
self.minimumSystemVersion = dict[SUAppcastElementMinimumSystemVersion];
self.maximumSystemVersion = dict[SUAppcastElementMaximumSystemVersion];
NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"];
NSString *shortVersionString = enclosure[SUAppcastAttributeShortVersionString];
if (nil == shortVersionString) {
shortVersionString = dict[@"sparkle:shortVersionString"]; // fall back on the <item>
shortVersionString = dict[SUAppcastAttributeShortVersionString]; // fall back on the <item>
}
if (shortVersionString)
if (shortVersionString) {
self.displayVersionString = shortVersionString;
else
self.displayVersionString = [self versionString];
} else {
self.displayVersionString = self.versionString;
}
// Find the appropriate release notes URL.
if (dict[@"sparkle:releaseNotesLink"])
self.releaseNotesURL = [NSURL URLWithString:dict[@"sparkle:releaseNotesLink"]];
else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) // if the description starts with http:// or https:// use that.
NSString *releaseNotesString = dict[SUAppcastElementReleaseNotesLink];
if (releaseNotesString) {
self.releaseNotesURL = [NSURL URLWithString:releaseNotesString];
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
else
} else {
self.releaseNotesURL = nil;
}
if (dict[@"deltas"])
{
NSArray *deltaDictionaries = dict[SUAppcastElementDeltas];
if (deltaDictionaries) {
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
NSArray *deltaDictionaries = dict[@"deltas"];
for (NSDictionary *deltaDictionary in deltaDictionaries) {
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
[fakeAppCastDict removeObjectForKey:@"deltas"];
fakeAppCastDict[@"enclosure"] = deltaDictionary;
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
NSString *deltaFrom = deltaDictionary[SUAppcastAttributeDeltaFrom];
if (!deltaFrom) continue;
deltas[deltaDictionary[@"sparkle:deltaFrom"]] = deltaItem;
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary;
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
deltas[deltaFrom] = deltaItem;
}
self.deltaUpdates = deltas;
}
+3 -10
View File
@@ -11,27 +11,20 @@
#import "SUWindowController.h"
@protocol SUAutomaticUpdateAlertDelegate;
typedef enum
{
typedef NS_ENUM(NSInteger, SUAutomaticInstallationChoice) {
SUInstallNowChoice,
SUInstallLaterChoice,
SUDoNotInstallChoice
} SUAutomaticInstallationChoice;
};
@class SUAppcastItem, SUHost;
@interface SUAutomaticUpdateAlert : SUWindowController
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle delegate:(id<SUAutomaticUpdateAlertDelegate>)delegate;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)hostBundle completionBlock:(void (^)(SUAutomaticInstallationChoice))c;
- (IBAction)installNow:sender;
- (IBAction)installLater:sender;
- (IBAction)doNotInstall:sender;
@end
@protocol SUAutomaticUpdateAlertDelegate <NSObject>
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)aua finishedWithChoice:(SUAutomaticInstallationChoice)choice;
@end
#endif
+15 -13
View File
@@ -11,23 +11,22 @@
#import "SUHost.h"
@interface SUAutomaticUpdateAlert ()
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
@property (strong) SUAppcastItem *updateItem;
@property (weak) id<SUAutomaticUpdateAlertDelegate> delegate;
@property (strong) SUHost *host;
@end
@implementation SUAutomaticUpdateAlert
@synthesize delegate;
@synthesize host;
@synthesize updateItem;
@synthesize completionBlock;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost delegate:(id<SUAutomaticUpdateAlertDelegate>)del
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
{
self = [super initWithHost:aHost windowNibName:@"SUAutomaticUpdateAlert"];
if (self)
{
self = [super initWithWindowNibName:@"SUAutomaticUpdateAlert"];
if (self) {
self.updateItem = item;
self.delegate = del;
self.completionBlock = block;
self.host = aHost;
[self setShouldCascadeWindows:NO];
[[self window] center];
@@ -35,32 +34,35 @@
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (IBAction)installNow:(id)__unused sender
{
[self close];
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUInstallNowChoice];
self.completionBlock(SUInstallNowChoice);
self.completionBlock = nil;
}
- (IBAction)installLater:(id)__unused sender
{
[self close];
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUInstallLaterChoice];
self.completionBlock(SUInstallLaterChoice);
self.completionBlock = nil;
}
- (IBAction)doNotInstall:(id)__unused sender
{
[self close];
[self.delegate automaticUpdateAlert:self finishedWithChoice:SUDoNotInstallChoice];
self.completionBlock(SUDoNotInstallChoice);
self.completionBlock = nil;
}
- (NSImage *)applicationIcon
- (NSImage *__nonnull)applicationIcon
{
return [self.host icon];
}
- (NSString *)titleText
- (NSString *__nonnull)titleText
{
if ([self.updateItem isCriticalUpdate])
{
+1 -1
View File
@@ -13,7 +13,7 @@
#import "SUBasicUpdateDriver.h"
#import "SUAutomaticUpdateAlert.h"
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUAutomaticUpdateAlertDelegate>
@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
@end
+27 -9
View File
@@ -42,13 +42,14 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)showUpdateAlert
{
self.interruptible = NO;
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host delegate:self];
self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) {
[self automaticUpdateAlertFinishedWithChoice:choice];
}];
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([self.host isBackgroundApplication])
{
if ([self.host isBackgroundApplication]) {
[[self.alert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
@@ -62,6 +63,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
// Sudden termination is available on 10.6+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
@@ -102,6 +104,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
if (self.willUpdateOnTermination)
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil];
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
[processInfo enableSuddenTermination];
@@ -135,10 +139,10 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
{
[[self.alert window] makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)automaticUpdateAlert:(SUAutomaticUpdateAlert *)__unused aua finishedWithChoice:(SUAutomaticInstallationChoice)choice
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
{
switch (choice)
{
@@ -150,6 +154,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
case SUInstallLaterChoice:
self.postponingInstallation = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil];
// We're already waiting on quit, just indicate that we're idle.
self.interruptible = YES;
break;
@@ -161,8 +166,6 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
}
}
- (BOOL)shouldInstallSynchronously { return self.postponingInstallation; }
- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI
{
if (relaunch) {
@@ -173,6 +176,13 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
[super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI];
}
- (void)systemWillPowerOff:(NSNotification *)__unused note
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil)
}]];
}
- (void)applicationWillTerminate:(NSNotification *)__unused note
{
[self installWithToolAndRelaunch:NO];
@@ -180,10 +190,18 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)abortUpdateWithError:(NSError *)error
{
if (self.showErrors)
if (self.showErrors) {
[super abortUpdateWithError:error];
else
} 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
+2 -1
View File
@@ -15,7 +15,7 @@
#import "SUAppcast.h"
@class SUAppcastItem, SUHost;
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate, SUAppcastDelegate>
@interface SUBasicUpdateDriver : SUUpdateDriver <NSURLDownloadDelegate, SUUnarchiverDelegate>
@property (strong, readonly) SUAppcastItem *updateItem;
@property (strong, readonly) NSURLDownload *download;
@@ -27,6 +27,7 @@
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
- (void)didFindValidUpdate;
- (void)didNotFindUpdate;
+142 -64
View File
@@ -21,15 +21,6 @@
#import "SUCodeSigningVerifier.h"
#import "SUUpdater_Private.h"
#ifdef FINISH_INSTALL_TOOL_NAME
// FINISH_INSTALL_TOOL_NAME expands to unquoted Autoupdate
#define QUOTE_NS_STRING2(str) @"" #str
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
#else
#error FINISH_INSTALL_TOOL_NAME not defined
#endif
@interface SUBasicUpdateDriver ()
@property (strong) SUAppcastItem *updateItem;
@@ -63,9 +54,15 @@
SUAppcast *appcast = [[SUAppcast alloc] init];
[appcast setDelegate:self];
[appcast setUserAgentString:[self.updater userAgentString]];
[appcast fetchAppcastFromURL:URL];
[appcast setHttpHeaders:[self.updater httpHeaders]];
[appcast fetchAppcastFromURL:URL completionBlock:^(NSError *error) {
if (error) {
[self abortUpdateWithError:error];
} else {
[self appcastDidFinishLoading:appcast];
}
}];
}
- (id<SUVersionComparison>)versionComparator
@@ -145,12 +142,10 @@
item = [updateEnumerator nextObject];
} while (item && ![self hostSupportsItem:item]);
if (binaryDeltaSupported()) {
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]];
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
self.nonDeltaUpdateItem = item;
item = deltaUpdateItem;
}
SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]];
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
self.nonDeltaUpdateItem = item;
item = deltaUpdateItem;
}
}
@@ -163,11 +158,6 @@
}
}
- (void)appcast:(SUAppcast *)__unused ac failedToLoadWithError:(NSError *)error
{
[self abortUpdateWithError:error];
}
- (void)didFindValidUpdate
{
assert(self.updateItem);
@@ -201,6 +191,11 @@
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[[self.updater delegate] updater:self.updater
willDownloadUpdate:self.updateItem
withRequest:request];
}
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
@@ -209,11 +204,11 @@
NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [self.host name], [self.updateItem versionString]];
self.tempDir = [[self.host appSupportPath] stringByAppendingPathComponent:downloadFileName];
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:downloadFileName];
int cnt = 1;
while ([[NSFileManager defaultManager] fileExistsAtPath:self.tempDir] && cnt <= 999)
{
self.tempDir = [[self.host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
self.tempDir = [self.host.appCachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]];
}
// Create the temporary directory if necessary.
@@ -229,29 +224,81 @@
[self.download setDestination:self.downloadPath allowOverwrite:YES];
}
/**
* If the update is a package, then it must be signed using DSA. No other verification is done.
*
* If the update is a bundle, then it must meet any one of:
*
* * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or
*
* * old and new Code Signing identity are the same and valid
*
*/
- (BOOL)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
{
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:self.host];
BOOL isPackage = NO;
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
if (installSourcePath == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
return NO;
}
// Modern packages are not distributed as bundles and are code signed differently than regular applications
if (isPackage) {
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
if (newBundlePath) {
if ([SUCodeSigningVerifier hostApplicationIsCodeSigned]) {
NSError *error = nil;
if ([SUCodeSigningVerifier codeSignatureIsValidAtPath:newBundlePath error:&error]) {
return YES;
} else {
SULog(@"Code signature check on update failed: %@. Sparkle will use DSA signature instead.", error);
}
} else {
SULog(@"The host app is not signed using Apple Code Signing, and therefore cannot verify updates this way. Sparkle will use DSA signature instead.");
if (!packageValidated) {
SULog(@"DSA signature validation of the package failed. The update will be rejected.");
}
return packageValidated;
}
NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath];
if (newBundle == nil) {
SULog(@"No suitable bundle is found in the update. The update will be rejected.");
return NO;
}
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
NSString *newPublicDSAKey = newHost.publicDSAKey;
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
if (newPublicDSAKey != nil) {
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
return NO;
}
}
BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath];
if (dsaKeysMatch) {
NSError *error = nil;
if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) {
SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error);
return NO;
}
} else {
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
if (!hostIsCodeSigned || !updateIsCodeSigned) {
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
return NO;
}
NSError *error = nil;
if (![SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:installSourcePath error:&error]) {
SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error);
return NO;
}
}
if (DSASignature) {
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
} else {
SULog(@"The appcast item for the update has no DSA signature. The update will be rejected, because both DSA and Apple Code Signing verification failed.");
return NO;
}
return YES;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
@@ -263,7 +310,22 @@
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
if (!failingUrl) {
failingUrl = [self.updateItem fileURL];
}
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[[self.updater delegate] updater:self.updater
failedToDownloadUpdate:self.updateItem
error:error];
}
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
}]];
}
- (BOOL)download:(NSURLDownload *)__unused download shouldDecodeSourceDataOfMIMEType:(NSString *)encodingType
@@ -275,14 +337,13 @@
- (void)extractUpdate
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHost:self.host];
if (!unarchiver)
{
SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath]];
if (!unarchiver) {
SULog(@"Error: No valid unarchiver for %@!", self.downloadPath);
[self unarchiverDidFail:nil];
return;
}
[unarchiver setDelegate:self];
unarchiver.delegate = self;
[unarchiver start];
}
@@ -312,8 +373,6 @@
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]];
}
- (BOOL)shouldInstallSynchronously { return NO; }
- (void)installWithToolAndRelaunch:(BOOL)relaunch
{
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
@@ -360,32 +419,39 @@
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;
NSBundle *sparkleBundle = self.updater.sparkleBundle;
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
if (relaunchPathToCopy != nil)
{
NSString *targetPath = [[self.host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
if (relaunchPathToCopy != nil) {
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error])
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
self.relaunchPath = targetPath;
else
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]}]];
} else {
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
}]];
}
}
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
[updaterDelegate updaterWillRelaunchApplication:self.updater];
if(!self.relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.relaunchPath])
{
NSString *relaunchToolPath = [[NSBundle bundleWithPath:self.relaunchPath] executablePath];
if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.relaunchPath]) {
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]], NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]}]];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]
}]];
// We intentionally don't abandon the update here so that the host won't initiate another.
return;
}
@@ -394,7 +460,6 @@
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
}
NSString *relaunchToolPath = [[self.relaunchPath stringByAppendingPathComponent:@"/Contents/MacOS"] stringByAppendingPathComponent:finishInstallToolName];
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
@@ -423,10 +488,16 @@
- (void)installerForHost:(SUHost *)aHost failedWithError:(NSError *)error
{
if (aHost != self.host) { return; }
if (aHost != self.host) {
return;
}
NSError *dontThrow = nil;
[[NSFileManager defaultManager] removeItemAtPath:self.relaunchPath error:&dontThrow]; // Clean up the copied relauncher
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil), NSLocalizedFailureReasonErrorKey: [error localizedDescription]}]];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while installing the update. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
}]];
}
- (void)abortUpdate
@@ -440,11 +511,18 @@
- (void)abortUpdateWithError:(NSError *)error
{
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
SULog(@"Error: %@ %@", [error localizedDescription], [error localizedFailureReason]);
SULog(@"Error: %@ %@ (URL %@)", error.localizedDescription, error.localizedFailureReason, error.userInfo[NSURLErrorFailingURLErrorKey]);
}
if (self.download) {
[self.download cancel];
}
// Notify host app that update has aborted
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
if ([updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) {
[updaterDelegate updater:self.updater didAbortWithError:error];
}
[self abortUpdate];
}
+1 -1
View File
@@ -10,6 +10,6 @@
#define SUBINARYDELTAAPPLY_H
@class NSString;
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile);
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose);
#endif
+159 -34
View File
@@ -10,62 +10,130 @@
#import "SUBinaryDeltaCommon.h"
#include <CommonCrypto/CommonDigest.h>
#import <Foundation/Foundation.h>
#include <bspatch.h>
#include "bspatch.h"
#include <stdio.h>
#include <stdlib.h>
#include <xar/xar.h>
static void applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFilePath, NSString *destinationFilePath)
{
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
bspatch(4, (char **)argv);
BOOL success = (bspatch(4, argv) == 0);
unlink([patchFile fileSystemRepresentation]);
return success;
}
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile)
int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose)
{
xar_t x = xar_open([patchFile UTF8String], READ);
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
if (!x) {
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile UTF8String]);
fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile fileSystemRepresentation]);
return 1;
}
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
NSString *expectedBeforeHash = nil;
NSString *expectedAfterHash = nil;
NSString *expectedBeforeHashv1 = nil;
NSString *expectedAfterHashv1 = nil;
NSString *expectedNewBeforeHash = nil;
NSString *expectedNewAfterHash = nil;
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (!strcmp(xar_subdoc_name(subdoc), "binary-delta-attributes")) {
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
const char *value = 0;
xar_subdoc_prop_get(subdoc, "before-sha1", &value);
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
if (value)
expectedBeforeHash = @(value);
xar_subdoc_prop_get(subdoc, "after-sha1", &value);
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
if (value)
expectedAfterHash = @(value);
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
if (value)
expectedNewBeforeHash = @(value);
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
if (value)
expectedNewAfterHash = @(value);
// only available in version 1.0
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_OLD_KEY, &value);
if (value)
expectedBeforeHashv1 = @(value);
// only available in version 1.0
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_OLD_KEY, &value);
if (value)
expectedAfterHashv1 = @(value);
}
}
if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "Unable to identify diff-version %u in delta. Giving up.\n", majorDiffVersion);
return 1;
}
if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "A later version is needed to apply this patch (on major version %u, but patch requests version %u).\n", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion);
return 1;
}
BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
NSString *expectedBeforeHash = usesNewTreeHash ? expectedNewBeforeHash : expectedBeforeHashv1;
NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1;
if (!expectedBeforeHash || !expectedAfterHash) {
fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n");
return 1;
}
fprintf(stderr, "Verifying source... ");
NSString *beforeHash = hashOfTree(source);
if (![beforeHash isEqualToString:expectedBeforeHash]) {
fprintf(stderr, "Source doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
if (verbose) {
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
fprintf(stderr, "Verifying source...");
}
NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion);
if (!beforeHash) {
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [source fileSystemRepresentation]);
return 1;
}
fprintf(stderr, "\nCopying files... ");
removeTree(destination);
copyTree(source, destination);
if (![beforeHash isEqualToString:expectedBeforeHash]) {
fprintf(stderr, "\nSource doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]);
return 1;
}
fprintf(stderr, "\nPatching... ");
if (verbose) {
fprintf(stderr, "\nCopying files...");
}
if (!removeTree(destination)) {
fprintf(stderr, "\nFailed to remove %s\n", [destination fileSystemRepresentation]);
return 1;
}
if (!copyTree(source, destination)) {
fprintf(stderr, "\nFailed to copy %s to %s\n", [source fileSystemRepresentation], [destination fileSystemRepresentation]);
return 1;
}
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
if (verbose) {
fprintf(stderr, "\nPatching...");
}
NSFileManager *fileManager = [[NSFileManager alloc] init];
xar_file_t file;
xar_iter_t iter = xar_iter_new();
for (file = xar_file_first(x, iter); file; file = xar_file_next(iter)) {
@@ -73,29 +141,86 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
NSString *sourceFilePath = [source stringByAppendingPathComponent:path];
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
BOOL removedFile = NO;
const char *value;
if (!xar_prop_get(file, "delete", &value) || !xar_prop_get(file, "delete-then-extract", &value)) {
removeTree(destinationFilePath);
if (!xar_prop_get(file, "delete", &value))
if (!xar_prop_get(file, DELETE_KEY, &value) ||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
if (!removeTree(destinationFilePath)) {
fprintf(stderr, "\n%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_OLD_KEY, [destination fileSystemRepresentation]);
return 1;
}
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
if (verbose) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
}
continue;
}
removedFile = YES;
}
if (!xar_prop_get(file, "binary-delta", &value))
applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath);
else
xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]);
if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) {
if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) {
fprintf(stderr, "\nUnable to patch %s to destination %s\n", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation]);
return 1;
}
if (verbose) {
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
}
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) ||
(!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) {
fprintf(stderr, "\nUnable to extract file to %s\n", [destinationFilePath fileSystemRepresentation]);
return 1;
}
if (verbose) {
if (fileExisted) {
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
} else {
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [path fileSystemRepresentation]);
}
}
} else if (verbose && removedFile) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
}
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue];
if (!modifyPermissions(destinationFilePath, mode)) {
fprintf(stderr, "\nUnable to modify permissions (%s) on file %s\n", value, [destinationFilePath fileSystemRepresentation]);
return 1;
}
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
}
}
}
xar_close(x);
fprintf(stderr, "\nVerifying destination... ");
NSString *afterHash = hashOfTree(destination);
if (verbose) {
fprintf(stderr, "\nVerifying destination...");
}
NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion);
if (!afterHash) {
fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [destination fileSystemRepresentation]);
return 1;
}
if (![afterHash isEqualToString:expectedAfterHash]) {
fprintf(stderr, "Destination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
fprintf(stderr, "\nDestination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]);
removeTree(destination);
return 1;
}
fprintf(stderr, "\nDone!\n");
if (verbose) {
fprintf(stderr, "\nDone!\n");
}
return 0;
}
+64 -6
View File
@@ -9,18 +9,76 @@
#ifndef SUBINARYDELTACOMMON_H
#define SUBINARYDELTACOMMON_H
#import <Foundation/Foundation.h>
#include <fts.h>
@class NSString;
@class NSData;
#define PERMISSION_FLAGS (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)
#define IS_VALID_PERMISSIONS(mode) \
(((mode & PERMISSION_FLAGS) == 0755) || ((mode & PERMISSION_FLAGS) == 0644))
#define APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY "com.apple.cs.CodeDirectory"
#define APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY "com.apple.cs.CodeRequirements"
#define APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY "com.apple.cs.CodeSignature"
#define BINARY_DELTA_ATTRIBUTES_KEY "binary-delta-attributes"
#define MAJOR_DIFF_VERSION_KEY "major-version"
#define MINOR_DIFF_VERSION_KEY "minor-version"
#define BEFORE_TREE_SHA1_KEY "before-tree-sha1"
#define AFTER_TREE_SHA1_KEY "after-tree-sha1"
#define DELETE_KEY "delete"
#define EXTRACT_KEY "extract"
#define BINARY_DELTA_KEY "binary-delta"
#define MODIFY_PERMISSIONS_KEY "mod-permissions"
// Properties no longer used in new patches
#define DELETE_THEN_EXTRACT_OLD_KEY "delete-then-extract"
#define BEFORE_TREE_SHA1_OLD_KEY "before-sha1"
#define AFTER_TREE_SHA1_OLD_KEY "after-sha1"
#define VERBOSE_DELETED "Deleted" // file is deleted from the file system when applying a patch
#define VERBOSE_REMOVED "Removed" // file is set to be removed when creating a patch
#define VERBOSE_ADDED "Added" // file is added to the patch or file system
#define VERBOSE_DIFFED "Diffed" // file is diffed when creating a patch
#define VERBOSE_PATCHED "Patched" // file is patched when applying a patch
#define VERBOSE_UPDATED "Updated" // file's contents are updated
#define VERBOSE_MODIFIED "Modified" // file's metadata is modified
#define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
// Each major version will be assigned a name of a color
// Changes that break backwards compatibility will have different major versions
// Changes that affect creating but not applying patches will have different minor versions
typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
{
SUAzureMajorVersion = 1,
SUBeigeMajorVersion = 2
};
// Only keep track of the latest minor version for each major version
typedef NS_ENUM(uint16_t, SUBinaryDeltaMinorVersion)
{
SUAzureMinorVersion = 1,
SUBeigeMinorVersion = 1,
};
#define FIRST_DELTA_DIFF_MAJOR_VERSION SUAzureMajorVersion
#define FIRST_DELTA_DIFF_MINOR_VERSION ((SUBinaryDeltaMinorVersion)0)
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
extern int binaryDeltaSupported(void);
extern int compareFiles(const FTSENT **a, const FTSENT **b);
extern NSData *hashOfFile(FTSENT *ent);
extern NSData *hashOfFileContents(FTSENT *ent);
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
extern NSString *hashOfTree(NSString *path);
extern void removeTree(NSString *path);
extern void copyTree(NSString *source, NSString *dest);
extern BOOL removeTree(NSString *path);
extern BOOL copyTree(NSString *source, NSString *dest);
extern BOOL modifyPermissions(NSString *path, mode_t desiredPermissions);
extern NSString *pathRelativeToDirectory(NSString *directory, NSString *path);
NSString *temporaryFilename(NSString *base);
NSString *temporaryDirectory(NSString *base);
NSString *stringWithFileSystemRepresentation(const char*);
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
#endif
+125 -52
View File
@@ -17,13 +17,6 @@
#include <sys/stat.h>
#include <xar/xar.h>
int binaryDeltaSupported(void)
{
// OS X 10.4 didn't include libxar, so we link against it weakly.
// This checks whether libxar is available at runtime.
return xar_close != 0;
}
int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll((*a)->fts_name, (*b)->fts_name);
@@ -39,23 +32,55 @@ NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
}
NSString *stringWithFileSystemRepresentation(const char *input) {
NSFileManager *fm = [NSFileManager defaultManager];
return [fm stringWithFileSystemRepresentation:input length:strlen(input)];
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
}
SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
{
switch (majorVersion) {
case SUAzureMajorVersion:
return SUAzureMinorVersion;
case SUBeigeMajorVersion:
return SUBeigeMinorVersion;
}
return (SUBinaryDeltaMinorVersion)0;
}
NSString *temporaryFilename(NSString *base)
{
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
const char *fsrepr = [template fileSystemRepresentation];
NSMutableData *data = [NSMutableData data];
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
const size_t buffer_len = strlen(fsrepr) + 1;
char *buffer = (char *)malloc(buffer_len);
strlcpy(buffer, fsrepr, buffer_len);
char *buffer = data.mutableBytes;
int fd = mkstemp(buffer);
if (fd == -1) {
perror("mkstemp");
return nil;
}
// mkstemp() can't be used, beause it returns a file descriptor, and XAR API requires a filename
NSString *ret = stringWithFileSystemRepresentation(mktemp(buffer));
free(buffer);
return ret;
if (close(fd) != 0) {
perror("close");
return nil;
}
return stringWithFileSystemRepresentation(buffer);
}
NSString *temporaryDirectory(NSString *base)
{
NSString *template = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXXXXX", base]];
NSMutableData *data = [NSMutableData data];
[data appendBytes:template.fileSystemRepresentation length:strlen(template.fileSystemRepresentation) + 1];
char *buffer = data.mutableBytes;
char *templateResult = mkdtemp(buffer);
if (templateResult == NULL) {
perror("mkdtemp");
return nil;
}
return stringWithFileSystemRepresentation(templateResult);
}
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)
@@ -67,62 +92,63 @@ static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t buffe
CC_SHA1_Final(hash, &hashContext);
}
static void _hashOfFile(unsigned char* hash, FTSENT *ent)
static BOOL _hashOfFileContents(unsigned char* hash, FTSENT *ent)
{
if (ent->fts_info == FTS_SL) {
char linkDestination[MAXPATHLEN + 1];
ssize_t linkDestinationLength = readlink(ent->fts_path, linkDestination, MAXPATHLEN);
if (linkDestinationLength < 0) {
perror("readlink");
return;
return NO;
}
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
return;
}
if (ent->fts_info == FTS_F) {
} else if (ent->fts_info == FTS_F) {
int fileDescriptor = open(ent->fts_path, O_RDONLY);
if (fileDescriptor == -1) {
perror("open");
return;
return NO;
}
ssize_t fileSize = ent->fts_statp->st_size;
if (fileSize == 0) {
_hashOfBuffer(hash, NULL, 0);
close(fileDescriptor);
return;
} else {
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);
perror("mmap");
return NO;
}
_hashOfBuffer(hash, buffer, fileSize);
munmap(buffer, (size_t)fileSize);
}
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);
perror("mmap");
return;
}
_hashOfBuffer(hash, buffer, fileSize);
munmap(buffer, (size_t)fileSize);
close(fileDescriptor);
return;
}
if (ent->fts_info == FTS_D)
} else if (ent->fts_info == FTS_D) {
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
} else {
return NO;
}
return YES;
}
NSData *hashOfFile(FTSENT *ent)
NSData *hashOfFileContents(FTSENT *ent)
{
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
_hashOfFile(fileHash, ent);
if (!_hashOfFileContents(fileHash, ent)) {
return nil;
}
return [NSData dataWithBytes:fileHash length:CC_SHA1_DIGEST_LENGTH];
}
NSString *hashOfTree(NSString *path)
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
{
const char *sourcePaths[] = {[path fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
char pathBuffer[PATH_MAX] = {0};
[path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
char * const sourcePaths[] = {pathBuffer, 0};
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return nil;
@@ -133,16 +159,34 @@ NSString *hashOfTree(NSString *path)
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL)
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
continue;
if (ent->fts_info == FTS_D && !MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
continue;
}
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
if (relativePath.length == 0)
continue;
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
_hashOfFile(fileHash, ent);
if (!_hashOfFileContents(fileHash, ent)) {
return nil;
}
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
NSString *relativePath = pathRelativeToDirectory(path, stringWithFileSystemRepresentation(ent->fts_path));
const char *relativePathBytes = [relativePath fileSystemRepresentation];
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
uint16_t mode = ent->fts_statp->st_mode;
uint16_t type = ent->fts_info;
uint16_t permissions = mode & PERMISSION_FLAGS;
CC_SHA1_Update(&hashContext, &type, sizeof(type));
CC_SHA1_Update(&hashContext, &permissions, sizeof(permissions));
}
}
fts_close(fts);
@@ -157,12 +201,41 @@ NSString *hashOfTree(NSString *path)
return @(hexHash);
}
void removeTree(NSString *path)
extern NSString *hashOfTree(NSString *path)
{
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
return hashOfTreeWithVersion(path, LATEST_DELTA_DIFF_MAJOR_VERSION);
}
void copyTree(NSString *source, NSString *dest)
BOOL removeTree(NSString *path)
{
[[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
NSFileManager *fileManager = [NSFileManager defaultManager];
// Don't use fileExistsForPath: because it will try to follow symbolic links
if (![fileManager attributesOfItemAtPath:path error:nil]) {
return YES;
}
return [fileManager removeItemAtPath:path error:nil];
}
BOOL copyTree(NSString *source, NSString *dest)
{
return [[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil];
}
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil];
if (!attributes) {
return NO;
}
NSNumber *permissions = attributes[NSFilePosixPermissions];
if (!permissions) {
return NO;
}
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
int (*changeModeFunc)(const char *, mode_t) = [attributes[NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
return NO;
}
return YES;
}
+17
View File
@@ -0,0 +1,17 @@
//
// SUBinaryDeltaCreate.m
// Sparkle
//
// Created by Mayur Pawashe on 4/9/15.
// Copyright (c) 2015 Sparkle Project. All rights reserved.
//
#ifndef SUBINARYDELTACREATE_H
#define SUBINARYDELTACREATE_H
#import "SUBinaryDeltaCommon.h"
@class NSString;
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose);
#endif
+515
View File
@@ -0,0 +1,515 @@
//
// SUBinaryDeltaCreate.m
// Sparkle
//
// Created by Mayur Pawashe on 4/9/15.
// Copyright (c) 2015 Sparkle Project. All rights reserved.
//
#import "SUBinaryDeltaCreate.h"
#import <Foundation/Foundation.h>
#include "SUBinaryDeltaCommon.h"
#import <CommonCrypto/CommonDigest.h>
#include <fcntl.h>
#include <fts.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/xattr.h>
#include <xar/xar.h>
extern int bsdiff(int argc, const char **argv);
@interface CreateBinaryDeltaOperation : NSOperation
@property (copy) NSString *relativePath;
@property (strong) NSString *resultPath;
@property (strong) NSNumber *oldPermissions;
@property (strong) NSNumber *permissions;
@property (strong) NSString *_fromPath;
@property (strong) NSString *_toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions;
@end
@implementation CreateBinaryDeltaOperation
@synthesize relativePath = _relativePath;
@synthesize resultPath = _resultPath;
@synthesize oldPermissions = _oldPermissions;
@synthesize permissions = _permissions;
@synthesize _fromPath = _fromPath;
@synthesize _toPath = _toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree oldPermissions:(NSNumber *)oldPermissions newPermissions:(NSNumber *)permissions
{
if ((self = [super init])) {
self.relativePath = relativePath;
self.oldPermissions = oldPermissions;
self.permissions = permissions;
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
}
return self;
}
- (void)main
{
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
int result = bsdiff(4, argv);
if (!result)
self.resultPath = temporaryFile;
}
@end
#define INFO_HASH_KEY @"hash"
#define INFO_TYPE_KEY @"type"
#define INFO_PERMISSIONS_KEY @"permissions"
#define INFO_SIZE_KEY @"size"
static NSDictionary *infoForFile(FTSENT *ent)
{
NSData *hash = hashOfFileContents(ent);
if (!hash) {
return nil;
}
off_t size = (ent->fts_info != FTS_D) ? ent->fts_statp->st_size : 0;
assert(ent->fts_statp != NULL);
mode_t permissions = ent->fts_statp->st_mode & PERMISSION_FLAGS;
return @{INFO_HASH_KEY: hash, INFO_TYPE_KEY: @(ent->fts_info), INFO_PERMISSIONS_KEY : @(permissions), INFO_SIZE_KEY: @(size)};
}
static bool aclExists(const FTSENT *ent)
{
// OS X does not currently support ACLs for symlinks
if (ent->fts_info == FTS_SL) {
return NO;
}
acl_t acl = acl_get_link_np(ent->fts_path, ACL_TYPE_EXTENDED);
if (acl != NULL) {
acl_entry_t entry;
int result = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry);
assert(acl_free((void *)acl) == 0);
return (result == 0);
}
return false;
}
static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
{
const int options = XATTR_NOFOLLOW;
ssize_t listSize = listxattr(ent->fts_path, NULL, 0, options);
if (listSize == -1) {
return false;
}
char *buffer = malloc((size_t)listSize);
assert(buffer != NULL);
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
assert(sizeBack == listSize);
size_t startCharacterIndex = 0;
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
if (buffer[characterIndex] == '\0') {
char *attribute = &buffer[startCharacterIndex];
size_t length = characterIndex - startCharacterIndex;
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
free(buffer);
return true;
}
startCharacterIndex = characterIndex + 1;
}
}
free(buffer);
return false;
}
static NSString *absolutePath(NSString *path)
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
return [[url absoluteURL] path];
}
static NSString *temporaryPatchFile(NSString *patchFile)
{
NSString *path = absolutePath(patchFile);
NSString *directory = [path stringByDeletingLastPathComponent];
NSString *file = [path lastPathComponent];
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
}
#define MIN_FILE_SIZE_FOR_CREATING_DELTA 4096
static BOOL shouldSkipDeltaCompression(NSDictionary* originalInfo, NSDictionary *newInfo)
{
unsigned long long fileSize = [newInfo[INFO_SIZE_KEY] unsignedLongLongValue];
if (fileSize < MIN_FILE_SIZE_FOR_CREATING_DELTA) {
return YES;
}
if (!originalInfo) {
return YES;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return YES;
}
if ([originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
// this is possible if just the permissions have changed
return YES;
}
return NO;
}
static BOOL shouldDeleteThenExtract(NSDictionary* originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return YES;
}
return NO;
}
static BOOL shouldSkipExtracting(NSDictionary *originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return NO;
}
if (![originalInfo[INFO_HASH_KEY] isEqual:newInfo[INFO_HASH_KEY]]) {
return NO;
}
return YES;
}
static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
}
if ([originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
return NO;
}
if ([originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue] == [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]) {
return NO;
}
return YES;
}
int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose)
{
if (majorVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "Version provided (%u) is not valid\n", majorVersion);
return 1;
}
if (majorVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) {
fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", majorVersion);
return 1;
}
SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion);
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
char pathBuffer[PATH_MAX] = {0};
[source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
char *sourcePaths[] = {pathBuffer, 0};
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return 1;
}
if (verbose) {
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
}
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(source, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
if (!info) {
fprintf(stderr, "\nFailed to retrieve info for file %s\n", ent->fts_path);
return 1;
}
originalTreeState[key] = info;
if (aclExists(ent)) {
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in before-tree on file %s\n", ent->fts_path);
return 1;
}
if (codeSignatureExtendedAttributeExists(ent)) {
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %s\n", ent->fts_path);
return 1;
}
}
fts_close(fts);
NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion);
if (!beforeHash) {
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [source fileSystemRepresentation]);
return 1;
}
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
for (NSString *key in originalTreeState)
{
newTreeState[key] = [NSNull null];
}
if (verbose) {
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
}
pathBuffer[0] = 0;
[destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
sourcePaths[0] = pathBuffer;
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return 1;
}
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(destination, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
if (!info) {
fprintf(stderr, "\nFailed to retrieve info from file %s\n", ent->fts_path);
return 1;
}
// 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)) {
fprintf(stderr, "\nInvalid file permissions after-tree on file %s\nOnly permissions with modes 0755 and 0644 are supported\n", ent->fts_path);
return 1;
}
if (aclExists(ent)) {
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in after-tree on file %s\n", ent->fts_path);
return 1;
}
if (codeSignatureExtendedAttributeExists(ent)) {
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %s\n", ent->fts_path);
return 1;
}
NSDictionary *oldInfo = originalTreeState[key];
if ([info isEqual:oldInfo]) {
[newTreeState removeObjectForKey:key];
} else {
newTreeState[key] = info;
if (oldInfo && [oldInfo[INFO_TYPE_KEY] unsignedShortValue] == FTS_D && [info[INFO_TYPE_KEY] unsignedShortValue] != FTS_D) {
NSArray *parentPathComponents = key.pathComponents;
for (NSString *childPath in originalTreeState) {
NSArray *childPathComponents = childPath.pathComponents;
if (childPathComponents.count > parentPathComponents.count &&
[parentPathComponents isEqualToArray:[childPathComponents subarrayWithRange:NSMakeRange(0, parentPathComponents.count)]]) {
[newTreeState removeObjectForKey:childPath];
}
}
}
}
}
fts_close(fts);
NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion);
if (!afterHash) {
fprintf(stderr, "\nFailed to generate hash for tree %s\n", [destination fileSystemRepresentation]);
return 1;
}
if (verbose) {
fprintf(stderr, "\nGenerating delta...");
}
NSString *temporaryFile = temporaryPatchFile(patchFile);
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
xar_subdoc_prop_set(attributes, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", majorVersion] UTF8String]);
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", minorVersion] UTF8String]);
// Version 1 patches don't have a major or minor version field, so we need to differentiate between the hash keys
const char *beforeHashKey =
MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? BEFORE_TREE_SHA1_KEY : BEFORE_TREE_SHA1_OLD_KEY;
const char *afterHashKey =
MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) ? AFTER_TREE_SHA1_KEY : AFTER_TREE_SHA1_OLD_KEY;
xar_subdoc_prop_set(attributes, beforeHashKey, [beforeHash UTF8String]);
xar_subdoc_prop_set(attributes, afterHashKey, [afterHash UTF8String]);
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
NSMutableArray *deltaOperations = [NSMutableArray array];
// Sort the keys by preferring the ones from the original tree to appear first
// We want to enforce deleting before extracting in the case paths differ only by case
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingComparator:^NSComparisonResult(NSString *key1, NSString *key2) {
NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2];
if (insensitiveCompareResult != NSOrderedSame) {
return insensitiveCompareResult;
}
return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending;
}];
for (NSString* key in keys) {
id value = [newTreeState valueForKey:key];
if ([value isEqual:[NSNull null]]) {
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, DELETE_KEY, "true");
if (verbose) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
}
continue;
}
NSDictionary *originalInfo = originalTreeState[key];
NSDictionary *newInfo = newTreeState[key];
if (shouldSkipDeltaCompression(originalInfo, newInfo)) {
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && shouldSkipExtracting(originalInfo, newInfo)) {
if (shouldChangePermissions(originalInfo, newInfo)) {
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
}
}
} else {
NSString *path = [destination stringByAppendingPathComponent:key];
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
assert(newFile);
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
xar_prop_set(newFile, DELETE_KEY, "true");
} else {
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
}
}
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
xar_prop_set(newFile, EXTRACT_KEY, "true");
}
if (verbose) {
if (originalInfo) {
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
} else {
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [key fileSystemRepresentation]);
}
}
}
} else {
NSNumber *permissions =
(MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion) && shouldChangePermissions(originalInfo, newInfo)) ?
newInfo[INFO_PERMISSIONS_KEY] :
nil;
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:source newTree:destination oldPermissions:originalInfo[INFO_PERMISSIONS_KEY] newPermissions:permissions];
[deltaQueue addOperation:operation];
[deltaOperations addObject:operation];
}
}
[deltaQueue waitUntilAllOperationsAreFinished];
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
NSString *resultPath = [operation resultPath];
if (!resultPath) {
fprintf(stderr, "\nFailed to create patch from source %s and destination %s\n", [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
return 1;
}
if (verbose) {
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
}
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
assert(newFile);
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
unlink([resultPath fileSystemRepresentation]);
if (operation.permissions) {
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
}
}
}
xar_close(x);
unlink([patchFile fileSystemRepresentation]);
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
unlink([temporaryFile fileSystemRepresentation]);
if (verbose) {
fprintf(stderr, "\nDone!\n");
}
return 0;
}
+186 -234
View File
@@ -6,261 +6,213 @@
// Copyright 2009 Mark Rowe. All rights reserved.
//
#define _DARWIN_NO_64_BIT_INODE 1
#include "SUBinaryDeltaCommon.h"
#include "SUBinaryDeltaApply.h"
#include <CommonCrypto/CommonDigest.h>
#include "SUBinaryDeltaCreate.h"
#import "SUBinaryDeltaCommon.h"
#include <Foundation/Foundation.h>
#include <fcntl.h>
#include <fts.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <xar/xar.h>
extern int bsdiff(int argc, const char **argv);
#define VERBOSE_FLAG @"--verbose"
#define VERSION_FLAG @"--version"
@interface CreateBinaryDeltaOperation : NSOperation
@property (copy) NSString *relativePath;
@property (strong) NSString *resultPath;
@property (strong) NSString *_fromPath;
@property (strong) NSString *_toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree;
@end
#define CREATE_COMMAND @"create"
#define APPLY_COMMAND @"apply"
#define VERSION_COMMAND @"version"
#define VERSION_ALTERNATE_COMMAND @"--version"
@implementation CreateBinaryDeltaOperation
@synthesize relativePath = _relativePath;
@synthesize resultPath = _resultPath;
@synthesize _fromPath = _fromPath;
@synthesize _toPath = _toPath;
- (id)initWithRelativePath:(NSString *)relativePath oldTree:(NSString *)oldTree newTree:(NSString *)newTree
static void printUsage(NSString *programName)
{
if ((self = [super init])) {
self.relativePath = relativePath;
self._fromPath = [oldTree stringByAppendingPathComponent:relativePath];
self._toPath = [newTree stringByAppendingPathComponent:relativePath];
fprintf(stderr, "Usage:\n");
fprintf(stderr, "%s create [--verbose] [--version=<version>] <before-tree> <after-tree> <patch-file>\n", [programName UTF8String]);
fprintf(stderr, "%s apply [--verbose] <before-tree> <after-tree> <patch-file>\n", [programName UTF8String]);
fprintf(stderr, "%s version [<patch-file>]\n", [programName UTF8String]);
}
static int runCreateCommand(NSString *programName, NSArray *args)
{
if (args.count < 3 || args.count > 5) {
printUsage(programName);
return 1;
}
return self;
NSUInteger numberOflagsFound = 0;
NSUInteger verboseIndex = [args indexOfObject:VERBOSE_FLAG];
NSUInteger versionIndex = NSNotFound;
for (NSUInteger argumentIndex = 0; argumentIndex < args.count; ++argumentIndex) {
if ([args[argumentIndex] hasPrefix:VERSION_FLAG]) {
versionIndex = argumentIndex;
break;
}
}
if (verboseIndex != NSNotFound) {
++numberOflagsFound;
}
if (versionIndex != NSNotFound) {
++numberOflagsFound;
}
if (args.count - numberOflagsFound < 3) {
printUsage(programName);
return 1;
}
BOOL verbose = (verboseIndex != NSNotFound);
NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil;
NSArray *versionComponents = nil;
if (versionField) {
versionComponents = [versionField componentsSeparatedByString:@"="];
if (versionComponents.count != 2) {
printUsage(programName);
return 1;
}
}
SUBinaryDeltaMajorVersion patchVersion =
!versionComponents ?
LATEST_DELTA_DIFF_MAJOR_VERSION :
(SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided
NSMutableArray *fileArgs = [NSMutableArray array];
for (NSString *argument in args) {
if (![argument hasPrefix:VERSION_FLAG] && ![argument isEqualToString:VERBOSE_FLAG]) {
[fileArgs addObject:argument];
}
}
if (fileArgs.count != 3) {
printUsage(programName);
return 1;
}
BOOL isDirectory;
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: before-tree must be a directory\n");
return 1;
}
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[1] isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: after-tree must be a directory\n");
return 1;
}
return createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose);
}
- (void)main
static int runApplyCommand(NSString *programName, NSArray *args)
{
NSString *temporaryFile = temporaryFilename(@"BinaryDelta");
const char *argv[] = {"/usr/bin/bsdiff", [self._fromPath fileSystemRepresentation], [self._toPath fileSystemRepresentation], [temporaryFile fileSystemRepresentation]};
int result = bsdiff(4, argv);
if (!result)
self.resultPath = temporaryFile;
if (args.count < 3 || args.count > 4) {
printUsage(programName);
return 1;
}
BOOL verbose = [args containsObject:VERBOSE_FLAG];
if (args.count == 4 && !verbose) {
printUsage(programName);
return 1;
}
NSMutableArray *fileArgs = [NSMutableArray array];
for (NSString *argument in args) {
if (![argument isEqualToString:VERBOSE_FLAG]) {
[fileArgs addObject:argument];
}
}
if (fileArgs.count != 3) {
printUsage(programName);
return 1;
}
BOOL isDirectory;
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: before-tree must be a directory\n");
return 1;
}
if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) {
printUsage(programName);
fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory);
return 1;
}
return applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose);
}
@end
static NSDictionary *infoForFile(FTSENT *ent)
static int runVersionCommand(NSString *programName, NSArray *args)
{
NSData *hash = hashOfFile(ent);
NSNumber *size = @0;
if (ent->fts_info != FTS_D) {
size = @(ent->fts_statp->st_size);
}
return @{@"hash": hash, @"type": @(ent->fts_info), @"size": size};
if (args.count > 1) {
printUsage(programName);
return 1;
}
if (args.count == 0) {
fprintf(stdout, "%u.%u\n", LATEST_DELTA_DIFF_MAJOR_VERSION, latestMinorVersionForMajorVersion(LATEST_DELTA_DIFF_MAJOR_VERSION));
} else {
NSString *patchFile = args[0];
xar_t x = xar_open([patchFile fileSystemRepresentation], READ);
if (!x) {
fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]);
return 1;
}
SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION;
SUBinaryDeltaMinorVersion minorDiffVersion = FIRST_DELTA_DIFF_MINOR_VERSION;
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (!strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY)) {
const char *value = 0;
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
if (value)
majorDiffVersion = (SUBinaryDeltaMajorVersion)[@(value) intValue];
// available in version 2.0 or later
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
if (value)
minorDiffVersion = (SUBinaryDeltaMinorVersion)[@(value) intValue];
}
}
fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion);
}
return 0;
}
static NSString *absolutePath(NSString *path)
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
return [[url absoluteURL] path];
}
static NSString *temporaryPatchFile(NSString *patchFile)
{
NSString *path = absolutePath(patchFile);
NSString *directory = [path stringByDeletingLastPathComponent];
NSString *file = [path lastPathComponent];
return [NSString stringWithFormat:@"%@/.%@.tmp", directory, file];
}
static BOOL shouldSkipDeltaCompression(NSString * __unused key, NSDictionary* originalInfo, NSDictionary *newInfo)
{
unsigned long long fileSize = [newInfo[@"size"] unsignedLongLongValue];
if (fileSize < 4096) {
return YES;
}
if (!originalInfo) {
return YES;
}
if ([originalInfo[@"type"] unsignedShortValue] != [newInfo[@"type"] unsignedShortValue]) {
return YES;
}
return NO;
}
static BOOL shouldDeleteThenExtract(NSString * __unused key, NSDictionary* originalInfo, NSDictionary *newInfo)
{
if (!originalInfo) {
return NO;
}
if ([originalInfo[@"type"] unsignedShortValue] != [newInfo[@"type"] unsignedShortValue]) {
return YES;
}
return NO;
}
int main(int argc, char **argv)
int main(int __unused argc, char __unused *argv[])
{
@autoreleasepool {
if (argc != 5) {
usage:
fprintf(stderr, "Usage: BinaryDelta [create | apply] before-tree after-tree patch-file\n");
exit(1);
}
NSString *command = @(argv[1]);
NSString *oldPath = stringWithFileSystemRepresentation(argv[2]);
NSString *newPath = stringWithFileSystemRepresentation(argv[3]);
NSString *patchFile = stringWithFileSystemRepresentation(argv[4]);
if ([command isEqualToString:@"apply"]) {
int result = applyBinaryDelta(oldPath, newPath, patchFile);
return result;
}
if (![command isEqualToString:@"create"]) {
goto usage;
}
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
const char *sourcePaths[] = {[oldPath fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
NSArray *args = [[NSProcessInfo processInfo] arguments];
NSString *programName = [args[0] lastPathComponent];
if (args.count < 2) {
printUsage(programName);
return 1;
}
fprintf(stderr, "Processing %s...", [oldPath UTF8String]);
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(oldPath, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
originalTreeState[key] = info;
NSString *command = args[1];
NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)];
int result;
if ([command isEqualToString:CREATE_COMMAND]) {
result = runCreateCommand(programName, commandArguments);
} else if ([command isEqualToString:APPLY_COMMAND]) {
result = runApplyCommand(programName, commandArguments);
} else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) {
result = runVersionCommand(programName, commandArguments);
} else {
result = 1;
printUsage(programName);
}
fts_close(fts);
NSString *beforeHash = hashOfTree(oldPath);
NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary];
for (NSString *key in originalTreeState)
{
newTreeState[key] = [NSNull null];
}
fprintf(stderr, "\nProcessing %s... ", [newPath UTF8String]);
sourcePaths[0] = [newPath fileSystemRepresentation];
fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return 1;
}
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) {
continue;
}
NSString *key = pathRelativeToDirectory(newPath, stringWithFileSystemRepresentation(ent->fts_path));
if (![key length]) {
continue;
}
NSDictionary *info = infoForFile(ent);
NSDictionary *oldInfo = originalTreeState[key];
if ([info isEqual:oldInfo])
[newTreeState removeObjectForKey:key];
else
newTreeState[key] = info;
}
fts_close(fts);
NSString *afterHash = hashOfTree(newPath);
fprintf(stderr, "\nGenerating delta... ");
NSString *temporaryFile = temporaryPatchFile(patchFile);
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
xar_subdoc_t attributes = xar_subdoc_new(x, "binary-delta-attributes");
xar_subdoc_prop_set(attributes, "before-sha1", [beforeHash UTF8String]);
xar_subdoc_prop_set(attributes, "after-sha1", [afterHash UTF8String]);
NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init];
NSMutableArray *deltaOperations = [NSMutableArray array];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wselector"
// Xcode 5.1.1: compare: is clearly declared, must warn due to a compiler bug?
NSArray *keys = [[newTreeState allKeys] sortedArrayUsingSelector:@selector(compare:)];
#pragma clang diagnostic pop
for (NSString* key in keys) {
id value = [newTreeState valueForKey:key];
if ([value isEqual:[NSNull null]]) {
xar_file_t newFile = xar_add_frombuffer(x, 0, [key fileSystemRepresentation], (char *)"", 1);
assert(newFile);
xar_prop_set(newFile, "delete", "true");
continue;
}
NSDictionary *originalInfo = originalTreeState[key];
NSDictionary *newInfo = newTreeState[key];
if (shouldSkipDeltaCompression(key, originalInfo, newInfo)) {
NSString *path = [newPath stringByAppendingPathComponent:key];
xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]);
assert(newFile);
if (shouldDeleteThenExtract(key, originalInfo, newInfo)) {
xar_prop_set(newFile, "delete-then-extract", "true");
}
} else {
CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath];
[deltaQueue addOperation:operation];
[deltaOperations addObject:operation];
}
}
[deltaQueue waitUntilAllOperationsAreFinished];
for (CreateBinaryDeltaOperation *operation in deltaOperations) {
NSString *resultPath = [operation resultPath];
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
assert(newFile);
xar_prop_set(newFile, "binary-delta", "true");
unlink([resultPath fileSystemRepresentation]);
}
xar_close(x);
unlink([patchFile fileSystemRepresentation]);
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
unlink([temporaryFile fileSystemRepresentation]);
fprintf(stderr, "Done!\n");
return 0;
return result;
}
}
+3 -3
View File
@@ -17,16 +17,16 @@
+ (BOOL)canUnarchivePath:(NSString *)path
{
return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
return [[path pathExtension] isEqualToString:@"delta"];
}
- (void)applyBinaryDelta
{
@autoreleasepool {
NSString *sourcePath = [[self.updateHost bundle] bundlePath];
NSString *sourcePath = self.updateHostBundlePath;
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath);
int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO);
if (!result) {
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
+3 -1
View File
@@ -12,8 +12,10 @@
#import <Foundation/Foundation.h>
@interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError **)error;
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError **)error;
+ (BOOL)hostApplicationIsCodeSigned;
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath;
@end
#endif
+86 -5
View File
@@ -13,7 +13,7 @@
@implementation SUCodeSigningVerifier
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)destinationPath error:(NSError *__autoreleasing *)error
+ (BOOL)codeSignatureMatchesHostAndIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
{
OSStatus result;
SecRequirementRef requirement = NULL;
@@ -37,20 +37,23 @@
goto finally;
}
newBundle = [NSBundle bundleWithPath:destinationPath];
newBundle = [NSBundle bundleWithPath:applicationPath];
if (!newBundle) {
SULog(@"Failed to load NSBundle for update");
result = -1;
goto finally;
}
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle executableURL], kSecCSDefaultFlags, &staticCode);
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
SULog(@"Failed to get static code %d", result);
goto finally;
}
result = SecStaticCodeCheckValidityWithErrors(staticCode, kSecCSDefaultFlags | kSecCSCheckAllArchitectures, requirement, &cfError);
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
if (cfError) {
NSError *tmpError = CFBridgingRelease(cfError);
@@ -80,6 +83,53 @@ finally:
return (result == noErr);
}
+ (BOOL)codeSignatureIsValidAtPath:(NSString *)applicationPath error:(NSError *__autoreleasing *)error
{
OSStatus result;
SecStaticCodeRef staticCode = NULL;
NSBundle *newBundle;
CFErrorRef cfError = NULL;
if (error) {
*error = nil;
}
newBundle = [NSBundle bundleWithPath:applicationPath];
if (!newBundle) {
SULog(@"Failed to load NSBundle");
result = -1;
goto finally;
}
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
SULog(@"Failed to get static code %d", result);
goto finally;
}
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures;
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
if (cfError) {
NSError *tmpError = CFBridgingRelease(cfError);
if (error) *error = tmpError;
}
if (result != noErr) {
if (result == errSecCSUnsigned) {
SULog(@"Error: The app is not signed using Apple Code Signing. %@", applicationPath);
}
if (result == errSecCSReqFailed) {
[self logSigningInfoForCode:staticCode label:@"new info"];
}
}
finally:
if (staticCode) CFRelease(staticCode);
return (result == noErr);
}
static id valueOrNSNull(id value) {
return value ? value : [NSNull null];
}
@@ -95,7 +145,7 @@ static id valueOrNSNull(id value) {
}
NSDictionary *infoPlist = signingDict[@"info-plist"];
relevantInfo[@"version"] = valueOrNSNull(infoPlist[@"CFBundleShortVersionString"]);
relevantInfo[@"build"] = valueOrNSNull(infoPlist[@"CFBundleVersion"]);
relevantInfo[@"build"] = valueOrNSNull(infoPlist[(__bridge NSString *)kCFBundleVersionKey]);
SULog(@"%@: %@", label, relevantInfo);
}
}
@@ -114,4 +164,35 @@ static id valueOrNSNull(id value) {
return (result == 0);
}
+ (BOOL)applicationAtPathIsCodeSigned:(NSString *)applicationPath
{
OSStatus result;
SecStaticCodeRef staticCode = NULL;
NSBundle *newBundle;
newBundle = [NSBundle bundleWithPath:applicationPath];
if (!newBundle) {
SULog(@"Failed to load NSBundle");
return NO;
}
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)[newBundle bundleURL], kSecCSDefaultFlags, &staticCode);
if (result == errSecCSUnsigned) {
return NO;
}
SecRequirementRef requirement = NULL;
result = SecCodeCopyDesignatedRequirement(staticCode, kSecCSDefaultFlags, &requirement);
if (staticCode) {
CFRelease(staticCode);
}
if (requirement) {
CFRelease(requirement);
}
if (result == errSecCSUnsigned) {
return NO;
}
return (result == 0);
}
@end
+27 -31
View File
@@ -10,21 +10,16 @@
#ifndef SUCONSTANTS_H
#define SUCONSTANTS_H
#import <Foundation/Foundation.h>
// -----------------------------------------------------------------------------
// Preprocessor flags:
// Misc:
// -----------------------------------------------------------------------------
// Sparkle usually doesn't allow downgrades as they're usually accidental, but
// if your app has a downgrade function or URL handler, turn this on:
#define PERMIT_AUTOMATED_DOWNGRADES 0
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
// If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it
// in place, giving you an app named 1.1b4 that is actually 1.2. Turn the
// following on to always reset the name back to "MyApp":
#define NORMALIZE_INSTALLED_APP_NAME 0
#define TRY_TO_APPEND_VERSION_NUMBER 1
extern NSString *const SUBundleIdentifier;
// -----------------------------------------------------------------------------
// Notifications:
@@ -56,32 +51,33 @@ extern NSString *const SUPromptUserOnFirstLaunchKey;
extern NSString *const SUKeepDownloadOnFailedInstallKey;
extern NSString *const SUDefaultsDomainKey;
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER.")));
extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES.")));
extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME.")));
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
// -----------------------------------------------------------------------------
// Errors:
// Appcast keys::
// -----------------------------------------------------------------------------
extern NSString *const SUSparkleErrorDomain;
// Appcast phase errors.
extern OSStatus SUAppcastParseError;
extern OSStatus SUNoUpdateError;
extern OSStatus SUAppcastError;
extern OSStatus SURunningFromDiskImageError;
extern NSString *const SUAppcastAttributeDeltaFrom;
extern NSString *const SUAppcastAttributeDSASignature;
extern NSString *const SUAppcastAttributeShortVersionString;
extern NSString *const SUAppcastAttributeVersion;
// Downlaod phase errors.
extern OSStatus SUTemporaryDirectoryError;
extern NSString *const SUAppcastElementCriticalUpdate;
extern NSString *const SUAppcastElementDeltas;
extern NSString *const SUAppcastElementMinimumSystemVersion;
extern NSString *const SUAppcastElementMaximumSystemVersion;
extern NSString *const SUAppcastElementReleaseNotesLink;
extern NSString *const SUAppcastElementTags;
// Extraction phase errors.
extern OSStatus SUUnarchivingError;
extern OSStatus SUSignatureError;
extern NSString *const SURSSAttributeURL;
// Installation phase errors.
extern OSStatus SUFileCopyFailure;
extern OSStatus SUAuthenticationFailure;
extern OSStatus SUMissingUpdateError;
extern OSStatus SUMissingInstallerToolError;
extern OSStatus SURelaunchError;
extern OSStatus SUInstallationError;
extern OSStatus SUDowngradeError;
extern NSString *const SURSSElementDescription;
extern NSString *const SURSSElementEnclosure;
extern NSString *const SURSSElementLink;
extern NSString *const SURSSElementPubDate;
extern NSString *const SURSSElementTitle;
#endif
+32 -15
View File
@@ -13,6 +13,16 @@
#import "SUVersionComparisonProtocol.h"
#import "SUConstants.h"
#ifndef DEBUG
#define DEBUG 0
#endif
// Define some minimum intervals to avoid DoS-like checking attacks
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";
NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
@@ -35,22 +45,29 @@ NSString *const SUPromptUserOnFirstLaunchKey = @"SUPromptUserOnFirstLaunch";
NSString *const SUFixedHTMLDisplaySizeKey = @"SUFixedHTMLDisplaySize";
NSString *const SUKeepDownloadOnFailedInstallKey = @"SUKeepDownloadOnFailedInstall";
NSString *const SUDefaultsDomainKey = @"SUDefaultsDomain";
NSString *const SUSparkleErrorDomain = @"SUSparkleErrorDomain";
OSStatus SUAppcastParseError = 1000;
OSStatus SUNoUpdateError = 1001;
OSStatus SUAppcastError = 1002;
OSStatus SURunningFromDiskImageError = 1003;
OSStatus SUTemporaryDirectoryError = 2000;
NSString *const SUAppendVersionNumberKey = @"SUAppendVersionNumber";
NSString *const SUEnableAutomatedDowngradesKey = @"SUEnableAutomatedDowngrades";
NSString *const SUNormalizeInstalledApplicationNameKey = @"SUNormalizeInstalledApplicationName";
NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
OSStatus SUUnarchivingError = 3000;
OSStatus SUSignatureError = 3001;
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
OSStatus SUFileCopyFailure = 4000;
OSStatus SUAuthenticationFailure = 4001;
OSStatus SUMissingUpdateError = 4002;
OSStatus SUMissingInstallerToolError = 4003;
OSStatus SURelaunchError = 4004;
OSStatus SUInstallationError = 4005;
OSStatus SUDowngradeError = 4006;
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
NSString *const SUAppcastElementMinimumSystemVersion = @"sparkle:minimumSystemVersion";
NSString *const SUAppcastElementMaximumSystemVersion = @"sparkle:maximumSystemVersion";
NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
NSString *const SUAppcastElementTags = @"sparkle:tags";
NSString *const SURSSAttributeURL = @"url";
NSString *const SURSSElementDescription = @"description";
NSString *const SURSSElementEnclosure = @"enclosure";
NSString *const SURSSElementLink = @"link";
NSString *const SURSSElementPubDate = @"pubDate";
NSString *const SURSSElementTitle = @"title";
+8
View File
@@ -15,6 +15,14 @@
#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;
+4 -1
View File
@@ -121,9 +121,12 @@
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 sugnature: %@; Signature data: %@", error, signature);
SULog(@"Could not understand format of the signature: %@; Signature data: %@", error, signature);
return cleanup();
}
+1 -1
View File
@@ -65,7 +65,7 @@
CFRelease(uuid);
}
}
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
while (noErr == FSPathMakeRefWithOptions((const UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
NSData *promptData = nil;
promptData = [NSData dataWithBytes:"yes\n" length:4];
+47
View File
@@ -0,0 +1,47 @@
//
// SUErrors.h
// Sparkle
//
// Created by C.W. Betts on 10/13/14.
// Copyright (c) 2014 Sparkle Project. All rights reserved.
//
#ifndef SUERRORS_H
#define SUERRORS_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
/**
* Error domain used by Sparkle
*/
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
typedef NS_ENUM(OSStatus, SUError) {
// Appcast phase errors.
SUAppcastParseError = 1000,
SUNoUpdateError = 1001,
SUAppcastError = 1002,
SURunningFromDiskImageError = 1003,
// Downlaod phase errors.
SUTemporaryDirectoryError = 2000,
// Extraction phase errors.
SUUnarchivingError = 3000,
SUSignatureError = 3001,
// Installation phase errors.
SUFileCopyFailure = 4000,
SUAuthenticationFailure = 4001,
SUMissingUpdateError = 4002,
SUMissingInstallerToolError = 4003,
SURelaunchError = 4004,
SUInstallationError = 4005,
SUDowngradeError = 4006,
// System phase errors
SUSystemPowerOffError = 5000
};
#endif
+18
View File
@@ -0,0 +1,18 @@
//
// SUExport.h
// Sparkle
//
// Created by Jake Petroules on 2014-08-23.
// Copyright (c) 2014 Sparkle Project. All rights reserved.
//
#ifndef SUEXPORT_H
#define SUEXPORT_H
#ifdef BUILDING_SPARKLE
#define SU_EXPORT __attribute__((visibility("default")))
#else
#define SU_EXPORT
#endif
#endif
+35
View File
@@ -0,0 +1,35 @@
//
// SUGuidedPackageInstaller.h
// Sparkle
//
// Created by Graham Miln on 14/05/2010.
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
//
/*!
# Sparkle Guided Installations
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
The installer package is installed using Mac OS X's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
## To Do
- Replace the use of `AuthorizationExecuteWithPrivilegesAndWait`. This method remains because it is well supported and tested. Ideally a helper tool or XPC would be used.
*/
#ifndef SUGUIDEDPACKAGEINSTALLER_H
#define SUGUIDEDPACKAGEINSTALLER_H
#import <Foundation/Foundation.h>
#import "Sparkle.h"
#import "SUInstaller.h"
@interface SUGuidedPackageInstaller : SUInstaller
/*! Perform the guided installation */
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
@end
#endif
+144
View File
@@ -0,0 +1,144 @@
//
// SUGuidedPackageInstaller.m
// Sparkle
//
// Created by Graham Miln on 14/05/2010.
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
//
#import <sys/stat.h>
#import <Security/Security.h>
#import "SUGuidedPackageInstaller.h"
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments)
{
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
/* AuthorizationExecuteWithPrivileges used to support 10.4+; should be replaced with XPC or external process */
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
#pragma clang diagnostic pop
{
int status = 0;
pid_t pid = wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
returnValue = NO;
}
else
returnValue = NO;
signal(SIGCHLD, oldSigChildHandler);
return returnValue;
}
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
{
SUParameterAssert(executablePath);
// Get authorization using advice in Apple's Technical Q&A1172
// ...create authorization without specific rights
AuthorizationRef auth = NULL;
OSStatus validAuth = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
// ...then extend authorization with desired rights
if ((validAuth == errAuthorizationSuccess) &&
(auth != NULL))
{
char executableFileSystemRepresentation[PATH_MAX];
[executablePath getFileSystemRepresentation:executableFileSystemRepresentation maxLength:sizeof(executableFileSystemRepresentation)];
// Prepare a right allowing script to execute with privileges
AuthorizationItem right = {
.name = kAuthorizationRightExecute,
.value = executableFileSystemRepresentation,
.valueLength = strlen(executableFileSystemRepresentation),
};
// Package up the single right
AuthorizationRights rights;
memset(&rights,0,sizeof(rights));
rights.count = 1;
rights.items = &right;
// Extend rights to run script
validAuth = AuthorizationCopyRights(auth,
&rights,
kAuthorizationEmptyEnvironment,
(AuthorizationFlags)
(kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed),
NULL);
if (validAuth != errAuthorizationSuccess)
{
// Error, clean up authorization
(void) AuthorizationFree(auth,kAuthorizationFlagDefaults);
auth = NULL;
}
}
return auth;
}
@end
@implementation SUGuidedPackageInstaller
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
{
SUParameterAssert(packagePath);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Preflight
NSString* installerPath = @"/usr/sbin/installer"; // Mac OS X 10.2+ command line installer tool
NSError* error = nil;
// Create authorization for installer executable
BOOL validInstallation = NO;
AuthorizationRef auth = [self authorizationForExecutable:installerPath];
if (auth != NULL)
{
char pathBuffer[PATH_MAX] = {0};
[packagePath getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
// Permission was granted to execute the installer with privileges
char * const arguments[] = {
"-pkg",
pathBuffer,
"-target",
"/",
NULL
};
validInstallation = AuthorizationExecuteWithPrivilegesAndWait(auth,
[installerPath fileSystemRepresentation],
kAuthorizationFlagDefaults,
arguments);
// TODO: wait for communications pipe to close via fileno & CFSocketCreateWithNative
AuthorizationFree(auth,kAuthorizationFlagDefaults);
}
else
{
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Script authorization denied."];
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationToPath:destinationPath
withResult:validInstallation
error:error
completionHandler:completionHandler];
});
});
}
@end
+2 -1
View File
@@ -5,6 +5,7 @@
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
@@ -18,7 +19,7 @@
- (instancetype)initWithBundle:(NSBundle *)aBundle;
@property (readonly, copy) NSString *bundlePath;
@property (readonly, copy) NSString *appSupportPath;
@property (readonly, copy) NSString *appCachePath;
@property (readonly, copy) NSString *installationPath;
@property (readonly, copy) NSString *name;
@property (readonly, copy) NSString *version;
+55 -35
View File
@@ -41,10 +41,10 @@ typedef struct {
{
if ((self = [super init]))
{
if (aBundle == nil) aBundle = [NSBundle mainBundle];
SUParameterAssert(aBundle);
self.bundle = aBundle;
if (![self.bundle bundleIdentifier]) {
SULog(@"Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", self.bundle);
SULog(@"Error: the bundle being updated at %@ has no %@! This will cause preference read/write to not work properly.", self.bundle, kCFBundleIdentifierKey);
}
self.defaultsDomain = [self.bundle objectForInfoDictionaryKey:SUDefaultsDomainKey];
@@ -53,7 +53,8 @@ typedef struct {
}
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
NSString *mainBundleIdentifier = NSBundle.mainBundle.bundleIdentifier;
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:mainBundleIdentifier];
}
return self;
}
@@ -66,55 +67,66 @@ typedef struct {
return [self.bundle bundlePath];
}
- (NSString *)appSupportPath
- (NSString *)appCachePath
{
NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *appSupportPath = nil;
if (!appSupportPaths || [appSupportPaths count] == 0)
{
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = nil;
if ([cachePaths count]) {
cachePath = cachePaths[0];
}
else {
appSupportPath = appSupportPaths[0];
if (!cachePath) {
SULog(@"Failed to find user's cache directory! Using system default");
cachePath = NSTemporaryDirectory();
}
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"];
return appSupportPath;
NSString *name = [self.bundle bundleIdentifier];
if (!name) {
name = [self name];
}
cachePath = [cachePath stringByAppendingPathComponent:name];
cachePath = [cachePath stringByAppendingPathComponent:@"Sparkle"];
return cachePath;
}
- (NSString *)installationPath
{
#if NORMALIZE_INSTALLED_APP_NAME
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:@"CFBundleName"], [[self.bundle bundlePath] pathExtension]]];
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:@"CFBundleName"], [[self.bundle bundlePath] pathExtension]]]]) {
return normalizedAppPath;
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) {
return normalizedAppPath;
}
}
#endif
return [self.bundle bundlePath];
}
- (NSString *)name
- (NSString *__nonnull)name
{
NSString *name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
NSString *name;
// Allow host bundle to provide a custom name
name = [self objectForInfoDictionaryKey:@"SUBundleName"];
if (name) return name;
name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
if (name) return name;
name = [self objectForInfoDictionaryKey:@"CFBundleName"];
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
if (name) return name;
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
}
- (NSString *)version
- (NSString *__nonnull)version
{
NSString *version = [self.bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
if (!version || [version isEqualToString:@""])
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no CFBundleVersion! This attribute is required.", [self bundlePath]];
[NSException raise:@"SUNoVersionException" format:@"This host (%@) has no %@! This attribute is required.", [self bundlePath], (__bridge NSString *)kCFBundleVersionKey];
return version;
}
- (NSString *)displayVersion
- (NSString *__nonnull)displayVersion
{
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (shortVersionString)
@@ -123,7 +135,7 @@ typedef struct {
return [self version]; // Fall back on the normal version string.
}
- (NSImage *)icon
- (NSImage *__nonnull)icon
{
// Cache the application icon.
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
@@ -140,7 +152,7 @@ typedef struct {
if (!icon) {
BOOL isMainBundle = (self.bundle == [NSBundle mainBundle]);
NSString *fileType = isMainBundle ? (NSString *)kUTTypeApplication : (NSString *)kUTTypeBundle;
NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
}
return icon;
@@ -158,17 +170,25 @@ typedef struct {
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
}
- (NSString *)publicDSAKey
- (NSString *__nullable)publicDSAKey
{
// Maybe the key is just a string in the Info.plist.
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
if (key) { return key; }
if (key) {
return key;
}
// More likely, we've got a reference to a Resources file by filename:
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
if (!keyFilename) { return nil; }
NSError *ignoreErr = nil;
return [NSString stringWithContentsOfFile:[self.bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error:&ignoreErr];
if (!keyFilename) {
return nil;
}
NSString *keyPath = [self.bundle pathForResource:keyFilename ofType:nil];
if (!keyPath) {
return nil;
}
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
}
- (NSArray *)systemProfile
+3 -10
View File
@@ -12,21 +12,14 @@
#import <Cocoa/Cocoa.h>
#import "SUVersionComparisonProtocol.h"
@protocol SUInstallerDelegate;
@class SUHost;
@interface SUInstaller : NSObject
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host;
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator;
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id<SUInstallerDelegate>)delegate;
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr;
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
+ (NSString *)updateFolder;
@end
@protocol SUInstallerDelegate <NSObject>
- (void)installerFinishedForHost:(SUHost *)host;
- (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error;
@end
#endif
+61 -61
View File
@@ -9,11 +9,11 @@
#import "SUInstaller.h"
#import "SUPlainInstaller.h"
#import "SUPackageInstaller.h"
#import "SUGuidedPackageInstaller.h"
#import "SUHost.h"
#import "SUConstants.h"
#import "SULog.h"
@implementation SUInstaller
static NSString *sUpdateFolder = nil;
@@ -42,50 +42,50 @@ static NSString *sUpdateFolder = nil;
return NO;
}
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
{
SUParameterAssert(inUpdateFolder);
SUParameterAssert(host);
// Search subdirectories for the application
NSString *currentFile,
*newAppDownloadPath = nil,
*bundleFileName = [[host bundlePath] lastPathComponent],
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
BOOL isPackage = NO;
BOOL isGuided = NO;
NSString *fallbackPackagePath = nil;
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
sUpdateFolder = inUpdateFolder;
while ((currentFile = [dirEnum nextObject]))
{
while ((currentFile = [dirEnum nextObject])) {
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
if ([[currentFile lastPathComponent] isEqualToString:bundleFileName] ||
[[currentFile lastPathComponent] isEqualToString:alternateBundleFileName]) // We found one!
NSString *currentFilename = [currentFile lastPathComponent];
NSString *currentExtension = [currentFile pathExtension];
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
if ([currentFilename isEqualToString:bundleFileName] ||
[currentFilename isEqualToString:alternateBundleFileName]) // We found one!
{
isPackage = NO;
newAppDownloadPath = currentPath;
break;
}
else if ([[currentFile pathExtension] isEqualToString:@"pkg"] ||
[[currentFile pathExtension] isEqualToString:@"mpkg"])
{
if ([[[currentFile lastPathComponent] stringByDeletingPathExtension] isEqualToString:[bundleFileName stringByDeletingPathExtension]])
{
} else if ([currentExtension isEqualToString:@"pkg"] ||
[currentExtension isEqualToString:@"mpkg"]) {
if ([currentFilenameNoExtension isEqualToString:bundleFileNameNoExtension]) {
isPackage = YES;
newAppDownloadPath = currentPath;
break;
}
else
{
} else {
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
fallbackPackagePath = currentPath;
}
}
else
{
} else {
// Try matching on bundle identifiers in case the user has changed the name of the host app
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
if(incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]])
{
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
if (incomingBundle && [incomingBundle.bundleIdentifier isEqualToString:hostBundleIdentifier]) {
isPackage = NO;
newAppDownloadPath = currentPath;
break;
@@ -99,35 +99,45 @@ static NSString *sUpdateFolder = nil;
// We don't have a valid path. Try to use the fallback package.
if (newAppDownloadPath == nil && fallbackPackagePath != nil)
{
if (newAppDownloadPath == nil && fallbackPackagePath != nil) {
isPackage = YES;
newAppDownloadPath = fallbackPackagePath;
}
if (isPackagePtr) *isPackagePtr = isPackage;
if (isPackage) {
// foo.app -> foo.sparkle_guided.pkg or foo.sparkle_guided.mpkg
if ([[[newAppDownloadPath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_guided"]) {
isGuided = YES;
}
}
if (isPackagePtr)
*isPackagePtr = isPackage;
if (isGuidedPtr)
*isGuidedPtr = isGuided;
if (!newAppDownloadPath) {
SULog(@"Searched %@ for %@.(app|pkg)", inUpdateFolder, bundleFileNameNoExtension);
}
return newAppDownloadPath;
}
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
BOOL isPackage = NO;
NSString *path = [self installSourcePathInUpdateFolder:updateFolder forHost:host isPackage:&isPackage];
return isPackage ? nil : path;
}
BOOL isGuided = NO;
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage isGuided:&isGuided];
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator
{
BOOL isPackage = NO;
NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage];
if (newAppDownloadPath == nil)
{
[self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] delegate:delegate];
}
else
{
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class])performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate versionComparator:comparator];
if (newAppDownloadPath == nil) {
[self finishInstallationToPath:installationPath withResult:NO error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler];
} else {
if (isPackage && isGuided) {
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
} else if (isPackage) {
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
} else {
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
}
}
}
@@ -140,8 +150,7 @@ static NSString *sUpdateFolder = nil;
NSTask *mdimport = [[NSTask alloc] init];
[mdimport setLaunchPath:@"/usr/bin/mdimport"];
[mdimport setArguments:@[installationPath]];
@try
{
@try {
[mdimport launch];
[mdimport waitUntilExit];
}
@@ -152,29 +161,20 @@ static NSString *sUpdateFolder = nil;
}
}
#define SUNotifyDictHostKey @"SUNotifyDictHost"
#define SUNotifyDictErrorKey @"SUNotifyDictError"
#define SUNotifyDictDelegateKey @"SUNotifyDictDelegate"
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id<SUInstallerDelegate>)delegate
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler
{
if (result)
{
if (result) {
[self mdimportInstallationPath:installationPath];
if ([delegate respondsToSelector:@selector(installerFinishedForHost:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[delegate installerFinishedForHost:host];
});
}
}
else
{
if ([delegate respondsToSelector:@selector(installerForHost:failedWithError:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[delegate installerForHost:host failedWithError:error];
});
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(nil);
});
} else {
if (!error) {
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:nil];
}
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(error);
});
}
}
+3 -2
View File
@@ -12,7 +12,8 @@
Your tech support will hug you if you tell them about this.
*/
#pragma once
#ifndef SULOG_H
#define SULOG_H
// -----------------------------------------------------------------------------
// Headers:
@@ -28,4 +29,4 @@
void SUClearLog(void);
void SULog(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
#endif
+10 -7
View File
@@ -18,7 +18,7 @@
// Constants:
// -----------------------------------------------------------------------------
#define LOG_FILE_PATH @"~/Library/Logs/SparkleUpdateLog.log"
static NSString *const SULogFilePath = @"~/Library/Logs/SparkleUpdateLog.log";
// -----------------------------------------------------------------------------
@@ -30,17 +30,14 @@
//
// TAKES:
// sender - Object that sent this message, typically of type X.
//
// GIVES:
// param - who owns the returned value?
// result - same here.
// -----------------------------------------------------------------------------
void SUClearLog(void)
{
FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "w");
FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "w");
if (logfile) {
fclose(logfile);
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
}
}
@@ -57,12 +54,18 @@ void SUClearLog(void)
void SULog(NSString *format, ...)
{
static BOOL loggedYet = NO;
if (!loggedYet) {
loggedYet = YES;
SUClearLog();
}
va_list ap;
va_start(ap, format);
NSString *theStr = [[NSString alloc] initWithFormat:format arguments:ap];
NSLog(@"Sparkle: %@", theStr);
FILE *logfile = fopen([[LOG_FILE_PATH stringByExpandingTildeInPath] fileSystemRepresentation], "a");
FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "a");
if (logfile) {
theStr = [NSString stringWithFormat:@"%@: %@\n", [NSDate date], theStr];
NSData *theData = [theStr dataUsingEncoding:NSUTF8StringEncoding];
+2
View File
@@ -9,6 +9,8 @@
#ifndef SUPACKAGEINSTALLER_H
#define SUPACKAGEINSTALLER_H
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
+3 -3
View File
@@ -12,7 +12,7 @@
@implementation SUPackageInstaller
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)__unused comparator
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
{
// Run installer using the "open" command to ensure it is launched in front of current application.
// -W = wait until the app has quit.
@@ -23,7 +23,7 @@
if (![[NSFileManager defaultManager] fileExistsAtPath:command]) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find Apple's installer tool!" }];
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
[self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler];
return;
}
@@ -33,7 +33,7 @@
// Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine.
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationToPath:installationPath withResult:YES host:host error:nil delegate:delegate];
[self finishInstallationToPath:installationPath withResult:YES error:nil completionHandler:completionHandler];
});
});
}
+71 -61
View File
@@ -22,14 +22,21 @@
@".tar.gz": @"extractTGZ",
@".tgz": @"extractTGZ",
@".tar.bz2": @"extractTBZ",
@".tbz": @"extractTBZ" };
@".tbz": @"extractTBZ",
@".tar.xz": @"extractTXZ",
@".txz": @"extractTXZ",
@".tar.lzma": @"extractTXZ"};
NSString *lastPathComponent = [path lastPathComponent];
for (NSString *currentType in typeSelectorDictionary)
{
NSString *value = typeSelectorDictionary[currentType];
assert(value);
if ([currentType length] > [lastPathComponent length]) continue;
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
return NSSelectorFromString(typeSelectorDictionary[currentType]);
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) {
return NSSelectorFromString(value);
}
}
return NULL;
}
@@ -45,73 +52,69 @@
}
// This method abstracts the types that use a command line tool piping data from stdin.
- (void)extractArchivePipingDataToCommand:(NSString *)command
- (void)extractArchivePipingDataToCommand:(NSString *)command args:(NSArray*)args
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
@autoreleasepool {
FILE *fp = NULL, *cmdFP = NULL;
char *oldDestinationString = NULL;
// We have to declare these before a goto to prevent an error under ARC.
// No, we cannot have them in the dispatch_async calls, as the goto "jump enters
// lifetime of block which strongly captures a variable"
dispatch_block_t delegateSuccess = ^{
[self notifyDelegateOfSuccess];
};
dispatch_block_t delegateFailure = ^{
[self notifyDelegateOfFailure];
};
SULog(@"Extracting %@ using '%@'", self.archivePath, command);
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
SULog(@"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
// Get the file size.
NSNumber *fs = [[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil][NSFileSize];
if (fs == nil) goto reportError;
NSUInteger expectedLength = [[[NSFileManager defaultManager] attributesOfItemAtPath:self.archivePath error:nil][NSFileSize] unsignedIntegerValue];
if (expectedLength > 0) {
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:self.archivePath];
// Thank you, Allan Odgaard!
// (who wrote the following extraction alg.)
fp = fopen([self.archivePath fileSystemRepresentation], "r");
if (!fp) goto reportError;
NSPipe *pipe = [NSPipe pipe];
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
oldDestinationString = getenv("DESTINATION");
setenv("DESTINATION", [[self.archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
cmdFP = popen([command fileSystemRepresentation], "w");
size_t written;
if (!cmdFP) goto reportError;
NSTask *task = [[NSTask alloc] init];
[task setStandardInput:[pipe fileHandleForReading]];
[task setStandardError:[NSFileHandle fileHandleWithStandardError]];
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
[task setLaunchPath:command];
[task setArguments:[args arrayByAddingObject:destination]];
[task launch];
char buf[32 * 1024];
size_t len;
while((len = fread(buf, 1, 32*1024, fp)))
{
written = fwrite(buf, 1, len, cmdFP);
if( written < len )
{
pclose(cmdFP);
goto reportError;
NSUInteger bytesRead = 0;
do {
NSData *data = [archiveInput readDataOfLength:256*1024];
NSUInteger len = [data length];
if (!len) {
break;
}
bytesRead += len;
[archiveOutput writeData:data];
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfProgress:(double)bytesRead / (double)expectedLength];
});
}
while(bytesRead < expectedLength);
[archiveOutput closeFile];
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfExtractedLength:len];
});
}
pclose(cmdFP);
if (ferror(fp)) {
goto reportError;
[task waitUntilExit];
if ([task terminationStatus] == 0) {
if (bytesRead == expectedLength) {
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfSuccess];
});
return;
} else {
SULog(@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesRead, (long)expectedLength);
}
} else {
SULog(@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]);
}
} else {
SULog(@"Extraction failed, archive '%@' is empty", self.archivePath);
}
dispatch_async(dispatch_get_main_queue(), delegateSuccess);
goto finally;
reportError:
dispatch_async(dispatch_get_main_queue(), delegateFailure);
finally:
if (fp)
fclose(fp);
if (oldDestinationString)
setenv("DESTINATION", oldDestinationString, 1);
else
unsetenv("DESTINATION");
dispatch_async(dispatch_get_main_queue(), ^{
[self notifyDelegateOfFailure];
});
}
}
@@ -119,28 +122,35 @@
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
[self extractArchivePipingDataToCommand:@"tar -xC \"$DESTINATION\""];
[self extractArchivePipingDataToCommand:@"/usr/bin/tar" args:@[@"-xC"]];
}
- (void)extractTGZ
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
[self extractArchivePipingDataToCommand:@"tar -zxC \"$DESTINATION\""];
[self extractArchivePipingDataToCommand:@"/usr/bin/tar" args:@[@"-zxC"]];
}
- (void)extractTBZ
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
[self extractArchivePipingDataToCommand:@"tar -jxC \"$DESTINATION\""];
[self extractArchivePipingDataToCommand:@"/usr/bin/tar" args:@[@"-jxC"]];
}
- (void)extractZIP
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
[self extractArchivePipingDataToCommand:@"ditto -x -k - \"$DESTINATION\""];
[self extractArchivePipingDataToCommand:@"/usr/bin/ditto" args:@[@"-x",@"-k",@"-"]];
}
- (void)extractTXZ
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
[self extractArchivePipingDataToCommand:@"/usr/bin/tar" args:@[@"-zxC"]];
}
+ (void)load
+3 -1
View File
@@ -9,6 +9,8 @@
#ifndef SUPLAININSTALLER_H
#define SUPLAININSTALLER_H
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
@@ -21,7 +23,7 @@
@interface SUPlainInstaller : SUInstaller
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator;
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
@end
+23 -13
View File
@@ -8,41 +8,51 @@
#import "SUPlainInstaller.h"
#import "SUPlainInstallerInternals.h"
#import "SUCodeSigningVerifier.h"
#import "SUConstants.h"
#import "SUHost.h"
@implementation SUPlainInstaller
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id<SUInstallerDelegate>)delegate versionComparator:(id<SUVersionComparison>)comparator
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
// Prevent malicious downgrades:
#if !PERMIT_AUTOMATED_DOWNGRADES
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedDescending)
{
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]];
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
[self finishInstallationToPath:installationPath withResult:NO host:host error:error delegate:delegate];
return;
SUParameterAssert(host);
BOOL allowDowngrades = SPARKLE_AUTOMATED_DOWNGRADES;
// Prevent malicious downgrades
if (!allowDowngrades) {
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) {
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
[self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler];
return;
}
}
#endif
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
NSString *oldPath = [host bundlePath];
NSString *tempName = [self temporaryNameForPath:[host installationPath]];
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName error:&error];
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error];
if (result) {
if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) {
result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error];
}
}
if (result) {
BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath:oldPath];
BOOL differentFromNew = ![oldPath isEqualToString:installationPath];
if (haveOld && differentFromNew) {
[self _movePathToTrash:oldPath]; // On success, trash old copy if there's still one due to renaming.
[self _movePathToTrash:oldPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER]; // On success, trash old copy if there's still one due to renaming.
}
}
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationToPath:installationPath withResult:result host:host error:error delegate:delegate];
[self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler];
});
});
}
+4 -2
View File
@@ -9,12 +9,14 @@
#ifndef SUPLAININSTALLERINTERNALS_H
#define SUPLAININSTALLERINTERNALS_H
#import <Foundation/Foundation.h>
#import "SUPlainInstaller.h"
@interface SUPlainInstaller (Internals)
+ (NSString *)temporaryNameForPath:(NSString *)path;
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error;
+ (void)_movePathToTrash:(NSString *)path;
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp appendVersion:(BOOL)a error:(NSError **)error;
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)a;
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error;
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
@end
+69 -49
View File
@@ -61,14 +61,14 @@ static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, const char *const *arguments)
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments)
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess)
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
{
int status;
pid_t pid = wait(&status);
@@ -90,7 +90,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
// Let's try to read the version number so the filename will be more meaningful.
NSString *postFix;
NSString *version;
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
@@ -107,7 +107,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
return [tempDir lastPathComponent];
}
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash:(BOOL *)outDidFindTrash
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path appendVersion:(BOOL)appendVersion didFindTrash:(BOOL *)outDidFindTrash
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
NSString *tempDir = nil;
@@ -117,7 +117,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
FSCatalogInfo catInfo;
memset(&catInfo, 0, sizeof(catInfo));
OSStatus err = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
OSStatus err = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
if( err == noErr )
{
err = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
@@ -138,23 +138,24 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (!tempDir)
tempDir = [path stringByDeletingLastPathComponent];
// Let's try to read the version number so the filename will be more meaningful.
#if TRY_TO_APPEND_VERSION_NUMBER
NSString *postFix = nil;
NSString *version = nil;
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:@"CFBundleVersion"]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
}
else {
postFix = @"old";
// Let's try to read the version number so the filename will be more meaningful
NSString *prefix;
if (appendVersion) {
NSString *postFix = nil;
NSString *version = nil;
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
{
NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
[validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]];
postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]];
}
else {
postFix = @"old";
}
prefix = [NSString stringWithFormat:@"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
} else {
prefix = [[path lastPathComponent] stringByDeletingPathExtension];
}
NSString *prefix = [NSString stringWithFormat:@"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix];
#else
NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension];
#endif
NSString *tempName = [prefix stringByAppendingPathExtension:[path pathExtension]];
tempDir = [tempDir stringByAppendingPathComponent:tempName];
@@ -171,9 +172,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
const char *tmpPath = [tmp fileSystemRepresentation];
const char *dstPath = [dst fileSystemRepresentation];
char srcPath[PATH_MAX] = {0};
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
char tmpPath[PATH_MAX] = {0};
[tmp getFileSystemRepresentation:tmpPath maxLength:sizeof(tmpPath)];
char dstPath[PATH_MAX] = {0};
[dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)];
struct stat dstSB;
if (stat(dstPath, &dstSB) != 0) // Doesn't exist yet, try containing folder.
@@ -227,16 +233,16 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
char *coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
if (!res)
SULog(@"chown -R %s %s failed.", uidgid, srcPath);
SULog(@"chown -R %@ %@ failed.", @(uidgid), @(srcPath));
}
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char *rmParams[] = { "-rf", tmpPath, NULL };
char *rmParams[] = { "-rf", tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"rm failed");
@@ -244,7 +250,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res && haveDst) // Move old exe to tmp path.
{
const char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
if (!res)
SULog(@"mv 1 failed");
@@ -252,7 +258,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Move new exe to old exe's path.
{
const char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2);
if (!res)
SULog(@"mv 2 failed");
@@ -303,9 +309,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
const char *dstPath = [dst fileSystemRepresentation];
const char *dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
char srcPath[PATH_MAX] = {0};
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
char dstPath[PATH_MAX] = {0};
[dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)];
char dstContainerPath[PATH_MAX] = {0};
[dst.stringByDeletingLastPathComponent getFileSystemRepresentation:dstContainerPath maxLength:sizeof(dstContainerPath)];
struct stat dstSB;
stat(dstContainerPath, &dstSB);
@@ -331,7 +342,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
char *coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
if (!res)
SULog(@"Can't set permissions");
@@ -340,7 +351,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst];
if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char *rmParams[] = { "-rf", dstPath, NULL };
char *rmParams[] = { "-rf", dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"Can't remove destination file");
@@ -348,7 +359,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Move!.
{
const char *mvParams[] = { "-f", srcPath, dstPath, NULL };
char *mvParams[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
if (!res)
SULog(@"Can't move source file");
@@ -377,7 +388,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
char srcPath[PATH_MAX] = {0};
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
@@ -396,7 +408,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char *rmParams[] = { "-rf", srcPath, NULL };
char *rmParams[] = { "-rf", srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"Can't remove destination file");
@@ -431,14 +443,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
return success;
}
+ (void)_movePathToTrash:(NSString *)path
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)appendVersion
{
//SULog(@"Moving %@ to the trash.", path);
NSInteger tag = 0;
if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag])
{
BOOL didFindTrash = NO;
NSString *trashPath = [self _temporaryCopyNameForPath:path didFindTrash:&didFindTrash];
NSString *trashPath = [self _temporaryCopyNameForPath:path appendVersion:appendVersion didFindTrash:&didFindTrash];
if( didFindTrash )
{
NSError *err = nil;
@@ -452,15 +464,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
}
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp error:(NSError *__autoreleasing *)error
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error
{
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
OSStatus err;
BOOL hadFileAtDest = NO, didFindTrash = NO;
NSString *tmpPath = [self _temporaryCopyNameForPath:dst didFindTrash:&didFindTrash];
NSString *tmpPath = [self _temporaryCopyNameForPath:dst appendVersion:appendVersion didFindTrash:&didFindTrash];
// Make FSRef for destination:
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
err = FSPathMakeRefWithOptions((const UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error.
if( hadFileAtDest )
{
@@ -480,12 +492,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if( hadFileAtDest )
{
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
err = FSPathMakeRef((const UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
if (err != noErr)
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
}
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
err = FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
if (err == noErr && hadFileAtDest)
{
@@ -499,7 +511,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
}
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
err = FSPathMakeRef((const UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
if (err == noErr)
{
NSFileManager *manager = [[NSFileManager alloc] init];
@@ -571,7 +583,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
NSFileManager *manager = [NSFileManager defaultManager];
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
if (!&NSURLQuarantinePropertiesKey) {
NSString *const quarantineAttribute = (NSString*)kLSItemQuarantineProperties;
NSString *const quarantineAttribute = (__bridge NSString *)kLSItemQuarantineProperties;
const int removeXAttrOptions = XATTR_NOFOLLOW;
[self removeXAttr:quarantineAttribute
@@ -598,7 +610,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
#endif
NSURL *rootURL = [NSURL fileURLWithPath:root];
[rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
id rootResourceValue = nil;
[rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL];
if (rootResourceValue) {
[rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
}
// Only recurse if it's actually a directory. Don't recurse into a
// root-level symbolic link.
@@ -611,7 +627,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
for (NSURL *file in directoryEnumerator) {
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
id fileResourceValue = nil;
[file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL];
if (fileResourceValue) {
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
}
}
}
}
+10 -2
View File
@@ -43,10 +43,18 @@
- (void)abortUpdateWithError:(NSError *)error
{
if (self.showErrors)
if (self.showErrors) {
[super abortUpdateWithError:error];
else
} 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
+3 -2
View File
@@ -9,7 +9,8 @@
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
#define SUSTANDARDVERSIONCOMPARATOR_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
/*!
@@ -19,7 +20,7 @@
It's "dumb" in that it does essentially string comparison,
in components split by character type.
*/
@interface SUStandardVersionComparator : NSObject <SUVersionComparison>
SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison>
/*!
Returns a singleton instance of the comparator.
+2 -2
View File
@@ -24,11 +24,11 @@
return defaultComparator;
}
typedef enum {
typedef NS_ENUM(NSInteger, SUCharacterType) {
kNumberType,
kStringType,
kSeparatorType,
} SUCharacterType;
};
- (SUCharacterType)typeOfCharacter:(NSString *)character
{
+1 -1
View File
@@ -31,7 +31,7 @@
- (instancetype)initWithHost:(SUHost *)aHost
{
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
self = [super initWithWindowNibName:@"SUStatus"];
if (self)
{
self.host = aHost;
+1 -1
View File
@@ -9,7 +9,7 @@
#ifndef SUSYSTEMPROFILER_H
#define SUSYSTEMPROFILER_H
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@class SUHost;
@interface SUSystemProfiler : NSObject
+25 -11
View File
@@ -7,11 +7,24 @@
// Adapted from Sparkle+, by Tom Harrington.
//
#import <Cocoa/Cocoa.h>
#import "SUSystemProfiler.h"
#import "SUHost.h"
#include <sys/sysctl.h>
static NSString *const SUSystemProfilerApplicationNameKey = @"appName";
static NSString *const SUSystemProfilerApplicationVersionKey = @"appVersion";
static NSString *const SUSystemProfilerCPU64bitKey = @"cpu64bit";
static NSString *const SUSystemProfilerCPUCountKey = @"ncpu";
static NSString *const SUSystemProfilerCPUFrequencyKey = @"cpuFreqMHz";
static NSString *const SUSystemProfilerCPUTypeKey = @"cputype";
static NSString *const SUSystemProfilerCPUSubtypeKey = @"cpusubtype";
static NSString *const SUSystemProfilerHardwareModelKey = @"model";
static NSString *const SUSystemProfilerMemoryKey = @"ramMB";
static NSString *const SUSystemProfilerOperatingSystemVersionKey = @"osVersion";
static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
@implementation SUSystemProfiler
+ (SUSystemProfiler *)sharedSystemProfiler
{
@@ -42,7 +55,7 @@
// OS version
NSString *currentSystemVersion = [SUHost systemVersionString];
if (currentSystemVersion != nil) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"osVersion", @"OS Version", currentSystemVersion, currentSystemVersion] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerOperatingSystemVersionKey, @"OS Version", currentSystemVersion, currentSystemVersion] forKeys:profileDictKeys]];
}
// CPU type (decoder info for values found here is in mach/machine.h)
@@ -52,11 +65,12 @@
cpuType = value;
NSString *visibleCPUType;
switch (value) {
case CPU_TYPE_ARM: visibleCPUType = @"ARM"; break;
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
default: visibleCPUType = @"Unknown"; break;
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cputype", @"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUTypeKey, @"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.cpu64bit_capable", &value, &length, NULL, 0);
if (error != 0) {
@@ -70,7 +84,7 @@
if (error == 0) {
is64bit = value == 1;
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpu64bit", @"CPU is 64-Bit?", @(is64bit), is64bit ? @"Yes" : @"No"] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPU64bitKey, @"CPU is 64-Bit?", @(is64bit), is64bit ? @"Yes" : @"No"] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.cpusubtype", &value, &length, NULL, 0);
if (error == 0) {
@@ -90,7 +104,7 @@
} else {
visibleCPUSubType = @"Other";
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpusubtype", @"CPU Subtype", @(value), visibleCPUSubType] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUSubtypeKey, @"CPU Subtype", @(value), visibleCPUSubType] forKeys:profileDictKeys]];
}
error = sysctlbyname("hw.model", NULL, &length, NULL, 0);
if (error == 0) {
@@ -103,7 +117,7 @@
if (visibleModelName == nil) {
visibleModelName = rawModelName;
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"model", @"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerHardwareModelKey, @"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]];
}
free(cpuModel);
}
@@ -112,24 +126,24 @@
// Number of CPUs
error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0);
if (error == 0) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ncpu", @"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUCountKey, @"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]];
}
// User preferred language
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defs objectForKey:@"AppleLanguages"];
if ([languages count] > 0) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"lang", @"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerPreferredLanguageKey, @"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]];
}
// Application sending the request
NSString *appName = [host name];
if (appName) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appName", @"Application Name", appName, appName] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerApplicationNameKey, @"Application Name", appName, appName] forKeys:profileDictKeys]];
}
NSString *appVersion = [host version];
if (appVersion) {
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appVersion", @"Application Version", appVersion, appVersion] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerApplicationVersionKey, @"Application Version", appVersion, appVersion] forKeys:profileDictKeys]];
}
// Number of displays?
@@ -139,7 +153,7 @@
size_t hz_size = sizeof(unsigned long);
if (sysctlbyname("hw.cpufrequency", &hz, &hz_size, NULL, 0) == 0) {
unsigned long mhz = hz / 1000000;
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cpuFreqMHz", @"CPU Speed (GHz)", @(mhz), @(mhz / 1000.)] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUFrequencyKey, @"CPU Speed (MHz)", @(mhz), @(mhz / 1000.)] forKeys:profileDictKeys]];
}
// amount of RAM
@@ -147,7 +161,7 @@
size_t bytes_size = sizeof(unsigned long);
if (sysctlbyname("hw.memsize", &bytes, &bytes_size, NULL, 0) == 0) {
double megabytes = bytes / (1024. * 1024.);
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ramMB", @"Memory (MB)", @(megabytes), @(megabytes)] forKeys:profileDictKeys]];
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerMemoryKey, @"Memory (MB)", @(megabytes), @(megabytes)] forKeys:profileDictKeys]];
}
return profileArray;
+1 -1
View File
@@ -15,7 +15,7 @@
@class SUStatusController;
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUUpdateAlertDelegate>
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
- (void)showModalAlert:(NSAlert *)alert;
- (IBAction)cancelDownload:(id)sender;
+19 -21
View File
@@ -28,8 +28,9 @@
- (void)didFindValidUpdate
{
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host];
[self.updateAlert setDelegate:self];
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:choice];
}];
id<SUVersionDisplay> versDisp = nil;
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
@@ -44,8 +45,7 @@
// 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 ([self.host isBackgroundApplication]) {
[[self.updateAlert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
@@ -63,11 +63,10 @@
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.")
defaultButton:SULocalizedString(@"OK", nil)
alternateButton:nil
otherButton:nil
informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates.");
alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
[alert addButtonWithTitle:SULocalizedString(@"OK", nil)];
[self showModalAlert:alert];
[self abortUpdate];
}
@@ -75,15 +74,14 @@
- (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification
{
[[self.updateAlert window] makeKeyAndOrderFront:self];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSApplicationDidBecomeActiveNotification" object:NSApp];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)updateAlert:(SUUpdateAlert *)__unused alert finishedWithChoice:(SUUpdateAlertChoice)choice
- (void)updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice
{
self.updateAlert = nil;
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice)
{
switch (choice) {
case SUInstallUpdateChoice:
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
@@ -154,16 +152,13 @@
[super extractUpdate];
}
- (void)unarchiver:(SUUnarchiver *)__unused ua extractedLength:(unsigned long)length
- (void)unarchiver:(SUUnarchiver *)__unused ua extractedProgress:(double)progress
{
// We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress.
if ([self.statusController maxProgressValue] == 0.0)
{
NSDictionary *attributes;
attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.downloadPath error:nil];
[self.statusController setMaxProgressValue:[attributes[NSFileSize] doubleValue]];
if ([self.statusController maxProgressValue] == 0.0) {
[self.statusController setMaxProgressValue:1];
}
[self.statusController setProgressValue:[self.statusController progressValue] + (double)length];
[self.statusController setProgressValue:progress];
}
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua
@@ -205,7 +200,10 @@
- (void)abortUpdateWithError:(NSError *)error
{
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", [error localizedDescription]];
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = SULocalizedString(@"Update Error!", nil);
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
[self showModalAlert:alert];
[super abortUpdateWithError:error];
}
+5 -3
View File
@@ -9,16 +9,18 @@
#ifndef SUUNARCHIVER_H
#define SUUNARCHIVER_H
#import <Foundation/Foundation.h>
@class SUHost;
@protocol SUUnarchiverDelegate;
@interface SUUnarchiver : NSObject
@property (copy, readonly) NSString *archivePath;
@property (weak, readonly) SUHost *updateHost;
@property (copy, readonly) NSString *updateHostBundlePath;
@property (weak) id<SUUnarchiverDelegate> delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host;
- (void)start;
@end
@@ -27,7 +29,7 @@
- (void)unarchiverDidFinish:(SUUnarchiver *)unarchiver;
- (void)unarchiverDidFail:(SUUnarchiver *)unarchiver;
@optional
- (void)unarchiver:(SUUnarchiver *)unarchiver extractedLength:(unsigned long)length;
- (void)unarchiver:(SUUnarchiver *)unarchiver extractedProgress:(double)progress;
@end
#endif
+8 -8
View File
@@ -18,15 +18,15 @@
@implementation SUUnarchiver
@synthesize archivePath;
@synthesize updateHost;
@synthesize updateHostBundlePath;
@synthesize delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHost:(SUHost *)host
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)hostPath
{
for (id current in [self unarchiverImplementations])
{
if ([current canUnarchivePath:path]) {
return [[current alloc] initWithPath:path host:host];
return [[current alloc] initWithPath:path hostBundlePath:hostPath];
}
}
return nil;
@@ -39,12 +39,12 @@
// No-op
}
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host
- (instancetype)initWithPath:(NSString *)path hostBundlePath:(NSString *)hostPath
{
if ((self = [super init]))
{
archivePath = [path copy];
updateHost = host;
updateHostBundlePath = hostPath;
}
return self;
}
@@ -54,10 +54,10 @@
return NO;
}
- (void)notifyDelegateOfExtractedLength:(size_t)length
- (void)notifyDelegateOfProgress:(double)progress
{
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) {
[self.delegate unarchiver:self extractedLength:length];
if ([self.delegate respondsToSelector:@selector(unarchiver:extractedProgress:)]) {
[self.delegate unarchiver:self extractedProgress:progress];
}
}
+2 -2
View File
@@ -16,9 +16,9 @@
+ (void)registerImplementation:(Class)implementation;
+ (NSArray *)unarchiverImplementations;
+ (BOOL)canUnarchivePath:(NSString *)path;
- (instancetype)initWithPath:(NSString *)path host:(SUHost *)host;
- (instancetype)initWithPath:(NSString *)archive hostBundlePath:(NSString *)host;
- (void)notifyDelegateOfExtractedLength:(size_t)length;
- (void)notifyDelegateOfProgress:(double)progress;
- (void)notifyDelegateOfSuccess;
- (void)notifyDelegateOfFailure;
@end
+3 -11
View File
@@ -14,21 +14,19 @@
@protocol SUUpdateAlertDelegate;
typedef enum
{
typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
SUInstallUpdateChoice,
SURemindMeLaterChoice,
SUSkipThisVersionChoice,
SUOpenInfoURLChoice
} SUUpdateAlertChoice;
};
@class WebView, SUAppcastItem, SUHost;
@interface SUUpdateAlert : SUWindowController
@property (weak) id<SUUpdateAlertDelegate> delegate;
@property (weak) id<SUVersionDisplay> versionDisplayer;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host completionBlock:(void(^)(SUUpdateAlertChoice))c;
- (IBAction)installUpdate:sender;
- (IBAction)skipThisVersion:sender;
@@ -36,10 +34,4 @@ typedef enum
@end
@protocol SUUpdateAlertDelegate <NSObject>
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
@optional
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate:(BOOL *)shouldAllowAutoUpdate;
@end
#endif
+20 -21
View File
@@ -21,6 +21,7 @@
@property (strong) SUAppcastItem *updateItem;
@property (strong) SUHost *host;
@property (strong) void(^completionBlock)(SUUpdateAlertChoice);
@property (strong) NSProgressIndicator *releaseNotesSpinner;
@property (assign) BOOL webViewFinishedLoading;
@@ -36,7 +37,7 @@
@implementation SUUpdateAlert
@synthesize delegate;
@synthesize completionBlock;
@synthesize versionDisplayer;
@synthesize updateItem;
@@ -52,11 +53,12 @@
@synthesize skipButton;
@synthesize laterButton;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
{
self = [super initWithHost:host windowNibName:@"SUUpdateAlert"];
self = [super initWithWindowNibName:@"SUUpdateAlert"];
if (self)
{
self.completionBlock = block;
host = aHost;
updateItem = item;
[self setShouldCascadeWindows:NO];
@@ -79,8 +81,8 @@
[self.releaseNotesView setPolicyDelegate:nil];
[self.releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
[self close];
if ([self.delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
[self.delegate updateAlert:self finishedWithChoice:choice];
self.completionBlock(choice);
self.completionBlock = nil;
}
- (IBAction)installUpdate:(id)__unused sender
@@ -105,18 +107,16 @@
- (void)displayReleaseNotes
{
// Set the default font
[self.releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
self.releaseNotesView.preferencesIdentifier = SUBundleIdentifier;
WebPreferences *prefs = [self.releaseNotesView preferences];
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
familyName = @"Lucida Grande";
}
[prefs setStandardFontFamily:familyName];
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
[prefs setPlugInsEnabled:NO];
[self.releaseNotesView setFrameLoadDelegate:self];
[self.releaseNotesView setPolicyDelegate:self];
prefs.plugInsEnabled = NO;
self.releaseNotesView.frameLoadDelegate = self;
self.releaseNotesView.policyDelegate = self;
// Set the default font
// "-apple-system-font" is a reference to the system UI font on OS X. "-apple-system" is the new recommended token, but for backward compatibility we can't use it.
prefs.standardFontFamily = @"-apple-system-font";
prefs.defaultFontSize = (int)[NSFont systemFontSize];
// Stick a nice big spinner in the middle of the web view until the page is loaded.
NSRect frame = [[self.releaseNotesView superview] frame];
@@ -164,10 +164,6 @@
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey])
allowAutoUpdates = [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
// Give delegate a chance to modify this choice:
if (self.delegate && [self.delegate respondsToSelector:@selector(updateAlert:shouldAllowAutoUpdate:)])
[self.delegate updateAlert:self shouldAllowAutoUpdate:&allowAutoUpdates];
return allowAutoUpdates;
}
@@ -241,7 +237,10 @@
- (void)webView:(WebView *)__unused sender decidePolicyForNavigationAction:(NSDictionary *)__unused actionInformation request:(NSURLRequest *)request frame:(WebFrame *)__unused frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
if (self.webViewFinishedLoading) {
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
NSURL *requestURL = request.URL;
if (requestURL) {
[[NSWorkspace sharedWorkspace] openURL:requestURL];
}
[listener ignore];
}
+2 -2
View File
@@ -11,10 +11,10 @@
#import "SUWindowController.h"
typedef enum {
typedef NS_ENUM(NSInteger, SUPermissionPromptResult) {
SUAutomaticallyCheck,
SUDoNotAutomaticallyCheck
} SUPermissionPromptResult;
};
@protocol SUUpdatePermissionPromptDelegate;
+11 -4
View File
@@ -45,7 +45,7 @@
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile delegate:(id<SUUpdatePermissionPromptDelegate>)d
{
self = [super initWithHost:aHost windowNibName:@"SUUpdatePermissionPrompt"];
self = [super initWithWindowNibName:@"SUUpdatePermissionPrompt"];
if (self)
{
host = aHost;
@@ -63,10 +63,17 @@
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
if ([aHost isBackgroundApplication]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; }
if ([aHost isBackgroundApplication]) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
[NSApp runModalForWindow:[prompt window]];
if (![NSApp modalWindow]) { // do not prompt if there is is another modal window on screen
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
NSWindow *window = [prompt window];
if (window) {
[NSApp runModalForWindow:window];
}
}
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }
+39 -26
View File
@@ -9,6 +9,8 @@
#ifndef SUUPDATER_H
#define SUUPDATER_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@@ -22,15 +24,16 @@
This class is used to configure the update paramters as well as manually
and automatically schedule and control checks for updates.
*/
@interface SUUpdater : NSObject
SU_EXPORT @interface SUUpdater : NSObject
@property (weak) IBOutlet id<SUUpdaterDelegate> delegate;
@property (unsafe_unretained) IBOutlet id<SUUpdaterDelegate> delegate;
+ (SUUpdater *)sharedUpdater;
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
- (instancetype)initForBundle:(NSBundle *)bundle;
@property (readonly, strong) NSBundle *hostBundle;
@property (strong, readonly) NSBundle *sparkleBundle;
@property BOOL automaticallyChecksForUpdates;
@@ -45,6 +48,8 @@
@property (nonatomic, copy) NSString *userAgentString;
@property (copy) NSDictionary *httpHeaders;
@property BOOL sendsSystemProfile;
@property BOOL automaticallyDownloadsUpdates;
@@ -107,17 +112,17 @@
// SUUpdater Notifications for events that might be interesting to more than just the delegate
// The updater will be the notification object
// -----------------------------------------------------------------------------
extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
extern NSString *const SUUpdaterDidFindValidUpdateNotification;
extern NSString *const SUUpdaterDidNotFindUpdateNotification;
extern NSString *const SUUpdaterWillRestartNotification;
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
extern NSString *const SUUpdaterAppcastItemNotificationKey;
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
extern NSString *const SUUpdaterAppcastNotificationKey;
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
@@ -205,6 +210,24 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
/*!
Called immediately before downloading the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be downloaded.
\param request The mutable URL request that will be used to download the update.
*/
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
/*!
Called after the specified update failed to download.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that failed to download.
\param error The error generated by the failed download.
*/
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
/*!
Called immediately before installing the specified update.
@@ -311,24 +334,14 @@ extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item;
/*!
Called after an update is aborted due to an error.
\param updater The SUUpdater instance.
\param error The error that caused the abort
*/
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
@end
// -----------------------------------------------------------------------------
// Constants:
// -----------------------------------------------------------------------------
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
#if defined(DEBUG) && DEBUG && 0
#define SU_MIN_CHECK_INTERVAL 60
#else
#define SU_MIN_CHECK_INTERVAL 60 * 60
#endif
#if defined(DEBUG) && DEBUG && 0
#define SU_DEFAULT_CHECK_INTERVAL 60
#else
#define SU_DEFAULT_CHECK_INTERVAL 60 * 60 * 24
#endif
#endif
+34 -36
View File
@@ -29,6 +29,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@interface SUUpdater () <SUUpdatePermissionPromptDelegate>
@property (strong) NSTimer *checkTimer;
@property (strong) NSBundle *sparkleBundle;
- (instancetype)initForBundle:(NSBundle *)bundle;
- (void)startUpdateCycle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
@@ -51,11 +53,10 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize delegate;
@synthesize checkTimer;
@synthesize userAgentString = customUserAgentString;
@synthesize httpHeaders;
@synthesize driver;
@synthesize host;
#pragma mark Initialization
@synthesize sparkleBundle;
static NSMutableDictionary *sharedUpdaters = nil;
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
@@ -82,6 +83,12 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
self = [super init];
if (bundle == nil) bundle = [NSBundle mainBundle];
self.sparkleBundle = [NSBundle bundleForClass:[self class]];
if (!self.sparkleBundle) {
SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to");
return nil;
}
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
if (self) {
[self registerAsObserver];
@@ -106,11 +113,17 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
if (!isMainBundle && !hasPublicDSAKey) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Insecure update error!";
alert.informativeText = @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.";
[alert runModal];
[self notifyDidShowModalAlert];
} else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Insecure update error!";
alert.informativeText = @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.";
[alert runModal];
[self notifyDidShowModalAlert];
}
@@ -147,38 +160,28 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)startUpdateCycle
{
BOOL shouldPrompt = NO;
BOOL hasLaunchedBefore = [self.host boolForUserDefaultsKey:SUHasLaunchedBeforeKey];
// If the user has been asked about automatic checks, don't bother prompting
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey])
{
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKey]) {
shouldPrompt = NO;
}
// Does the delegate want to take care of the logic for when we should ask permission to update?
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)])
{
else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) {
shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self];
}
// Has he been asked already? And don't ask if the host has a default value set in its Info.plist.
else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil)
{
if ([self.host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) {
[self setAutomaticallyChecksForUpdates:[self.host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]];
}
else if ([self.host objectForKey:SUEnableAutomaticChecksKey] == nil) {
// Now, we don't want to ask the user for permission to do a weird thing on the first launch.
// We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey.
else if (![self.host objectForKey:SUPromptUserOnFirstLaunchKey])
{
if ([self.host boolForUserDefaultsKey:SUHasLaunchedBeforeKey] == NO)
[self.host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
else
shouldPrompt = YES;
}
else
shouldPrompt = YES;
shouldPrompt = [self.host objectForKey:SUPromptUserOnFirstLaunchKey] || hasLaunchedBefore;
}
if (shouldPrompt)
{
if (!hasLaunchedBefore) {
[self.host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey];
}
if (shouldPrompt) {
NSArray *profileInfo = [self.host systemProfile];
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
@@ -186,9 +189,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
}
[SUUpdatePermissionPrompt promptWithHost:self.host systemProfile:profileInfo delegate:self];
// We start the update checks and register as observer for changes after the prompt finishes
}
else
{
} else {
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
[self scheduleNextUpdateCheck];
}
@@ -231,8 +232,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// Now we want to figure out how long until we check again.
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
updateCheckInterval = SUMinimumUpdateCheckInterval;
if (intervalSinceCheck < updateCheckInterval)
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
else
@@ -334,9 +335,6 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
if ([self updateInProgress]) { return; }
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
SUClearLog();
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
[self willChangeValueForKey:@"lastUpdateCheckDate"];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
[self didChangeValueForKey:@"lastUpdateCheckDate"];
@@ -411,7 +409,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// Hack to support backwards compatibility with older Sparkle versions, which supported
// disabling updates by setting the check interval to 0.
if (automaticallyCheckForUpdates && (NSInteger)[self updateCheckInterval] == 0) {
[self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL];
[self setUpdateCheckInterval:SUDefaultUpdateCheckInterval];
}
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
// Provide a small delay in case multiple preferences are being updated simultaneously.
@@ -476,7 +474,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
return customUserAgentString;
}
NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"];
NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"];
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding];
@@ -553,7 +551,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
if (intervalValue)
return [intervalValue doubleValue];
else
return SU_DEFAULT_CHECK_INTERVAL;
return SUDefaultUpdateCheckInterval;
}
- (void)dealloc
-10
View File
@@ -78,16 +78,6 @@
[super abortUpdate];
}
- (void)appcast:(SUAppcast *)ac failedToLoadWithError:(NSError *)error
{
if (self.isCanceled)
{
[self abortUpdate];
return;
}
[super appcast:ac failedToLoadWithError:error];
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
{
// We don't check to see if this update's been skipped, because the user explicitly *asked* if he had the latest version.
+1
View File
@@ -10,6 +10,7 @@
#define SUVERSIONCOMPARISONPROTOCOL_H
#import <Cocoa/Cocoa.h>
#import "SUExport.h"
/*!
Provides version comparison facilities for Sparkle.
+1 -1
View File
@@ -7,7 +7,7 @@
//
#import <Cocoa/Cocoa.h>
#import "SUExport.h"
/*!
Applies special display formatting to version numbers.
+1 -1
View File
@@ -14,7 +14,7 @@
@class SUHost;
@interface SUWindowController : NSWindowController
// We use this instead of plain old NSWindowController initWithWindowNibName so that we'll be able to find the right path when running in a bundle loaded from another app.
- (instancetype)initWithHost:(SUHost *)host windowNibName:(NSString *)nibName;
- (instancetype)initWithWindowNibName:(NSString *)nibName;
@end
#endif
+2 -9
View File
@@ -11,16 +11,9 @@
@implementation SUWindowController
- (instancetype)initWithHost:(SUHost *)host windowNibName:(NSString *)nibName
- (instancetype)initWithWindowNibName:(NSString *)nibName
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:nibName ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[[host bundle] sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:nibName ofType:@"nib"];
}
self = [super initWithWindowNibPath:path owner:self];
self = [super initWithWindowNibName:nibName owner:self];
return self;
}
+2 -2
View File
@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.andymatuschak.Sparkle</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION} git</string>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+6 -3
View File
@@ -9,14 +9,17 @@
#ifndef SPARKLE_H
#define SPARKLE_H
#import <Cocoa/Cocoa.h>
// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
// there are name-space collisions) so we can list all of them to start with:
#import <Sparkle/SUUpdater.h>
#import <Sparkle/SUAppcast.h>
#import <Sparkle/SUAppcastItem.h>
#import <Sparkle/SUVersionComparisonProtocol.h>
#import <Sparkle/SUStandardVersionComparator.h>
#import <Sparkle/SUUpdater.h>
#import <Sparkle/SUVersionComparisonProtocol.h>
#import <Sparkle/SUVersionDisplayProtocol.h>
#import <Sparkle/SUErrors.h>
#endif
+12 -3
View File
@@ -8,11 +8,20 @@
#ifdef __OBJC__
#define SPARKLE_BUNDLE [NSBundle bundleWithIdentifier:@"org.andymatuschak.Sparkle"]
#define SULocalizedString(key,comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", SPARKLE_BUNDLE, comment)
#define SUAbstractFail() NSAssert2(nil, @"Can't call %@ on an instance of %@; this is an abstract method!", __PRETTY_FUNCTION__, [self class]);
#if !defined(__clang_major__) || __clang_major__ < 7
#define __nonnull
#define __nullable
#endif
#import <Cocoa/Cocoa.h>
#import "SUConstants.h"
#import "SUErrors.h"
#define SULocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", (NSBundle *__nonnull)([NSBundle bundleWithIdentifier:SUBundleIdentifier] ? [NSBundle bundleWithIdentifier:SUBundleIdentifier] : [NSBundle mainBundle]), comment)
// Work around a warning generated by some versions of Xcode that we still support,
// when using NSParameterAssert
#define SUParameterAssert(condition) \
NSAssert((condition), @"Invalid parameter not satisfying: %@", @(#condition))
#endif
+1 -1
View File
@@ -44,7 +44,7 @@ DQ
<button verticalHuggingPriority="750" id="14">
<rect key="frame" x="138" y="12" width="117" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<buttonCell key="cell" type="push" title="Don't Check" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="177">
<buttonCell key="cell" type="push" title="Don’t Check" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="177">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Loaded 100 of 151 files, more files were not shown because too many files have changed in this diff. Show more