mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-23 04:34:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d01298c9ce | ||
|
|
a242035c74 | ||
|
|
8f19f6a8cc | ||
|
|
9568732f78 | ||
|
|
f49295b054 | ||
|
|
aff67ceda8 | ||
|
|
c8d5d18ce0 | ||
|
|
f1167b3649 | ||
|
|
3077864a3e | ||
|
|
2db0d8cb37 | ||
|
|
0d16b459a5 | ||
|
|
4c3e202d2e | ||
|
|
96d162c7e5 | ||
|
|
01b48d44e8 | ||
|
|
c39f7df513 | ||
|
|
ec15362770 |
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ if [ "$ACTION" = "" ] ; then
|
||||
fi
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
|
||||
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
|
||||
|
||||
mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$SRCROOT/CHANGELOG" "$SRCROOT/LICENSE" "$SRCROOT/Resources/SampleAppcast.xml" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
@@ -37,6 +37,6 @@ if [ "$ACTION" = "" ] ; then
|
||||
|
||||
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"
|
||||
fi
|
||||
@@ -14,7 +14,7 @@ localizable-strings:
|
||||
|
||||
release:
|
||||
xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2
|
||||
open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.xz
|
||||
cat Sparkle.podspec
|
||||
@echo "Don't forget to update CocoaPods! pod trunk push"
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
@@ -26,7 +26,7 @@ The upcoming Sparkle 2 (currently in beta) can be found in the [2.x branch](http
|
||||
* Runtime: macOS 10.7 or greater
|
||||
* Build: Xcode 9 and 10.11 SDK or greater
|
||||
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
|
||||
* No sandboxing. Sparkle 1.x can't update sandboxed apps. [Sparkle 2.x](https://github.com/sparkle-project/Sparkle/tree/2.x) can.
|
||||
* 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
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.22.0"
|
||||
s.version = "1.23.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"
|
||||
|
||||
@@ -276,6 +276,7 @@
|
||||
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
|
||||
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
|
||||
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 */; };
|
||||
@@ -948,6 +949,7 @@
|
||||
8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
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 +1326,7 @@
|
||||
5AA96C571E0AE0DB00CA4346 /* main.swift */,
|
||||
5AE13F771E0C9B12000D2C2C /* Signatures.swift */,
|
||||
5A5AC5351E0C6CA300998119 /* Unarchive.swift */,
|
||||
B2D3F864245CEA24009BA78C /* URL+Hashing.swift */,
|
||||
);
|
||||
path = generate_appcast;
|
||||
sourceTree = "<group>";
|
||||
@@ -2275,6 +2278,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 */,
|
||||
|
||||
Vendored
+3
-2
@@ -352,7 +352,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 = [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || isAboutBlank;
|
||||
|
||||
// Do not allow redirects to dangerous protocols such as file://
|
||||
if (!whitelistedSafe) {
|
||||
@@ -362,7 +363,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
}
|
||||
|
||||
if (self.webViewFinishedLoading) {
|
||||
if (requestURL) {
|
||||
if (requestURL && !isAboutBlank) {
|
||||
[[NSWorkspace sharedWorkspace] openURL:requestURL];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -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"/>
|
||||
|
||||
@@ -46,6 +46,7 @@ class ArchiveItem: CustomStringConvertible {
|
||||
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
var downloadUrlPrefix: URL?;
|
||||
|
||||
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
|
||||
self.version = version;
|
||||
@@ -125,8 +126,11 @@ class ArchiveItem: CustomStringConvertible {
|
||||
guard let escapedFilename = self.archivePath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
|
||||
let _ = 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()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,7 +58,13 @@ func unarchiveUpdates(archivesSourceDir: URL, archivesDestDir: URL, verbose: Boo
|
||||
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 archiveDestDir: URL
|
||||
|
||||
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) {
|
||||
|
||||
+149
-54
@@ -25,6 +25,19 @@ func printUsage() {
|
||||
)
|
||||
}
|
||||
|
||||
func printHelp() {
|
||||
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent;
|
||||
print(
|
||||
"Usage: \(command) [OPTIONS] [ARCHIVES_FOLDER]\n",
|
||||
"Options:\n",
|
||||
"\t-f: provide the path to the private DSA key\n",
|
||||
"\t-n: provide the name of the private DSA key. This option has to be used together with `-k`\n",
|
||||
"\t-k: provide the name of the keychain. This option has to be used together with `-n`\n",
|
||||
"\t-s: provide the path to the private EdDSA key\n",
|
||||
"\t--download-url-prefix: provide a static url that will be used as prefix for the url from where updates will be downloaded\n"
|
||||
)
|
||||
}
|
||||
|
||||
func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> PrivateKeys {
|
||||
var privateEdKey: Data?;
|
||||
var publicEdKey: Data?;
|
||||
@@ -62,6 +75,129 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses all possible command line options and returns the values in a tuple.
|
||||
*/
|
||||
func parseCommandLineOptions(argumentList: [String]) -> (privateDSAKey: SecKey?, privateEdString: String?, downloadUrlPrefix: URL?, archivesSourceDir: URL) {
|
||||
// if the option `-h` is in the argument list print the help dialog
|
||||
if argumentList.contains("-h") {
|
||||
printHelp()
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// make a mutable copy of the argument list
|
||||
var arguments = argumentList
|
||||
// remove the first element since this is the path to executable which we don't need
|
||||
arguments.removeFirst()
|
||||
|
||||
// define the variables for the possible argument values
|
||||
var privateDSAKey: SecKey? = nil
|
||||
var privateEdString: String? = nil
|
||||
var downloadUrlPrefix: URL? = nil
|
||||
var archivesSourceDir: URL
|
||||
|
||||
// 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)
|
||||
} 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 {
|
||||
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
|
||||
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
|
||||
downloadUrlPrefix = URL(string: arguments[downloadUrlPrefixOptionIndex + 1])
|
||||
|
||||
// remove the parsed argument
|
||||
arguments.remove(at: downloadUrlPrefixOptionIndex + 1)
|
||||
arguments.remove(at: downloadUrlPrefixOptionIndex)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
privateDSAKey = try loadPrivateDSAKey(at: privateKeyUrl)
|
||||
} catch {
|
||||
print("Unable to load DSA private key from", privateKeyUrl.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// remove the parsed path to the DSA key
|
||||
arguments.removeFirst()
|
||||
}
|
||||
|
||||
// now only the archives source dir is left
|
||||
archivesSourceDir = URL(fileURLWithPath: arguments[0], isDirectory: true)
|
||||
|
||||
return (privateDSAKey, privateEdString, downloadUrlPrefix, archivesSourceDir)
|
||||
}
|
||||
|
||||
func main() {
|
||||
let args = CommandLine.arguments;
|
||||
if args.count < 2 {
|
||||
@@ -71,66 +207,25 @@ func main() {
|
||||
|
||||
var privateDSAKey: SecKey? = nil;
|
||||
var privateEdString: String? = nil;
|
||||
|
||||
// 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])
|
||||
|
||||
do {
|
||||
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)
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
var downloadUrlPrefix: URL? = nil;
|
||||
var archivesSourceDir: URL
|
||||
|
||||
(privateDSAKey, privateEdString, downloadUrlPrefix, archivesSourceDir) = parseCommandLineOptions(argumentList: args)
|
||||
|
||||
let archivesSourceDir = URL(fileURLWithPath: args.last!, isDirectory: true)
|
||||
let keys = loadPrivateKeys(privateDSAKey, privateEdString)
|
||||
|
||||
do {
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose:verbose);
|
||||
|
||||
// if a download url prefix was provided set it for each archive item
|
||||
if downloadUrlPrefix != nil {
|
||||
for (_, archiveItems) in allUpdates {
|
||||
for archiveItem in archiveItems {
|
||||
archiveItem.downloadUrlPrefix = downloadUrlPrefix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
|
||||
try writeAppcast(appcastDestPath:appcastDestPath, updates:updates);
|
||||
|
||||
Reference in new issue
Block a user