Compare commits

..
451 Commits
Author SHA1 Message Date
Sparkle-Bot 10d96f2b9b Update Package.swift and Sparkle.podspec for version 1.27.3 2024-05-12 23:43:54 +00:00
Zorg a9f370460a Update CHANGELOG for 1.27.3 2024-05-12 16:39:23 -07:00
Zorg d7db589432 Revert unarchiver code to how it used to work in generate_appcast (#2556)
Also remove temp directory before extraction.
2024-05-05 21:50:25 -07:00
Sparkle-Bot 56ad4aa3c8 Update Package.swift and Sparkle.podspec for version 1.27.2 2024-05-02 21:18:49 +00:00
Zorg b5350bf58f Update CHANGELOG for 1.27.2 2024-05-02 23:11:05 +02:00
Zorg bbe887e160 Extract archives in a separate directory from the input archive
This is ported from the 2.x branch.
2024-05-02 16:11:13 +02:00
trss f453625573 Fix incorrect xz log warning in make release (#2044) 2021-12-25 00:57:13 -08:00
Sparkle-Bot 7918c1c8fc Update Package.swift and Sparkle.podspec for version 1.27.1 2021-11-13 05:29:24 +00:00
Zorg 4875f83bea Update CHANGELOG 2021-11-12 21:17:23 -08:00
Zorg 43403a5068 Revert monotonic timer (1.x) (#2019) 2021-11-12 15:14:23 -08:00
Sparkle-Bot 4222fd6179 Update Package.swift and Sparkle.podspec for version 1.27.1-rc.2 2021-11-08 07:16:11 +00:00
Zorg 16c2f9b78b Fix create-draft-release not including pre-release suffix 2021-11-07 23:10:01 -08:00
Sparkle-Bot 26d30d7c2b Update Package.swift and Sparkle.podspec for version 1.27.1 2021-11-08 06:53:54 +00:00
Zorg b3b5f5f246 Update 1.27.1 Changelog 2021-11-07 20:12:23 -08:00
Zorg a49d83dc22 Prevent potential rapid update checks from sleep/wake events (#2000) 2021-11-07 17:16:09 -08:00
Zorg 08932966b2 Disable hide on deactivate for update window (1.x) (#2008)
This is a backport of #1804 to 1.x
2021-11-06 15:43:03 -07:00
Zorg d80ad46c4f Whitelist about:srcdoc as a safe web URL (#2007)
The document I tested (after enabling javascript) was:

<description>
          <![CDATA[
              <p>Hello</p>
              <script>
              var iframe = document.createElement("iframe");
              iframe.srcdoc = `<!DOCTYPE html><p>Hello World!</p>`;
              document.body.appendChild(iframe);
              </script>
          ]]>
</description>
2021-11-06 14:52:25 -07:00
Zorg 4a00b97592 Add project version inputs to create-draft-release workflow (1.x) (#1999) 2021-10-30 22:55:50 -07:00
Sparkle-Bot a319cb2c90 Update Package.swift and Sparkle.podspec for version 1.27.1-rc.1 2021-10-30 23:40:31 +00:00
Zorg 43596bbc5e Update changelog and version for 1.27.1-rc.1 (#1996) 2021-10-30 12:21:57 -07:00
Zorg 3ed77f975a Don't use current date unless necessary when scheduling next update (1.x) (#1991) 2021-10-30 11:03:37 -07:00
Zorg c64d0467b2 Revert "Set CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO for release (#1974)" (#1995)
This reverts commit f601a7a3df.

For development we should include task-get-allow entitlements. For distribution if people use custom workflows, they need to properly re-sign the app without preserving this entitlement.
2021-10-29 23:10:21 -07:00
Zorg 7b109be51d Add safer handling for applying binary delta files (1.x) (#1990) 2021-10-29 12:15:45 -07:00
Zorg c427650ed8 Update create-draft-release to use Xcode 13.1 too 2021-10-28 23:19:14 -07:00
Zorg 70f58b515d Fix Xcode version in CI 2021-10-28 23:18:11 -07:00
Zorg 65900a1aea Update Xcode 13 to 13.1 in CI 2021-10-28 23:15:09 -07:00
Zorg f601a7a3df Set CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO for release (#1974)
This removes the com.apple.security.get-task-allow entitlement on helper executable tools and XPC Services. While this is not a big deal, I don't think we should distribute executables with this entitlement which allows debugging them (with SIP / hardened runtime on). Note notarization ought to reject this entitlement with library validation enabled, so people must be getting around this anyway (either by using Xcode's Archive / Export which automatically strips this entitlement, or re-signing Sparkle tools without preserving entitlements).
2021-10-17 23:31:07 -07:00
Daniel Jalkut 1ede0bc994 When applying the system font size to the baseline CSS for the web view, use px instead of pt to specify the font size. This is consistent with best practices for web content, and alleviates a problem wherein the text in the web view, if not based on a full-fledged release notes HTML document, appears too large. (#1962) 2021-09-22 22:24:11 -07:00
Daniel Jalkut 5b8ab1b919 Don't manipulate the default WebView preferences, which at least on Monterey beta returns a preferences instance with nil identifier and with autosaves set to YES. This has the unfortunate effect of causing Sparkle, when it uses SULegacyWebView, to pollute the host app's user defaults with high level WebKit defaults for user style sheet, font sizes, etc. Specifying a unique identifier as well as turning autosaves off should both ensure Sparkle doesn't impose app-wide defaults on the host app, and also avoid littering the host app's preference file with identifier-prefixed defaults. (#1961) 2021-09-22 19:15:22 -07:00
Sparkle-Bot 99dbdcbd96 Update Package.swift and Sparkle.podspec for version 1.27.0 2021-09-18 00:14:10 +00:00
Zorg d18ccf12f3 Update changelog and final version for 1.27 (#1954) 2021-09-17 17:09:50 -07:00
ZorgandKonstantin Zamyakin a6ff74889e update some russian translates (#1947) (#1949)
Co-authored-by: Konstantin Zamyakin <dev@weblab.pro>
2021-09-12 00:07:00 -07:00
ZorgandVojtěch Koňařík a1d0e036fb Another localization update. (#1943) (#1950)
Co-authored-by: Vojtěch Koňařík <vojtakonarik@pm.me>
2021-09-12 00:05:11 -07:00
Sparkle-Bot 09ab0a5138 Update Package.swift and Sparkle.podspec for version 1.27.0-rc.1 2021-09-04 02:28:33 +00:00
Mayur Pawashe 1c55a7e7fc Update changelog and project version for 1.x (#1937) 2021-09-03 10:49:05 -07:00
Mayur Pawashe 1d9125f8a2 Update podspec to use https URLs (#1936) 2021-09-03 10:16:49 -07:00
J-rg bf3c932844 Fix German localization (#1932) 2021-09-03 08:41:44 -07:00
Mayur Pawashe b5755d41cb Use a custom bot personal access token (#1930) (#1934)
This bot has owner access to the repo and should be able to push changes to protected branches, as long as the workflows are being ran from trusted branches / remotes.

Also extract changelog and use it for the draft.
2021-09-02 23:54:20 -07:00
Mayur Pawashe 8f7fad4d3a Port versioning changes back to 1.x (#1928) 2021-08-29 23:02:46 -07:00
Zorg 3d4e4494ad Bump version to 1.27.0
Also remove old DSA generation script in 1.x too.
2021-08-21 12:34:42 +01:00
Mayur Pawashe f7d830d9ad Update change log for 1.x (#1898) 2021-07-24 13:53:46 -07:00
Mayur Pawashe f3db8fb959 Create valid xar files (#1906)
* Create xar files with valid directory/filename structure

* Don't use file hash for determining if files are equal or not
2021-07-24 09:08:35 -07:00
Sungbin Jo 55394e1359 Fix appcast pubDate tag generation in different locales
Fixes #1900
2021-07-21 18:42:40 -07:00
Mayur Pawashe ea14942643 Fix project warnings (#1893)
Port changes from 2.x to fix some project warnings in master branch:

* Copy phase strip warning on binaries when building Distribution
* No app category set on Autoupdate
* -Watimport-in-framework-header warnings
* id messaging warnings
* -Wcompletion-handler warnings
* Some deprecated base64 APIs
* Explicit SDK and adhoc signing identity
* Upgrade project last update check
* Don't use manual ordering for building targets and set Sparkle.framework as dependency to XCFrameworks aggregate target
* Silenced WKWebView deprecation warning
* Fixed no output node warning in git config script by removing input node like in 2.x
2021-07-19 08:07:06 -07:00
Mayur Pawashe a2adcd8407 Sync Sample Appcast from 2.x (#1895)
Plus made changes to use https://
2021-07-18 13:08:09 -07:00
Mayur Pawashe 2929333b49 Backport security and DSA changes to 1.x (#1892)
* Avoid DSA verification if EdDSA verification passes

This ports #1888 over to 1.x.

* Log error if app is using DSA public key only

* Log error if app is not using EdDSA key
2021-07-16 00:09:07 -07:00
Mayur Pawashe c4fcf17050 Merge pull request #1873 from sparkle-project/http-headers-releasenotes-1x
Pass http headers and user agent when downloading release notes (1.x)
2021-06-20 14:54:59 -07:00
Zorg 99785ceebb Pass http headers and user agent when downloading release notes 2021-06-17 22:38:19 -07:00
Kornel c0933a516b Update Package.swift 2021-02-27 12:02:42 +00:00
Mayur Pawashe 490f8aa71a Merge pull request #1785 from sparkle-project/bump-unarchiving-test-timeout
Bump unarchiving tests timeout from 7 seconds to 30 seconds
2021-02-22 07:44:23 -08:00
Mayur Pawashe 2931c3f8aa Merge pull request #1782 from sparkle-project/bz2-make-fallback
Add fallback to bz2 when building Sparkle distribution
2021-02-22 07:44:00 -08:00
Kornel b5c9539f16 Fight SPM retagging 2021-02-22 09:46:32 +00:00
Kornel 9d9205851d Changelog 2021-02-22 09:37:50 +00:00
Zorg 22c15e8d79 Bump unarchiving tests timeout from 7 seconds to 30 seconds 2021-02-21 18:03:01 -08:00
Mayur Pawashe 056d84eaca Merge pull request #1780 from sparkle-project/fix-compiling
Fix compilation issues & add building distribution in Release in CI
2021-02-21 17:49:04 -08:00
Zorg 252cfc32e1 Add fallback to bz2 when building Sparkle distribution 2021-02-21 17:16:06 -08:00
Zorg cde2af9c7f Add SULog.m to Sparkle Test App to fix compile failures 2021-02-21 15:39:27 -08:00
Zorg 741bb2825d Add building distribution in Release in CI 2021-02-21 15:30:02 -08:00
Kornel 1a52f7df98 Bump 2021-02-21 17:23:31 +00:00
Kornel 26882d4ed4 Update Package.swift 2021-02-21 17:19:26 +00:00
Kornel 1b926c85f5 1.25.0 2021-02-21 17:17:10 +00:00
Mayur Pawashe 4853c187ae Merge pull request #1775 from sparkle-project/ignore-format-non-iso
Ignore -Wno-format-non-iso warnings
2021-02-21 07:14:19 -08:00
Zorg 8409cbb9f6 Ignore -Wno-format-non-iso warnings 2021-02-20 20:41:13 -08:00
Mayur Pawashe 126f9d214a Merge pull request #1772 from lovette/patch-2
Correct generate_appcast -s command line argument usage help
2021-02-20 20:00:34 -08:00
Lance Lovette c7b1d221b9 Correct generate_appcast -s command line argument usage help
Fixes sparkle-project/Sparkle#1766
2021-02-20 11:47:16 -05:00
Mayur Pawashe 1013c5076d Merge pull request #1771 from sparkle-project/fix-1768
Fix XQuartz update failing because NSLog caused issues
2021-02-20 08:35:10 -08:00
Zorg a1133829e4 Fix wrong SULog format specifier 2021-02-20 08:22:24 -08:00
Zorg 7980c4dfdc Disable determinate progress for guided pkg install properly 2021-02-19 20:50:04 -08:00
Zorg acd22dda12 Undo removing progress change 2021-02-19 20:38:47 -08:00
Zorg 9f5dd63697 Fix unit tests not building due to missing SULog symbol 2021-02-19 19:54:08 -08:00
Zorg 28a4d70aa0 Fix XQuartz update failing because NSLog caused issues
In Sparkle 1.x, Autoupdate is NSTask'ed from the updater with LSBackgroundOnly / LSUIElement set. Somehow when updating XQuartz, any NSLog usage makes Autoupdate get mysteriously killed afterwards.

Literally if I put the two statements right in main():

NSLog(@"foo");
NSLog(@"bar");

Only foo would be logged, bar would not be logged. I even verified this was not just a "logging" issue by writing out files to disk.

So in SUFileManager before we prompt the user an authorization dialog, we logged:
Sparkle: Authorization required to run pkg installer file:///Users/msp/Library/Caches/org.xquartz.X11/org.sparkle-project.Sparkle/PersistentDownloads/YYhaX4Tma/XQuartz%202.8.8/Xquartz.pkg

Which is the last thing seen. Normally if an error occurred we'd log it.

I don't know if there is an OS bug involved but anyway, we should just replace all NSLog usage with SULog in Autoupdate. fileop in 1.x which uses SUFileManager should probably never NSLog anyway. Autoupdate tool in 2.x is spawned as a launchd daemon for package installs, so it might not be affected, but I should update SULog usages there anyway to be in sync.

The determinate progress reporting was also broken (#1402), so I'm making it an indeterminate progress bar again rather than trying to debug what has apparently become fragile text parsing.
2021-02-19 19:29:10 -08:00
Mayur Pawashe abe6b493f8 Merge pull request #1765 from lovette/patch-1
Fix -f command line argument handling
2021-02-17 20:32:20 -08:00
Lance Lovette d5e80b56d6 Fix -f command line argument handling
https://github.com/sparkle-project/Sparkle/issues/1763
2021-02-17 08:54:51 -05:00
Kornel eee82a9b5c Merge pull request #1760 from vojtakonarik/master 2021-02-16 09:28:11 +00:00
Vojtěch Koňařík cdd1392362 Update Sparkle.strings 2021-02-14 00:13:22 +01:00
Vojtěch Koňařík a8be860ed9 Update Sparkle.strings 2021-02-14 00:09:43 +01:00
Vojtěch Koňařík 6d392e6800 Update SUUpdatePermissionPrompt.strings 2021-02-13 23:56:50 +01:00
Vojtěch Koňařík bf30749aa3 Update SUUpdateAlert.strings 2021-02-13 23:29:31 +01:00
Vojtěch Koňařík eb2b818c35 Update SUAutomaticUpdateAlert.strings 2021-02-13 22:08:38 +01:00
Mayur Pawashe 057e15e5f2 Merge pull request #1746 from sparkle-project/flat-package-1x
Backport flat non-archived package support from #1745 (for 1.x)
2021-02-13 11:14:01 -08:00
Zorg 6673fc18e2 Support mpkg for updating/installing flat non-archived packages 2021-02-13 10:14:53 -08:00
Kornel c7c90d4d1d Merge pull request #1748 from grit96/patch-1
Apply custom headers to app download
2021-02-07 15:02:47 +00:00
Geraint White 8ffb4956de Apply custom headers to app download
The custom headers added in #489 only applied to the appcast download.
This makes them apply to the app download as well for the case when both are hosted behind authentication.
2021-02-07 09:54:16 +00:00
Mayur Pawashe e1c565f6ce Merge pull request #1756 from sparkle-project/describe-tests
Add description of test cases in PR review template
2021-02-07 00:13:35 -08:00
Zorg 5a2bd7421a Add description of test cases in PR review template 2021-02-07 00:04:56 -08:00
Kornel 07b044dd8f Update Package.swift 2021-02-06 02:07:55 +00:00
Kornel cd9495214d RC 2021-02-06 02:04:17 +00:00
Mayur Pawashe be3fb5caf2 Merge pull request #1751 from thebluepotato/patch-2
Fix Package.swift
2021-02-05 15:43:44 -08:00
Jonas Zaugg 3b500aeaa3 Update make-release-package.sh
Now provides an error and exits when not complying with SemVer
2021-02-05 21:05:14 +01:00
Jonas Zaugg cc1e43c115 Update make-release-package.sh
Only check and update tag in Package.swift when not running a CI build. As long as GitHub actions are reserved for tests, this should be ok as this is a "fake" update of Package.swift anyway. If you ever use GitHub actions for releases, you'll probably have to rethink the tagging logic once again
2021-02-05 00:15:18 +01:00
Jonas Zaugg 07dfc86c47 Checks SemVer and default to force tagging 2021-02-04 14:29:03 +01:00
Jonas Zaugg 22e130d10b Various fixes to SPM logic
Improves prompt asking to force move tag (default is NO, but can be triggered after `make release`). Fixes issues with single quotes in make-release-package.sh.
2021-02-04 13:36:51 +01:00
Jonas Zaugg 75dfdd8279 Include tag instead of version in Package.swift 2021-02-04 13:13:31 +01:00
Kornel 27448add37 Changelog 2021-02-03 12:11:16 +00:00
Zorg 067eedbb7a Fix generate_appcast compile error 2021-01-31 00:18:29 -08:00
Zorg a841415046 Backport flat package support from #1745 2021-01-31 00:02:38 -08:00
Mayur Pawashe 3b78c78702 Merge pull request #1740 from sparkle-project/phased-group-fixes-1x
Fix issues with phased group updates found in #1736
2021-01-30 18:17:05 -08:00
Zorg a8ec752c51 Add phased rollouts feature to automatic update driver too
Previously phased rollouts did not work if the user/developer set updates to be automatically downloaded in 1.x
2021-01-30 17:54:23 -08:00
Mayur Pawashe 464142c73d Merge pull request #1742 from sparkle-project/remove-disable-automatic-skip-1x
Remove hiding skip button and retitling later button
2021-01-30 12:54:43 -08:00
Mayur Pawashe baa26a1b19 Merge pull request #1743 from sparkle-project/deprecate-installUpdatesIfAvailable
Deprecate installUpdatesIfAvailable
2021-01-30 12:34:39 -08:00
Mayur Pawashe 513158dfcc Merge pull request #1744 from sparkle-project/revert-exposing-system-profile-array
Revert exposing systemProfileInformationArray until implemented a better way
2021-01-30 12:34:04 -08:00
Zorg 901683d837 Revert "Exposed systemProfileInformationArray, e.g. for use by the app preferences GUI"
This reverts commit 1c32cc7fcb.

* We cannot make it look like applications are collecting system profile information all the time.
* The method collects non-system profile information too (feed parameters from delegate). Presumably users only cares about system profile information. Otherwise the name is incorrect.
* Adding a mutable property to SUUpdater is heavyweight; perhaps an API to ask and compute for the systemProfileArray is better idea. Or a delegate API when system profile array will be sent.
* This change introduced nullability warnings in SUUpdater.h due to other things not being null annotated there.
2021-01-30 11:08:46 -08:00
Zorg 10d24078cc Add note about using automaticallyDownloadsUpdates property 2021-01-30 10:40:16 -08:00
Zorg 9944f000f8 Deprecate installUpdatesIfAvailable 2021-01-30 08:59:41 -08:00
Zorg bf96a6e066 Remove hiding skip button and retitling later button
Same reason as #1741

If we can handle all cases properly (minimumAutoupdateVersion, user opting out of automatic downloads, and absence of allowsAutomaticUpdates which is removed in 2.x to both handle sandboxing and resuming automatic downloads) we can possibly accept a contribution to disable skipping / remind me later buttons.

But right now this is edge case-y and not compatible to 2.x going forward.
2021-01-30 08:51:00 -08:00
Kornel 8fb9c83adf Bump 2021-01-30 11:25:45 +00:00
Zorg d662b67a58 Fix issues with phased group updates found in #1736 2021-01-29 22:12:07 -08:00
Mayur Pawashe 0b682d3349 Merge pull request #1734 from sparkle-project/alert-adjustments-1x
Alert adjustments 1x
2021-01-24 10:15:41 -08:00
Zorg 9561d522e3 Keep skip button available if there is a minimum autoupdate version 2021-01-24 01:09:36 -08:00
Zorg f60b60b08f Fix automatic updates checkbox state when not showing release notes 2021-01-23 21:14:59 -08:00
Zorg a85db747f1 Add more comments 2021-01-23 19:37:29 -08:00
Zorg 9cc9f51d7c Add clarification on developer too 2021-01-23 19:20:33 -08:00
Zorg bb9ee3c59b Fix edge cases with hiding alert buttons and using "Install Later" 2021-01-23 19:09:25 -08:00
Mayur Pawashe 4cb4ab8954 Merge pull request #1732 from sparkle-project/migrate-keys-1.x
Integrate generate_keys export/import options changes from #1730
2021-01-23 16:39:22 -08:00
Mayur Pawashe ab82c70aef Merge pull request #1731 from sparkle-project/update-pr-template
Update pull request template
2021-01-23 08:20:18 -08:00
Zorg eb9f4c303a Integrate generate_keys export/import options changes from #1730 2021-01-23 08:13:31 -08:00
Zorg e3c4a702f4 Update pull request template 2021-01-23 08:09:05 -08:00
Mayur Pawashe 039a46c96a Merge pull request #1729 from R4N/fr_translation_capitalization
Capitalizes french translation of "Vous utilisez actuellement..." ("Y…
2021-01-20 19:16:42 -08:00
Micah Moore f711abe9de Capitalizes french translation of "Vous utilisez actuellement..." ("You are currently running...") 2021-01-20 14:06:55 -05:00
Kornel dfecd4d2fa Merge pull request #1727 from zorgiepoo/pr-issues-templates 2021-01-19 11:39:53 +00:00
Kornel fddbadb114 Merge pull request #1696 from lorenrh/customUpdateButtons
Hide automatic update button and skip button, depending on `SUAutomaticallyUpdate` key
2021-01-19 11:39:09 +00:00
Kornel bfdce8d232 Merge pull request #1723 from zorgiepoo/about-blank-fix
Ignore opening about:blank URLs
2021-01-19 11:36:16 +00:00
Kornel 3111483cb2 Merge pull request #1725 from zorgiepoo/update-readme-build
Update build information in 1.x ReadMe
2021-01-19 11:35:30 +00:00
Zorg f5282705b4 Updated PR template regarding back porting and types of testing 2021-01-18 09:23:49 -08:00
Lorena Rangel 4c9397d752 Show check for updates button only when automatic updates are enabled
Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
2021-01-18 17:18:56 +01:00
Zorg 43184ea0bf Add pull request template and update issue templates
These changes require development changes to be made on 2.x branch first. This is separate from changing the default branch, which can happen and be done independently.

On the repo level, I also want to protect master and 2.x from direct pushes because inevitably it's tempting to push changes directly that should be reviewed -- and changes that get integrated that way are less pleasant to track.

And I want to require a minimum of two project members to review PR changes (with a reasonable bypass for trivial bug-fixes, localization or doc updates). With that, I will put a commitment in reviewing changes here, and this would result in less work for project members and better quality review.
2021-01-18 00:15:34 -08:00
Zorg 866bb8245f Update build information in 1.x ReadMe 2021-01-17 12:29:56 -08:00
Zorg 65f473b237 Ignore opening about:blank URLs
Fix from 8f19f6a8cc which I regressed accidentally.
2021-01-16 21:04:25 -08:00
Tobias Fonfara 0c8b7f1d25 Don't initialize the webview if we don't show release notes 2021-01-06 18:02:56 +00:00
Kornel 06520272ee Merge pull request #1710 from thebluepotato/fix-catch-22 2021-01-05 14:45:24 +00:00
Jonas Zaugg 602ac871b8 Update release-move-tag.sh
Fixes commit counting logic, some typos and logs more info.
2021-01-05 14:42:40 +01:00
Jonas Zaugg 1b5e938423 Update Makefile 2021-01-05 13:17:05 +01:00
Jonas Zaugg d21a303b2e Update release-move-tag.sh
Prevents re-tagging when there are more than one commits since latest tag (to prevent accidentally moving an old tag)
2021-01-05 13:07:11 +01:00
Jonas Zaugg 2e048a8601 Add script to commit and re-tag changes to Package.swift 2021-01-05 12:19:14 +01:00
Kornel da1748f7bd Merge pull request #1709 from zorgiepoo/webkit2-1.x 2021-01-05 02:17:28 +00:00
Zorg 54bbaee7f5 Re-add setting WebUIDelegate fix for legacy web view 2021-01-04 16:24:15 -08:00
Zorg 8bba4d21fc Fix not adding effectiveAppearance observer during merge 2021-01-04 16:16:16 -08:00
Zorg 6283992215 Implement loadRequest method on SUWebView 2021-01-04 16:12:58 -08:00
Zorg dfff98d19e Adopt WKWebView for 1.x 2021-01-04 16:08:19 -08:00
Jonas Zaugg 0ca9d34f42 [WIP] Fix catch-22 Swift Package Manager binary target
Should fix #1674, currently WIP
2021-01-04 11:24:26 +01:00
Kornel 5f47ce3dea Merge pull request #1707 from sparkle-project/github-ci-1.x 2021-01-03 10:09:01 +00:00
Zorg 470e3734b9 Use macos-10.15 instead of macOS-latest 2021-01-02 12:58:31 -08:00
Zorg 397467e6d7 Specify Xcode version to use instead of macOS version
It is more important OS version is stable in their virtual environment setup.
2021-01-01 19:55:35 -08:00
Zorg 3695ae6059 Adopt GitHub Actions for CI and fix issues with our UI test 2021-01-01 19:25:39 -08:00
Kornel 544df06b72 Merge pull request #1702 from sparkle-project/base-internationalization 2020-12-29 16:26:39 +00:00
Zorg 239693a91b Add auto layout constraints to SUAutomaticUpdateAlert window 2020-12-28 16:12:03 -08:00
Zorg 4022e128d3 Use SUAdHocCodeSigning to reduce code duplication 2020-12-28 15:43:11 -08:00
Zorg 6bdaeab2c6 Fix CheckLocalizations script because I moved english Sparkle.strings 2020-12-28 11:46:17 -08:00
Zorg 82718ca77f Add explicit CODE_SIGN_IDENTITY ad-hoc setting for test app 2020-12-28 11:35:38 -08:00
Zorg 84c442c3eb Specify ENABLE_HARDENED_RUNTIME in xcconfig files 2020-12-28 11:31:25 -08:00
Zorg 848eb7955e Add comment where codesignAppURL: was taken from 2020-12-28 11:22:23 -08:00
Zorg d7cead40be Fix and cleanup Hebrew, Catalan, Finnish localizations 2020-12-28 11:18:09 -08:00
Zorg eac1a41dba Fix Test Application and add localizations to test app 2020-12-28 11:07:52 -08:00
Zorg 4bde9854f7 Add localizations to xib files properly 2020-12-28 10:28:21 -08:00
Zorg 0909f0db81 Remove non-english localizations from TestApplication 2020-12-27 23:29:55 -08:00
Zorg cdd373b800 Remove English localization for Sparkle.strings 2020-12-27 23:25:52 -08:00
Zorg 66589042db Remove contents of English Sparkle.strings 2020-12-27 23:24:16 -08:00
Zorg 6b715b7c37 Add base localization file for Sparkle.strings 2020-12-27 23:22:46 -08:00
Zorg 0a5add74f8 Enable base internalization for alert xibs 2020-12-27 21:59:22 -08:00
Adam Tharani 02d0d749a0 Add —release-notes-url-prefix support to localized release notes
Signed-off-by: Adam Tharani <adamtharani@me.com>
2020-12-09 22:48:25 +00:00
pierswalter 65eb63f1d7 Allow an appcast to prevent the new version from being installed automatically (#1688) 2020-12-02 21:43:53 +00:00
Kornel d4d4c68ad2 Remove locale symlinks 2020-12-01 11:10:41 +00:00
Piers Uso Walter 1c32cc7fcb Exposed systemProfileInformationArray, e.g. for use by the app preferences GUI 2020-11-27 17:49:59 +00:00
Piers Uso Walter 79589c3e2b Made buttons wide enough to display the full text.
Made window wide enough to display the widened buttons (el, fi, ru, uk)
2020-11-27 11:54:27 +00:00
pierswalter d39fc1d75e Update SUSystemProfiler.m
Fixed syntax error
2020-11-27 10:40:58 +00:00
pierswalter a38e8c4607 Update SUSystemProfiler.m
Masked sysctl hw.cputype value when evaluating the CPU type.
Used macros from mach/machine.h instead of magic numbers.
Added support for ARM in evaluation of hw.cpusubtype.
2020-11-27 10:40:58 +00:00
Kornel d5b0804b4a Add explicit dependencies to fix Xcode linking errors 2020-11-20 18:05:46 +00:00
Kornel c3c1b1af99 Raise minimum system version to 10.9 2020-11-20 13:03:47 +00:00
George Nachman 4aff5912a5 Remove width constraint 2020-11-17 10:18:36 +00:00
George Nachman 3d0e7a26f1 Remove max size from update alert. 2020-11-17 10:18:36 +00:00
Kornel Lesiński 891afd44c7 Rename SPM zip 2020-11-15 21:27:23 +00:00
Kornel Lesiński 489ae19e74 Release 2020-11-13 18:40:00 +00:00
Nicolas Bosi 0e162c98be Prioritize UserDefaults when fetching value for EnableAutomaticChecks
Users of the framework may override the value for this setting in runtime, as oppossed to using a static value written into Info.plist.
With the current implementation, the fix for issue 1480 was a breaking change, making users that set this parameter dinamically not see the 'Remind me later' button anymore, unless a value is provided in Info.plist.
Sparkle users that set this parameter in runtime should not be forced to set the parameter in Info.plist as a workaround to have the 'Remind me later' button visible. Instead, Sparkle should honour its documentation and make the value dinamically set via [SUUpdater setAutomaticChecksEnabled] take precedence over the defualt set in Info.plist.
2020-11-12 15:38:14 +00:00
Kornel cf8e5163b6 Merge pull request #1668 from xhacker/zh-hans 2020-11-03 16:52:29 +00:00
柳东原 · Dongyuan Liu c8f6eca09a Update zh_CN localization 2020-11-03 22:36:59 +08:00
Kornel dbfb300931 Merge pull request #1667 from vojtakonarik/patch-1
Czech localization update
2020-10-26 20:39:34 +00:00
Vojtěch Koňařík eeab95936a Update Sparkle.strings 2020-10-26 10:50:19 +01:00
Kornel 04dbde7b8d Merge pull request #1661 from zorgiepoo/master-double-quote-include 2020-10-03 14:13:59 +01:00
Zorg c1e7c09886 Remove -Wno-quoted-include-in-framework-header from WARNING_CFLAGS
It is already specified above as CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER.
2020-10-03 01:01:02 -07:00
Zorg c15b9da2a7 Set CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER instead 2020-10-03 00:43:57 -07:00
Zorg 80264da368 Add -Wno-quoted-include-in-framework-header to ConfigCommon 2020-10-03 00:14:06 -07:00
Zorg a5725cf443 Use double quote includes with pragma ignore warning 2020-10-02 23:58:23 -07:00
Dom Neill 22bc73be59 Corrected hyphenation for 'already current' status message 2020-09-28 12:22:59 +01:00
Georg Seifert 989589524b Use spaces (#1657) 2020-09-24 15:11:49 +01:00
Kornel dcf59b1f8a Merge pull request #1655 from vitorgalvao/master 2020-09-17 18:49:37 +01:00
Julian Mayer a64af3517c Change lockfile directory to /private/tmp/ so that it is cleared on reboot 2020-09-17 17:31:23 +02:00
CoreCode cfd963002f Create lockfile for improved compatibility with 3rd party updaters 2020-09-16 03:07:23 +01:00
Denis Dzyubenko 7233bb93e7 generate_appcast follow symbolic links
When archives are stored as symlinks e.g. due to storing binary files in a
git-annex repository, everything works file except file size in the generate
feed xml file. This patch makes generate_appcast correctly determine file size
by following the symlink
2020-09-10 13:40:34 +01:00
Bi11 f2fc729b69 Support App Store URL scheme in release note webview 2020-09-03 13:49:01 +01:00
Brad Andalman 7c7e924ed4 generate_appcast can update the release notes element’s URL when required
Previously, generate_appcast could only add or remove the release notes element for an update. This was probably fine, because it was unlikely to change: the release notes URL was determined by the SUFeedURL.

However, now that —release-notes-url-prefix was added, the release notes element CAN change. So, with this commit, if the release notes element is present for an update, the URL will be set correctly.
2020-09-03 13:47:05 +01:00
Kornel 640ba1b737 Merge pull request #1648 from oneeightyg/feature-1646-generate-appcast-output-filename 2020-09-03 13:46:13 +01:00
Brad Andalman 215b7db5a1 Fix incorrect comment for parseCommandLineOptions
This function returns a *struct*, not a dictionary.
2020-09-02 18:47:55 -07:00
Brad Andalman 4fec1b7301 Use a struct to simplify command line argument parsing
Changed parseCommandLineOptions so that it returns a struct that contains possible argument values, rather than a tuple.

Also unified the “help” and “usage” messages into a single message.
2020-09-02 15:57:05 -07:00
Brad Andalman 7c84c537a5 Add output filename option to generate_appcast
Added a “-o <filename.xml>” to generate_appcast so that users can specify the destination for the appcast. It’s an error if this is specified and multiple appcasts would be written.
2020-09-02 14:13:32 -07:00
Milen Dzhumerov a3a0ec7e2f Use angle-bracketed includes for all public framework headers (#1645) 2020-09-02 00:36:44 +01:00
Kornel 7ea72a2af4 Merge pull request #1644 from oneeightyg/feature-1642-release-notes-url-prefix
Add —release-notes-url-prefix to generate_appcast
2020-09-01 22:13:13 +01:00
Brad Andalman 752849d727 Add —release-notes-url-prefix to generate_appcast
Added a —release-notes-url-prefix argument to generate_appcast so that users can provide a prefix that will be used to construct the URL for the location of release notes.
2020-09-01 13:39:34 -07:00
Kornel 360575c611 Merge pull request #1634 from thebluepotato/spm-xcframework 2020-08-29 14:05:10 +01:00
Kornel bfccdabfa2 Merge pull request #1640 from trevordevore/tkd-issue-373
fix: read SUAutomaticallyUpdate from Info.plist
2020-08-29 12:21:48 +01:00
Trevor DeVore 4f47fb02db fix: read SUAutomaticallyUpdate from Info.plist
`SUAutomaticallyUpdate` will now be read from `Info.plist` if it has not been set in `NSUserDefaults`. This brings the behavior into line with the documentation.
2020-08-28 20:30:22 -05:00
Jonas Zaugg 7962e95fd9 Travis updated to more recent Xcode 12 beta 2020-08-29 01:32:40 +02:00
Jonas Zaugg 2629a05e48 Light renaming and cleanup 2020-08-03 02:43:13 +02:00
Jonas Zaugg a56ca505ea Distribution target now builds the XCFramework as well 2020-08-03 01:43:33 +02:00
Jonas Zaugg 17d78dfc0f Update README.markdown 2020-08-02 22:33:57 +02:00
Jonas Zaugg 23a24f17ec Finalize Travis integration 2020-08-02 16:17:03 +02:00
Jonas Zaugg 1ac42dcd5b Update .travis.yml 2020-08-02 15:45:17 +02:00
Jonas Zaugg 8199aee292 Debug Travis build 2020-08-02 15:15:41 +02:00
Jonas Zaugg b3e5f7b000 Update .travis.yml
The current version of Xcode on Travis does not support the `-debug-symbols` flag for `-create-xcframework`
2020-07-31 09:55:56 +02:00
Jonas Zaugg dd12653c29 Removing the need for Package-template 2020-07-31 01:28:53 +02:00
Jonas Zaugg c7f1a75f95 Improve inclusion of debug symbols and include binaries alongside XCFramework 2020-07-30 01:09:05 +02:00
Jonas Zaugg 7c5adb11ac Bundle more files into the XCFramework 2020-07-29 22:35:20 +02:00
Jonas Zaugg cae2068a44 Only one release and improve zipping 2020-07-29 13:27:27 +02:00
Jonas Zaugg d95a0d5c92 Enable SPM support via binary target 2020-07-29 12:01:22 +02:00
Kevin Wojniak 1ff3ed7fad Fix casting Boolean to BOOL on Apple Silicon
This fixes the following error when compiling for Apple Silicon on Xcode 12:

> SUHost.m:231:23: Cast from function call of type 'Boolean' (aka 'unsigned char') to non-matching type 'BOOL' (aka 'bool')
2020-06-29 02:02:04 +01:00
Nate Weaver b7793249e0 Fix timeout in testDeprecatedDownloader() 2020-06-16 13:20:49 +01:00
milotype e26f1dab23 Update Croatian (#1603) 2020-05-31 21:41:52 +01:00
Kornel 8a9963bf04 Merge pull request #1596 from rajivshah3/chore/swiftlint 2020-05-26 13:34:24 +01:00
Kornel 0b14472ede Merge pull request #1597 from rajivshah3/fix/ci 2020-05-26 13:04:47 +01:00
Rajiv Shah d0e054fc54 Only use Xcode 10.3 and 11.4 2020-05-26 00:58:25 -04:00
Rajiv Shah df718b0c4c Fix SUCodeSigningVerifierTest on macOS 10.15
Pre-installed apps, such as Calculator, are now installed under the System folder
2020-05-26 00:46:50 -04:00
Rajiv Shah 1690ce6cbc Only run tests on Xcode 10+
Sparkle uses Swift 4.2 which isn't supported on earlier Xcode versions
2020-05-26 00:46:50 -04:00
Rajiv Shah a746675f53 Set Swift Language Version to 4.2 in top level config 2020-05-25 23:13:59 -04:00
Rajiv Shah 13cadf0118 Fix CI test script 2020-05-25 23:05:13 -04:00
Rajiv Shah 6c3ce5cb97 Remove old code coverage configurations
Apple has a new way of enabling and formatting code coverage info
2020-05-25 22:57:43 -04:00
Rajiv Shah 372d75cc09 Fail the build if xcodebuild runs into an error 2020-05-25 22:15:39 -04:00
Rajiv Shah 6468ea2bb5 Remove brew update, nothing is being installed afterwards 2020-05-25 22:09:51 -04:00
Rajiv Shah c49df15f13 Use build matrix to test on multiple Xcode versions 2020-05-25 22:05:57 -04:00
Rajiv Shah 0090aa227b Allow force tries and force casts in tests 2020-05-25 17:29:30 -04:00
Rajiv Shah e9ab9d09a5 Relax rules a bit 2020-05-25 17:26:38 -04:00
Rajiv Shah 9c13919fd8 Run SwiftLint autocorrect 2020-05-25 17:06:53 -04:00
Rajiv Shah 6d7753ea66 Add SwiftLint config 2020-05-25 16:27:53 -04:00
Xashyar b9fa2f43b7 Persian translation 2020-05-18 16:18:52 +01:00
Kornel 2c1125a86a Revert "Persian translations"
This reverts commit e33a10638d.
2020-05-18 16:18:00 +01:00
Kornel d37d85b812 Merge pull request #1591 from R4N/fullscreen-alert-fix-v1 2020-05-15 20:39:06 +01:00
Kornel 388915c8d0 Merge pull request #1593 from Xashyar/patch-6 2020-05-15 20:38:33 +01:00
Xashyar e33a10638d Persian translations 2020-05-15 23:27:15 +04:30
Micah Moore d1d71dc127 Sets UpdateAlert and AutomaticUpdateAlert window's fullscreen collectionBehavior to NSWindowCollectionBehaviorFullScreenAuxiliary to allow them to present on top of the Main App's window if it's fullscreen. 2020-05-15 14:06:52 -04:00
Kornel 4ed56d5961 Merge pull request #1589 from ianbytchek/master 2020-05-15 17:33:58 +01:00
Ian Bytchek 1ab5ad82b5 Improve best appcast item selection handling
This fixes #1572 and takes care of situations when item dates are unavailable and when items with higher versions use earlier dates than items with lower versions, e.g., version 1.2.3 was published today and version 2.3.4 was published yesterday.
2020-05-15 17:08:34 +01:00
Kornel d01298c9ce Bump 2020-05-13 11:15:47 +01:00
Kornel a242035c74 Merge pull request #1586 from lwouis/fix-iframe-popup 2020-05-12 13:54:36 +01:00
Louis Pontoise 8f19f6a8cc fix: when the user set a release note url, and that page was creating iframes without src attributes, these would make popups appear saying "There is no application set to open the URL about:blank."
A request URL to about:blank has no purpose of being opened, so we ignore it.
2020-05-12 02:12:54 +09:00
Kornel 9568732f78 Merge pull request #1582 from Wevah/generate-appcast-hashpath 2020-05-02 15:53:48 +01:00
Nate Weaver f49295b054 Use the SHA-256 hash of the archive as the extraction path
Issue #1559.
2020-05-01 19:49:20 -05:00
Nate Weaver aff67ceda8 Add documentation comments; don't return an optional from the FileHandle method 2020-05-01 19:23:58 -05:00
Nate Weaver c8d5d18ce0 Add URL+Hashing 2020-05-01 19:15:29 -05:00
Kornel f1167b3649 Merge pull request #1575 from DanielFirlej/Polish2622
Update SUUpdateAlert.xib
2020-04-12 22:20:35 +01:00
DanielFirlej 3077864a3e Update SUUpdateAlert.xib
Missing translation > Software Update > Uaktualnienie oprogramowania
2020-04-12 20:40:15 +02:00
Kornel 2db0d8cb37 Merge pull request #1571 from D0miH/feature/1569-download-url-prefix-option
Prefix for download url can be provided to generate_appcast
2020-04-07 00:17:05 +01:00
Dominik H 0d16b459a5 added help command line option 2020-04-06 17:09:55 +02:00
Dominik H 4c3e202d2e added function that parses all command line options 2020-04-06 16:57:17 +02:00
Dominik H 96d162c7e5 command line option to provide a download url prefix is now parsed and set on each archive item 2020-04-04 23:12:26 +02:00
Kornel 01b48d44e8 Merge pull request #1561 from TheTechRobo/master
Update README.markdown
2020-03-17 14:08:01 +00:00
Ittussarom Retals Mail Ynohtna c39f7df513 Update README.markdown
A few changes to the README file to make it a tad more clear
2020-03-17 09:38:22 -04:00
Kornel ec15362770 Compress with lzma 2020-02-11 18:24:54 +00:00
Kenneth Johnsen 962878b843 Fix missing Danish translations in Sparkle.strings 2020-02-03 17:23:52 +00:00
pteeson 9d8909c38d Remove .h files from Build Rules for bsdiff and ed25519 (#1538)
On branch VendorBuildPhasesFix
Changes to be committed:
	modified:   Sparkle.xcodeproj/project.pbxproj

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

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

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

Try to preserve Finder tags while updating apps

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

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

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

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

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

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

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

    Fixed capitalization

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

    Fix for changed string

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

    Improvements

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

No files matched your search

@@ -1,24 +1,11 @@
---
name: Enhancements and Bug Fixes
about: Found a bug? Want to implement a new feature? Something else?
about: Found a bug? Want to implement a new feature?
title: ''
assignees: ''
---
<!--
If this is a question or an idea, please consider posting in Discussions first:
https://github.com/sparkle-project/Sparkle/discussions
Otherwise the answer to your issue may already be in Console.app on your computer.
Please use Console.app and search for Sparkle.
Please try troubleshooting steps:
https://github.com/sparkle-project/Sparkle#troubleshooting
-->
## Summary
[provide general summary to the issue or enhancement and its rationale]
@@ -29,4 +16,4 @@ https://github.com/sparkle-project/Sparkle#troubleshooting
## Version
[please specify versions of Sparkle this is applicable to]
[please specify versions of Sparkle this is applicable to; note new pull requests must be developed and landed in 2.x development branch first]
@@ -1,7 +1,8 @@
---
name: Sparkle doesn't work in my app
about: Problems with integration, unexpected errors using Sparkle
name: Sparkle 1.x doesn't work in my app
about: Problems with integration, unexpected errors
title: ''
labels: '1.x'
assignees: ''
---
@@ -31,5 +32,3 @@ https://github.com/sparkle-project/Sparkle#troubleshooting
```
### Steps to reproduce the behavior
[The more information provided and pasted verbatim, the easier it will be to diagnose an issue. If you can provide the affected application/binary and XML feed to reproduce an issue, share them]
@@ -0,0 +1,34 @@
---
name: Sparkle 2.x doesn't work in my app
about: Problems with using the beta version of Sparkle 2
title: ''
labels: '2.x'
assignees: ''
---
<!--
The answer to your issue is probably already in Console.app on your computer.
Please use Console.app and search for Sparkle.
Please try troubleshooting steps:
https://github.com/sparkle-project/Sparkle#troubleshooting
-->
### Description of the problem
### Do you use Sandboxing in your app?
### Version of `Sparkle.framework` in the latest version of your app
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
### Sparkle's output from Console.app
```
```
### Steps to reproduce the behavior
+11 -3
View File
@@ -2,10 +2,18 @@
Fixes # (issue)
## Misc Checklist
## Checklist:
- [ ] My change requires a documentation update on [Sparkle's website repository](https://github.com/sparkle-project/sparkle-project.github.io)
- [ ] My change requires changes to generate_appcast, generate_keys, or sign_update
- [ ] My change is being tested and reviewed against the Sparkle 2.x branch. New changes must be developed on the 2.x development branch first.
- [ ] My change is being backported to master branch (Sparkle 1.x), if deemed necessary. Please create a separate pull request for 1.x, should it be backported.
- [ ] I have reviewed and commented my code, particularly in hard-to-understand areas.
## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] My change is or requires a documentation or localization update
## Testing
+6 -45
View File
@@ -10,21 +10,17 @@ jobs:
build:
strategy:
matrix:
xcode: ['xcode14.3.1', 'xcode15']
xcode: ['xcode12.5.1', 'xcode13.1']
include:
- xcode: 'xcode15'
xcode-path: '/Applications/Xcode_15.0.app/Contents/Developer'
- xcode: 'xcode12.5.1'
xcode-path: '/Applications/Xcode_12.5.1.app/Contents/Developer'
upload-dist: false
run-analyzer: true
macos: 'macos-13'
- xcode: 'xcode14.3.1'
xcode-path: '/Applications/Xcode_14.3.1.app/Contents/Developer'
- xcode: 'xcode13.1'
xcode-path: '/Applications/Xcode_13.1.app/Contents/Developer'
upload-dist: true
run-analyzer: false
macos: 'macos-13'
name: Build and Test Sparkle
runs-on: ${{ matrix.macos }}
runs-on: macos-11
steps:
- name: Checkout
@@ -52,41 +48,6 @@ jobs:
DEVELOPER_DIR: ${{ matrix.xcode-path }}
run: |
xcodebuild test-without-building -project Sparkle.xcodeproj -scheme UITests -configuration Debug -derivedDataPath build
- name: Analyze Sparkle
if: ${{ matrix.run-analyzer && github.event_name == 'pull_request' }}
env:
DEVELOPER_DIR: ${{ matrix.xcode-path }}
run: |
xcodebuild analyze -project Sparkle.xcodeproj -quiet -scheme Sparkle -configuration Release -derivedDataPath analyze > anaylze_output.txt
- name: Find Analyzed Warnings
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' }}
id: findwarnings
env:
DEVELOPER_DIR: ${{ matrix.xcode-path }}
run: |
if grep -q "warning:" anaylze_output.txt; then
echo '::set-output name=analyzestatus::0'
else
echo '::set-output name=analyzestatus::1'
fi
- name: Extract Analyzed Warnings
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }}
id: warnings
run: |
echo ::set-output name=content::$(cat anaylze_output.txt)
- name: Post Analyzed Warnings
if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }}
uses: mshick/add-pr-comment@v1
with:
allow-repeats: false
repo-token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
repo-token-user-login: 'Sparkle-Bot'
message: "``` ${{ steps.warnings.outputs.content }} ```"
- name: Build Release Distribution
env:
DEVELOPER_DIR: ${{ matrix.xcode-path }}
+5 -6
View File
@@ -2,7 +2,7 @@ name: "Create Draft Release"
env:
BUILDDIR: "build"
DEVELOPER_DIR: "/Applications/Xcode_14.3.1.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_13.1.app/Contents/Developer"
on:
workflow_dispatch:
@@ -29,11 +29,11 @@ concurrency:
jobs:
release:
name: "Publish binaries for release"
runs-on: macos-13
runs-on: macos-11
steps:
- name: "Checkout sources"
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
submodules: true
@@ -80,7 +80,7 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
- name: "Push the updated package description"
- name: "Push the updated Swift package description"
env:
GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
run: git push
@@ -90,8 +90,7 @@ jobs:
with:
draft: true
prerelease: ${{ env.PRERELEASE_VERSION }}
target_commitish: ${{ github.ref_name }}
name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
name: "Sparkle ${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
fail_on_unmatched_files: true
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
+3
View File
@@ -0,0 +1,3 @@
[submodule "Vendor/ed25519"]
path = Vendor/ed25519
url = https://github.com/orlp/ed25519
-35
View File
@@ -1,35 +0,0 @@
//
// AgentConnection.h
// Sparkle
//
// Created by Mayur Pawashe on 7/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol AgentConnectionDelegate <NSObject>
- (void)agentConnectionDidInitiate;
- (void)agentConnectionDidInvalidate;
@end
@protocol SPUInstallerAgentProtocol;
SPU_OBJC_DIRECT_MEMBERS @interface AgentConnection : NSObject
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate;
- (void)startListener;
- (void)invalidate;
@property (nonatomic, readonly, nullable) id<SPUInstallerAgentProtocol> agent;
@property (nonatomic, readonly) BOOL connected;
@property (nonatomic, nullable) NSError *invalidationError;
@end
NS_ASSUME_NONNULL_END
-119
View File
@@ -1,119 +0,0 @@
//
// AgentConnection.m
// Sparkle
//
// Created by Mayur Pawashe on 7/17/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "AgentConnection.h"
#import "SPUMessageTypes.h"
#import "SPUInstallerAgentProtocol.h"
#import "SUInstallerAgentInitiationProtocol.h"
#include "AppKitPrevention.h"
@interface AgentConnection () <NSXPCListenerDelegate, SUInstallerAgentInitiationProtocol>
@end
@implementation AgentConnection
{
NSXPCListener *_xpcListener;
NSXPCConnection *_activeConnection;
__weak id<AgentConnectionDelegate> _delegate;
}
@synthesize agent = _agent;
@synthesize connected = _connected;
@synthesize invalidationError = _invalidationError;
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate
{
self = [super init];
if (self != nil) {
// Agents should always be the one that connect to daemons due to how mach bootstraps work
// For this reason, we are the ones that are creating a listener, not the agent
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUProgressAgentServiceNameForBundleIdentifier(bundleIdentifier)];
_xpcListener.delegate = self;
_delegate = delegate;
}
return self;
}
- (void)startListener
{
[_xpcListener resume];
}
- (void)invalidate
{
_delegate = nil;
[_activeConnection invalidate];
_activeConnection = nil;
[_xpcListener invalidate];
_xpcListener = nil;
}
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
{
if (_activeConnection != nil) {
[newConnection invalidate];
return NO;
}
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentInitiationProtocol)];
newConnection.exportedObject = self;
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SPUInstallerAgentProtocol)];
_activeConnection = newConnection;
__weak __typeof__(self) weakSelf = self;
newConnection.interruptionHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
__typeof__(self) strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf->_activeConnection invalidate];
}
});
};
newConnection.invalidationHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
__typeof__(self) strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf->_delegate agentConnectionDidInvalidate];
}
});
};
[newConnection resume];
_agent = newConnection.remoteObjectProxy;
return YES;
}
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
{
dispatch_async(dispatch_get_main_queue(), ^{
self->_connected = YES;
[self->_delegate agentConnectionDidInitiate];
});
acknowledgement();
}
- (void)connectionWillInvalidateWithError:(NSError *)error
{
dispatch_async(dispatch_get_main_queue(), ^{
self->_invalidationError = error;
});
}
@end
-24
View File
@@ -1,24 +0,0 @@
//
// AppInstaller.h
// Sparkle
//
// Created by Mayur Pawashe on 3/7/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUUnarchiverProtocol.h"
NS_ASSUME_NONNULL_BEGIN
SPU_OBJC_DIRECT_MEMBERS @interface AppInstaller : NSObject
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName;
- (void)start;
- (void)cleanupAndExitWithStatus:(int)status error:(NSError * _Nullable)error __attribute__((noreturn));
@end
NS_ASSUME_NONNULL_END
-675
View File
@@ -1,675 +0,0 @@
//
// AppInstaller.m
// Sparkle
//
// Created by Mayur Pawashe on 3/7/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "AppInstaller.h"
#import "SUInstaller.h"
#import "SUUpdateValidator.h"
#import "SULog.h"
#import "SULog+NSError.h"
#import "SUHost.h"
#import "SULocalizations.h"
#import "SUStandardVersionComparator.h"
#import "SPUMessageTypes.h"
#import "SPUSecureCoding.h"
#import "SPUInstallationInputData.h"
#import "SUUnarchiver.h"
#import "SUFileManager.h"
#import "SPUInstallationInfo.h"
#import "SUAppcastItem.h"
#import "SUErrors.h"
#import "SUInstallerCommunicationProtocol.h"
#import "AgentConnection.h"
#import "SPUInstallerAgentProtocol.h"
#import "SPUInstallationType.h"
#import "SPULocalCacheDirectory.h"
#include "AppKitPrevention.h"
#define FIRST_UPDATER_MESSAGE_TIMEOUT 18ull
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 8ull
/**
* Show display progress UI after a delay from starting the final part of the installation.
* This should be long enough so that we don't show progress for very fast installations, but
* short enough so that we don't leave the user wondering why nothing is happening.
*/
static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
@interface AppInstaller () <NSXPCListenerDelegate, SUInstallerCommunicationProtocol, AgentConnectionDelegate>
@end
@implementation AppInstaller
{
NSXPCListener* _xpcListener;
NSXPCConnection *_activeConnection;
id<SUInstallerCommunicationProtocol> _communicator;
AgentConnection *_agentConnection;
SUUpdateValidator *_updateValidator;
NSString *_hostBundleIdentifier;
NSString *_homeDirectory;
NSString *_userName;
SUHost *_host;
NSString *_updateDirectoryPath;
NSString *_downloadName;
NSString *_decryptionPassword;
SUSignatures *_signatures;
NSString *_relaunchPath;
NSString *_installationType;
id<SUInstallerProtocol> _installer;
dispatch_queue_t _installerQueue;
BOOL _shouldRelaunch;
BOOL _shouldShowUI;
BOOL _receivedUpdaterPong;
BOOL _willCompleteInstallation;
BOOL _receivedInstallationData;
BOOL _finishedValidation;
BOOL _agentInitiatedConnection;
BOOL _performedStage1Installation;
BOOL _performedStage2Installation;
BOOL _performedStage3Installation;
BOOL _targetTerminated;
}
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
{
if (!(self = [super init])) {
return nil;
}
_hostBundleIdentifier = [hostBundleIdentifier copy];
_homeDirectory = [homeDirectory copy];
_userName = [userName copy];
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier)];
_xpcListener.delegate = self;
_agentConnection = [[AgentConnection alloc] initWithHostBundleIdentifier:hostBundleIdentifier delegate:self];
return self;
}
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
{
if (_activeConnection != nil) {
SULog(SULogLevelDefault, @"Rejecting multiple connections...");
[newConnection invalidate];
return NO;
}
_activeConnection = newConnection;
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
newConnection.exportedObject = self;
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
__weak __typeof__(self) weakSelf = self;
newConnection.interruptionHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
__typeof__(self) strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf->_activeConnection invalidate];
}
});
};
newConnection.invalidationHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
__typeof__(self) strongSelf = weakSelf;
if (strongSelf != nil) {
if (strongSelf->_activeConnection != nil && !strongSelf->_willCompleteInstallation) {
[strongSelf cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Invalidation on remote port being called, and installation is not close enough to completion!" }]];
}
strongSelf->_communicator = nil;
strongSelf->_activeConnection = nil;
}
});
};
[newConnection resume];
_communicator = newConnection.remoteObjectProxy;
return YES;
}
- (void)start
{
[_xpcListener resume];
[_agentConnection startListener];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FIRST_UPDATER_MESSAGE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self->_receivedInstallationData) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: installation data was never received" }]];
}
if (!self->_agentConnection.connected) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout: agent connection was never initiated" }]];
}
});
}
- (void)extractAndInstallUpdate SPU_OBJC_DIRECT
{
[_communicator handleMessageWithIdentifier:SPUExtractionStarted data:[NSData data]];
NSString *archivePath = [_updateDirectoryPath stringByAppendingPathComponent:_downloadName];
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:archivePath updatingHostBundlePath:_host.bundlePath decryptionPassword:_decryptionPassword expectingInstallationType:_installationType];
NSError *unarchiverError = nil;
BOOL success = NO;
if (!unarchiver) {
unarchiverError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"No valid unarchiver was found for %@", archivePath] }];
success = NO;
} else {
_updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:archivePath signatures:_signatures host:_host];
// Delta & package updates will require validation before extraction
// Normal application updates are a bit more lenient allowing developers to change one of apple dev ID or EdDSA keys
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction] || ![_installationType isEqualToString:SPUInstallationTypeApplication];
if (needsPrevalidation) {
success = [_updateValidator validateDownloadPathWithError:&unarchiverError];
} else {
success = YES;
}
}
if (!success) {
[self unarchiverDidFailWithError:unarchiverError];
} else {
[unarchiver
unarchiveWithCompletionBlock:^(NSError * _Nullable error) {
if (error != nil) {
[self unarchiverDidFailWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to unarchive %@", archivePath], NSUnderlyingErrorKey: (NSError * _Nonnull)error }]];
} else {
[self->_communicator handleMessageWithIdentifier:SPUValidationStarted data:[NSData data]];
NSError *validationError = nil;
BOOL validationSuccess = [self->_updateValidator validateWithUpdateDirectory:self->_updateDirectoryPath error:&validationError];
if (!validationSuccess) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Update validation was a failure", NSUnderlyingErrorKey: validationError }]];
} else {
[self->_communicator handleMessageWithIdentifier:SPUInstallationStartedStage1 data:[NSData data]];
self->_finishedValidation = YES;
if (self->_agentInitiatedConnection) {
[self retrieveProcessIdentifierAndStartInstallation];
}
}
}
}
progressBlock:^(double progress) {
if (sizeof(progress) == sizeof(uint64_t)) {
uint64_t progressValue = CFSwapInt64HostToLittle(*(uint64_t *)&progress);
NSData *data = [NSData dataWithBytes:&progressValue length:sizeof(progressValue)];
[self->_communicator handleMessageWithIdentifier:SPUExtractedArchiveWithProgress data:data];
}
}];
}
}
- (void)clearUpdateDirectory SPU_OBJC_DIRECT
{
if (_updateDirectoryPath != nil) {
NSError *theError = nil;
if (![[[SUFileManager alloc] init] removeItemAtURL:[NSURL fileURLWithPath:_updateDirectoryPath] error:&theError]) {
SULog(SULogLevelError, @"Couldn't remove update folder: %@.", theError);
}
_updateDirectoryPath = nil;
}
}
- (void)unarchiverDidFailWithError:(NSError *)error SPU_OBJC_DIRECT
{
SULog(SULogLevelError, @"Failed to unarchive file");
SULogError(error);
// No longer need update validator until next possible extraction (eg: if initial delta update fails)
_updateValidator = nil;
// Client could try update again with different inputs
// Eg: one common case is if a delta update fails, client may want to fall back to regular update
// We really only need to set updateDirectoryPath to nil since that's the field we check if we've received installation data,
// but may as well set other fields to nil too
[self clearUpdateDirectory];
_downloadName = nil;
_decryptionPassword = nil;
_signatures = nil;
_relaunchPath = nil;
_host = nil;
NSData *archivedError = SPUArchiveRootObjectSecurely(error);
[_communicator handleMessageWithIdentifier:SPUArchiveExtractionFailed data:archivedError != nil ? archivedError : [NSData data]];
}
- (void)agentConnectionDidInitiate
{
_agentInitiatedConnection = YES;
if (_finishedValidation) {
[self retrieveProcessIdentifierAndStartInstallation];
}
}
- (void)agentConnectionDidInvalidate
{
if (!_finishedValidation || !_agentInitiatedConnection || !_targetTerminated) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Error: Agent connection invalidated before installation began" }];
NSError *agentError = _agentConnection.invalidationError;
if (agentError != nil) {
userInfo[NSUnderlyingErrorKey] = agentError;
}
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:userInfo]];
}
}
- (void)retrieveProcessIdentifierAndStartInstallation SPU_OBJC_DIRECT
{
// We use the relaunch path for the bundle to listen for termination instead of the host path
// For a plug-in this makes a big difference; we want to wait until the app hosting the plug-in terminates
// Otherwise for an app, the relaunch path and host path should be identical
__block BOOL receivedResponse = NO;
[_agentConnection.agent registerApplicationBundlePath:_relaunchPath reply:^(BOOL targetTerminated) {
dispatch_async(dispatch_get_main_queue(), ^{
receivedResponse = YES;
if (!targetTerminated) {
[self->_agentConnection.agent listenForTerminationWithCompletion:^{
dispatch_async(dispatch_get_main_queue(), ^{
self->_targetTerminated = YES;
if (self->_performedStage1Installation) {
[self finishInstallationAfterHostTermination];
}
});
}];
} else {
self->_targetTerminated = YES;
}
[self startInstallation];
});
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!receivedResponse) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Timeout error: failed to retreive process identifier from agent" }]];
}
});
}
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
{
if (identifier == SPUInstallationData && _updateDirectoryPath == nil) {
dispatch_async(dispatch_get_main_queue(), ^{
// Mark that we have received the installation data
// Do not rely on eg: self->_updateDirectoryPath != nil because we may set it to nil again if an early stage fails (i.e, archive extraction)
self->_receivedInstallationData = YES;
SPUInstallationInputData *installationData = (SPUInstallationInputData *)SPUUnarchiveRootObjectSecurely(data, [SPUInstallationInputData class]);
if (installationData == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to unarchive input installation data" }]];
return;
}
NSString *installationType = installationData.installationType;
if (!SPUValidInstallationType(installationType)) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Received invalid installation type: %@", installationType] }]];
return;
}
NSBundle *hostBundle = [NSBundle bundleWithPath:installationData.hostBundlePath];
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self->_hostBundleIdentifier]) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to match host bundle identifiers %@ and %@", self->_hostBundleIdentifier, bundleIdentifier] }]];
return;
}
// This will be important later
if (installationData.relaunchPath == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to obtain relaunch path from installation data" }]];
return;
}
// This installation path is specific to sparkle and the bundle identifier
NSString *rootCacheInstallationPath = [[SPULocalCacheDirectory cachePathForBundleIdentifier:bundleIdentifier] stringByAppendingPathComponent:@"Installation"];
[SPULocalCacheDirectory removeOldItemsInDirectory:rootCacheInstallationPath];
NSString *cacheInstallationPath = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:rootCacheInstallationPath];
if (cacheInstallationPath == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to create installation cache directory in %@", rootCacheInstallationPath] }]];
return;
}
// Resolve the bookmark data for the downloaded update
// See "Share file access between processes with URL bookmarks" in https://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox
BOOL isStale = NO;
NSError *bookmarkError = nil;
NSURL *downloadURL = [NSURL URLByResolvingBookmarkData:installationData.updateURLBookmarkData options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil bookmarkDataIsStale:&isStale error:&bookmarkError];
if (downloadURL == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to resolve bookmark data from downloaded update", NSUnderlyingErrorKey: bookmarkError }]];
return;
}
// Validate the download URL before moving it
{
NSArray<NSString *> *downloadURLPathComponents = downloadURL.URLByResolvingSymlinksInPath.pathComponents;
if (downloadURLPathComponents == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to retrieve path components from download URL" }]];
return;
}
if ([downloadURLPathComponents containsObject:@".."]) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: download URL path components contains '..' which is unsafe" }]];
return;
}
if (![downloadURLPathComponents containsObject:@SPARKLE_BUNDLE_IDENTIFIER] || ![downloadURLPathComponents containsObject:@"PersistentDownloads"]) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: download URL path components does not contain PersistentDownloads or "@SPARKLE_BUNDLE_IDENTIFIER }]];
return;
}
}
if (!isStale) {
SULog(SULogLevelError, @"Error: bookmark data for update download is stale.. but still continuing.");
}
NSString *downloadName = downloadURL.lastPathComponent;
if (downloadName == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to retrieve download name from download URL" }]];
return;
}
// Move the download archive to somewhere where probably only we will be touching it
// This prevents eg: if a bug exists in the updater that removes files we are trying to install
// When this tool is ran as root, we are moving it into a directory that only root will have access to
NSURL *downloadDestinationURL = [[NSURL fileURLWithPath:cacheInstallationPath] URLByAppendingPathComponent:downloadName];
NSError *moveError = nil;
if (![[[SUFileManager alloc] init] moveItemAtURL:downloadURL toURL:downloadDestinationURL error:&moveError]) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to move download archive to new location", NSUnderlyingErrorKey: moveError }]];
return;
}
// Make sure the downloaded archive we moved over is a regular file and not a symbolic link placed by an attacker
NSError *attributesError = nil;
NSString *downloadDestinationPath = downloadDestinationURL.path;
if (downloadDestinationPath == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to retrieve download archive path from %@", downloadDestinationURL] }]];
return;
}
NSDictionary<NSString *, id> *archiveAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:downloadDestinationPath error:&attributesError];
if (archiveAttributes == nil) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Failed to retrieve download archive attributes from %@", downloadDestinationPath] }]];
return;
}
if (![(NSString *)archiveAttributes[NSFileType] isEqualToString:NSFileTypeRegular]) {
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Error: Received bad archive file type: %@", archiveAttributes[NSFileType]] }]];
return;
}
// Carry these properities separately rather than using the SUInstallationInputData object
// Some of our properties may slightly differ than our input and we don't want to make the mistake of using one of those
self->_installationType = installationType;
self->_relaunchPath = installationData.relaunchPath;
self->_downloadName = downloadName;
self->_signatures = installationData.signatures;
self->_updateDirectoryPath = cacheInstallationPath;
self->_host = [[SUHost alloc] initWithBundle:hostBundle];
[self extractAndInstallUpdate];
});
} else if (identifier == SPUSentUpdateAppcastItemData) {
SUAppcastItem *updateItem = (SUAppcastItem *)SPUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
if (updateItem != nil) {
SPUInstallationInfo *installationInfo = [[SPUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[_installer canInstallSilently]];
NSData *archivedData = SPUArchiveRootObjectSecurely(installationInfo);
if (archivedData != nil) {
[_agentConnection.agent registerInstallationInfoData:archivedData];
}
}
} else if (identifier == SPUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
// Because anyone can ask us to resume the installation, it may be wise to think about backwards compatibility here if IPC changes
uint8_t relaunch = *((const uint8_t *)data.bytes);
uint8_t showsUI = *((const uint8_t *)data.bytes + 1);
dispatch_async(dispatch_get_main_queue(), ^{
// This flag has an impact on interactive type installations and showing UI progress during non-interactive installations
self->_shouldShowUI = (BOOL)showsUI;
// Don't test if the application was alive initially, leave that to the progress agent if we decide to relaunch
self->_shouldRelaunch = (BOOL)relaunch;
if (self->_performedStage1Installation) {
// Resume the installation if we aren't done with stage 2 yet, and remind the client we are prepared to relaunch
dispatch_async(self->_installerQueue, ^{
if (!self->_performedStage2Installation) {
[self performStage2Installation];
} else if (!self->_performedStage3Installation) {
// If we already performed the 2nd stage, re-purpose this request to re-try sending another termination signal
dispatch_async(dispatch_get_main_queue(), ^{
// Don't check if the target is already terminated, leave that to the progress agent
// We could be slightly off if there were multiple instances running
[self->_agentConnection.agent sendTerminationSignal];
});
}
});
}
});
} else if (identifier == SPUCancelInstallation) {
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:0 error:nil];
});
} else if (identifier == SPUUpdaterAlivePong) {
_receivedUpdaterPong = YES;
}
}
- (void)startInstallation SPU_OBJC_DIRECT
{
_willCompleteInstallation = YES;
dispatch_queue_attr_t queuePriority = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0);
_installerQueue = dispatch_queue_create("org.sparkle-project.sparkle.installer", queuePriority);
dispatch_async(_installerQueue, ^{
NSError *installerError = nil;
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self->_host expectedInstallationType:self->_installationType updateDirectory:self->_updateDirectoryPath homeDirectory:self->_homeDirectory userName:self->_userName error:&installerError];
if (installer == nil) {
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to create installer instance", NSUnderlyingErrorKey: installerError }]];
});
return;
}
NSError *firstStageError = nil;
if (![installer performInitialInstallation:&firstStageError]) {
self->_installer = nil;
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to start installer", NSUnderlyingErrorKey: firstStageError }]];
});
return;
}
uint8_t canPerformSilentInstall = (uint8_t)[installer canInstallSilently];
dispatch_async(dispatch_get_main_queue(), ^{
self->_installer = installer;
uint8_t sendInformation[] = {canPerformSilentInstall, (uint8_t)self->_targetTerminated};
NSData *sendData = [NSData dataWithBytes:sendInformation length:sizeof(sendInformation)];
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage1 data:sendData];
self->_performedStage1Installation = YES;
if (self->_targetTerminated) {
// Stage 2 can still be run before we finish installation
// if the updater requests for it before the app is terminated
[self finishInstallationAfterHostTermination];
}
});
});
}
- (void)performStage2Installation SPU_OBJC_DIRECT
{
BOOL canPerformSecondStage = _shouldShowUI || [_installer canInstallSilently];
if (canPerformSecondStage) {
_performedStage2Installation = YES;
dispatch_async(dispatch_get_main_queue(), ^{
uint8_t targetTerminated = (uint8_t)self->_targetTerminated;
NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)];
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage2 data:sendData];
// Don't check if the target is already terminated, leave that to the progress agent
// We could be slightly off if there were multiple instances running
[self->_agentConnection.agent sendTerminationSignal];
});
} else {
_installer = nil;
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Error: Failed to resume installer on stage 2 because installation cannot be installed silently" }]];
});
}
}
- (void)finishInstallationAfterHostTermination SPU_OBJC_DIRECT
{
assert(self->_targetTerminated);
// Show our installer progress UI tool if only after a certain amount of time passes,
// and if our installer is silent (i.e, doesn't show progress on its own)
__block BOOL shouldShowUIProgress = YES;
if (self->_shouldShowUI && [self->_installer canInstallSilently]) {
// Ask the updater if it is still alive
// If they are, we will receive a pong response back
// Reset if we received a pong just to be on the safe side
self->_receivedUpdaterPong = NO;
[self->_communicator handleMessageWithIdentifier:SPUUpdaterAlivePing data:[NSData data]];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUDisplayProgressTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// Make sure we're still eligible for showing the installer progress
// Also if the updater process is still alive, showing the progress should not be our duty
// if the communicator object is nil, the updater definitely isn't alive. However, if it is not nil,
// this does not necessarily mean the updater is alive, so we should also check if we got a recent response back from the updater
if (shouldShowUIProgress && (!self->_receivedUpdaterPong || self->_communicator == nil)) {
[self->_agentConnection.agent showProgress];
}
});
}
dispatch_async(self->_installerQueue, ^{
if (!self->_performedStage2Installation) {
[self performStage2Installation];
}
if (!self->_performedStage2Installation) {
// We failed and we're going to exit shortly
return;
}
NSError *thirdStageError = nil;
if (![self->_installer performFinalInstallationProgressBlock:nil error:&thirdStageError]) {
[self->_installer performCleanup];
self->_installer = nil;
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:EXIT_FAILURE error:[NSError errorWithDomain:SUSparkleErrorDomain code:SPUInstallerError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to finalize installation", NSUnderlyingErrorKey: thirdStageError }]];
});
return;
}
self->_performedStage3Installation = YES;
dispatch_async(dispatch_get_main_queue(), ^{
// Make sure to stop our displayed progress before we move onto cleanup & relaunch
// This will also stop the agent from broadcasting the status info service, which we want to do before
// we relaunch the app because the relaunched app could check the service upon launch..
[self->_agentConnection.agent stopProgress];
shouldShowUIProgress = NO;
[self->_communicator handleMessageWithIdentifier:SPUInstallationFinishedStage3 data:[NSData data]];
if (self->_shouldRelaunch) {
// This will also signal to the agent that it will terminate soon
[self->_agentConnection.agent relaunchApplication];
}
[self->_installer performCleanup];
[self cleanupAndExitWithStatus:EXIT_SUCCESS error:nil];
});
});
}
- (void)cleanupAndExitWithStatus:(int)status error:(NSError * _Nullable)error __attribute__((noreturn))
{
if (error != nil) {
SULogError(error);
NSData *errorData = SPUArchiveRootObjectSecurely((NSError * _Nonnull)error);
if (errorData != nil) {
[_communicator handleMessageWithIdentifier:SPUInstallerError data:errorData];
}
}
// It's nice to tell the other end we're invalidating
[_activeConnection invalidate];
_activeConnection = nil;
[_xpcListener invalidate];
_xpcListener = nil;
[_agentConnection invalidate];
_agentConnection = nil;
[self clearUpdateDirectory];
exit(status);
}
@end
-19
View File
@@ -1,19 +0,0 @@
//
// SPUDeltaArchive.h
// Sparkle
//
// Created by Mayur Pawashe on 12/29/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol SPUDeltaArchiveProtocol;
@class SPUDeltaArchiveHeader;
NS_ASSUME_NONNULL_BEGIN
// Opens patch file for reading and decodes the archive header
id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFile, SPUDeltaArchiveHeader * _Nullable __autoreleasing * _Nullable outHeader);
NS_ASSUME_NONNULL_END
-121
View File
@@ -1,121 +0,0 @@
//
// SPUDeltaArchive.m
// Sparkle
//
// Created by Mayur Pawashe on 12/29/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import "SPUDeltaArchive.h"
#import "SPUDeltaArchiveProtocol.h"
#import "SPUSparkleDeltaArchive.h"
#import "SPUXarDeltaArchive.h"
#import <CommonCrypto/CommonDigest.h>
#include "AppKitPrevention.h"
SPUDeltaCompressionMode SPUDeltaCompressionModeDefault = (SPUDeltaCompressionMode)UINT8_MAX;
id<SPUDeltaArchiveProtocol> SPUDeltaArchiveReadPatchAndHeader(NSString *patchFile, SPUDeltaArchiveHeader * _Nullable __autoreleasing * _Nullable outHeader)
{
id<SPUDeltaArchiveProtocol> sparkleArchive = [[SPUSparkleDeltaArchive alloc] initWithPatchFileForReading:patchFile];
SPUDeltaArchiveHeader *header = [sparkleArchive readHeader];
if (header == nil) {
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
NSError *archiveError = sparkleArchive.error;
if (archiveError != nil && [archiveError.domain isEqualToString:SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN] && archiveError.code == SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC) {
// Retry with XAR archive if the magic value is unexpected
[sparkleArchive close];
id<SPUDeltaArchiveProtocol> xarArchive = [[SPUXarDeltaArchive alloc] initWithPatchFileForReading:patchFile];
SPUDeltaArchiveHeader *xarHeader = [xarArchive readHeader];
if (outHeader != NULL) {
*outHeader = xarHeader;
}
return xarArchive;
} else
#endif
{
if (outHeader != NULL) {
*outHeader = nil;
}
return sparkleArchive;
}
} else {
if (outHeader != NULL) {
*outHeader = header;
}
return sparkleArchive;
}
}
@implementation SPUDeltaArchiveItem
@synthesize relativeFilePath = _relativeFilePath;
@synthesize itemFilePath = _itemFilePath;
@synthesize clonedRelativePath = _clonedRelativePath;
@synthesize sourcePath = _sourcePath;
@synthesize commands = _commands;
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
@synthesize xarContext = _xarContext;
#endif
@synthesize mode = _mode;
@synthesize codedDataLength = _codedDataLength;
- (instancetype)initWithRelativeFilePath:(NSString *)relativeFilePath commands:(SPUDeltaItemCommands)commands mode:(uint16_t)mode
{
self = [super init];
if (self != nil) {
_relativeFilePath = [relativeFilePath copy];
_commands = commands;
_mode = mode;
}
return self;
}
@end
@implementation SPUDeltaArchiveHeader
{
unsigned char _beforeTreeHash[CC_SHA1_DIGEST_LENGTH];
unsigned char _afterTreeHash[CC_SHA1_DIGEST_LENGTH];
}
@synthesize compression = _compression;
@synthesize compressionLevel = _compressionLevel;
@synthesize fileSystemCompression = _fileSystemCompression;
@synthesize majorVersion = _majorVersion;
@synthesize minorVersion = _minorVersion;
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash
{
self = [super init];
if (self != nil)
{
_compression = compression;
_compressionLevel = compressionLevel;
_fileSystemCompression = fileSystemCompression;
_majorVersion = majorVersion;
_minorVersion = minorVersion;
memcpy(_beforeTreeHash, beforeTreeHash, sizeof(_beforeTreeHash));
memcpy(_afterTreeHash, afterTreeHash, sizeof(_afterTreeHash));
}
return self;
}
- (unsigned char *)beforeTreeHash
{
return _beforeTreeHash;
}
- (unsigned char *)afterTreeHash
{
return _afterTreeHash;
}
@end
-112
View File
@@ -1,112 +0,0 @@
//
// SPUDeltaArchiveProtocol.h
// Autoupdate
//
// Created by Mayur Pawashe on 12/28/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SPUDeltaCompressionMode.h"
NS_ASSUME_NONNULL_BEGIN
// Attributes for an item we extract/write to the archive
// Note: BinaryDiff cannot coexist together with Delete
typedef NS_ENUM(uint8_t, SPUDeltaItemCommands) {
SPUDeltaItemCommandEndMarker = 0,
SPUDeltaItemCommandDelete = (1u << 0),
SPUDeltaItemCommandExtract = (1u << 1),
SPUDeltaItemCommandModifyPermissions = (1u << 2),
SPUDeltaItemCommandBinaryDiff = (1u << 3),
SPUDeltaItemCommandClone = (1u << 4),
};
// Represents header for our archive
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveHeader : NSObject
- (instancetype)initWithCompression:(SPUDeltaCompressionMode)compression compressionLevel:(uint8_t)compressionLevel fileSystemCompression:(bool)fileSystemCompression majorVersion:(uint16_t)majorVersion minorVersion:(uint16_t)minorVersion beforeTreeHash:(const unsigned char *)beforeTreeHash afterTreeHash:(const unsigned char *)afterTreeHash;
@property (nonatomic, readonly) SPUDeltaCompressionMode compression;
@property (nonatomic, readonly) uint8_t compressionLevel;
@property (nonatomic, readonly) bool fileSystemCompression;
@property (nonatomic, readonly) uint16_t majorVersion;
@property (nonatomic, readonly) uint16_t minorVersion;
@property (nonatomic, readonly) unsigned char *beforeTreeHash;
@property (nonatomic, readonly) unsigned char *afterTreeHash;
@end
// Represents an item we read or write to in our delta archive
SPU_OBJC_DIRECT_MEMBERS @interface SPUDeltaArchiveItem : NSObject
- (instancetype)initWithRelativeFilePath:(NSString *)relativeFilePath commands:(SPUDeltaItemCommands)commands mode:(uint16_t)mode;
// The relative file path of the item, eg /Contents/MacOS/Foo
@property (nonatomic, readonly) NSString *relativeFilePath;
// For extraction, the path where the item will be extracted. For creation, the path to the item to add to the archive.
@property (nonatomic, nullable) NSString *itemFilePath;
// The relative file path of the originating item for clones. This may be null.
// For example, if /Contents/Resources/hello/foo.txt moves to /Contents/Resources/hello2/foo.txt, the former is the relative path
@property (nonatomic, nullable) NSString *clonedRelativePath;
// The source path of the item to extract file metadata from such as file size.
@property (nonatomic, nullable) NSString *sourcePath;
// The commands that describe the actions to take for this item.
@property (nonatomic, readonly) SPUDeltaItemCommands commands;
// Provided change in permissions for item or tracking file mode for the item
@property (nonatomic) uint16_t mode;
// Private properties
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
// xar_file context for Xar delta archiver
@property (nonatomic, nullable) const void *xarContext;
#endif
// Tracking length of item's data in data section, when encoding items and when extracting items
@property (nonatomic) uint64_t codedDataLength;
@end
// A protocol for reading and writing binary delta patches
// Operations must be done in order. The header must first be read or written before any other operations.
// For reading, file items cannot be extracted out of order.
@protocol SPUDeltaArchiveProtocol <NSObject>
@property (nonatomic, readonly, class) BOOL maySupportSafeExtraction;
// If non-nil, there was an error with reading or writing data from the archive
@property (nonatomic, readonly, nullable) NSError *error;
// Closes file for reading/writing, called in -dealloc if it's not called manually
- (void)close;
// For reading
// Retrieves metadata for the archive including major/minor version and expected bundle hashes
- (nullable SPUDeltaArchiveHeader *)readHeader;
// Enumerate through items in the patch file and read the path, attributes, permissions (if permission attribute is available), and way to stop enumeration
- (void)enumerateItems:(void (^)(SPUDeltaArchiveItem *item, BOOL *stop))itemHandler;
// Extract a file item from the patch file to a destination file
// The item's physical file path must be set as a destination
- (BOOL)extractItem:(SPUDeltaArchiveItem *)item;
// ------------
// For writing
// Set metadata for archive including major/minor version and expected bundle hashes
- (void)writeHeader:(SPUDeltaArchiveHeader *)header;
// Add item to patch file
// Physical file path must be provided if there is an extract or binary delta attribute
// Permissions are used only if there is a modify permissions attribute
- (void)addItem:(SPUDeltaArchiveItem *)item;
// Finishes encoding items after having added all of them
- (void)finishEncodingItems;
@end
NS_ASSUME_NONNULL_END
-22
View File
@@ -1,22 +0,0 @@
//
// SPUDeltaCompressionMode.h
// Sparkle
//
// Created by Mayur Pawashe on 1/3/22.
// Copyright © 2022 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
// Compression mode to use during patch creation
typedef NS_ENUM(uint8_t, SPUDeltaCompressionMode) {
SPUDeltaCompressionModeNone = 0,
SPUDeltaCompressionModeBzip2,
SPUDeltaCompressionModeLZMA,
SPUDeltaCompressionModeLZFSE,
SPUDeltaCompressionModeLZ4,
SPUDeltaCompressionModeZLIB
};
// For Swift access
extern SPUDeltaCompressionMode SPUDeltaCompressionModeDefault;
-26
View File
@@ -1,26 +0,0 @@
//
// SPUInstallationInfo.h
// Sparkle
//
// Created by Mayur Pawashe on 4/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem;
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInfo : NSObject <NSSecureCoding>
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentyInstall;
@property (nonatomic, readonly) SUAppcastItem *appcastItem;
@property (nonatomic, readonly) BOOL canSilentlyInstall;
@property (nonatomic) BOOL systemDomain;
@end
NS_ASSUME_NONNULL_END
-65
View File
@@ -1,65 +0,0 @@
//
// SPUInstallationInfo.m
// Sparkle
//
// Created by Mayur Pawashe on 4/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUInstallationInfo.h"
#import "SUAppcastItem.h"
#include "AppKitPrevention.h"
static NSString *SUAppcastItemKey = @"SUAppcastItem";
static NSString *SUCanSilentlyInstallKey = @"SUCanSilentlyInstall";
static NSString *SUSystemDomainKey = @"SUSystemDomain";
@implementation SPUInstallationInfo
@synthesize appcastItem = _appcastItem;
@synthesize canSilentlyInstall = _canSilentlyInstall;
@synthesize systemDomain = _systemDomain;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall systemDomain:(BOOL)systemDomain
{
self = [super init];
if (self != nil) {
_appcastItem = appcastItem;
_canSilentlyInstall = canSilentlyInstall;
_systemDomain = systemDomain;
}
return self;
}
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall
{
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:NO];
}
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
{
SUAppcastItem *appcastItem = [decoder decodeObjectOfClass:[SUAppcastItem class] forKey:SUAppcastItemKey];
if (appcastItem == nil) {
return nil;
}
BOOL canSilentlyInstall = [decoder decodeBoolForKey:SUCanSilentlyInstallKey];
BOOL systemDomain = [decoder decodeBoolForKey:SUSystemDomainKey];
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall systemDomain:systemDomain];
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:_appcastItem forKey:SUAppcastItemKey];
[coder encodeBool:_canSilentlyInstall forKey:SUCanSilentlyInstallKey];
[coder encodeBool:_systemDomain forKey:SUSystemDomainKey];
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
@end
-36
View File
@@ -1,36 +0,0 @@
//
// SPUInstallationInputData.h
// Sparkle
//
// Created by Mayur Pawashe on 3/24/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
@class SUSignatures;
NS_ASSUME_NONNULL_BEGIN
SPU_OBJC_DIRECT_MEMBERS @interface SPUInstallationInputData : NSObject <NSSecureCoding>
/*
* relaunchPath - path to application bundle to relaunch and listen for termination
* hostBundlePath - path to host bundle to update & replace
* updateDirectoryPath - path to update directory (i.e, temporary directory containing the new update archive)
* downloadName - name of update archive in update directory
* signatures - signatures for the update that came from the appcast item
* decryptionPassword - optional decryption password for dmg archives
*/
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateURLBookmarkData:(NSData *)updateURLBookmarkData installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
@property (nonatomic, copy, readonly) NSString *relaunchPath;
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
@property (nonatomic, copy, readonly) NSData *updateURLBookmarkData;
@property (nonatomic, copy, readonly) NSString *installationType;
@property (nonatomic, readonly, nullable) SUSignatures *signatures; // nullable because although not using signatures is deprecated, it's still supported
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
@end
NS_ASSUME_NONNULL_END
-97
View File
@@ -1,97 +0,0 @@
//
// SPUInstallationInputData.m
// Sparkle
//
// Created by Mayur Pawashe on 3/24/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUInstallationInputData.h"
#import "SPUInstallationType.h"
#import "SUSignatures.h"
#include "AppKitPrevention.h"
static NSString *SURelaunchPathKey = @"SURelaunchPath";
static NSString *SUHostBundlePathKey = @"SUHostBundlePath";
static NSString *SUUpdateURLBookmarkDataKey = @"SUUpdateURLBookmarkData";
static NSString *SUSignaturesKey = @"SUSignatures";
static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
static NSString *SUInstallationTypeKey = @"SUInstallationType";
@implementation SPUInstallationInputData
@synthesize relaunchPath = _relaunchPath;
@synthesize hostBundlePath = _hostBundlePath;
@synthesize updateURLBookmarkData = _updateURLBookmarkData;
@synthesize signatures = _signatures;
@synthesize decryptionPassword = _decryptionPassword;
@synthesize installationType = _installationType;
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateURLBookmarkData:(NSData *)updateURLBookmarkData installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword
{
self = [super init];
if (self != nil) {
_relaunchPath = [relaunchPath copy];
_hostBundlePath = [hostBundlePath copy];
_updateURLBookmarkData = updateURLBookmarkData;
_installationType = [installationType copy];
assert(SPUValidInstallationType(_installationType));
_signatures = signatures;
_decryptionPassword = [decryptionPassword copy];
}
return self;
}
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
{
NSString *relaunchPath = [decoder decodeObjectOfClass:[NSString class] forKey:SURelaunchPathKey];
if (relaunchPath == nil) {
return nil;
}
NSString *hostBundlePath = [decoder decodeObjectOfClass:[NSString class] forKey:SUHostBundlePathKey];
if (hostBundlePath == nil) {
return nil;
}
NSData *updateURLBookmarkData = [decoder decodeObjectOfClass:[NSData class] forKey:SUUpdateURLBookmarkDataKey];
if (updateURLBookmarkData == nil) {
return nil;
}
NSString *installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUInstallationTypeKey];
if (!SPUValidInstallationType(installationType)) {
return nil;
}
SUSignatures *signatures = [decoder decodeObjectOfClass:[SUSignatures class] forKey:SUSignaturesKey];
if (signatures == nil) {
return nil;
}
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateURLBookmarkData:updateURLBookmarkData installationType:installationType signatures:signatures decryptionPassword:decryptionPassword];
}
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:_relaunchPath forKey:SURelaunchPathKey];
[coder encodeObject:_hostBundlePath forKey:SUHostBundlePathKey];
[coder encodeObject:_updateURLBookmarkData forKey:SUUpdateURLBookmarkDataKey];
[coder encodeObject:_installationType forKey:SUInstallationTypeKey];
[coder encodeObject:_signatures forKey:SUSignaturesKey];
if (_decryptionPassword != nil) {
[coder encodeObject:_decryptionPassword forKey:SUDecryptionPasswordKey];
}
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
@end
-49
View File
@@ -1,49 +0,0 @@
//
// SPUMessageTypes.h
// Sparkle
//
// Created by Mayur Pawashe on 3/11/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
// Order matters; higher stages have higher values.
typedef NS_ENUM(int32_t, SPUInstallerMessageType)
{
SPUInstallerNotStarted = 0,
SPUExtractionStarted = 1,
SPUExtractedArchiveWithProgress = 2,
SPUArchiveExtractionFailed = 3,
SPUValidationStarted = 4,
SPUInstallationStartedStage1 = 5,
SPUInstallationFinishedStage1 = 6,
SPUInstallationFinishedStage2 = 7,
SPUInstallationFinishedStage3 = 8,
SPUUpdaterAlivePing = 9,
SPUInstallerError = 10
};
typedef NS_ENUM(int32_t, SPUUpdaterMessageType)
{
SPUInstallationData = 0,
SPUSentUpdateAppcastItemData = 1,
SPUResumeInstallationToStage2 = 2,
SPUUpdaterAlivePong = 3,
SPUCancelInstallation = 4
};
BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUInstallerMessageType newMessageType);
// Used by framework to communicate to installer (Autoupdate)
NSString *SPUInstallerServiceNameForBundleIdentifier(NSString *bundleIdentifier);
// Used by framework to communicate to progress agent tool (Updater)
NSString *SPUStatusInfoServiceNameForBundleIdentifier(NSString *bundleIdentifier);
// Used by progress agent tool to communicate to installer (Autoupdate)
NSString *SPUProgressAgentServiceNameForBundleIdentifier(NSString *bundleIdentifier);
NS_ASSUME_NONNULL_END
-85
View File
@@ -1,85 +0,0 @@
//
// SPUMessageTypes.m
// Sparkle
//
// Created by Mayur Pawashe on 3/11/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SPUMessageTypes.h"
#include "AppKitPrevention.h"
// Tags added to the bundle identifier which is used as Mach service names
// These should be very short because of length restrictions
#define SPARKLE_INSTALLER_TAG @"-spki"
#define SPARKLE_STATUS_TAG @"-spks"
#define SPARKLE_PROGRESS_TAG @"-spkp"
// macOS 10.8 couldn't handle service names that are >= 64 characters,
// but 10.9 raised this to >= 128 characters
#define MAX_SERVICE_NAME_LENGTH 127u
BOOL SPUInstallerMessageTypeIsLegal(SPUInstallerMessageType oldMessageType, SPUInstallerMessageType newMessageType)
{
BOOL legal;
switch (newMessageType) {
case SPUInstallerNotStarted:
legal = (oldMessageType == SPUInstallerNotStarted);
break;
case SPUExtractionStarted:
legal = (oldMessageType == SPUInstallerNotStarted);
break;
case SPUExtractedArchiveWithProgress:
case SPUArchiveExtractionFailed:
legal = (oldMessageType == SPUExtractionStarted || oldMessageType == SPUExtractedArchiveWithProgress);
break;
case SPUValidationStarted:
legal = (oldMessageType == SPUExtractionStarted || oldMessageType == SPUExtractedArchiveWithProgress);
break;
case SPUInstallationStartedStage1:
legal = (oldMessageType == SPUValidationStarted);
break;
case SPUInstallationFinishedStage1:
legal = (oldMessageType == SPUInstallationStartedStage1);
break;
case SPUInstallationFinishedStage2:
legal = (oldMessageType == SPUInstallationFinishedStage1);
break;
case SPUInstallationFinishedStage3:
legal = (oldMessageType == SPUInstallationFinishedStage2);
break;
case SPUInstallerError:
case SPUUpdaterAlivePing:
// Having this state being dependent on other installation states would make the complicate our logic
// So just always allow these type of messages
legal = YES;
break;
}
return legal;
}
static NSString *SPUServiceNameWithTag(NSString *tagName, NSString *bundleIdentifier)
{
NSString *serviceName = [bundleIdentifier stringByAppendingString:tagName];
NSUInteger length = MIN(serviceName.length, MAX_SERVICE_NAME_LENGTH);
// If the service name is too long, cut off the beginning rather than cutting off the end
// This should lead to a more unique name
return [serviceName substringFromIndex:serviceName.length - length];
}
NSString *SPUInstallerServiceNameForBundleIdentifier(NSString *bundleIdentifier)
{
return SPUServiceNameWithTag(SPARKLE_INSTALLER_TAG, bundleIdentifier);
}
NSString *SPUStatusInfoServiceNameForBundleIdentifier(NSString *bundleIdentifier)
{
return SPUServiceNameWithTag(SPARKLE_STATUS_TAG, bundleIdentifier);
}
NSString *SPUProgressAgentServiceNameForBundleIdentifier(NSString *bundleIdentifier)
{
return SPUServiceNameWithTag(SPARKLE_PROGRESS_TAG, bundleIdentifier);
}
-107
View File
@@ -1,107 +0,0 @@
//
// SPUSparkleDeltaArchive.h
// Sparkle
//
// Created by Mayur Pawashe on 12/30/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SPUDeltaArchiveProtocol.h"
#import "SPUDeltaCompressionMode.h"
NS_ASSUME_NONNULL_BEGIN
#define SPARKLE_DELTA_ARCHIVE_ERROR_DOMAIN @"Sparkle Delta Archive"
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_MAGIC 1
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_COMPRESSION_VALUE 2
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CHUNK_SIZE 3
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_BAD_CLONE_LOOKUP 4
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_TOO_MANY_FILES 5
#define SPARKLE_DELTA_ARCHIVE_ERROR_CODE_LINK_TOO_LONG 6
/*
Modern container format for binary delta archives.
Delta archive format has four sections which are the header, the relative file path table, the commands, and the data blobs.
The relative file path table records all the file paths the archive needs to know about.
The commands are the operations to be recorded (eg: extract, clone, binary diff, delete).
The commands may additionally have more metadata such as file permission modes, relative path indexes in the case of clones, or file sizes for the data blobs.
The data blobs contain all file data from extract and binary diff outputs.
The implementation design of this archive is such that we do not seek backwards or skip ahead to fetch data.
We go through the archive when writing or reading from it in a single pass.
-- UNCOMPRESSED --
[ HEADER (part 1) ]
magic (length: 4)
compression (length: 1)
metadata (See format below. length: 1)
-- METADATA --
compressionLevel (bits [0, 4])
(bits [5, 6] reserved)
fileSystemCompression (bit 7)
-- COMPRESSED --
[ HEADER (part 2)]
majorVersion (length: 2)
minorVersion (length: 2)
beforeTreeHash (length: 40)
afterTreeHash (length: 40)
[ RELATIVE_FILE_PATH_TABLE ]
sizeOfRelativeFilePathTable (length: 8 bytes)
List of null terminated path strings joined together (N paths)
[ COMMANDS ]
[ Command ]
Set of command types for entry (length: 1 byte)
Additional metadata for command (see below section)
(M commands where M <= N paths)
(Indexes for commands refer to indexes to relative file path table, excluding extraneous trailing entries in relative path table used for clones)
(Last command must be a ZERO COMMAND (a null terminating command))
[COMMAND METADATA]
[COMMAND: DELETE]
N/A: no additional data
[COMMAND: MODIFY_PERMISSIONS]
fileMode (length: 2)
[COMMAND: CLONE_FILE]
sourceRelativePathIndex (length: 4)
[COMMAND: EXTRACT_FILE]
dataLength (length: 8 for regular files, 2 for symbolic links, 0 for directories)
[COMMAND: BINARY_DIFF_FILE]
dataLength (length: 8)
Note: These command types may be OR'd or combined. In those cases, different commands
that have the same attribute (eg dataLength) are not repeated. This list of metadata is also
in order in what will be encoded/decoded first.
EXTRACT_FILE and BINARY_DIFF_FILE cannot be combined.
CLONE_FILE and EXTRACT_FILE cannot be combined.
MODIFY_PERMISSIONS can be combined with either CLONE_FILE, EXTRACT_FILE, BINARY_DIFF_FILE, or just by itself.
CLONE_FILE can be combined with BINARY_DIFF_FILE or just by itself.
DELETE can be combined with EXTRACT_FILE, or just by itself. It is only combined with EXTRACT_FILE when the file type (regular, directory, or symlink) changes.
[ DATA_BLOBS ]
All raw binary data joined together
(P number of blobs where P <= M commands)
(Indexes for data blobs correspond to indexes for a filtered list of applicable commands (EXTRACT_FILE, BINARY_DIFF_FILE) that have data content)
*/
SPU_OBJC_DIRECT_MEMBERS @interface SPUSparkleDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile;
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile;
@end
NS_ASSUME_NONNULL_END
File diff suppressed because it is too large. Load diff
-28
View File
@@ -1,28 +0,0 @@
//
// SPUXarDeltaArchive.h
// Autoupdate
//
// Created by Mayur Pawashe on 12/28/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
#import <Foundation/Foundation.h>
#import "SPUDeltaArchiveProtocol.h"
#import "SPUDeltaCompressionMode.h"
NS_ASSUME_NONNULL_BEGIN
// Legacy container format for binary delta archives
SPU_OBJC_DIRECT_MEMBERS @interface SPUXarDeltaArchive : NSObject <SPUDeltaArchiveProtocol>
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile SPU_OBJC_DIRECT;
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile SPU_OBJC_DIRECT;
@end
NS_ASSUME_NONNULL_END
#endif
-413
View File
@@ -1,413 +0,0 @@
//
// SPUXarDeltaArchive.m
// Autoupdate
//
// Created by Mayur Pawashe on 12/28/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#if SPARKLE_BUILD_LEGACY_DELTA_SUPPORT
#import "SPUXarDeltaArchive.h"
#include <xar/xar.h>
#include "SUBinaryDeltaCommon.h"
#import <Availability.h>
#import <CommonCrypto/CommonDigest.h>
#include "AppKitPrevention.h"
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
#define HAS_XAR_GET_SAFE_PATH 1
#else
#define HAS_XAR_GET_SAFE_PATH 0
#endif
#if HAS_XAR_GET_SAFE_PATH
// This is preferred over xar_get_path (which is deprecated) when it's available
// Don't use OS availability for this API
extern char *xar_get_safe_path(xar_file_t f) __attribute__((weak_import));
#endif
// Xar attribute keys
#define BINARY_DELTA_ATTRIBUTES_KEY "binary-delta-attributes"
#define MAJOR_DIFF_VERSION_KEY "major-version"
#define MINOR_DIFF_VERSION_KEY "minor-version"
#define BEFORE_TREE_SHA1_KEY "before-tree-sha1"
#define AFTER_TREE_SHA1_KEY "after-tree-sha1"
#define DELETE_KEY "delete"
#define EXTRACT_KEY "extract"
#define BINARY_DELTA_KEY "binary-delta"
#define MODIFY_PERMISSIONS_KEY "mod-permissions"
// Errors
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN @"Sparkle XAR Archive"
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE 1
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE 2
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE 3
#define SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE 4
@implementation SPUXarDeltaArchive
{
NSMutableDictionary<NSString *, NSValue *> *_fileTable;
NSString *_patchFile;
xar_t _x;
int32_t _xarMode;
}
@synthesize error = _error;
- (instancetype)initWithPatchFileForWriting:(NSString *)patchFile
{
self = [super init];
if (self != nil) {
_patchFile = [patchFile copy];
_xarMode = WRITE;
_fileTable = [NSMutableDictionary dictionary];
}
return self;
}
- (instancetype)initWithPatchFileForReading:(NSString *)patchFile
{
self = [super init];
if (self != nil) {
_patchFile = [patchFile copy];
_xarMode = READ;
}
return self;
}
- (void)dealloc
{
[self close];
}
- (void)close
{
if (_x != NULL) {
xar_close(_x);
_x = NULL;
}
}
// This indicates if safe extraction is available at compile time (SDK), but not if it's available at runtime.
+ (BOOL)maySupportSafeExtraction
{
return HAS_XAR_GET_SAFE_PATH;
}
- (nullable SPUDeltaArchiveHeader *)readHeader
{
NSString *patchFile = _patchFile;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// Sparkle's XAR delta archives have been superceded by Sparkle's own format
xar_t x = xar_open(patchFile.fileSystemRepresentation, READ);
#pragma clang diagnostic pop
if (x == NULL) {
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for reading: %@", patchFile] }];
return nil;
}
_x = x;
uint16_t majorDiffVersion = SUBinaryDeltaMajorVersionFirst;
uint16_t minorDiffVersion = 0;
NSString *expectedBeforeHash = nil;
NSString *expectedAfterHash = nil;
xar_subdoc_t subdoc;
for (subdoc = xar_subdoc_first(_x); subdoc; subdoc = xar_subdoc_next(subdoc)) {
if (strcmp(xar_subdoc_name(subdoc), BINARY_DELTA_ATTRIBUTES_KEY) == 0) {
{
// available in version 2.0 or later
const char *value = NULL;
xar_subdoc_prop_get(subdoc, MAJOR_DIFF_VERSION_KEY, &value);
if (value != NULL) {
majorDiffVersion = (uint16_t)[@(value) intValue];
}
}
{
// available in version 2.0 or later
const char *value = NULL;
xar_subdoc_prop_get(subdoc, MINOR_DIFF_VERSION_KEY, &value);
if (value != NULL) {
minorDiffVersion = (uint16_t)[@(value) intValue];
}
}
// available in version 2.0 or later
{
const char *value = NULL;
xar_subdoc_prop_get(subdoc, BEFORE_TREE_SHA1_KEY, &value);
if (value != NULL) {
expectedBeforeHash = @(value);
}
}
// available in version 2.0 or later
{
const char *value = NULL;
xar_subdoc_prop_get(subdoc, AFTER_TREE_SHA1_KEY, &value);
if (value != NULL) {
expectedAfterHash = @(value);
}
}
}
}
unsigned char rawExpectedBeforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
getRawHashFromDisplayHash(rawExpectedBeforeHash, expectedBeforeHash);
unsigned char rawExpectedAfterHash[CC_SHA1_DIGEST_LENGTH] = {0};
getRawHashFromDisplayHash(rawExpectedAfterHash, expectedAfterHash);
// I wasn't able to figure out how to retrieve the compression options from xar,
// so we will use default flags to indicate the info isn't available
return [[SPUDeltaArchiveHeader alloc] initWithCompression:SPUDeltaCompressionModeDefault compressionLevel:0 fileSystemCompression:false majorVersion:majorDiffVersion minorVersion:minorDiffVersion beforeTreeHash:rawExpectedBeforeHash afterTreeHash:rawExpectedAfterHash];
}
- (void)writeHeader:(SPUDeltaArchiveHeader *)header
{
NSString *patchFile = _patchFile;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// Sparkle's XAR delta archives have been superceded by Sparkle's own format
xar_t x = xar_open(patchFile.fileSystemRepresentation, WRITE);
#pragma clang diagnostic pop
if (x == NULL) {
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to xar_open() file for writing: %@", patchFile] }];
return;
}
_x = x;
SPUDeltaCompressionMode compression = (header.compression == SPUDeltaCompressionModeDefault ? SPUDeltaCompressionModeBzip2 : header.compression);
uint8_t compressionLevel;
// Only 1 - 9 are valid, 0 is special case to use default level 9
if (header.compressionLevel <= 0 || header.compressionLevel > 9) {
compressionLevel = 9;
} else {
compressionLevel = header.compressionLevel;
}
switch (compression) {
case SPUDeltaCompressionModeNone:
xar_opt_set(x, XAR_OPT_COMPRESSION, XAR_OPT_VAL_NONE);
break;
case SPUDeltaCompressionModeBzip2: {
xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2");
char buffer[256] = {0};
snprintf(buffer, sizeof(buffer) - 1, "%d", compressionLevel);
xar_opt_set(x, XAR_OPT_COMPRESSIONARG, buffer);
break;
}
case SPUDeltaCompressionModeLZMA:
case SPUDeltaCompressionModeLZFSE:
case SPUDeltaCompressionModeLZ4:
case SPUDeltaCompressionModeZLIB: {
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Version 2 patches only support bzip2 compression."] }];
return;
}
}
xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);
xar_subdoc_prop_set(attributes, MAJOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", header.majorVersion] UTF8String]);
xar_subdoc_prop_set(attributes, MINOR_DIFF_VERSION_KEY, [[NSString stringWithFormat:@"%u", header.minorVersion] UTF8String]);
xar_subdoc_prop_set(attributes, BEFORE_TREE_SHA1_KEY, [displayHashFromRawHash(header.beforeTreeHash) UTF8String]);
xar_subdoc_prop_set(attributes, AFTER_TREE_SHA1_KEY, [displayHashFromRawHash(header.afterTreeHash) UTF8String]);
}
static xar_file_t _xarAddFile(NSMutableDictionary<NSString *, NSValue *> *fileTable, xar_t x, NSString *relativePath, NSString *filePath)
{
NSArray<NSString *> *rootRelativePathComponents = relativePath.pathComponents;
// Relative path must at least have starting "/" component and one more path component
if (rootRelativePathComponents.count < 2) {
return NULL;
}
NSArray<NSString *> *relativePathComponents = [rootRelativePathComponents subarrayWithRange:NSMakeRange(1, rootRelativePathComponents.count - 1)];
NSUInteger relativePathComponentsCount = relativePathComponents.count;
// Build parent files as needed until we get to our final file we want to add
// So if we get "Contents/Resources/foo.txt", we will first add "Contents" parent,
// then "Resources" parent, then "foo.txt" as the final entry we want to add
// We store every file we add into a fileTable for easy referencing
// Note if a diff has Contents/Resources/foo/ and Contents/Resources/foo/bar.txt,
// due to sorting order we will add the foo directory first and won't end up with
// mis-ordering bugs
xar_file_t lastParent = NULL;
for (NSUInteger componentIndex = 0; componentIndex < relativePathComponentsCount; componentIndex++) {
NSArray<NSString *> *subpathComponents = [relativePathComponents subarrayWithRange:NSMakeRange(0, componentIndex + 1)];
NSString *subpathKey = [subpathComponents componentsJoinedByString:@"/"];
xar_file_t cachedFile = [fileTable[subpathKey] pointerValue];
if (cachedFile != NULL) {
lastParent = cachedFile;
} else {
xar_file_t newParent;
BOOL atLastIndex = (componentIndex == relativePathComponentsCount - 1);
NSString *lastPathComponent = subpathComponents.lastObject;
if (atLastIndex && filePath != nil) {
newParent = xar_add_frompath(x, lastParent, lastPathComponent.fileSystemRepresentation, filePath.fileSystemRepresentation);
} else {
newParent = xar_add_frombuffer(x, lastParent, lastPathComponent.fileSystemRepresentation, "", 1);
}
lastParent = newParent;
fileTable[subpathKey] = [NSValue valueWithPointer:newParent];
}
}
return lastParent;
}
- (void)addItem:(SPUDeltaArchiveItem *)item
{
if (_error != nil) {
return;
}
NSString *relativeFilePath = item.relativeFilePath;
NSString *filePath = item.itemFilePath;
SPUDeltaItemCommands commands = item.commands;
uint16_t mode = item.mode;
xar_file_t newFile = _xarAddFile(_fileTable, _x, relativeFilePath, filePath);
if (newFile == NULL) {
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to add xar file entry: %@", relativeFilePath] }];
return;
}
if ((commands & SPUDeltaItemCommandDelete) != 0) {
xar_prop_set(newFile, DELETE_KEY, "true");
}
if ((commands & SPUDeltaItemCommandExtract) != 0) {
xar_prop_set(newFile, EXTRACT_KEY, "true");
}
if ((commands & SPUDeltaItemCommandBinaryDiff) != 0) {
xar_prop_set(newFile, BINARY_DELTA_KEY, "true");
}
if ((commands & SPUDeltaItemCommandModifyPermissions) != 0) {
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [NSString stringWithFormat:@"%u", mode].UTF8String);
}
}
- (void)finishEncodingItems
{
// Items are already encoded when they are extracted prior
}
- (void)enumerateItems:(void (^)(SPUDeltaArchiveItem *, BOOL *))itemHandler
{
if (_error != nil) {
return;
}
BOOL exitedEarly = NO;
xar_iter_t iter = xar_iter_new();
for (xar_file_t file = xar_file_first(_x, iter); file; file = xar_file_next(iter)) {
char *pathCString;
#if HAS_XAR_GET_SAFE_PATH
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
if (xar_get_safe_path != NULL) {
pathCString = xar_get_safe_path(file);
}
#pragma clang diagnostic pop
else
#endif
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
pathCString = xar_get_path(file);
#pragma clang diagnostic pop
}
if (pathCString == NULL) {
continue;
}
NSString *relativePath = [[NSString alloc] initWithBytesNoCopy:pathCString length:strlen(pathCString) encoding:NSUTF8StringEncoding freeWhenDone:YES];
if (relativePath == nil) {
free(pathCString);
continue;
}
SPUDeltaItemCommands commands = 0;
{
const char *value = NULL;
if (xar_prop_get(file, DELETE_KEY, &value) == 0) {
commands |= SPUDeltaItemCommandDelete;
}
}
{
const char *value = NULL;
if (xar_prop_get(file, BINARY_DELTA_KEY, &value) == 0) {
commands |= SPUDeltaItemCommandBinaryDiff;
}
}
{
const char *value = NULL;
if (xar_prop_get(file, EXTRACT_KEY, &value) == 0) {
commands |= SPUDeltaItemCommandExtract;
}
}
uint16_t mode = 0;
{
const char *value = NULL;
if (xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value) == 0) {
commands |= SPUDeltaItemCommandModifyPermissions;
mode = (uint16_t)[@(value) intValue];
}
}
SPUDeltaArchiveItem *item = [[SPUDeltaArchiveItem alloc] initWithRelativeFilePath:relativePath commands:commands mode:mode];
item.xarContext = file;
itemHandler(item, &exitedEarly);
if (exitedEarly) {
break;
}
}
xar_iter_free(iter);
}
- (BOOL)extractItem:(SPUDeltaArchiveItem *)item
{
if (_error != nil) {
return NO;
}
assert(item.itemFilePath != nil);
assert(item.xarContext != NULL);
xar_file_t file = item.xarContext;
if (xar_extract_tofile(_x, file, item.itemFilePath.fileSystemRepresentation) != 0) {
_error = [NSError errorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAIN code:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILURE userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to extract xar file entry to %@", item.itemFilePath] }];
return NO;
}
return YES;
}
@end
#endif
-481
View File
@@ -1,481 +0,0 @@
//
// SUBinaryDeltaApply.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#import "SUBinaryDeltaApply.h"
#import "SUBinaryDeltaCommon.h"
#import "SPUDeltaArchiveProtocol.h"
#import "SPUDeltaArchive.h"
#import <CommonCrypto/CommonDigest.h>
#import <Foundation/Foundation.h>
#include "bspatch.h"
#include <stdio.h>
#include <stdlib.h>
#import <sys/stat.h>
#include "AppKitPrevention.h"
static BOOL applyBinaryDeltaToFile(NSString *patchFile, NSString *sourceFilePath, NSString *destinationFilePath)
{
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
BOOL success = (bspatch(4, argv) == 0);
unlink([patchFile fileSystemRepresentation]);
return success;
}
BOOL applyBinaryDelta(NSString *source, NSString *finalDestination, NSString *patchFile, BOOL verbose, void (^progressCallback)(double progress), NSError *__autoreleasing *error)
{
SPUDeltaArchiveHeader *header = nil;
id<SPUDeltaArchiveProtocol> archive = SPUDeltaArchiveReadPatchAndHeader(patchFile, &header);
if (archive.error != nil) {
if (error != NULL) {
*error = archive.error;
}
return NO;
}
progressCallback(0/7.0);
SUBinaryDeltaMajorVersion majorDiffVersion = header.majorVersion;
uint16_t minorDiffVersion = header.minorVersion;
unsigned char *expectedBeforeHash = header.beforeTreeHash;
unsigned char *expectedAfterHash = header.afterTreeHash;
if (majorDiffVersion < SUBinaryDeltaMajorVersionFirst) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.", majorDiffVersion] }];
}
return NO;
}
if (majorDiffVersion < SUBinaryDeltaMajorVersionFirstSupported) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Applying version %u patches is no longer supported.", majorDiffVersion] }];
}
return NO;
}
if (majorDiffVersion > SUBinaryDeltaMajorVersionLatest) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).", SUBinaryDeltaMajorVersionLatest, majorDiffVersion] }];
}
return NO;
}
// Reject patches that did not generate valid hierarchical xar container paths
// These will not succeed to patch using recent versions of BinaryDelta
if ([[archive class] maySupportSafeExtraction] && majorDiffVersion == SUBinaryDeltaMajorVersion2 && minorDiffVersion < 3) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"This patch version (%u.%u) is too old and potentially unsafe to apply. Please re-generate the patch using the latest version of BinaryDelta or generate_appcast. New version %u.%u patches will still be compatible with older versions of Sparkle.", majorDiffVersion, minorDiffVersion, majorDiffVersion, latestMinorVersionForMajorVersion(majorDiffVersion)] }];
}
return NO;
}
if (expectedBeforeHash == nil || expectedAfterHash == nil) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }];
}
return NO;
}
if (verbose) {
fprintf(stderr, "Applying version %u.%u patch...\n", majorDiffVersion, minorDiffVersion);
fprintf(stderr, "Verifying source...");
}
progressCallback(1/7.0);
unsigned char beforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
if (!getRawHashOfTreeWithVersion(beforeHash, source, majorDiffVersion)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", source] }];
}
return NO;
}
if (memcmp(beforeHash, expectedBeforeHash, CC_SHA1_DIGEST_LENGTH) != 0) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", displayHashFromRawHash(expectedBeforeHash), displayHashFromRawHash(beforeHash)] }];
}
return NO;
}
if (verbose) {
fprintf(stderr, "\nCopying files...");
}
progressCallback(2/7.0);
// Make a temporary destination path if necessary
// If we want to apply file system compression after we're done applying, we'll need to use a different
// temporary path
NSString *destination;
if (header.fileSystemCompression) {
destination = [finalDestination.stringByDeletingLastPathComponent stringByAppendingPathComponent:[NSString stringWithFormat:@".tmp.%@", finalDestination.lastPathComponent]];
} else {
destination = finalDestination;
}
if (!removeTree(destination)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }];
}
return NO;
}
progressCallback(3/7.0);
if (!copyTree(source, destination)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }];
}
return NO;
}
progressCallback(4/7.0);
if (verbose) {
fprintf(stderr, "\nPatching...");
}
NSFileManager *fileManager = [[NSFileManager alloc] init];
// Ensure error is cleared out in advance
if (error != NULL) {
*error = nil;
}
[archive enumerateItems:^(SPUDeltaArchiveItem *item, BOOL *stop) {
NSString *relativePath = item.relativeFilePath;
if ([relativePath.pathComponents containsObject:@".."]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path '%@' contains '..' path component", relativePath] }];
}
*stop = YES;
return;
}
NSString *sourceFilePath = [source stringByAppendingPathComponent:relativePath];
NSString *destinationFilePath = [destination stringByAppendingPathComponent:relativePath];
{
NSString *destinationParentDirectory = destinationFilePath.stringByDeletingLastPathComponent;
NSDictionary<NSFileAttributeKey, id> *destinationParentDirectoryAttributes = [fileManager attributesOfItemAtPath:destinationParentDirectory error:NULL];
// It is OK for the directory parent to not exist if it has already been removed
if (destinationParentDirectoryAttributes != nil) {
// But if it does exist, make sure the entry in the parent directory we're looking at is good
// If it's inside a symlink, this is not good in any circumstance
NSString *fileType = destinationParentDirectoryAttributes[NSFileType];
if ([fileType isEqualToString:NSFileTypeSymbolicLink]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch because '%@' cannot be a symbolic link.", destinationParentDirectory] }];
}
*stop = YES;
return;
}
}
}
// Don't use -[NSFileManager fileExistsAtPath:] because it will follow symbolic links
BOOL fileExisted = verbose && [fileManager attributesOfItemAtPath:destinationFilePath error:nil];
BOOL removedFile = NO;
// Files that have no property set that we check for will get ignored
// This is important because they aren't part of the delta, just part of the directory structure
SPUDeltaItemCommands commands = item.commands;
if ((commands & SPUDeltaItemCommandDelete) != 0) {
if (!removeTree(destinationFilePath)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"delete: failed to remove %@", destination] }];
}
*stop = YES;
return;
}
removedFile = YES;
}
if ((commands & SPUDeltaItemCommandClone) != 0 && (commands & SPUDeltaItemCommandBinaryDiff) == 0) {
NSString *clonedRelativePath = item.clonedRelativePath;
if ([clonedRelativePath.pathComponents containsObject:@".."]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone '%@' contains '..' path component", clonedRelativePath] }];
}
*stop = YES;
return;
}
NSString *clonedOriginalPath = [source stringByAppendingPathComponent:clonedRelativePath];
// Ensure there isn't an item already at our destination
[fileManager removeItemAtPath:destinationFilePath error:NULL];
NSError *copyError = nil;
if (![fileManager copyItemAtPath:clonedOriginalPath toPath:destinationFilePath error:&copyError]) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = copyError;
}
*stop = YES;
return;
}
if (verbose) {
fprintf(stderr, "\n✂️ %s %s -> %s", VERBOSE_CLONED, [clonedRelativePath fileSystemRepresentation], [relativePath fileSystemRepresentation]);
}
} else if ((commands & SPUDeltaItemCommandBinaryDiff) != 0) {
NSString *tempDiffFile = temporaryFilename(@"apply-binary-delta");
item.itemFilePath = tempDiffFile;
if (![archive extractItem:item]) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract diffed file to %@", tempDiffFile], NSUnderlyingErrorKey: (NSError * _Nonnull)archive.error }];
}
*stop = YES;
return;
}
NSString *sourceDiffFilePath;
NSString *clonedRelativePath;
if ((commands & SPUDeltaItemCommandClone) != 0) {
clonedRelativePath = item.clonedRelativePath;
if ([clonedRelativePath.pathComponents containsObject:@".."]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Relative path for clone '%@' contains '..' path component", clonedRelativePath] }];
}
*stop = YES;
return;
}
sourceDiffFilePath = [source stringByAppendingPathComponent:clonedRelativePath];
} else {
sourceDiffFilePath = sourceFilePath;
clonedRelativePath = nil;
}
// Decide if we need to preserve original file permissions from the original file
// applyBinaryDeltaToFile() normally preserves file permissions on the file it's replacing.
// However this is not possible if the destination file we're patching is not writable.
// We also need to preserve permissions for clones except when we'll be changing permissions later anyway.
BOOL needsToCopyFilePermissions;
if (![fileManager isWritableFileAtPath:destinationFilePath]) {
// Remove the file non-writable we're patching that may cause issues
[fileManager removeItemAtPath:destinationFilePath error:NULL];
// We will need to preserve permissons if there is no need to make permission changes later on
needsToCopyFilePermissions = (commands & SPUDeltaItemCommandModifyPermissions) == 0;
} else {
needsToCopyFilePermissions = ((commands & SPUDeltaItemCommandClone) != 0) && ((commands & SPUDeltaItemCommandModifyPermissions) == 0);
}
if (!applyBinaryDeltaToFile(tempDiffFile, sourceDiffFilePath, destinationFilePath)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to patch %@ to destination %@", sourceFilePath, destinationFilePath] }];
}
*stop = YES;
return;
}
if (needsToCopyFilePermissions) {
struct stat sourceFileInfo = {0};
if (lstat(sourceDiffFilePath.fileSystemRepresentation, &sourceFileInfo) != 0) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to retrieve stat info from %@", sourceFilePath] }];
}
*stop = YES;
return;
}
if (chmod(destinationFilePath.fileSystemRepresentation, sourceFileInfo.st_mode) != 0) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%u) on file %@", sourceFileInfo.st_mode, destinationFilePath] }];
}
*stop = YES;
return;
}
}
if (verbose) {
if ((commands & SPUDeltaItemCommandClone) != 0) {
fprintf(stderr, "\n🔨 %s %s -> %s", VERBOSE_PATCHED, [clonedRelativePath fileSystemRepresentation], [relativePath fileSystemRepresentation]);
} else {
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [relativePath fileSystemRepresentation]);
}
}
} else if ((commands & SPUDeltaItemCommandExtract) != 0) { // extract and permission modifications don't coexist
item.itemFilePath = destinationFilePath;
if (![archive extractItem:item]) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath], NSUnderlyingErrorKey: (NSError * _Nonnull)archive.error }];
}
*stop = YES;
return;
}
if (verbose) {
if (fileExisted) {
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [relativePath fileSystemRepresentation]);
} else {
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [relativePath fileSystemRepresentation]);
}
}
} else if (verbose && removedFile) {
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [relativePath fileSystemRepresentation]);
}
if ((commands & SPUDeltaItemCommandModifyPermissions) != 0) {
mode_t mode = (mode_t)item.mode;
if (!modifyPermissions(destinationFilePath, mode)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%u) on file %@", mode, destinationFilePath] }];
}
*stop = YES;
return;
}
if (verbose) {
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [relativePath fileSystemRepresentation], mode & PERMISSION_FLAGS);
}
}
}];
[archive close];
// Set error from enumerating items if we have encountered an error and haven't set it yet
NSError *archiveError = archive.error;
if (archiveError != nil) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL && *error == nil) {
*error = archiveError;
}
removeTree(destination);
return NO;
}
progressCallback(5/7.0);
// Re-apply file system compression is requested
if (header.fileSystemCompression) {
if (verbose) {
fprintf(stderr, "\nApplying file system compression...");
}
NSTask *dittoTask = [[NSTask alloc] init];
dittoTask.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto" isDirectory:NO];
dittoTask.arguments = @[@"--hfsCompression", destination, finalDestination];
// If we fail to apply file system compression, we will try falling back to not doing this
BOOL failedToApplyFileSystemCompression = NO;
NSError *launchError = nil;
if (![dittoTask launchAndReturnError:&launchError]) {
failedToApplyFileSystemCompression = YES;
fprintf(stderr, "\nWarning: failed to launch ditto task for file compression: %s", launchError.localizedDescription.UTF8String);
}
if (!failedToApplyFileSystemCompression) {
[dittoTask waitUntilExit];
if (dittoTask.terminationStatus != 0) {
failedToApplyFileSystemCompression = YES;
fprintf(stderr, "\nWarning: ditto task for file compression returned exit status %d", dittoTask.terminationStatus);
}
}
if (failedToApplyFileSystemCompression) {
// Try to replace bundle normally
if (![fileManager replaceItemAtURL:[NSURL fileURLWithPath:finalDestination] withItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] backupItemName:nil options:0 resultingItemURL:NULL error:error]) {
removeTree(destination);
return NO;
}
} else {
// Remove original copy
[fileManager removeItemAtURL:[NSURL fileURLWithPath:destination isDirectory:YES] error:NULL];
}
}
progressCallback(6/7.0);
if (verbose) {
fprintf(stderr, "\nVerifying destination...");
}
unsigned char afterHash[CC_SHA1_DIGEST_LENGTH] = {0};
if (!getRawHashOfTreeWithVersion(afterHash, finalDestination, majorDiffVersion)) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", finalDestination] }];
}
removeTree(finalDestination);
return NO;
}
if (memcmp(afterHash, expectedAfterHash, CC_SHA1_DIGEST_LENGTH) != 0) {
if (verbose) {
fprintf(stderr, "\n");
}
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", displayHashFromRawHash(expectedAfterHash), displayHashFromRawHash(afterHash)] }];
}
removeTree(finalDestination);
return NO;
}
progressCallback(7/7.0);
if (verbose) {
fprintf(stderr, "\nDone!\n");
}
return YES;
}
-78
View File
@@ -1,78 +0,0 @@
//
// SUBinaryDeltaCommon.h
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#ifndef SUBINARYDELTACOMMON_H
#define SUBINARYDELTACOMMON_H
#import <Foundation/Foundation.h>
#import "SPUDeltaCompressionMode.h"
#include <fts.h>
#define PERMISSION_FLAGS (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)
#define VALID_SYMBOLIC_LINK_PERMISSIONS 0755
// Enforcing Sparkle's executable permissions to be valid allows us to perform a preflight test before
// downloading delta items
#define VALID_SPARKLE_EXECUTABLE_PERMISSIONS 0755
#define APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY "com.apple.cs.CodeDirectory"
#define APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY "com.apple.cs.CodeRequirements"
#define APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY "com.apple.cs.CodeSignature"
#define 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 VERBOSE_CLONED "Cloned" // file is cloned in content from a differently named file
#define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
// Relative path of custom icon data that may be set on a bundle via a resource fork
#define CUSTOM_ICON_PATH @"/Icon\r"
// Changes that break backwards compatibility will have different major versions
// Changes that affect creating but not applying patches will have different minor versions
typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
{
// Note: support for creating or applying version 1 deltas have been removed
SUBinaryDeltaMajorVersion1 = 1,
SUBinaryDeltaMajorVersion2 = 2,
SUBinaryDeltaMajorVersion3 = 3
};
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault;
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest;
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst;
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported;
// Additional compression methods for version 3 patches that we have for debugging are zlib, bzip2, none
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma' (best compression, slowest), 'lzfse' (good compression, fast), 'lz4' (worse compression, fastest), and 'default'. Note that version 2 delta files only support 'bzip2', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 delta files is currently lzma."
//#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
SPUDeltaCompressionMode deltaCompressionModeFromDescription(NSString *description, BOOL *requestValid);
NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode);
extern int compareFiles(const FTSENT **a, const FTSENT **b);
BOOL getRawHashOfTreeWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion);
BOOL getRawHashOfTreeAndFileTablesWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion, NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *hashToFileKeyDictionary, NSMutableDictionary<NSString *, NSData *> *fileKeyToHashDictionary);
NSString *displayHashFromRawHash(const unsigned char *hash);
void getRawHashFromDisplayHash(unsigned char *hash, NSString *hexHash);
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
extern NSString *hashOfTree(NSString *path);
extern BOOL removeTree(NSString *path);
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*);
uint16_t latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion);
#endif
-384
View File
@@ -1,384 +0,0 @@
//
// SUBinaryDeltaCommon.m
// Sparkle
//
// Created by Mark Rowe on 2009-06-01.
// Copyright 2009 Mark Rowe. All rights reserved.
//
#include "SUBinaryDeltaCommon.h"
#import "SUFileManager.h"
#include <CommonCrypto/CommonDigest.h>
#include <Foundation/Foundation.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <xlocale.h>
#include "AppKitPrevention.h"
// Note: the framework bundle version must be bumped, and generate_appcast must be updated to compare it,
// when we add/change new major versions and defaults. Unit tests need to be updated to use new versions too.
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault = SUBinaryDeltaMajorVersion3;
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest = SUBinaryDeltaMajorVersion3;
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst = SUBinaryDeltaMajorVersion1;
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported = SUBinaryDeltaMajorVersion2;
SPUDeltaCompressionMode deltaCompressionModeFromDescription(NSString *requestedDescription, BOOL *requestValid)
{
// Set to NO later if request was not valid
if (requestValid != NULL) {
*requestValid = YES;
}
SPUDeltaCompressionMode compression;
NSString *description = requestedDescription.lowercaseString;
if ([description isEqualToString:@"default"]) {
compression = SPUDeltaCompressionModeDefault;
} else if ([description isEqualToString:@"none"]) {
compression = SPUDeltaCompressionModeNone;
} else if ([description isEqualToString:@"bzip2"]) {
compression = SPUDeltaCompressionModeBzip2;
} else if ([description isEqualToString:@"lzma"]) {
compression = SPUDeltaCompressionModeLZMA;
} else if ([description isEqualToString:@"lzfse"]) {
compression = SPUDeltaCompressionModeLZFSE;
} else if ([description isEqualToString:@"lz4"]) {
compression = SPUDeltaCompressionModeLZ4;
} else if ([description isEqualToString:@"zlib"]) {
compression = SPUDeltaCompressionModeZLIB;
} else {
compression = SPUDeltaCompressionModeDefault;
if (requestValid != NULL) {
*requestValid = NO;
}
}
return compression;
}
NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode)
{
switch (mode) {
case SPUDeltaCompressionModeBzip2:
return @"bzip2";
case SPUDeltaCompressionModeLZMA:
return @"LZMA";
case SPUDeltaCompressionModeNone:
return @"no";
case SPUDeltaCompressionModeLZ4:
return @"LZ4";
case SPUDeltaCompressionModeLZFSE:
return @"LZFSE";
case SPUDeltaCompressionModeZLIB:
return @"ZLIB";
default:
break;
}
if (mode == SPUDeltaCompressionModeDefault) {
return @"default";
}
return @"unknown";
}
int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll_l((*a)->fts_name, (*b)->fts_name, _c_locale);
}
NSString *pathRelativeToDirectory(NSString *directory, NSString *path)
{
NSUInteger directoryLength = [directory length];
if ([path hasPrefix:directory])
return [path substringFromIndex:directoryLength];
return path;
}
NSString *stringWithFileSystemRepresentation(const char *input)
{
return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:input length:strlen(input)];
}
uint16_t latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersion majorVersion)
{
switch (majorVersion) {
case SUBinaryDeltaMajorVersion1:
return 2;
case SUBinaryDeltaMajorVersion2:
return 4;
case SUBinaryDeltaMajorVersion3:
return 1;
}
return 0;
}
NSString *temporaryFilename(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;
int fd = mkstemp(buffer);
if (fd == -1) {
perror("mkstemp");
return nil;
}
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)
{
assert(bufferLength >= 0 && bufferLength <= UINT32_MAX);
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
CC_SHA1_Update(&hashContext, buffer, (CC_LONG)bufferLength);
CC_SHA1_Final(hash, &hashContext);
}
static BOOL _hashOfFileContents(unsigned char *hash, FTSENT *ent, void *tempBuffer, size_t tempBufferSize)
{
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 NO;
}
_hashOfBuffer(hash, linkDestination, linkDestinationLength);
} else if (ent->fts_info == FTS_F) {
ssize_t fileSize = ent->fts_statp->st_size;
if (fileSize <= 0) {
_hashOfBuffer(hash, NULL, 0);
} else {
FILE *file = fopen(ent->fts_path, "rb");
if (file == NULL) {
perror("fopen");
return NO;
}
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
size_t bytesLeft = (size_t)fileSize;
while (bytesLeft > 0) {
size_t bytesToConsume = (bytesLeft >= tempBufferSize) ? tempBufferSize : bytesLeft;
if (fread(tempBuffer, bytesToConsume, 1, file) < 1) {
perror("fread");
fclose(file);
return NO;
}
CC_SHA1_Update(&hashContext, tempBuffer, (CC_LONG)bytesToConsume);
bytesLeft -= bytesToConsume;
}
CC_SHA1_Final(hash, &hashContext);
fclose(file);
}
} else if (ent->fts_info == FTS_D) {
memset(hash, 0xdd, CC_SHA1_DIGEST_LENGTH);
} else {
return NO;
}
return YES;
}
BOOL getRawHashOfTreeWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t majorVersion)
{
return getRawHashOfTreeAndFileTablesWithVersion(hashBuffer, path, majorVersion, nil, nil);
}
BOOL getRawHashOfTreeAndFileTablesWithVersion(unsigned char *hashBuffer, NSString *path, uint16_t __unused majorVersion, NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *hashToFileKeyDictionary, NSMutableDictionary<NSString *, NSData *> *fileKeyToHashDictionary)
{
char pathBuffer[PATH_MAX] = { 0 };
if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) {
return NO;
}
const size_t tempBufferSize = 16384;
void *tempBuffer = calloc(1, tempBufferSize);
if (tempBuffer == NULL) {
perror("calloc");
return NO;
}
char *const sourcePaths[] = { pathBuffer, 0 };
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
free(tempBuffer);
return NO;
}
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
// Ensure the path uses filesystem-specific Unicode normalization #1017
NSString *normalizedPath = stringWithFileSystemRepresentation(pathBuffer);
FTSENT *ent = 0;
while ((ent = fts_read(fts))) {
if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D)
continue;
NSString *relativePath = pathRelativeToDirectory(normalizedPath, stringWithFileSystemRepresentation(ent->fts_path));
// Ignore icon resource fork data
if (relativePath.length == 0 || [relativePath isEqualToString:CUSTOM_ICON_PATH]) {
continue;
}
unsigned char fileHash[CC_SHA1_DIGEST_LENGTH];
if (!_hashOfFileContents(fileHash, ent, tempBuffer, tempBufferSize)) {
fts_close(fts);
free(tempBuffer);
return NO;
}
CC_SHA1_Update(&hashContext, fileHash, sizeof(fileHash));
// For file hash tables we only track regular files
if (ent->fts_info == FTS_F) {
NSData *hashKey = [NSData dataWithBytes:fileHash length:sizeof(fileHash)];
if (hashToFileKeyDictionary != nil) {
if (hashToFileKeyDictionary[hashKey] == nil) {
hashToFileKeyDictionary[hashKey] = [NSMutableArray array];
}
[hashToFileKeyDictionary[hashKey] addObject:relativePath];
}
if (fileKeyToHashDictionary != nil) {
fileKeyToHashDictionary[relativePath] = hashKey;
}
}
const char *relativePathBytes = [relativePath fileSystemRepresentation];
CC_SHA1_Update(&hashContext, relativePathBytes, (CC_LONG)strlen(relativePathBytes));
uint16_t mode = ent->fts_statp->st_mode;
uint16_t type = ent->fts_info;
uint16_t permissions = mode & PERMISSION_FLAGS;
// permission of symlinks are 0777 on some linux file systems and can't be changed,
// differing from the 0755 macOS default.
// hardcoding a value helps avoid differences between filesystems.
uint16_t hashedPermissions = (ent->fts_info == FTS_SL) ? VALID_SYMBOLIC_LINK_PERMISSIONS : permissions;
CC_SHA1_Update(&hashContext, &type, sizeof(type));
CC_SHA1_Update(&hashContext, &hashedPermissions, sizeof(hashedPermissions));
}
free(tempBuffer);
fts_close(fts);
CC_SHA1_Final(hashBuffer, &hashContext);
return YES;
}
void getRawHashFromDisplayHash(unsigned char *hash, NSString *hexHash)
{
const char *hexString = hexHash.UTF8String;
if (hexString == NULL) {
return;
}
for (size_t blockIndex = 0; blockIndex < CC_SHA1_DIGEST_LENGTH; blockIndex++) {
const char *currentBlock = hexString + blockIndex * 2;
char convertedBlock[3] = {currentBlock[0], currentBlock[1], '\0'};
hash[blockIndex] = (unsigned char)strtol(convertedBlock, NULL, 16);
}
}
NSString *displayHashFromRawHash(const unsigned char *hash)
{
char hexHash[CC_SHA1_DIGEST_LENGTH * 2 + 1] = {0};
for (size_t i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
snprintf(hexHash + i * 2, 3, "%02x", hash[i]);
}
return @(hexHash);
}
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
{
unsigned char hash[CC_SHA1_DIGEST_LENGTH];
if (!getRawHashOfTreeWithVersion(hash, path, majorVersion)) {
return nil;
}
return displayHashFromRawHash(hash);
}
extern NSString *hashOfTree(NSString *path)
{
return hashOfTreeWithVersion(path, SUBinaryDeltaMajorVersionLatest);
}
BOOL removeTree(NSString *path)
{
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)
{
// SUFileManager will be more reliable for copying items especially across network mounts
return [[[SUFileManager alloc] init] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
}
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil];
if (!attributes) {
return NO;
}
NSNumber *permissions = [attributes objectForKey:NSFilePosixPermissions];
if (!permissions) {
return NO;
}
mode_t newMode = ([permissions unsignedShortValue] & ~PERMISSION_FLAGS) | desiredPermissions;
int (*changeModeFunc)(const char *, mode_t) = [(NSString *)[attributes objectForKey:NSFileType] isEqualToString:NSFileTypeSymbolicLink] ? lchmod : chmod;
if (changeModeFunc([path fileSystemRepresentation], newMode) != 0) {
return NO;
}
return YES;
}
File diff suppressed because it is too large. Load diff
-29
View File
@@ -1,29 +0,0 @@
//
// SUCodeSigningVerifier.h
// Sparkle
//
// Created by Andy Matuschak on 7/5/12.
//
//
#ifndef SUCODESIGNINGVERIFIER_H
#define SUCODESIGNINGVERIFIER_H
#import <Foundation/Foundation.h>
#ifndef BUILDING_SPARKLE_TESTS
SPU_OBJC_DIRECT_MEMBERS
#endif
@interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError **)error;
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL checkNestedCode:(BOOL)checkNestedCode error:(NSError **)error;
// Same as above except does not check for nested code. This method should be used by the framework.
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error;
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL;
@end
#endif
-261
View File
@@ -1,261 +0,0 @@
//
// SUCodeSigningVerifier.m
// Sparkle
//
// Created by Andy Matuschak on 7/5/12.
//
//
#include <Security/CodeSigning.h>
#include <Security/SecCode.h>
#import "SUCodeSigningVerifier.h"
#import "SULog.h"
#import "SUErrors.h"
#include "AppKitPrevention.h"
@implementation SUCodeSigningVerifier
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)newBundleURL andMatchesSignatureAtBundleURL:(NSURL *)oldBundleURL error:(NSError * __autoreleasing *)error
{
OSStatus result;
SecRequirementRef requirement = NULL;
SecStaticCodeRef staticCode = NULL;
SecStaticCodeRef oldCode = NULL;
CFErrorRef cfError = NULL;
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)oldBundleURL, kSecCSDefaultFlags, &oldCode);
if (result == errSecCSUnsigned) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Bundle is not code signed: %@", newBundleURL] }];
}
return NO;
}
result = SecCodeCopyDesignatedRequirement(oldCode, kSecCSDefaultFlags, &requirement);
if (result != noErr) {
NSString *message = [NSString stringWithFormat:@"Failed to copy designated requirement. Code Signing OSStatus code: %d", result];
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
goto finally;
}
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)newBundleURL, kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
NSString *message = [NSString stringWithFormat:@"Failed to get static code %d", result];
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
goto finally;
}
// Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing.
// See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206
// Aditionally, there are several reasons to stay away from deep verification and to prefer EdDSA signing the download archive instead.
// See https://github.com/sparkle-project/Sparkle/pull/523#commitcomment-17549302 and https://github.com/sparkle-project/Sparkle/issues/543
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError);
if (result != errSecSuccess) {
NSError *underlyingError;
if (cfError != NULL) {
NSError *tmpError = CFBridgingRelease(cfError);
underlyingError = tmpError;
} else {
underlyingError = nil;
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (underlyingError != nil) {
userInfo[NSUnderlyingErrorKey] = underlyingError;
}
if (result == errSecCSUnsigned) {
NSString *message = @"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
userInfo[NSLocalizedDescriptionKey] = message;
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
} else if (result == errSecCSReqFailed) {
CFStringRef requirementString = nil;
NSString *initialMessage;
if (SecRequirementCopyString(requirement, kSecCSDefaultFlags, &requirementString) == noErr) {
initialMessage = [NSString stringWithFormat:@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.", requirementString];
SULog(SULogLevelError, @"%@", initialMessage);
CFRelease(requirementString);
} else {
initialMessage = @"Code signature of new version doesn't match the old version. Please ensure that old and new app is signed using exactly the same certificate.";
}
NSDictionary *oldInfo = [self logSigningInfoForCode:oldCode label:@"old info"];
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
if (error != NULL) {
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"%@ old info: %@. new info: %@", initialMessage, oldInfo, newInfo];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
} else {
if (error != NULL) {
userInfo[NSLocalizedDescriptionKey] = @"Error: Old app bundle code signing signature failed to match new bundle code signature";
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
}
}
finally:
if (oldCode) CFRelease(oldCode);
if (staticCode) CFRelease(staticCode);
if (requirement) CFRelease(requirement);
return (result == noErr);
}
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL error:(NSError *__autoreleasing *)error
{
return [self codeSignatureIsValidAtBundleURL:bundleURL checkNestedCode:NO error:error];
}
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundleURL checkNestedCode:(BOOL)checkNestedCode error:(NSError *__autoreleasing *)error
{
OSStatus result;
SecStaticCodeRef staticCode = NULL;
CFErrorRef cfError = NULL;
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)bundleURL, kSecCSDefaultFlags, &staticCode);
if (result != noErr) {
SULog(SULogLevelError, @"Failed to get static code %d", result);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to get static code for verifying code signature: %d", result] }];
}
goto finally;
}
// See in -codeSignatureIsValidAtBundleURL:andMatchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not always passed
SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures);
if (checkNestedCode) {
flags |= kSecCSCheckNestedCode;
}
result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError);
if (result != errSecSuccess) {
NSError *underlyingError;
if (cfError != NULL) {
NSError *tmpError = CFBridgingRelease(cfError);
underlyingError = tmpError;
} else {
underlyingError = nil;
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (underlyingError != nil) {
userInfo[NSUnderlyingErrorKey] = underlyingError;
}
if (result == errSecCSUnsigned) {
NSString *message = [NSString stringWithFormat:@"Error: The app is not signed using Apple Code Signing. %@", bundleURL];
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
userInfo[NSLocalizedDescriptionKey] = message;
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
} else if (result == errSecCSReqFailed) {
if (error != NULL) {
NSDictionary *newInfo = [self logSigningInfoForCode:staticCode label:@"new info"];
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@ - new info: %@", bundleURL, newInfo];
userInfo[NSLocalizedDescriptionKey] = message;
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
} else {
if (error != NULL) {
NSString *message = [NSString stringWithFormat:@"Error: The app failed Apple Code Signing checks: %@", bundleURL];
userInfo[NSLocalizedDescriptionKey] = message;
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInsufficientSigningError userInfo:[userInfo copy]];
}
}
}
finally:
if (staticCode) CFRelease(staticCode);
return (result == noErr);
}
static id valueOrNSNull(id value) {
return value ? value : [NSNull null];
}
+ (NSDictionary *)codeSignatureInfoForCode:(SecStaticCodeRef)code SPU_OBJC_DIRECT
{
CFDictionaryRef signingInfo = nil;
const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation);
if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) {
NSDictionary *signingDict = CFBridgingRelease(signingInfo);
NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary];
for (NSString *key in @[@"format", @"identifier", @"requirements", @"teamid", @"signing-time"]) {
[relevantInfo setObject:valueOrNSNull([signingDict objectForKey:key]) forKey:key];
}
NSDictionary *infoPlist = [signingDict objectForKey:@"info-plist"];
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:@"CFBundleShortVersionString"]) forKey:@"version"];
[relevantInfo setObject:valueOrNSNull([infoPlist objectForKey:(__bridge NSString *)kCFBundleVersionKey]) forKey:@"build"];
return [relevantInfo copy];
}
return nil;
}
+ (NSDictionary *)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label SPU_OBJC_DIRECT
{
NSDictionary *relevantInfo = [self codeSignatureInfoForCode:code];
SULog(SULogLevelDefault, @"%@: %@", label, relevantInfo);
return relevantInfo;
}
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundleURL
{
OSStatus result;
SecStaticCodeRef staticCode = NULL;
result = SecStaticCodeCreateWithPath((__bridge CFURLRef)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
-65
View File
@@ -1,65 +0,0 @@
//
// SUFlatPackageUnarchiver.m
// Autoupdate
//
// Created by Mayur Pawashe on 1/30/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#if SPARKLE_BUILD_PACKAGE_SUPPORT
#import "SUFlatPackageUnarchiver.h"
#import "SUUnarchiverNotifier.h"
#import "SPUInstallationType.h"
#import "SUErrors.h"
#include "AppKitPrevention.h"
@implementation SUFlatPackageUnarchiver
{
NSString *_flatPackagePath;
NSString *_expectedInstallationType;
}
+ (BOOL)canUnarchivePath:(NSString *)path
{
return [path.pathExtension isEqualToString:@"pkg"] || [path.pathExtension isEqualToString:@"mpkg"];
}
+ (BOOL)mustValidateBeforeExtraction
{
return YES;
}
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath expectingInstallationType:(NSString *)installationType
{
self = [super init];
if (self != nil) {
_flatPackagePath = [flatPackagePath copy];
_expectedInstallationType = [installationType copy];
}
return self;
}
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
{
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
// Flat packages must use guided package installs, not interactive
BOOL isDirectory = NO;
if (![_expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not have guided installation type but %@ instead", _expectedInstallationType]}]];
} else if (![[NSFileManager defaultManager] fileExistsAtPath:_flatPackagePath isDirectory:&isDirectory] || isDirectory) {
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", _flatPackagePath]}]];
} else {
[notifier notifyProgress:1.0];
[notifier notifySuccess];
}
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _flatPackagePath]; }
@end
#endif
-92
View File
@@ -1,92 +0,0 @@
//
// SUGuidedPackageInstaller.m
// Sparkle
//
// Created by Graham Miln on 14/05/2010.
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
//
#if SPARKLE_BUILD_PACKAGE_SUPPORT
#import <sys/stat.h>
#import "SUGuidedPackageInstaller.h"
#import "SUErrors.h"
#include "AppKitPrevention.h"
@implementation SUGuidedPackageInstaller
{
NSString *_packagePath;
NSString *_homeDirectory;
NSString *_userName;
}
- (instancetype)initWithPackagePath:(NSString *)packagePath homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName
{
self = [super init];
if (self != nil) {
_packagePath = [packagePath copy];
_homeDirectory = [homeDirectory copy];
_userName = [userName copy];
}
return self;
}
- (BOOL)performInitialInstallation:(NSError * __autoreleasing *)__unused error
{
return YES;
}
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))__unused cb error:(NSError * __autoreleasing *)error
{
// This command *must* be run as root
NSString *installerPath = @"/usr/sbin/installer";
NSTask *task = [[NSTask alloc] init];
task.launchPath = installerPath;
task.arguments = @[@"-pkg", _packagePath, @"-target", @"/"];
// Set the $HOME and $USER variables so pre/post install scripts reference the correct user environment
task.environment = @{@"HOME": _homeDirectory, @"USER": _userName};
task.standardError = nil;
task.standardOutput = nil;
NSError *launchError = nil;
if (![task launchAndReturnError:&launchError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Guided package installer failed to launch" }];
if (launchError != nil) {
userInfo[NSUnderlyingErrorKey] = launchError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}
[task waitUntilExit];
if (task.terminationStatus != EXIT_SUCCESS) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer returned non-zero exit status (%d)", task.terminationStatus] }];
}
return NO;
}
return YES;
}
- (void)performCleanup
{
}
- (BOOL)canInstallSilently
{
return YES;
}
@end
#endif
-28
View File
@@ -1,28 +0,0 @@
//
// SUInstaller.h
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUInstallerProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
SPU_OBJC_DIRECT_MEMBERS @interface SUInstaller : NSObject
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError **)error;
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
#if SPARKLE_BUILD_PACKAGE_SUPPORT
isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr
#endif
;
@end
NS_ASSUME_NONNULL_END
-209
View File
@@ -1,209 +0,0 @@
//
// SUInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUInstaller.h"
#import "SUPlainInstaller.h"
#import "SUPackageInstaller.h"
#import "SUGuidedPackageInstaller.h"
#import "SUHost.h"
#import "SUConstants.h"
#import "SULog.h"
#import "SUErrors.h"
#import "SPUInstallationType.h"
#import "SUNormalization.h"
#include "AppKitPrevention.h"
@implementation SUInstaller
+ (BOOL)isAliasFolderAtPath:(NSString *)path SPU_OBJC_DIRECT
{
NSNumber *aliasFlag = nil;
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
NSNumber *directoryFlag = nil;
[[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil];
return aliasFlag.boolValue && directoryFlag.boolValue;
}
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host
#if SPARKLE_BUILD_PACKAGE_SUPPORT
isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
#endif
{
NSParameterAssert(inUpdateFolder);
NSParameterAssert(host);
// Search subdirectories for the application
NSString *currentFile,
*newAppDownloadPath = nil,
*bundleFileName = [[host bundlePath] lastPathComponent],
*alternateBundleFileName = [[host name] stringByAppendingPathExtension:[[host bundlePath] pathExtension]];
#if SPARKLE_BUILD_PACKAGE_SUPPORT
NSString *fallbackPackagePath = nil;
BOOL isPackage = NO;
BOOL isGuided = YES;
#endif
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder];
NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension];
while ((currentFile = [dirEnum nextObject])) {
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
NSString *currentFilename = [currentFile lastPathComponent];
#if SPARKLE_BUILD_PACKAGE_SUPPORT
NSString *currentExtension = [currentFile pathExtension];
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
#endif
if ([currentFilename isEqualToString:bundleFileName] ||
[currentFilename isEqualToString:alternateBundleFileName]) // We found one!
{
#if SPARKLE_BUILD_PACKAGE_SUPPORT
isPackage = NO;
#endif
newAppDownloadPath = currentPath;
break;
#if SPARKLE_BUILD_PACKAGE_SUPPORT
} else if ([currentExtension isEqualToString:@"pkg"] ||
[currentExtension isEqualToString:@"mpkg"]) {
if ([currentFilenameNoExtension isEqualToString:bundleFileNameNoExtension]) {
isPackage = YES;
newAppDownloadPath = currentPath;
break;
} else {
// Remember any other non-matching packages we have seen should we need to use one of them as a fallback.
fallbackPackagePath = currentPath;
}
#endif
} else {
// Try matching on bundle identifiers in case the user has changed the name of the host app
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
if (incomingBundle && [incomingBundle.bundleIdentifier isEqualToString:hostBundleIdentifier]) {
#if SPARKLE_BUILD_PACKAGE_SUPPORT
isPackage = NO;
#endif
newAppDownloadPath = currentPath;
break;
}
}
// Some DMGs have symlinks into /Applications! That's no good!
if ([self isAliasFolderAtPath:currentPath])
[dirEnum skipDescendents];
}
#if SPARKLE_BUILD_PACKAGE_SUPPORT
// We don't have a valid path. Try to use the fallback package.
if (newAppDownloadPath == nil && fallbackPackagePath != nil) {
isPackage = YES;
newAppDownloadPath = fallbackPackagePath;
}
if (isPackage) {
// Guided (or now "normal") installs used to be opt-in (i.e, Sparkle would detect foo.sparkle_guided.pkg or foo.sparkle_guided.mpkg),
// but to get an interactive (or "unguided") install, the developer now must opt-out of guided installations.
// foo.app -> foo.sparkle_interactive.pkg or foo.sparkle_interactive.mpkg
if ([[[newAppDownloadPath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_interactive"]) {
isGuided = NO;
}
}
if (isPackagePtr)
*isPackagePtr = isPackage;
if (isGuidedPtr)
*isGuidedPtr = isGuided;
#endif
if (!newAppDownloadPath) {
SULog(SULogLevelError, @"Searched %@ for %@.(app%@)", inUpdateFolder, bundleFileNameNoExtension,
#if SPARKLE_BUILD_PACKAGE_SUPPORT
@"|pkg"
#else
@""
#endif
);
}
return newAppDownloadPath;
}
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory homeDirectory:(NSString *)homeDirectory userName:(NSString *)userName error:(NSError * __autoreleasing *)error
{
#if SPARKLE_BUILD_PACKAGE_SUPPORT
BOOL isPackage = NO;
BOOL isGuided = NO;
#endif
NSString *newDownloadPath = [self installSourcePathInUpdateFolder:updateDirectory forHost:host
#if SPARKLE_BUILD_PACKAGE_SUPPORT
isPackage:&isPackage isGuided:&isGuided
#endif
];
if (newDownloadPath == nil) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }];
}
return nil;
}
// Make sure we find the type of installer that we were expecting to find
// We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine
// ahead of time whether or not this installer tool should be ran as root or not
id <SUInstallerProtocol> installer = nil;
#if SPARKLE_BUILD_PACKAGE_SUPPORT
if (isPackage && isGuided) {
if (![expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found guided package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SPUInstallationTypeGuidedPackage] }];
}
} else {
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath homeDirectory:homeDirectory userName:userName];
}
} else if (isPackage) {
if (![expectedInstallationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SPUInstallationTypeInteractivePackage] }];
}
} else {
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
}
} else
#endif
{
if (![expectedInstallationType isEqualToString:SPUInstallationTypeApplication]) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found regular application update but expected '%@=%@' from the appcast item enclosure instead", SUAppcastAttributeInstallationType, expectedInstallationType] }];
}
} else {
NSString *normalizedInstallationPath = nil;
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
normalizedInstallationPath = SUNormalizedInstallationPath(host);
}
// If we have a normalized path, we'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
// Otherwise if there's no normalized path (the more likely case), we'll just use the host bundle's path
// Check progress agent app which computes normalized path too according to these rules
NSString *installationPath;
if (normalizedInstallationPath != nil && ![[NSFileManager defaultManager] fileExistsAtPath:normalizedInstallationPath]) {
installationPath = normalizedInstallationPath;
} else {
installationPath = host.bundlePath;
}
installer = [[SUPlainInstaller alloc] initWithHost:host bundlePath:newDownloadPath installationPath:installationPath];
}
}
return installer;
}
@end
-38
View File
@@ -1,38 +0,0 @@
//
// SUInstallerProtocol.h
// Sparkle
//
// Created by Mayur Pawashe on 3/12/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SUInstallerProtocol <NSObject>
// Any installation work can be done prior to user application being terminated and relaunched
// No UI should occur during this stage (i.e, do not show package installer apps, etc..)
// Should be able to be called from non-main thread
- (BOOL)performInitialInstallation:(NSError **)error;
// Any installation work after the user application has has been terminated. This is where the final installation work can be done.
// After this stage is done, the user application may be relaunched.
// Should be able to be called from non-main thread
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))cb error:(NSError **)error;
// Any clean up work can be done here
// This is work that may be performed after the user application may have been updated / relaunched,
// or after an error occurred in the previous stages.
// Should be able to be called from any thread
- (void)performCleanup;
// Indicates whether or not this installer can install the update silently in the background, without hindering the user
// If this returns NO, then the installation can fail if the user did not directly request for the install to occur.
// Should be thread safe
- (BOOL)canInstallSilently;
@end
NS_ASSUME_NONNULL_END
-23
View File
@@ -1,23 +0,0 @@
//
// SUPackageInstaller.h
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#if SPARKLE_BUILD_PACKAGE_SUPPORT
#import <Foundation/Foundation.h>
#import "SUInstallerProtocol.h"
// This is the deprecated package installation type, aka the "interactive" package installer
// For a more supported package installation, see SUGuidedPackageInstaller
SPU_OBJC_DIRECT_MEMBERS @interface SUPackageInstaller : NSObject <SUInstallerProtocol>
- (instancetype)initWithPackagePath:(NSString *)packagePath;
@end
#endif
-240
View File
@@ -1,240 +0,0 @@
//
// SUPipedUnarchiver.m
// Sparkle
//
// Created by Andy Matuschak on 6/16/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPipedUnarchiver.h"
#import "SUUnarchiverNotifier.h"
#import "SULog.h"
#import "SUErrors.h"
#include "AppKitPrevention.h"
@implementation SUPipedUnarchiver
{
NSString *_archivePath;
}
static NSArray <NSString *> * _Nullable _commandAndArgumentsConformingToTypeOfPath(NSString *path)
{
NSArray <NSString *> *extractTGZ = @[@"/usr/bin/tar", @"-zxC"];
NSArray <NSString *> *extractTBZ = @[@"/usr/bin/tar", @"-jxC"];
NSArray <NSString *> *extractTXZ = extractTGZ;
// Note: keep this list in sync with generate_appcast's unarchiveUpdates()
NSDictionary <NSString *, NSArray<NSString *> *> *extractCommandDictionary =
@{
@".zip" : @[@"/usr/bin/ditto", @"-x",@"-k",@"-"],
@".tar" : @[@"/usr/bin/tar", @"-xC"],
@".tar.gz" : extractTGZ,
@".tgz" : extractTGZ,
@".tar.bz2" : extractTBZ,
@".tbz" : extractTBZ,
@".tar.xz" : extractTXZ,
@".txz" : extractTXZ,
@".tar.lzma" : extractTXZ
};
NSString *lastPathComponent = [path lastPathComponent];
for (NSString *currentType in extractCommandDictionary)
{
if ([lastPathComponent hasSuffix:currentType]) {
return [extractCommandDictionary objectForKey:currentType];
}
}
return nil;
}
+ (BOOL)canUnarchivePath:(NSString *)path
{
return _commandAndArgumentsConformingToTypeOfPath(path) != nil;
}
+ (BOOL)mustValidateBeforeExtraction
{
return NO;
}
- (instancetype)initWithArchivePath:(NSString *)archivePath
{
self = [super init];
if (self != nil) {
_archivePath = [archivePath copy];
}
return self;
}
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
{
NSArray <NSString *> *commandAndArguments = _commandAndArgumentsConformingToTypeOfPath(_archivePath);
assert(commandAndArguments != nil);
NSString *command = commandAndArguments.firstObject;
assert(command != nil);
NSArray <NSString *> *arguments = [commandAndArguments subarrayWithRange:NSMakeRange(1, commandAndArguments.count - 1)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
[self extractArchivePipingDataToCommand:command arguments:arguments notifier:notifier];
});
}
// This method abstracts the types that use a command line tool piping data from stdin.
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier SPU_OBJC_DIRECT
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
@autoreleasepool {
NSString *destination = [_archivePath stringByDeletingLastPathComponent];
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], _archivePath, destination);
// Get the file size.
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:_archivePath error:nil];
NSUInteger expectedLength = [(NSNumber *)[attributes objectForKey:NSFileSize] unsignedIntegerValue];
if (expectedLength == 0) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, archive '%@' is empty", _archivePath]}];
[notifier notifyFailureWithError:error];
return;
}
NSFileHandle *archiveInput = [NSFileHandle fileHandleForReadingAtPath:_archivePath];
NSPipe *pipe = [NSPipe pipe];
NSTask *task = [[NSTask alloc] init];
[task setStandardInput:pipe];
[task setStandardError:[NSFileHandle fileHandleWithStandardError]];
[task setStandardOutput:[NSFileHandle fileHandleWithStandardOutput]];
[task setLaunchPath:command];
[task setArguments:[args arrayByAddingObject:destination]];
NSError *launchError = nil;
if (![task launchAndReturnError:&launchError]) {
[notifier notifyFailureWithError:launchError];
return;
}
NSFileHandle *archiveOutput = [pipe fileHandleForWriting];
NSUInteger bytesWritten = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
BOOL hasIOErrorMethods;
if (@available(macOS 10.15, *)) {
hasIOErrorMethods = YES;
} else {
hasIOErrorMethods = NO;
}
#endif
do {
NSData *data;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
if (!hasIOErrorMethods) {
@try {
data = [archiveInput readDataOfLength:256*1024];
} @catch (NSException *exception) {
SULog(SULogLevelError, @"Failed to read data from archive with exception reason %@", exception.reason);
data = nil;
}
}
else
#endif
{
NSError *readError = nil;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
data = [archiveInput readDataUpToLength:256*1024 error:&readError];
#pragma clang diagnostic pop
if (data == nil) {
SULog(SULogLevelError, @"Failed to read data from archive with error %@", readError);
}
}
NSUInteger len = [data length];
if (len == 0) {
break;
}
NSError *writeError = nil;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
if (!hasIOErrorMethods) {
@try {
[archiveOutput writeData:data];
} @catch (NSException *exception) {
SULog(SULogLevelError, @"Failed to write data to pipe with exception reason %@", exception.reason);
break;
}
}
else
#endif
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
if (![archiveOutput writeData:data error:&writeError]) {
#pragma clang diagnostic pop
SULog(SULogLevelError, @"Failed to write data to pipe with error %@", writeError);
break;
}
}
bytesWritten += len;
[notifier notifyProgress:(double)bytesWritten / (double)expectedLength];
}
while(bytesWritten < expectedLength);
if (@available(macOS 10.15, *)) {
NSError *archiveOutputCloseError = nil;
if (![archiveOutput closeAndReturnError:&archiveOutputCloseError]) {
SULog(SULogLevelError, @"Failed to close pipe with error %@", archiveOutputCloseError);
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
else
{
[archiveOutput closeFile];
}
#endif
if (@available(macOS 10.15, *)) {
NSError *archiveInputCloseError = nil;
if (![archiveInput closeAndReturnError:&archiveInputCloseError]) {
SULog(SULogLevelError, @"Failed to close archive input with error %@", archiveInputCloseError);
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15
else
{
[archiveInput closeFile];
}
#endif
[task waitUntilExit];
if ([task terminationStatus] != 0) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' returned %d", command, [task terminationStatus]]}];
[notifier notifyFailureWithError:error];
return;
}
if (bytesWritten != expectedLength) {
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes", command, (long)bytesWritten, (long)expectedLength]}];
[notifier notifyFailureWithError:error];
return;
}
[notifier notifySuccess];
}
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], _archivePath]; }
@end
-346
View File
@@ -1,346 +0,0 @@
//
// SUPlainInstaller.m
// Sparkle
//
// Created by Andy Matuschak on 4/10/08.
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import "SUPlainInstaller.h"
#import "SUFileManager.h"
#import "SUConstants.h"
#import "SUHost.h"
#import "SULog.h"
#import "SUErrors.h"
#import "SUVersionComparisonProtocol.h"
#import "SUStandardVersionComparator.h"
#include "AppKitPrevention.h"
@implementation SUPlainInstaller
{
SUHost *_host;
NSString *_bundlePath;
NSString *_installationPath;
NSURL *_temporaryOldDirectory;
// We get an obj-c warning if we use 'newTemporaryDirectory' name about new + ownership stuff, so use 'temporaryNewDirectory' instead
NSURL *_temporaryNewDirectory;
BOOL _newAndOldBundlesOnSameVolume;
}
- (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath
{
self = [super init];
if (self != nil) {
_host = host;
_bundlePath = [bundlePath copy];
_installationPath = [installationPath copy];
}
return self;
}
- (void)_performInitialInstallationWithFileManager:(SUFileManager *)fileManager oldBundleURL:(NSURL *)oldBundleURL newBundleURL:(NSURL *)newBundleURL progressBlock:(nullable void(^)(double))progress SPU_OBJC_DIRECT
{
// Release our new app from quarantine
NSError *quarantineError = nil;
if (![fileManager releaseItemFromQuarantineAtRootURL:newBundleURL error:&quarantineError]) {
// Not big enough of a deal to fail the entire installation
SULog(SULogLevelError, @"Failed to release quarantine at %@ with error %@", newBundleURL.path, quarantineError);
}
if (progress) {
progress(5/11.0);
}
// Try to preserve Finder Tags
NSArray *resourceTags = nil;
BOOL retrievedResourceTags = [oldBundleURL getResourceValue:&resourceTags forKey:NSURLTagNamesKey error:NULL];
if (retrievedResourceTags && resourceTags.count > 0) {
[newBundleURL setResourceValue:resourceTags forKey:NSURLTagNamesKey error:NULL];
}
if (progress) {
progress(6/11.0);
}
// Update owner and group (if possible)
NSError *changeOwnerAndGroupError = nil;
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newBundleURL toMatchURL:oldBundleURL error:&changeOwnerAndGroupError]) {
// Not a fatal error
SULog(SULogLevelError, @"Failed to change owner and group of new app at %@ to match old app at %@", newBundleURL.path, oldBundleURL.path);
SULog(SULogLevelError, @"Error: %@", changeOwnerAndGroupError);
}
if (progress) {
progress(7/11.0);
}
// Register the new bundle with LaunchServices and the system
NSError *touchError = nil;
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:newBundleURL error:&touchError]) {
// Not a fatal error, but a pretty unfortunate one
SULog(SULogLevelError, @"Failed to update modification and access time of new app at %@", newBundleURL.path);
SULog(SULogLevelError, @"Error: %@", touchError);
}
if (progress) {
progress(8/11.0);
}
}
- (BOOL)startInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host progressBlock:(nullable void(^)(double))progress error:(NSError * __autoreleasing *)error SPU_OBJC_DIRECT
{
if (installationURL == nil || newURL == nil) {
// this really shouldn't happen but just in case
SULog(SULogLevelError, @"Failed to perform installation because either installation URL (%@) or new URL (%@) is nil", installationURL, newURL);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because the paths to install at and from are not valid" }];
}
return NO;
}
if (progress) {
progress(1/11.0);
}
SUFileManager *fileManager = [[SUFileManager alloc] init];
// Update the access time of our entire application before moving it into a temporary directory
// The system periodically cleans up files by looking at the mod & access times, so we have to make sure they're up to date
// They could be potentially be preserved when archiving an application, but also an update could just be sitting on the system for a long time
// before being installed
if (!_newAndOldBundlesOnSameVolume) {
NSError *accessTimeError = nil;
if (![fileManager updateAccessTimeOfItemAtRootURL:newURL error:&accessTimeError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: @"Failed to recursively update new application's modification time before moving into temporary directory" }];
if (accessTimeError != nil) {
userInfo[NSUnderlyingErrorKey] = accessTimeError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}
}
NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath];
if (oldURL == nil) {
// this really shouldn't happen but just in case
SULog(SULogLevelError, @"Failed to construct URL from bundle path: %@", host.bundlePath);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because a path could not be constructed for the old installation" }];
}
return NO;
}
if (progress) {
progress(2/11.0);
}
NSURL *tempNewDirectoryURL;
if (!_newAndOldBundlesOnSameVolume) {
// Create a temporary directory for our new app that resides on our destination's volume
// We use oldURL here instead of installationURL because in the case of normalization, installationURL may not exist
// And we don't want to use either of the URL's parent directories because the parent directory could be on a different volume
tempNewDirectoryURL = [fileManager makeTemporaryDirectoryAppropriateForDirectoryURL:oldURL error:error];
if (tempNewDirectoryURL == nil) {
return NO;
}
_temporaryNewDirectory = tempNewDirectoryURL;
} else {
tempNewDirectoryURL = nil;
}
if (progress) {
progress(3/11.0);
}
// Move the new app to our temporary directory if needed
NSURL *newFinalURL;
if (!_newAndOldBundlesOnSameVolume) {
NSString *newURLLastPathComponent = newURL.lastPathComponent;
newFinalURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURLLastPathComponent];
NSError *newTempMoveError = nil;
if (![fileManager moveItemAtURL:newURL toURL:newFinalURL error:&newTempMoveError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newFinalURL.path] }];
if (newTempMoveError != nil) {
userInfo[NSUnderlyingErrorKey] = newTempMoveError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}
} else {
newFinalURL = newURL;
}
if (progress) {
progress(4/11.0);
}
if (!_newAndOldBundlesOnSameVolume) {
[self _performInitialInstallationWithFileManager:fileManager oldBundleURL:oldURL newBundleURL:newFinalURL progressBlock:progress];
}
if (progress) {
progress(9/11.0);
}
// First try swapping the application atomically
NSError *swapError = nil;
BOOL swappedApp;
// If the app is normalized and the installation path differs, go through the old swap path
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME && ![oldURL.path isEqual:installationURL.path]) {
swappedApp = NO;
} else {
// We will be cleaning up the temporary directory later in -performCleanup:
// We don't want to clean it up now because it can take some time
swappedApp = [fileManager swapItemAtURL:installationURL withItemAtURL:newFinalURL error:&swapError];
}
if (!swappedApp) {
// Otherwise swap out the old and new applications using the legacy path
if (swapError != nil) {
SULog(SULogLevelDefault, @"Invoking fallback from failing to replace original item with error: %@", swapError);
}
// Create a temporary directory for our old app that resides on its volume
NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryAppropriateForDirectoryURL:oldURL error:error];
if (tempOldDirectoryURL == nil) {
return NO;
}
_temporaryOldDirectory = tempOldDirectoryURL;
if (progress) {
progress(10/11.0);
}
NSString *oldURLFilename = oldURL.lastPathComponent;
if (oldURLFilename == nil) {
// this really shouldn't happen..
SULog(SULogLevelError, @"Failed to retrieve last path component from old URL: %@", oldURL.path);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because the last path component of the old installation URL could not be constructed." }];
}
return NO;
}
// Move the old app to the temporary directory
NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURLFilename];
NSError *oldMoveError = nil;
if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:&oldMoveError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path] }];
if (oldMoveError != nil) {
userInfo[NSUnderlyingErrorKey] = oldMoveError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
return NO;
}
if (progress) {
progress(10.5/11.0);
}
// Move the new app to its final destination
NSError *installMoveError = nil;
if (![fileManager moveItemAtURL:newFinalURL toURL:installationURL error:&installMoveError]) {
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move new app at %@ to final destination %@", newFinalURL.path, installationURL.path] }];
if (installMoveError != nil) {
userInfo[NSUnderlyingErrorKey] = installMoveError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:userInfo];
}
// Attempt to restore our old app back the way it was on failure
[fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL];
return NO;
}
}
if (progress) {
progress(11/11.0);
}
return YES;
}
- (BOOL)performInitialInstallation:(NSError * __autoreleasing *)error
{
// Prevent malicious downgrades
// Note that we may not be able to do this for package installations, hence this code being done here
NSString *hostVersion = [_host version];
NSBundle *bundle = [NSBundle bundleWithPath:_bundlePath];
SUHost *updateHost = [[SUHost alloc] initWithBundle:bundle];
NSString *updateVersion = [updateHost objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
id<SUVersionComparison> comparator = [[SUStandardVersionComparator alloc] init];
if (!updateVersion || [comparator compareVersion:hostVersion toVersion:updateVersion] == NSOrderedDescending) {
if (error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", hostVersion, updateVersion];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
}
return NO;
}
SUFileManager *fileManager = [[SUFileManager alloc] init];
_newAndOldBundlesOnSameVolume = [fileManager itemAtURL:bundle.bundleURL isOnSameVolumeItemAsURL:_host.bundle.bundleURL];
// We can do a lot of the installation work ahead of time if the new app update does not need to be copied to another volume
if (_newAndOldBundlesOnSameVolume) {
[self _performInitialInstallationWithFileManager:fileManager oldBundleURL:_host.bundle.bundleURL newBundleURL:bundle.bundleURL progressBlock:NULL];
}
return YES;
}
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))cb error:(NSError *__autoreleasing*)error
{
// Note: we must do most installation work in the third stage due to relying on our application sitting in temporary directories.
// It must not be possible for our update to sit in temporary directories for a very long time.
return [self startInstallationToURL:[NSURL fileURLWithPath:_installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:_bundlePath] withHost:_host progressBlock:cb error:error];
}
- (void)performCleanup
{
SUFileManager *fileManager = [[SUFileManager alloc] init];
if (_temporaryNewDirectory != nil) {
[fileManager removeItemAtURL:_temporaryNewDirectory error:NULL];
}
if (_temporaryOldDirectory != nil) {
[fileManager removeItemAtURL:_temporaryOldDirectory error:NULL];
}
}
- (BOOL)canInstallSilently
{
return YES;
}
@end
-392
View File
@@ -1,392 +0,0 @@
//
// SUDSAVerifier.m
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
// Includes code by Zach Waldowski on 10/18/13.
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
//
// Includes code from Plop by Mark Hamlin.
// Copyright 2011 Mark Hamlin. Licensed under BSD.
//
#import "SUSignatureVerifier.h"
#import "SULog.h"
#import "SUSignatures.h"
#import "SUErrors.h"
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
#include <CommonCrypto/CommonDigest.h>
#endif
#import "ed25519.h"
#include "AppKitPrevention.h"
@implementation SUSignatureVerifier
{
SUPublicKeys *_pubKeys;
}
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys error:(NSError * __autoreleasing *)error
{
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
if (verifier == nil) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create SUSignatureVerifier instance" }];
}
return NO;
}
return [verifier verifyFileAtPath:path signatures:signatures error:error];
}
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
{
self = [super init];
if (self != nil) {
_pubKeys = pubkeys;
}
return self;
}
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
- (SecKeyRef)dsaSecKeyRef SPU_OBJC_DIRECT
{
NSData *data = [_pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
if (!self || !data.length) {
SULog(SULogLevelError, @"Could not read public DSA key");
return nil;
}
SecExternalFormat format = kSecFormatOpenSSL;
SecExternalItemType itemType = kSecItemTypePublicKey;
CFArrayRef items = NULL;
OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items);
if (status != errSecSuccess || !items) {
if (items) {
CFRelease(items);
}
SULog(SULogLevelError, @"Public DSA key could not be imported: %d", status);
return nil;
}
SecKeyRef dsaPubKeySecKey = nil;
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-qual"
dsaPubKeySecKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
#pragma clang diagnostic pop
}
CFRelease(items);
return dsaPubKeySecKey;
}
#endif
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures error:(NSError * __autoreleasing *)error
{
if (!path || !path.length) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Path passed to verify has zero length and is not valid" }];
}
return NO;
}
if (!signatures) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"No signatures given to verifyFileAtPath" }];
}
return NO;
}
switch (_pubKeys.ed25519PubKeyStatus) {
case SUSigningInputStatusAbsent:
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
SULog(SULogLevelDefault, @"The update has an EdDSA signature, but it won't be used, because the old app doesn't have an EdDSA public key");
}
break;
case SUSigningInputStatusInvalid:
if (signatures.ed25519SignatureStatus != SUSigningInputStatusAbsent) {
NSString *message = @"The update has an EdDSA signature, but the app has an invalid EdDSA public key, so the update will automatically be rejected.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
SULog(SULogLevelDefault, @"The app has an invalid EdDSA public key, but there is no EdDSA signature in the update. Falling back to DSA.");
break;
case SUSigningInputStatusPresent:
switch (signatures.ed25519SignatureStatus) {
case SUSigningInputStatusAbsent: {
NSString *message = @"The app has an EdDSA public key, but there is no EdDSA signature in the update, so the update will be rejected.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
case SUSigningInputStatusInvalid: {
NSString *message = @"The update has an EdDSA signature, but it's invalid, so the update will automatically be rejected.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
case SUSigningInputStatusPresent: {
NSError *dataError = nil;
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&dataError];
if (!data || !data.length) {
SULog(SULogLevelError, @"Failed to load file %@: %@", path, dataError);
if (error != NULL) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Failed to load file: %@", path];
if (dataError != nil) {
userInfo[NSUnderlyingErrorKey] = dataError;
}
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
}
return NO;
}
if (ed25519_verify(signatures.ed25519Signature, data.bytes, data.length, _pubKeys.ed25519PubKey)) {
SULog(SULogLevelDefault, @"OK: EdDSA signature is correct");
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
// No need to check DSA when EdDSA verification succeeded, unless a DSA signature is provided and it's
// erroneously invalid
if (signatures.dsaSignatureStatus != SUSigningInputStatusInvalid)
#endif
{
return YES;
}
} else {
NSString *message = @"EdDSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.";
SULog(SULogLevelError, @"%@", message);
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
SULog(SULogLevelDefault, @"DSA signature won't be checked, because EdDSA verification has already failed");
}
#endif
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
}
}
break;
}
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
switch (_pubKeys.dsaPubKeyStatus) {
case SUSigningInputStatusAbsent:
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
}
break;
case SUSigningInputStatusInvalid:
if (signatures.dsaSignatureStatus != SUSigningInputStatusAbsent) {
// We will have already logged an error for this failure when the public key was read in, so just do an informational log here.
NSString *message = @"The update has a DSA signature, but the app has an invalid DSA public key, so the update will automatically be rejected.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
SULog(SULogLevelDefault, @"The app has an invalid DSA public key, but there is no DSA signature in the update.");
break;
case SUSigningInputStatusPresent:
switch (signatures.dsaSignatureStatus) {
case SUSigningInputStatusAbsent:
SULog(SULogLevelError, @"There is no DSA signature in the update");
break;
case SUSigningInputStatusInvalid: {
NSString *message = @"The update has a DSA signature, but it's invalid, so the update will automatically be rejected.";
SULog(SULogLevelError, @"%@", message);
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: message }];
}
return NO;
}
case SUSigningInputStatusPresent: {
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:signatures.dsaSignature error:error];
}
}
}
#else
switch (_pubKeys.dsaPubKeyStatus) {
case SUSigningInputStatusAbsent:
break;
case SUSigningInputStatusInvalid:
// We don't keep track of DSA signatures, so we will ignore this mistake and treat it as if it were absent
break;
case SUSigningInputStatusPresent:
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"The old app has a DSA public key but DSA support is disabled, and the old app does not have an EdDSA public key." }];
}
return NO;
}
#endif
if (error != NULL) {
// Use generic failure
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"EdDSA and DSA verification for the update has failed" }];
}
return NO;
}
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature error:(NSError * __autoreleasing *)outError SPU_OBJC_DIRECT
{
if (!stream || !dsaSignature) {
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Invalid arguments to verifyStream" }];
}
return NO;
}
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
if (!dsaPubKeySecKey) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to create DSA Sec Key Ref" }];
}
return NO;
}
// Sparkle's DSA support is deprecated
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
__block SecGroupTransformRef group = SecTransformCreateGroupTransform();
__block SecTransformRef dataReadTransform = NULL;
__block SecTransformRef dataDigestTransform = NULL;
__block SecTransformRef dataVerifyTransform = NULL;
__block CFErrorRef error = NULL;
BOOL (^cleanup)(void) = ^{
if (group) CFRelease(group);
if (dataReadTransform) CFRelease(dataReadTransform);
if (dataDigestTransform) CFRelease(dataDigestTransform);
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
if (error) CFRelease(error);
if (dsaPubKeySecKey) CFRelease(dsaPubKeySecKey);
return NO;
};
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
if (!dataReadTransform) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecTransform for input stream)" }];
}
return cleanup();
}
dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, CC_SHA1_DIGEST_LENGTH, NULL);
if (!dataDigestTransform) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"File containing update archive could not be read (failed to create SecDigest for input stream)" }];
}
return cleanup();
}
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
if (!dataVerifyTransform) {
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
if (outError != NULL) {
NSError *underlyingError = (__bridge NSError *)error;
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"Could not understand format of the signature data %@", dsaSignature];
if (underlyingError != NULL) {
userInfo[NSUnderlyingErrorKey] = underlyingError;
}
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:[userInfo copy]];
}
return cleanup();
}
#pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
#pragma clang diagnostic pop
if (error) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data read transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
}
return cleanup();
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataVerifyTransform, kSecTransformInputAttributeName, group, &error);
#pragma clang diagnostic pop
if (error) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{NSLocalizedDescriptionKey : @"Failed to connect data digest transform", NSUnderlyingErrorKey: (__bridge NSError *)error}];
}
return cleanup();
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSNumber *result = CFBridgingRelease(SecTransformExecute(group, &error));
#pragma clang diagnostic pop
if (error) {
SULog(SULogLevelError, @"DSA signature verification failed: %@", error);
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature verification failed", NSUnderlyingErrorKey: (__bridge NSError *)error}];
}
return cleanup();
}
if (!result.boolValue) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUValidationError userInfo:@{ NSLocalizedDescriptionKey: @"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set"}];
}
}
cleanup();
return result.boolValue;
}
#endif
@end
-21
View File
@@ -1,21 +0,0 @@
//
// SUStatusInfoProtocol.h
// Sparkle
//
// Created by Mayur Pawashe on 7/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SUStatusInfoProtocol
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable installationInfoData))reply;
- (void)probeStatusConnectivityWithReply:(void (^)(void))reply;
@end
NS_ASSUME_NONNULL_END
-26
View File
@@ -1,26 +0,0 @@
//
// StatusInfo.h
// Sparkle
//
// Created by Mayur Pawashe on 7/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUStatusInfoProtocol.h"
NS_ASSUME_NONNULL_BEGIN
SPU_OBJC_DIRECT_MEMBERS @interface StatusInfo : NSObject <SUStatusInfoProtocol>
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier;
@property (nonatomic, nullable) NSData *installationInfoData;
- (void)startListener;
- (void)invalidate;
@end
NS_ASSUME_NONNULL_END
-105
View File
@@ -1,105 +0,0 @@
//
// StatusInfo.m
// Sparkle
//
// Created by Mayur Pawashe on 7/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "StatusInfo.h"
#import "SPUMessageTypes.h"
#include "AppKitPrevention.h"
#define REPLY_STATUS_INFO_TIMEOUT 2
@interface StatusInfo () <NSXPCListenerDelegate>
@end
@implementation StatusInfo
{
NSXPCListener *_xpcListener;
NSMutableDictionary *_pendingReplies;
NSUInteger _pendingReplyCounter;
}
@synthesize installationInfoData = _installationInfoData;
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier
{
self = [super init];
if (self != nil) {
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SPUStatusInfoServiceNameForBundleIdentifier(bundleIdentifier)];
_xpcListener.delegate = self;
_pendingReplies = [NSMutableDictionary dictionary];
}
return self;
}
- (void)startListener
{
[_xpcListener resume];
}
- (void)invalidate
{
[_xpcListener invalidate];
_xpcListener = nil;
}
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
{
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUStatusInfoProtocol)];
newConnection.exportedObject = self;
[newConnection resume];
return YES;
}
- (void)setInstallationInfoData:(NSData *)installationInfoData
{
_installationInfoData = installationInfoData;
// Respond to all of our pending replies
for (NSNumber *replyKey in _pendingReplies) {
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[replyKey];
replyBlock(_installationInfoData);
}
[_pendingReplies removeAllObjects];
}
- (void)probeStatusInfoWithReply:(void (^)(NSData * _Nullable))reply
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self->_installationInfoData != nil) {
reply(self->_installationInfoData);
} else {
// If we don't have the installation info data currently, we may receive it in a very short window afterwards
// In this case wait a bit for the reply. If we receive the data it will be in -setInstallationInfoData:
NSUInteger currentReplyCounter = self->_pendingReplyCounter;
self->_pendingReplyCounter++;
NSNumber *currentReplyCounterKey = @(currentReplyCounter);
self->_pendingReplies[currentReplyCounterKey] = [reply copy];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(REPLY_STATUS_INFO_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
void (^replyBlock)(NSData * _Nullable) = self->_pendingReplies[currentReplyCounterKey];
if (replyBlock != nil) {
replyBlock(self->_installationInfoData);
[self->_pendingReplies removeObjectForKey:currentReplyCounterKey];
}
});
}
});
}
- (void)probeStatusConnectivityWithReply:(void (^)(void))reply
{
reply();
}
@end
-43
View File
@@ -1,43 +0,0 @@
#import <Foundation/Foundation.h>
#import "AppInstaller.h"
#include "AppKitPrevention.h"
int main(int __unused argc, const char __unused *argv[])
{
@autoreleasepool
{
NSArray<NSString *> *args = [[NSProcessInfo processInfo] arguments];
if (args.count != 4) {
return EXIT_FAILURE;
}
NSString *hostBundleIdentifier = args[1];
NSString *homeDirectory = args[2];
NSString *userName = args[3];
AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostBundleIdentifier:hostBundleIdentifier homeDirectory:homeDirectory userName:userName];
[appInstaller start];
// Ignore SIGTERM because we are going to catch it ourselves
signal(SIGTERM, SIG_IGN);
// Ignore SIGPIPE because we won't want read or write failures due to broken pipe to unexpectably
// terminate the process (e.g, when extracting archives or performing package installs).
signal(SIGPIPE, SIG_IGN);
dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
dispatch_source_set_event_handler(sigtermSource, ^{
// Don't clear the update directory because the installer may be in middle of installing an update
// We still need to set an event handler for receiving SIGTERM though, otherwise our job may not terminate
// (This is also recommended from the developer documentation).
// Simply exit with SIGTERM if we recieve this signal
exit(SIGTERM);
});
dispatch_resume(sigtermSource);
[[NSRunLoop currentRunLoop] run];
}
return EXIT_SUCCESS;
}
-8
View File
@@ -1,8 +0,0 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "SUBinaryDeltaApply.h"
#import "SUBinaryDeltaCreate.h"
#import "SPUDeltaArchive.h"
#import "SPUDeltaArchiveProtocol.h"
-228
View File
@@ -1,228 +0,0 @@
//
// main.swift
// BinaryDelta
//
// Created by Mayur Pawashe on 1/3/22.
// Copyright © 2022 Sparkle Project. All rights reserved.
//
import Foundation
import ArgumentParser
// Create a patch from an old and new bundle
struct Create: ParsableCommand {
@Option(name: .long, help: ArgumentHelp("The major version of the patch to generate. Defaults to the latest stable version. Older versions will need to be specified for updating from applications using older versions of Sparkle.", valueName: "version"))
var version: Int = Int(SUBinaryDeltaMajorVersionDefault.rawValue)
@Flag(name: .customLong("verbose"), help: ArgumentHelp("Enable logging of the changes being archived into the generated patch."))
var verbose: Bool = false
@Option(name: .long, help: ArgumentHelp(COMPRESSION_METHOD_ARGUMENT_DESCRIPTION, valueName: "compression"))
var compression: String = "default"
@Option(name: .long, help: .hidden)
var compressionLevel: UInt8 = 0
@Argument(help: ArgumentHelp("Path to original bundle to create a patch from."))
var beforeTree: String
@Argument(help: ArgumentHelp("Path to new bundle to create a patch from."))
var afterTree: String
@Argument(help: ArgumentHelp("Path to new patch file to create."))
var patchFile: String
func validate() throws {
var validCompression: ObjCBool = false
let compressionMode = deltaCompressionModeFromDescription(compression, &validCompression)
guard validCompression.boolValue else {
fputs("Error: unrecognized compression \(compression)\n", stderr)
throw ExitCode(1)
}
switch compressionMode {
case SPUDeltaCompressionModeDefault:
fallthrough
case .none:
guard compressionLevel == 0 else {
fputs("Error: compression level must be 0 for compression \(compression)\n", stderr)
throw ExitCode(1)
}
break
case .bzip2:
guard compressionLevel >= 0 && compressionLevel <= 9 else {
fputs("Error: compression level \(compressionLevel) is not valid.\n", stderr)
throw ExitCode(1)
}
break
case .LZMA:
fallthrough
case .LZFSE:
fallthrough
case .LZ4:
fallthrough
case .ZLIB:
guard version >= 3 else {
fputs("Error: version \(version) patch files do not support compression \(compression)\n", stderr)
throw ExitCode(1)
}
guard compressionLevel == 0 else {
fputs("Error: compression level provided must be 0 for compression \(compression)\n", stderr)
throw ExitCode(1)
}
break
@unknown default:
fputs("Error: unrecognized compression \(compression)\n", stderr)
throw ExitCode(1)
}
guard version >= SUBinaryDeltaMajorVersionFirst.rawValue else {
fputs("Error: version provided \(version) is not valid.\n", stderr)
throw ExitCode(1)
}
guard version >= SUBinaryDeltaMajorVersionFirstSupported.rawValue else {
fputs("Error: creating version \(version) patches is no longer supported.\n", stderr)
throw ExitCode(1)
}
guard version <= SUBinaryDeltaMajorVersionLatest.rawValue else {
fputs("Error: this program is too old to create a version \(version) patch, or the version number provided is invalid.\n", stderr)
throw ExitCode(1)
}
let fileManager = FileManager.default
var isDirectory: ObjCBool = false
if !fileManager.fileExists(atPath: beforeTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
fputs("Error: before-tree must be a directory\n", stderr)
throw ExitCode(1)
}
if !fileManager.fileExists(atPath: afterTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
fputs("Error: after-tree must be a directory\n", stderr)
throw ExitCode(1)
}
}
func run() throws {
let compressionMode = deltaCompressionModeFromDescription(compression, nil)
guard let majorDeltaVersion = SUBinaryDeltaMajorVersion(rawValue: UInt16(version)) else {
// We shouldn't reach here
fputs("Error: failed to retrieve major version from provided version: \(version)\n", stderr)
throw ExitCode(1)
}
var createDiffError: NSError? = nil
if !createBinaryDelta(beforeTree, afterTree, patchFile, majorDeltaVersion, compressionMode, compressionLevel, verbose, &createDiffError) {
if let error = createDiffError {
fputs("\(error.localizedDescription)\n", stderr)
} else {
fputs("Error: Failed to create patch due to unknown reason.\n", stderr)
}
throw ExitCode(1)
}
}
}
// Apply a patch from an old bundle to generate a new bundle
struct Apply: ParsableCommand {
static let configuration = CommandConfiguration(abstract: "Apply a patch against an original bundle to generate a new bundle.")
@Flag(name: .customLong("verbose"), help: ArgumentHelp("Enable logging of changes being applied from the patch."))
var verbose: Bool = false
@Argument(help: ArgumentHelp("Path to original bundle to patch."))
var beforeTree: String
@Argument(help: ArgumentHelp("Path to new bundle to create."))
var afterTree: String
@Argument(help: ArgumentHelp("Path to patch file to apply."))
var patchFile: String
func validate() throws {
let fileManager = FileManager.default
var isDirectory: ObjCBool = false
if !fileManager.fileExists(atPath: beforeTree, isDirectory: &isDirectory) || !isDirectory.boolValue {
fputs("Error: before-tree must be a directory\n", stderr)
throw ExitCode(1)
}
if !fileManager.fileExists(atPath: patchFile, isDirectory: &isDirectory) || isDirectory.boolValue {
fputs("Error: patch-file must be a file\n", stderr)
throw ExitCode(1)
}
}
func run() throws {
var applyDiffError: NSError?
if (!applyBinaryDelta(beforeTree, afterTree, patchFile, verbose, { _ in }, &applyDiffError)) {
if let error = applyDiffError {
fputs("\(error.localizedDescription)\n", stderr)
} else {
fputs("Error: patch failed to apply for unknown reason\n", stderr)
}
throw ExitCode(1)
}
}
}
// Output information for BinaryDelta or from a patch file
struct Info: ParsableCommand {
@Argument(help: ArgumentHelp("Path to patch file to extract information from."))
var patchFile : String?
func run() throws {
if let patchFile = patchFile {
// Print version of patch file
var header: SPUDeltaArchiveHeader? = nil
let archive = SPUDeltaArchiveReadPatchAndHeader(patchFile, &header)
if let error = archive.error {
fputs("Error: Unable to open patch \(patchFile): \(error.localizedDescription)\n", stderr)
throw ExitCode(1)
}
if let header = header {
if header.majorVersion < SUBinaryDeltaMajorVersionFirst.rawValue {
fputs("Error: major version \(header.majorVersion) is invalid.\n", stderr)
throw ExitCode(1)
}
fputs("Patch version \(header.majorVersion).\(header.minorVersion)", stdout)
// Print out compression info only if it's available
// We can't get compression info from version 2 files
if header.compression != SPUDeltaCompressionModeDefault, let compressionDescription = deltaCompressionStringFromMode(header.compression) {
fputs(" using \(compressionDescription) compression", stdout)
// Compression level isn't available or applicable for all formats
if header.compressionLevel != 0 {
fputs(" with level \(header.compressionLevel)", stdout)
}
}
fputs("\n", stdout)
} else {
fputs("Error: Failed to retrieve header due to unknown reason.\n", stderr)
throw ExitCode(1)
}
} else {
// Print version of program
fputs("BinaryDelta version \(SUBinaryDeltaMajorVersionLatest.rawValue).\(latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersionLatest))\n", stdout)
}
}
}
struct BinaryDelta: ParsableCommand {
static let configuration = CommandConfiguration(commandName: "BinaryDelta", abstract: "Create and apply small and efficient delta patches between an old and new version of a bundle.", subcommands: [Create.self, Apply.self, Info.self])
}
DispatchQueue.global().async(execute: {
BinaryDelta.main()
CFRunLoopStop(CFRunLoopGetMain())
})
CFRunLoopRun()
+5 -228
View File
@@ -1,234 +1,11 @@
# 2.5.2
# 1.27.3
* Don't clean up update directory when Autoupdate receives SIGTERM (#2479) (Zorg)
* Update Japanese localization (#2475) (1024jp)
* Improve Turkish translations (#2464) (Emir SARI)
* Update Spanish translation for 'You are currently running version %@.' and 'Version History' (#2463) (Billy Gray)
* Create and use temp extraction directory in generate_appcast again (#2556) (Zorg)
# 2.5.1
# 1.27.2
* Default to English for XML nodes when no xml:lang is present (#2440) (Zorg)
* Filter for archive files in generate_appcast more intelligently (#2448) (Zorg)
* Use correct entitlements and dsym files when using custom bundle id and XPC names in ConfigCommon (#2446) (floorish)
# 2.5.0
* Add ability to adapt release notes based on the currently installed version (#2373) (Nathan Manceaux-Panot)
* Allow developers to use custom URL schemes in the release notes view (#2393) (Zorg)
* Adopt cooperative app activation APIs in macOS 14 Sonoma (#2409) (Zorg)
* Improve permission prompt layout (#2420) (Zorg)
* Remove hyphenation in "You're up to date" message (#2425) (Zorg, Dom Neill)
* Pre-warm installs before relaunch and resolve sporadic failures in CI (#2421) (Zorg)
* Fix make release not building distribution successfully (#2430) (Zorg)
* Fix Updater app not starting when running Sparkle as root (e.g. from CLI with sudo or a daemon) on macOS 14 Sonoma (#2432) (Zorg)
* Fix KVO usage for updaterController.updater.* (#2404) (Zorg)
* Replace CFUUID* with NSUUID (#2395) (Eitot)
* Report an error when detecting duplicate updates in generate_appcast (#2407) (Zorg)
* Improve error for rejecting xattr based code signing for delta updates (#2408) (Zorg)
* Fail gracefully when auxiliary tool cannot be located (#2436) (Zorg)
# 2.4.2
* Ignore release notes download when we shouldn't show release notes (#2381) (Zorg)
* Fix NSKeyedUnarchiver warning for not specifying keyed NSString class (#2381) (Zorg)
* Harden verification of Sparkle update download (#2392) (Zorg)
# 2.4.1
* Remove auxiliary apps and relocate symbols in SPM package to resolve missing AvailableLibraries warnings (#2356) (Zorg)
* Add -Wno-declaration-after-statement to silence warnings that only apply to pre-C99 (#2345) (Kent Sutherland)
* Fix compile error when setting SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE=0 (#2346) (Zorg)
* Improve how downloaded update is passed to the installer (#2359) (Zorg)
# 2.4.0
* Reduce code size
* Enable deployment postprocessing in Release to properly strip debug symbols and strip all non-global symbols (#2286, #2305) (Zorg)
* Remove duplicate Sparkle localization strings in Updater app (#2288) (Zorg)
* Optimize codebase for generated code size (less properties, direct methods, etc) (#2305) (Zorg)
* Add additional settings to `ConfigCommon.xcconfig` for disabling features
* Ask permission for automatically downloading and installing new updates (#2285) (Zorg)
* Add support for plain text release notes view that does not use web view (#2315) (Zorg)
* Update `SUVersionDisplay` to better customize and display how versions are shown (#2321) (Zorg)
* Add deprecations/warnings for incorrect background update checking usage (#2295) (Zorg)
* Deprecate `-[SPUUpdater setFeedURL:]` API and add `-[SPUUpdater clearFeedURLFromUserDefaults]` for migrating away from `-[SPUUpdater setFeedURL:]` (#2295)
* Trigger a new update check in `-[SPUUpdater resetUpdateCycle]` if the updater's feed or allowed channels have changed (#2324) (Zorg)
* Exit with an error if generate_appcast cannot sign an update that must be signed (#2322) (Zorg)
* Remove a redundant Apple code signing check when verifying new updates (#2341) (Zorg)
* Turn off auto-linking for XPC targets to alleviate circular dependency issues (#2332) (Daniel Jalkut)
# 2.3.2
* Fix potential crash during download if appcast item includes invalid enclosure URL (#2317) (Zorg)
* Add delegate method to hide showing version history option (#2303) (Zorg)
* Finnish localization grammar fixes (#2311) (Lauri-Matti Parppei)
# 2.3.1
* Fix update permission alert title text overlapping with question text in some languages (#2284) (Zorg)
* Log the URL that failed to download correctly (#2296) (Zorg)
* Update Czech translation (#2275) (Sam)
* Add zh_HK (Chinese, Hong Kong) localization (#2273) (Bing Zheung)
# 2.3.0
* Bump minimum deployment target to macOS 10.13 (#2196) (Zorg)
* Remove and preserve necessary updates in generate_appcast (#2218) (Zorg)
* Move old update files no longer needed to old_updates/ in archive directory in generate_appcast (#2228) (Zorg)
* Expose maximum-versions option (per branch) in generate_appcast to preserve in the feed (#2259) (Zorg)
* Add -p option to sign_update to only print the signed signature (#2268) (Zorg)
* Hide automatic install check box when allowsAutomaticUpdates is disabled (#2202) (Jie)
* Allow developer to always force allowing automatic updates (#2266) (Zorg)
* Fix update window going haywire during resize when release notes are hidden by disabling resizing (#2200) (Zorg)
* Allow user to re-try installing/relaunching application when quit is delayed/cancelled (#2234) (Zorg)
* Add delta update attributes for validating an app hasn't been stripped from removed localizations or architectures (#2219) (Zorg)
* Fix delta patches not applying edge case if files from source that need to be diffed are not writeable (#2211) (Zorg)
* Add delegate callback when user makes choice to install, dismiss, or skip an update (#2250) (Zorg)
* Reject serving updates with DSA only and no EdDSA (#2167) (Zorg)
* Find potential matching running apps that are translocated in the updater agent (#2233) (Zorg)
* Expose -[SPUStandardUserDriver activeUpdateAlert] as private API (#2255) (Zorg)
* Add zh_CN l10n for "Version History" (#2247) (kakaiikaka)
* Update zh_TW localization (#2271) (Chiahong)
* Remove ed25519 git submodule in favor of including the dependency directly (#2244) (Zorg)
* Clean up left-over code (#2243) (Eitot)
* Update Package.resolved (#2245) (Zorg)
* Remove model translation table for system profiling (#2188) (Zorg)
* Improve documentation usage for SPUUpdater properties (#2256) (Zorg)
This release improves generate_appcast by automatically removing updates that are no longer needed in the generated appcast, and moving old update files to old_updates/ in the archives directory. New delta update attributes are also added to let Sparkle know when to skip downloading delta updates if the application has been stripped.
macOS 10.13 or later is now required (due to Xcode 14 dropping support for deploying to older OS versions).
If you're not generating appcasts automatically, remember to add `<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>` element to `<item>`s in your appcast.
# 2.2.2
* Critical update alerts may not show up as promptly as they should when they are being automatically installed (#2230) (Zorg)
* Remove module imports from framework headers (#2217) (Zorg)
* Update Portuguese localization (#2224) (Kent Sutherland)
* Update zh_TW localization (#2246) (Chiahong)
# 2.2.1
* Make scroll bar dark in dark theme for Release Notes by default (#2187) (Pavel Moiseenko)
* Fix memory leaks when using generate_appcast (#2193) (Zorg)
* Update Italian localization (#2192) (VinBoiSoft)
# 2.2.0
* Update Focus Improvements (#924)
* Present new scheduled updates in utmost focus only at opportune times (Zorg)
* For regular apps opportune times are: app launch, app re-activation, and system being idle (without a power assertion being held to prevent display sleep).
* For background (dockless) apps opportune time is just app launch. Otherwise, the update is now shown behind other applications and windows, instead of previously stealing focus from other active apps.
* Add APIs and documentation for adding gentle update reminders to compliment Sparkle's standard user interface (Zorg) (#2122)
* Allow status window to be minimizable for regular app installs (Zorg) (#2100)
* Center status window and inherit key focus from the previously shown update alert window (Zorg)
* Activate app when checking for updates if the app is not currently active (e.g, from a menu bar extra menu item) (Zorg)
* Fix issue where bringing status window to front made other active windows exit in macOS Ventura's Stage Manager (#2153) (Zorg)
* Fix showing update in focus not bringing the "checking for updates" window in focus (Zorg) (#2150)
* Rename XPC Service filenames for Sandboxing to show more friendly human-readable name in authorization dialog (Zorg) (#2096)
* Add support for running the framework and sparkle-cli as root (Zorg) (#2119)
* Fix issue where update cycle may not complete in unusual configuration if automatic checks are disabled + automatic downloading is enabled + install requires user interaction (Zorg) (#2133)
* Synchronize usage of XPC connections to main queue to fix potential race conditions (Zorg) (#2178)
* Update last update check time when choosing to install an update & relaunch (Zorg) (#2136)
* Improve error reporting in the framework and sparkle-cli when installation fails with no write permission (Zorg) (#2157)
* Use displayVersionString instead of versionString for OS version mismatch error message (samschott) (#2138)
* Make displayVersionString non-null and update fallback documentation (Zorg) (#2139)
* Ignore custom icons set via resource forks when applying delta updates (Zorg) (#2114)
* Fall back to regular update if delta update fails to download (Zorg) (#2118)
* Skip downloading delta updates when application has been moved to a file system (like FAT) that doesn't support regular permission modes (Zorg) (#2148)
* Bump initial installer message timeouts and declare daemon/agents processes as Interactive (Zorg) (#2162)
* Add and improve translation strings and update pt-BR (BR Lingo) (#2094)
* Update localisations (Eitot) (#2113)
* Update Greek localizations (seitsme) (#2184, #2185)
* Update Japanese localization (1024jp) (#2182)
* Replace deprecated code with newer APIs (Eitot) (#2112)
* Remove obsolete fallbacks for older OS versions (Eitot) (#2110)
* Remove SPUURLRequest (Zorg) (#2124)
* Silence ivar deprecation warnings (Zorg) (#2099)
* Fix Xcode 14 project warnings (Zorg) (#2147, #2179)
* Deprecate -s flag and add --ed-key-file option to generate_appcast (Zorg) (#2170)
* Update text for external licenses (Zorg) (#2164)
This update renames the bundled XPC Services, brings improvements to notifying users of new updates without disrupting their focus, and adds [gentle update reminder APIs](https://sparkle-project.org/documentation/gentle-reminders/) to further customize how Sparkle's standard user interface delivers new update alerts.
The `-s` flag for passing a raw private EdDSA key to sign_update and generate_appcast is now deprecated. If you were using this option previously, please see the help pages of these tools for more information.
# 2.1.0
* New Binary Delta format (version 3)
* Features a custom and more efficient container format, migrating away from the deprecated xar format (Zorg) (#2051)
* Adds delta compression options for lzma, bzip2, zlib, lzfse, lz4, and no compression (Zorg) (#2051)
* Changes default delta format compression from bzip2 (in version 2) to lzma (in version 3) resulting in smaller deltas (Zorg) (#2051)
* Preserve file system (HFS+/apfs) level compression when applying delta updates (Zorg) (#2084)
* Tracks renames and binary diffs for files that have moved around to new locations using intelligent heuristics (Zorg) (#2051, #2053)
* Added more unit tests, UI tests, and generate_appcast/BinaryDelta tools support for the new format (Zorg) (#2052, #2054)
* Major upgrade improvements (#2070)
* Fix skipping a major version to not skip subsequent major versions (Zorg) (#2079)
* Add sparkle:belowVersion element for informational updates (Zorg) (#2080)
* Add option to allow developers to ignore/reset user skipped upgrades (Zorg) (#2081)
* Fix progress bar and button alignment for checking updates (Zorg) (#2066)
* This deprecates `-[SPUUserDriver showInstallingUpdate]` and `-[SPUUserDriver showSendingTerminationSignal]` in favor for `-[SPUUserDriver showInstallingUpdateWithApplicationTerminated:]`
* Fix unsteady progress when installing updates (Zorg) (#2072)
* Check http statusCode in didFinishDownloadingToURL (Eric Shapiro, Zorg) (#2049, #2073)
* Use strcoll_l() for locale-independent comparisons for delta updates (Dan Rigdon-Bel) (#2087)
* Fix version compare not treating '2.1.0' and '2.1' as being equal (Zorg) (#2065)
* Add verify and account options for signing updates (Zorg) (#2074)
* Add delta patch and Apple code signing verification in generate_appcast (Zorg) (#2076, #2077)
* Use more modern NSSecureCoding APIs when available (Zorg) (#2058)
* Use more modern FileManager APIs for copying files (Zorg) (#2059)
* Fix make release failing when customizing XPC_SERVICE_BUNDLE_ID_PREFIX (Zorg) (#2060)
* Preserve the Entitlements directory in podspec (digitalMoksha) (#2062)
* Add hidden option to generate_appcast to set max CDATA threshold (Zorg) (#2075)
This update introduces a new major format for [delta updates](https://sparkle-project.org/documentation/delta-updates/), which migrates away from deprecated APIs (xar) and creates smaller patches. If you don't use `generate_appcast`, please check the [compatibility notes for creating delta updates](https://sparkle-project.org/documentation/delta-updates/#compatibility).
# 2.0.0
* Support for Sandboxed Applications (Zorg)
* Support for writing custom user interfaces (Zorg)
* Support for updating external Sparkle-based bundles (Zorg)
* Added command line utility to update Sparkle-based bundles (Zorg)
* Modern architecture
* Moves extraction, validation, and installation into a submitted launchd agent/daemon with XPC communication (Zorg)
* Features faster installs with shorter update/relaunch times (#1802) (Zorg)
* Provides more robust installs when user authorization is needed (Zorg)
* Adoption of improved atomic-safe updates leveraging APFS (#1801) (Zorg)
* API Changes
* Introduced new SPUStandardUpdaterController, SPUUpdater, SPUUserDriver classes/protocols (Zorg)
* Decoupled AppKit and UI logic in the framework from core functionality (Zorg)
* Ensure (most) API compatibility with Sparkle 1; you can likely test Sparkle 2 in an existing app with little to no changes (Zorg)
* Deprecated SUUpdater, albeit it is still functional for testing and transitional purposes (Zorg)
* `-bestValidUpdateInAppcast:forUpdater:` delegate method behavior has been refined and discouraged for some cases. Please review its updated header documentation in `SPUUpdaterDelegate.h` if you use this method. (#1838, #1862, #1879, #1880) (Zorg)
* Delegation methods may have been removed or added to the newer updater API. Please review `SPUUpdaterDelegate` if using `SPUUpdater`. (Zorg)
* Updater Changes
* Automatic silent and manual update alert prompts are now merged together (Zorg)
* Updates will attempt to install even if the user quits the application without relaunching the application update explicitly (Zorg)
* Updates can be downloaded in the background automatically but later prompt the user to install them, particularly if Sparkle doesn't have sufficient permission to install them without the user's permission (Zorg)
* Authorization now occurs before launching the installer and before terminating the application, which can be canceled by the user cleanly (Zorg)
* Sparkle uses the icon of the bundle to update for its authorization dialog. A 32x32 image representation of the icon is needed. (Zorg)
* Sudden termination for silent automatic updates isn't disabled anymore (Zorg)
* Policy Changes
* Non-bare package based updates that are zipped or archived must add sparkle:installationType="package" to the appcast item enclosure (this doesn't apply to bare packages which aren't archived) (Zorg)
* We now recommend using sparkle:version and sparkle:shortVersionString top level elements instead of enclosure attributes (#1878) (Zorg)
* The link element in an appcast item is now used for directing users to the product's website if they don't meet minimum system requirements (#1877) (Zorg)
* Expose why a new update is unavailable and direct user to prior release notes or website info (#1877, #1886) (Zorg)
* Add <sparkle:fullReleaseNotesLink> element allowing Sparkle to show a better stylized and full changelog to the user (#2001) (aONe)
* Add delegate API allowing applications to show full in-app or offline version history to the user (#1989) (Billy Gray)
* Major/Paid Upgrades Enhancements
* Latest minor updates are preferred over major updates (specified by sparkle:minimumAutoupdateVersion) (#1850) (Zorg)
* Major updates can be skipped with a user confirmation (#1853) (Zorg)
* Informational only and critical updates can be specified selectively by app version (#1862)
* Add support for posting updates only on specific channels (eg for supporting beta updates) (#1879) (Zorg)
* System profiler privacy and transparency (#1690) (Martin Pilkington)
* Support getting app icon from asset catalog (#1694) (Charles Srstka)
* Don't bring up authorization just because group ID doesn't match (#1830) (Zorg)
* Raise minimum system version to macOS 10.11 (Zorg)
* Special thanks to developers using early builds of this release in production and contributors for keeping this running (Kornel, Jonas Zaugg, Gwynne Raskind, Jordan Rose, Tony Arnold, Bryan Jones, Christian Tietze, Jakob Egger, and many more)
Please visit [Sparkle's website](http://sparkle-project.org) for more information on documentation and migration.
If you are migrating from earlier beta versions of Sparkle 2 and use sandboxing, please re-familiarize yourself with the [Sandboxing guide](https://sparkle-project.org/documentation/sandboxing/). Some of the XPC Services are now optional and integration with XPC Services and code signing have been simplified. The SPUUserDriver protocol for custom user interfaces has been greatly simplified too.
* Extract archives in a separate directory from the input archive (#2552) (Zorg)
* Fix incorrect xz log warning in make release (#2044) (trss)
# 1.27.1
-1
View File
@@ -1 +0,0 @@
{"1.27.1": "https://github.com/sparkle-project/Sparkle/releases/download/1.27.1/Sparkle-1.27.1.tar.xz", "2.0.0-beta.6": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-beta.6/Sparkle-2.0.0-beta.6.tar.xz", "2.0.0-rc.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-rc.1/Sparkle-2.0.0-rc.1.tar.xz", "2.0.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0/Sparkle-2.0.0.tar.xz", "2.1.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.1/Sparkle-2.1.0-beta.1.tar.xz", "2.1.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0-beta.2/Sparkle-2.1.0-beta.2.tar.xz", "2.1.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0/Sparkle-2.1.0.tar.xz", "2.2.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.1/Sparkle-2.2.0-beta.1.tar.xz", "2.2.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0-beta.2/Sparkle-2.2.0-beta.2.tar.xz", "2.2.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.0/Sparkle-2.2.0.tar.xz", "2.2.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.1/Sparkle-2.2.1.tar.xz", "2.2.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.2.2/Sparkle-2.2.2.tar.xz", "2.3.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.1/Sparkle-2.3.0-beta.1.tar.xz", "2.3.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.2/Sparkle-2.3.0-beta.2.tar.xz", "2.3.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0/Sparkle-2.3.0.tar.xz", "2.3.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.1/Sparkle-2.3.1.tar.xz", "2.3.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.3.2/Sparkle-2.3.2.tar.xz", "2.4.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.1/Sparkle-2.4.0-beta.1.tar.xz", "2.4.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0-beta.2/Sparkle-2.4.0-beta.2.tar.xz", "2.4.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.0/Sparkle-2.4.0.tar.xz", "2.4.1-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.1-beta.1/Sparkle-2.4.1-beta.1.tar.xz", "2.4.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.1/Sparkle-2.4.1.tar.xz", "2.4.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.4.2/Sparkle-2.4.2.tar.xz", "2.5.0-beta.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.5.0-beta.1/Sparkle-2.5.0-beta.1.tar.xz", "2.5.0-beta.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.5.0-beta.2/Sparkle-2.5.0-beta.2.tar.xz", "2.5.0": "https://github.com/sparkle-project/Sparkle/releases/download/2.5.0/Sparkle-2.5.0.tar.xz", "2.5.1": "https://github.com/sparkle-project/Sparkle/releases/download/2.5.1/Sparkle-2.5.1.tar.xz", "2.5.2": "https://github.com/sparkle-project/Sparkle/releases/download/2.5.2/Sparkle-2.5.2.tar.xz"}
@@ -1,6 +0,0 @@
// Generate Appcast only
#include "ConfigSwift.xcconfig"
SWIFT_OBJC_BRIDGING_HEADER = $(PRODUCT_NAME)/Bridging-Header.h
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_EXTERNALLY=1
@@ -0,0 +1 @@
// BinaryDelta tool only
@@ -0,0 +1,2 @@
#include "ConfigBinaryDelta.xcconfig"
@@ -0,0 +1 @@
#include "ConfigBinaryDelta.xcconfig"
+25 -91
View File
@@ -1,124 +1,55 @@
// Common
// Set to 1 or 0 to build and bundle the provided XPC Services in Sparkle framework
// (Note for testing purposes for sandboxed apps, disabling all XPC services and then re-enabling them
// may not work on the same login session due to a system caching issue. See comments for setting FRAMEWORK_VERSION for more info)
SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE = 1
// Embedding the downloader service also enables building legacy WebKit1 support
SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE = 1
SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE = 0
SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE = 0
// Set to 0 to disable building legacy 1.x SUUpdater stub
SPARKLE_BUILD_LEGACY_SUUPDATER = 1
// Set to 0 to not build legacy DSA signing support
// Don't disable this if you haven't migrated to EdDSA yet or if you support updating
// other developer's applications that haven't migrated to EdDSA yet
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
SPARKLE_BUILD_LEGACY_DSA_SUPPORT = 1
// Set to 0 to not build legacy DSA signing support for generate_appcast
// Don't disable this if you still have items in your appcast feed that still need DSA signatures
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT = 1
// Set to 0 to not build legacy / xar based delta update support
SPARKLE_BUILD_LEGACY_DELTA_SUPPORT = 1
// Set to 0 to not build bzip2 support for version 3 delta based updates
SPARKLE_BUILD_BZIP2_DELTA_SUPPORT = 1
// Set to 0 to not build support for package (pkg) based installations
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
SPARKLE_BUILD_PACKAGE_SUPPORT = 1
// Set to 0 to not build support for extracting updates from disk images (dmgs)
// If this is disabled, this requires an update to OTHER_SWIFT_FLAGS_COMMON below
SPARKLE_BUILD_DMG_SUPPORT = 1
// Set to 0 to only build all non-UI bits (which means client uses a custom SPUUserDriver)
SPARKLE_BUILD_UI_BITS = 1
// Set to 0 to not use and copy localization / string files to framework
SPARKLE_COPY_LOCALIZATIONS = 1
// Compilation flags for Swift tools and unit tests
// If SPARKLE_BUILD_LEGACY_DELTA_SUPPORT is set to 0, remove -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT
// If GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT is set to 0, remove -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT
// If SPARKLE_BUILD_PACKAGE_SUPPORT is set to 0, remove -DSPARKLE_BUILD_PACKAGE_SUPPORT
// If SPARKLE_BUILD_DMG_SUPPORT is set to 0, remove -DSPARKLE_BUILD_DMG_SUPPORT
OTHER_SWIFT_FLAGS_COMMON = -DSPARKLE_BUILD_LEGACY_DSA_SUPPORT -DGENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT -DSPARKLE_BUILD_PACKAGE_SUPPORT -DSPARKLE_BUILD_DMG_SUPPORT
// Minimum supported macOS version
MACOSX_DEPLOYMENT_TARGET = 10.13
// Supported architectures
ARCHS = $(ARCHS_STANDARD)
// Default Sparkle names
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
SPARKLE_INSTALLER_PROGRESS_TOOL_NAME = Updater
SPARKLE_INSTALLER_PROGRESS_TOOL_BUNDLE_ID = $(SPARKLE_BUNDLE_IDENTIFIER).$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)
SPARKLE_FILEOP_TOOL_NAME = fileop
// Set these if you want to use custom name for the XPC Services
// For the Installer one in particular, this name may show up in an authorization prompt
// when installing an update that requires authorization.
INSTALLER_CONNECTION_NAME = InstallerConnection
INSTALLER_STATUS_NAME = InstallerStatus
INSTALLER_LAUNCHER_NAME = Installer
DOWNLOADER_NAME = Downloader
SPARKLE_APPEND_VERSION_NUMBER = 1
// Set this to your own prefix if you want to use XPC Service bundle IDs with different prefix
XPC_SERVICE_BUNDLE_ID_PREFIX = org.sparkle-project
INSTALLER_CONNECTION_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerConnection
INSTALLER_STATUS_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerStatus
INSTALLER_LAUNCHER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerLauncher
DOWNLOADER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.Downloader
// 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"
// If you are using this option to change the name of your app, you should
// disable the option again when you no longer need it
// Note this option is only supported for regular application updates and not plug-ins
// following on to always reset the name back to "MyApp":
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_ICON_NAME = AppIcon
// If you change any of these version details, you must increase CURRENT_PROJECT_VERSION
// These variables must have a space after the '=' too
SPARKLE_VERSION_MAJOR = 2
SPARKLE_VERSION_MINOR = 5
SPARKLE_VERSION_PATCH = 2
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 27
SPARKLE_VERSION_PATCH = 3
// This should be in SemVer format or empty, ie. "-beta.1"
// This should be in SemVer format or empty, ie. "-rc.1"
// These variables must have a space after the '=' too
SPARKLE_VERSION_SUFFIX =
CURRENT_PROJECT_VERSION = 2033
// This is now a monotonically increasing ID number, even across prereleases, but let's keep this below 2.0
CURRENT_PROJECT_VERSION = 1.108
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
ALWAYS_SEARCH_USER_PATHS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 10.9
PRODUCT_NAME = ${TARGET_NAME}
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPU_OBJC_DIRECT=__attribute__((objc_direct)) SPU_OBJC_DIRECT_MEMBERS=__attribute__((objc_direct_members)) SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_COPY_LOCALIZATIONS=$(SPARKLE_COPY_LOCALIZATIONS) SPARKLE_BUILD_LEGACY_SUUPDATER=$(SPARKLE_BUILD_LEGACY_SUUPDATER) SPARKLE_BUILD_PACKAGE_SUPPORT=$(SPARKLE_BUILD_PACKAGE_SUPPORT) SPARKLE_BUILD_DMG_SUPPORT=$(SPARKLE_BUILD_DMG_SUPPORT) SPARKLE_BUILD_LEGACY_DELTA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DELTA_SUPPORT) SPARKLE_BUILD_BZIP2_DELTA_SUPPORT=$(SPARKLE_BUILD_BZIP2_DELTA_SUPPORT) SPARKLE_BUILD_LEGACY_DSA_SUPPORT=$(SPARKLE_BUILD_LEGACY_DSA_SUPPORT) GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT=$(GENERATE_APPCAST_BUILD_LEGACY_DSA_SUPPORT) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" MARKETING_VERSION=\"$(MARKETING_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_BUNDLE_ID=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_BUNDLE_ID)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_NAME=\"${INSTALLER_LAUNCHER_NAME}\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_LAUNCHER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE) INSTALLER_CONNECTION_NAME=\"${INSTALLER_CONNECTION_NAME}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_CONNECTION_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE) INSTALLER_STATUS_NAME=\"${INSTALLER_STATUS_NAME}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" INSTALLER_STATUS_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE) DOWNLOADER_NAME=\"${DOWNLOADER_NAME}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\" DOWNLOADER_XPC_SERVICE_EMBEDDED=$(SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE)
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" MARKETING_VERSION=\"$(MARKETING_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
CODE_SIGN_IDENTITY = -
SDKROOT = macosx
ENABLE_HARDENED_RUNTIME = YES
ENABLE_HARDENED_RUNTIME = YES;
CLANG_ENABLE_OBJC_ARC = YES
GCC_ENABLE_PASCAL_STRINGS = NO
GCC_NO_COMMON_BLOCKS = YES
COMBINE_HIDPI_IMAGES = NO
GCC_NO_COMMON_BLOCKS = YES;
COMBINE_HIDPI_IMAGES = NO;
// Enable warnings
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
@@ -134,7 +65,7 @@ CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
@@ -161,5 +92,8 @@ GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_UNUSED_VARIABLE = YES
// These should be removed once the conversion to ARC is complete
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso -Wno-direct-ivar-access -Wno-declaration-after-statement -Werror=undef
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-format-non-iso $(WARNING_CFLAGS_EXTRA)
@@ -1,13 +0,0 @@
#include "ConfigCommonDebug.xcconfig"
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_GENERATE_TEST_COVERAGE_FILES = YES
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
@@ -13,6 +13,5 @@ DEBUG_INFORMATION_FORMAT = dwarf
ENABLE_TESTABILITY = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
ONLY_ACTIVE_ARCH = YES
COPY_PHASE_STRIP = NO
+1 -3
View File
@@ -11,10 +11,8 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_OPTIMIZATION_LEVEL = s
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=0
OTHER_SWIFT_FLAGS = $(OTHER_SWIFT_FLAGS_COMMON)
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON)
DEAD_CODE_STRIPPING = YES
GCC_TREAT_WARNINGS_AS_ERRORS = NO
GCC_WARN_UNINITIALIZED_AUTOS = YES
COPY_PHASE_STRIP = NO
DEPLOYMENT_POSTPROCESSING = YES
-9
View File
@@ -1,9 +0,0 @@
// Downloader
INFOPLIST_FILE = Downloader/Info.plist
WRAPPER_EXTENSION = xpc
PRODUCT_BUNDLE_IDENTIFIER = ${DOWNLOADER_BUNDLE_ID}
PRODUCT_NAME = ${DOWNLOADER_NAME}
CODE_SIGN_ENTITLEMENTS = Downloader/org.sparkle-project.Downloader.entitlements
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
CLANG_MODULES_AUTOLINK = NO
@@ -1,2 +0,0 @@
// Downloader Debug
#include "ConfigDownloader.xcconfig"
+5
View File
@@ -0,0 +1,5 @@
// Fileop tool only
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
SKIP_INSTALL = YES
CLANG_ENABLE_MODULES = NO
+2 -14
View File
@@ -4,22 +4,10 @@ DYLIB_INSTALL_NAME_BASE = @rpath
DYLIB_COMPATIBILITY_VERSION = 1.6
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
WRAPPER_EXTENSION = framework
// Sparkle 2 used to support developers embedding XPC Services in their own app bundle
// However the Sparkle framework now bundles these XPC Services. Unfortunately this causes
// a cache conflict in the system from upgrading from previous to newer versions of Sparkle, and
// XPC Services inside Sparkle may not launch (a system reboot would fix this though).
// The system cache seems to depend on the Sparkle file path,
// so as a better workaround we have changed the FRAMEWORK_VERSION from A to B
FRAMEWORK_VERSION = B
FRAMEWORK_VERSION = A
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
SKIP_INSTALL = YES
DEFINES_MODULE = YES
PRODUCT_BUNDLE_IDENTIFIER = ${SPARKLE_BUNDLE_IDENTIFIER}
// As long as we don't ourselves depend upon any Frameworks that are incompatible
// with Application Extensions, then we should allow frameworks that require
// compatibility to be able to link with us.
APPLICATION_EXTENSION_API_ONLY = YES
@@ -1,4 +1,2 @@
#include "ConfigFramework.xcconfig"
// Strip all non-global symbols (including debug symbols)
STRIP_STYLE = non-global
@@ -0,0 +1,7 @@
// Generate Appcast only
#include "ConfigSwift.xcconfig"
SWIFT_OBJC_BRIDGING_HEADER = generate_appcast/Appcast-Bridging-Header.h
MACOSX_DEPLOYMENT_TARGET = 10.11
PRODUCT_NAME = generate_appcast
@@ -1,4 +1,4 @@
// Generate Appcast Debug
#include "CommandLineTool-Shared.xcconfig"
#include "ConfigGenerateAppcast.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
@@ -1,4 +1,4 @@
// Generate Appcast Release
#include "CommandLineTool-Shared.xcconfig"
#include "ConfigGenerateAppcast.xcconfig"
#include "ConfigSwiftRelease.xcconfig"
@@ -0,0 +1,7 @@
// Generate Appcast only
#include "ConfigSwift.xcconfig"
SWIFT_OBJC_BRIDGING_HEADER = generate_keys/Bridging-Header.h
MACOSX_DEPLOYMENT_TARGET = 10.11
PRODUCT_NAME = generate_keys
@@ -0,0 +1,4 @@
// Generate Appcast Debug
#include "ConfigGenerateKeys.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
@@ -0,0 +1,4 @@
// Generate Appcast Release
#include "ConfigGenerateKeys.xcconfig"
#include "ConfigSwiftRelease.xcconfig"
@@ -1,8 +0,0 @@
// InstallerConnection
INFOPLIST_FILE = InstallerConnection/Info.plist
WRAPPER_EXTENSION = xpc
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_CONNECTION_BUNDLE_ID}
PRODUCT_NAME = ${INSTALLER_CONNECTION_NAME}
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
CLANG_MODULES_AUTOLINK = NO
@@ -1,3 +0,0 @@
// InstallerConnection Debug
#include "ConfigInstallerConnection.xcconfig"
@@ -1,8 +0,0 @@
// Installer Launcher
INFOPLIST_FILE = InstallerLauncher/Info.plist
WRAPPER_EXTENSION = xpc
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_LAUNCHER_BUNDLE_ID}
PRODUCT_NAME = ${INSTALLER_LAUNCHER_NAME}
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
CLANG_MODULES_AUTOLINK = NO
@@ -1,2 +0,0 @@
// Installer Launcher Debug
#include "ConfigInstallerLauncher.xcconfig"
@@ -1,8 +0,0 @@
// Installer Progress only
INFOPLIST_FILE = Sparkle/InstallerProgress/InstallerProgress-Info.plist
PRODUCT_NAME = $(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)
PRODUCT_BUNDLE_IDENTIFIER = $(SPARKLE_INSTALLER_PROGRESS_TOOL_BUNDLE_ID)
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
SKIP_INSTALL = YES
CLANG_ENABLE_MODULES = NO
@@ -1,8 +0,0 @@
// InstallerStatus
INFOPLIST_FILE = InstallerStatus/Info.plist
WRAPPER_EXTENSION = xpc
PRODUCT_BUNDLE_IDENTIFIER = ${INSTALLER_STATUS_BUNDLE_ID}
PRODUCT_NAME = ${INSTALLER_STATUS_NAME}
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE=0 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
CLANG_MODULES_AUTOLINK = NO
@@ -1,3 +0,0 @@
// InstallerStatus Debug
#include "ConfigInstallerStatus.xcconfig"
+3 -1
View File
@@ -1,6 +1,8 @@
// Relaunch Tool only
INFOPLIST_FILE = Sparkle/Autoupdate/Autoupdate-Info.plist
PRODUCT_NAME = $(SPARKLE_RELAUNCH_TOOL_NAME)
SKIP_INSTALL = YES
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_MODULES = NO
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
@@ -0,0 +1 @@
#include "ConfigRelaunch.xcconfig"
@@ -0,0 +1 @@
#include "ConfigRelaunch.xcconfig"
@@ -1,7 +0,0 @@
// sparkle command line tool only
INFOPLIST_FILE = sparkle-cli/Info.plist
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.sparkle-cli
PRODUCT_NAME = sparkle
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks/
ENABLE_HARDENED_RUNTIME = NO
+1 -1
View File
@@ -1,2 +1,2 @@
SWIFT_VERSION = 5
SWIFT_VERSION = 4.2
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
+1 -2
View File
@@ -1,2 +1 @@
SWIFT_OPTIMIZATION_LEVEL = -O
SWIFT_COMPILATION_MODE = wholemodule
SWIFT_OPTIMIZATION_LEVEL = -Owholemodule
+3 -3
View File
@@ -1,9 +1,9 @@
// Test Application
// Test Application only
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
WRAPPER_EXTENSION = app
ASSETCATALOG_COMPILER_APPICON_NAME = $(SPARKLE_ICON_NAME)
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
CODE_SIGN_ENTITLEMENTS = TestApplication/Sparkle-Test-App.entitlements
ENABLE_HARDENED_RUNTIME = NO
CODE_SIGN_IDENTITY = -
+1 -1
View File
@@ -1,2 +1,2 @@
// Test Application Debug
#include "ConfigTestApp.xcconfig"
@@ -1,7 +0,0 @@
// Test Application Helper
INFOPLIST_FILE = TestAppHelper/Info.plist
WRAPPER_EXTENSION = xpc
LD_RUNPATH_SEARCH_PATHS = @executable_path/../../../../Frameworks
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.TestAppHelper
ENABLE_HARDENED_RUNTIME = NO
@@ -1,2 +0,0 @@
// Test Application Helper Debug
#include "ConfigTestAppHelper.xcconfig"
@@ -0,0 +1 @@
#include "ConfigTestApp.xcconfig"
+1
View File
@@ -4,6 +4,7 @@
INFOPLIST_FILE = UITests/UITests-Info.plist
WRAPPER_EXTENSION = xctest
MACOSX_DEPLOYMENT_TARGET = 10.11
ENABLE_HARDENED_RUNTIME = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
@@ -1,5 +0,0 @@
#include "ConfigUITest.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
+1 -1
View File
@@ -9,6 +9,6 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO
WARNING_CFLAGS = $(inherited) -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments
FRAMEWORK_SEARCH_PATHS = $(inherited) $(DEVELOPER_FRAMEWORKS_DIR)
LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks
MACOSX_DEPLOYMENT_TARGET = 10.9
CLANG_ENABLE_MODULES = YES
SWIFT_OBJC_BRIDGING_HEADER = Tests/Sparkle Unit Tests-Bridging-Header.h
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) BUILDING_SPARKLE_TESTS=1 BUILDING_SPARKLE_SOURCES_EXTERNALLY=1
@@ -1,5 +0,0 @@
#include "ConfigUnitTest.xcconfig"
#include "ConfigSwiftDebug.xcconfig"
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
-3
View File
@@ -1,6 +1,3 @@
// Copyright © 2019 Sparkle Project. All rights reserved.
#include "bsdiff-Shared.xcconfig"
// Disable asserts for performance
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) NDEBUG=1
-3
View File
@@ -12,6 +12,3 @@ ALWAYS_SEARCH_USER_PATHS = NO
// Disable Warnings - this is a third-party project, and we'll trust that the maintainers know what they're doing.
WARNING_CFLAGS = $(inherited) -Wno-cast-qual -Wno-conversion -Wno-sign-conversion
// Disable dead stores analyzer warning
CLANG_ANALYZER_DEADCODE_DEADSTORES = NO
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh
# If Carthage is trying to build us, it won't preserve code signing information from our bundled tools properly
# Building Sparkle from source with Carthage is thus not supported
if [ "$CARTHAGE" = "YES" ]; then
echo "Error: Building Sparkle from source using Carthage is not supported. Please visit https://sparkle-project.org/documentation/ for proper Carthage integration."
exit 1
fi
# Create symlinks to our helper tools in Sparkle framework bundle
# so URLForAuxiliaryExecutable: will pick up the tools. Doing this is supported in the Code Signing in Depth guide.
FRAMEWORK_PATH="${TARGET_BUILD_DIR}"/"${FULL_PRODUCT_NAME}"
ln -h -f -s "Versions/Current/""${SPARKLE_RELAUNCH_TOOL_NAME}" "${FRAMEWORK_PATH}"/"${SPARKLE_RELAUNCH_TOOL_NAME}"
ln -h -f -s "Versions/Current/""${SPARKLE_INSTALLER_PROGRESS_TOOL_NAME}".app "${FRAMEWORK_PATH}"/"${SPARKLE_INSTALLER_PROGRESS_TOOL_NAME}".app
+41 -82
View File
@@ -5,7 +5,6 @@ set -e
# This guards against our archives being corrupt / created incorrectly.
function verify_code_signatures() {
verification_directory="$1"
check_aux_apps="$2"
if [[ -z "$verification_directory" ]]; then
echo "Provided verification directory does not exist" >&2
@@ -14,11 +13,7 @@ function verify_code_signatures() {
# Search the current directory for all instances of the framework to verify them (XCFrameworks can have multiple copies of a framework for different platforms).
find "${verification_directory}" -name "Sparkle.framework" -type d -exec codesign --verify -vvv --deep {} \;
if [ "$check_aux_apps" = true ] ; then
codesign --verify -vvv --deep "${verification_directory}/sparkle.app"
codesign --verify -vvv --deep "${verification_directory}/Sparkle Test App.app"
fi
codesign --verify -vvv --deep "${verification_directory}/Sparkle Test App.app"
codesign --verify -vvv --deep "${verification_directory}/bin/BinaryDelta"
codesign --verify -vvv --deep "${verification_directory}/bin/generate_appcast"
codesign --verify -vvv --deep "${verification_directory}/bin/sign_update"
@@ -34,52 +29,28 @@ if [ "$ACTION" = "" ] ; then
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm"
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/INSTALL" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/INSTALL" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging-spm"
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging-spm"
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging-spm"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.xcframework" "$CONFIGURATION_BUILD_DIR/staging-spm"
if [[ "$SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE" -eq 1 ]]; then
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Entitlements"
mkdir -p "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements"
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging/Entitlements/$DOWNLOADER_NAME.entitlements"
cp -R "$SRCROOT/Downloader/org.sparkle-project.Downloader.entitlements" "$CONFIGURATION_BUILD_DIR/staging-spm/Entitlements/$DOWNLOADER_NAME.entitlements"
fi
mkdir -p "$CONFIGURATION_BUILD_DIR/staging/Symbols"
# Only copy dSYMs for Release builds, but don't check for the presence of the actual files
# because missing dSYMs in a release build SHOULD trigger a build failure
if [ "$CONFIGURATION" = "Release" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/sparkle.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/Autoupdate.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/Updater.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/${INSTALLER_LAUNCHER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/${DOWNLOADER_NAME}.xpc.dSYM" "$CONFIGURATION_BUILD_DIR/staging/Symbols"
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging-spm"
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
fi
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
@@ -113,51 +84,43 @@ if [ "$ACTION" = "" ] ; then
# Test code signing validity of the extracted products
# This guards against our archives being corrupt / created incorrectly
verify_code_signatures "/tmp/sparkle-extract" true
verify_code_signatures "/tmp/sparkle-extract"
rm -rf "/tmp/sparkle-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
# Generate zip containing the xcframework for SPM
rm -rf "/tmp/sparkle-spm-extract"
mkdir -p "/tmp/sparkle-spm-extract"
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
# rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"
# Test code signing validity of the extracted Swift package
# This guards against our archives being corrupt / created incorrectly
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
verify_code_signatures "/tmp/sparkle-spm-extract"
rm -rf "/tmp/sparkle-spm-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
# Get latest git tag
cd "$SRCROOT"
latest_git_tag=$( git describe --tags --abbrev=0 || true )
latest_git_tag=$(git describe --tags --abbrev=0)
if [ -n "$latest_git_tag" ] ; then
# Generate zip containing the xcframework for SPM
rm -rf "/tmp/sparkle-spm-extract"
mkdir -p "/tmp/sparkle-spm-extract"
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
# rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"
# Test code signing validity of the extracted Swift package
# This guards against our archives being corrupt / created incorrectly
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
verify_code_signatures "/tmp/sparkle-spm-extract" false
rm -rf "/tmp/sparkle-spm-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
cd "$SRCROOT"
# Check semantic versioning
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Tag $latest_git_tag follows semantic versioning"
else
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
exit 1
fi
# Generate new Package manifest, podspec, and carthage files
cd "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Carthage-dev.json" "$CONFIGURATION_BUILD_DIR"
# Check semantic versioning
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Tag $latest_git_tag follows semantic versioning"
else
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
exit 1
fi
if [ -z "$latest_git_tag" ] ; then
echo "warning: No git repository found so skipping updating package management files"
elif [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
# Generate new Package manifest and podspec
cd "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
# is equivalent to shasum -a 256 FILE
spm_checksum=$(swift package compute-checksum "Sparkle-for-Swift-Package-Manager.zip")
rm -rf ".build"
@@ -169,12 +132,8 @@ if [ "$ACTION" = "" ] ; then
echo "Checksum: $spm_checksum"
sed -E -i '' -e "/s\.version.+=/ s/\".+\"/\"$MARKETING_VERSION\"/" "Sparkle.podspec"
"$SRCROOT/Configurations/update-carthage.py" "Carthage-dev.json" "$MARKETING_VERSION"
cp "Sparkle.podspec" "$SRCROOT"
# Note the Carthage-dev.json file will finally be copied to the website repo in Carthage/Sparkle.json in the end
cp "Carthage-dev.json" "$SRCROOT"
echo "Sparkle.podspec and Carthage-dev.json updated with following values:"
echo "Sparkle.podspec updated with following values:"
echo "Version: $MARKETING_VERSION"
else
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
-15
View File
@@ -1,15 +0,0 @@
#!/bin/bash
# Deleting old products
rm -rd "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive"
rm -rd "$BUILT_PRODUCTS_DIR/Sparkle.xcframework"
xcodebuild archive -scheme Sparkle -archivePath "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
if [ $XCODE_VERSION_MAJOR -ge "1200" ]; then
xcodebuild -create-xcframework -framework "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/Products/Library/Frameworks/Sparkle.framework" -debug-symbols "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Sparkle.framework.dSYM" -debug-symbols "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Autoupdate.dSYM" -debug-symbols "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Updater.app.dSYM" -debug-symbols "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/$INSTALLER_LAUNCHER_NAME.xpc.dSYM" -debug-symbols "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/$DOWNLOADER_NAME.xpc.dSYM" -output "$BUILT_PRODUCTS_DIR/Sparkle.xcframework"
else
echo "warning: Your Xcode version does not support bundling dSYMs in XCFrameworks directly. You should copy them manually into the XCFramework."
echo "note: cp '$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Sparkle.framework.dSYM' '$BUILT_PRODUCTS_DIR/Sparkle.xcframework/your_architecture/dSYMs'"
xcodebuild -create-xcframework -framework "$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/Products/Library/Frameworks/Sparkle.framework" -output "$BUILT_PRODUCTS_DIR/Sparkle.xcframework"
fi
+7 -11
View File
@@ -2,19 +2,15 @@
set -e
# Convenience script to automatically commit Package.swift after updating the checksum and move the latest tag
latest_git_tag=$( git describe --tags --abbrev=0 || true ) # gets the latest tag name
if [ -z "$latest_git_tag" ] ; then
exit 0
fi
latest_git_tag=$(git describe --tags --abbrev=0) # gets the latest tag name
commits_since_tag=$(git rev-list ${latest_git_tag}.. --count)
function move_tag() {
long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message
long_message=${long_message/$latest_git_tag} # trims tag name
long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace
git add Package.swift Sparkle.podspec Carthage-dev.json
git commit -m "Update Package management files for version ${latest_git_tag}"
git add Package.swift Sparkle.podspec
git commit -m "Update Package.swift and Sparkle.podspec for version ${latest_git_tag}"
git tag -fa $latest_git_tag -m "${long_message}"
echo "Package.swift and Sparkle.podspec committed and tag '$latest_git_tag' moved."
}
@@ -22,16 +18,16 @@ function move_tag() {
if [ "$commits_since_tag" -gt 0 ]; then
# If there have been commits since the latest tag, it's highly likely that we did not intend to do a full release
echo "WARNING: $commits_since_tag commit(s) since tag '$latest_git_tag'. Did you tag a new version?"
echo "Package management files have not been committed and tag has not been moved."
echo "Package.swift has not been committed and tag has not been moved."
elif [ "$CI" == true ]; then
move_tag
else
# TODO: add sanity check to see if version is actually being updated or not?
read -p "Do you want to commit changes to Package.swift, Sparkle.podspec, Carthage-dev.json and force move tag '$latest_git_tag'? (required for official release) [Y/n]" -n 1 -r
read -p "Do you want to commit changes to Package.swift and Sparkle.podspec, and force move tag '$latest_git_tag'? (required for official release) [Y/n]" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
move_tag
else
echo "Package.swift, Sparkle.podspec, and Carthage-dev.json have not been committed and tag has not been moved."
echo "Package.swift and Sparkle.podspec have not been committed and tag has not been moved."
fi
fi
fi
+1 -1
View File
@@ -9,7 +9,7 @@ if [ -z "$SRCROOT" ] || \
[ -z "$BUILT_PRODUCTS_DIR" ] || \
[ -z "$INFOPLIST_PATH" ] || \
[ -z "$MARKETING_VERSION" ]; then
echo "$0: Must be run from Xcode!" 1>&2
echo "$0: Must be run from Xcode!" 1>&2
exit 1
fi
-58
View File
@@ -1,58 +0,0 @@
#!/bin/sh
FRAMEWORK_PATH="${TARGET_BUILD_DIR}"/"${FULL_PRODUCT_NAME}"
# Remove any unused XPC Services
removedservices=0
if [[ "$SPARKLE_EMBED_INSTALLER_LAUNCHER_XPC_SERVICE" -eq 0 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_LAUNCHER_NAME}.xpc"
removedservices=$((removedservices+1))
fi
if [[ "$SPARKLE_EMBED_DOWNLOADER_XPC_SERVICE" -eq 0 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${DOWNLOADER_NAME}.xpc"
removedservices=$((removedservices+1))
fi
if [[ "$SPARKLE_EMBED_INSTALLER_STATUS_XPC_SERVICE" -eq 0 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_STATUS_NAME}.xpc"
removedservices=$((removedservices+1))
fi
if [[ "$SPARKLE_EMBED_INSTALLER_CONNECTION_XPC_SERVICE" -eq 0 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"/"${INSTALLER_CONNECTION_NAME}.xpc"
removedservices=$((removedservices+1))
fi
if [[ "$removedservices" -eq 4 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/XPCServices"
rm -rf "${FRAMEWORK_PATH}"/"XPCServices"
fi
# Remove any unused nibs
if [[ "$SPARKLE_BUILD_UI_BITS" -eq 0 ]]; then
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"SUStatus.nib"
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"Base.lproj/SUUpdateAlert.nib"
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"Base.lproj/SUUpdatePermissionPrompt.nib"
rm -rf "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/"ReleaseNotesColorStyle.css"
fi
# Remove localization files if requested
if [[ "$SPARKLE_COPY_LOCALIZATIONS" -eq 0 ]]; then
for dir in "${FRAMEWORK_PATH}"/"Versions/"${FRAMEWORK_VERSION}"/Resources"/*; do
base=$(basename "$dir")
if [[ "$base" =~ .*".lproj" ]]; then
if [[ "$base" = "Base.lproj" ]]; then
rm -rf "$dir/Sparkle.strings"
# Remove Base.lproj if it's empty and the nibs have been stripped out already
rmdir "$dir"
else
rm -rf "$dir"
fi
fi
done
fi
-20
View File
@@ -1,20 +0,0 @@
#!/usr/bin/env python3
import os, sys, json
if len(sys.argv) < 3:
print("Usage: path-to-carthage-file release-tag")
sys.exit(1)
carthage_file = sys.argv[1]
release_tag = sys.argv[2]
with open(carthage_file, "r") as json_file:
data = json.load(json_file)
if release_tag in data:
sys.exit(0)
with open(carthage_file, "w") as json_file:
data[release_tag] = "https://github.com/sparkle-project/Sparkle/releases/download/" + release_tag + "/Sparkle-" + release_tag + ".tar.xz"
json.dump(data, json_file)
-12
View File
@@ -1,12 +0,0 @@
# Sparkle 2 API Reference
These are the primary classes and protocols in Sparkle 2 you may be interested in:
- `SPUStandardUpdaterController` for creating a standard updater (encapsulates a `SPUUpdater` and `SPUStandardUserDriver`)
- `SPUUpdater` for invoking update checks and retrieving updater properties.
- `SPUUpdaterDelegate` for delegation methods to control the behavior of `SPUUpdater`.
- `SPUUserDriver` for making custom user interfaces.
If you are migrating from Sparkle 1, please refer to `SPUStandardUpdaterController` and `SPUUpdater`.
Please also visit the [Basic Setup](https://sparkle-project.org/documentation/) guide which shows how to instantiate an updater in a nib or how to create one programmatically.
-47
View File
@@ -1,47 +0,0 @@
# Design Practices
## XPC Services
XPC services in Sparkle are all optional, so the code involved in the services needs to be usable directly from the framework as well. For this to work well, if the class used in the XPC service takes a delegate, it must not be weakly referenced, so the retain cycle will have to be broken explicitly (via an explicit added invalidate method). dealloc also must not be implemented (do cleanup in custom invalidate method). As one may tell, two of the services are simply proxies (InstallerConnection, InstallerStatus) -- we now recommend most developers to set up a temporary exception with their bundle ID rather than use these two services.
The protocols used in XPC services must also not adopt other protocols (i.e, one protocol inheriting from another protocol). This is because the XPC protocol decoder on older supported systems doesn't properly handle this case, and won't be able to find that methods exist on a class.
## Singletons
Singletons and other global mutable variables have been either removed entirely or completely avoided with an exception to backwards compatibility. They have no place in a well architectured framework.
`SPUUpdater` doesn't maintain singleton instances and can now be properly deconstructed. Note because a caller is not expected to explicitly invalidate an updater, this means that the updater needs to avoid geting into a retain cycle. Intermediate clasess were created for the update cycle and schedule timer to avoid just this.
One may argue that we shouldn't allow multiple live updaters running at the same bundle simutaneously, but I disagree and I think that is missing the point. It also does not account for updaters running external to the process. For example, it may be perfectly reasonable to start an update from `sparkle-cli` that defers the installation until quit, and have the application that is being updated be able to resume that installation and relaunch immediately.
The original `SUUpdater` may have also been created to assist plug-ins and other non-app bundles. My advice there is in order to be truely safe, you must not inject a framework like Sparkle into the host application anyway. An external tool that is bundled like `sparkle-cli` may be more appropriate to use here.
## Extensibility
Sparkle 2.0 does not support subclassing classes internal (not exported) to Sparkle anymore. Doing so would be almost impossible to maintain into the future. Subclassing in general has been banned. Composition is prefered everywhere, even amongst the internal update drivers which were rewritten to follow a protocol oriented approach. The reason why composition is preferred is because it's easier to follow the flow of logic.
I hope the user driver API gives enough extensibility without someone wanting to create another fork.
## Delegation
Newer classes, other than assisting backwards compatibility, that support delegation don't pass the delegator around anymore. Doing so has some [bad consequences](https://zgcoder.net/ramblings/avoid-passing-the-delegator) and makes code hard to maintain.
Optional delegate methods that have return types need to be optional or have known default values for primitive types.
You may notice that the delegate and user driver are not accessible as properties from `SPUUpdater`. This is intentional. The methods that belong to these types aren't meaningful to any caller except from internal classes.
## Decoupling
Two software components should not directly know about each other. Preferrably they wouldn't know about each other at all, but if they must, they can use the delegation pattern with a declared protocol.
See `Documentation/graph-of-sparkle.png` for a graph of how the code looks like currently. This was generated via [objc_dep](https://github.com/nst/objc_dep) (great tool). Note that there are no red edges which would mean that two nodes know of each other.
## Attributes & Code Size
Instance variables and instance variable access should be used for private members (declared in `@implementation` block) whenever possible over properties. Preferring instance variables over properties for internal usage can significantly reduce code size. Instance variables should also be ordered by having the larger sized data members declared first.
`SPU_OBJC_DIRECT_MEMBERS` should be used for any internal class in Sparkle and `SPU_OBJC_DIRECT` should be used for any other internal methods to Sparkle that doesn't need to utilize the Obj-C runtime to reduce code size. Note these attributes should not be used for *any* class or method that is exported to the developer (this includes private headers / APIs we carefully decided to expose too). For internal methods and classes that are also used by our Swift tools or unit tests, we may not expose them as direct specifically when building for those targets.
`nonatomic` should really be used wherever possible with regards to obj-c properties (`atomic` is a bad default). `readonly` should be used wherever possible as well, which also implies that only ivar access should be used in initializers. `NS_ASSUME_NONNULL_BEGIN` and `NS_ASSUME_NONNULL_END` should be used around new headers whenever possible. AppKit prevention guards should be used for any non-UI class whenever possible.
Sparkle has several feature flags in ConfigCommon.xcconfig (e.g. `SPARKLE_BUILD_LEGACY_SUUPDATER`, `SPARKLE_BUILD_LEGACY_DSA_SUPPORT`, `SPARKLE_BUILD_UI_BITS`, etc). This allows disabling any combination of these features and building Sparkle with a more minimal feature set. These flags (with the exception for stripping UI bits, localizations, or XPC Services) are for disabling features that are legacy or not recommended to use for most applications. Note when altering these flags, `OTHER_SWIFT_FLAGS_COMMON` may need to be updated appropriately too.
Loaded 100 of 663 files, more files were not shown because too many files have changed in this diff. Show more