Compare commits

...
83 Commits
Author SHA1 Message Date
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
71 changed files with 1547 additions and 1013 deletions

No files matched your search

+4
View File
@@ -41,3 +41,7 @@ Carthage/Build
Network Trash Folder
Temporary Items
.apdisk
# Swift Package Manager
/.build
.swiftpm
+20
View File
@@ -0,0 +1,20 @@
excluded:
- Vendor
disabled_rules:
- opening_brace
- empty_parentheses_with_trailing_closure
- function_body_length
- line_length
- cyclomatic_complexity
- large_tuple
# Rule-specific config
trailing_comma:
mandatory_comma: true
force_try:
severity: warning
force_cast:
severity: warning
identifier_name:
min_length:
warning: 2
+6 -4
View File
@@ -1,5 +1,7 @@
os: osx
language: objective-c
osx_image: xcode9
before_install:
- brew update
script: make ci
osx_image:
- xcode11.4
- xcode12
script:
- set -o pipefail && xcodebuild test -project Sparkle.xcodeproj -scheme Distribution -derivedDataPath build -enableCodeCoverage YES | xcpretty
+11
View File
@@ -1,3 +1,14 @@
# 1.24.0-alpha
* Fixed error about "about:blank" release notes (Louis Pontoise)
* Use the SHA-256 hash of the archive as the cache path (Nate Weaver)
* Don't return an optional from the FileHandle method (Nate Weaver)
* Added URL+Hashing (Nate Weaver)
* Update SUUpdateAlert.xib (DanielFirlej)
* Added help command line option (Dominik H)
* Added function that parses all command line options (Dominik H)
* Command line option to provide a download url prefix is now parsed and set on each archive item (Dominik H)
# 1.23.0
* Support generating appcast with localizations (#1499) (Alik Vovkotrub)
+2 -1
View File
@@ -16,7 +16,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 23
SPARKLE_VERSION_MINOR = 24
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
@@ -55,6 +55,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 = NO
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
@@ -1,10 +0,0 @@
#include "ConfigCommonDebug.xcconfig"
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
GCC_GENERATE_TEST_COVERAGE_FILES = YES
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES
@@ -1,4 +0,0 @@
#include "ConfigUITest.xcconfig"
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
@@ -1,4 +0,0 @@
#include "ConfigUnitTest.xcconfig"
GCC_GENERATE_TEST_COVERAGE_FILES = NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
+31 -2
View File
@@ -12,17 +12,23 @@ if [ "$ACTION" = "" ] ; then
fi
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
rm -f "Sparkle-SPM-$CURRENT_PROJECT_VERSION.zip"
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
mkdir -p "$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 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"
# 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
@@ -32,11 +38,34 @@ if [ "$ACTION" = "" ] ; then
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"
cd "$CONFIGURATION_BUILD_DIR/staging"
# Sorted file list groups similar files together, which improves tar compression
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
# Generate zip containing the xcframework for SPM
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
#rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
zip -rqyX -9 "../Sparkle-SPM-$CURRENT_PROJECT_VERSION.zip" *
# Generate new Package manifest
cd "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
# is equivalent to shasum -a 256 FILE
spm_checksum=$(swift package compute-checksum "Sparkle-SPM-$CURRENT_PROJECT_VERSION.zip")
rm -rf ".build"
sed -E -i '' -e "/let version/ s/[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/$CURRENT_PROJECT_VERSION/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
cp "Package.swift" "$SRCROOT"
echo "Package.swift updated with the following values:"
echo "Version: $CURRENT_PROJECT_VERSION"
echo "Checksum: $spm_checksum"
else
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
fi
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
fi
+1 -1
View File
@@ -9,7 +9,7 @@ if [ -z "$SRCROOT" ] || \
[ -z "$BUILT_PRODUCTS_DIR" ] || \
[ -z "$INFOPLIST_PATH" ] || \
[ -z "$CURRENT_PROJECT_VERSION" ]; then
echo "$0: Must be run from Xcode!" 1>&2
echo "$0: Must be run from Xcode!" 1>&2
exit 1
fi
+2 -1
View File
@@ -14,9 +14,10 @@ localizable-strings:
release:
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
open "$(BUILDDIR)/Build/Products/Release/"
cat Sparkle.podspec
@echo "Don't forget to update CocoaPods! pod trunk push"
@echo "Don't forget to commit the updated Package manifest before releasing!"
build:
xcodebuild clean build
+24
View File
@@ -0,0 +1,24 @@
// swift-tools-version:5.3
import PackageDescription
let version = "1.24.0"
let checksum = "2b6fec0cad2bb643ed222b708f37bf9e98f5ed84d77c9ba69e66dd2b82b0fffa"
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(version)/Sparkle-SPM-\(version).zip"
let package = Package(
name: "Sparkle",
platforms: [.macOS(.v10_11)],
products: [
.library(
name: "Sparkle",
targets: ["Sparkle"])
],
targets: [
.binaryTarget(
name: "Sparkle",
url: url,
checksum: checksum
)
]
)
+3 -3
View File
@@ -4,7 +4,7 @@ Secure and reliable software update framework for Cocoa developers.
<img src="Resources/Screenshot.png" width="732" alt="Sparkle shows familiar update window with release notes">
This branch is the production ready, battle-tested version of Sparkle used by thousands of Mac apps.
This branch is the production ready, battle-tested version of Sparkle used by thousands of Mac apps.
The upcoming Sparkle 2 (currently in beta) can be found in the [2.x branch](https://github.com/sparkle-project/Sparkle/tree/2.x).
## Features
@@ -24,9 +24,9 @@ The upcoming Sparkle 2 (currently in beta) can be found in the [2.x branch](http
## Requirements
* Runtime: macOS 10.7 or greater
* Build: Xcode 9 and 10.11 SDK or greater
* Build: Xcode 9 and 10.11 SDK or greater (Xcode 12 if using Swift Package Manager)
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
* No sandboxing. Sparkle 1.x can't update sandboxed apps. [Sparkle 2.x](https://github.com/sparkle-project/Sparkle/tree/2.x) can.
* No sandboxing. Sparkle 1.x can't update sandboxed apps. However, [Sparkle 2.x](https://github.com/sparkle-project/Sparkle/tree/2.x) can.
## Usage
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.22.0"
s.version = "1.24.0"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
+80 -143
View File
@@ -25,6 +25,17 @@
name = All;
productName = All;
};
895C5DB924D75F370058A82D /* XCFramework */ = {
isa = PBXAggregateTarget;
buildConfigurationList = 895C5DBC24D75F370058A82D /* Build configuration list for PBXAggregateTarget "XCFramework" */;
buildPhases = (
895C5DBD24D75F590058A82D /* ShellScript */,
);
dependencies = (
);
name = XCFramework;
productName = Sparkle.xcframework;
};
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
@@ -275,7 +286,10 @@
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; };
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
A3AD648C24D283F400058938 /* SUGlobalUpdateLock.m in Sources */ = {isa = PBXBuildFile; fileRef = A3AD648A24D283F400058938 /* SUGlobalUpdateLock.m */; };
A3AD648D24D283F400058938 /* SUGlobalUpdateLock.h in Headers */ = {isa = PBXBuildFile; fileRef = A3AD648B24D283F400058938 /* SUGlobalUpdateLock.h */; };
A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; };
B2D3F865245CEA24009BA78C /* URL+Hashing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2D3F864245CEA24009BA78C /* URL+Hashing.swift */; };
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; };
E1545EC51E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = E1545EC31E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h */; };
E1545EC61E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m */; };
@@ -467,6 +481,13 @@
remoteGlobalIDString = 61B5F90109C4CEE200B25A18;
remoteInfo = "Sparkle Test App";
};
895C5DBE24D764DD0058A82D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 895C5DB924D75F370058A82D;
remoteInfo = Sparkle.xcframework;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -582,8 +603,6 @@
14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdaterTest.m; sourceTree = "<group>"; usesTabs = 0; };
14958C6B19AEBC530061B14F /* signed-test-file.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "signed-test-file.txt"; sourceTree = "<group>"; };
14958C6C19AEBC610061B14F /* test-pubkey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "test-pubkey.pem"; sourceTree = "<group>"; };
149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigCommonCoverage.xcconfig; sourceTree = "<group>"; };
149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUnitTestCoverage.xcconfig; sourceTree = "<group>"; };
1A985A321C5C329C0001163A /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1A985A331C5C329D0001163A /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1A985A341C5C329E0001163A /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@@ -926,7 +945,6 @@
729924711DF3478A00DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateValidator.h; sourceTree = "<group>"; };
729924721DF3478A00DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateValidator.m; sourceTree = "<group>"; };
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = "<group>"; };
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = "<group>"; };
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestRelease.xcconfig; sourceTree = "<group>"; };
72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUFileManagerTest.swift; sourceTree = "<group>"; };
@@ -946,8 +964,11 @@
767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A3AD648A24D283F400058938 /* SUGlobalUpdateLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGlobalUpdateLock.m; sourceTree = "<group>"; };
A3AD648B24D283F400058938 /* SUGlobalUpdateLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGlobalUpdateLock.h; sourceTree = "<group>"; };
A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestWebServer.h; sourceTree = "<group>"; };
A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestWebServer.m; sourceTree = "<group>"; };
B2D3F864245CEA24009BA78C /* URL+Hashing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Hashing.swift"; sourceTree = "<group>"; };
C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.enc.dmg; sourceTree = "<group>"; };
E1545EC31E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTouchBarButtonGroup.h; sourceTree = "<group>"; };
E1545EC41E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTouchBarButtonGroup.m; sourceTree = "<group>"; };
@@ -1324,6 +1345,7 @@
5AA96C571E0AE0DB00CA4346 /* main.swift */,
5AE13F771E0C9B12000D2C2C /* Signatures.swift */,
5A5AC5351E0C6CA300998119 /* Unarchive.swift */,
B2D3F864245CEA24009BA78C /* URL+Hashing.swift */,
);
path = generate_appcast;
sourceTree = "<group>";
@@ -1535,6 +1557,8 @@
61299A2E09CA2DAB00B7442F /* SUSignatureVerifier.m */,
729924711DF3478A00DBCDF5 /* SUUpdateValidator.h */,
729924721DF3478A00DBCDF5 /* SUUpdateValidator.m */,
A3AD648B24D283F400058938 /* SUGlobalUpdateLock.h */,
A3AD648A24D283F400058938 /* SUGlobalUpdateLock.m */,
);
name = Support;
sourceTree = "<group>";
@@ -1604,7 +1628,6 @@
5D06E8F20FD68D21005AE3F6 /* ConfigBinaryDeltaDebug.xcconfig */,
5D06E8F30FD68D21005AE3F6 /* ConfigBinaryDeltaRelease.xcconfig */,
FA1941D00D94A70100DD942E /* ConfigCommon.xcconfig */,
149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */,
FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */,
FA1941CC0D94A70100DD942E /* ConfigCommonRelease.xcconfig */,
722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */,
@@ -1627,11 +1650,9 @@
FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */,
FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */,
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */,
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */,
729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */,
729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */,
FA3AAF3B1050B273004B3130 /* ConfigUnitTest.xcconfig */,
149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */,
FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */,
FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */,
EA4311C9229D614300A5503D /* ed25519-Debug.xcconfig */,
@@ -1655,6 +1676,7 @@
611142E910FB1BE5009810AA /* bspatch.h in Headers */,
5AB8F185214D564C00A1187F /* ed25519.h in Headers */,
5AB8F184214D564C00A1187F /* fe.h in Headers */,
A3AD648D24D283F400058938 /* SUGlobalUpdateLock.h in Headers */,
5AB8F18A214D564C00A1187F /* fixedint.h in Headers */,
5AB8F18B214D564C00A1187F /* ge.h in Headers */,
5AB8F187214D564C00A1187F /* precomp_data.h in Headers */,
@@ -1752,6 +1774,7 @@
14732BCB1960F73500593899 /* PBXTargetDependency */,
1454BA1619637EDB00344E57 /* PBXTargetDependency */,
14732BCF1960F73500593899 /* PBXTargetDependency */,
895C5DBF24D764DD0058A82D /* PBXTargetDependency */,
1454BA1819637EE900344E57 /* PBXTargetDependency */,
);
name = Distribution;
@@ -2011,6 +2034,9 @@
LastSwiftMigration = 0800;
TestTargetID = 61B5F90109C4CEE200B25A18;
};
895C5DB924D75F370058A82D = {
CreatedOnToolsVersion = 12.0;
};
8DC2EF4F0486A6940098B216 = {
LastSwiftMigration = 0920;
};
@@ -2083,6 +2109,7 @@
14732BC51960F69300593899 /* Distribution */,
1420DF491962329200203BB0 /* Documentation */,
1495005F195FB89400BC5B5B /* All */,
895C5DB924D75F370058A82D /* XCFramework */,
726B2B5C1C645FC900388755 /* UI Tests */,
722954B31D04ADAF00ECF9CA /* fileop */,
5AA96C541E0AE0DB00CA4346 /* generate_appcast */,
@@ -2228,6 +2255,23 @@
shellScript = "ln -sfh \"pt_BR.lproj\" \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/pt.lproj\"";
showEnvVarsInLog = 0;
};
895C5DBD24D75F590058A82D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Deleting old products\nrm -rd \"$BUILT_PRODUCTS_DIR/Sparkle.xcarchive\"\nrm -rd \"$BUILT_PRODUCTS_DIR/Sparkle.xcframework\"\n\nxcodebuild archive -scheme Sparkle -archivePath \"$BUILT_PRODUCTS_DIR/Sparkle.xcarchive\" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO\n\nif [ $XCODE_VERSION_MAJOR -ge \"1200\" ]; then\nxcodebuild -create-xcframework -framework \"$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/Products/Library/Frameworks/Sparkle.framework\" -debug-symbols \"$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Sparkle.framework.dSYM\" -output \"$BUILT_PRODUCTS_DIR/Sparkle.xcframework\"\nelse\necho \"warning: Your Xcode version does not support bundling dSYMs in XCFrameworks directly. You should copy them manually into the XCFramework.\"\necho \"note: cp '$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/dSYMs/Sparkle.framework.dSYM' '$BUILT_PRODUCTS_DIR/Sparkle.xcframework/your_architecture/dSYMs'\"\nxcodebuild -create-xcframework -framework \"$BUILT_PRODUCTS_DIR/Sparkle.xcarchive/Products/Library/Frameworks/Sparkle.framework\" -output \"$BUILT_PRODUCTS_DIR/Sparkle.xcframework\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -2275,6 +2319,7 @@
5A5AC5381E0C6D3000998119 /* FeedXML.swift in Sources */,
5AA96C581E0AE0DB00CA4346 /* main.swift in Sources */,
5AE13F781E0C9B12000D2C2C /* Signatures.swift in Sources */,
B2D3F865245CEA24009BA78C /* URL+Hashing.swift in Sources */,
5AE13FBA1E0DA389000D2C2C /* SUBinaryDeltaApply.m in Sources */,
5AAD00661E0C2D9B00AF411E /* SUBinaryDeltaCommon.m in Sources */,
5AAD00671E0C2D9B00AF411E /* SUBinaryDeltaCreate.m in Sources */,
@@ -2412,6 +2457,7 @@
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
72316BE41E0E1C7F0039EFD9 /* SUSystemUpdateInfo.m in Sources */,
A3AD648C24D283F400058938 /* SUGlobalUpdateLock.m in Sources */,
E1545EC61E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m in Sources */,
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */,
@@ -2562,6 +2608,11 @@
target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */;
targetProxy = 726B2B621C645FC900388755 /* PBXContainerItemProxy */;
};
895C5DBF24D764DD0058A82D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 895C5DB924D75F370058A82D /* XCFramework */;
targetProxy = 895C5DBE24D764DD0058A82D /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -2805,70 +2856,6 @@
};
name = Release;
};
149B785A1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */;
buildSettings = {
};
name = Coverage;
};
149B785B1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Coverage;
};
149B785C1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
149B785D1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */;
buildSettings = {
};
name = Coverage;
};
149B785E1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5D06E8F20FD68D21005AE3F6 /* ConfigBinaryDeltaDebug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
149B785F1B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941D30D94A70100DD942E /* ConfigRelaunchDebug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
149B78601B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Coverage;
};
149B78611B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Coverage;
};
149B78621B7D398100D7D62C /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Coverage;
};
1DEB91AE08733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */;
@@ -2894,6 +2881,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */;
buildSettings = {
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -2902,6 +2890,7 @@
baseConfigurationReference = FA1941CC0D94A70100DD942E /* ConfigCommonRelease.xcconfig */;
buildSettings = {
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -2929,15 +2918,6 @@
};
name = Debug;
};
5A5ADEDD214EDE4900DF0099 /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5AB8F1AA214DA85900A1187F /* ConfigGenerateKeysDebug.xcconfig */;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Coverage;
};
5A5ADEDE214EDE4900DF0099 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5AB8F1A9214DA85900A1187F /* ConfigGenerateKeysRelease.xcconfig */;
@@ -2955,14 +2935,6 @@
};
name = Debug;
};
5AA96C5A1E0AE0DC00CA4346 /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7205C4351E12CA7000E370AE /* ConfigGenerateAppcastDebug.xcconfig */;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
};
name = Coverage;
};
5AA96C5B1E0AE0DC00CA4346 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7205C4341E12C66D00E370AE /* ConfigGenerateAppcastRelease.xcconfig */;
@@ -2981,16 +2953,6 @@
};
name = Debug;
};
5AB8F1A5214DA72000A1187F /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5AB8F1AA214DA85900A1187F /* ConfigGenerateKeysDebug.xcconfig */;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Coverage;
};
5AB8F1A6214DA72000A1187F /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5AB8F1A9214DA85900A1187F /* ConfigGenerateKeysRelease.xcconfig */;
@@ -3052,15 +3014,6 @@
};
name = Debug;
};
722954B91D04ADAF00ECF9CA /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */;
buildSettings = {
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Coverage;
};
722954BA1D04ADAF00ECF9CA /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */;
@@ -3077,13 +3030,6 @@
};
name = Debug;
};
726B2B651C645FC900388755 /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */;
buildSettings = {
};
name = Coverage;
};
726B2B661C645FC900388755 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F11001C65A9B500DFCCC5 /* ConfigUITestRelease.xcconfig */;
@@ -3091,6 +3037,18 @@
};
name = Release;
};
895C5DBA24D75F370058A82D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Debug;
};
895C5DBB24D75F370058A82D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Release;
};
EA4311A2229D5FBC00A5503D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = EA4311C9229D614300A5503D /* ed25519-Debug.xcconfig */;
@@ -3098,13 +3056,6 @@
};
name = Debug;
};
EA4311A3229D5FBC00A5503D /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = EA4311C9229D614300A5503D /* ed25519-Debug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
EA4311A4229D5FBC00A5503D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = EA4311C8229D613B00A5503D /* ed25519-Release.xcconfig */;
@@ -3119,13 +3070,6 @@
};
name = Debug;
};
EA4311ED229D651300A5503D /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = EA4311FA229D656700A5503D /* bsdiff-Debug.xcconfig */;
buildSettings = {
};
name = Coverage;
};
EA4311EE229D651300A5503D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = EA4311FB229D657A00A5503D /* bsdiff-Release.xcconfig */;
@@ -3140,7 +3084,6 @@
isa = XCConfigurationList;
buildConfigurations = (
1420DF4B1962329200203BB0 /* Debug */,
149B78611B7D398100D7D62C /* Coverage */,
1420DF4C1962329200203BB0 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3150,7 +3093,6 @@
isa = XCConfigurationList;
buildConfigurations = (
14732BC71960F69300593899 /* Debug */,
149B78601B7D398100D7D62C /* Coverage */,
14732BC81960F69300593899 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3160,7 +3102,6 @@
isa = XCConfigurationList;
buildConfigurations = (
14950061195FB89500BC5B5B /* Debug */,
149B78621B7D398100D7D62C /* Coverage */,
14950062195FB89500BC5B5B /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3170,7 +3111,6 @@
isa = XCConfigurationList;
buildConfigurations = (
1DEB91AE08733DA50010E9CD /* Debug */,
149B785B1B7D398100D7D62C /* Coverage */,
1DEB91AF08733DA50010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3180,7 +3120,6 @@
isa = XCConfigurationList;
buildConfigurations = (
1DEB91B208733DA50010E9CD /* Debug */,
149B785A1B7D398100D7D62C /* Coverage */,
1DEB91B308733DA50010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3190,7 +3129,6 @@
isa = XCConfigurationList;
buildConfigurations = (
55C14BBB136EEF1500649790 /* Debug */,
149B785F1B7D398100D7D62C /* Coverage */,
55C14BBC136EEF1500649790 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3200,7 +3138,6 @@
isa = XCConfigurationList;
buildConfigurations = (
5A5ADEDC214EDE4900DF0099 /* Debug */,
5A5ADEDD214EDE4900DF0099 /* Coverage */,
5A5ADEDE214EDE4900DF0099 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3210,7 +3147,6 @@
isa = XCConfigurationList;
buildConfigurations = (
5AA96C591E0AE0DC00CA4346 /* Debug */,
5AA96C5A1E0AE0DC00CA4346 /* Coverage */,
5AA96C5B1E0AE0DC00CA4346 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3220,7 +3156,6 @@
isa = XCConfigurationList;
buildConfigurations = (
5AB8F1A4214DA72000A1187F /* Debug */,
5AB8F1A5214DA72000A1187F /* Coverage */,
5AB8F1A6214DA72000A1187F /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3230,7 +3165,6 @@
isa = XCConfigurationList;
buildConfigurations = (
5D06E8D20FD68C7D005AE3F6 /* Debug */,
149B785E1B7D398100D7D62C /* Coverage */,
5D06E8D30FD68C7D005AE3F6 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3240,7 +3174,6 @@
isa = XCConfigurationList;
buildConfigurations = (
612279DB0DB5470300AB99EA /* Debug */,
149B785D1B7D398100D7D62C /* Coverage */,
612279DC0DB5470300AB99EA /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3250,7 +3183,6 @@
isa = XCConfigurationList;
buildConfigurations = (
61B5F90609C4CEE300B25A18 /* Debug */,
149B785C1B7D398100D7D62C /* Coverage */,
61B5F90709C4CEE300B25A18 /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3260,7 +3192,6 @@
isa = XCConfigurationList;
buildConfigurations = (
722954B81D04ADAF00ECF9CA /* Debug */,
722954B91D04ADAF00ECF9CA /* Coverage */,
722954BA1D04ADAF00ECF9CA /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3270,17 +3201,24 @@
isa = XCConfigurationList;
buildConfigurations = (
726B2B641C645FC900388755 /* Debug */,
726B2B651C645FC900388755 /* Coverage */,
726B2B661C645FC900388755 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
895C5DBC24D75F370058A82D /* Build configuration list for PBXAggregateTarget "XCFramework" */ = {
isa = XCConfigurationList;
buildConfigurations = (
895C5DBA24D75F370058A82D /* Debug */,
895C5DBB24D75F370058A82D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EA4311A1229D5FBC00A5503D /* Build configuration list for PBXNativeTarget "ed25519" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EA4311A2229D5FBC00A5503D /* Debug */,
EA4311A3229D5FBC00A5503D /* Coverage */,
EA4311A4229D5FBC00A5503D /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3290,7 +3228,6 @@
isa = XCConfigurationList;
buildConfigurations = (
EA4311EC229D651300A5503D /* Debug */,
EA4311ED229D651300A5503D /* Coverage */,
EA4311EE229D651300A5503D /* Release */,
);
defaultConfigurationIsVisible = 0;
@@ -3,7 +3,7 @@
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "895C5DB924D75F370058A82D"
BuildableName = "XCFramework"
BlueprintName = "XCFramework"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "895C5DB924D75F370058A82D"
BuildableName = "XCFramework"
BlueprintName = "XCFramework"
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+6 -6
View File
@@ -89,14 +89,14 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
SULog(SULogLevelError, @"Failed to listen for application termination");
// Continue on with the installation anyway?
}
if (self.shouldShowUI) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self.isTerminating) {
// Show app icon in the dock
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
}
if (!self.isTerminating) {
// Show app icon in the dock
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
}
});
}
+8 -8
View File
@@ -199,7 +199,7 @@
NSUInteger options = NSXMLNodeLoadExternalEntitiesNever; // Prevent inclusion from file://
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:appcastData options:options error:errorp];
if (nil == document) {
if (nil == document) {
return nil;
}
@@ -212,7 +212,7 @@
NSEnumerator *nodeEnum = [xmlItems objectEnumerator];
NSXMLNode *node;
while((node = [nodeEnum nextObject])) {
while((node = [nodeEnum nextObject])) {
NSMutableDictionary *nodesDict = [NSMutableDictionary dictionary];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
@@ -239,7 +239,7 @@
// enclosure is flattened as a separate dictionary for some reason
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
[dict setObject:encDict forKey:name];
}
}
else if ([name isEqualToString:SURSSElementPubDate]) {
// We don't want to parse and create a NSDate instance -
// that's a risk we can avoid. We don't use the date anywhere other
@@ -248,8 +248,8 @@
if (dateString) {
[dict setObject:dateString forKey:name];
}
}
else if ([name isEqualToString:SUAppcastElementDeltas]) {
}
else if ([name isEqualToString:SUAppcastElementDeltas]) {
NSMutableArray *deltas = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
@@ -258,7 +258,7 @@
}
}
[dict setObject:deltas forKey:name];
}
}
else if ([name isEqualToString:SUAppcastElementTags]) {
NSMutableArray *tags = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
@@ -270,7 +270,7 @@
}
[dict setObject:tags forKey:name];
}
else if (name != nil) {
else if (name != nil) {
// add all other values as strings
NSString *theValue = [[node stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (theValue != nil) {
@@ -283,7 +283,7 @@
SUAppcastItem *anItem = [[SUAppcastItem alloc] initWithDictionary:dict failureReason:&errString];
if (anItem) {
[appcastItems addObject:anItem];
}
}
else {
SULog(SULogLevelError, @"Sparkle Updater: Failed to parse appcast item: %@.\nAppcast dictionary was: %@", errString, dict);
if (errorp) *errorp = [NSError errorWithDomain:SUSparkleErrorDomain
+1 -1
View File
@@ -139,7 +139,7 @@
}
// Need an info URL or an enclosure URL. Former to show "More Info"
// page, latter to download & install:
// page, latter to download & install:
if (!enclosure && !theInfoURL) {
if (error) {
*error = @"No enclosure in feed item";
+2 -2
View File
@@ -179,8 +179,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice
{
self.alert = nil;
switch (choice)
{
switch (choice)
{
case SUInstallNowChoice:
[self stopUpdatingOnTermination];
[self installWithToolAndRelaunch:YES];
+19 -8
View File
@@ -25,6 +25,7 @@
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUGlobalUpdateLock.h"
#import "SPUURLRequest.h"
#import "SPUDownloaderDeprecated.h"
@@ -63,8 +64,8 @@
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
if ([aHost isRunningOnReadOnlyVolume])
{
if ([aHost isRunningOnReadOnlyVolume])
{
NSString *hostName = [aHost name];
if ([aHost isRunningTranslocated])
{
@@ -118,13 +119,17 @@
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
{
SUAppcastItem *item = nil;
NSComparisonResult order;
for(SUAppcastItem *candidate in appcastItems) {
if ([self hostSupportsItem:candidate]) {
// Pick this item if nothing is picked yet. Always pick an item with a higher version. Only if versions are the same
// compare their dates and pick this item if its date is not lower – this covers cases when no date is available
// and picks items at the end of the appcast list as they are more likely to be the most recent releases.
if (
!item || (
[item.date compare:candidate.date] == NSOrderedAscending &&
[comparator compareVersion:item.versionString toVersion:candidate.versionString] != NSOrderedDescending
)
!item
|| (order = [comparator compareVersion:item.versionString toVersion:candidate.versionString]) == NSOrderedAscending
|| (order == NSOrderedSame && [item.date compare:candidate.date] != NSOrderedDescending)
) {
item = candidate;
}
@@ -144,7 +149,7 @@
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
{
BOOL osOK = [ui isMacOsUpdate];
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) {
return osOK;
}
@@ -173,7 +178,7 @@
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
{
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
if (skippedVersion == nil) { return NO; }
if (skippedVersion == nil) { return NO; }
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
}
@@ -297,6 +302,9 @@
[[NSFileManager defaultManager] removeItemAtPath:appCachePath error:NULL];
}
// Ensure no other thirdparty app-updater is concurrently updating this app.
[[SUGlobalUpdateLock sharedLock] lock];
id<SUUpdaterPrivate> updater = self.updater;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
@@ -673,6 +681,9 @@
- (void)abortUpdate
{
// Remove lockfile to prevent 3rd party updaters from updating this app if the update is not going to happen anyway
[[SUGlobalUpdateLock sharedLock] unlock];
[self cleanUpDownload];
[[NSNotificationCenter defaultCenter] removeObserver:self];
self.updateItem = nil;
+4 -4
View File
@@ -13,7 +13,7 @@
#import <Foundation/Foundation.h>
// -----------------------------------------------------------------------------
// Misc:
// Misc:
// -----------------------------------------------------------------------------
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
@@ -24,13 +24,13 @@ extern NSString *const SUBundleIdentifier;
extern NSString *const SUAppcastAttributeValueMacOS;
// -----------------------------------------------------------------------------
// Notifications:
// Notifications:
// -----------------------------------------------------------------------------
extern NSString *const SUTechnicalErrorInformationKey;
// -----------------------------------------------------------------------------
// PList keys::
// PList keys::
// -----------------------------------------------------------------------------
extern NSString *const SUFeedURLKey;
@@ -62,7 +62,7 @@ extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((dep
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
// -----------------------------------------------------------------------------
// Appcast keys::
// Appcast keys::
// -----------------------------------------------------------------------------
extern NSString *const SUAppcastAttributeDeltaFrom;
+8 -8
View File
@@ -56,7 +56,7 @@
// Called on a non-main thread.
- (void)extractDMGWithNotifier:(SUUnarchiverNotifier *)notifier
{
@autoreleasepool {
@autoreleasepool {
BOOL mountedSuccessfully = NO;
// get a unique mount point path
@@ -65,7 +65,7 @@
NSError *error;
NSArray *contents;
do
{
{
// Using NSUUID would make creating UUIDs be done in Cocoa,
// and thus managed under ARC. Sadly, the class is in 10.8 and later.
CFUUIDRef uuid = CFUUIDCreate(NULL);
@@ -135,8 +135,8 @@
[notifier notifyProgress:0.5];
if (taskResult != 0)
{
if (taskResult != 0)
{
NSString *resultStr = output ? [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding] : nil;
SULog(SULogLevelError, @"hdiutil failed with code: %ld data: <<%@>>", (long)taskResult, resultStr);
goto reportError;
@@ -155,8 +155,8 @@
double itemsCopied = 0;
double totalItems = [contents count];
for (NSString *item in contents)
{
for (NSString *item in contents)
{
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
@@ -169,8 +169,8 @@
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
{
if (![manager copyItemAtPath:fromPath toPath:toPath error:&error])
{
goto reportError;
}
}
+2 -1
View File
@@ -7,10 +7,11 @@
//
#import "SUFileManager.h"
#import "SUErrors.h"
#import "SUOperatingSystem.h"
#import "SUFileOperationConstants.h"
#import "SUErrors.h"
#include <sys/xattr.h>
#include <sys/errno.h>
#include <sys/time.h>
+26
View File
@@ -0,0 +1,26 @@
//
// SUGlobalUpdateLock.h
// Sparkle
//
// Created by Bibhas Acharya on 7/12/20.
// Copyright © 2020 Sparkle Project. All rights reserved.
//
#ifndef SUGLOBALUPDATELOCK_H
#define SUGLOBALUPDATELOCK_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
@interface SUGlobalUpdateLock : NSObject
+ (SUGlobalUpdateLock *)sharedLock;
- (void)lock;
- (void)unlock;
@end
#endif
+65
View File
@@ -0,0 +1,65 @@
//
// SUGlobalUpdateFileLock.m
// Sparkle
//
// Created by Bibhas Acharya on 7/12/20.
// Copyright © 2020 Sparkle Project. All rights reserved.
//
#import "SUGlobalUpdateLock.h"
#import "SULog.h"
@implementation SUGlobalUpdateLock
+ (SUGlobalUpdateLock *)sharedLock
{
static dispatch_once_t once;
static SUGlobalUpdateLock *sharedInstance = nil;
dispatch_once(&once, ^{
sharedInstance = [self new];
});
return sharedInstance;
}
- (void)lock
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileLockPath = [self fileLockPath];
BOOL success = [fileManager createFileAtPath:fileLockPath contents:nil attributes:nil];
if (!success) {
SULog(SULogLevelDefault, @"Couldn't create lockfile at: %@", fileLockPath);
}
}
- (void)unlock
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileLockPath = [self fileLockPath];
if ([fileManager fileExistsAtPath:fileLockPath]) {
NSError *error = nil;
[fileManager removeItemAtPath:fileLockPath error:&error];
if (error != nil) {
SULog(SULogLevelError, @"Couldn't remove lockfile at: %@ [%@]", fileLockPath, [error localizedDescription]);
}
}
}
- (NSString *)identifier
{
NSString *resp = [[NSBundle mainBundle] bundleIdentifier];
if (resp == nil) {
// If there's no bundle identifier, use the executable path
resp = [[[NSBundle mainBundle] executablePath] stringByReplacingOccurrencesOfString:@"/" withString:@"."];
}
return resp;
}
- (NSString *)fileLockPath
{
return [NSString stringWithFormat:@"/private/tmp/%@.Sparkle.pid", [self identifier]];
}
@end
+20 -20
View File
@@ -41,8 +41,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithBundle:(NSBundle *)aBundle
{
if ((self = [super init]))
{
if ((self = [super init]))
{
NSParameterAssert(aBundle);
self.bundle = aBundle;
if (![self.bundle bundleIdentifier]) {
@@ -80,10 +80,10 @@ NS_ASSUME_NONNULL_BEGIN
if (name && name.length > 0) return name;
name = [self objectForInfoDictionaryKey:@"CFBundleDisplayName"];
if (name && name.length > 0) return name;
if (name && name.length > 0) return name;
name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey];
if (name && name.length > 0) return name;
if (name && name.length > 0) return name;
return [[[NSFileManager defaultManager] displayNameAtPath:[self bundlePath]] stringByDeletingPathExtension];
}
@@ -128,13 +128,13 @@ NS_ASSUME_NONNULL_BEGIN
{
// Maybe the key is just a string in the Info.plist.
NSString *key = [self objectForInfoDictionaryKey:SUPublicDSAKeyKey];
if (key) {
if (key) {
return key;
}
// More likely, we've got a reference to a Resources file by filename:
NSString *keyFilename = [self publicDSAKeyFileKey];
if (!keyFilename) {
if (!keyFilename) {
return nil;
}
@@ -204,12 +204,12 @@ NS_ASSUME_NONNULL_BEGIN
// Note this handles nil being passed for defaultName, in which case the user default will be removed
- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName
{
if (self.usesStandardUserDefaults)
{
if (self.usesStandardUserDefaults)
{
[[NSUserDefaults standardUserDefaults] setObject:value forKey:defaultName];
}
else
{
}
else
{
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFPropertyListRef)(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
}
@@ -225,10 +225,10 @@ NS_ASSUME_NONNULL_BEGIN
CFPropertyListRef plr = CFPreferencesCopyAppValue((__bridge CFStringRef)defaultName, (__bridge CFStringRef)self.defaultsDomain);
if (plr == NULL) {
value = NO;
}
else
{
value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr);
}
else
{
value = CFBooleanGetValue((CFBooleanRef)plr) ? YES : NO;
CFRelease(plr);
}
return value;
@@ -236,12 +236,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName
{
if (self.usesStandardUserDefaults)
{
if (self.usesStandardUserDefaults)
{
[[NSUserDefaults standardUserDefaults] setBool:value forKey:defaultName];
}
else
{
}
else
{
CFPreferencesSetValue((__bridge CFStringRef)defaultName, (__bridge CFBooleanRef) @(value), (__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFPreferencesSynchronize((__bridge CFStringRef)self.defaultsDomain, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
}
+1 -1
View File
@@ -92,7 +92,7 @@
- (void)extractArchivePipingDataToCommand:(NSString *)command arguments:(NSArray*)args notifier:(SUUnarchiverNotifier *)notifier
{
// *** GETS CALLED ON NON-MAIN THREAD!!!
@autoreleasepool {
@autoreleasepool {
NSError *error = nil;
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
+1 -1
View File
@@ -208,7 +208,7 @@
if (progress) {
progress(9/10.0);
}
// Try to preserve Finder tags. Failure can be accepted without complaint as previous Sparkle versions did not do this at all
if (SUAVAILABLE(10, 9)) {
NSArray *resourceTags;
+6 -6
View File
@@ -159,13 +159,13 @@
__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 (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;
return NO;
};
dataReadTransform = SecTransformCreateReadTransformWithReadStream((__bridge CFReadStreamRef)stream);
+3 -3
View File
@@ -37,8 +37,8 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
- (instancetype)initWithHost:(SUHost *)aHost
{
self = [super initWithWindowNibName:@"SUStatus"];
if (self)
{
if (self)
{
self.host = aHost;
[self setShouldCascadeWindows:NO];
}
@@ -125,7 +125,7 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
- (void)setMaxProgressValue:(double)value
{
if (value < 0.0) value = 0.0;
if (value < 0.0) value = 0.0;
maxProgressValue = value;
[self setProgressValue:0.0];
[self.progressBar setIndeterminate:(value == 0.0)];
+7 -7
View File
@@ -62,9 +62,9 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
NSString *visibleCPUType;
switch (value) {
case CPU_TYPE_ARM: visibleCPUType = @"ARM"; break;
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
default: visibleCPUType = @"Unknown"; break;
case CPU_TYPE_X86: visibleCPUType = @"Intel"; break;
case CPU_TYPE_POWERPC: visibleCPUType = @"PowerPC"; break;
default: visibleCPUType = @"Unknown"; break;
}
[profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerCPUTypeKey, @"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]];
}
@@ -92,10 +92,10 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang";
} else if (cpuType == 18) {
// PowerPC
switch (value) {
case 9: visibleCPUSubType=@"G3"; break;
case 10: case 11: visibleCPUSubType=@"G4"; break;
case 100: visibleCPUSubType=@"G5"; break;
default: visibleCPUSubType=@"Other"; break;
case 9: visibleCPUSubType=@"G3"; break;
case 10: case 11: visibleCPUSubType=@"G4"; break;
case 100: visibleCPUSubType=@"G5"; break;
default: visibleCPUSubType=@"Other"; break;
}
} else {
visibleCPUSubType = @"Other";
+3 -3
View File
@@ -138,7 +138,7 @@
alert.informativeText = SULocalizedString(@"No valid update information could be loaded.", nil);
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
}
[self showAlert:alert];
}
@@ -373,8 +373,8 @@
- (void)abortUpdate
{
if (self.statusController)
{
if (self.statusController)
{
[self.statusController close];
self.statusController = nil;
}
+24 -24
View File
@@ -7,7 +7,7 @@
//
// -----------------------------------------------------------------------------
// Headers:
// Headers:
// -----------------------------------------------------------------------------
#import "SUUpdateAlert.h"
@@ -81,8 +81,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
{
self = [super initWithWindowNibName:@"SUUpdateAlert"];
if (self)
{
if (self)
{
self.completionBlock = block;
host = aHost;
updateItem = item;
@@ -195,12 +195,12 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
[[self.releaseNotesView superview] addSubview:self.releaseNotesSpinner];
// If there's a release notes URL, load it; otherwise, just stick the contents of the description into the web view.
if ([self.updateItem releaseNotesURL])
{
if ([self.updateItem releaseNotesURL])
{
[[self.releaseNotesView mainFrame] loadRequest:[NSURLRequest requestWithURL:[self.updateItem releaseNotesURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]];
}
else
{
}
else
{
[[self.releaseNotesView mainFrame] loadHTMLString:[self.updateItem itemDescription] baseURL:nil];
}
}
@@ -208,14 +208,14 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
- (BOOL)showsReleaseNotes
{
NSNumber *shouldShowReleaseNotes = [self.host objectForInfoDictionaryKey:SUShowReleaseNotesKey];
if (shouldShowReleaseNotes == nil)
{
if (shouldShowReleaseNotes == nil)
{
// Don't show release notes if RSS item contains no description and no release notes URL:
return (([self.updateItem itemDescription] != nil
&& [[[self.updateItem itemDescription] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)
|| [self.updateItem releaseNotesURL] != nil);
}
else
}
else
return [shouldShowReleaseNotes boolValue];
}
@@ -271,12 +271,11 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
self.laterButton.enabled = NO;
self.laterButton.hidden = YES;
}
[self.window center];
}
- (BOOL)automaticChecksEnabled {
NSNumber *automaticChecksEnabled = [self.host objectForInfoDictionaryKey:SUEnableAutomaticChecksKey];
NSNumber *automaticChecksEnabled = [self.host objectForKey:SUEnableAutomaticChecksKey];
if (automaticChecksEnabled == nil)
{
return false;
@@ -287,8 +286,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
- (BOOL)windowShouldClose:(NSNotification *) __unused note
{
[self endWithSelection:SURemindMeLaterChoice];
return YES;
[self endWithSelection:SURemindMeLaterChoice];
return YES;
}
- (NSImage *)applicationIcon
@@ -352,7 +351,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
{
NSURL *requestURL = request.URL;
NSString *scheme = requestURL.scheme;
BOOL whitelistedSafe = [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [requestURL.absoluteString isEqualToString:@"about:blank"];
BOOL isAboutBlank = [requestURL.absoluteString isEqualToString:@"about:blank"];
BOOL whitelistedSafe = isAboutBlank || [@[@"http", @"https", @"macappstore", @"macappstores", @"itms-apps", @"itms-appss"] containsObject:scheme];
// Do not allow redirects to dangerous protocols such as file://
if (!whitelistedSafe) {
@@ -362,7 +362,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
}
if (self.webViewFinishedLoading) {
if (requestURL) {
if (requestURL && !isAboutBlank) {
[[NSWorkspace sharedWorkspace] openURL:requestURL];
}
@@ -378,14 +378,14 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
{
NSMutableArray<NSMenuItem *> *webViewMenuItems = [defaultMenuItems mutableCopy];
if (webViewMenuItems)
{
for (NSMenuItem *menuItem in defaultMenuItems)
{
if (webViewMenuItems)
{
for (NSMenuItem *menuItem in defaultMenuItems)
{
NSInteger tag = [menuItem tag];
switch (tag)
{
switch (tag)
{
case WebMenuItemTagOpenLinkInNewWindow:
case WebMenuItemTagDownloadLinkToDisk:
case WebMenuItemTagOpenImageInNewWindow:
+7 -7
View File
@@ -58,8 +58,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
- (instancetype)initWithHost:(SUHost *)aHost systemProfile:(NSArray *)profile reply:(void (^)(SUUpdatePermissionResponse *))reply
{
self = [super initWithWindowNibName:@"SUUpdatePermissionPrompt"];
if (self)
{
if (self)
{
_reply = reply;
host = aHost;
self.isShowingMoreInfo = NO;
@@ -75,7 +75,7 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]]) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
@@ -92,8 +92,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
- (void)windowDidLoad
{
if (![self shouldAskAboutProfile])
{
if (![self shouldAskAboutProfile])
{
NSRect frame = [[self window] frame];
frame.size.height -= [self.moreInfoButton frame].size.height;
[[self window] setFrame:frame display:YES];
@@ -128,8 +128,8 @@ static NSString *const SUUpdatePermissionPromptTouchBarIndentifier = @"" SPARKLE
NSRect profileMoreInfoButtonFrame = [self.moreInfoButton frame];
NSRect descriptionFrame = [self.descriptionTextField frame];
if (self.isShowingMoreInfo)
{
if (self.isShowingMoreInfo)
{
// Add the subview
contentViewFrame.size.height += profileMoreInfoViewFrame.size.height;
profileMoreInfoViewFrame.origin.y = profileMoreInfoButtonFrame.origin.y - profileMoreInfoViewFrame.size.height;
+24 -21
View File
@@ -27,6 +27,7 @@
#import "SUSystemUpdateInfo.h"
#import "SUSignatures.h"
#import "SUOperatingSystem.h"
#import "SUGlobalUpdateLock.h"
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
@@ -121,11 +122,11 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
if (updater)
{
{
self = updater;
}
else if (self)
{
}
else if (self)
{
if (sharedUpdaters == nil) {
sharedUpdaters = [[NSMutableDictionary alloc] init];
}
@@ -222,6 +223,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
[self.host setBool:NO forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];
}
[[SUGlobalUpdateLock sharedLock] unlock]; // For safety, remove active lock if present in any case and not just when relaunching from an app update
if (shouldPrompt) {
NSArray<NSDictionary<NSString *, NSString *> *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
// Always say we're sending the system profile here so that the delegate displays the parameters it would send.
@@ -248,8 +251,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)updateDriverDidFinish:(NSNotification *)note
{
if ([note object] == self.driver && [self.driver finished])
{
if ([note object] == self.driver && [self.driver finished])
{
self.driver = nil;
[self updateLastUpdateCheckDate];
[self scheduleNextUpdateCheck];
@@ -276,16 +279,16 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)scheduleNextUpdateCheck
{
if (self.checkTimer)
{
if (self.checkTimer)
{
[self.checkTimer invalidate];
self.checkTimer = nil; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
}
if (![self automaticallyChecksForUpdates]) return;
if (![self automaticallyChecksForUpdates]) return;
// How long has it been since last we checked for an update?
NSDate *lastCheckDate = [self lastUpdateCheckDate];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
// Now we want to figure out how long until we check again.
@@ -376,13 +379,13 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d
{
if ([self updateInProgress]) { return; }
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
if ([self updateInProgress]) { return; }
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
[self updateLastUpdateCheckDate];
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] )
{
{
[self scheduleNextUpdateCheck];
return;
}
@@ -414,8 +417,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)unregisterAsObserver
{
@try
{
@try
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey]];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey]];
@@ -428,7 +431,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext))
if (context == (__bridge void *)(SUUpdaterDefaultsObservationContext))
{
// Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking.
// Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them.
@@ -482,7 +485,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
}
// Otherwise, automatically downloading updates is allowed. Does the user want it?
return [self.host boolForUserDefaultsKey:SUAutomaticallyUpdateKey];
return [self.host boolForKey:SUAutomaticallyUpdateKey];
}
- (void)setFeedURL:(NSURL *)feedURL
@@ -564,12 +567,12 @@ static NSString *escapeURLComponent(NSString *str) {
if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) {
parameters = [parameters arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]];
}
if (sendingSystemProfile)
{
if (sendingSystemProfile)
{
parameters = [parameters arrayByAddingObjectsFromArray:[SUSystemProfiler systemProfileArrayForHost:self.host]];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastProfileSubmitDateKey];
}
if ([parameters count] == 0) { return baseFeedURL; }
if ([parameters count] == 0) { return baseFeedURL; }
// Build up the parameterized URL.
NSMutableArray *parameterStrings = [NSMutableArray array];
@@ -612,7 +615,7 @@ static NSString *escapeURLComponent(NSString *str) {
- (void)dealloc
{
[self unregisterAsObserver];
if (checkTimer) { [checkTimer invalidate]; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
if (checkTimer) { [checkTimer invalidate]; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
+1 -1
View File
@@ -36,7 +36,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
/*!
+6 -6
View File
@@ -33,8 +33,8 @@
});
return;
}
if (self.checkingController)
{
if (self.checkingController)
{
[[self.checkingController window] close];
self.checkingController = nil;
}
@@ -57,16 +57,16 @@
// For background applications, obtain focus.
// Useful if the update check is requested from another app like System Preferences.
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]])
{
if ([SUApplicationInfo isBackgroundApplication:[NSApplication sharedApplication]])
{
[NSApp activateIgnoringOtherApps:YES];
}
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
if (self.isCanceled)
{
if (self.isCanceled)
{
[self abortUpdate];
return;
}
+6
View File
@@ -12,6 +12,10 @@
// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
// there are name-space collisions) so we can list all of them to start with:
#pragma clang diagnostic push
// Do not use <> style includes since 2.x has two frameworks that need to work: Sparkle and SparkleCore
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUStandardVersionComparator.h"
@@ -30,4 +34,6 @@
#import "SPUURLRequest.h"
#import "SUCodeSigningVerifier.h"
#pragma clang diagnostic pop
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?" = "Aplikace %1$@ %2$@ byla stažena a je připravena k použití po příštím spuštění! Toto je důležitá aktualizace; přejete si aplikaci %1$@ nyní nainstalovat a znovu spustit?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "Aplikace %1$@ %2$@ byla stažean a je připravena k použití po příštím spuštění! Přejete si aplikaci %1$@ nyní nainstalovat a znovu spustit?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "Aplikace %1$@ %2$@ byla stažena a je připravena k použití po příštím spuštění! Přejete si aplikaci %1$@ nyní nainstalovat a znovu spustit?";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "Aplikace %1$@ nemůže být aktualizována, protože je spuštěna z dočasného umístění nebo z umístění, na které nelze zapisovat.";
+1
View File
@@ -17,6 +17,7 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUAutomaticUpdateAlert" animationBehavior="default" id="5" userLabel="Window">
<windowStyleMask key="styleMask" titled="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="114" y="521" width="616" height="152"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
+1
View File
@@ -25,6 +25,7 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window identifier="SUUpdateAlert" title="Software Update" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="746" y="229" width="620" height="370"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
+1 -1
View File
@@ -94,4 +94,4 @@
"You already have the newest version of %@." = "You already have the newest version of %@.";
/* Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates. */
"You're up-to-date!" = "You’re up-to-date!";
"You're up-to-date!" = "You’re up to date!";
+97
View File
@@ -0,0 +1,97 @@
"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ بارگیری شده و آمادهٔ استفاده است! این به‌روزرسانی مهمی است، آیا اکنون مایل به نصب و بازکردن دوبارهٔ %1$@ هستید؟";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ بارگیری شده و آمادهٔ استفاده است! آیا اکنون مایل به نصب و بازکردن دوبارهٔ %1$@ هستید؟";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "%1$@ نمی‌تواند به‌روزرسانی شود، زیرا از محلی با سطح دسترسی فقط-خواندن یا موقت باز شده است";
"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "از Finder برای کپی کردن %1$@ به پوشهٔ برنامه استفاده کنید، سپس %1$@ را دوباره باز کرده و مجدداً امتحان کنید.";
"Quit %1$@, move it into your Applications folder, relaunch it from there and try again." = "از %1$@ خارج شوید آن را به پوشهٔ برنامه انتقال دهید سپس آن را دوباره باز کرده و دوباره امتحان کنید.";
"%1$@ can’t be updated if it’s running from the location it was downloaded to." = "%1$@ نمی‌تواند به‌روزرسانی شود، اگر از محلی که در آن بارگیری شده باز شود";
"%@ %@ is currently the newest version available." = "%1$@ %2$@ در حال حاضر جدیدترین نسخهٔ موجود است";
"%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ در حال حاضر جدیدترین نسخه است.\n(شما در حال اجرای نسخهٔ %3$@ هستید.)";
/* Description text for SUUpdateAlert when the update is downloadable. */
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ اکنون در دسترس است-- نسخهٔ شما: %3$@. اکنون می‌خواهید آن را دریافت کنید؟";
/* Description text for SUUpdateAlert when the update informational with no download. */
"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ اکنون در دسترس است-- نسخهٔ شما: %3$@. می‌خواهید در مورد آن بیشتر یاد بگیرید؟";
"%@ downloaded" = "دانلود شده است %@";
"%@ of %@" = "%1$@ از %2$@";
"A new version of %@ is available!" = "نسخه‌ای جدید از %@ در دسترس است";
"A new version of %@ is ready to install!" = "نسخه‌ای جدید از %@ برای نصب آماده است!";
"An error occurred in retrieving update information. Please try again later." = "خطایی هنگام دستیابی به اطلاعات به‌روزرسانی رخ داد. لطفاً دوباره امتحان کنید.";
"An error occurred while downloading the update. Please try again later." = "خطایی در هنگام بارگیری به‌روزرسانی رخ داد. لطفاً دوباره امتحان کنید.";
"An error occurred while extracting the archive. Please try again later." = "خطایی در بازکردن آرشیو رخ داد. لطفاً دوباره امتحان کنید. ";
"An error occurred while installing the update. Please try again later." = "خطایی در هنگام نصب به‌روزرسانی رخ داد. لطفاً دوباره امتحان کنید.";
"An error occurred while parsing the update feed." = "خطایی در بررسی به‌روزرسانی رخ داد";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "خطایی در حین باز کردن دوبارهٔ %1$@ رخ داد، اما نسخهٔ جدید در هنگام اجرای بعدی %1$@ در دسترس خواهد بود.";
"An important update to %@ is ready to install" = "یک به‌روزرسانی مهم آمادهٔ نصب است";
/* the unit for bytes */
"B" = "بایت";
"Cancel" = "لغو";
"Cancel Update" = "لغو به‌روزرسانی";
"Checking for updates..." = "بررسی وجود به‌روزرسانی";
/* Take care not to overflow the status window. */
"Downloading update..." = "در حال بارگیری به‌روزرسانی";
/* Take care not to overflow the status window. */
"Extracting update..." = "در حال بازکردن بستهٔ به‌روزرسانی";
/* the unit for gigabytes */
"GB" = "گیگابایت";
"Install and Relaunch" = "نصب و بازکردن دوباره";
/* Take care not to overflow the status window. */
"Installing update..." = "در حال نصب به‌روزرسانی";
/* the unit for kilobytes */
"KB" = "کیلوبایت";
/* Alternative name for "Install" button if we have a paid update or other update
without a download but with a URL. */
"Learn More..." = "یادگیری بیشتر...";
/* the unit for megabytes */
"MB" = "مگابایت";
/* OK button. */
"OK" = "پذیرفتن";
/* Status message on progress window once download has finished. */
"Ready to Install" = "آماده برای نصب";
/* Message that is optionally shown at startup to allow users to turn on/off update checks. */
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "آیا می‌خواهید بررسی به‌روزرسانی‌ها %1$@ به صورت خودکار انجام شود؟ همیشه می‌توانید به‌روزرسانی‌های %1$@ را به صورت دستی بررسی کنید.";
"The update is improperly signed." = "این به‌روزرسانی به‌درستی امضا نشده است";
"Update Error!" = "خطای به‌روزرسانی!";
"Updating %@" = "%@ در حال به‌روزرسانی";
/* 'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI) */
"You already have the newest version of %@." = "شما در حال استفاده از جدیدترین نسخهٔ %@ هستید.";
/* Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates. */
"You're up-to-date!" = "برنامهٔ شما به‌روز است";
+2 -2
View File
@@ -61,7 +61,7 @@
<button verticalHuggingPriority="750" misplaced="YES" id="15">
<rect key="frame" x="407" y="12" width="195" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<buttonCell key="cell" type="push" title="Instaliraj i ponovo pokreni" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="41">
<buttonCell key="cell" type="push" title="Instaliraj i pokreni ponovo" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="41">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
@@ -75,7 +75,7 @@ DQ
<button verticalHuggingPriority="750" id="30">
<rect key="frame" x="102" y="12" width="116" height="32"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="push" title="Ne instaliraj" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="44">
<buttonCell key="cell" type="push" title="Nemoj instalirati" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="44">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
+3 -3
View File
@@ -24,7 +24,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window identifier="SUUpdateAlert" title="Aktualiziranje programskog paketa" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<window identifier="SUUpdateAlert" title="Aktualiziranje softvera" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="746" y="229" width="620" height="370"/>
@@ -121,7 +121,7 @@
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="100" constant="100" id="gkn-FW-9aC"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Napomene izdanja:" usesSingleLineMode="YES" id="170">
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Napomene uz izdanje:" usesSingleLineMode="YES" id="170">
<font key="font" metaFont="smallSystemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -146,7 +146,7 @@
</customView>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="998" translatesAutoresizingMaskIntoConstraints="NO" id="23">
<rect key="frame" x="103" y="12" width="169" height="32"/>
<buttonCell key="cell" type="push" title="Zanemari ovu inačicu" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="172">
<buttonCell key="cell" type="push" title="Zanemari ovu verziju" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="172">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
+5 -5
View File
@@ -32,7 +32,7 @@
<button verticalHuggingPriority="750" misplaced="YES" tag="1" id="13">
<rect key="frame" x="247" y="12" width="177" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<buttonCell key="cell" type="push" title="Provjeravaj automatski" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" tag="1" inset="2" id="176">
<buttonCell key="cell" type="push" title="Provjeri automatski" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" tag="1" inset="2" id="176">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
@@ -46,7 +46,7 @@ DQ
<textField verticalHuggingPriority="750" misplaced="YES" id="32">
<rect key="frame" x="104" y="114" width="289" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Provjeravaj nadogradnje automatski?" id="178">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Automatski provjeriti nadogradnje?" id="178">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -112,7 +112,7 @@ DQ
<button verticalHuggingPriority="750" misplaced="YES" id="14">
<rect key="frame" x="100" y="12" width="127" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<buttonCell key="cell" type="push" title="Ne provjeravaj" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="177">
<buttonCell key="cell" type="push" title="Nemoj provjeravati" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="177">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
@@ -146,9 +146,9 @@ Gw
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="183">
<font key="font" metaFont="smallSystem"/>
<string key="title">Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this.
<string key="title">Anonimizirani podaci profila susatava pomažu nam planirati budući razvoj. Kontaktiraj nas, ako imaš pitanja o tome.
This is the information that would be sent:</string>
Šalju se sljedeći podaci:</string>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
+17 -17
View File
@@ -1,28 +1,28 @@
"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ je preuzeto i spremno za upotrebu! Ovo je važna nadogradnja. Želiš li je sada instalirati, te ponovo pokrenuti %1$@?";
"%1$@ %2$@ has been downloaded and is ready to use! This is an important update; would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ je preuzeta i spremna za upotrebu! Ovo je važna nadogradnja. Želiš li je sada instalirati, te ponovo pokrenuti %1$@?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ je preuzeto i spremno za upotrebu! Želiš li je sada instalirati, te ponovo pokrenuti %1$@?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ je preuzeta i spremna za upotrebu! Želiš li je sada instalirati, te ponovo pokrenuti %1$@?";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "%1$@ nije moguće aktualizirati, jer je pokrenuto s lokacije bez korisničkih prava pisanja, npr. dmg.";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "%1$@ nije moguće aktualizirati, jer je pokrenuta s lokacije bez korisničkih prava pisanja, npr. dmg.";
"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "Kopiraj %1$@ u mapu Aplikacije, pokreni je odande i pokušaj ponovo.";
"%@ %@ is currently the newest version available." = "%1$@ %2$@ je trenutačno najnovija dostupna inačica.";
"%@ %@ is currently the newest version available." = "%1$@ %2$@ je trenutačno najnovija dostupna verzija.";
"%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ je trenutačno najnovija dostupna inačica.\n(You are currently running version %3$@.)";
"%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ je trenutačno najnovija dostupna verzija.\n(Trenutačno pokrećeš verziju %3$@.)";
/* Description text for SUUpdateAlert when the update is downloadable. */
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ je sada dostupna. Ti koristiš inačicu %3$@. Želiš li je sada preuzeti?";
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ je sada dostupna. Ti koristiš verziju %3$@. Želiš li je sada preuzeti?";
/* Description text for SUUpdateAlert when the update informational with no download. */
"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ je sada dostupna. Ti koristiš inačicu %3$@. Želiš li saznati više o ovoj nadogradnji na webu?";
"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ je sada dostupna. Ti koristiš verziju %3$@. Želiš li saznati više o ovoj nadogradnji na našim web-stranicama?";
"%@ downloaded" = "%@ preuzeto";
"%@ of %@" = "%1$@ od %2$@";
"A new version of %@ is available!" = "Dostupna je nova inačica za %@!";
"A new version of %@ is available!" = "Dostupna je nova verzija za %@!";
"A new version of %@ is ready to install!" = "Nova inačica za %@ je spremna za instaliranje!";
"A new version of %@ is ready to install!" = "Nova verzija za %@ je spremna za instaliranje!";
"An error occurred in retrieving update information. Please try again later." = "Dogodila se greška u dohvaćanju informacija o nadogradnji. Pokušaj kasnije ponovo.";
@@ -32,9 +32,9 @@
"An error occurred while installing the update. Please try again later." = "Dogodila se greška prilikom instaliranja nadogradnje. Pokušaj kasnije ponovo.";
"An error occurred while parsing the update feed." = "Dogodila se greška prilikom analize nadogradnje.";
"An error occurred while parsing the update feed." = "Dogodila se greška prilikom obrađivanja nadogradnje.";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "Dogodila se greška prilikom ponovog pokretanja %1$@. Unatoč tome, nova inačica će biti dostupna prilikom idućeg pokretanja %1$@.";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "Dogodila se greška prilikom ponovog pokretanja %1$@a. Unatoč tome, nova verzija će biti dostupna prilikom idućeg pokretanja %1$@a.";
"An important update to %@ is ready to install" = "Važna nadogradnja za %@ je spremna za instaliranje";
@@ -43,7 +43,7 @@
"Cancel" = "Odustani";
"Cancel Update" = "Odustani od aktualiziranja";
"Cancel Update" = "Prekini aktualiziranje";
"Checking for updates..." = "Provjera nadogradnji …";
@@ -78,16 +78,16 @@
"Ready to Install" = "Spremno za instaliranje";
/* Message that is optionally shown at startup to allow users to turn on/off update checks. */
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Da li da %1$@ automatski provjerava nadogradnje? Nadogradnje možeš i ručno provjeriti u %1$@ izborniku.";
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Želiš li da %1$@ automatski provjerava nadogradnje? Nadogradnje možeš i ručno provjeriti u %1$@ izborniku.";
"The update is improperly signed." = "Nadogradnja ima neispravnu signaturu.";
"The update is improperly signed." = "Nadogradnja ima neispravan potpis.";
"Update Error!" = "Greška prilikom aktualiziranja!";
"Updating %@" = "Aktualiziranje %@";
"Updating %@" = "%@ se aktualizira";
/* 'Error' message when the user checks for updates but is already current or the feed doesn't contain any updates. (not necessarily shown in UI) */
"You already have the newest version of %@." = "Već koristiš najnoviju inačicu za %@.";
"You already have the newest version of %@." = "Već koristiš najnoviju verziju za %@.";
/* Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates. */
"You're up-to-date!" = "Koristiš najnoviju inačicu!";
"You're up-to-date!" = "Koristiš najnoviju verziju!";
+1 -1
View File
@@ -23,7 +23,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window identifier="SUUpdateAlert" title="Software Update" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<window identifier="SUUpdateAlert" title="Uaktualnienie oprogramowania" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="746" y="229" width="620" height="370"/>
+6 -6
View File
@@ -1,6 +1,6 @@
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ 已下载完毕并可以使用!您想要现在安装 %1$@ 吗?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ 已下载完毕并可以使用。您想要现在安装 %1$@ 吗?";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "无法更新 %1$@,因为它运行于一个只读宗卷如磁盘映像或光盘。";
"%1$@ can't be updated, because it was opened from a read-only or a temporary location." = "无法更新 %1$@,因为它运行于一个只读或临时位置。";
"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again." = "移动 %1$@ 到应用程序文件夹并再试一次。";
@@ -10,12 +10,12 @@
"%@ %@ is currently the newest version available." = "%1$@ %2$@ 是当前的最新版本。";
"%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ 是当前的最新版本。\n(You are currently running version %3$@.)";
"%@ %@ is currently the newest version available.\n(You are currently running version %@.)" = "%1$@ %2$@ 是当前的最新版本(您正在运行 %3$@)。";
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 可供下载,您现在的版本是 %3$@。要现在下载吗?";
/* Description text for SUUpdateAlert when the update informational with no download. */
"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?";
"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ 已经推出,您正在运行 %3$@。您要在网站上查看关于更新的更多信息吗?";
"%@ downloaded" = "%@ 已下载";
@@ -35,7 +35,7 @@
"An error occurred while parsing the update feed." = "解析更新信息时出现错误,请稍后再试。";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "重新启动 %1$@ 时出现错误,但在下次运行 %1$@ 时新版本将可使用。";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "重新启动 %1$@ 时出现错误,在下次运行 %1$@ 时将会使用新版本。";
/* the unit for bytes */
"B" = "B";
@@ -83,4 +83,4 @@
/* Alternative name for "Install" button if we have a paid update or other update
without a download but with a URL. */
"Learn More..." = "下载更新包";
"Learn More..." = "查看更多…";
+4
View File
@@ -0,0 +1,4 @@
# Inherits from top level config
disabled_rules:
- force_try
- force_cast
+28 -27
View File
@@ -10,30 +10,30 @@ import XCTest
import Sparkle
class SPUDownloaderTestDelegate: NSObject, SPUDownloaderDelegate {
var asyncExpectation: XCTestExpectation?
var tempResult: SPUDownloadData?
var downloadPath: URL?
func downloaderDidReceiveData(ofLength length: UInt64)
{
}
func downloaderDidReceiveExpectedContentLength(_ expectedContentLength: Int64)
{
}
func downloaderDidSetDestinationName(_ destinationName: String, temporaryDirectory: String)
{
self.downloadPath = NSURL(fileURLWithPath: temporaryDirectory).appendingPathComponent(destinationName)
}
func downloaderDidFailWithError(_ error: Error)
{
XCTFail(error.localizedDescription);
XCTFail(error.localizedDescription)
self.asyncExpectation?.fulfill()
}
func downloaderDidFinish(withTemporaryDownloadData downloadData: SPUDownloadData?)
{
self.tempResult = downloadData
@@ -47,35 +47,35 @@ class SPUDownloaderTest: XCTestCase
{
let delegateExpectation = expectation(description: "SPUDownloader temporary download")
delegate.asyncExpectation = delegateExpectation
let url = URL.init(string: "https://sparkle-project.org/unit_test/test.xml")
var request = URLRequest(url: url!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 30.0)
request.setValue("application/rss+xml,*/*;q=0.1", forHTTPHeaderField: "Accept")
let downloaderRequest = SPUURLRequest(request: request as URLRequest)
downloader.startTemporaryDownload(with: downloaderRequest)
super.waitForExpectations(timeout: 30.0) { error in
if let error = error {
XCTFail("waitForExpectations had error: \(error)")
}
guard let result = delegate.tempResult else {
XCTFail("Expected result to be non-nil")
return
}
let str = String.init(data: result.data,
encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
XCTAssert(str == "<test>appcast</test>\n")
}
}
// SHA256 code from: https://stackoverflow.com/a/42934185/3938401
func sha256(data: Data) -> Data
{
var digestData = Data(count: Int(CC_SHA256_DIGEST_LENGTH))
_ = digestData.withUnsafeMutableBytes {digestBytes in
data.withUnsafeBytes {messageBytes in
CC_SHA256(messageBytes, CC_LONG(data.count), digestBytes)
@@ -83,59 +83,60 @@ class SPUDownloaderTest: XCTestCase
}
return digestData
}
func performPersistentDownloadTest(withDownloader downloader: SPUDownloader, delegate: SPUDownloaderTestDelegate)
{
let delegateExpectation = expectation(description: "SPUDownloader persistent download")
delegate.asyncExpectation = delegateExpectation
let url = URL.init(string: "https://sparkle-project.org/unit_test/icon.png")
var request = URLRequest(url: url!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 30.0)
request.setValue("image/png", forHTTPHeaderField: "Accept")
let downloaderRequest = SPUURLRequest(request: request as URLRequest)
let bundleIdentifier = Bundle.init(for: self.superclass!).bundleIdentifier
downloader.startPersistentDownload(with: downloaderRequest, bundleIdentifier: bundleIdentifier!, desiredFilename: "icon")
super.waitForExpectations(timeout: 30.0) { error in
if let error = error {
XCTFail("waitForExpectations had error: \(error)")
}
guard let filePath = delegate.downloadPath else {
XCTFail("Expected download path to be non-nil")
return
}
let fileManager = FileManager.default
XCTAssert(fileManager.fileExists(atPath: filePath.path))
do {
let iconData = try Data.init(contentsOf: filePath)
let sha256HashData = self.sha256(data: iconData)
let hashString = sha256HashData.map { String(format: "%02hhx", $0) }.joined().uppercased()
XCTAssert(hashString == "F262E65663C505B9C6449B61660FA3F223912465AE637014288294A8CB286B85")
} catch {
XCTFail("Something went wrong reading the file data")
}
}
}
func testDeprecatedDownloader()
{
let delegate = SPUDownloaderTestDelegate()
let downloader = SPUDownloaderDeprecated(delegate: delegate)
var downloader = SPUDownloaderDeprecated(delegate: delegate)
self.performTemporaryDownloadTest(withDownloader: downloader!, delegate: delegate)
downloader = SPUDownloaderDeprecated(delegate: delegate)
self.performPersistentDownloadTest(withDownloader: downloader!, delegate: delegate)
}
func testSessionDownloader()
{
let delegate = SPUDownloaderTestDelegate()
var downloader = SPUDownloaderSession(delegate: delegate)
self.performTemporaryDownloadTest(withDownloader: downloader!, delegate: delegate)
downloader = SPUDownloaderSession(delegate: delegate)
self.performPersistentDownloadTest(withDownloader: downloader!, delegate: delegate)
+49 -49
View File
@@ -7,64 +7,64 @@
//
import XCTest
import Sparkle;
import Sparkle
class SUAppcastTest: XCTestCase {
func testParseAppcast() {
let appcast = SUAppcast();
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);
let appcast = SUAppcast()
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testappcast", ofType: "xml")!
let testFileUrl = URL(fileURLWithPath: testFile)
XCTAssertNotNil(testFileUrl)
do {
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
XCTAssertEqual(4, items.count);
XCTAssertEqual("Version 2.0", items[0].title);
XCTAssertEqual("desc", items[0].itemDescription);
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem]
XCTAssertEqual(4, items.count)
XCTAssertEqual("Version 2.0", items[0].title)
XCTAssertEqual("desc", items[0].itemDescription)
XCTAssertEqual("Sat, 26 Jul 2014 15:20:11 +0000", items[0].dateString)
XCTAssertTrue(items[0].isCriticalUpdate);
XCTAssertTrue(items[0].isCriticalUpdate)
// This is the best release matching our system version
XCTAssertEqual("Version 3.0", items[1].title);
XCTAssertNil(items[1].itemDescription);
XCTAssertEqual("Version 3.0", items[1].title)
XCTAssertNil(items[1].itemDescription)
XCTAssertNil(items[1].dateString)
XCTAssertFalse(items[1].isCriticalUpdate);
XCTAssertEqual(items[1].phasedRolloutInterval, 86400);
XCTAssertEqual("Version 4.0", items[2].title);
XCTAssertNil(items[2].itemDescription);
XCTAssertFalse(items[1].isCriticalUpdate)
XCTAssertEqual(items[1].phasedRolloutInterval, 86400)
XCTAssertEqual("Version 4.0", items[2].title)
XCTAssertNil(items[2].itemDescription)
XCTAssertEqual("Sat, 26 Jul 2014 15:20:13 +0000", items[2].dateString)
XCTAssertFalse(items[2].isCriticalUpdate);
XCTAssertEqual("Version 5.0", items[3].title);
XCTAssertNil(items[3].itemDescription);
XCTAssertFalse(items[2].isCriticalUpdate)
XCTAssertEqual("Version 5.0", items[3].title)
XCTAssertNil(items[3].itemDescription)
XCTAssertNil(items[3].dateString)
XCTAssertFalse(items[3].isCriticalUpdate);
XCTAssertFalse(items[3].isCriticalUpdate)
// Test best appcast item & a delta update item
var deltaItem: SUAppcastItem? = nil
var deltaItem: SUAppcastItem?
let bestAppcastItem = SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator.default())
XCTAssertEqual(bestAppcastItem, items[1])
XCTAssertEqual(deltaItem!.fileURL.lastPathComponent, "3.0_from_1.0.patch")
// Test latest delta update item available
var latestDeltaItem: SUAppcastItem? = nil
var latestDeltaItem: SUAppcastItem?
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator.default())
XCTAssertEqual(latestDeltaItem!.fileURL.lastPathComponent, "3.0_from_2.0.patch")
// Test a delta item that does not exist
var nonexistantDeltaItem: SUAppcastItem? = nil
var nonexistantDeltaItem: SUAppcastItem?
SUBasicUpdateDriver.bestItem(fromAppcastItems: items, getDeltaItem: &nonexistantDeltaItem, withHostVersion: "2.1", comparator: SUStandardVersionComparator.default())
XCTAssertNil(nonexistantDeltaItem)
} catch let err as NSError {
NSLog("%@", err);
XCTFail(err.localizedDescription);
NSLog("%@", err)
XCTFail(err.localizedDescription)
}
}
@@ -76,7 +76,7 @@ class SUAppcastTest: XCTestCase {
XCTAssertNotNil(testFileUrl)
do {
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem]
XCTAssertEqual("https://sparkle-project.org/#localized_notes_link_works", items[0].releaseNotesURL.absoluteString)
} catch let err as NSError {
NSLog("%@", err)
@@ -85,23 +85,23 @@ class SUAppcastTest: XCTestCase {
}
func testNamespaces() {
let appcast = SUAppcast();
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!;
let testFileUrl = URL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);
let appcast = SUAppcast()
let testFile = Bundle(for: SUAppcastTest.self).path(forResource: "testnamespaces", ofType: "xml")!
let testFileUrl = URL(fileURLWithPath: testFile)
XCTAssertNotNil(testFileUrl)
do {
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem];
let items = try appcast.parseAppcastItems(fromXMLFile: testFileUrl) as! [SUAppcastItem]
XCTAssertEqual(2, items.count);
XCTAssertEqual(2, items.count)
XCTAssertEqual("Version 2.0", items[1].title);
XCTAssertEqual("desc", items[1].itemDescription);
XCTAssertNotNil(items[0].releaseNotesURL);
XCTAssertEqual("https://sparkle-project.org/#works", items[0].releaseNotesURL!.absoluteString);
XCTAssertEqual("Version 2.0", items[1].title)
XCTAssertEqual("desc", items[1].itemDescription)
XCTAssertNotNil(items[0].releaseNotesURL)
XCTAssertEqual("https://sparkle-project.org/#works", items[0].releaseNotesURL!.absoluteString)
} catch let err as NSError {
NSLog("%@", err);
XCTFail(err.localizedDescription);
NSLog("%@", err)
XCTFail(err.localizedDescription)
}
}
+5
View File
@@ -11,7 +11,12 @@
#import "SUCodeSigningVerifier.h"
#import "SUFileManager.h"
#if defined(__MAC_10_15)
// In macOS 10.15 and later, pre-installed apps are installed under the System folder
#define CALCULATOR_PATH @"/System/Applications/Calculator.app"
#else
#define CALCULATOR_PATH @"/Applications/Calculator.app"
#endif
@interface SUCodeSigningVerifierTest : XCTestCase
+70 -70
View File
@@ -13,54 +13,54 @@ class SUFileManagerTest: XCTestCase
func makeTempFiles(_ testBlock: (SUFileManager, URL, URL, URL, URL, URL, URL) -> Void)
{
let fileManager = SUFileManager.default()
let tempDirectoryURL = (try! fileManager.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory())))
defer {
try! fileManager.removeItem(at: tempDirectoryURL)
}
let ordinaryFileURL = tempDirectoryURL.appendingPathComponent("a file written by sparkles unit tests")
try! "foo".data(using: String.Encoding.utf8)!.write(to: ordinaryFileURL, options: .atomic)
let directoryURL = tempDirectoryURL.appendingPathComponent("a directory written by sparkles unit tests")
try! FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: false, attributes: nil)
let fileInDirectoryURL = directoryURL.appendingPathComponent("a file inside a directory written by sparkles unit tests")
try! "bar baz".data(using: String.Encoding.utf8)!.write(to: fileInDirectoryURL, options: .atomic)
let validSymlinkURL = tempDirectoryURL.appendingPathComponent("symlink test")
try! FileManager.default.createSymbolicLink(at: validSymlinkURL, withDestinationURL: directoryURL)
let invalidSymlinkURL = tempDirectoryURL.appendingPathComponent("symlink test 2")
try! FileManager.default.createSymbolicLink(at: invalidSymlinkURL, withDestinationURL: (tempDirectoryURL.appendingPathComponent("does not exist")))
testBlock(fileManager, tempDirectoryURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL)
}
func testMoveFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL))
XCTAssertNil(try? fileManager.moveItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
XCTAssertNil(try? fileManager.moveItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
try! fileManager.moveItem(at: ordinaryFileURL, to: newFileURL)
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
let newValidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink"))
try! fileManager.moveItem(at: validSymlinkURL, to: newValidSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
let newInvalidSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new invalid symlink"))
try! fileManager.moveItem(at: invalidSymlinkURL, to: newInvalidSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: invalidSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: newValidSymlinkURL))
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
try! fileManager.moveItem(at: directoryURL, to: newDirectoryURL)
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
@@ -69,23 +69,23 @@ class SUFileManagerTest: XCTestCase
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL.appendingPathComponent(fileInDirectoryURL.lastPathComponent)))
}
}
func testCopyFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, _, invalidSymlinkURL in
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL))
XCTAssertNil(try? fileManager.copyItem(at: ordinaryFileURL, to: directoryURL.appendingPathComponent("foo").appendingPathComponent("bar")))
XCTAssertNil(try? fileManager.copyItem(at: rootURL.appendingPathComponent("does not exist"), to: directoryURL))
let newFileURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new file"))
try! fileManager.copyItem(at: ordinaryFileURL, to: newFileURL)
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: newFileURL))
let newSymlinkURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new symlink file"))
try! fileManager.copyItem(at: invalidSymlinkURL, to: newSymlinkURL)
XCTAssertTrue(fileManager._itemExists(at: newSymlinkURL))
let newDirectoryURL = (ordinaryFileURL.deletingLastPathComponent().appendingPathComponent("new directory"))
try! fileManager.copyItem(at: directoryURL, to: newDirectoryURL)
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
@@ -97,80 +97,80 @@ class SUFileManagerTest: XCTestCase
func testRemoveFiles()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
XCTAssertNil(try? fileManager.removeItem(at: rootURL.appendingPathComponent("does not exist")))
try! fileManager.removeItem(at: ordinaryFileURL)
XCTAssertFalse(fileManager._itemExists(at: ordinaryFileURL))
try! fileManager.removeItem(at: validSymlinkURL)
XCTAssertFalse(fileManager._itemExists(at: validSymlinkURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
try! fileManager.removeItem(at: directoryURL)
XCTAssertFalse(fileManager._itemExists(at: directoryURL))
XCTAssertFalse(fileManager._itemExists(at: fileInDirectoryURL))
}
}
func testReleaseFilesFromQuarantine()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, _, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
let quarantineData = "does not really matter what is here".cString(using: String.Encoding.utf8)!
let quarantineDataLength = Int(strlen(quarantineData))
XCTAssertEqual(0, setxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
try! fileManager.releaseItemFromQuarantine(atRootURL: ordinaryFileURL)
XCTAssertEqual(-1, getxattr(ordinaryFileURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(0, setxattr(directoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(0, setxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
// Extended attributes can't be set on symbolic links currently
try! fileManager.releaseItemFromQuarantine(atRootURL: validSymlinkURL)
XCTAssertGreaterThan(getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(-1, getxattr(validSymlinkURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
try! fileManager.releaseItemFromQuarantine(atRootURL: directoryURL)
XCTAssertEqual(-1, getxattr(directoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
}
}
func groupIDAtPath(_ path: String) -> gid_t
{
let attributes = try! FileManager.default.attributesOfItem(atPath: path)
let groupID = attributes[FileAttributeKey.groupOwnerAccountID] as! NSNumber
return groupID.uint32Value
}
// Only the super user can alter user IDs, so changing user IDs is not tested here
// Instead we try to change the group ID - we just have to be a member of that group
func testAlterFilesGroupID()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, _ in
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: rootURL.appendingPathComponent("does not exist")))
XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItem(atRootURL: rootURL.appendingPathComponent("does not exist"), toMatch: ordinaryFileURL))
let everyoneGroup = getgrnam("everyone")
let everyoneGroupID = everyoneGroup?.pointee.gr_gid
let staffGroup = getgrnam("staff")
let staffGroupID = staffGroup?.pointee.gr_gid
XCTAssertNotEqual(staffGroupID, everyoneGroupID)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
@@ -179,103 +179,103 @@ class SUFileManagerTest: XCTestCase
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: ordinaryFileURL, toMatch: ordinaryFileURL)
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(staffGroupID, self.groupIDAtPath(validSymlinkURL.path))
XCTAssertEqual(0, chown(ordinaryFileURL.path, getuid(), everyoneGroupID!))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(ordinaryFileURL.path))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: fileInDirectoryURL, toMatch: directoryURL)
XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: validSymlinkURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(validSymlinkURL.path))
try! fileManager.changeOwnerAndGroupOfItem(atRootURL: directoryURL, toMatch: ordinaryFileURL)
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(directoryURL.path))
XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path))
}
}
func testUpdateFileModificationTime()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, _ in
XCTAssertNil(try? fileManager.updateModificationAndAccessTimeOfItem(at: rootURL.appendingPathComponent("does not exist")))
let oldOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
let oldDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
let oldValidSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
sleep(1); // wait for clock to advance
try! fileManager.updateModificationAndAccessTimeOfItem(at: ordinaryFileURL)
try! fileManager.updateModificationAndAccessTimeOfItem(at: directoryURL)
try! fileManager.updateModificationAndAccessTimeOfItem(at: validSymlinkURL)
let newOrdinaryFileAttributes = try! FileManager.default.attributesOfItem(atPath: ordinaryFileURL.path)
XCTAssertGreaterThan((newOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldOrdinaryFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: directoryURL.path)
XCTAssertGreaterThan((newDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newSymlinkAttributes = try! FileManager.default.attributesOfItem(atPath: validSymlinkURL.path)
XCTAssertGreaterThan((newSymlinkAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldValidSymlinkAttributes[FileAttributeKey.modificationDate] as! Date), 0)
}
}
func testFileExists()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, invalidSymlinkURL in
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL))
XCTAssertTrue(fileManager._itemExists(at: directoryURL))
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist")))
var isOrdinaryFileDirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExists(at: ordinaryFileURL, isDirectory: &isOrdinaryFileDirectory) && !isOrdinaryFileDirectory.boolValue)
var isDirectoryADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExists(at: directoryURL, isDirectory: &isDirectoryADirectory) && isDirectoryADirectory.boolValue)
XCTAssertFalse(fileManager._itemExists(at: rootURL.appendingPathComponent("does not exist"), isDirectory: nil))
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL))
var validSymlinkIsADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExists(at: validSymlinkURL, isDirectory: &validSymlinkIsADirectory) && !validSymlinkIsADirectory.boolValue)
// Symlink should still exist even if it doesn't point to a file that exists
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL))
var invalidSymlinkIsADirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExists(at: invalidSymlinkURL, isDirectory: &invalidSymlinkIsADirectory) && !invalidSymlinkIsADirectory.boolValue)
}
}
func testMakeDirectory()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, _, validSymlinkURL, _ in
XCTAssertNil(try? fileManager.makeDirectory(at: ordinaryFileURL))
XCTAssertNil(try? fileManager.makeDirectory(at: directoryURL))
XCTAssertNil(try? fileManager.makeDirectory(at: rootURL.appendingPathComponent("this should").appendingPathComponent("be a failure")))
let newDirectoryURL = rootURL.appendingPathComponent("new test directory")
XCTAssertFalse(fileManager._itemExists(at: newDirectoryURL))
try! fileManager.makeDirectory(at: newDirectoryURL)
var isDirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExists(at: newDirectoryURL, isDirectory: &isDirectory))
try! fileManager.removeItem(at: directoryURL)
XCTAssertNil(try? fileManager.makeDirectory(at: validSymlinkURL))
}
}
func testAcquireBadAuthorization()
{
let fileManager = SUFileManager.default()
+14 -14
View File
@@ -14,47 +14,47 @@ class SUSpotlightImporterTest: XCTestCase
{
let fileManager = SUFileManager.default()
let tempDirectoryURL = try! fileManager.makeTemporaryDirectory(withPreferredName: "Sparkle Unit Test Data", appropriateForDirectoryURL: URL(fileURLWithPath: NSHomeDirectory()))
let bundleDirectory = tempDirectoryURL.appendingPathComponent("bundle.app")
try! fileManager.makeDirectory(at: bundleDirectory)
let innerDirectory = bundleDirectory.appendingPathComponent("foo")
try! fileManager.makeDirectory(at: innerDirectory)
try! Data().write(to: (bundleDirectory.appendingPathComponent("bar")), options: .atomicWrite)
let importerDirectory = innerDirectory.appendingPathComponent("baz.mdimporter")
try! fileManager.makeDirectory(at: importerDirectory)
try! fileManager.makeDirectory(at: innerDirectory.appendingPathComponent("flag"))
try! Data().write(to: (importerDirectory.appendingPathComponent("file")), options: .atomicWrite)
let oldFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.path)
let oldBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory.appendingPathComponent("bar").path)
let oldImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.path)
let oldFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.appendingPathComponent("flag").path)
let oldFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.appendingPathComponent("file").path)
sleep(1) // wait for clock to advance
// Update spotlight bundles
SUBinaryDeltaUnarchiver.updateSpotlightImporters(atBundlePath: bundleDirectory.path)
let newFooDirectoryAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.path)
XCTAssertEqual((newFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFooDirectoryAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newBarFileAttributes = try! FileManager.default.attributesOfItem(atPath: bundleDirectory.appendingPathComponent("bar").path)
XCTAssertEqual((newBarFileAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldBarFileAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.path)
XCTAssertGreaterThan((newImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newFlagAttributes = try! FileManager.default.attributesOfItem(atPath: innerDirectory.appendingPathComponent("flag").path)
XCTAssertEqual((newFlagAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFlagAttributes[FileAttributeKey.modificationDate] as! Date), 0)
let newFileInImporterAttributes = try! FileManager.default.attributesOfItem(atPath: importerDirectory.appendingPathComponent("file").path)
XCTAssertEqual((newFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date).timeIntervalSince(oldFileInImporterAttributes[FileAttributeKey.modificationDate] as! Date), 0)
try! fileManager.removeItem(at: tempDirectoryURL)
}
}
+30 -29
View File
@@ -13,84 +13,85 @@ class SUUnarchiverTest: XCTestCase
func unarchiveTestAppWithExtension(_ archiveExtension: String, password: String? = nil) {
let appName = "SparkleTestCodeSignApp"
let archiveResourceURL = Bundle(for: type(of: self)).url(forResource: appName, withExtension: archiveExtension)!
let fileManager = FileManager.default
// Do not remove this temporary directory
// If we do want to clean up and remove it (which isn't necessary but nice), we'd have to remove it
// after *both* our unarchive success and failure calls below finish (they both have async completion blocks inside their implementation)
let tempDirectoryURL = try! fileManager.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: URL(fileURLWithPath: NSHomeDirectory()), create: true)
let unarchivedSuccessExpectation = super.expectation(description: "Unarchived Success (format: \(archiveExtension))")
let unarchivedFailureExpectation = super.expectation(description: "Unarchived Failure (format: \(archiveExtension))")
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
self.unarchiveTestSuccessAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, testExpectation: unarchivedSuccessExpectation);
self.unarchiveTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation);
self.unarchiveTestSuccessAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, testExpectation: unarchivedSuccessExpectation)
self.unarchiveTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
super.waitForExpectations(timeout: 7.0, handler: nil)
XCTAssertTrue(fileManager.fileExists(atPath: extractedAppURL.path))
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path))
}
func unarchiveTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension);
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension)
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
XCTAssertNotNil(error);
XCTAssertNotNil(error)
testExpectation.fulfill()
}, progressBlock: nil);
}, progressBlock: nil)
}
// swiftlint:disable function_parameter_count
func unarchiveTestSuccessAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, testExpectation: XCTestExpectation) {
let fileManager = FileManager.default
try! fileManager.copyItem(at: archiveResourceURL, to: tempArchiveURL)
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
XCTAssertNil(error);
XCTAssertNil(error)
testExpectation.fulfill()
}, progressBlock: nil);
}, progressBlock: nil)
}
func testUnarchivingZip()
{
self.unarchiveTestAppWithExtension("zip")
}
func testUnarchivingTarDotGz()
{
self.unarchiveTestAppWithExtension("tar.gz")
}
func testUnarchivingTar()
{
self.unarchiveTestAppWithExtension("tar")
}
func testUnarchivingTarDotBz2()
{
self.unarchiveTestAppWithExtension("tar.bz2")
}
func testUnarchivingTarDotXz()
{
self.unarchiveTestAppWithExtension("tar.xz")
}
func testUnarchivingDmg()
{
self.unarchiveTestAppWithExtension("dmg")
}
func testUnarchivingEncryptedDmg()
{
self.unarchiveTestAppWithExtension("enc.dmg", password: "testpass")
+5 -5
View File
@@ -79,11 +79,11 @@
{
// SUStandardVersionComparator *comparator = [[SUStandardVersionComparator alloc] init];
// SUAssertAscending(comparator, @"1.0 beta", @"1.0");
// SUAssertAscending(comparator, @"1.0 - beta", @"1.0");
// SUAssertAscending(comparator, @"1.0 alpha", @"1.0 beta");
// SUAssertEqual(comparator, @"1.0 - beta", @"1.0beta");
// SUAssertEqual(comparator, @"1.0 - beta", @"1.0 beta");
// SUAssertAscending(comparator, @"1.0 beta", @"1.0");
// SUAssertAscending(comparator, @"1.0 - beta", @"1.0");
// SUAssertAscending(comparator, @"1.0 alpha", @"1.0 beta");
// SUAssertEqual(comparator, @"1.0 - beta", @"1.0beta");
// SUAssertEqual(comparator, @"1.0 - beta", @"1.0 beta");
}
- (void)testVersionsWithReverseDateBasedNumbers
+4
View File
@@ -0,0 +1,4 @@
# Inherits from top level config
disabled_rules:
- force_try
- force_cast
+29 -29
View File
@@ -10,10 +10,10 @@ import XCTest
class SUTestApplicationTest: XCTestCase
{
var testApplicationURL: URL? = nil
var testApplicationBackupURL: URL? = nil
var tempDirectoryURL: URL? = nil
var testApplicationURL: URL?
var testApplicationBackupURL: URL?
var tempDirectoryURL: URL?
func runningTestApplication() -> NSRunningApplication
{
// TODO: don't hardcode bundle ID?
@@ -21,91 +21,91 @@ class SUTestApplicationTest: XCTestCase
XCTAssertEqual(runningApplications.count, 1, "More than one or zero running instances of the Test Application are found")
return runningApplications[0]
}
override func setUp()
{
super.setUp()
let app = XCUIApplication()
app.launch()
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
// We need to grab the app URL so we can back up the app
// When a successful test is over we'll revert the update
let testApplicationURL = self.runningTestApplication().bundleURL!
let tempDirectoryURL = try! FileManager.default.url(for: .itemReplacementDirectory, in: FileManager.SearchPathDomainMask.userDomainMask, appropriateFor: testApplicationURL, create: true)
let testApplicationBackupURL = tempDirectoryURL.appendingPathComponent(testApplicationURL.lastPathComponent)
try! FileManager.default.copyItem(at: testApplicationURL, to: testApplicationBackupURL)
self.testApplicationURL = testApplicationURL
self.testApplicationBackupURL = testApplicationBackupURL
self.tempDirectoryURL = tempDirectoryURL
// when we add more tests we don't want to continue after a failure
// since a test can fail after the new app has been placed in
self.continueAfterFailure = false
}
override func tearDown()
{
// Terminate just in case the app hasn't already quit
XCUIApplication().terminate()
// Revert our update with the original test application
var resultingURL: NSURL? = nil
var resultingURL: NSURL?
try! FileManager.default.replaceItem(at: self.testApplicationURL!, withItemAt: self.testApplicationBackupURL!, backupItemName: nil, options: .usingNewMetadataOnly, resultingItemURL: &resultingURL)
do {
try FileManager.default.removeItem(at: self.tempDirectoryURL!)
} catch let error as NSError {
NSLog("Failed to remove temporary directory \(self.tempDirectoryURL) with error: \(error)")
}
// The URL we get back from NSFileManager should be the same..
XCTAssertEqual(self.testApplicationURL, resultingURL as URL?, "Test application was replaced, but at a different location")
super.tearDown()
}
func testRegularUpdate()
{
let app = XCUIApplication()
let menuBarsQuery = app.menuBars
menuBarsQuery.menuBarItems["Sparkle Test App"].click()
// If the update window already showed up automatically, this option will be disabled.
// Even if it's disabled, attempting to click it will do no harm and continue on
menuBarsQuery.menuItems["Check for Updates…"].click()
// Workaround to make sure we can click the install update button later
// This workaround is needed if the alert prompts up automatically *before* we manually check for updates
// I'm not sure why this workaround works or is necessary
app.dialogs["SUUpdateAlert"].staticTexts["Software Update"].click()
app.dialogs["SUUpdateAlert"].buttons["Install Update"].click()
app.windows["SUStatus"].buttons["Install and Relaunch"].click()
// Wait for the new updated app to finish launching so we can test if it's the frontmost app
sleep(3)
// Our new updated app should be launched now. Test if it's the active app
// We used to run into timing issues where the updated app sometimes may not show up as the frontmost one
XCTAssertTrue(self.runningTestApplication().isActive)
// Grab another XCUIApplication instance rather than using the old one, just in case
let updatedApp = XCUIApplication()
// Check if we can click the "Update succeeded!" label rather than using the exists property
// Checking the exists property doesn't reload the "cache" and as such the UI tests still would think we are
// referring to the older app. Clicking does force the UI tests to find the new app however
updatedApp.dialogs["alert"].staticTexts["Update succeeded!"].click()
updatedApp.dialogs["alert"].buttons["OK"].click()
}
}
+2 -2
View File
@@ -41,7 +41,7 @@ typedef NS_ENUM(uint8_t, SUFileOpError)
int main(int argc, const char *argv[])
{
@autoreleasepool {
@autoreleasepool {
// Before we do anything, we should let the parent know our pid so they can wait() on us
// We do this because AuthorizationExecuteWithPrivileges() has no way of reporting back the child pid,
// but it does give us a communication pipe
@@ -152,5 +152,5 @@ int main(int argc, const char *argv[])
}
return EXIT_SUCCESS;
}
}
}
+55 -55
View File
@@ -6,159 +6,159 @@
import Foundation
// Maximum number of delta updates (per OS).
let maxDeltas = 5;
let maxDeltas = 5
func makeError(code: SUError, _ description: String) -> NSError {
return NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(code.rawValue)), userInfo: [
NSLocalizedDescriptionKey: description,
]);
])
}
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String:[ArchiveItem]] {
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast");
let comparator = SUStandardVersionComparator();
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String: [ArchiveItem]] {
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast")
let comparator = SUStandardVersionComparator()
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose:verbose))
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose: verbose))
.sorted(by: {
.orderedDescending == comparator.compareVersion($0.version, toVersion:$1.version)
.orderedDescending == comparator.compareVersion($0.version, toVersion: $1.version)
})
if allUpdates.count == 0 {
throw makeError(code: .noUpdateError, "No usable archives found in \(archivesSourceDir.path)");
throw makeError(code: .noUpdateError, "No usable archives found in \(archivesSourceDir.path)")
}
var updatesByAppcast:[String:[ArchiveItem]] = [:];
var updatesByAppcast: [String: [ArchiveItem]] = [:]
let group = DispatchGroup();
let group = DispatchGroup()
for update in allUpdates {
group.enter();
group.enter()
DispatchQueue.global().async {
if let privateDSAKey = keys.privateDSAKey {
do {
update.dsaSignature = try dsaSignature(path: update.archivePath, privateDSAKey: privateDSAKey);
update.dsaSignature = try dsaSignature(path: update.archivePath, privateDSAKey: privateDSAKey)
} catch {
print(update, error);
print(update, error)
}
} else if update.supportsDSA {
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified");
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified")
}
if let publicEdKey = update.publicEdKey {
if let privateEdKey = keys.privateEdKey, let expectedPublicKey = keys.publicEdKey {
if publicEdKey == expectedPublicKey {
do {
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey)
} catch {
print(update, error);
print(update, error)
}
} else {
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match");
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match")
}
} else {
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key");
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key")
}
}
group.leave();
group.leave()
}
let appcastFile = update.feedURL?.lastPathComponent ?? "appcast.xml";
let appcastFile = update.feedURL?.lastPathComponent ?? "appcast.xml"
if updatesByAppcast[appcastFile] == nil {
updatesByAppcast[appcastFile] = [];
updatesByAppcast[appcastFile] = []
}
updatesByAppcast[appcastFile]!.append(update);
updatesByAppcast[appcastFile]!.append(update)
}
for (_, updates) in updatesByAppcast {
var latestUpdatePerOS:[String:ArchiveItem] = [:];
var latestUpdatePerOS: [String: ArchiveItem] = [:]
for update in updates {
// items are ordered starting latest first
let os = update.minimumSystemVersion;
let os = update.minimumSystemVersion
if latestUpdatePerOS[os] == nil {
latestUpdatePerOS[os] = update;
latestUpdatePerOS[os] = update
}
}
for (_,latestItem) in latestUpdatePerOS {
var numDeltas = 0;
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent;
for (_, latestItem) in latestUpdatePerOS {
var numDeltas = 0
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent
for item in updates {
if numDeltas > maxDeltas {
break;
break
}
// No downgrades
if .orderedAscending != comparator.compareVersion(item.version, toVersion: latestItem.version) {
continue;
continue
}
// Old version will not be able to verify the new version
if !item.supportsDSA && item.publicEdKey == nil {
continue;
continue
}
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version;
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta");
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta")
var delta:DeltaUpdate;
let ignoreMarkerPath = cacheDir.appendingPathComponent(deltaPath.lastPathComponent).appendingPathExtension(".ignore");
let fm = FileManager.default;
var delta: DeltaUpdate
let ignoreMarkerPath = cacheDir.appendingPathComponent(deltaPath.lastPathComponent).appendingPathExtension(".ignore")
let fm = FileManager.default
if fm.fileExists(atPath: ignoreMarkerPath.path) {
continue;
continue
}
if !fm.fileExists(atPath: deltaPath.path) {
do {
delta = try DeltaUpdate.create(from: item, to: latestItem, archivePath: deltaPath);
delta = try DeltaUpdate.create(from: item, to: latestItem, archivePath: deltaPath)
} catch {
print("Could not create delta update", deltaPath.path, error);
continue;
print("Could not create delta update", deltaPath.path, error)
continue
}
} else {
delta = DeltaUpdate(fromVersion: item.version, archivePath: deltaPath);
delta = DeltaUpdate(fromVersion: item.version, archivePath: deltaPath)
}
numDeltas += 1;
numDeltas += 1
// Require delta to be a bit smaller
if delta.fileSize / 7 > latestItem.fileSize / 8 {
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
continue;
continue
}
group.enter();
group.enter()
DispatchQueue.global().async {
if item.supportsDSA, let privateDSAKey = keys.privateDSAKey {
do {
delta.dsaSignature = try dsaSignature(path: deltaPath, privateDSAKey: privateDSAKey);
delta.dsaSignature = try dsaSignature(path: deltaPath, privateDSAKey: privateDSAKey)
} catch {
print(delta.archivePath.lastPathComponent, error);
print(delta.archivePath.lastPathComponent, error)
}
}
if let publicEdKey = item.publicEdKey, let privateEdKey = keys.privateEdKey {
do {
delta.edSignature = try edSignature(path: deltaPath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
delta.edSignature = try edSignature(path: deltaPath, publicEdKey: publicEdKey, privateEdKey: privateEdKey)
} catch {
print(delta.archivePath.lastPathComponent, error);
print(delta.archivePath.lastPathComponent, error)
}
}
if delta.dsaSignature != nil || delta.edSignature != nil {
latestItem.deltas.append(delta);
latestItem.deltas.append(delta)
} else {
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
print("Delta \(delta.archivePath.path) ignored, because it could not be signed");
print("Delta \(delta.archivePath.path) ignored, because it could not be signed")
}
group.leave();
group.leave()
}
}
}
}
group.wait();
group.wait()
return updatesByAppcast;
return updatesByAppcast
}
func markDeltaAsIgnored(delta: DeltaUpdate, markerPath: URL) {
let _ = try? FileManager.default.removeItem(at: delta.archivePath)
let _ = try? Data.init().write(to: markerPath); // 0-sized file
_ = try? FileManager.default.removeItem(at: delta.archivePath)
_ = try? Data.init().write(to: markerPath); // 0-sized file
}
+88 -77
View File
@@ -6,62 +6,66 @@
import Foundation
class DeltaUpdate {
let fromVersion: String;
let archivePath: URL;
var dsaSignature: String?;
var edSignature: String?;
let fromVersion: String
let archivePath: URL
var dsaSignature: String?
var edSignature: String?
init(fromVersion: String, archivePath: URL) {
self.archivePath = archivePath;
self.fromVersion = fromVersion;
self.archivePath = archivePath
self.fromVersion = fromVersion
}
var fileSize : Int64 {
let archiveFileAttributes = try! FileManager.default.attributesOfItem(atPath: self.archivePath.path);
return (archiveFileAttributes[.size] as! NSNumber).int64Value;
var fileSize: Int64 {
let archiveFileAttributes = try! FileManager.default.attributesOfItem(atPath: self.archivePath.path)
return (archiveFileAttributes[.size] as! NSNumber).int64Value
}
class func create(from: ArchiveItem, to: ArchiveItem, archivePath: URL) throws -> DeltaUpdate {
var applyDiffError: NSError? = nil;
var applyDiffError: NSError?
if (!createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, .beigeMajorVersion, false, &applyDiffError)) {
throw applyDiffError!;
if !createBinaryDelta(from.appPath.path, to.appPath.path, archivePath.path, .beigeMajorVersion, false, &applyDiffError) {
throw applyDiffError!
}
return DeltaUpdate(fromVersion: from.version, archivePath: archivePath);
return DeltaUpdate(fromVersion: from.version, archivePath: archivePath)
}
}
class ArchiveItem: CustomStringConvertible {
let version: String;
let _shortVersion: String?;
let minimumSystemVersion: String;
let archivePath: URL;
let appPath: URL;
let feedURL: URL?;
let publicEdKey: Data?;
let supportsDSA: Bool;
let archiveFileAttributes: [FileAttributeKey:Any];
var deltas: [DeltaUpdate];
let version: String
// swiftlint:disable identifier_name
let _shortVersion: String?
let minimumSystemVersion: String
let archivePath: URL
let appPath: URL
let feedURL: URL?
let publicEdKey: Data?
let supportsDSA: Bool
let archiveFileAttributes: [FileAttributeKey: Any]
var deltas: [DeltaUpdate]
var dsaSignature: String?;
var edSignature: String?;
var dsaSignature: String?
var edSignature: String?
var downloadUrlPrefix: URL?
var releaseNotesURLPrefix: URL?
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
self.version = version;
self._shortVersion = shortVersion;
self.feedURL = feedURL;
self.minimumSystemVersion = minimumSystemVersion ?? "10.7";
self.archivePath = archivePath;
self.appPath = appPath;
self.supportsDSA = supportsDSA;
self.version = version
self._shortVersion = shortVersion
self.feedURL = feedURL
self.minimumSystemVersion = minimumSystemVersion ?? "10.7"
self.archivePath = archivePath
self.appPath = appPath
self.supportsDSA = supportsDSA
if let publicEdKey = publicEdKey {
self.publicEdKey = Data(base64Encoded: publicEdKey);
self.publicEdKey = Data(base64Encoded: publicEdKey)
} else {
self.publicEdKey = nil;
self.publicEdKey = nil
}
self.archiveFileAttributes = try FileManager.default.attributesOfItem(atPath: self.archivePath.path);
self.deltas = [];
let path = (self.archivePath.path as NSString).resolvingSymlinksInPath
self.archiveFileAttributes = try FileManager.default.attributesOfItem(atPath: path)
self.deltas = []
}
convenience init(fromArchive archivePath: URL, unarchivedDir: URL) throws {
@@ -74,24 +78,24 @@ class ArchiveItem: CustomStringConvertible {
} else {
return false
}
});
})
if bundles.count > 0 {
if bundles.count > 1 {
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(bundles)");
throw makeError(code: .unarchivingError, "Too many bundles in \(unarchivedDir.path) \(bundles)")
}
let appPath = bundles[0];
let appPath = bundles[0]
guard let infoPlist = NSDictionary(contentsOf: appPath.appendingPathComponent("Contents/Info.plist")) else {
throw makeError(code: .unarchivingError, "No plist \(appPath.path)");
throw makeError(code: .unarchivingError, "No plist \(appPath.path)")
}
guard let version = infoPlist[kCFBundleVersionKey] as? String else {
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)");
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)")
}
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String;
let publicEdKey = infoPlist[SUPublicEDKeyKey] as? String;
let supportsDSA = infoPlist[SUPublicDSAKeyKey] != nil || infoPlist[SUPublicDSAKeyFileKey] != nil;
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String
let publicEdKey = infoPlist[SUPublicEDKeyKey] as? String
let supportsDSA = infoPlist[SUPublicDSAKeyKey] != nil || infoPlist[SUPublicDSAKeyFileKey] != nil
var feedURL:URL? = nil;
var feedURL: URL?
if let feedURLStr = infoPlist["SUFeedURL"] as? String {
feedURL = URL(string: feedURLStr)
if feedURL?.pathExtension == "php" {
@@ -107,51 +111,54 @@ class ArchiveItem: CustomStringConvertible {
publicEdKey: publicEdKey,
supportsDSA: supportsDSA,
appPath: appPath,
archivePath: archivePath);
archivePath: archivePath)
} else {
throw makeError(code: .missingUpdateError, "No supported items in \(unarchivedDir) \(items) [note: only .app bundles are supported]");
throw makeError(code: .missingUpdateError, "No supported items in \(unarchivedDir) \(items) [note: only .app bundles are supported]")
}
}
var shortVersion: String {
return self._shortVersion ?? self.version;
return self._shortVersion ?? self.version
}
var description : String {
var description: String {
return "\(self.archivePath) \(self.version)"
}
var archiveURL: URL? {
guard let escapedFilename = self.archivePath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
return nil;
return nil
}
if let relative = self.feedURL {
return URL(string: escapedFilename, relativeTo: relative)
if let downloadUrlPrefix = self.downloadUrlPrefix {
// if a download url prefix was given use this one
return URL(string: escapedFilename, relativeTo: downloadUrlPrefix)
} else if let relativeFeedUrl = self.feedURL {
return URL(string: escapedFilename, relativeTo: relativeFeedUrl)
}
return URL(string: escapedFilename)
}
var pubDate : String {
let date = self.archiveFileAttributes[.creationDate] as! Date;
let formatter = DateFormatter();
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZ";
return formatter.string(from: date);
var pubDate: String {
let date = self.archiveFileAttributes[.creationDate] as! Date
let formatter = DateFormatter()
formatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss ZZ"
return formatter.string(from: date)
}
var fileSize : Int64 {
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value;
var fileSize: Int64 {
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value
}
private var releaseNotesPath : URL? {
var basename = self.archivePath.deletingPathExtension();
private var releaseNotesPath: URL? {
var basename = self.archivePath.deletingPathExtension()
if basename.pathExtension == "tar" { // tar.gz
basename = basename.deletingPathExtension();
basename = basename.deletingPathExtension()
}
let releaseNotes = basename.appendingPathExtension("html");
let releaseNotes = basename.appendingPathExtension("html")
if !FileManager.default.fileExists(atPath: releaseNotes.path) {
return nil;
return nil
}
return releaseNotes;
return releaseNotes
}
private func getReleaseNotesAsHTMLFragment(_ path: URL) -> String? {
@@ -159,31 +166,35 @@ class ArchiveItem: CustomStringConvertible {
if html.utf8.count < 1000 &&
!html.localizedCaseInsensitiveContains("<!DOCTYPE") &&
!html.localizedCaseInsensitiveContains("<body") {
return html;
return html
}
}
return nil;
return nil
}
var releaseNotesHTML : String? {
var releaseNotesHTML: String? {
if let path = self.releaseNotesPath {
return self.getReleaseNotesAsHTMLFragment(path);
return self.getReleaseNotesAsHTMLFragment(path)
}
return nil;
return nil
}
var releaseNotesURL : URL? {
var releaseNotesURL: URL? {
guard let path = self.releaseNotesPath else {
return nil;
return nil
}
// The file is already used as inline description
if self.getReleaseNotesAsHTMLFragment(path) != nil {
return nil;
return nil
}
guard let escapedFilename = path.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
return nil;
return nil
}
if let relative = self.feedURL {
if let releaseNotesURLPrefix = self.releaseNotesURLPrefix {
// If a URL prefix for release notes was passed on the command-line, use it
return URL(string: escapedFilename, relativeTo: releaseNotesURLPrefix)
} else if let relative = self.feedURL {
return URL(string: escapedFilename, relativeTo: relative)
}
return URL(string: escapedFilename)
@@ -207,5 +218,5 @@ class ArchiveItem: CustomStringConvertible {
return localizedReleaseNotes
}
let mimeType = "application/octet-stream";
let mimeType = "application/octet-stream"
}
+77 -70
View File
@@ -5,121 +5,128 @@
import Foundation
let maxVersionsInFeed = 5;
let maxVersionsInFeed = 5
func findElement(name: String, parent: XMLElement) -> XMLElement? {
if let found = try? parent.nodes(forXPath: name) {
if found.count > 0 {
if let element = found[0] as? XMLElement {
return element;
return element
}
}
}
return nil;
return nil
}
func findOrCreateElement(name: String, parent: XMLElement) -> XMLElement {
if let element = findElement(name: name, parent: parent) {
return element;
return element
}
let element = XMLElement(name: name);
parent.addChild(element);
return element;
let element = XMLElement(name: name)
parent.addChild(element)
return element
}
func text(_ text: String) -> XMLNode {
return XMLNode.text(withStringValue: text) as! XMLNode
}
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent;
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle";
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
var doc: XMLDocument;
var doc: XMLDocument
do {
let options: XMLNode.Options = [
XMLNode.Options.nodeLoadExternalEntitiesNever,
XMLNode.Options.nodePreserveCDATA,
XMLNode.Options.nodePreserveWhitespace,
];
doc = try XMLDocument(contentsOf: appcastDestPath, options: options);
]
doc = try XMLDocument(contentsOf: appcastDestPath, options: options)
} catch {
let root = XMLElement(name: "rss");
root.addAttribute(XMLNode.attribute(withName: "xmlns:sparkle", stringValue: sparkleNS) as! XMLNode);
root.addAttribute(XMLNode.attribute(withName: "version", stringValue: "2.0") as! XMLNode);
doc = XMLDocument(rootElement: root);
doc.isStandalone = true;
let root = XMLElement(name: "rss")
root.addAttribute(XMLNode.attribute(withName: "xmlns:sparkle", stringValue: sparkleNS) as! XMLNode)
root.addAttribute(XMLNode.attribute(withName: "version", stringValue: "2.0") as! XMLNode)
doc = XMLDocument(rootElement: root)
doc.isStandalone = true
}
var channel: XMLElement;
var channel: XMLElement
let rootNodes = try doc.nodes(forXPath: "/rss");
let rootNodes = try doc.nodes(forXPath: "/rss")
if rootNodes.count != 1 {
throw makeError(code: .appcastError, "Weird XML? \(appcastDestPath.path)");
throw makeError(code: .appcastError, "Weird XML? \(appcastDestPath.path)")
}
let root = rootNodes[0] as! XMLElement
let channelNodes = try root.nodes(forXPath: "channel");
let channelNodes = try root.nodes(forXPath: "channel")
if channelNodes.count > 0 {
channel = channelNodes[0] as! XMLElement;
channel = channelNodes[0] as! XMLElement
} else {
channel = XMLElement(name: "channel");
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement);
root.addChild(channel);
channel = XMLElement(name: "channel")
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement)
root.addChild(channel)
}
var numItems = 0;
var numItems = 0
for update in updates {
var item: XMLElement;
let existingItems = try channel.nodes(forXPath: "item[enclosure[@sparkle:version=\"\(update.version)\"]]");
let createNewItem = existingItems.count == 0;
var item: XMLElement
let existingItems = try channel.nodes(forXPath: "item[enclosure[@sparkle:version=\"\(update.version)\"]]")
let createNewItem = existingItems.count == 0
// Update all old items, but aim for less than 5 in new feeds
if createNewItem && numItems >= maxVersionsInFeed {
continue;
continue
}
numItems += 1;
numItems += 1
if createNewItem {
item = XMLElement.element(withName: "item") as! XMLElement;
channel.addChild(item);
item = XMLElement.element(withName: "item") as! XMLElement
channel.addChild(item)
} else {
item = existingItems[0] as! XMLElement;
item = existingItems[0] as! XMLElement
}
if nil == findElement(name: "title", parent: item) {
item.addChild(XMLElement.element(withName: "title", stringValue: update.shortVersion) as! XMLElement);
item.addChild(XMLElement.element(withName: "title", stringValue: update.shortVersion) as! XMLElement)
}
if nil == findElement(name: "pubDate", parent: item) {
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement);
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement)
}
if let html = update.releaseNotesHTML {
let descElement = findOrCreateElement(name: "description", parent: item);
let cdata = XMLNode(kind:.text, options:.nodeIsCDATA);
cdata.stringValue = html;
descElement.setChildren([cdata]);
let descElement = findOrCreateElement(name: "description", parent: item)
let cdata = XMLNode(kind: .text, options: .nodeIsCDATA)
cdata.stringValue = html
descElement.setChildren([cdata])
}
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item);
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item)
if nil == minVer {
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement;
item.addChild(minVer!);
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement
item.addChild(minVer!)
}
minVer?.setChildren([text(update.minimumSystemVersion)]);
minVer?.setChildren([text(update.minimumSystemVersion)])
// Look for an existing release notes element
let releaseNotesXpath = "\(SUAppcastElementReleaseNotesLink)"
let results = ((try? item.nodes(forXPath: releaseNotesXpath)) as? [XMLElement])?
.filter { !($0.attributes ?? [])
.contains(where: { $0.name == SUXMLLanguage }) }
let relElement = results?.first
if let url = update.releaseNotesURL {
if nil == relElement {
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement);
// The update includes a valid release notes URL
if let existingReleaseNotesElement = relElement {
// The existing item includes a release notes element. Update it.
existingReleaseNotesElement.stringValue = url.absoluteString
} else {
// The existing item doesn't have a release notes element. Add one.
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement)
}
} else if let childIndex = relElement?.index {
item.removeChild(at: childIndex);
// The update doesn't include a release notes URL. Remove it.
item.removeChild(at: childIndex)
}
let languageNotesNodes = ((try? item.nodes(forXPath: releaseNotesXpath)) as? [XMLElement])?
@@ -134,42 +141,42 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
let localizedNode = XMLNode.element(withName: SUAppcastElementReleaseNotesLink,
children: [XMLNode.text(withStringValue: url.lastPathComponent) as! XMLNode],
attributes: [XMLNode.attribute(withName: SUXMLLanguage,
stringValue: language) as! XMLNode])
stringValue: language) as! XMLNode, ])
item.addChild(localizedNode as! XMLNode)
}
}
var enclosure = findElement(name: "enclosure", parent: item);
var enclosure = findElement(name: "enclosure", parent: item)
if nil == enclosure {
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement;
item.addChild(enclosure!);
enclosure = XMLElement.element(withName: "enclosure") as? XMLElement
item.addChild(enclosure!)
}
guard let archiveURL = update.archiveURL?.absoluteString else {
throw makeError(code: .appcastError, "Bad archive name or feed URL");
};
throw makeError(code: .appcastError, "Bad archive name or feed URL")
}
var attributes = [
XMLNode.attribute(withName: "url", stringValue: archiveURL) as! XMLNode,
XMLNode.attribute(withName: SUAppcastAttributeVersion, uri: sparkleNS, stringValue: update.version) as! XMLNode,
XMLNode.attribute(withName: SUAppcastAttributeShortVersionString, uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
XMLNode.attribute(withName: "length", stringValue: String(update.fileSize)) as! XMLNode,
XMLNode.attribute(withName: "type", stringValue: update.mimeType) as! XMLNode,
];
]
if let sig = update.edSignature {
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
}
if let sig = update.dsaSignature {
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
}
enclosure!.attributes = attributes;
enclosure!.attributes = attributes
if update.deltas.count > 0 {
var deltas = findElement(name: SUAppcastElementDeltas, parent: item);
var deltas = findElement(name: SUAppcastElementDeltas, parent: item)
if nil == deltas {
deltas = XMLElement.element(withName: SUAppcastElementDeltas, uri: sparkleNS) as? XMLElement;
item.addChild(deltas!);
deltas = XMLElement.element(withName: SUAppcastElementDeltas, uri: sparkleNS) as? XMLElement
item.addChild(deltas!)
} else {
deltas!.setChildren([]);
deltas!.setChildren([])
}
for delta in update.deltas {
var attributes = [
@@ -179,20 +186,20 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
XMLNode.attribute(withName: SUAppcastAttributeDeltaFrom, uri: sparkleNS, stringValue: delta.fromVersion) as! XMLNode,
XMLNode.attribute(withName: "length", stringValue: String(delta.fileSize)) as! XMLNode,
XMLNode.attribute(withName: "type", stringValue: "application/octet-stream") as! XMLNode,
];
]
if let sig = delta.edSignature {
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
}
if let sig = delta.dsaSignature {
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode)
}
deltas!.addChild(XMLNode.element(withName: "enclosure", children: nil, attributes: attributes) as! XMLElement);
deltas!.addChild(XMLNode.element(withName: "enclosure", children: nil, attributes: attributes) as! XMLElement)
}
}
}
let options: XMLNode.Options = [.nodeCompactEmptyElement, .nodePrettyPrint];
let docData = doc.xmlData(options:options);
let _ = try XMLDocument(data: docData, options:XMLNode.Options()); // Verify that it was generated correctly, which does not always happen!
try docData.write(to: appcastDestPath);
let options: XMLNode.Options = [.nodeCompactEmptyElement, .nodePrettyPrint]
let docData = doc.xmlData(options: options)
_ = try XMLDocument(data: docData, options: XMLNode.Options()); // Verify that it was generated correctly, which does not always happen!
try docData.write(to: appcastDestPath)
}
+49 -49
View File
@@ -6,109 +6,109 @@
import Foundation
struct PrivateKeys {
var privateDSAKey: SecKey?;
var privateEdKey: Data?;
var publicEdKey: Data?;
var privateDSAKey: SecKey?
var privateEdKey: Data?
var publicEdKey: Data?
init(privateDSAKey: SecKey?, privateEdKey: Data?, publicEdKey: Data?) {
self.privateDSAKey = privateDSAKey;
self.privateEdKey = privateEdKey;
self.publicEdKey = publicEdKey;
self.privateDSAKey = privateDSAKey
self.privateEdKey = privateEdKey
self.publicEdKey = publicEdKey
}
}
func loadPrivateDSAKey(at privateKeyURL: URL) throws -> SecKey {
let data = try Data(contentsOf: privateKeyURL);
let data = try Data(contentsOf: privateKeyURL)
var cfitems: CFArray? = nil;
var format = SecExternalFormat.formatOpenSSL;
var type = SecExternalItemType.itemTypePrivateKey;
var cfitems: CFArray?
var format = SecExternalFormat.formatOpenSSL
var type = SecExternalItemType.itemTypePrivateKey
let status = SecItemImport(data as CFData, nil, &format, &type, SecItemImportExportFlags(rawValue: UInt32(0)), nil, nil, &cfitems);
if (status != errSecSuccess || cfitems == nil) {
print("Private DSA key file", privateKeyURL.path, "exists, but it could not be read. SecItemImport error", status);
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil);
let status = SecItemImport(data as CFData, nil, &format, &type, SecItemImportExportFlags(rawValue: UInt32(0)), nil, nil, &cfitems)
if status != errSecSuccess || cfitems == nil {
print("Private DSA key file", privateKeyURL.path, "exists, but it could not be read. SecItemImport error", status)
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
}
if (format != SecExternalFormat.formatOpenSSL || type != SecExternalItemType.itemTypePrivateKey) {
throw makeError(code: .signatureError, "Not an OpensSSL private key \(format) \(type)");
if format != SecExternalFormat.formatOpenSSL || type != SecExternalItemType.itemTypePrivateKey {
throw makeError(code: .signatureError, "Not an OpensSSL private key \(format) \(type)")
}
return (cfitems! as NSArray)[0] as! SecKey;
return (cfitems! as NSArray)[0] as! SecKey
}
func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) throws -> SecKey {
var keychain: SecKeychain? = nil
var keychain: SecKeychain?
guard SecKeychainOpen(keychainURL.path, &keychain) == errSecSuccess, keychain != nil else {
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
}
let query: [CFString: CFTypeRef] = [
kSecClass: kSecClassKey,
kSecAttrKeyClass: kSecAttrKeyClassPrivate,
kSecAttrLabel: keyName as CFString,
kSecMatchLimit: kSecMatchLimitOne,
kSecUseKeychain: keychain!,
kSecReturnRef: kCFBooleanTrue
kSecReturnRef: kCFBooleanTrue,
]
var item: CFTypeRef? = nil
var item: CFTypeRef?
guard SecItemCopyMatching(query as CFDictionary, &item) == errSecSuccess, item != nil else {
throw NSError(domain: SUSparkleErrorDomain, code: Int(OSStatus(SUError.signatureError.rawValue)), userInfo: nil)
}
return item! as! SecKey
}
func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
var error: Unmanaged<CFError>?;
var error: Unmanaged<CFError>?
let stream = InputStream(fileAtPath:path.path)!;
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream);
let stream = InputStream(fileAtPath: path.path)!
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream)
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil);
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil)
guard let dataSignTransform = SecSignTransformCreate(privateDSAKey, &error) else {
print("can't use the key");
throw error!.takeRetainedValue();
print("can't use the key")
throw error!.takeRetainedValue()
}
let group = SecTransformCreateGroupTransform();
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error);
if (error != nil) {
throw error!.takeRetainedValue();
let group = SecTransformCreateGroupTransform()
SecTransformConnectTransforms(dataReadTransform, kSecTransformOutputAttributeName, dataDigestTransform, kSecTransformInputAttributeName, group, &error)
if error != nil {
throw error!.takeRetainedValue()
}
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataSignTransform, kSecTransformInputAttributeName, group, &error);
if (error != nil) {
throw error!.takeRetainedValue();
SecTransformConnectTransforms(dataDigestTransform, kSecTransformOutputAttributeName, dataSignTransform, kSecTransformInputAttributeName, group, &error)
if error != nil {
throw error!.takeRetainedValue()
}
let result = SecTransformExecute(group, &error);
if (error != nil) {
throw error!.takeRetainedValue();
let result = SecTransformExecute(group, &error)
if error != nil {
throw error!.takeRetainedValue()
}
guard let resultData = result as? Data else {
throw makeError(code: .signatureError, "SecTransformExecute returned non-data");
throw makeError(code: .signatureError, "SecTransformExecute returned non-data")
}
return resultData.base64EncodedString();
return resultData.base64EncodedString()
}
func edSignature(path: URL, publicEdKey: Data, privateEdKey: Data) throws -> String {
assert(publicEdKey.count == 32)
assert(privateEdKey.count == 64)
let data = try Data.init(contentsOf: path, options: .mappedIfSafe);
let len = data.count;
var output = Data(count: 64);
let data = try Data.init(contentsOf: path, options: .mappedIfSafe)
let len = data.count
var output = Data(count: 64)
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
});
});
})
})
})
});
return output.base64EncodedString();
})
return output.base64EncodedString()
}
+54
View File
@@ -0,0 +1,54 @@
//
// URL+Hashing.swift
// generate_appcast
//
// Created by Nate Weaver on 2020-05-01.
// Copyright © 2020 Sparkle Project. All rights reserved.
//
import Foundation
import CommonCrypto
extension FileHandle {
/// Calculate the SHA-256 hash of the file referenced by the file handle.
///
/// - Returns: The SHA-256 hash of the file (as a hexadecimal string).
func sha256String() -> String {
// This uses CommonCrypto instead of CryptoKit so it can work on macOS < 10.15
var context = CC_SHA256_CTX()
CC_SHA256_Init(&context)
while true {
let data = self.readData(ofLength: 65_536)
guard data.count > 0 else { break }
_ = data.withUnsafeBytes {
CC_SHA256_Update(&context, $0.baseAddress, numericCast($0.count))
}
}
let hash = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: Int(CC_SHA256_DIGEST_LENGTH))
CC_SHA256_Final(hash.baseAddress, &context)
return hash.reduce("") { $0 + String(format: "%02x", $1) }
}
}
extension URL {
/// Calculates the SHA-256 hash of the file referened by the URL.
///
/// - Returns: The SHA-256 hash of the file (as a hexadecimal string), or `nil` if
/// the URL doesn't point to a file.
func sha256String() -> String? {
guard self.isFileURL else { return nil }
guard let filehandle = try? FileHandle(forReadingFrom: self) else { return nil }
return filehandle.sha256String()
}
}
+51 -45
View File
@@ -5,105 +5,111 @@
import Foundation
func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
let fileManager = FileManager.default;
let tempDir = archiveDestDir.appendingPathExtension("tmp");
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent);
func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
let fileManager = FileManager.default
let tempDir = archiveDestDir.appendingPathExtension("tmp")
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent)
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:]);
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:])
do {
do {
try fileManager.linkItem(at: itemPath, to: itemCopy);
try fileManager.linkItem(at: itemPath, to: itemCopy)
} catch {
try fileManager.copyItem(at: itemPath, to: itemCopy);
try fileManager.copyItem(at: itemPath, to: itemCopy)
}
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath:nil, decryptionPassword:nil) {
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath: nil, decryptionPassword: nil) {
unarchiver.unarchive(completionBlock: { (error: Error?) in
if error != nil {
callback(error);
return;
callback(error)
return
}
_ = try? fileManager.removeItem(at: itemCopy);
_ = try? fileManager.removeItem(at: itemCopy)
do {
try fileManager.moveItem(at: tempDir, to: archiveDestDir);
callback(nil);
try fileManager.moveItem(at: tempDir, to: archiveDestDir)
callback(nil)
} catch {
callback(error);
callback(error)
}
}, progressBlock: nil)
} else {
_ = try? fileManager.removeItem(at: itemCopy);
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"));
_ = try? fileManager.removeItem(at: itemCopy)
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"))
}
} catch {
_ = try? fileManager.removeItem(at: tempDir);
callback(error);
_ = try? fileManager.removeItem(at: tempDir)
callback(error)
}
}
func unarchiveUpdates(archivesSourceDir: URL, archivesDestDir: URL, verbose: Bool) throws -> [ArchiveItem] {
if verbose {
print("Unarchiving to temp directory", archivesDestDir.path);
print("Unarchiving to temp directory", archivesDestDir.path)
}
let group = DispatchGroup();
let group = DispatchGroup()
let fileManager = FileManager.default;
let fileManager = FileManager.default
var unarchived:[ArchiveItem] = [];
var unarchived: [ArchiveItem] = []
let dir = try fileManager.contentsOfDirectory(atPath: archivesSourceDir.path);
var running = 0;
let dir = try fileManager.contentsOfDirectory(atPath: archivesSourceDir.path)
var running = 0
for item in dir.filter({ !$0.hasPrefix(".") && !$0.hasSuffix(".delta") && !$0.hasSuffix(".xml") && !$0.hasSuffix(".html") }) {
let itemPath = archivesSourceDir.appendingPathComponent(item);
let archiveDestDir = archivesDestDir.appendingPathComponent(itemPath.lastPathComponent);
let itemPath = archivesSourceDir.appendingPathComponent(item)
let archiveDestDir: URL
var isDir:ObjCBool = false;
if (fileManager.fileExists(atPath: itemPath.path, isDirectory: &isDir) && isDir.boolValue) {
continue;
if let hash = itemPath.sha256String() {
archiveDestDir = archivesDestDir.appendingPathComponent(hash)
} else {
archiveDestDir = archivesDestDir.appendingPathComponent(itemPath.lastPathComponent)
}
var isDir: ObjCBool = false
if fileManager.fileExists(atPath: itemPath.path, isDirectory: &isDir) && isDir.boolValue {
continue
}
let addItem = {
do {
let item = try ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir);
let item = try ArchiveItem(fromArchive: itemPath, unarchivedDir: archiveDestDir)
if verbose {
print("Found archive", item);
print("Found archive", item)
}
objc_sync_enter(unarchived);
unarchived.append(item);
objc_sync_exit(unarchived);
objc_sync_enter(unarchived)
unarchived.append(item)
objc_sync_exit(unarchived)
} catch {
if verbose {
print("Skipped", item, error);
print("Skipped", item, error)
}
}
}
if fileManager.fileExists(atPath: archiveDestDir.path) {
addItem();
addItem()
} else {
group.enter();
group.enter()
unarchive(itemPath: itemPath, archiveDestDir: archiveDestDir) { (error: Error?) in
if let error = error {
print("Could not unarchive", itemPath.path, error);
print("Could not unarchive", itemPath.path, error)
} else {
addItem();
addItem()
}
group.leave();
group.leave()
}
}
// Crude limit of concurrency
running += 1;
running += 1
if running >= 8 {
running = 0;
group.wait();
running = 0
group.wait()
}
}
group.wait();
group.wait()
return unarchived;
return unarchived
}
+243 -84
View File
@@ -8,27 +8,53 @@
import Foundation
var verbose = false;
var verbose = false
// Enum that contains keys for command-line arguments
struct CommandLineArguments {
var privateDSAKey : SecKey?
var privateEdString : String?
var downloadURLPrefix : URL?
var releaseNotesURLPrefix: URL?
var outputPathURL: URL?
var archivesSourceDir: URL?
}
func printUsage() {
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent;
print("Generate appcast from a directory of Sparkle update archives\n",
"Usage:\n",
" \(command) <directory with update files>\n",
" e.g. \(command) ./my-app-release-zipfiles/\n",
"\nOR for old apps that have a DSA keys (deprecated):\n",
" \(command) <private DSA key path> <directory with update files>\n",
" e.g. \(command) dsa_priv.pem archives/\n",
"\n",
"Appcast files and deltas will be written to the archives directory.\n",
"Note that pkg-based updates are not supported.\n"
)
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent
let usage = """
Generate appcast from a directory of Sparkle update archives
Usage: \(command) [OPTIONS] [ARCHIVES_FOLDER]
-h: prints this message
-f: provide the path to the private DSA key
-n: provide the name of the private DSA key. This option must be used with `-k`
-k: provide the name of the keychain. This option must be used with `-n`
-s: provide the path to the private EdDSA key
-o: provide a filename for the generated appcast (allowed when only one will be created)
--download-url-prefix: provide a prefix used to construct URLs for update downloads
--release-notes-url-prefix: provide a prefix used to construct URLs for release notes
Examples:
\(command) ./my-app-release-zipfiles/
\(command) -o appcast-name.xml ./my-app-release-zipfiles/
\(command) dsa_priv.pem ./my-app-release-zipfiles/ [DEPRECATED]
Appcast files and deltas will be written to the archives directory.
Note that pkg-based updates are not supported.
"""
print(usage)
}
func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> PrivateKeys {
var privateEdKey: Data?;
var publicEdKey: Data?;
var item: CFTypeRef?;
var privateEdKey: Data?
var publicEdKey: Data?
var item: CFTypeRef?
var keys: Data?
// private + public key is provided as argument
@@ -36,7 +62,7 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr
if privateEdString.count == 128, let data = Data(base64Encoded: privateEdString) {
keys = data
} else {
print("Warning: Private key not found in the argument. Please provide a valid key.");
print("Warning: Private key not found in the argument. Please provide a valid key.")
}
}
// get keys from kechain instead
@@ -47,104 +73,237 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
kSecReturnData as String: kCFBooleanTrue,
] as CFDictionary, &item);
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let data = Data(base64Encoded: encoded) {
keys = data
} else {
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool");
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool")
}
}
if let keys = keys {
privateEdKey = keys[0..<64];
publicEdKey = keys[64...];
privateEdKey = keys[0..<64]
publicEdKey = keys[64...]
}
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey);
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey)
}
func main() {
let args = CommandLine.arguments;
if args.count < 2 {
/**
* Parses all possible command line options and returns a struct that contains them
*/
func parseCommandLineOptions() -> CommandLineArguments {
var arguments = CommandLine.arguments
// If there are fewer than two arguments (the name of the application +
// the required archive directory), or if `-h` is in the argument list,
// then show the usage message
if arguments.count < 2 || arguments.contains("-h") {
printUsage()
exit(1)
}
var privateDSAKey: SecKey? = nil;
var privateEdString: String? = nil;
// Remove the first element since this is the path to executable which we don't need
arguments.removeFirst()
// this was typical usage for DSA keys
if args.count == 3 || (args.count == 4 && args[1] == "-f") {
// private key specified by filename
let privateKeyURL = URL(fileURLWithPath: args.count == 3 ? args[1] : args[2])
// Create the struct that will hold the parsed args
var commandLineArguments = CommandLineArguments()
// check if the private dsa key option is present
if let privateDSAKeyOptionIndex = arguments.firstIndex(of: "-f") {
// check that when accessing the value of the option we don't get out of bounds
if privateDSAKeyOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// get the private DSA key
let privateKeyUrl = URL(fileURLWithPath: arguments[privateDSAKeyOptionIndex + 1])
do {
privateDSAKey = try loadPrivateDSAKey(at: privateKeyURL)
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(at: privateKeyUrl)
} catch {
print("Unable to load DSA private key from", privateKeyUrl.path, "\n", error)
exit(1)
}
// remove the already parsed arguments
arguments.remove(at: privateDSAKeyOptionIndex)
arguments.remove(at: privateDSAKeyOptionIndex + 1)
}
// check if the private dsa sould be loaded using the keyname and the name of the keychain
if let keyNameOptionIndex = arguments.firstIndex(of: "-n"), let keychainNameOptionIndex = arguments.firstIndex(of: "-k") {
// check that when accessing one of the values of the options we don't get out of bounds
if keyNameOptionIndex + 1 >= arguments.count || keychainNameOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// get the keyname and the keychain url to load the private DSA key
let keyName: String = arguments[keyNameOptionIndex + 1]
let keychainUrl: URL = URL(fileURLWithPath: arguments[keychainNameOptionIndex + 1])
do {
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(named: keyName, fromKeychainAt: keychainUrl)
} catch {
print("Unable to load DSA private key '\(keyName)' from keychain at", keychainUrl.path, "\n", error)
exit(1)
}
// remove the already parsed arguments
arguments.remove(at: keyNameOptionIndex + 1)
arguments.remove(at: keyNameOptionIndex)
arguments.remove(at: arguments.firstIndex(of: "-k")! + 1)
arguments.remove(at: keychainNameOptionIndex)
}
// check if the private EdDSA key string was given as an argument
if let privateEdDSAKeyOptionIndex = arguments.firstIndex(of: "-s") {
// check that when accessing the value of the option we don't get out of bounds
if privateEdDSAKeyOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// get the private EdDSA key string
commandLineArguments.privateEdString = arguments[privateEdDSAKeyOptionIndex + 1]
// remove the already parsed argument
arguments.remove(at: privateEdDSAKeyOptionIndex + 1)
arguments.remove(at: privateEdDSAKeyOptionIndex)
}
// check if a prefix for the download url of the archives was given
if let downloadUrlPrefixOptionIndex = arguments.firstIndex(of: "--download-url-prefix") {
// check that when accessing the value of the option we don't get out of bounds
if downloadUrlPrefixOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// get the download url prefix
commandLineArguments.downloadURLPrefix = URL(string: arguments[downloadUrlPrefixOptionIndex + 1])
// remove the parsed argument
arguments.remove(at: downloadUrlPrefixOptionIndex + 1)
arguments.remove(at: downloadUrlPrefixOptionIndex)
}
// Check if a URL prefix was specified for the release notes
if let releaseNotesURLPrefixOptionIndex = arguments.firstIndex(of: "--release-notes-url-prefix") {
if releaseNotesURLPrefixOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// Get the URL prefix for the release notes
commandLineArguments.releaseNotesURLPrefix = URL(string: arguments[releaseNotesURLPrefixOptionIndex + 1])
// Remove the parsed argument
arguments.remove(at: releaseNotesURLPrefixOptionIndex + 1)
arguments.remove(at: releaseNotesURLPrefixOptionIndex)
}
// Check if an output filename was specified
if let outputFilenameOptionIndex = arguments.firstIndex(of: "-o") {
// check that when accessing the value of the option we don't get out of bounds
if outputFilenameOptionIndex + 1 >= arguments.count {
print("Too few arguments were given")
exit(1)
}
// Get the URL prefix for the release notes
commandLineArguments.outputPathURL = URL(fileURLWithPath: arguments[outputFilenameOptionIndex + 1])
// Remove the parsed argument
arguments.remove(at: outputFilenameOptionIndex + 1)
arguments.remove(at: outputFilenameOptionIndex)
}
// now that all command line options have been removed from the arguments array
// there should only be the path to the private DSA key (if provided) path to the archives dir left
if arguments.count == 2 {
// if there are two arguments left they are the private DSA key and the path to the archives directory (in this order)
// first get the private DSA key
let privateKeyURL = URL(fileURLWithPath: arguments[0])
do {
commandLineArguments.privateDSAKey = try loadPrivateDSAKey(at: privateKeyURL)
} catch {
print("Unable to load DSA private key from", privateKeyURL.path, "\n", error)
exit(1)
}
}
// this is legacy for DSA keychain; probably very rarely used
else if args.count == 6 && (args[1] == "-n" || args[1] == "-k") {
// private key specified by keychain + key name
let keyName: String
let keychainURL: URL
if args[1] == "-n" {
if args[3] != "-k" {
printUsage()
exit(1)
}
keyName = args[2]
keychainURL = URL(fileURLWithPath: args[4])
}
else {
if args[3] != "-n" {
printUsage()
exit(1)
}
keyName = args[4]
keychainURL = URL(fileURLWithPath: args[2])
}
do {
privateDSAKey = try loadPrivateDSAKey(named: keyName, fromKeychainAt: keychainURL)
} catch {
print("Unable to load DSA private key '\(keyName)' from keychain at", keychainURL.path, "\n", error)
exit(1)
}
// remove the parsed path to the DSA key
arguments.removeFirst()
}
// private + public EdDSA keys are provided via command line argument
else if args.count == 4 && args[1] == "-s" {
privateEdString = args[2]
}
else if args.count != 2 {
printUsage()
exit(1)
// now only the archives source dir is left
if let archivesSourceDir = arguments.first {
commandLineArguments.archivesSourceDir = URL(fileURLWithPath: archivesSourceDir, isDirectory: true)
} else {
print("Archive folder must be specified")
exit(1);
}
return commandLineArguments
}
func main() {
// Parse the command line arguments
let args = parseCommandLineOptions()
// If parsing the command line options was successful, then
// the archivesSourceDir must exist
let archivesSourceDir = args.archivesSourceDir!
// Extract the keys
let keys = loadPrivateKeys(args.privateDSAKey, args.privateEdString)
let archivesSourceDir = URL(fileURLWithPath: args.last!, isDirectory: true)
let keys = loadPrivateKeys(privateDSAKey, privateEdString)
do {
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose:verbose);
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose: verbose)
// If a URL prefix was provided, set on the archive items
if args.downloadURLPrefix != nil || args.releaseNotesURLPrefix != nil {
for (_, archiveItems) in allUpdates {
for archiveItem in archiveItems {
if let downloadURLPrefix = args.downloadURLPrefix {
archiveItem.downloadUrlPrefix = downloadURLPrefix
}
if let releaseNotesURLPrefix = args.releaseNotesURLPrefix {
archiveItem.releaseNotesURLPrefix = releaseNotesURLPrefix
}
}
}
}
// If a (single) output filename was specified on the command-line, but more than one
// appcast file was found in the archives, then it's an error.
if let outputPathURL = args.outputPathURL,
allUpdates.count > 1 {
print("Cannot write to \(outputPathURL.path): multiple appcasts found")
exit(1);
}
for (appcastFile, updates) in allUpdates {
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
try writeAppcast(appcastDestPath:appcastDestPath, updates:updates);
print("Written", appcastDestPath.path, "based on", updates.count, "updates");
// If an output filename was specified, use it.
// Otherwise, use the name of the appcast file found in the archive.
let appcastDestPath = args.outputPathURL ?? URL(fileURLWithPath: appcastFile,
relativeTo: archivesSourceDir)
// Write the appcast
try writeAppcast(appcastDestPath: appcastDestPath, updates: updates)
// Inform the user, pluralizing "update" if necessary
let updateString = (updates.count == 1) ? "update" : "updates"
print("Wrote \(updates.count) \(updateString) to: \(appcastDestPath.path)")
}
} catch {
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error);
exit(1);
print("Error generating appcast from directory", archivesSourceDir.path, "\n", error)
exit(1)
}
}
DispatchQueue.global().async(execute: {
main();
CFRunLoopStop(CFRunLoopGetMain());
});
main()
CFRunLoopStop(CFRunLoopGetMain())
})
CFRunLoopRun();
CFRunLoopRun()
+30 -34
View File
@@ -10,52 +10,49 @@ import Foundation
import Security
func findPublicKey() -> Data? {
var item: CFTypeRef?;
var item: CFTypeRef?
let res = SecItemCopyMatching([
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: "https://sparkle-project.org",
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
kSecReturnData as String: kCFBooleanTrue,
] as CFDictionary, &item);
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
print("OK! Read the existing key saved in the Keychain.");
print("OK! Read the existing key saved in the Keychain.")
return keys[64...]
}
else if res == errSecItemNotFound {
return nil;
}
else if res == errSecAuthFailed {
print("\nERROR! Access denied. Can't check existing keys in the keychain.");
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
}
else if res == errSecUserCanceled {
print("\nABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
} else if res == errSecItemNotFound {
return nil
} else if res == errSecAuthFailed {
print("\nERROR! Access denied. Can't check existing keys in the keychain.")
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
} else if res == errSecUserCanceled {
print("\nABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.")
} else if res == errSecInteractionNotAllowed {
print("\nERROR! The operating system has blocked access to the Keychain.");
print("\nERROR! The operating system has blocked access to the Keychain.")
} else {
print("\nERROR! Unable to access existing item in the Keychain", res, "(you can look it up at osstatus.com)");
print("\nERROR! Unable to access existing item in the Keychain", res, "(you can look it up at osstatus.com)")
}
exit(1)
}
func generateKeyPair() -> Data {
var seed = Data(count: 32);
var publicEdKey = Data(count: 32);
var privateEdKey = Data(count: 64);
var seed = Data(count: 32)
var publicEdKey = Data(count: 32)
var privateEdKey = Data(count: 64)
if !seed.withUnsafeMutableBytes { (seed: UnsafeMutablePointer<UInt8>) in 0 == ed25519_create_seed(seed)} {
print("\nERROR: Unable to initialize random seed");
print("\nERROR: Unable to initialize random seed")
exit(1)
}
seed.withUnsafeBytes({(seed: UnsafePointer<UInt8>) in
publicEdKey.withUnsafeMutableBytes({(publicEdKey: UnsafeMutablePointer<UInt8>) in
privateEdKey.withUnsafeMutableBytes({(privateEdKey: UnsafeMutablePointer<UInt8>) in
ed25519_create_keypair(publicEdKey, privateEdKey, seed);
});
});
});
ed25519_create_keypair(publicEdKey, privateEdKey, seed)
})
})
})
let bothKeys = privateEdKey + publicEdKey; // public key can't be derived from the private one
let query = [
@@ -71,24 +68,23 @@ func generateKeyPair() -> Data {
kSecAttrLabel as String: "Private key for signing Sparkle updates",
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(publicEdKey.base64EncodedString())",
kSecAttrDescription as String: "private key",
] as CFDictionary;
let res = SecItemAdd(query, nil);
] as CFDictionary
let res = SecItemAdd(query, nil)
if res == errSecSuccess {
print("OK! A new key has been generated and saved in the Keychain.");
}
else if res == errSecDuplicateItem {
print("\nERROR: You already have a previously generated key in the Keychain");
print("OK! A new key has been generated and saved in the Keychain.")
} else if res == errSecDuplicateItem {
print("\nERROR: You already have a previously generated key in the Keychain")
} else if res == errSecAuthFailed {
print("\nERROR: System denied access to the Keychain. Unable to save the new key");
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
print("\nERROR: System denied access to the Keychain. Unable to save the new key")
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
} else {
print("\nERROR: The key could not be saved to the Keychain. error: \(res) (you can look it up at osstatus.com)");
print("\nERROR: The key could not be saved to the Keychain. error: \(res) (you can look it up at osstatus.com)")
}
exit(1);
exit(1)
}
print("This tool uses macOS Keychain to store the Sparkle private key.")
print("If the Keychain prompts you for permission, please allow it.")
let pubKey = findPublicKey() ?? generateKeyPair();
let pubKey = findPublicKey() ?? generateKeyPair()
print("\nIn your app's Info.plist set SUPublicEDKey to:\n\(pubKey.base64EncodedString())\n")
+22 -25
View File
@@ -18,30 +18,27 @@ func parseKeysFromString(_ string: String) -> (Data, Data) {
return (keys[0..<64], keys[64...])
}
func findKeys() -> (Data, Data) {
var item: CFTypeRef?;
var item: CFTypeRef?
let res = SecItemCopyMatching([
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: "https://sparkle-project.org",
kSecAttrAccount as String: "ed25519",
kSecAttrProtocol as String: kSecAttrProtocolSSH,
kSecReturnData as String: kCFBooleanTrue,
] as CFDictionary, &item);
] as CFDictionary, &item)
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
return (keys[0..<64], keys[64..<(64+32)])
}
else if res == errSecItemNotFound {
print("ERROR! Signing key not found. Please run generate_keys tool first.");
}
else if res == errSecAuthFailed {
print("ERROR! Access denied. Can't get keys from the keychain.");
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
}
else if res == errSecUserCanceled {
print("ABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
} else if res == errSecItemNotFound {
print("ERROR! Signing key not found. Please run generate_keys tool first.")
} else if res == errSecAuthFailed {
print("ERROR! Access denied. Can't get keys from the keychain.")
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.")
} else if res == errSecUserCanceled {
print("ABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.")
} else if res == errSecInteractionNotAllowed {
print("ERROR! The operating system has blocked access to the Keychain.");
print("ERROR! The operating system has blocked access to the Keychain.")
} else {
print("ERROR! Unable to access required key in the Keychain", res, "(you can look it up at osstatus.com)");
print("ERROR! Unable to access required key in the Keychain", res, "(you can look it up at osstatus.com)")
}
exit(1)
}
@@ -49,24 +46,24 @@ func findKeys() -> (Data, Data) {
func edSignature(data: Data, publicEdKey: Data, privateEdKey: Data) -> String {
assert(publicEdKey.count == 32)
assert(privateEdKey.count == 64)
let len = data.count;
var output = Data(count: 64);
let len = data.count
var output = Data(count: 64)
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
});
});
})
})
})
});
return output.base64EncodedString();
})
return output.base64EncodedString()
}
let args = CommandLine.arguments;
let args = CommandLine.arguments
if args.count != 2 && !(args.count == 4 && args[1] == "-s") {
print("Usage: \n")
print("\t1. \(args[0]) <archive to sign>\n\tPrivate EdDSA (ed25519) key is automatically read from the Keychain.\n");
print("\t1. \(args[0]) <archive to sign>\n\tPrivate EdDSA (ed25519) key is automatically read from the Keychain.\n")
print("\t2 \(args[0]) -s <key> <archive to sign>\n\tThe key's length is 128 that includes private and public key.\n")
exit(1)
}
@@ -74,9 +71,9 @@ let (priv, pub) = args.count == 2 ? findKeys() : parseKeysFromString(args[2])
let filePath = args.count == 2 ? args[1] : args[3]
do {
let data = try Data.init(contentsOf: URL.init(fileURLWithPath: filePath), options: .mappedIfSafe);
let sig = edSignature(data:data , publicEdKey: pub, privateEdKey: priv);
print("sparkle:edSignature=\"\(sig)\" length=\"\(data.count)\"");
let data = try Data.init(contentsOf: URL.init(fileURLWithPath: filePath), options: .mappedIfSafe)
let sig = edSignature(data: data, publicEdKey: pub, privateEdKey: priv)
print("sparkle:edSignature=\"\(sig)\" length=\"\(data.count)\"")
} catch {
print("ERROR: ", error)
}